/**
 * Type A — Promo Rail.
 *
 * A bordered banner beside the hero, in three zones:
 *
 *   ┌────────────────────┐
 *   │▓ WINTER           ▓│  upper chevron — --csl-rail-top, or artwork behind it
 *   │▓ BEAUTY Bonanza   ▓│
 *   │ ▓▓▓╲__________╱▓▓▓ │
 *   │        ███         │  light band — the rail's own ground; the packshot rides
 *   │  [25%] ███         │  up over the chevron edge and sits on top of it
 *   │   PRODUCT NAME     │
 *   │  ╱▔▔▔▔▔▔▔▔▔▔▔▔╲    │
 *   │▓▓  $14           ▓▓│  lower chevron — --csl-rail-bottom
 *   │▓▓  [Shop Now]    ▓▓│
 *   └────────────────────┘
 *
 * Only two colours are asked for because the band between them is the rail's ground, not a fill.
 *
 * Both chevrons are clip-paths rather than bordered triangles: a border triangle cannot take a
 * percentage width, so it would be pinned to a pixel size while the rail's column is fluid.
 *
 * Unlike every other section type this one takes raw colours rather than a named scheme, so its
 * ink cannot be looked up — the renderer derives it and passes it in. Nothing here reads a scheme.
 */

/*
 * The rail and the hero 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 the rail is the Code module's own two wrappers, which are content-sized, so the
 * `height: 100%` below has nothing definite to resolve against and falls back to the rail's own
 * copy. That is why the two rails currently disagree with each other by as much as 54px.
 *
 * Passing the column height down through those wrappers gives the band one height that every
 * column fills. It holds whatever the copy in each rail runs to, which a hand-picked number
 * matching today's copy would not.
 *
 * 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--promo-rail ),
	.et_pb_code_inner:has( > .csl-section--promo-rail ),
	.csl-section--promo-rail {
		height: 100%;
	}
}

.csl-rail {
	--csl-rail-notch: 26px;

	/*
	 * The rail sizes its own headline — see `.csl-rail__headline-lead`. Inline-size containment
	 * only; the rail's width comes from the Divi column it sits in, never from its contents, so
	 * there is nothing here for the containment to break.
	 */
	container-type: inline-size;

	display: flex;
	flex-direction: column;
	height: 100%;
	min-height: 380px;
	border: 4px solid var( --csl-brand-navy );
	border-radius: var( --csl-radius-lg );
	background-color: #ffffff;
	color: var( --csl-brand-navy );
	overflow: hidden;

	/* The rail is an `<a>` whenever it has a destination; the copy inside must not underline. */
	text-decoration: none;
}

/*
 * One link, one target. The button inside the rail is a span, so it has no hover of its own;
 * pointing anywhere on the banner lights it with the same fill `.csl-btn--amber:hover` uses, and
 * the whole rail reads as clickable rather than just its button.
 *
 * Keyboard focus lands on the rail, so the ring goes there — outside the navy border, where it is
 * visible against the page and not clipped by the rail's own `overflow: hidden`.
 */
.csl-rail:hover .csl-rail__cta {
	background-color: var( --csl-brand-orange );
}

.csl-rail:focus-visible {
	outline: 3px solid var( --csl-brand-pink-deep );
	outline-offset: 3px;
}

/* ---------------------------------------------------------- upper chevron */

