/**
 * Hero slider and its tile navigation.
 *
 * Splide ships only structural CSS (splide-core); everything visual is here, taking its colours
 * from the scheme each slide carries.
 */

/*
 * No max-width, no margin, no side padding: the hero sits inside a Divi column beside the two
 * promo rails, and anything here would double-constrain it and break the three-up alignment.
 *
 * No gap either — the navy strap is flush against the bottom edge of the slider in the design,
 * reading as one block. Only the tile navigation below is separated.
 */
.csl-hero {
	display: flex;
	flex-direction: column;
}

/*
 * The hero and the two promo rails are three columns of one Divi row, and the design ends all
 * three on the same line. Divi's row already stretches its columns to the tallest of them; what
 * stops that height reaching us is the Code module's own two wrappers, which are content-sized.
 * Passing it through gives the band one height that every column fills, so the three agree
 * whatever the copy in them runs to — which a hand-picked slider height would not.
 *
 * The slider takes the surplus and the strap and tiles keep their content height, because the
 * slider is the part with room to give: its copy is centred in it, so a taller or shorter stage
 * changes the band of colour around the words and nothing else.
 *
 * Above Divi's 980px column-stacking breakpoint only: below it each column is its own full-width
 * row and there is nothing left to line up with.
 */
@media ( min-width: 981px ) {
	.et_pb_module:has( > .et_pb_code_inner > .csl-section--hero-slider ),
	.et_pb_code_inner:has( > .csl-section--hero-slider ),
	.csl-section--hero-slider,
	.csl-hero {
		height: 100%;
	}

	.csl-hero__stage {
		flex: 1 1 auto;
		min-height: 0;
	}

	/* splide-core already gives .splide__list its 100%, and the slides stretch as flex items. */
	.csl-hero__slider,
	.csl-hero__slider .splide__track {
		height: 100%;
	}
}

/*
 * No-JS fallback. Splide's own stylesheet sets `visibility: hidden` on .splide and relies on its
 * script to reveal the component, so anything that stops the script leaves a blank band where the
 * most-seen element on the site should be. Show the first slide instead — a static hero is a far
 * better failure than an empty one.
 *
 * Keyed on a class the markup ships and our script removes, NOT on Splide's `.is-initialized`.
 * That distinction is the whole point: Splide adds `.is-initialized` only after mount() has
 * finished, so an `:not( .is-initialized )` fallback is still live while Splide measures the
 * track. It would be measuring a `display: block` list whose every slide after the first — clones
 * included — is `display: none`, so the loop offset came out wrong and the slider settled between
 * two slides. Our script drops this class before constructing Splide, which hands measurement a
 * correct flex layout and lets Splide's own `visibility: hidden` cover the mount.
 */
.csl-hero__slider--static {
	visibility: visible;
}

.csl-hero__slider--static .splide__list {
	display: block;
}

.csl-hero__slider--static .splide__slide + .splide__slide {
	display: none;
}

/* `display: block` above drops the slide out of the flex row that would otherwise stretch it. */
.csl-hero__slider--static .splide__slide {
	height: 100%;
}

.csl-hero__slider {
	position: relative;
	border-radius: var( --csl-radius-lg );
	overflow: hidden;
}

.csl-hero__slide {
	position: relative;
	display: flex;
	align-items: center;
	/*
	 * A floor, not the height. On desktop the band above sets the height and the stage grows into
	 * it; this is what the slide falls back to once the columns stack and there is no band left.
	 *
	 * `cqi` rather than `vw` for the same reason the rail headline uses it: the hero is a 940px
	 * column at a 1920 viewport, so a viewport fraction sized it against something twice its own
	 * width. The old 42vw resolved to the 520px ceiling on every desktop screen, which is where
	 * most of the 150px the hero overshot the rails by came from.
	 *
	 * The plain value above each clamp is the fallback for a browser without container units.
	 */
	min-height: 340px;
	min-height: clamp( 300px, 34cqi, 420px );
	padding: var( --csl-space-10 );
	background-color: var( --csl-ground );
	color: var( --csl-ink );
}

