/*
 * The pre-event hero (`src/lib/site/opening.ts`, `visual/opening.ts`) and its sea
 * (`src/lib/site/visual/`, for a tenant whose brand names one). First the sea: a school of ASCII
 * fish across the whole top of the page while the countdown is up, behind every word. The layer
 * sits in the root stacking context at z-index -1 (above the page's ground, under all content),
 * edge to edge, from the page's top to a little below the hero, fading into the ground before the
 * courts. It reserves nothing and moves nothing. The script sets its height, lets the school swim in
 * and removes the layer when play starts; without JS a static scatter (`<noscript>`) stands in.
 * Colours are the tenant's tokens.
 */
.ld-sea {
	position: absolute;
	z-index: -1;
	inset-block-start: 0;
	inset-inline: 0;
	/* The recap sizes it around its champions block (`--ld-sea-h`, `visual/recap.ts`); the
	   countdown's page keeps this first-screen height until its script stretches it. */
	block-size: var(--ld-sea-h, 720px);
	pointer-events: none;
	overflow: hidden;
	-webkit-mask-image: linear-gradient(180deg, #000 calc(100% - 180px), transparent);
	mask-image: linear-gradient(180deg, #000 calc(100% - 180px), transparent);
}
.ld-sea-still,
.ld-sea-canvas {
	position: absolute;
	inset: 0;
	display: block;
	inline-size: 100%;
	block-size: 100%;
}
.ld-sea-still .is-wake {
	fill: var(--muted);
	opacity: 0.25;
}
.ld-sea-still .is-school {
	fill: var(--muted);
	opacity: 0.5;
}
.ld-sea-still .is-mark {
	fill: var(--accent);
	opacity: 0.7;
}
/* The still is composed for the open water beside the words on a desk; a phone keeps the ground. */
@media (max-width: 699px) {
	.ld-sea-still {
		display: none;
	}
}

/*
 * The start (`start.ts`): the live cards wait, invisible but in place, until the school's shoal
 * lands on them, then arrive. The script clears the mark when the show ends, whatever happened.
 */
[data-sea-arrive='wait'] {
	opacity: 0;
	transform: translateY(12px);
}
/* The bar's pill keeps its place: it only turns up, LIVE, as the start's ring reaches it. */
.ld-trust[data-sea-arrive] {
	transform: none;
}
[data-sea-arrive='in'] {
	transition:
		opacity 0.24s ease-out,
		transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
}

/*
 * The opening: the hero before the start. The countdown sits in the middle of the water with the
 * date line above it, its unit labels under it and one bracket corner; a scroll cue points to the
 * teams. On a phone it fills the first screen under the bar (`--ld-bar-h`, `bar.ts`); on a desk it
 * is a tall stage, capped. At zero the same place turns to the hold (`data-count="0"` on the
 * countdown box): the hold word, its line, the date without the time and the landing strip.
 */
.ld-hero-row[data-kind='countdown'] {
	margin-block: 0;
}
:root {
	/* The opening's countdown (and the hold word in its place, and its ghost at the start) is the
	   first screen's dominant element: sized by the width and by the height. */
	--ld-open-num: clamp(72px, min(20vw, 34vh), 300px);
	/* The bar's height before its script publishes it (`--ld-bar-h`, `bar.ts`): its real height,
	   so the first paint without script already stands where it will stay. */
	--ld-bar-first: 65px;
	/* The unit labels' zone under the numerals (their gap, the label line): the hold word stands
	   on its top edge, the hold's line starts where the labels did. */
	--ld-cd-labels: calc(
		var(--ld-s2, 8px) + 8px + clamp(12px, calc(var(--ld-open-num) * 0.055), 17px)
	);
	/* The hold word's width per px of its size (GLEICH LIVE, 600, 0.02em): Oswald's once it has
	   loaded (`html.ld-fonts`, `client.ts`), the wider fallback face's before or without it. */
	--ld-hold-ratio: 5.95;
	/* The hold word in the numerals' place, as large as one line of it allows and never wider than
	   the opening (`100cqi`): 48 px keep its corner (22 px) and some air inside. */
	--ld-hold-size: min(var(--ld-open-num), 15vw, calc((100cqi - 48px) / var(--ld-hold-ratio)));
	/* Where the countdown stands, from the opening's top: the same before zero and after it, so
	   the hold word takes the numerals' place and what the hold adds (its line, the strip) comes
	   in below without moving it. A little above the middle; on a phone a little lower. */
	--ld-open-top: clamp(0px, calc((100vh - 480px) * 0.3), 240px);
}
@supports (height: 100svh) {
	:root {
		--ld-open-top: clamp(0px, calc((100svh - 480px) * 0.3), 240px);
	}
}
/* Live any moment is longer than Gleich live: the same one line, a size smaller. */
html[lang='en'] {
	--ld-hold-ratio: 9.1;
}
html.ld-fonts {
	--ld-hold-ratio: 5.05;
}
html.ld-fonts[lang='en'] {
	--ld-hold-ratio: 7.47;
}
.ld-opening {
	/* The hold word measures itself against the opening (`100cqi`), not the viewport. */
	container-type: inline-size;
	display: flex;
	flex-direction: column;
	align-items: center;
	text-align: center;
	box-sizing: border-box;
	/* On a desk the first screen is one composition, closed at its foot: the countdown, the cue and
	   the page's intro under it (`--ld-intro-h`, its height and gap, measured by
	   `visual/opening.ts`), with 28 px of air under the buttons, less than the 48 px before the
	   teams: they begin below the fold at any height. */
	min-block-size: max(
		480px,
		calc(100vh - var(--ld-bar-h, var(--ld-bar-first)) - 20px - var(--ld-intro-h, 58px) - 28px)
	);
	min-block-size: max(
		480px,
		calc(100svh - var(--ld-bar-h, var(--ld-bar-first)) - 20px - var(--ld-intro-h, 58px) - 28px)
	);
	padding-block: calc(var(--ld-s6, 32px) + var(--ld-open-top)) var(--ld-s4, 16px);
}
/* The hold is the whole first screen on every size: its word, line, strip and the water; the page
   below begins under the fold. */
.ld-opening.is-hold {
	min-block-size: calc(100vh - var(--ld-bar-h, var(--ld-bar-first)) - 20px);
	min-block-size: calc(100svh - var(--ld-bar-h, var(--ld-bar-first)) - 20px);
}
.ld-open-block {
	display: grid;
	grid-template-areas: 'date' 'box' 'line' 'first';
	justify-items: center;
	gap: var(--ld-s3, 12px);
	margin-block-end: var(--ld-s5, 24px);
}
/* The countdown's date line and the hold's share one place, as do the numerals and the hold word:
   at zero one fades into the other where it stands (see the hold below). */
.ld-open-block > .ld-open-date {
	grid-area: date;
	align-self: end;
}
.ld-open-block > .ld-cd-box {
	grid-area: box;
}
/* The hold's line takes the unit labels' place at the box's foot, right under the word, and grows
   downward when it needs a second line: its row's gap and the labels' zone are pulled back. */
.ld-open-block > .ld-hold-line {
	grid-area: line;
	margin-block-start: calc(var(--ld-s2, 8px) - var(--ld-s3, 12px) - var(--ld-cd-labels));
}
.ld-open-block > .ld-cd-first {
	grid-area: first;
}
.ld-opening p {
	margin: 0;
}
/* The small words over the water keep a soft pool of ground behind them. */
.ld-open-date,
.ld-opening .ld-cd-unit small,
.ld-cue {
	background: radial-gradient(
		closest-side,
		color-mix(in srgb, var(--ink) 78%, transparent),
		transparent
	);
	padding: 4px 14px;
}
.ld-open-date > span {
	display: inline-block;
}
/* On a desk the place follows the date after the dot; on a phone it takes its own line. */
.ld-open-venue::before {
	content: '·';
	padding-inline: 0.45em;
}
.ld-open-date {
	font: 600 clamp(13px, calc(var(--ld-open-num) * 0.062), 20px) / 1.3 var(--font-display);
	letter-spacing: var(--ld-track-label, 0.14em);
	text-transform: uppercase;
	color: var(--muted);
}
.ld-opening .ld-cd-box {
	position: relative;
}
.ld-opening .ld-cd {
	--cd-gap: clamp(14px, 3vw, 32px);
	justify-content: center;
	margin: 0;
	/* A number line and its labels even when there are no numbers (the hold, a page opened in it):
	   the hold word stands in this box, and nothing under it moves at zero. */
	min-block-size: calc(var(--ld-open-num) * 0.92 + var(--ld-cd-labels));
	flex-wrap: nowrap;
	font: 600 var(--ld-open-num) / 0.92 var(--font-display);
	letter-spacing: var(--ld-track-display, 0.02em);
}
.ld-opening .ld-cd-unit b {
	/* A number never breaks (the page lets long words break anywhere). */
	white-space: nowrap;
	overflow-wrap: normal;
	letter-spacing: 0;
}
/* One slot per digit, as wide as the widest digit (the zero, `1ch`; the face has no tabular
   figures): a changing second never moves another number, a colon or a label. */
.ld-opening .ld-cd-d {
	display: inline-block;
	inline-size: 1.04ch;
	text-align: center;
}
.ld-opening .ld-cd-unit {
	gap: var(--ld-s2, 8px);
}
.ld-opening .ld-cd-unit small {
	font: 600 clamp(12px, calc(var(--ld-open-num) * 0.055), 17px) / 1 var(--font-display);
	letter-spacing: var(--ld-track-label, 0.14em);
	color: var(--muted);
}
/* Magenta keeps to its four roles: the colons between the units are the countdown's ink. */
.ld-opening .ld-cd-unit + .ld-cd-unit::before {
	color: var(--muted);
}
/* The single static signature of the swarm: one bracket corner at the countdown's foot. */
.ld-open-corner {
	position: absolute;
	inset-inline-end: -22px;
	inset-block-end: 14px;
	inline-size: 22px;
	block-size: 22px;
	border-inline-end: 2px solid var(--accent);
	border-block-end: 2px solid var(--accent);
}
.ld-opening .ld-cd-first {
	font: 500 var(--ld-t-body, 15px) / 1.4 var(--font-body);
	color: var(--muted);
}
.ld-cue {
	margin-block-start: auto;
	font: 600 12px / 1 var(--font-display);
	letter-spacing: var(--ld-track-label, 0.14em);
	text-transform: uppercase;
	color: var(--muted);
	text-decoration: none;
	transition: opacity var(--ld-m-change, 240ms) ease-out;
}
/* A down mark (the × would read as close). */
.ld-cue-down {
	display: inline-block;
	inline-size: 7px;
	block-size: 7px;
	margin-inline-start: 10px;
	border-inline-end: 1.5px solid currentColor;
	border-block-end: 1.5px solid currentColor;
	rotate: 45deg;
	translate: 0 -3px;
}
.ld-cue:focus-visible {
	outline: 2px solid var(--text);
	outline-offset: 4px;
}
/* It fades on the first scroll, and is gone for the pointer and the keyboard. */
.ld-opening[data-scrolled] .ld-cue {
	opacity: 0;
	visibility: hidden;
	transition:
		opacity var(--ld-m-change, 240ms) ease-out,
		visibility 0s linear var(--ld-m-change, 240ms);
}
/* The link down to the teams stops them under the bar. */
#ld-teams {
	scroll-margin-top: calc(var(--ld-bar-h, var(--ld-bar-first)) + 16px);
}
.ld-sr {
	position: absolute;
	inline-size: 1px;
	block-size: 1px;
	overflow: hidden;
	clip-path: inset(50%);
	white-space: nowrap;
}

/* The hold. Zero is one passage, not a replace: the numerals shrink a little into the hold word
   as it decodes in their place, the date line fades into the hold's, the corner moves to the
   word's end, the cue fades; the line and the strip arrive below (`is-arriving`). */
.ld-hold-only,
.ld-hold-line .is-long {
	display: none;
}
.ld-opening.is-hold .ld-hold-only {
	display: block;
}
.ld-opening.is-hold .ld-hold-line {
	display: flex;
}
/* What arrives waits until what leaves is nearly gone: never text over text. */
.ld-opening .ld-open-date,
.ld-opening .ld-cd,
.ld-opening .ld-open-corner,
.ld-cd-box > .ld-hold-word,
.ld-opening .ld-cue {
	transition:
		opacity 240ms ease-out 140ms,
		transform 240ms ease-out 140ms,
		visibility 0s linear 140ms;
}
/* Present before zero, invisible until it. */
.ld-opening .ld-open-date.ld-hold-only,
.ld-cd-box > .ld-hold-word.ld-hold-only {
	display: block;
}
.ld-opening:not(.is-hold) .ld-open-date.ld-hold-only,
.ld-opening:not(.is-hold) .ld-cd-box > .ld-hold-word,
.ld-opening.is-hold .ld-open-date:not(.ld-hold-only),
.ld-opening.is-hold .ld-cd,
.ld-opening.is-hold .ld-open-corner,
.ld-opening.is-hold .ld-cue {
	opacity: 0;
	visibility: hidden;
	transition:
		opacity 160ms ease-in,
		transform 160ms ease-in,
		visibility 0s linear 160ms;
}
.ld-opening.is-hold .ld-cd {
	transform: scale(0.8);
}
/* The word on the numerals' foot, centred across it: the line under it keeps the labels' gap
   whatever the word's size. */
.ld-cd-box > .ld-hold-word {
	position: absolute;
	inset-inline-start: 50%;
	inset-block-end: var(--ld-cd-labels);
	translate: -50% 0;
	margin: 0;
}
.ld-cd-box > .ld-hold-word::after {
	content: '';
	position: absolute;
	inset-inline-end: -22px;
	inset-block-end: 0.1em;
	inline-size: 22px;
	block-size: 22px;
	border-inline-end: 2px solid var(--accent);
	border-block-end: 2px solid var(--accent);
}
.ld-opening[data-hold-long] .ld-hold-line .is-short {
	display: none;
}
.ld-opening[data-hold-long] .ld-hold-line .is-long {
	display: inline;
}
.ld-hold-word {
	font: 600 var(--ld-hold-size) / 0.92 var(--font-display);
	letter-spacing: var(--ld-track-display, 0.02em);
	text-transform: uppercase;
	color: var(--text);
	white-space: nowrap;
}
.ld-hold-line {
	align-items: center;
	justify-content: center;
	gap: 10px;
	max-inline-size: 34ch;
	font: 400 var(--ld-t-body, 15px) / 1.45 var(--font-body);
	color: var(--text);
}
.ld-hold-line .ld-dot {
	flex: none;
	inline-size: 8px;
	block-size: 8px;
	border-radius: 50%;
	background: var(--accent);
	box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 22%, transparent);
}

