/*
 * Hero System V1 — campaign hero component (S11-B4;
 * design-lab/final/hero-campaign/ R2, HERO-CONTRACT.md,
 * HOMEPAGE-VISUAL-SYSTEM-LOCK.md S11-B4 amendment note; production R2
 * robustness corrections H-1 / M-3 / M-5). Prefix `pp-hero-`. Builds ONLY
 * on the theme's existing tokens and primitives (design-system.css:
 * --pp-navy / .pp-btn / .pp-btn-inverse / .pp-icon-btn / .pp-i / motion +
 * focus tokens; home-page.css: .pp-home-eyebrow-dot, .pp-home-textlink).
 * No new colour, radius, type role or control size.
 *
 * Model: one stage; up to two slides GRID-STACKED in the same cell
 * (grid-area 1/1) so they can crossfade while remaining in normal flow —
 * the stage is exactly as tall as its tallest slide, which is what makes
 * the layout robust for every content length the campaign schema permits
 * (R2 correction H-1): long copy GROWS the hero instead of clipping or
 * overlapping. Each campaign slide = a "world" (artwork + flat world-edge
 * extension colours, supplied per slide as validated data → inline custom
 * properties) + a soft Navy scrim + an HTML commerce layer + shared
 * controls. With ONE resolved slide the same component renders statically:
 * no controls, no autoplay, no carousel script, no swipe touch handling.
 *
 * Geometry (locked): ≥ 900px = OVERLAY — the commerce layer reserves the
 * approved stage height as a MINIMUM (600 / 560 / 520px by tier; approved
 * content renders at exactly those heights), artwork is height-fitted
 * (never cropped vertically) and anchored by the campaign's per-tier
 * anchor; wider stages extend the world with the measured flat edge colour.
 * ≤ 899px = STACK — artwork band first (aspect-ratio-sized; ≤ 640 uses the
 * approved mobile-crop ratio), copy below on the world's bottom-row colours
 * with the approved copy height as a MINIMUM (224px / 300px ≤ 640).
 *
 * Contrast (locked, R2-corrected): the linear Navy scrim plus a LOCAL band
 * of the same Navy that is ANCHORED TO THE COPY BLOCK (.pp-hero-copy::before)
 * rather than to fixed stage coordinates, so the support line and CTA row
 * keep their ≥ 4.5:1 worst-case contrast wherever wrapped content moves
 * them. For the approved copy lengths it reproduces the R2-lab band
 * geometry (feather 40→110, solid to copy-bottom, feather +65px) exactly.
 */

