/*
 * Design System - AELITA
 * components/tradein-page.css - "Викуп автомобіля та Trade-In" page
 * (page-vikup-avtomobilya.php).
 *
 * Composition follows the Stitch screens "Викуп автомобіля та Trade-In
 * (Desktop)" and "tradein mob":
 *
 *   desktop: split hero (H1 + summary + photo + 4 benefits | dark lead form),
 *            4-step process row, dark contact band;
 *   mobile:  H1 + summary + dealership photo + benefits, process, form,
 *            contact band.
 *
 * The mobile order is created with `display: contents` on the hero wrappers
 * and `order` on the direct children of <main>; there is only one form in
 * the DOM. On desktop the wrappers become a normal 7/5 grid again.
 *
 * Scoped under .a-tradein. Consumes tokens.css + layout.css + button.css.
 * No raw brand hex, no `transition: all`, hover effects gated behind
 * (hover: hover) and (pointer: fine).
 *
 * Loaded only on the buyout page (see inc/enqueue.php).
 */

/* This page only (the stylesheet is enqueued on this template only): the
 * legacy body has min-width: 320px, which creates a 15px horizontal scroll at
 * a 320px viewport once the scrollbar is counted. The page-id selector
 * outranks the legacy `body` rule even though the design-system styles print
 * before the theme styles. */
body.page-id-40223 {
	min-width: 0;
}

/* -------------------------------------------------------------------- */
/* Page shell                                                           */
/* -------------------------------------------------------------------- */
.a-tradein {
	--tradein-h1: clamp(26px, 3vw, 32px);
	--tradein-h2: clamp(23px, 2.6vw, 30px);

	display: flex;
	flex-direction: column;
	color: var(--text-primary);
	font-family: var(--font-body);
	font-size: var(--fs-body);
	line-height: var(--lh-body);
	background-color: var(--bg);
	overflow-x: clip;
}

/* Mobile: the hero wrappers disappear from the box tree, so the intro, the
 * form, the process and the contact band all become direct flex children of
 * <main> and can be ordered like the Stitch mobile screen. */
.a-tradein__hero,
.a-tradein__hero-grid {
	display: contents;
}

.a-tradein__intro {
	order: 1;
	min-width: 0;
	padding: var(--space-4) var(--space-5) 0;
}

.a-tradein__process {
	order: 2;
}

.a-tradein__form-card {
	order: 3;
	margin: 0 var(--space-5);
}

.a-tradein__contact {
	order: 4;
}

/* -------------------------------------------------------------------- */
/* Hero - copy                                                          */
/* -------------------------------------------------------------------- */
.a-tradein__eyebrow {
	display: inline-flex;
	align-items: center;
	gap: var(--space-2);
	margin: 0 0 var(--space-3);
	font-family: var(--font-body);
	font-size: var(--fs-caption);
	font-weight: var(--fw-semibold);
	line-height: 1.2;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	color: var(--text-secondary);
}

.a-tradein__eyebrow::before {
	content: "";
	display: block;
	flex: 0 0 auto;
	width: 10px;
	height: 10px;
	background-color: var(--c-red-600);
}

.a-tradein__title {
	margin: 0;
	font-family: var(--font-display-strong);
	font-size: var(--tradein-h1);
	font-weight: var(--fw-bold);
	line-height: 1.2;
	letter-spacing: 0;
	text-transform: uppercase;
	text-wrap: balance;
	color: var(--c-ink-900);
}

.a-tradein__lead {
	max-width: 58ch;
	margin: var(--space-3) 0 0;
	font-size: var(--fs-body);
	line-height: 1.65;
	color: var(--text-secondary);
}

/* Catalog links under the hero lead: one compact inline row, not a new
 * section. Kept on the existing text scale so the approved hero composition
 * does not change. */
.a-tradein__catalog-links {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0 var(--space-2);
	margin: var(--space-2) 0 0;
	font-size: var(--fs-small);
	line-height: 1.5;
	color: var(--text-secondary);
}

.a-tradein__catalog-links a {
	color: var(--c-ink-900);
	font-weight: var(--fw-semibold);
	text-decoration: underline;
	text-decoration-thickness: 1px;
	text-underline-offset: 2px;
	white-space: nowrap;
}

@media (hover: hover) and (pointer: fine) {
	.a-tradein__catalog-links a:hover {
		color: var(--c-red-600);
	}
}

