/*
 * Hero slider.
 *
 * Layout follows the reference: copy centred near the top, the product image
 * large below it, and a labelled progress navigation pinned to the bottom.
 *
 * All slides live in the DOM at once and cross-fade by toggling .is-active.
 * Slide 0 is already active in the server-rendered HTML, so the hero is never
 * blank. Inactive slides are visibility:hidden and carry `inert`, which keeps
 * their links out of the tab order.
 *
 * The progress bars are driven from JavaScript (a scaleX written each frame),
 * NOT by a CSS animation - that is what keeps them in lockstep with the slide
 * clock and lets a hover freeze them mid-fill. There is deliberately no
 * transition on .hero-nav__fill for the same reason.
 */

/*
 * The theme has no global border-box rule, so width:100% plus padding
 * overflows: the slide's inner box measured 415px inside a 375px viewport and
 * the buttons 433px, pushing them past the edge (invisible in scrollWidth
 * only because .hero clips them). Every box in this component sizes properly.
 */
.hero,
.hero *,
.hero *::before,
.hero *::after {
	box-sizing: border-box;
}

.hero {
	position: relative;
	display: flex;
	flex-direction: column;
	height: clamp(600px, 86dvh, 900px);
	overflow: hidden;
	background: radial-gradient(120% 90% at 50% 0%, #23262b 0%, #0d0f12 55%, var(--wp--preset--color--base-darker) 100%);
	color: var(--wp--preset--color--base);
}

/*
 * The slide stack covers the whole hero, navigation included, so a full-bleed
 * photograph runs to the bottom edge instead of stopping in a black band above
 * the progress bars. The navigation is the only child left in flow and pins
 * itself to the bottom, drawn above the stack.
 */
.hero__viewport {
	position: absolute;
	inset: 0;
}

/* --- Slide -------------------------------------------------------------- */

.hero-slide {
	position: absolute;
	inset: 0;
	display: flex;
	flex-direction: column;
	align-items: center;
	/* The copy sits in the middle of the slide, not parked against the top. */
	justify-content: center;
	opacity: 0;
	visibility: hidden;
	/* Delay the visibility flip until the cross-fade has finished. */
	transition:
		opacity 700ms var(--wp--custom--ease--in-out),
		visibility 0s linear 700ms;
}

.hero-slide.is-active {
	opacity: 1;
	visibility: visible;
	transition:
		opacity 700ms var(--wp--custom--ease--in-out),
		visibility 0s linear 0s;
	z-index: 1;
}

/* --- Promo background ----------------------------------------------------- */

/*
 * A slide with promo art fills itself with the photograph and drops the
 * cut-out. The scrim is what makes the copy legible over it. It holds an even
 * mid-band because the copy is centred - a scrim that thinned out through the
 * middle, which suited copy parked at the top, left the subtitle and the ghost
 * button washed out over a bright sky - and deepens at both edges, behind the
 * header above and the progress navigation below.
 */
.hero-slide__bg {
	position: absolute;
	inset: 0;
	z-index: 0;
	overflow: hidden;
}

.hero-slide__bgimg {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
	/*
	 * cover always crops. --hero-focus is the point of the photograph that must
	 * survive that crop - usually the product - and each slide sets its own,
	 * because a banner cropped from the centre can lose the very thing it is
	 * advertising.
	 */
	object-position: var(--hero-focus, 50% 50%);
}

.hero-slide__bg::after {
	content: "";
	position: absolute;
	inset: 0;
	background: linear-gradient(
		180deg,
		rgba(5, 5, 5, 0.68) 0%,
		rgba(5, 5, 5, 0.46) 22%,
		rgba(5, 5, 5, 0.44) 58%,
		rgba(5, 5, 5, 0.62) 84%,
		rgba(5, 5, 5, 0.9) 100%
	);
}

/* --- Copy ---------------------------------------------------------------- */

.hero-slide__inner {
	position: relative;
	z-index: 2;
	width: 100%;
	max-width: 1320px;
	margin-inline: auto;
	/*
	 * The slide covers the whole hero, navigation included, so the bottom
	 * padding is what lifts the centred block clear of the progress bars and
	 * leaves it optically centred in the space above them.
	 */
	padding: var(--wp--preset--spacing--5) var(--wp--preset--spacing--5) var(--wp--preset--spacing--10);
	display: flex;
	flex-direction: column;
	align-items: center;
	text-align: center;
	gap: var(--wp--preset--spacing--3);
	flex-shrink: 0;
}

.hero-slide__title {
	margin: 0;
	font-size: var(--wp--preset--font-size--display);
	font-weight: 800;
	line-height: 1.02;
	letter-spacing: -0.04em;
	color: var(--wp--preset--color--base);
	text-wrap: balance;
}

.hero-slide__text {
	margin: 0;
	max-width: 40ch;
	font-size: var(--wp--preset--font-size--xl-2);
	line-height: 1.45;
	color: rgba(255, 255, 255, 0.72);
}

/* Real WooCommerce attributes; absent for models not in the catalogue. */
.hero-slide__spec {
	margin: 0;
	font-size: var(--wp--preset--font-size--base);
	font-weight: 600;
	letter-spacing: 0.04em;
	color: rgba(255, 255, 255, 0.9);
	font-variant-numeric: tabular-nums;
}

.hero-slide__actions {
	margin: var(--wp--preset--spacing--3) 0 0;
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	gap: var(--wp--preset--spacing--3);
}

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

.hero-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-height: 52px;
	padding: 0 34px;
	border-radius: var(--wp--custom--radius--pill);
	border: 1px solid transparent;
	font-size: var(--wp--preset--font-size--base);
	font-weight: 600;
	line-height: 1;
	text-decoration: none;
	white-space: nowrap;
	transition:
		background-color var(--wp--custom--duration--fast) var(--wp--custom--ease--out),
		border-color var(--wp--custom--duration--fast) var(--wp--custom--ease--out),
		color var(--wp--custom--duration--fast) var(--wp--custom--ease--out);
}

