/**
 * Autoteippaus-leads front end styles.
 * Mobile-first, plain CSS with custom properties so the host theme can
 * override the look via --atl-* variables declared on .atl-widget.
 */

.atl-widget {
	--atl-color-accent: var(--awb-color4, #ffec4f);
	--atl-color-accent-contrast: #1a1414;
	--atl-color-bg: #ffffff;
	--atl-color-bg-alt: #f4f2f1;
	--atl-color-text: #1a1414;
	--atl-color-text-muted: #5c5252;
	--atl-color-border: #d9d3d1;
	--atl-color-error: #b3261e;
	--atl-color-error-bg: #fbeceb;
	--atl-radius: 14px;
	--atl-gap: 12px;
	--atl-font: inherit;

	box-sizing: border-box;
	max-width: 640px;
	width: 100%;
	margin: 0 auto;
	font-family: var(--atl-font);
	color: var(--atl-color-text);
	background: var(--atl-color-bg);
	border-radius: var(--atl-radius);
	overflow: hidden;
}

.atl-widget *,
.atl-widget *::before,
.atl-widget *::after {
	box-sizing: border-box;
}

.atl-widget .atl-inner {
	display: flex;
	flex-direction: column;
	gap: var(--atl-gap);
	padding: 16px;
	min-width: 0;
}

.atl-widget button,
.atl-widget input,
.atl-widget textarea,
.atl-widget select {
	font-family: inherit;
	font-size: 16px;
}

.atl-widget :focus-visible {
	/* The accent is a light brand yellow, too low-contrast on its own for a
	   WCAG-compliant focus indicator on a white background — pair it with a
	   dark hairline so the ring stays visible regardless of surrounding color. */
	outline: 3px solid var(--atl-color-accent);
	outline-offset: 2px;
	box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.45);
}

/* ------------------------------------------------------------------ */
/* Buttons                                                              */
/* ------------------------------------------------------------------ */

.atl-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-height: 48px;
	min-width: 48px;
	padding: 10px 20px;
	border-radius: calc(var(--atl-radius) * 0.6);
	border: 2px solid transparent;
	font-weight: 600;
	cursor: pointer;
	background: var(--atl-color-bg-alt);
	color: var(--atl-color-text);
}

.atl-btn--primary {
	background: var(--atl-color-accent);
	color: var(--atl-color-accent-contrast);
}

.atl-btn--ghost {
	background: transparent;
	border-color: var(--atl-color-border);
}

.atl-btn--secondary {
	background: var(--atl-color-bg-alt);
	border-color: var(--atl-color-border);
}

.atl-btn:disabled {
	opacity: 0.45;
	cursor: not-allowed;
}

/* ------------------------------------------------------------------ */
/* Shared: inputs, fieldsets, consents, badges, errors                  */
/* ------------------------------------------------------------------ */

.atl-field {
	display: flex;
	flex-direction: column;
	gap: 6px;
	margin-bottom: var(--atl-gap);
}

.atl-field label {
	font-weight: 600;
	font-size: 0.95em;
}

.atl-input {
	min-height: 48px;
	padding: 10px 14px;
	border: 2px solid var(--atl-color-border);
	border-radius: calc(var(--atl-radius) * 0.5);
	background: var(--atl-color-bg);
	color: var(--atl-color-text);
	width: 100%;
}

textarea.atl-input {
	min-height: 88px;
	resize: vertical;
}

.atl-fieldset {
	border: 0;
	padding: 0;
	margin: 0;
	min-width: 0;
}

.atl-step-heading {
	font-size: 1.25rem;
	font-weight: 700;
	line-height: 1.3;
	padding: 0;
	margin: 0 0 4px;
}

.atl-consents {
	display: flex;
	flex-direction: column;
	gap: 10px;
	margin: var(--atl-gap) 0;
}

.atl-consent {
	display: flex;
	align-items: flex-start;
	gap: 10px;
	font-size: 0.95em;
	cursor: pointer;
}

.atl-consent input {
	width: 22px;
	height: 22px;
	min-width: 22px;
	margin-top: 2px;
}

.atl-consent a {
	/* Not accent-colored: the brand yellow is too light to pass text-contrast
	   requirements on this background, so links stay dark and underlined. */
	color: var(--atl-color-text);
	text-decoration-color: var(--atl-color-accent);
	text-decoration-thickness: 2px;
}

.atl-hp {
	position: absolute !important;
	width: 1px !important;
	height: 1px !important;
	padding: 0 !important;
	margin: -1px !important;
	overflow: hidden !important;
	clip: rect(0, 0, 0, 0) !important;
	white-space: nowrap !important;
	border: 0 !important;
}

.atl-error {
	background: var(--atl-color-error-bg);
	color: var(--atl-color-error);
	border-radius: calc(var(--atl-radius) * 0.5);
	padding: 10px 14px;
	font-weight: 600;
}

.atl-result {
	padding: 8px 4px;
}

.atl-result__heading {
	margin: 0 0 8px;
}

.atl-result__price {
	font-size: 1.1em;
}

.atl-result__disclaimer {
	color: var(--atl-color-text-muted);
	font-size: 0.9em;
}

/* ------------------------------------------------------------------ */
/* Option cards (stepper) / chips (chat) — shared visual language       */
/* ------------------------------------------------------------------ */

.atl-cards {
	display: grid;
	grid-template-columns: 1fr;
	gap: 10px;
}

@media (min-width: 480px) {
	.atl-cards {
		grid-template-columns: 1fr 1fr;
	}
}

.atl-card-wrap {
	position: relative;
}