/* Mobile hero photo: a real AELITA dealership photo, not the old banner with
 * baked-in copy. On desktop it sits in the hero left column at its native
 * wide ratio, which keeps the column balanced with the form. */
.a-tradein__hero-media {
	margin: var(--space-4) 0 0;
	aspect-ratio: 2 / 1;
	overflow: hidden;
	background-color: var(--bg-muted);
}

/* The WebP <source> lives inside <picture>, so the wrapper must occupy the
 * same box as the image and keep the existing object-fit behaviour. */
.a-tradein__hero-media picture {
	display: block;
	width: 100%;
	height: 100%;
}

.a-tradein__hero-media img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
	object-position: center;
}

/* -------------------------------------------------------------------- */
/* Benefits - mobile: compact Stitch list with a left accent bar         */
/* -------------------------------------------------------------------- */
.a-tradein__benefits {
	display: grid;
	grid-template-columns: minmax(0, 1fr);
	gap: var(--space-2);
	margin: var(--space-4) 0 0;
	padding: 0;
	list-style: none;
}

.a-tradein__benefit {
	display: flex;
	align-items: center;
	gap: var(--space-3);
	min-height: 56px;
	padding: var(--space-3);
	border-left: 3px solid var(--c-red-600);
	background-color: var(--bg-muted);
}

.a-tradein__benefit-icon {
	flex: 0 0 auto;
	width: 20px;
	color: var(--c-red-600);
	font-size: 18px;
	line-height: 1;
	text-align: center;
}

.a-tradein__benefit-title {
	margin: 0;
	font-family: var(--font-display);
	font-size: 13px;
	font-weight: var(--fw-bold);
	line-height: 1.3;
	letter-spacing: 0.02em;
	text-transform: uppercase;
	color: var(--c-ink-900);
}

/* -------------------------------------------------------------------- */
/* Lead form (existing ids / endpoint / messages)                       */
/* -------------------------------------------------------------------- */
.a-tradein__form-card {
	padding: var(--space-4);
	background-color: var(--c-ink-900);
	color: var(--c-white);
}

.a-tradein__form-head {
	display: flex;
	align-items: flex-start;
	justify-content: space-between;
	gap: var(--space-3);
	padding-bottom: var(--space-3);
	border-bottom: 1px solid rgba(255, 255, 255, 0.14);
}

.a-tradein__form-eyebrow {
	margin: 0 0 var(--space-1);
	font-size: 10px;
	font-weight: var(--fw-semibold);
	line-height: 1.2;
	letter-spacing: 0.1em;
	text-transform: uppercase;
	color: var(--c-ink-300);
}

.a-tradein__form-title {
	margin: 0;
	font-family: var(--font-display-strong);
	font-size: var(--fs-h3);
	font-weight: var(--fw-bold);
	line-height: var(--lh-heading);
	text-transform: uppercase;
	color: var(--c-white);
}

.a-tradein__form-sub {
	margin: var(--space-1) 0 0;
	font-size: var(--fs-small);
	line-height: var(--lh-body);
	color: var(--c-ink-300);
}

.a-tradein__form-shield {
	flex: 0 0 auto;
	margin-top: var(--space-1);
	color: var(--c-red-500);
	font-size: 26px;
	line-height: 1;
}

.a-tradein__form {
	display: grid;
	gap: var(--space-2);
	margin-top: var(--space-3);
}

.a-tradein__form-body {
	display: grid;
	gap: var(--space-2);
}

.a-tradein__form-fields,
.a-tradein__form-actions {
	display: grid;
	gap: var(--space-2);
}

/* The `hidden` attribute must win over the display: grid above. */
.a-tradein__form-fields[hidden],
.a-tradein__form-actions[hidden] {
	display: none;
}

.a-tradein__field {
	display: grid;
	gap: var(--space-1);
	min-width: 0;
}

.a-tradein__field-row {
	display: grid;
	grid-template-columns: minmax(0, 1fr);
	gap: var(--space-2);
}

.a-tradein__label {
	margin: 0;
	font-size: 11px;
	font-weight: var(--fw-semibold);
	line-height: 1.4;
	letter-spacing: 0.06em;
	text-transform: uppercase;
	color: var(--c-ink-300);
}

.a-tradein__req {
	color: var(--c-red-500);
}