.csl-hero__media {
	position: absolute;
	inset: 0;
	z-index: 0;
}

.csl-hero__media .csl-hero__image {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
}

/*
 * A product packshot is not a background — show it whole, to one side. Centred in the right half
 * rather than anchored to the floor, which is where the design puts it.
 *
 * Sized to the packshot, not to the slide: a 350px image needs nowhere near 42% of the width, and
 * the space it was holding empty belongs to the headline.
 */
.csl-hero__media--product {
	position: absolute;
	inset: 0 6% 0 auto;
	width: min( 32%, 300px );
	display: flex;
	align-items: center;
	justify-content: center;
	padding: var( --csl-space-6 ) 0;
}

.csl-hero__media--product .csl-hero__image {
	width: auto;
	max-width: 100%;
	height: 350px;
	/* Only bites on a slide too short for that height — the packshot shrinks, it never overflows. */
	max-height: 100%;
	object-fit: contain;
}

/*
 * Only laid over a full-bleed background image, where text would otherwise sit on unpredictable
 * photography. A product-packshot slide keeps its clean scheme ground.
 */
.csl-hero__slide:has( .csl-hero__media:not(.csl-hero__media--product) )::after {
	content: "";
	position: absolute;
	inset: 0;
	z-index: 1;
	background: linear-gradient( to right, var( --csl-ground ) 0%, rgba( 0, 0, 0, 0.35 ) 55%, rgba( 0, 0, 0, 0.1 ) 100% );
	opacity: 0.82;
}

.csl-hero__body {
	position: relative;
	z-index: 2;
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	gap: var( --csl-space-3 );
	max-width: min( 62%, 640px );
}

/*
 * The eyebrow is the one pink note on an otherwise neutral slide, as drawn.
 *
 * Twice the shared 2xs size — 11px is a caption size, and on a full-bleed hero the line reads as
 * an afterthought rather than as the campaign's opening word. Scoped to .csl-hero so the promo
 * rails, feature grid and product rows keep the small eyebrow the token layer sets.
 */
.csl-hero .csl-eyebrow {
	color: var( --csl-brand-pink-deep );
	font-size: calc( var( --csl-text-2xs ) * 2 );
	font-weight: var( --csl-weight-bold );
}

/*
 * Two weights, as drawn: the first line light, everything after it heavy. Written as separate
 * lines in the headline field rather than as two fields.
 */
.csl-hero__headline {
	margin: 0;
	/*
	 * Sized against the stage, not the viewport. `--csl-text-4xl` is a `2.8vw` clamp built for
	 * full-width titles and it pinned the headline to its 56px ceiling from 1100px up — including
	 * at 1280, where the body column is only 362px wide and `Up to 60% off` broke over three
	 * lines. That headline alone was 268px of a 595px slide, so no floor could have brought the
	 * hero down to the rails while it stood.
	 */
	font-size: var( --csl-text-3xl );
	font-size: clamp( 1.75rem, 5.25cqi, 3.25rem );
	font-weight: var( --csl-weight-bold );
	line-height: var( --csl-leading-tight );
	letter-spacing: var( --csl-tracking-tight );
	color: var( --csl-ink );
	/* `balance` evened the headline into a narrow ragged block; `pretty` fills the width it now has. */
	text-wrap: pretty;
}

.csl-hero__headline-lead {
	display: block;
	font-weight: var( --csl-weight-regular );
}

.csl-hero__headline-rest {
	display: block;
	font-weight: var( --csl-weight-bold );
}

.csl-hero__subcopy {
	margin: 0;
	font-size: var( --csl-text-lg );
	line-height: var( --csl-leading-snug );
	color: var( --csl-ink-soft );
	max-width: 44ch;
}

.csl-hero__price {
	margin: 0;
	font-size: var( --csl-text-2xl );
	font-weight: var( --csl-weight-bold );
	font-variant-numeric: tabular-nums;
	color: var( --csl-ink );
}