.atl-card__input {
	position: absolute;
	opacity: 0;
	width: 100%;
	height: 100%;
	margin: 0;
	cursor: pointer;
}

.atl-card {
	display: flex;
	align-items: center;
	gap: 10px;
	min-height: 48px;
	padding: 12px 14px;
	border: 2px solid var(--atl-color-border);
	border-radius: calc(var(--atl-radius) * 0.6);
	cursor: pointer;
	background: var(--atl-color-bg);
}

.atl-card__input:focus-visible + .atl-card {
	outline: 3px solid var(--atl-color-accent);
	outline-offset: 2px;
}

.atl-card.is-selected {
	border-color: var(--atl-color-accent);
	background: color-mix(in srgb, var(--atl-color-accent) 8%, var(--atl-color-bg));
}

.atl-card__icon svg,
.atl-chip__icon svg {
	width: 22px;
	height: 22px;
	stroke: currentColor;
	fill: none;
	stroke-width: 1.7;
	stroke-linecap: round;
	stroke-linejoin: round;
	flex-shrink: 0;
}

.atl-card__label {
	font-weight: 600;
	line-height: 1.3;
}

.atl-chips {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
}

.atl-chip {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	min-height: 48px;
	padding: 10px 16px;
	border-radius: 999px;
	border: 2px solid var(--atl-color-border);
	background: var(--atl-color-bg);
	color: var(--atl-color-text);
	cursor: pointer;
	font-weight: 600;
}

.atl-chip:hover {
	border-color: var(--atl-color-accent);
}

/* ------------------------------------------------------------------ */
/* Stepper flow                                                         */
/* ------------------------------------------------------------------ */

.atl-stepper {
	display: flex;
	flex-direction: column;
	gap: var(--atl-gap);
}

.atl-progress__track {
	height: 8px;
	border-radius: 999px;
	background: var(--atl-color-bg-alt);
	overflow: hidden;
}

.atl-progress__fill {
	height: 100%;
	background: var(--atl-color-accent);
	transition: width 0.3s ease;
}

.atl-progress__label {
	margin: 6px 0 0;
	font-size: 0.85em;
	color: var(--atl-color-text-muted);
}

.atl-stepper__body {
	min-width: 0;
}

.atl-stepper__body.atl-anim-in {
	animation: atl-slide-in 0.25s ease;
}

.atl-contact-fields {
	margin-top: 4px;
}

.atl-nav {
	display: flex;
	justify-content: space-between;
	gap: 10px;
}

.atl-nav .atl-btn {
	flex: 1;
}

/* ------------------------------------------------------------------ */
/* Chat flow                                                            */
/* ------------------------------------------------------------------ */

.atl-chat {
	display: flex;
	flex-direction: column;
	gap: var(--atl-gap);
	min-height: 420px;
}

.atl-chat__log {
	display: flex;
	flex-direction: column;
	gap: 8px;
	max-height: 55vh;
	min-height: 200px;
	overflow-y: auto;
	padding: 4px 2px;
	scroll-behavior: smooth;
}

.atl-bubble {
	max-width: 85%;
	padding: 10px 14px;
	border-radius: calc(var(--atl-radius) * 0.7);
	line-height: 1.4;
	word-break: break-word;
}

.atl-bubble--bot {
	align-self: flex-start;
	background: var(--atl-color-bg-alt);
	border-bottom-left-radius: 4px;
}

.atl-bubble--user {
	align-self: flex-end;
	background: var(--atl-color-accent);
	color: var(--atl-color-accent-contrast);
	border-bottom-right-radius: 4px;
}

.atl-typing {
	align-self: flex-start;
	display: inline-flex;
	gap: 4px;
	padding: 12px 16px;
	border-radius: calc(var(--atl-radius) * 0.7);
	background: var(--atl-color-bg-alt);
}

.atl-typing span {
	width: 7px;
	height: 7px;
	border-radius: 50%;
	background: var(--atl-color-text-muted);
	animation: atl-bounce 1.1s infinite ease-in-out;
}

.atl-typing span:nth-child(2) {
	animation-delay: 0.15s;
}

.atl-typing span:nth-child(3) {
	animation-delay: 0.3s;
}

.atl-chat__options {
	min-width: 0;
}

.atl-chat__field-form {
	display: flex;
	gap: 8px;
	flex-wrap: wrap;
}

.atl-chat__field-form .atl-input {
	flex: 1 1 200px;
}

.atl-chat__consent-turn {
	background: var(--atl-color-bg-alt);
	border-radius: calc(var(--atl-radius) * 0.6);
	padding: 12px;
}

.atl-chat__footer {
	display: flex;
	flex-direction: column;
	gap: 8px;
}

.atl-chat__restart {
	align-self: flex-start;
}

/* ------------------------------------------------------------------ */
/* Motion                                                                */
/* ------------------------------------------------------------------ */

@keyframes atl-bounce {
	0%, 80%, 100% { transform: translateY(0); opacity: 0.5; }
	40% { transform: translateY(-4px); opacity: 1; }
}

@keyframes atl-slide-in {
	from { opacity: 0; transform: translateX(8px); }
	to { opacity: 1; transform: translateX(0); }
}

@media (prefers-reduced-motion: reduce) {
	.atl-progress__fill,
	.atl-stepper__body.atl-anim-in,
	.atl-typing span {
		animation: none !important;
		transition: none !important;
	}
}

/* ------------------------------------------------------------------ */
/* Small screens (360px baseline)                                       */
/* ------------------------------------------------------------------ */

@media (max-width: 359px) {
	.atl-widget .atl-inner {
		padding: 12px;
	}
}