.a-tradein__input {
	width: 100%;
	min-height: calc(var(--space-6) + var(--space-3)); /* 44px touch target */
	padding: var(--space-3) var(--space-4);
	border: var(--border-w) solid rgba(255, 255, 255, 0.16);
	border-radius: var(--radius);
	background-color: rgba(255, 255, 255, 0.05);
	color: var(--c-white);
	font-family: var(--font-body);
	font-size: var(--fs-body);
	line-height: 1.3;
	-webkit-appearance: none;
	appearance: none;
	transition: border-color var(--dur-press) var(--ease-out);
}

.a-tradein__input::placeholder,
.a-tradein .a-tradein__input::placeholder {
	color: var(--c-ink-300);
	opacity: 1;
}

/* Chrome autofill turns dark inputs light; keep the dark surface + white text. */
.a-tradein__input:-webkit-autofill,
.a-tradein__input:-webkit-autofill:hover,
.a-tradein__input:-webkit-autofill:focus {
	-webkit-text-fill-color: var(--c-white);
	box-shadow: 0 0 0 1000px var(--c-ink-800) inset;
	transition: background-color 5000s ease-in-out 0s;
}

.a-tradein__input:focus {
	border-color: var(--c-red-500);
}

.a-tradein__input[aria-invalid="true"] {
	border-color: var(--c-red-500);
}

.a-tradein__submit {
	width: 100%;
	min-height: calc(var(--space-6) + var(--space-4)); /* 48px */
	margin-top: var(--space-1);
	padding-inline: var(--space-4);
	font-size: var(--fs-small);
	letter-spacing: 0.04em;
	text-transform: uppercase;
}

.a-tradein__submit-arrow {
	font-size: 1.1em;
	line-height: 1;
}

/* The legacy theme sets `*:focus { outline: none !important; }`; keep a
 * visible ring on this page's controls. */
.a-tradein .a-button:focus-visible,
.a-tradein a:focus-visible,
.a-tradein__input:focus-visible {
	outline: 2px solid var(--focus-ring) !important;
	outline-offset: 2px;
}

.a-tradein__consent {
	margin: 0;
	font-size: 12px;
	line-height: 1.5;
	color: var(--c-ink-100);
}

.a-tradein__consent a {
	color: var(--c-white);
	text-decoration: underline;
	text-underline-offset: 2px;
}

@media (hover: hover) and (pointer: fine) {
	.a-tradein__consent a:hover {
		color: var(--c-red-500);
	}
}

/* AJAX status containers (same ids as the legacy form). */
.a-tradein__form-status {
	font-size: var(--fs-small);
	line-height: var(--lh-body);
	color: var(--c-white);
}

.a-tradein__form-status:empty {
	display: none;
}

.a-tradein__form-status--error {
	padding: var(--space-3) var(--space-4);
	border: var(--border-w) solid var(--c-red-500);
	background-color: rgba(255, 255, 255, 0.04);
}

/* The endpoint wraps its error in <i style="color:red">. Normalise it to the
 * accessible white-on-ink treatment; the red border carries the severity. */
.a-tradein__form-status--error i {
	color: var(--c-white) !important;
	font-style: normal;
	font-weight: var(--fw-semibold);
}

.a-tradein__form-status .feedback-form__text {
	font-size: var(--fs-small);
	line-height: var(--lh-body);
}

.a-tradein__form-status img {
	display: block;
	width: 48px;
	height: 48px;
	margin: 0 auto var(--space-3);
}

/* -------------------------------------------------------------------- */
/* Process                                                              */
/* -------------------------------------------------------------------- */
.a-tradein__process {
	padding-block: var(--space-6);
	background-color: var(--bg-muted);
}

.a-tradein__section-head {
	display: flex;
	flex-direction: column;
	gap: var(--space-3);
	margin-bottom: var(--space-5);
}

.a-tradein__section-eyebrow {
	margin: 0 0 var(--space-1);
	font-size: var(--fs-caption);
	font-weight: var(--fw-bold);
	line-height: 1.2;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	color: var(--c-red-600);
}

.a-tradein__section-title {
	margin: 0;
	font-family: var(--font-display-strong);
	font-size: var(--tradein-h2);
	font-weight: var(--fw-bold);
	line-height: var(--lh-heading);
	text-transform: uppercase;
	color: var(--c-ink-900);
}

.a-tradein__section-meta {
	margin: 0;
	font-size: var(--fs-small);
	line-height: var(--lh-body);
	color: var(--text-secondary);
}

.a-tradein__section-meta a {
	font-weight: var(--fw-semibold);
	color: var(--c-ink-900);
	text-decoration: none;
	white-space: nowrap;
}