.hero-btn--solid {
	background: var(--wp--preset--color--base);
	color: var(--wp--preset--color--base-darker);
}

.hero-btn--solid:hover {
	background: rgba(255, 255, 255, 0.85);
	color: var(--wp--preset--color--base-darker);
}

.hero-btn--ghost {
	background: transparent;
	border-color: rgba(255, 255, 255, 0.62);
	color: var(--wp--preset--color--base);
}

.hero-btn--ghost:hover {
	background: var(--wp--preset--color--base);
	border-color: var(--wp--preset--color--base);
	color: var(--wp--preset--color--base-darker);
}

/* --- Product image --------------------------------------------------------- */

.hero-slide__media {
	position: relative;
	z-index: 1;
	flex: 1 1 auto;
	min-height: 0;
	width: 100%;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: var(--wp--preset--spacing--5) var(--wp--preset--spacing--5) 0;
}

/*
 * contain, not cover: these are cut-out product shots on a transparent
 * background, so the gradient shows through and nothing is cropped. The media
 * area owns a fixed share of the hero, which is what keeps the layout from
 * shifting when the image swaps.
 */
.hero-slide__img {
	max-width: min(760px, 92%);
	max-height: 100%;
	width: auto;
	height: auto;
	object-fit: contain;
}

/* --- Entrance ------------------------------------------------------------- */

/*
 * Gated on .has-motion so that with no JS, or under prefers-reduced-motion,
 * every line sits in its final position. The animation only ever runs on the
 * slide that is currently active.
 */
@keyframes ef-hero-in {
	from {
		opacity: 0;
		transform: translateY(15px);
	}
}

@keyframes ef-hero-media-in {
	from {
		opacity: 0;
		transform: scale(1.03);
	}
}

.has-motion .hero-slide.is-active .hero-slide__title,
.has-motion .hero-slide.is-active .hero-slide__text,
.has-motion .hero-slide.is-active .hero-slide__spec,
.has-motion .hero-slide.is-active .hero-slide__actions {
	animation: ef-hero-in 450ms var(--wp--custom--ease--out) backwards;
}