.csl-rail__top {
	position: relative;
	display: flex;
	flex-direction: column;
	align-items: center;
	text-align: center;
	padding: var( --csl-space-6 );

	/*
	 * The band below pulls itself up by twice the notch, so that much of this padding is
	 * cancelled before anything paints. Paying the pull-up back here leaves --csl-space-5 as the
	 * real clearance between the last line of copy and the packshot.
	 */
	padding-bottom: calc( var( --csl-rail-notch ) * 2 + var( --csl-space-5 ) );
	background-color: var( --csl-rail-top, #d22f70 );
	background-position: center;
	background-size: cover;
	background-repeat: no-repeat;
	color: var( --csl-rail-ink-top, #ffffff );
	clip-path: polygon(
		0 0,
		100% 0,
		100% calc( 100% - var( --csl-rail-notch ) ),
		50% 100%,
		0 calc( 100% - var( --csl-rail-notch ) )
	);
}

/*
 * The eyebrow is the first of the headline's three lines in the design — "Winter" over "BEAUTY"
 * over "Bonanza" — set exactly like the third line: bold, title case, no tracking. It drops the
 * small-caps treatment every other section's eyebrow has, and its own margin, so the three lines
 * stack as one block. Sized the same way as the headline below, against the rail.
 */
.csl-rail__top .csl-eyebrow {
	margin-bottom: 0;
	font-family: var( --csl-font-heading );
	font-size: var( --csl-text-lg );
	font-size: clamp( 0.75rem, 9cqi, 1.25rem );
	font-weight: var( --csl-weight-bold );
	line-height: 1.1;
	letter-spacing: 0;
	text-transform: none;
	color: inherit;
}

/*
 * Two sparkles in the chevron, placed as the design places them: one to the right of the copy
 * where the packshot's cap will rise past it, a smaller one lower on the left. Percentages of the
 * chevron, so they keep their station as the copy runs longer or shorter, and sized against the
 * rail like everything else in it. They are the ink colour, so artwork or a dark top fill still
 * gets a sparkle that reads. Decoration only: hidden from the tree and from the pointer.
 */
.csl-rail__sparkle {
	position: absolute;
	display: block;
	width: clamp( 0.625rem, 13cqi, 1.375rem );
	height: auto;
	color: inherit;
	pointer-events: none;
}

.csl-rail__sparkle--right {
	top: 70%;
	left: 66%;
}

.csl-rail__sparkle--left {
	top: 86%;
	left: 22%;
	width: clamp( 0.5rem, 9cqi, 1rem );
}

/* ------------------------------------------------------------- light band */

/*
 * Pulled up so the packshot overlaps the chevron above it and reads as sitting on the artwork
 * rather than beside it. z-index beats the clipped block, which paints first.
 */
.csl-rail__middle {
	position: relative;
	z-index: 2;
	flex: 1 1 auto;
	display: flex;
	flex-direction: column;
	gap: var( --csl-space-3 );
	margin-top: calc( var( --csl-rail-notch ) * -2 );
	padding: 0 var( --csl-space-5 ) var( --csl-space-4 );
	min-height: 0;
}

.csl-rail__media {
	position: relative;
	flex: 1 1 auto;
	display: flex;
	align-items: center;
	justify-content: center;
	min-height: 130px;
}

/*
 * Positioning only. The flat pink chip the rails use instead of the two-tone flag is
 * `.csl-badge--solid` in the token layer, alongside the flag it replaces.
 *
 * Right-anchored in both rails, not mirrored to the outer edge: the chip reads as belonging to
 * the packshot, so it stays on the same side of the product whichever side the rail sits on.
 */
.csl-rail__badge {
	position: absolute;
	right: 0;
	bottom: var( --csl-space-4 );
	z-index: 3;
}

.csl-rail__image {
	display: block;
	max-width: 100%;
	max-height: 230px;
	width: auto;
	height: auto;

	/* `contain` semantics, as with the card: aspect ratios here run from 0.08 to 1.23. */
	object-fit: contain;

	/* The packshot is the thing overlapping the chevron, so it carries the lift. */
	filter: drop-shadow( 0 6px 14px rgba( 20, 50, 66, 0.18 ) );
}

/*
 * Bold, full-strength navy and three lines, as drawn. It was semi-transparent regular weight
 * clamped to two lines, which turned "ESSIE NAIL POLISH SALTWATER HAPPY" into "ESSIE NAIL
 * POLISH…"; the catalogue's names are long and the third line is what fits them.
 */
.csl-rail__product {
	margin: 0;
	font-size: var( --csl-text-xs );
	font-weight: var( --csl-weight-bold );
	letter-spacing: var( --csl-tracking-wide );
	text-transform: uppercase;
	color: var( --csl-brand-navy );
	text-align: center;

	display: -webkit-box;
	-webkit-line-clamp: 3;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

/* ---------------------------------------------------------- lower chevron */

.csl-rail__bottom {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: var( --csl-space-3 );
	padding: calc( var( --csl-rail-notch ) + var( --csl-space-3 ) ) var( --csl-space-5 ) var( --csl-space-6 );
	background-color: var( --csl-rail-bottom, #fdebf2 );
	color: var( --csl-rail-ink-bottom, #143242 );
	clip-path: polygon(
		0 var( --csl-rail-notch ),
		50% 0,
		100% var( --csl-rail-notch ),
		100% 100%,
		0 100%
	);
}

/* ----------------------------------------------------------------- pieces */

.csl-rail__headline {
	margin: 0;
	font-family: var( --csl-font-heading );
	line-height: 1.02;
	letter-spacing: var( --csl-tracking-tight );
	text-wrap: balance;
}

/*
 * Sized against the rail, not the viewport.
 *
 * These were on `--csl-text-3xl` / `--csl-text-2xl`, and `-3xl` is a `1.8vw` clamp built for
 * full-width section titles. The rail is a fixed ~150px column beside the hero, so the two scale
 * in opposite directions: a wider screen bought the headline 40px of type and the column barely a
 * pixel, and `BEAUTY` ran under the rail's `overflow: hidden` as `BEAUT`. Capping the value would
 * only have moved the breakpoint at which it happened.
 *
 * `cqi` is a percentage of the rail's own inline size, so the headline now grows and shrinks with
 * the thing that has to contain it. The clamp ceiling is what the mobile stack used to set by
 * hand — a full-width stacked rail hits it and lands on the same size as before.
 *
 * The plain `font-size` above each clamp is the fallback: a browser without container units drops
 * the whole `clamp()` as invalid and keeps it.
 */
/*
 * The lead word is navy on the pink fill in the design, not the derived ink — it is the one
 * line that changes colour, and the contrast with the white lines either side is the point.
 * Brand navy rather than an instance colour, so it stays the same token as the rail's border.
 */
.csl-rail__headline-lead {
	display: block;
	font-size: var( --csl-text-2xl );
	font-size: clamp( 0.875rem, 16cqi, 1.875rem );
	font-weight: var( --csl-weight-bold );
	text-transform: uppercase;
	color: var( --csl-brand-navy );
}

/* Third line: the same setting as the eyebrow, so the two bracket the lead symmetrically. */
.csl-rail__headline-rest {
	display: block;
	font-size: var( --csl-text-lg );
	font-size: clamp( 0.75rem, 9cqi, 1.25rem );
	font-weight: var( --csl-weight-bold );
	font-style: normal;
	line-height: 1.1;
	letter-spacing: 0;
	text-transform: none;
}

.csl-rail__subcopy {
	margin: var( --csl-space-3 ) 0 0;
	font-size: var( --csl-text-sm );
	font-size: clamp( 0.6875rem, 5.5cqi, 0.875rem );
	line-height: var( --csl-leading-snug );
	max-width: 24ch;
	color: inherit;
}

/* Same reasoning as the headline: a flat 1.75rem `$13.99` is wider than the rail below 1440. */
.csl-rail__price {
	margin: 0;
	font-size: var( --csl-text-2xl );
	font-size: clamp( 1rem, 19cqi, 1.75rem );
	font-weight: var( --csl-weight-bold );
	font-variant-numeric: tabular-nums;
	color: inherit;
}

.csl-rail__price .woocommerce-Price-amount { color: inherit; }

/*
 * The CTA stays on one line. `.csl-btn` is a flex row sized for a full-width section; dropped into
 * a rail whose content box is 70px at a 1024 viewport, `Shop Now` wrapped to two lines and the
 * button's own minimum width pushed it through the rail's right border.
 *
 * `nowrap` is the instruction; the container-scaled padding and label are what make it fit rather
 * than just overflow in one line instead of two. Both stop at the values `.csl-btn` already sets,
 * so at 1600 and above the button is byte-for-byte what it was.
 */
.csl-rail__cta {
	max-width: 100%;
	padding: 0.7em clamp( 0.5em, 9cqi, 1.4em );
	font-size: clamp( 0.6875rem, 9cqi, 0.875rem );
	white-space: nowrap;
}

.csl-rail__cta-icon { flex: 0 0 auto; }

/* ------------------------------------------------------- narrow rail */

/*
 * The rail's column is fluid and gets thin fast: measured inner width is 171px at a 1920 viewport,
 * 150px at 1600, 119px at 1280 and 94px at 1024. At that last one the horizontal padding alone —
 * 24px a side in the chevron, 20px in the band — is more than half the rail, leaving 46px for a
 * headline. So below 110px the padding gives way before the type does; the copy is the reason the
 * rail exists and the gutter is not.
 *
 * A container query, not a media query: what matters is how wide the rail is, and that is set by
 * the Divi column it lands in, not by the viewport.
 */
@container ( max-width: 110px ) {
	.csl-rail__top,
	.csl-rail__middle,
	.csl-rail__bottom {
		padding-left: var( --csl-space-3 );
		padding-right: var( --csl-space-3 );
	}
}

/*
 * The cart glyph goes before the label does. With `nowrap` the CTA's content decides its width,
 * and the icon plus its gap is about 22px of it — a fifth of the button at a 135px rail and a
 * third at 94px, which is what pushed it through the border. The label is the part that has to
 * survive; the glyph is decoration that repeats what the label already says, and `.csl-rail__cta`
 * keeps its accessible name either way.
 */
@container ( max-width: 145px ) {
	.csl-rail__cta-icon {
		display: none;
	}
}

/*
 * Mobile. Which of these applies is a client setting, because the trade-off is real: stacking
 * keeps the promotion visible, hiding keeps the hero above the fold.
 *
 * The three zones stay stacked rather than turning sideways — the chevrons only read as chevrons
 * across the full width, and a squat two-column version loses the shape entirely.
 */
@media ( max-width: 900px ) {
	.csl-rail {
		--csl-rail-notch: 18px;

		min-height: 0;
	}

	.csl-rail--mobile-hide {
		display: none;
	}

	/*
	 * The two headline overrides that used to live here are gone: a stacked rail is full width,
	 * so it reaches the clamp ceiling on its own and lands on exactly the sizes they set.
	 */
	.csl-rail--mobile-stack .csl-rail__image { max-height: 170px; }
}
