/* ============================================================================
   THE SNAP SYSTEM — the homepage (Design System §6)

   The site's signature and the highest-risk responsive work on it.

   Kept from the PoC, deliberately:
     - 100svh for sections, 100lvh for the fixed dot rail. The correct pair for
       mobile address-bar collapse. Do not "fix" these to vh.
     - scroll-snap-align: start, with the document as the scroller.
     - pointer-events: none on the header, auto on its controls (06-chrome).

   The grid, from the homepage comp: one inset on every side of the well
   (--inset-edge-x, shared with the header, so the wordmark, the rail and the
   category tag all hang off the same two vertical lines); the rail and the
   content block separated by a full --space-xl gutter; the product name in
   the poster voice; the two buttons sharing the content block's width.

   Fixed from the PoC:
     - The header-overlap formula and --content-top-pad are gone (dead code,
       written for center-aligned snap). Top padding is just --header-height.
     - calc(100svh - 24px) → 100svh. The duplicate padding declaration is gone.
     - The dots navigate, with 24×24 targets.
   ============================================================================ */

@layer pages {

/* ── Snap behaviour ───────────────────────────────────────────────────────────
   On the page that has snap sections only. The launch page snaps the same way
   at every width: mandatory, phone to desktop. A section taller than the
   screen stays readable — launch.js gives every section a second snap point
   at its bottom edge, and browsers let you scroll freely inside a snap area
   taller than the viewport. No snap at all under reduced motion. */

html:has(.snapPage) {
	scroll-snap-type: y mandatory;
	/* Snap positions are the section tops. The site-wide header clearance
	   would shrink the snapport and leave a strip of the previous section
	   showing under the header. */
	scroll-padding-top: 0;
	/* Overscroll past the top or bottom shows brown, not cream. */
	background: var(--color-surface-brand);
}

/* The launch page is brown throughout. */
html:has(.snapPage) body {
	background: var(--color-surface-brand);
}

/* A section's bottom edge is a snap point too (launch.js adds a .snapEnd to
   each), so a section up to twice the viewport's height shows all of itself
   in two stops even where a browser won't scroll freely inside it. */
.snapEnd {
	position: absolute;
	inset-inline-start: 0;
	bottom: 0;
	width: 1px;
	height: 1px;
	pointer-events: none;
	scroll-snap-align: end;
}

/* When a section outgrows even that — text zoomed to 200%, a very short
   landscape phone — mandatory snap could skip past the middle of it.
   launch.js sets .snapRelaxed while any section is more than twice the
   viewport's height, and snap only assists. */
html.snapRelaxed:has(.snapPage) {
	scroll-snap-type: y proximity;
}

@media (prefers-reduced-motion: reduce) {
	html:has(.snapPage),
	html.snapRelaxed:has(.snapPage) { scroll-snap-type: none; }
}

/* ── Section ──────────────────────────────────────────────────────────────── */

.snapSection {
	container: snapsection / inline-size;
	position: relative;
	isolation: isolate;
	/* min-height + height: auto is an ACCESSIBILITY FIX, not polish. Text
	   zoomed to 200% makes content taller than a fixed-height section, and
	   mandatory snap would refuse to let anyone scroll through it. Do not
	   simplify this back to a fixed height. */
	min-height: 100svh;
	height: auto;
	scroll-snap-align: start;
	background: var(--color-surface-brand);

	/* A focused section (moved to by a dot) doesn't get a page-sized ring. */
	&:focus { outline: none; }

	/* The scrim: above the media, below the content, never a background on
	   the media. Top AND bottom stops are --scrim-strong in both recipes — the
	   top one carries the transparent header. */
	&::after {
		content: "";
		position: absolute;
		inset: 0;
		z-index: -1;
		pointer-events: none;
		background: var(--scrim-from-top);
	}

	&.corner-bottom-left::after,
	&.corner-bottom-right::after {
		background: var(--scrim-from-bottom);
	}

	/* Above 1024px every variant's content collapses to the bottom edge (see
	   the corner variants below), so the scrim recipe follows it there. A
	   media query rather than the snapsection container query: ::after belongs
	   to the container itself, which can't query its own size. The section is
	   always viewport-wide, so the two agree. */
	@media (min-width: 1024px) {
		&::after {
			background: var(--scrim-from-bottom);
		}
	}
}

/* ── Media ────────────────────────────────────────────────────────────────── */

.snapMedia {
	position: absolute;
	inset: 0;
	z-index: -2;
	overflow: hidden;
	background: var(--color-surface-brand);

	img,
	video {
		position: absolute;
		inset: 0;
		width: 100%;
		height: 100%;
		object-fit: cover;
		background: transparent;
	}
}

/* The video fades in over the poster once it is actually playing, so a slow
   or refused load never flashes an empty frame. */
.snapVideo {
	opacity: 0;
	transition: opacity var(--duration-slow) ease;

	&.isPlaying { opacity: 1; }
}

/* ── The well ─────────────────────────────────────────────────────────────────
   The corner is the corner of a well, not of the viewport. The photograph
   bleeds full width; the content anchors to a container capped at
   --wrap-wide, so at 2560px the composition reads as it does at 1440. */

.snapInner {
	display: flex;
	flex-direction: column;
	justify-content: space-between;
	gap: var(--space-l);
	width: 100%;
	max-width: var(--wrap-wide);
	min-height: 100svh;
	margin-inline: auto;
	padding: var(--header-height) var(--inset-edge-x) var(--inset-edge-y);
	/* The fixed dot rail owns a column at the right edge of the viewport;
	   right-anchored content (a vertical spec rail, the category tag) stays
	   a clear gutter out of it. */
	padding-inline-end: max(var(--inset-edge-x), calc(var(--target-min) + var(--space-l)));
}

.snapBody {
	display: flex;
	align-items: flex-start;
	/* The rail is a caption, not a column of the content: a full gutter
	   between them, so the rail never reads as the name's first letter. */
	gap: var(--space-xl);
}

.snapContent {
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	gap: var(--space-m);
	flex: 1;
	min-width: 0;

	/* The eyebrow sits tight on the name it introduces. */
	> .eyebrow + * {
		margin-top: calc(var(--space-xs) * -1);
	}

	/* Two buttons share the block's width equally (the comp), up to a
	   sensible pair width on a wide screen. */
	.btnRow {
		width: 100%;
		max-width: 26rem;
		margin-top: var(--space-2xs);

		/* Side by side while both fit; stacked when they can't (text zoomed
		   to 200%), never pushed off the side of the screen. */
		> *, > form { flex: 1 1 8rem; min-width: 0; }
		> form > .btn { width: 100%; }
		.btn { padding-inline: 1em; }

		/* A lone button is content-width, not a bar across the block. */
		> :only-child { flex: 0 1 auto; min-width: min(12.5rem, 100%); }
	}
}

/* The spec rail: a vertical caption the height of the content block, set
   bottom-to-top and aligned to the block's baseline. */
.snapRail {
	flex-shrink: 0;
	align-self: flex-end;
	writing-mode: vertical-rl;
	rotate: 180deg;
	/* In vertical text, max-height caps the line length: a long rail — or one
	   zoomed to 200% — wraps into a second column instead of running out of
	   the section. */
	max-height: 60svh;
}

.snapMeta {
	display: flex;
	align-items: flex-end;
	justify-content: space-between;
	gap: var(--space-s);
}

.snapCategory {
	writing-mode: vertical-rl;
	rotate: 180deg;
	max-height: 40svh;
}

/* ── Corner variants ──────────────────────────────────────────────────────────
   top/bottom — which edge the content block sits at (the meta row takes the
   other). left/right — which side the rail and stock status hug; the category
   tag takes the opposite side. */

.corner-top-right,
.corner-bottom-right {
	.snapBody,
	.snapMeta {
		flex-direction: row-reverse;
	}
	/* The block hangs off the right edge, but its type stays left-aligned:
	   ragged-left paragraphs read badly, and the name, copy and buttons keep
	   one shared left edge inside the block. */
	.snapContent {
		flex: 0 1 auto;
	}
}

.corner-bottom-left,
.corner-bottom-right {
	.snapInner {
		flex-direction: column-reverse;
	}
	.snapBody {
		align-items: flex-end;
	}
	.snapMeta {
		align-items: flex-start;
	}
}

/* Above 1024px the four corners collapse to two. More of the section is
   visible at once, so left/right alternation carries the rhythm and
   top/bottom variation reads as inconsistency. Both collapse to the bottom
   edge, where the content sits clear of the header. */
@container snapsection (min-width: 1024px) {
	.snapInner {
		flex-direction: column-reverse;
	}
	.snapBody {
		align-items: flex-end;
	}
	.snapMeta {
		align-items: flex-start;
	}
	/* Bring the far edge of the content block in, so the diagonal between
	   the block and the meta row doesn't outgrow the type. */
	.snapContent {
		max-width: 52rem;
	}
}

/* Copy on photography stays at its class measure; the block stops the
   buttons wandering across a wide screen. */
.snapCopy {
	max-width: 36ch;
}

/* ── Hero ─────────────────────────────────────────────────────────────────── */

.snapHero {
	.snapCopy {
		max-width: 40ch;
	}
}

/* ── Closing section ──────────────────────────────────────────────────────────
   A brown band (.themeDark), no media, no scrim. */

.snapClosing {
	/* Closing content sits low in the band, leading into the footer below
	   rather than floating mid-screen above a second brown field. Top-down
	   at every width: above 1024 the snap wells flip to column-reverse for
	   the corner layouts, which turned this flex-end into the TOP. */
	.snapInner {
		flex-direction: column;
		justify-content: flex-end;
	}

	/* The footer is NOT a snap point (Design System §6.3). But under
	   mandatory snap, content past the last snap position is unreachable —
	   the page snaps back. So the closing section's snap *area* is extended
	   down over the footer: a snap area taller than the viewport lets the
	   browser scroll freely inside it, and the footer comes into reach
	   without ever becoming a snap target itself. */
	scroll-margin-bottom: 200lvh;

	&::after { content: none; }
}

.snapClosingContent {
	display: grid;
	justify-items: start;
	gap: var(--space-l);
}

.snapClosingLinks {
	display: flex;
	flex-wrap: wrap;
	gap: 0 var(--space-l);

	/* Big italic words need to say "link": an arrow that leans in on hover
	   and focus, and an underline. */
	a {
		display: inline-flex;
		align-items: center;
		gap: 0.15em;
		min-height: var(--control-height-compact);
		text-underline-offset: 0.15em;
		text-decoration-thickness: 2px;

		&:hover, &:focus-visible {
			text-decoration-line: underline;
			.snapClosingArrow { translate: 0.15em 0; opacity: 1; }
		}
	}
}

.snapClosingArrow {
	width: 0.6em;
	height: 0.6em;
	opacity: 0.6;
	transition:
		translate var(--duration-base) var(--ease-out),
		opacity var(--duration-base) var(--ease-out);
}

/* ── Holding page ─────────────────────────────────────────────────────────────
   The launch page: the snap system with no header. A hero on the poster
   (and loop, when there is one), then three plain bands — brown, paper, brown.
   The bands have no media, so no scrim. */

/* With no header, the wordmark is the page's masthead: centred, and
   larger than the header's. Its strong scrim band grows with it — the
   hero's scrim is re-cut to hold --scrim-strong through the masthead's
   height rather than the header's, the same guarantee for a taller mark. */
.holdingPage {
	--holding-mark-height: calc(var(--wordmark-height) * 1.4);
	--holding-mast-height: calc(var(--holding-mark-height) + var(--space-m) * 2);

	.snapHero::after {
		background: linear-gradient(to top,
			var(--scrim-strong) 0%, var(--scrim-soft) 35%, var(--scrim-soft) 70%,
			var(--scrim-strong) calc(100% - var(--holding-mast-height)), var(--scrim-strong) 100%);
	}
}

.holdingMast {
	position: absolute;
	inset-inline: 0;
	top: 0;
	display: flex;
	justify-content: center;
	padding: var(--space-m) var(--inset-edge-x);
	filter: var(--shadow-on-media);

	.wordmark {
		display: block;
		height: var(--holding-mark-height);
		width: auto;
	}
}

.holdingBand {
	/* No photograph, nothing to scrim. */
	&::after { content: none; }

	/* Top-down at every width. Above 1024 the snap sections' wells flip to
	   column-reverse for their corner layouts, which would turn this band's
	   flex-end (low) into the top of the screen. */
	.snapInner {
		flex-direction: column;
		justify-content: center;
	}

}

/* With no header to clear, the closing band still sits low, toward the
   bottom edge, as the homepage's does. */
.holdingBand.snapClosing {
	/* No footer below it, so no need to stretch its snap area over one. */
	scroll-margin-bottom: 0;

	.snapInner { justify-content: flex-end; }
}

.holdingStatement {
	display: grid;
	justify-items: start;
	gap: var(--space-l);
	width: 100%;

	/* The eyebrow sits tight on the line it introduces. */
	> .eyebrow + * {
		margin-top: calc(var(--space-m) * -1);
	}
}

.holdingCopy {
	display: grid;
	gap: var(--space-s);
}

/* The four collections as one line of display words, a yellow point between
   each. The point is a fill, never ink, so the action yellow is safe here. */
.holdingCategories {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0 0.28em;
	max-width: none;

	li {
		display: inline-flex;
		align-items: center;
	}

	/* After the word, not before the next: a wrapped line ends on a point
	   rather than starting with one. The lead-in clears the italic's
	   overhang so the point sits midway between words. */
	li:not(:last-child)::after {
		content: "";
		width: 0.16em;
		height: 0.16em;
		margin-inline-start: 0.24em;
		border-radius: var(--radius-round);
		background: var(--color-action);
	}
}

.holdingMakers {
	display: grid;
	gap: var(--space-s);
	width: 100%;
	margin-top: var(--space-m);

	ul {
		display: grid;
		/* Three across at desktop, so nine makers land as a square. */
		grid-template-columns: repeat(auto-fit, minmax(min(100%, 20rem), 1fr));
		gap: var(--space-m) var(--space-l);
	}

	li {
		display: grid;
		align-content: start;
		gap: var(--space-3xs);
		padding-top: var(--space-s);
		border-top: 1px solid var(--color-rule-strong);
	}
}

/* Stacked, one address to a line, never two sharing one. */
.holdingContactLinks {
	flex-direction: column;
}

.holdingLegal {
	margin-top: var(--space-l);
}

/* ── Pagination dots ──────────────────────────────────────────────────────── */

.snapDots {
	position: fixed;
	top: 0;
	right: 0;
	z-index: 30;
	/* The chapter marker stacks above the dots, in the rail's own column —
	   the one strip of the screen no section content may enter. */
	display: flex;
	flex-direction: column;
	justify-content: center;
	align-items: center;
	gap: var(--space-s);
	height: 100lvh;
	padding-inline-end: var(--space-2xs);
	pointer-events: none;
	filter: var(--shadow-on-media);
	transition:
		opacity var(--duration-base) var(--ease-out),
		visibility 0s linear 0s;

	ol {
		display: grid;
		pointer-events: auto;
	}

	/* Over a paper band the rail takes the page's ink, and the legibility
	   shadow — there for photography — comes off. */
	&.isOnPaper { filter: none; }

	/* Over the footer: faded out and out of the tab order. */
	&.isHidden {
		opacity: 0;
		visibility: hidden;
		transition:
			opacity var(--duration-base) var(--ease-out),
			visibility 0s linear var(--duration-base);
	}
}

/* The chapter marker: only where there is room for it beside the rail. Each
   new section's marker rolls up into place. */
.snapDotsMarker {
	display: none;

	/* Set vertically, bottom to top, like the sections' spec rails, so it
	   fits the dots' 24px column. */
	@media (min-width: 1024px) {
		display: flex;
		gap: var(--space-xs);
		width: var(--target-min);
		align-items: center;
		writing-mode: vertical-rl;
		rotate: 180deg;
		color: var(--color-text-1);
		white-space: nowrap;
		animation: markerRoll var(--duration-base) var(--ease-out) both;
	}
}

/* The link is the 24×24 target; the dot is drawn inside it. The current
   section's dot stretches into a short bar — shown by shape and opacity,
   not colour — and the stretch is animated, so moving between sections
   reads as the marker travelling. */
.snapDot {
	position: relative;
	display: grid;
	place-items: center;
	width: var(--target-min);
	height: var(--target-min);
	color: var(--color-text-1);

	&::before {
		content: "";
		width: 6px;
		height: 6px;
		border-radius: var(--radius-round);
		background: currentColor;
		opacity: 0.55;
		transition:
			opacity var(--duration-base) var(--ease-out),
			height var(--duration-sheet) var(--ease-sheet);
	}

	&[aria-current="true"]::before {
		opacity: 1;
		height: 18px;
	}

	&:hover::before {
		opacity: 1;
	}
}

} /* @layer pages */