.has-motion .hero-slide.is-active .hero-slide__title   { animation-delay: 80ms; }
.has-motion .hero-slide.is-active .hero-slide__text    { animation-delay: 150ms; }
.has-motion .hero-slide.is-active .hero-slide__spec    { animation-delay: 200ms; }
.has-motion .hero-slide.is-active .hero-slide__actions { animation-delay: 250ms; }

.has-motion .hero-slide.is-active .hero-slide__media,
.has-motion .hero-slide.is-active .hero-slide__bg {
	animation: ef-hero-media-in 800ms var(--wp--custom--ease--in-out) backwards;
}

/* --- Progress navigation ---------------------------------------------------- */

/*
 * A centred cluster rather than three columns spanning the full content width:
 * at 1320px each rail was over 400px long, which read as a page-wide ruler
 * instead of a control. Each item now has a fixed, modest measure and the group
 * sits centred under the copy.
 */
.hero__nav {
	position: relative;
	z-index: 3;
	margin-top: auto;
	flex-shrink: 0;
	display: flex;
	justify-content: center;
	gap: var(--wp--preset--spacing--5);
	width: 100%;
	margin-inline: auto;
	padding: 0 var(--wp--preset--spacing--5) var(--wp--preset--spacing--7);
}

.hero-nav__item {
	appearance: none;
	background: none;
	border: 0;
	padding: var(--wp--preset--spacing--3) 0 0;
	cursor: pointer;
	display: flex;
	flex-direction: column;
	gap: var(--wp--preset--spacing--2);
	/* Compact but still a comfortable target, and never wider than a third. */
	flex: 0 1 clamp(96px, 12vw, 168px);
	min-height: 44px;
	text-align: left;
	color: rgba(255, 255, 255, 0.55);
	transition: color var(--wp--custom--duration--fast) var(--wp--custom--ease--out);
}

.hero-nav__item:hover {
	color: rgba(255, 255, 255, 0.85);
}

.hero-nav__item.is-active {
	color: var(--wp--preset--color--base);
}

.hero-nav__label {
	font-size: var(--wp--preset--font-size--xs);
	font-weight: 600;
	letter-spacing: 0.01em;
	line-height: 1.2;
	white-space: nowrap;
}

/* The rail every bar runs in. */
.hero-nav__track {
	display: block;
	height: 2px;
	border-radius: 2px;
	background: rgba(255, 255, 255, 0.22);
	overflow: hidden;
}

/*
 * No transition here on purpose: the scale is written every frame by hero.js,
 * so a transition would lag behind the clock it is meant to be showing.
 */
.hero-nav__fill {
	display: block;
	height: 100%;
	background: var(--wp--preset--color--base);
	transform: scaleX(0);
	transform-origin: left center;
	will-change: transform;
}

/* --- Mobile ------------------------------------------------------------------ */

@media (max-width: 781px) {
	.hero {
		height: clamp(560px, 88dvh, 820px);
	}

	.hero-slide__inner {
		padding-top: var(--wp--preset--spacing--8);
		gap: var(--wp--preset--spacing--2);
	}

	.hero-slide__text {
		font-size: var(--wp--preset--font-size--lg);
	}

	.hero-slide__spec {
		font-size: var(--wp--preset--font-size--sm);
	}

	.hero-btn {
		min-height: 50px;
	}

	.hero-slide__actions {
		flex-direction: column;
		align-self: stretch;
		gap: var(--wp--preset--spacing--2);
	}

	.hero-btn {
		width: 100%;
	}

	.hero__nav {
		gap: var(--wp--preset--spacing--3);
		padding-bottom: var(--wp--preset--spacing--6);
	}
}

/* --- Reduced motion ----------------------------------------------------------- */

/*
 * The slider still advances and the bars still fill - what goes away is the
 * animation: slides swap instantly instead of cross-fading, and the entrance
 * keyframes are neutralised in motion.css. The bar is driven from JavaScript
 * rather than by a transition, so it keeps working here untouched.
 */
@media (prefers-reduced-motion: reduce) {
	.hero-slide,
	.hero-slide.is-active {
		transition: none;
	}
}