.pp-hero {
	/* ---- tunables; campaign data overrides per slide via inline custom properties ---- */
	--pp-hero-h: 600px;                 /* overlay MINIMUM stage height ≥ 1280 (approved content renders at exactly this) */
	--pp-hero-art-ratio: 2.3571;       /* per-campaign: widest desktop rendition w/h (inline on the section) */
	--pp-hero-art-ratio-m: 1.1313;     /* per-campaign: widest mobile rendition w/h */
	--pp-hero-scrim: .66;               /* peak Navy alpha of the copy scrim (campaign data may override) */
	--pp-hero-cl: max(0px, calc((100% - var(--pp-container-max)) / 2)); /* container left edge (0 below 1320) */
	--pp-hero-scrim-x1: calc(var(--pp-hero-cl) + 560px);  /* where the directional scrim reaches 0 — right of the copy column, left of the HERO product */
	/* Local contrast band (R2 lab decision, §4.6): same linear Navy under the copy block. Horizontal geometry is
	   container-relative via the COPY BLOCK's own left edge (copy left = container-left + gutter, so a right
	   offset from the copy reproduces the locked container-left + 460/420/390px zero points at every width). */
	--pp-hero-scrim-band: .40;                                 /* extra Navy alpha inside the band */
	--pp-hero-band-r: 428px;                                   /* band reaches 0 at copy-left + this (= container-left + 460px) — left of the hero product's fruit edge */
	--pp-hero-band-fade: 90px;                                 /* horizontal fall-off length */
	--pp-hero-support-max: 20.4em;                             /* overlay support wrap limit (H-1 §3.3): font-relative, a hair wider than the approved line (20.13em), so the approved copy never wraps and WRAPPED long lines end where the approved line already ends — inside the band zone whose worst-case contrast the lab measured ≥ 4.5:1 at every tier. */
	/* R3 (human-directed desktop balance): the copy composition centres
	   vertically in the campaign field. With the layer's asymmetric padding
	   (56px top / 88px control reserve below) flex-centering lands the copy's
	   centre ~16px ABOVE the stage's mathematical centre — the approved
	   "optically raised centre" (~47% of the 600px stage; ~46% at the 1024
	   tier) — with no offsets, no transforms, and full compatibility with
	   the R2 intrinsic-growth contract (content taller than the minimum
	   consumes the slack and grows the stage exactly as before). Stack mode
	   already centres and is untouched. */
	--pp-hero-copy-align: center;
	--pp-hero-copy-h: 300px;            /* STACK: MINIMUM copy block height ≤ 640 (approved content renders at exactly this) */
	--pp-hero-copy-h-t: 224px;          /* STACK: MINIMUM copy block height 641–899 */
	--pp-hero-fade: 500ms;
	/* World colours are CAMPAIGN DATA (measured from the artwork, validated hex → Theme-composed gradients,
	   inline per slide). These neutral fallbacks paint when a slide supplies none. */
	--pp-hero-world-l: var(--pp-soft-surface);
	--pp-hero-world-r: var(--pp-soft-surface);
	--pp-hero-world-b: var(--pp-soft-surface);
	--pp-hero-navy-rgb: 20, 47, 81;     /* --pp-navy #142F51 as channels for the scrim alphas */
	position: relative;
	background: var(--pp-soft-surface);
	color: var(--pp-ink);
}
@media (max-width: 1279px) { .pp-hero { --pp-hero-h: 560px; --pp-hero-scrim-x1: calc(var(--pp-hero-cl) + 480px); --pp-hero-band-r: 358px; --pp-hero-band-fade: 50px; } }
@media (min-width: 1280px) and (max-width: 1439px) { .pp-hero { --pp-hero-scrim-x1: calc(var(--pp-hero-cl) + 520px); --pp-hero-band-r: 388px; --pp-hero-band-fade: 75px; } }
@media (max-width: 1024px) { .pp-hero { --pp-hero-h: 520px; } }

/* ---------- Stage + slides ---------- */
/* Slides share one grid cell: crossfade stacking WITHOUT absolute
   positioning, so the stage grows with its content (H-1). Only the
   carousel restricts touch behaviour, and then only to what swipe needs —
   vertical panning and pinch zoom stay native (M-5). */
.pp-hero-stage {
	position: relative;
	display: grid;
	overflow: hidden;
	isolation: isolate;
}
.pp-hero[data-pp-hero] .pp-hero-stage { touch-action: pan-y pinch-zoom; }
.pp-hero-slide {
	grid-area: 1 / 1;
	position: relative;
	min-width: 0;
	opacity: 0;
	transition: opacity var(--pp-hero-fade) var(--pp-ease-standard);
	will-change: opacity;
	/* Artwork anchor by tier — the campaign's per-tier art direction (0…1),
	   slide-scoped so two slides may anchor differently. */
	--pp-hero-anchor: var(--pp-hero-anchor-wide, 1);
}
@media (min-width: 1280px) and (max-width: 1439px) { .pp-hero-slide { --pp-hero-anchor: var(--pp-hero-anchor-mid, .5); } }
@media (max-width: 1279px) { .pp-hero-slide { --pp-hero-anchor: var(--pp-hero-anchor-narrow, .32); } }
.pp-hero-slide.is-active { opacity: 1; z-index: 2; }
.pp-hero-slide.is-leaving { opacity: 1; z-index: 1; transition: none; } /* stays underneath until the fade completes */
.pp-hero-slide[inert] { pointer-events: none; }
@media (prefers-reduced-motion: reduce) {
	.pp-hero-slide { transition: none; }
}