/* Days and hours: each unit named in words under its number and no colon between them, so the
   two numbers never read as a clock time. */
.ld-opening .ld-cd-unit[data-unit='d'] + .ld-cd-unit::before {
	content: none;
}
.ld-opening .ld-cd-unit[data-unit='d'] {
	margin-inline-end: calc(var(--cd-gap) * 0.6);
}
.ld-opening .ld-cd-unit[data-unit='d'] small,
.ld-opening .ld-cd-unit[data-unit='d'] ~ .ld-cd-unit small {
	font-size: clamp(14px, calc(var(--ld-open-num) * 0.1), 30px);
	color: var(--text);
}

/* The landing strip: round 1, court by court, where the shoals will land. */
.ld-strip {
	display: grid;
	grid-template-columns: repeat(4, minmax(0, 1fr));
	gap: 0 var(--ld-s5, 24px);
	inline-size: min(100%, 1280px);
	margin: var(--ld-s7, 48px) 0 0;
	padding: 0;
	list-style: none;
	text-align: start;
}
.ld-strip-court {
	display: grid;
	gap: 6px;
	padding-block: var(--ld-s3, 12px);
	border-block-start: 1px solid var(--ld-hair-strong, rgba(255, 255, 255, 0.16));
}
.ld-strip-pair {
	/* 14 px: a pairing and its "gegen" line each fit one line of a desk's column. */
	font: 400 14px / 1.4 var(--font-body);
	color: var(--text);
}
.ld-strip-vs {
	color: var(--muted);
}
.ld-strip-a,
.ld-strip-b {
	display: block;
}
.ld-opening > .ld-hold-only {
	inline-size: 100%;
	display: none;
	justify-items: center;
}
.ld-opening.is-hold > .ld-hold-only {
	display: grid;
}