.csl-hero__price .woocommerce-Price-amount { color: inherit; }

/*
 * The hero CTA is the page's primary action, so it overrides the shared .csl-btn--amber fill with
 * brand orange and sits a step larger than the default button.
 *
 * The label is white, as drawn in the comp and as the client asked. Note the contrast cost: white
 * on brand orange #ff8728 is 2.40:1, which is below AA even for large text. It is legible at this
 * size but it is not accessible; #b34700 under white would be 4.53:1 if that ever needs fixing.
 *
 * Hover therefore darkens rather than lightens — the old hover raised the fill to brand yellow,
 * which under a white label would drop to 1.85:1. #ec7a15 is the darkened orange the token layer
 * already uses for .csl-btn--orange:hover, so no new colour enters the system.
 *
 * No !important: this stylesheet declares csl-tokens as a dependency, so it always cascades after
 * .csl-btn--amber at equal specificity.
 */
.csl-hero__cta {
	margin-top: var( --csl-space-4 );
	padding: 0.5em 1.9em;
	/* 1.5x the base size. Padding is in em, so the whole button scales with it. */
	font-size: calc( var( --csl-text-base ) * 1.5 );
	max-width: 100%;
	background-color: var( --csl-brand-orange );
	color: #ffffff;
	border-color: var( --csl-brand-navy );
}

.csl-hero__cta:hover,
.csl-hero__cta:focus-visible {
	background-color: #ec7a15;
	color: #ffffff;
}

/*
 * Positioning only. Padding here used to inset the flag's halves from its own border, leaving a
 * ring of background between them and the outline — the shared .csl-badge owns all appearance.
 */
.csl-hero__badge {
	position: absolute;
	top: var( --csl-space-5 );
	right: var( --csl-space-5 );
	z-index: 3;
}

.csl-hero__counter {
	position: absolute;
	right: var( --csl-space-5 );
	bottom: var( --csl-space-5 );
	z-index: 3;
	margin: 0;
	font-size: var( --csl-text-xs );
	font-variant-numeric: tabular-nums;
	color: var( --csl-ink-soft );
}

/* ------------------------------------------------------------ splide chrome */

/*
 * The arrows overlay the slide at its left and right edges, as drawn. They previously sat in a
 * 46px gutter each side of the stage, which stole 92px of width from a hero that has to line up
 * with the promo rails beside it.
 */
.csl-hero__stage {
	position: relative;

	/*
	 * Arrow size, and the room the slide copy keeps clear of it: the arrow's inset, its width and
	 * the same gap again. The comp keeps the copy well clear of the arrows; without this the copy
	 * started 40px in (24px under 900px) and ran beneath a 46px-deep arrow.
	 */
	--csl-hero-arrow: 34px;
	--csl-hero-arrow-clear: calc( var( --csl-space-3 ) * 2 + var( --csl-hero-arrow ) );

	/*
	 * The query container for the slide — the headline and the slide's own floor size against the
	 * stage's width. Inline-size containment only; the stage's width comes from the Divi column
	 * and never from its contents, so there is nothing here for the containment to break.
	 */
	container-type: inline-size;
}

.csl-hero__slider .splide__arrow {
	position: absolute;
	top: 50%;
	transform: translateY( -50% );
	z-index: 4;
	width: var( --csl-hero-arrow );
	height: var( --csl-hero-arrow );
	display: flex;
	align-items: center;
	justify-content: center;
	border: 1px solid var( --csl-brand-neutral );
	border-radius: var( --csl-radius-sm );
	background: #ffffff;
	color: var( --csl-brand-navy );
	cursor: pointer;
	opacity: 1;
}