/* ---------- Campaign slide: world + art (overlay ≥ 900) ---------- */
.pp-hero-slide--campaign { background: var(--pp-hero-world-l); }
.pp-hero-art { position: absolute; inset: 0; overflow: hidden; background: var(--pp-hero-world-l); z-index: 1; container-type: size; }
.pp-hero-art::after { /* right-hand world extension (only visible when a slide anchors left) */
	content: ""; position: absolute; top: 0; bottom: 0; right: 0; width: 50%;
	background: var(--pp-hero-world-r); z-index: 0;
	opacity: calc(1 - var(--pp-hero-anchor));
}
.pp-hero-art picture { display: contents; }
.pp-hero-art img {
	position: absolute; top: 0; z-index: 1;
	height: 100%; width: auto; max-width: none;
	/* Height-fitted, never cropped vertically. The anchor math needs the
	   rendered artwork WIDTH (= art height × ratio): the container-query
	   unit form tracks the real art height even when long content grows the
	   stage beyond the minimum; the --pp-hero-h form is the static fallback
	   (exact at the approved heights) for engines without size containers. */
	left: calc(var(--pp-hero-anchor) * (100% - var(--pp-hero-h) * var(--pp-hero-art-ratio)));
}
@supports (width: 100cqh) {
	.pp-hero-art img { left: calc(var(--pp-hero-anchor) * (100% - 100cqh * var(--pp-hero-art-ratio))); }
}
.pp-hero-scrim {
	position: absolute; inset: 0; z-index: 2; pointer-events: none;
	/* directional, CONTAINER-relative (px offsets from the container's left edge, so the copy column sits in the
	   peak zone at every viewport width): peak → ~230px soft fall-off → ZERO before the hero product */
	background: linear-gradient(90deg,
		rgba(var(--pp-hero-navy-rgb), var(--pp-hero-scrim)) 0%,
		rgba(var(--pp-hero-navy-rgb), var(--pp-hero-scrim)) calc(var(--pp-hero-scrim-x1) - 230px),
		rgba(var(--pp-hero-navy-rgb), calc(var(--pp-hero-scrim) * .85)) calc(var(--pp-hero-scrim-x1) - 160px),
		rgba(var(--pp-hero-navy-rgb), calc(var(--pp-hero-scrim) * .45)) calc(var(--pp-hero-scrim-x1) - 90px),
		rgba(var(--pp-hero-navy-rgb), 0) var(--pp-hero-scrim-x1));
}

/* ---------- Commerce layer (HTML copy) ---------- */
/* In flow (not absolute): its min-height IS the approved stage height, and
   longer content grows the hero instead of clipping (H-1). */