@media (max-width: 899px) {
	/* A tablet: the courts two by two, the countdown a little lower. */
	.ld-strip {
		grid-template-columns: repeat(2, minmax(0, 1fr));
		margin-block-start: var(--ld-s6, 32px);
		text-align: center;
	}
	:root {
		--ld-open-top: clamp(0px, calc((100vh - 480px) * 0.4), 240px);
	}
	@supports (height: 100svh) {
		:root {
			--ld-open-top: clamp(0px, calc((100svh - 480px) * 0.4), 240px);
		}
	}
	.ld-strip-court {
		justify-items: center;
		padding-block: var(--ld-s3, 12px);
	}
}
@media (max-width: 640px) {
	:root {
		--ld-bar-first: 61px;
	}
	/* The phone's opening is the whole first screen, the cue at its foot above the browser's own
	   bar (`svh`) and the home indicator. */
	.ld-opening {
		min-block-size: calc(100vh - var(--ld-bar-h, var(--ld-bar-first)) - 20px);
		min-block-size: calc(100svh - var(--ld-bar-h, var(--ld-bar-first)) - 20px);
		padding-block-end: calc(var(--ld-s4, 16px) + env(safe-area-inset-bottom, 0px));
	}
	/* The place on a line of its own under the date. */
	.ld-open-date > .ld-open-venue {
		display: block;
	}
	.ld-open-venue::before {
		content: none;
	}
	.ld-open-corner,
	.ld-cd-box > .ld-hold-word::after {
		inset-inline-end: -12px;
		inline-size: 16px;
		block-size: 16px;
	}
	/* A phone: the courts one under the other, close enough that the hold ends on the first
	   screen; the countdown a little lower than on a desk. */
	.ld-strip {
		grid-template-columns: minmax(0, 1fr);
		margin-block-start: var(--ld-s5, 24px);
	}
	.ld-strip-court {
		gap: 4px;
		padding-block: var(--ld-s2, 8px);
	}
	:root {
		--ld-open-top: clamp(0px, calc((100vh - 668px) * 0.83), 240px);
	}
	@supports (height: 100svh) {
		:root {
			--ld-open-top: clamp(0px, calc((100svh - 668px) * 0.83), 240px);
		}
	}
}
/* The player open before the start (`stream.ts`): the opening gives up its full-screen air, so
   the player under it stands on the first screen. */