.csl-hero__slider .splide__arrow:hover { opacity: 1; }
.csl-hero__slider .splide__arrow svg { width: 16px; height: 16px; fill: currentColor; }
/*
 * The vendored stylesheet is splide-core, which carries no arrow styling, and Splide emits the
 * same right-pointing path for both arrows — the full theme CSS is what normally mirrors the
 * previous one. It was never vendored, so that flip has to live here or both arrows point right.
 * It goes on the svg, not the button: the button already spends its transform on translateY.
 */
.csl-hero__slider .splide__arrow--prev { left: var( --csl-space-3 ); }
.csl-hero__slider .splide__arrow--prev svg { transform: scaleX( -1 ); }
.csl-hero__slider .splide__arrow--next { right: var( --csl-space-3 ); }
.csl-hero__slider .splide__arrow:disabled { opacity: 0.4; cursor: default; }

/* Two classes, so it holds against the single-class slide padding at every breakpoint. */
.csl-hero__slider .csl-hero__slide { padding-inline: var( --csl-hero-arrow-clear ); }

.csl-hero__slider .splide__arrow:focus-visible {
	outline: 2px solid var( --csl-accent );
	outline-offset: 2px;
}

/* ---------------------------------------------------------------- strap */

/*
 * The dark band of copy fused to the bottom edge of the slider in the design — no gap, same
 * width, so the slider and the strap read as a single object.
 */
/* `p.` + the parent out-specifies Divi's `p:not(.has-background):last-of-type{padding-bottom:0}`,
   which would otherwise strip the bottom of the band and sit the copy on its edge. */
.csl-hero p.csl-hero__strap {
	margin: 0;
	/* Even top and bottom — the copy sits centred in the band rather than pushed up in it. */
	padding: var( --csl-space-4 ) var( --csl-space-10 );
	background-color: var( --csl-brand-navy );
	color: #ffffff;
	font-size: var( --csl-text-sm );
	line-height: 1.5;
	/* Ranged left. The horizontal padding tracks the slide's so the copy starts on the same
	   line as the headline above it — the two are drawn as one block. */
	text-align: left;
	max-width: none;
}

/* ---------------------------------------------------------------- tile nav */

/*
 * The one gap in the hero: the tiles are their own row, the slider and strap are not.
 *
 * Flex rather than four grid columns — there is one tile per slide, and three slides should
 * make three tiles across the full width, not three tiles and an empty box.
 */
.csl-hero__tiles {
	display: flex;
	gap: var( --csl-gap );
	margin-top: var( --csl-gap );
}

/*
 * Image panel above, solid navy label bar beneath — the label is not an overlay, it is its own
 * band, which is what makes the tiles read as a set.
 *
 * A tile is a button or a link, so the first half of this rule is undoing the UA defaults: a
 * browser button font and centred text, or a link underline, would otherwise reach the label.
 */
.csl-hero__tile {
	flex: 1 1 0;
	min-width: 0;
	display: flex;
	flex-direction: column;
	padding: 0;
	font: inherit;
	text-align: inherit;
	text-decoration: none;
	cursor: pointer;
	overflow: hidden;
	/* Transparent, not absent: the active tile takes this border and must not resize to do it. */
	border: 2px solid transparent;
	background-color: #fbe4ee;
	color: var( --csl-brand-navy );
	transition: transform var( --csl-transition ), border-color var( --csl-transition );
}

/*
 * The current slide's tile. Border and dimming together, never colour alone — and `aria-current`
 * carries the same fact to a screen reader, which sees no border at all.
 */
.csl-hero__tile.is-active { border-color: var( --csl-brand-navy ); }

/* The packshot dims on inactive tiles, not the panel: its gradient below is part of the design. */
.csl-hero__tile:not( .is-active ) .csl-hero__tile-image { opacity: 0.6; }

.csl-hero__tile:hover { transform: translateY( -2px ); }
.csl-hero__tile:hover .csl-hero__tile-image { opacity: 1; }

/*
 * The panel is the comp's two-part pink, sampled from it: a barely-there lightening down the
 * top four fifths, then a hard edge into a stronger pink band that fades back towards the
 * label. The doubled stop at 80% is that edge — one gradient, no extra element.
 */