.pp-hero-layer {
	position: relative; z-index: 3;
	min-height: var(--pp-hero-h);
	display: flex; align-items: var(--pp-hero-copy-align);
	padding-block: 56px 88px;
}
.pp-hero-copy { position: relative; isolation: isolate; max-width: 34rem; color: #fff; }
/* R2-approved LOCAL contrast band, anchored to the copy block so it follows
   the real support/CTA geometry at every content length (H-1 §3.3). At the
   approved copy sizes this reproduces the lab band exactly: vertical
   feather from copy-top − 16px (solid 70px later), solid to copy-bottom
   − 5px, transparent by copy-bottom + 65px; horizontally full from the
   viewport's left edge, fading to 0 at copy-left + --pp-hero-band-r
   (= container-left + 460 / 420 / 390px by tier). It is a soft continuation
   of the scrim — never a panel, box or rectangle. */
.pp-hero-copy::before {
	content: ""; position: absolute; z-index: -1; pointer-events: none;
	top: -16px; bottom: -65px;
	left: -100vw; right: calc(-1 * var(--pp-hero-band-r));
	background: linear-gradient(90deg,
		rgba(var(--pp-hero-navy-rgb), var(--pp-hero-scrim-band)) 0%,
		rgba(var(--pp-hero-navy-rgb), var(--pp-hero-scrim-band)) calc(100% - var(--pp-hero-band-fade)),
		rgba(var(--pp-hero-navy-rgb), calc(var(--pp-hero-scrim-band) * .5)) calc(100% - var(--pp-hero-band-fade) / 2),
		rgba(var(--pp-hero-navy-rgb), 0) 100%);
	-webkit-mask-image: linear-gradient(180deg, transparent 0, #000 70px, #000 calc(100% - 70px), transparent 100%);
	mask-image: linear-gradient(180deg, transparent 0, #000 70px, #000 calc(100% - 70px), transparent 100%);
}
.pp-hero-eyebrow {
	display: flex; align-items: center; gap: 7px;
	font: 700 11px/1.3 var(--pp-font-body); letter-spacing: .08em; text-transform: uppercase;
	color: #fff; margin: 0 0 14px;
}
.pp-hero-title {
	font: 600 clamp(2.5rem, 3.75vw, 3.5rem)/1.04 var(--pp-font-display);
	letter-spacing: -0.02em; margin: 0 0 14px; max-width: 12ch; text-wrap: balance; color: #fff;
}
/* Support and CTA rows wrap INSIDE the band's guaranteed-contrast zone
   (overlay tiers): long content folds to extra lines that keep the same
   measured worst-case backdrop instead of running into the fade and the
   bright ghosted artwork (H-1 §3.3). The approved content is narrower than
   every cap and renders identically. */
.pp-hero-support { font: 400 17px/1.45 var(--pp-font-body); color: rgba(255,255,255,.86); margin: 0 0 28px; max-width: var(--pp-hero-support-max); }
.pp-hero-actions { display: flex; align-items: center; gap: 12px 24px; flex-wrap: wrap; max-width: var(--pp-hero-band-r); }
/* R2 APPROVED: primary CTA on a dark campaign slide = the theme's existing inverse button (white surface, Navy text). */
.pp-hero-slide[data-theme="dark"] .pp-btn-inverse:focus-visible { outline: none; box-shadow: var(--pp-focus-ring-on-dark); }
.pp-hero-slide[data-theme="dark"] .pp-home-textlink { color: #fff; }
.pp-hero-slide[data-theme="dark"] :focus-visible { outline: none; box-shadow: var(--pp-focus-ring-on-dark); }

/* ---------- Light slide copy (a light-theme campaign keeps ink on its own world) ---------- */
.pp-hero-slide[data-theme="light"] .pp-hero-copy,
.pp-hero-slide[data-theme="light"] .pp-hero-eyebrow,
.pp-hero-slide[data-theme="light"] .pp-hero-title { color: var(--pp-ink); }
.pp-hero-slide[data-theme="light"] .pp-hero-support { color: var(--pp-secondary-text); }
.pp-hero-slide[data-theme="light"] .pp-hero-scrim,
.pp-hero-slide[data-theme="light"] .pp-hero-copy::before { display: none; }

/* ---------- Controls (carousel markup only; PROGRESSIVE ENHANCEMENT) ----------
   Hidden until hero-carousel.js has successfully initialised and set
   data-ready on the root (R2 correction M-3): a no-JS visitor sees the
   first slide with its copy and CTAs and NO dead carousel UI. */
.pp-hero-controls { display: none; }
.pp-hero[data-ready] .pp-hero-controls {
	position: absolute; left: 0; right: 0; bottom: 16px; z-index: 5;
	display: flex; align-items: center; justify-content: space-between; gap: 12px;
	pointer-events: none;
}
.pp-hero-controls > * { pointer-events: auto; }
.pp-hero-pager { display: flex; align-items: center; gap: 2px; }
.pp-hero-dot {
	width: var(--pp-hit-min); height: var(--pp-hit-min);
	display: grid; place-items: center; background: none; border: 0; padding: 0; cursor: pointer;
	border-radius: var(--pp-radius-control); -webkit-tap-highlight-color: transparent;
}
.pp-hero-dot::before {
	content: ""; width: 8px; height: 8px; border-radius: 4px;
	background: rgba(255,255,255,.55);
	transition: width var(--pp-motion-component) var(--pp-ease-out), background-color var(--pp-motion-micro) var(--pp-ease-out);
}
.pp-hero-dot[aria-current="true"]::before { width: 24px; background: #fff; }
.pp-hero-toggle, .pp-hero-arrow { color: #fff; }
@media (hover: hover) { .pp-hero-toggle:hover, .pp-hero-arrow:hover { background: rgba(255,255,255,.14); } } /* UI.1 P2 (Human Lock §8): hover-capable input only — a tap never leaves this shade behind. */
.pp-hero-arrow { border: 1px solid rgba(255,255,255,.55); background: rgba(var(--pp-hero-navy-rgb), .28); }
.pp-hero-arrows { display: none; gap: 8px; }
@media (min-width: 1025px) { .pp-hero[data-ready] .pp-hero-arrows { display: flex; } }
.pp-hero-toggle .pp-hero-ico-play, .pp-hero-toggle[data-playing="0"] .pp-hero-ico-pause { display: none; }
.pp-hero-toggle[data-playing="0"] .pp-hero-ico-play { display: inline-block; }
.pp-hero[data-state="off"] .pp-hero-toggle { display: none; }   /* autoplay disabled (setting or reduced motion): no rotation control needed */
/* light theme (a light slide active) */
.pp-hero-stage[data-theme="light"] .pp-hero-dot::before { background: rgba(var(--pp-hero-navy-rgb), .32); }
.pp-hero-stage[data-theme="light"] .pp-hero-dot[aria-current="true"]::before { background: var(--pp-navy); }
.pp-hero-stage[data-theme="light"] .pp-hero-toggle, .pp-hero-stage[data-theme="light"] .pp-hero-arrow { color: var(--pp-navy); }
.pp-hero-stage[data-theme="light"] .pp-hero-arrow { border-color: var(--pp-border-hover); background: #fff; }
@media (hover: hover) { .pp-hero-stage[data-theme="light"] .pp-hero-toggle:hover, .pp-hero-stage[data-theme="light"] .pp-hero-arrow:hover { background: var(--pp-soft-surface); } } /* UI.1 P2 (Human Lock §8): hover-capable input only — a tap never leaves this shade behind. */
.pp-hero-stage[data-theme="dark"] .pp-hero-controls :focus-visible { outline: none; box-shadow: var(--pp-focus-ring-on-dark); }
.pp-hero-stage[data-theme="light"] .pp-hero-controls :focus-visible { outline: none; box-shadow: var(--pp-focus-ring); }

/* ---------- Compact overlay (1025–1279) ---------- */
@media (max-width: 1279px) {
	.pp-hero-copy { max-width: 26rem; }
	.pp-hero-title { font-size: clamp(2.25rem, 3.4vw, 2.75rem); }
	.pp-hero-support { font-size: 16px; }
	.pp-hero-layer { padding-block: 48px 84px; }
}
/* ---------- Tablet overlay (900–1024) ---------- */
@media (max-width: 1024px) {
	.pp-hero-copy { max-width: 22rem; }
	.pp-hero-title { font-size: 2.25rem; }
	.pp-hero-support { font-size: 15px; }   /* R2 lab: keeps the line's end inside the local band at the tightest overlay tier */
	.pp-hero-layer { padding-block: 40px 80px; }
}

/* ---------- STACK mode (≤ 899): artwork band first (in flow, aspect-ratio
   sized), copy below on the world's bottom-row colours. The copy area's
   approved height is a MINIMUM: legitimate long content grows it downward
   (H-1 §3.2) while the artwork band above stays visually stable. The seam
   treatment (Navy tint over the copy on the world colours, feathering up
   across the artwork seam) is attached to the copy layer itself, so it
   follows the real boundary at every content length. ---------- */
@media (max-width: 899px) {
	.pp-hero-art {
		position: relative; inset: auto;
		width: 100%; aspect-ratio: var(--pp-hero-art-ratio);
		background: transparent;
	}
	.pp-hero-art::after { display: none; }
	.pp-hero-art img { position: absolute; inset: 0; left: 0; width: 100%; height: 100%; object-fit: cover; object-position: 50% 50%; }
	.pp-hero-slide--campaign { background: var(--pp-hero-world-b); }
	.pp-hero-scrim { display: none; }
	.pp-hero-copy::before { display: none; }   /* the stack seam treatment below already gives ≥ 5:1 */
	.pp-hero-layer {
		min-height: var(--pp-hero-copy-h-t);
		align-items: center; padding-block: 20px 56px;
		background: linear-gradient(180deg,
			rgba(var(--pp-hero-navy-rgb), calc(var(--pp-hero-scrim) * .9)) 0%,
			rgba(var(--pp-hero-navy-rgb), var(--pp-hero-scrim)) 100%);
	}
	.pp-hero-layer::before { /* feather up across the artwork seam (the lab's 56px + 4px ramp) */
		content: ""; position: absolute; bottom: 100%; left: 0; right: 0; height: 60px; pointer-events: none;
		background: linear-gradient(180deg, rgba(var(--pp-hero-navy-rgb), 0), rgba(var(--pp-hero-navy-rgb), calc(var(--pp-hero-scrim) * .9)));
	}
	.pp-hero-copy { max-width: 36rem; width: 100%; }
	.pp-hero-title { font-size: clamp(2rem, 4.2vw, 2.5rem); max-width: 18ch; margin-bottom: 10px; }
	.pp-hero-eyebrow { margin-bottom: 10px; }
	.pp-hero-support { font-size: 15px; margin-bottom: 18px; max-width: 40ch; }   /* stack: the full-width seam scrim carries contrast — no band cap */
	.pp-hero-actions { max-width: none; }
	.pp-hero[data-ready] .pp-hero-controls { justify-content: center; bottom: 8px; }
}

@media (max-width: 640px) {
	.pp-hero-art { aspect-ratio: var(--pp-hero-art-ratio-m); }
	.pp-hero-layer { min-height: var(--pp-hero-copy-h); padding-block: 18px 52px; }
	.pp-hero-title { font-size: clamp(2rem, 8.4vw, 2.5rem); max-width: none; }
	.pp-hero-actions { flex-direction: column; align-items: stretch; gap: 4px; }
	.pp-hero-actions .pp-btn { justify-content: center; width: 100%; }
	.pp-hero-actions .pp-home-textlink { justify-content: center; }
	.pp-hero[data-ready] .pp-hero-controls { bottom: 6px; }
}

/* ---------- HD.1 final correction — the transition area above the hero ----------
   At >= 768 the header is FIXED over a constant spacer of its full height. When a fast scroll-up runs ahead of the
   header's scroll-linked height (a frame or two), part of that spacer shows between the header and the hero; it is
   transparent, so it showed the white page. The hero paints that area with its own world: the first slide's measured
   bottom-row gradient (--pp-hero-top, inc/hero.php) — in the overlay layout under the same directional copy scrim as
   the artwork (the stops of .pp-hero-scrim above); the stacked layout has no scrim. The area sits behind the header
   at rest, so nothing changes there; only a hero that is the page's first block and has a measured world paints it. */
@media screen and (min-width: 768px) {
	#pp-main > .pp-hero[data-pp-hero-top]:first-child::before {
		content: "";
		position: absolute;
		inset-inline: 0;
		bottom: 100%;
		height: var(--pp-header-full-h, 150px);
		background: var(--pp-hero-top);
		pointer-events: none;
	}
}
@media screen and (min-width: 900px) {
	#pp-main > .pp-hero[data-pp-hero-top]:first-child::before {
		background:
			linear-gradient(90deg,
				rgba(var(--pp-hero-navy-rgb), var(--pp-hero-top-scrim, var(--pp-hero-scrim))) 0%,
				rgba(var(--pp-hero-navy-rgb), var(--pp-hero-top-scrim, var(--pp-hero-scrim))) calc(var(--pp-hero-scrim-x1) - 230px),
				rgba(var(--pp-hero-navy-rgb), calc(var(--pp-hero-top-scrim, var(--pp-hero-scrim)) * .85)) calc(var(--pp-hero-scrim-x1) - 160px),
				rgba(var(--pp-hero-navy-rgb), calc(var(--pp-hero-top-scrim, var(--pp-hero-scrim)) * .45)) calc(var(--pp-hero-scrim-x1) - 90px),
				rgba(var(--pp-hero-navy-rgb), 0) var(--pp-hero-scrim-x1)),
			var(--pp-hero-top);
	}
}