@media (hover: hover) and (pointer: fine) {
	.a-tradein__section-meta a:hover {
		color: var(--c-red-600);
	}
}

.a-tradein__steps {
	display: grid;
	grid-template-columns: minmax(0, 1fr);
	gap: var(--space-2);
	margin: 0;
	padding: 0;
	list-style: none;
}

.a-tradein__step {
	display: flex;
	flex-direction: column;
	gap: var(--space-2);
	min-height: 100%;
	padding: var(--space-3);
	border: var(--border-w) solid var(--border);
	background-color: var(--bg);
}

.a-tradein__step-head {
	display: flex;
	align-items: flex-start;
	justify-content: space-between;
	gap: var(--space-3);
}

.a-tradein__step-num {
	display: block;
	font-family: var(--font-display-strong);
	font-size: 24px;
	font-weight: var(--fw-bold);
	line-height: 1;
	letter-spacing: -0.02em;
	color: var(--c-red-600);
}

.a-tradein__step-icon {
	flex: 0 0 auto;
	margin-top: var(--space-1);
	color: var(--c-ink-900);
	font-size: 18px;
	line-height: 1;
}

.a-tradein__step-title {
	margin: 0;
	font-family: var(--font-display);
	font-size: 13px;
	font-weight: var(--fw-bold);
	line-height: 1.3;
	letter-spacing: 0.02em;
	text-transform: uppercase;
	color: var(--c-ink-900);
}

.a-tradein__step-text {
	margin: 0;
	font-size: var(--fs-small);
	line-height: 1.55;
	color: var(--text-secondary);
}

/* -------------------------------------------------------------------- */
/* Contact band                                                         */
/* -------------------------------------------------------------------- */
.a-tradein__contact {
	padding-block: var(--space-6);
	background-color: var(--bg);
}

.a-tradein__contact-card {
	display: grid;
	grid-template-columns: minmax(0, 1fr);
	overflow: hidden;
	background-color: var(--c-ink-900);
}

.a-tradein__contact-body {
	padding: var(--space-4);
	color: var(--c-white);
}

.a-tradein__contact-actions {
	padding: 0 var(--space-4) var(--space-4);
}

.a-tradein__contact-eyebrow {
	margin: 0 0 var(--space-2);
	font-size: 10px;
	font-weight: var(--fw-bold);
	line-height: 1.2;
	letter-spacing: 0.1em;
	text-transform: uppercase;
	color: var(--c-red-500);
}

.a-tradein__contact-title {
	margin: 0;
	font-family: var(--font-display-strong);
	font-size: var(--tradein-h2);
	font-weight: var(--fw-bold);
	line-height: var(--lh-heading);
	text-transform: uppercase;
	color: var(--c-white);
}

.a-tradein__contact-text {
	margin: var(--space-2) 0 0;
	font-size: var(--fs-small);
	line-height: var(--lh-body);
	color: var(--c-ink-300);
}

/* -------------------------------------------------------------------- */
/* Tablet benefits (2 columns, still the compact mobile cards)          */
/* -------------------------------------------------------------------- */
@media (min-width: 576px) {
	.a-tradein__benefits {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}

	.a-tradein__field-row {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}
}

@media (min-width: 768px) and (max-width: 1199px) {
	.a-tradein__steps {
		grid-template-columns: repeat(2, minmax(0, 1fr));
		gap: var(--space-3);
	}
}