.csl-hero__tile-media {
	display: flex;
	align-items: center;
	justify-content: center;
	aspect-ratio: 16 / 10;
	padding: var( --csl-space-3 );
	min-height: 0;
	background-image: linear-gradient(
		180deg,
		#fdecf2 0%,
		#fdf6f8 80%,
		#f6aec8 80%,
		#f8cee6 100%
	);
}

/* A packshot sits in the panel. */
.csl-hero__tile-image {
	width: auto;
	max-width: 100%;
	max-height: 100%;
	transition: opacity var( --csl-transition );
	object-fit: contain;
}

/* A background image is scenery, so it fills the panel instead, edge to edge. */
.csl-hero__tile-media:has( .csl-hero__tile-image--fill ) { padding: 0; }

.csl-hero__tile-image--fill {
	width: 100%;
	height: 100%;
	max-height: none;
	object-fit: cover;
}

.csl-hero__tile-label {
	display: block;
	margin-top: auto;
	padding: 0.85em 0.6em;
	background-color: var( --csl-brand-navy );
	color: #ffffff;
	font-size: var( --csl-text-2xs );
	font-weight: var( --csl-weight-semibold );
	letter-spacing: var( --csl-tracking-wide );
	text-transform: uppercase;
	text-align: center;
}

/* An unlabelled slide gets no empty navy strip. */
.csl-hero__tile-label:empty { display: none; }

.csl-hero__tile:focus-visible {
	outline: 2px solid var( --csl-brand-pink-deep );
	outline-offset: 2px;
}

@media ( max-width: 900px ) {
	.csl-hero__slide { padding: var( --csl-space-6 ); }
	.csl-hero p.csl-hero__strap { padding: var( --csl-space-4 ) var( --csl-space-6 ); }
	.csl-hero__body { max-width: 100%; }
	.csl-hero__media--product { width: 32%; right: var( --csl-space-4 ); opacity: 0.9; }
	/* Under the desktop slide height the packshot goes back to filling whatever room is left. */
	.csl-hero__media--product .csl-hero__image { height: auto; }
	.csl-hero__tiles { flex-wrap: wrap; }
	.csl-hero__tile { flex-basis: calc( 50% - var( --csl-gap ) ); }
	/* Full desktop size would run past the slide once the packshot takes its 32%. */
	.csl-hero__cta { font-size: calc( var( --csl-text-base ) * 1.25 ); }
}

@media ( max-width: 560px ) {
	/*
	 * The packshot used to be dropped outright at this width, which left the slide a flat colour
	 * panel — the one element that shows a shopper what is actually on offer, gone at the width
	 * where most of them see it.
	 *
	 * It stays, flush to the right edge and wide enough to read. There is no room to sit it beside
	 * the copy at this width, so it sits behind: the body is already full-width here, and holding
	 * a column open for a 52% image would leave the headline three words to a line.
	 */
	.csl-hero__media--product {
		right: 0;
		width: 52%;
		opacity: 0.55;
		padding: 0;
	}

	/*
	 * Blurred, because at this width the copy has nowhere else to go: the headline runs the full
	 * slide and lands on the packshot, and a sharp product photo behind type wins the contrast
	 * fight every time. Out of focus it reads as ground rather than as a competing subject — the
	 * shopper still sees what is on offer, and the words stay first.
	 */
	.csl-hero__media--product .csl-hero__image { filter: blur( 2px ); }
	.csl-hero__slider .splide__arrow { display: none; }
	/* No arrows at this width, so no room to keep clear of them. */
	.csl-hero__slider .csl-hero__slide { padding-inline: var( --csl-space-6 ); }
	.csl-hero p.csl-hero__strap { font-size: var( --csl-text-xs ); padding: var( --csl-space-3 ) var( --csl-space-4 ); }
	.csl-hero__cta { font-size: var( --csl-text-base ); padding: 0.5em 1.5em; }
}