html[data-player='open'] .ld-opening,
html[data-player='open'] .ld-opening.is-hold {
	min-block-size: 0;
	padding-block-start: var(--ld-s5, 24px);
}
/* Short screens (a phone on its side): the content's own height, nothing clipped. */
@media (max-height: 599px) {
	.ld-opening,
	.ld-opening.is-hold {
		min-block-size: auto;
	}
}

@media (prefers-reduced-motion: no-preference) {
	/* The countdown's one change of format: the new numbers fade in where they now stand. */
	.ld-opening .ld-cd.is-reformat {
		animation: ld-cd-reformat 560ms var(--ld-ease-out, ease-out) both;
	}
	.ld-cue-down {
		animation: ld-bob 1.8s ease-in-out infinite;
	}
	.ld-hold-line .ld-dot {
		animation: ld-hold-pulse 2.2s ease-in-out infinite;
	}
	/* Once, when the hold begins (`visual/opening.ts` adds the class, never a repaint). */
	.ld-opening.is-arriving .ld-strip-court {
		animation: ld-strip-in var(--ld-m-arrive, 520ms) var(--ld-spring, ease-out) both;
	}
	.ld-opening.is-arriving .ld-strip-court:nth-child(2) {
		animation-delay: 90ms;
	}
	.ld-opening.is-arriving .ld-strip-court:nth-child(3) {
		animation-delay: 180ms;
	}
	.ld-opening.is-arriving .ld-strip-court:nth-child(4) {
		animation-delay: 270ms;
	}
	/* After the labels it replaces have faded. */
	.ld-opening.is-arriving .ld-hold-line {
		animation: ld-strip-in var(--ld-m-arrive, 520ms) var(--ld-spring, ease-out) 140ms both;
	}
}
@keyframes ld-bob {
	50% {
		transform: translateY(4px);
	}
}
@keyframes ld-hold-pulse {
	50% {
		box-shadow: 0 0 0 7px color-mix(in srgb, var(--accent) 8%, transparent);
	}
}
@keyframes ld-cd-reformat {
	from {
		opacity: 0;
		transform: scale(0.97);
	}
}
@keyframes ld-strip-in {
	from {
		opacity: 0;
		transform: translateY(10px);
	}
}

/*
 * The hold's ghosts at the start (`visual/mount.ts`): copies of the hold word and the landing
 * strip's courts, over the page while they fly into the empty places of the live cards.
 */
.ld-morph {
	position: absolute;
	inset: 0 auto auto 0;
	z-index: 5;
	pointer-events: none;
}
.ld-ghost {
	position: absolute;
	box-sizing: border-box;
	margin: 0;
	list-style: none;
}
.ld-ghost.ld-hold-only {
	display: block;
	text-align: center;
}
.ld-ghost.ld-hold-line {
	display: flex;
}
.ld-ghost .is-long {
	display: inline;
}
.ld-ghost[data-hold-word] {
	transform-origin: 50% 50%;
	will-change: transform, opacity;
}
@media (max-width: 899px) {
	.ld-ghost.ld-strip-court {
		text-align: center;
		justify-items: center;
	}
}