/* -------------------------------------------------------------------- */
/* Desktop                                                              */
/* -------------------------------------------------------------------- */
@media (min-width: 992px) {
	.a-tradein {
		display: block;
	}

	.a-tradein__hero {
		display: block;
		padding-block: var(--space-6) var(--space-7);
	}

	.a-tradein__hero-grid {
		display: grid;
		grid-template-columns: minmax(0, 7fr) minmax(360px, 5fr);
		gap: var(--space-6);
		align-items: start;
	}

	.a-tradein__intro {
		order: initial;
		padding: 0;
	}

	.a-tradein__hero-media {
		aspect-ratio: 1920 / 532;
	}

	.a-tradein__lead {
		font-size: 16px;
	}

	/* Desktop benefits: a hairline 2x2 matrix instead of four grey boxes. */
	.a-tradein__benefits {
		grid-template-columns: repeat(2, minmax(0, 1fr));
		gap: 0;
		margin-top: var(--space-5);
	}

	.a-tradein__benefit {
		min-height: 0;
		padding: var(--space-5) var(--space-5) var(--space-5) 0;
		border-left: 0;
		border-top: 1px solid var(--border);
		background-color: transparent;
	}

	.a-tradein__benefit:nth-child(odd) {
		border-right: 1px solid var(--border);
	}

	.a-tradein__benefit:nth-child(even) {
		padding-left: var(--space-5);
	}

	.a-tradein__benefit-icon {
		width: 22px;
		font-size: 20px;
	}

	.a-tradein__benefit-title {
		font-size: 14px;
	}

	.a-tradein__form-card {
		order: initial;
		margin: 0;
		padding: var(--space-5);
	}

	.a-tradein__form-head {
		gap: var(--space-4);
		padding-bottom: var(--space-4);
	}

	.a-tradein__form {
		gap: var(--space-3);
		margin-top: var(--space-4);
	}

	.a-tradein__form-body,
	.a-tradein__form-fields,
	.a-tradein__form-actions {
		gap: var(--space-3);
	}

	.a-tradein__field-row {
		gap: var(--space-3);
	}

	.a-tradein__process {
		padding-block: var(--space-8);
	}

	.a-tradein__contact {
		padding-block: var(--space-5);
		border-top: 1px solid var(--border);
		background-color: var(--bg-muted);
	}

	.a-tradein__section-head {
		flex-direction: row;
		align-items: flex-end;
		justify-content: space-between;
	}

	/* The contact strip carries the phone on desktop; the process header
	 * keeps only the eyebrow + H2 there. */
	.a-tradein__section-meta {
		display: none;
	}

	.a-tradein__steps {
		grid-template-columns: repeat(2, minmax(0, 1fr));
		gap: var(--space-4);
	}

	.a-tradein__step {
		padding: var(--space-5);
	}

	.a-tradein__step-num {
		font-size: var(--fs-display);
	}

	.a-tradein__step-icon {
		font-size: 20px;
	}

	.a-tradein__step-title {
		font-size: var(--fs-small);
	}

	/* Desktop contact: the closing CTA of the muted process zone. Light,
	 * inline and compact — no dark plate, no banner, one red primary button. */
	.a-tradein__contact-card {
		grid-template-columns: minmax(0, 1fr) auto;
		align-items: center;
		gap: var(--space-6);
		background-color: transparent;
		overflow: visible;
	}

	.a-tradein__contact-body {
		padding: 0;
		color: var(--c-ink-900);
	}

	.a-tradein__contact-title {
		color: var(--c-ink-900);
	}

	.a-tradein__contact-text {
		max-width: 52ch;
		color: var(--text-secondary);
	}

	.a-tradein__contact-actions {
		display: flex;
		align-items: center;
		justify-content: flex-end;
		padding: 0;
	}

	.a-tradein__contact-phone {
		min-height: calc(var(--space-6) + var(--space-4)); /* 48px */
	}
}

@media (min-width: 1200px) {
	.a-tradein__steps {
		grid-template-columns: repeat(4, minmax(0, 1fr));
	}
}

/* -------------------------------------------------------------------- */
/* Mobile rhythm and order (below the tablet breakpoint)                */
/* -------------------------------------------------------------------- */
@media (max-width: 767px) {
	/* White breathing room between the visually last block (the form) and the
	 * dark footer; the form is ordered last in this range. */
	.a-tradein {
		padding-bottom: var(--space-7);
	}

	/* More air between the benefits and the muted process section. */
	.a-tradein__intro {
		padding-bottom: var(--space-5);
	}

	.a-tradein__process {
		padding-top: var(--space-6);
		padding-bottom: var(--space-7);
	}

	/* Eyebrow -> H2 -> phone -> first card. */
	.a-tradein__section-head {
		gap: var(--space-3);
		margin-bottom: var(--space-6);
	}

	.a-tradein__section-eyebrow {
		margin-bottom: var(--space-3);
	}

	/* Even, comfortable gaps between the four step cards. */
	.a-tradein__steps {
		gap: var(--space-4);
	}

	/* Stitch mobile order: contact CTA right after the process, before the form. */
	.a-tradein__contact {
		order: 3;
	}

	.a-tradein__form-card {
		order: 4;
		margin-top: var(--space-5);
	}
}

/* -------------------------------------------------------------------- */
/* Reduced motion                                                       */
/* -------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
	.a-tradein__input {
		transition: none;
	}
}
