/* #region Batch stage timeline (overview panel) */
/*
	The illustrated life-stage timeline in the Batch Overview panel. Its markup comes from
	Views/Batches/Partials/_BatchStageTimelinePartial.cshtml, which only prints what the server computed (states,
	dates, lane geometry, the --k / --n intro order), and its art from the VectorPartials/Facility/BatchStages
	partials. It has its own .stage-* namespace because TransportDetails.cshtml keeps <timeline-stage>
	(vertical_timeline.js) and .vertical-timeline-container, so neither timeline can restyle the other.

	Colours are read through var(--...) only. The --stage-* tokens sit in both theme blocks of variables.css, derived
	from the existing palette: walnut ink (--global-font-color), gold (--primary-green / --darker-primary-green) and
	the card (--blue-gray). The contrast each pairing reaches is noted where its token is defined.
*/

/* Stage art in the dark theme: stop-color is a CSS property, so these rules beat the SVG's own attributes. The
	values are the --stage-dk-* tokens in the dark theme block of variables.css. */
[data-theme="dark"] :where(.stage-timeline) .stage-face .dk-wood0 {
	stop-color: var(--stage-dk-wood0);
}

[data-theme="dark"] :where(.stage-timeline) .stage-face .dk-wood1 {
	stop-color: var(--stage-dk-wood1);
}

[data-theme="dark"] :where(.stage-timeline) .stage-face .dk-wood2 {
	stop-color: var(--stage-dk-wood2);
}

[data-theme="dark"] :where(.stage-timeline) .stage-face .dk-shell0 {
	stop-color: var(--stage-dk-shell0);
}

[data-theme="dark"] :where(.stage-timeline) .stage-face .dk-shell1 {
	stop-color: var(--stage-dk-shell1);
}

[data-theme="dark"] :where(.stage-timeline) .stage-face .dk-shell2 {
	stop-color: var(--stage-dk-shell2);
}

[data-theme="dark"] :where(.stage-timeline) .stage-face .dk-root0 {
	stop-color: var(--stage-dk-root0);
}

[data-theme="dark"] :where(.stage-timeline) .stage-face .dk-root1 {
	stop-color: var(--stage-dk-root1);
}

[data-theme="dark"] :where(.stage-timeline) .stage-face .dk-root2 {
	stop-color: var(--stage-dk-root2);
}

[data-theme="dark"] :where(.stage-timeline) .stage-face .dk-deep0 {
	stop-color: var(--stage-dk-deep0);
}

[data-theme="dark"] :where(.stage-timeline) .stage-face .dk-deep1 {
	stop-color: var(--stage-dk-deep1);
}

[data-theme="dark"] :where(.stage-timeline) .stage-face .dk-deep2 {
	stop-color: var(--stage-dk-deep2);
}

/* ---------------------------------------------------------------- layout */
.stage-timeline {
	/* One design pixel: exactly 1px at the app's 13px root, and 12/13 or 11/13 of a pixel where global.css steps the
	   root down (12px under 1500px, 11px under 1100px). Every length in this stylesheet is a multiple of it and every
	   type size is in rem, so the whole timeline (coins, rail, seals, text) shrinks with the rest of the app instead
	   of staying a fixed slab of pixels on a smaller screen. Plain px lengths and max(px, rem) type floors once kept
	   it at its 13px-root size everywhere. Sizes quoted as px in this file's comments are design pixels.
	   The server's "+N" tag offset (_BatchStageTimelinePartial.cshtml) is in the same unit. */
	--u: calc(1rem / 13);
	/* Every row, and the finish line under a completed list, shares one node column, so all coins and seals centre
	   on the same rail whatever their size. Declared here, on the element that holds both the list and the finish
	   row, so changing --node moves everything together. */
	--node: calc(114 * var(--u));
	/* Stepped down from 110px: at full size the hero dominated the card and its row stood taller than the facts
	   beside it needed. The node column stays 114px so the smaller coins keep their place on the rail. */
	--hero: calc(100 * var(--u));
	/* The gold fill takes ~300ms however many rows it crosses (--n half-segments, set inline by the server on this
	   element, because a custom property's var() resolves where it is declared). */
	--seg: calc(300ms / var(--n, 4));
	/* The overview fades in over 300ms (<sl-animation name="fadeIn" duration="300"> in _BatchOverviewPartial.cshtml),
	   starting the moment HTMX inserts it, as the intro does. Every intro delay waits this long first, so the gold
	   fills on a card that is already fully visible instead of mostly under the fade. Keep the two in step. */
	--intro-wait: 300ms;
	/* Width is the node column plus a text column. The Batch Overview keeps the timeline at this width beside the
	   batch's facts, and batch.css ("Batch overview body") works out where the facts gain or lose a column from it
	   (334px with .has-over below, written there as 334rem / 13 because a container query cannot read --u), so a
	   change here moves those breakpoints too. */
	width: calc(300 * var(--u));
	max-width: 100%;
	color: var(--stage-ink);
}

/* Over the typical length the "+N" tag sits outside the hero's left edge (measured: up to ~29px past the node
	column, near 9 o'clock). The server adds .has-over so the timeline reserves that room, plus a few px of air,
	inside its own box: nothing spills over the card edge or into the facts beside it, and a host with
	overflow:auto never clips it or grows a scrollbar. The box grows by the same amount, so the text column keeps
	its width. Only overtime batches pay for it. */
.stage-timeline.has-over {
	width: calc(334 * var(--u));
	padding-left: calc(34 * var(--u));
}

/* When the over-running stage is the first row (Germination or Propagation), the tag can also rise above the
	list (measured: ~5px over its top edge at the longest overtime lane), so the box reserves that too. */
.stage-timeline.has-over-top {
	padding-top: calc(12 * var(--u));
}

:where(.stage-timeline) .stage-track {
	position: relative;
	display: flex;
	flex-direction: column;
	margin: 0;
	padding: 0;
	list-style: none;
}

/* One continuous dashed hairline behind the whole list (so its dash rhythm never breaks at row joints); gold
	segments are drawn over it per row. Both ends hide behind the first and last coin. */
:where(.stage-timeline) .stage-track::before {
	content: "";
	position: absolute;
	top: calc(24 * var(--u));
	bottom: calc(24 * var(--u));
	left: calc(var(--node) / 2 - var(--u));
	width: calc(2 * var(--u));
	background: repeating-linear-gradient(to bottom, var(--stage-rail-dash) 0 calc(4 * var(--u)), transparent calc(4 * var(--u)) calc(8 * var(--u)));
}

:where(.stage-timeline) .stage-track > .stage {
	position: relative;
	display: grid;
	grid-template-columns: var(--node) minmax(0, 1fr);
	column-gap: calc(8 * var(--u));
	align-items: center;
	padding: calc(5 * var(--u)) 0;
}

:where(.stage-timeline) .stage-track > .stage.is-current {
	/* Room below for the day seal that hangs off the coin's bottom rim. */
	padding: calc(6 * var(--u)) 0 calc(12 * var(--u));
}

/* When a partial harvest puts two stages in the spotlight both heroes step down a size, which keeps the list
	inside the ~400px the panel allows. */
:where(.stage-timeline) .stage-track.is-split {
	--hero: calc(94 * var(--u));
}

:where(.stage-timeline) .stage-track.is-split > .stage.is-current {
	padding: calc(4 * var(--u)) 0 calc(10 * var(--u));
}

/* ---------------------------------------------------------------- rail */
:where(.stage-timeline) .stage-rail {
	position: absolute;
	inset: 0 auto 0 calc(var(--node) / 2 - 2 * var(--u));
	width: calc(4 * var(--u));
}

:where(.stage-timeline) .rail-in,
:where(.stage-timeline) .rail-out {
	position: absolute;
	left: 0;
	width: calc(4 * var(--u));
	background: var(--stage-rail);
	box-shadow: var(--stage-rail-glow);
	transform-origin: top;
}

:where(.stage-timeline) .rail-in {
	top: 0;
	height: 50%;
}

:where(.stage-timeline) .rail-out {
	top: 50%;
	height: 50%;
}

/* ---------------------------------------------------------------- coins */
:where(.stage-timeline) .stage-node {
	position: relative;
	z-index: 1;
	justify-self: center;
	display: grid;
	place-items: center;
}

:where(.stage-timeline) .stage-coin {
	position: relative;
	display: block;
	border-radius: 50%;
}

:where(.stage-timeline) .stage-face {
	display: block;
	width: 100%;
	height: 100%;
	border-radius: 50%;
	overflow: hidden;
	background: var(--stage-face);
	box-shadow: var(--stage-face-shadow);
}

/* The art is composed inside a circular safe area, so it is shown at 100%: the rim never crops it. */
:where(.stage-timeline) .stage-face > svg {
	display: block;
	width: 100%;
	height: 100%;
}

/* Completed: full-colour clay coin in a thin gold rim, stamped with a check seal. */
:where(.stage-timeline) .is-done .stage-coin {
	width: calc(46 * var(--u));
	height: calc(46 * var(--u));
	padding: calc(2 * var(--u));
	background: var(--stage-rim);
	box-shadow: var(--stage-coin-shadow);
}

/* The seal is the non-colour "completed" cue (it survives greyscale), so it stays at least 17px (14.4 real pixels at
	the 11px root, still clear beside the 39px coin it sits on there). */
:where(.stage-timeline) .stage-seal {
	position: absolute;
	right: calc(-5 * var(--u));
	bottom: calc(-4 * var(--u));
	z-index: 2;
	display: grid;
	place-items: center;
	width: calc(17 * var(--u));
	height: calc(17 * var(--u));
	border-radius: 50%;
	background: var(--stage-seal);
	box-shadow: 0 0 0 calc(2 * var(--u)) var(--stage-card), var(--stage-seal-shadow);
}

:where(.stage-timeline) .stage-seal svg {
	width: calc(11 * var(--u));
	height: calc(11 * var(--u));
	fill: none;
	stroke: var(--stage-badge-ink);
	stroke-width: 2.4;
	stroke-linecap: round;
	stroke-linejoin: round;
}

/* Upcoming: a socket pressed into the card with a dashed edge, holding a line drawing of what is to come. */
:where(.stage-timeline) .is-pending .stage-coin {
	width: calc(42 * var(--u));
	height: calc(42 * var(--u));
	background: var(--stage-socket);
	box-shadow: var(--stage-socket-shadow);
}

:where(.stage-timeline) .is-pending .stage-coin::after {
	content: "";
	position: absolute;
	inset: calc(-3 * var(--u));
	border: calc(1.5 * var(--u)) dashed var(--stage-socket-dash);
	border-radius: 50%;
}

:where(.stage-timeline) .is-pending .stage-face {
	background: none;
	box-shadow: none;
	color: var(--stage-socket-ink);
}

/* The same stage SVG serves all three states: pending hides colour-only shading (.c) and redraws silhouettes (.o)
	as socket-filled outlines and structural lines (.l) in ink, so shapes still occlude each other like proper line
	art. */
:where(.stage-timeline) .is-pending svg .c {
	display: none;
}

:where(.stage-timeline) .is-pending svg :is(.o, .o *) {
	fill: var(--stage-socket);
	fill-opacity: 1;
	stroke: currentColor;
	stroke-opacity: 1;
	stroke-width: calc(1.15 * var(--u));
	stroke-linejoin: round;
	vector-effect: non-scaling-stroke;
}

:where(.stage-timeline) .is-pending svg :is(.l, .l *) {
	fill: none;
	stroke: currentColor;
	stroke-opacity: 1;
	stroke-width: calc(1.15 * var(--u));
	vector-effect: non-scaling-stroke;
}

/* At socket size fine detail (ribs, hairs, stripes) turns to noise, so only silhouettes and structure remain. */
:where(.stage-timeline) .is-pending svg .d {
	display: none;
}

/* ---------------------------------------------------------------- current stage (the hero) */
:where(.stage-timeline) .is-current .stage-node {
	width: var(--hero);
	height: var(--hero);
}

/* Warm halo behind the hero: a baked radial gradient, no blur filter (cheap in CEF). */
:where(.stage-timeline) .is-current .stage-node::before {
	content: "";
	position: absolute;
	inset: calc(-10 * var(--u));
	z-index: -1;
	border-radius: 50%;
	background: radial-gradient(closest-side, var(--stage-halo) 58%, transparent 100%);
}

:where(.stage-timeline) .is-current .stage-coin {
	position: absolute;
	inset: 9.6%;
	padding: calc(3 * var(--u));
	background: var(--stage-rim);
	box-shadow: var(--stage-coin-shadow);
}

:where(.stage-timeline) .is-current .stage-face {
	background: var(--stage-hero-face);
}

/* Keep-out for the day seal: it hangs over the bottom ~20% of the hero coin, so the hero lifts its art into the
	space above it, and shrinks it only a little: the illustration is what the hero is for, so it stays as large as
	the seal allows (about 1.7x the art in a completed coin). Pots, the jar base and the falling clippings land at
	~0.76 of the face and clear the seal's knock-out ring by 2px or more; the drying rod and the jar lid still fit
	inside the circle's chord at the top. The smaller coins have no seal over the art, so they keep it centred at
	full size.
	One rule serves both hero sizes: the 100px hero's 32px seal and the split hero's 94px / 30px seal are the same size
	relative to their hero (0.32 of its width), so the same lift clears both by the same margin. The split hero used
	to need its own, higher lift, when the full hero was 110px with a 34px seal. Everything here is a share of the
	face, so it holds at every root size. */
:where(.stage-timeline) .is-current .stage-face > svg {
	transform: translateY(-11%) scale(.93);
}

/* A hero with no start date to count from (.is-undated, from the server: no recorded transition date, or a partial
	harvest that no harvest dates) has no day seal, so the lift above has nothing to clear and only pushes its art up
	off centre. It keeps the hero's scale, so it never differs in size from the hero beside it in a split. Nothing
	animates this svg's transform (the idle loops move groups inside it), so replacing the value clobbers no animation. */
:where(.stage-timeline) .is-current.is-undated .stage-face > svg {
	transform: scale(.93);
}

/* Progress lane: day N of the typical (historical average) length, down the right-hand side of the coin from
	20 to 142 degrees (about 1 to 5 o'clock). pathLength="360" makes the server's dash numbers plain degrees. */
:where(.stage-timeline) .stage-orbit {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	overflow: visible;
	transform: rotate(-90deg);
}

:where(.stage-timeline) .stage-orbit circle {
	fill: none;
	stroke-linecap: round;
}

:where(.stage-timeline) .orbit-track {
	stroke: var(--stage-ring-track);
	stroke-width: 6;
}

:where(.stage-timeline) .orbit-edge {
	stroke: var(--stage-ring-edge);
	stroke-width: 6.4;
}

:where(.stage-timeline) .orbit-fill {
	stroke: var(--stage-ring);
	stroke-width: 3.4;
}

/* The bead rides the leading edge. --a (degrees from 12 o'clock) comes from the server. */
:where(.stage-timeline) .stage-bead {
	position: absolute;
	inset: 0;
	transform: rotate(var(--a));
	pointer-events: none;
}

:where(.stage-timeline) .stage-bead::after {
	content: "";
	position: absolute;
	top: calc(4.8% - 5.5 * var(--u));
	left: calc(50% - 5.5 * var(--u));
	width: calc(11 * var(--u));
	height: calc(11 * var(--u));
	border-radius: 50%;
	background: var(--stage-bead);
	box-shadow: 0 0 0 calc(1.5 * var(--u)) var(--stage-ring-edge), var(--stage-bead-glow);
}

/* Over-running the typical length: the lane is full and a dashed overtime lane carries on round the left side,
	past the day seal, to the bead. A "+N" tag sits just outside the bead, pushed out along the radius so it never
	lands on the coin, the art or the day seal; .has-over on the timeline reserves the room it needs. The dashes and
	the tag (not colour) are the cue; the meta line spells it out ("10 days past typical"). */
:where(.stage-timeline) .orbit-over {
	fill: none;
	stroke: var(--stage-ring-edge);
	stroke-width: 3.4;
	stroke-linecap: round;
	stroke-dasharray: 3.2 3.6;
}

:where(.stage-timeline) .stage-over {
	position: absolute;
	z-index: 2;
	/* left/top (from the server) are the tag's centre: bead radius + 3px gap + the tag's half-extent along the
	   radius, so its near edge always sits 3px beyond the bead. */
	transform: translate(-50%, -50%);
	padding: calc(1 * var(--u)) calc(5 * var(--u)) calc(2 * var(--u));
	/* A quiet walnut-gold outline tag rather than a dark pill: it is a footnote to the lane, not the darkest
	   object in the timeline. Text 5.56:1 (light) and 7.8:1 (dark) on the card. */
	border: calc(1.5 * var(--u)) solid var(--stage-ring-edge);
	border-radius: 999px;
	background: var(--stage-card);
	color: var(--stage-eyebrow);
	font-size: .77rem;
	font-weight: 800;
	line-height: 1.2;
	font-variant-numeric: tabular-nums;
	white-space: nowrap;
}

/* Day seal on the bottom rim: the hero's big number, in the same round-seal language as the completed checks. 32px
	keeps it in proportion with the 100px hero (0.32 of its width, like the split hero's 30px seal), so the art lift
	above clears it; at 34px it would cover more of the smaller coin than the lift allows for. */
:where(.stage-timeline) .stage-day {
	position: absolute;
	top: calc(90.4% - 16 * var(--u));
	left: calc(50% - 16 * var(--u));
	z-index: 2;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	width: calc(32 * var(--u));
	height: calc(32 * var(--u));
	border-radius: 50%;
	background: var(--stage-badge);
	color: var(--stage-badge-ink);
	box-shadow: 0 0 0 calc(2.5 * var(--u)) var(--stage-card), var(--stage-day-shadow);
	line-height: 1;
	white-space: nowrap;
}

:where(.stage-timeline) .stage-day span {
	margin-top: calc(1 * var(--u));
	font-size: .73rem;
	font-weight: 750;
	letter-spacing: .06em;
	text-transform: uppercase;
}

/* Sized between the old 34px seal's number (1.08rem) and the split 30px seal's (.98rem), in step with the seal itself,
	so three digits keep the same breathing room inside the disc. */
:where(.stage-timeline) .stage-day b {
	font-size: 1.03rem;
	font-weight: 800;
	font-variant-numeric: tabular-nums;
	letter-spacing: -.02em;
}

/* Day N counts whole days since the transition, the same number as "In Life Stage For". On the transition day
	itself that is 0, and a "Day 0" seal looks broken, so the seal says New instead. */
:where(.stage-timeline) .stage-day.is-new b {
	font-size: .77rem;
	letter-spacing: .04em;
	text-transform: uppercase;
}

/* Four digits are wider than the seal: at the full size "1000" ran off the gold disc onto its white knock-out ring
	(35px of number in what was then a 34px seal). From 1000 days the server adds .is-long, and the number steps down
	until it fits inside the disc's chord at the height of the digits. Between the 34px seal's .8rem and the split
	seal's .7rem, like the regular number above. */
:where(.stage-timeline) .stage-day.is-long b {
	font-size: .75rem;
	letter-spacing: -.04em;
}

:where(.stage-timeline) .is-split .stage-day {
	top: calc(90.4% - 15 * var(--u));
	left: calc(50% - 15 * var(--u));
	width: calc(30 * var(--u));
	height: calc(30 * var(--u));
}

:where(.stage-timeline) .is-split .stage-day b {
	font-size: .98rem;
}

/* The split seal is smaller still. Restated here because .is-split .stage-day b is as specific as the .is-long rule
	above and comes later, so it would undo the step down. */
:where(.stage-timeline) .is-split .stage-day.is-long b {
	font-size: .7rem;
}

/* No typical length yet (new organisation, first batch of a kind): no lane and no bead, a plain gold ring. */
:where(.stage-timeline) .is-current.is-untimed .stage-coin {
	box-shadow: var(--stage-coin-shadow), 0 0 0 calc(3 * var(--u)) var(--stage-card), 0 0 0 calc(5 * var(--u)) var(--stage-ring-edge);
}

/* ---------------------------------------------------------------- labels */
:where(.stage-timeline) .stage-text {
	display: flex;
	flex-direction: column;
	gap: calc(1 * var(--u));
	min-width: 0;
}

/* Sizes follow the app's rem scale (13px root, 12px and 11px on narrower screens) with no px floor, like the app's
	own --font-size-* tokens. A floor would stop the text shrinking while the coins beside it do, so the labels would
	grow against the art on exactly the screens with the least room. */
:where(.stage-timeline) .stage-name {
	font-size: 1rem;
	font-weight: 650;
	line-height: 1.2;
	color: var(--stage-ink);
}

:where(.stage-timeline) .stage-meta {
	font-size: .85rem;
	font-weight: 500;
	line-height: 1.35;
	color: var(--stage-meta);
}

:where(.stage-timeline) .stage-meta b {
	font-weight: 700;
	color: var(--stage-ink);
}

:where(.stage-timeline) .is-pending .stage-name {
	font-weight: 600;
	color: var(--stage-meta);
}

:where(.stage-timeline) .is-pending .stage-meta {
	display: flex;
	flex-wrap: wrap;
	align-items: baseline;
	column-gap: calc(6 * var(--u));
}

:where(.stage-timeline) .stage-eyebrow,
:where(.stage-timeline) .stage-tag {
	font-size: .77rem;
	font-weight: 700;
	letter-spacing: .08em;
	line-height: 1.3;
	text-transform: uppercase;
	color: var(--stage-eyebrow);
}

:where(.stage-timeline) .is-current .stage-name {
	margin: calc(1 * var(--u)) 0 calc(3 * var(--u));
	font-size: 1.7rem;
	font-weight: 750;
	line-height: 1.08;
	letter-spacing: -.01em;
}

:where(.stage-timeline) .is-split .is-current .stage-name {
	margin-bottom: calc(2 * var(--u));
	font-size: 1.45rem;
}

/* ---------------------------------------------------------------- grow complete (batch in Curing) */
:where(.stage-timeline) .stage-track.is-complete::before {
	display: none;
}

:where(.stage-timeline) .stage-finish {
	position: relative;
	display: grid;
	grid-template-columns: var(--node) minmax(0, 1fr);
	column-gap: calc(8 * var(--u));
	align-items: center;
	margin: calc(2 * var(--u)) 0 0;
	padding-top: calc(10 * var(--u));
}

/* The gold rail runs on from the last coin into the finish seal. */
:where(.stage-timeline) .stage-finish::before {
	content: "";
	position: absolute;
	top: calc(-6 * var(--u));
	left: calc(var(--node) / 2 - 2 * var(--u));
	width: calc(4 * var(--u));
	height: calc(24 * var(--u));
	background: var(--stage-rail);
	box-shadow: var(--stage-rail-glow);
}

/* The finish seal is the grow's closing moment: a larger seal in a soft gold ring (static, no motion). */
:where(.stage-timeline) .stage-finish > .stage-seal {
	position: relative;
	right: auto;
	bottom: auto;
	justify-self: center;
	width: calc(28 * var(--u));
	height: calc(28 * var(--u));
	box-shadow: 0 0 0 calc(2 * var(--u)) var(--stage-card), 0 0 0 calc(6 * var(--u)) var(--stage-halo), var(--stage-seal-shadow);
}

:where(.stage-timeline) .stage-finish > .stage-seal svg {
	width: calc(16 * var(--u));
	height: calc(16 * var(--u));
}

:where(.stage-timeline) .stage-finish > span:last-child {
	display: flex;
	flex-direction: column;
}

:where(.stage-timeline) .stage-finish b {
	font-size: 1rem;
	font-weight: 750;
	color: var(--stage-ink);
}

/* Screen-reader-only sentence per row. Feature-prefixed like the app's other sr-only classes (.performance-sr-only,
	.purchases-sr-only), so a generic name never collides elsewhere. */
:where(.stage-timeline) .stage-sr-only {
	position: absolute;
	width: 1px;
	height: 1px;
	margin: -1px;
	overflow: hidden;
	clip-path: inset(50%);
	white-space: nowrap;
}

/* ---------------------------------------------------------------- compact window
	The server renders six stages, which fill the height beside the overview's facts while those are in one or two
	columns. At three columns the facts are short, and six stages would hang below them over a band of empty card, so
	the timeline drops to the four the server marked as its compact window (every row without .is-extra). Hiding rows
	that are already rendered keeps one rendering path for every width; the builder picks the two windows so the
	compact one is always an unbroken run of rows inside the full one, holding the current stage, a partial harvest's
	second hero and "Up next".
	The condition is the facts' own three-column query in batch.css ("Batch overview body"), so the switch follows the
	facts whatever the window, menu or root font size; keep the two in step. Outside the Batch Overview there is no
	batch-overview container, so this never matches and all six stages show. */
@container batch-overview (min-width: calc(334rem / 13 + 47rem)) {
	/* Times the intro over the visible rows only: --n-compact counts their gold half-segments and --k-skip pulls every
	   --k back past the hidden rows' share (both from the server, see BatchStageTimelineModel), so the gold starts
	   with the intro and fills in the same ~300ms, instead of pausing over rows nobody can see. Declared on the same
	   element as the base --seg, and later in the file, so it replaces it. */
	.stage-timeline {
		--seg: calc(300ms / var(--n-compact, var(--n, 4)));
		--k-skip: var(--k-skip-compact, 0);
	}

	:where(.stage-timeline) .stage-track > .stage.is-extra {
		display: none;
	}

	/* The first visible row's gold half above its coin joined it to the row above, now hidden. Left in, it would be a
	   stub of gold rising out of the top of the list, so it goes too, and the rail starts at the first coin as it does
	   on the list's real first row. Hidden rows sit only above the first visible row or below the last, and the ones
	   below are always still to come, which carry no gold, so the bottom needs no such rule. */
	:where(.stage-timeline) .stage-track > .stage.is-extra + .stage:not(.is-extra) .rail-in {
		display: none;
	}
}

/* ---------------------------------------------------------------- motion
	Opt-in only: nothing moves unless the viewer allows motion, and every resting state above is already final
	(rail filled, lane at its value), so switching motion off loses nothing. Transform/opacity/stroke only; no
	filters.
	The intro plays every time an overview appears: staff asked to see it on every batch they open, not only the first
	one on a page. So the gate is on each timeline: the intro rules match a .stage-timeline until that element carries
	data-intro="played". A new timeline arrives without the flag, so its intro starts the moment HTMX inserts it, with
	no script to wait for (HTMX only announces new content in its settle step, 20ms after the swap, often after a
	frame has been painted). batch_stage_timeline.js sets "played" once the intro has had time to finish, so the intro
	does not start over if that element's styles are rebuilt later (CSS animations restart when an element comes back
	from display:none), and no finished intro animation is left holding its last frame. The back and forward buttons
	restore a saved copy of the page whose timelines already say "played"; the script resets them before the copy is
	first painted, so they play as well. Every intro delay starts with --intro-wait, so the intro plays after the
	overview's own fade-in. Every --k is counted from --k-skip (0 unless the compact window hides rows above, see
	"compact window"), so the first gold that can be seen always moves first.
	Idle loops run on the current stage only, once each, and all rest within five seconds: they start by themselves
	again on every HTMX swap, and WCAG 2.2.2 (Pause, Stop, Hide) only allows such motion without a pause control when
	it stops within five seconds.
*/
@media (prefers-reduced-motion: no-preference) {
	.stage-timeline:not([data-intro="played"]) .stage-track .rail-in,
	.stage-timeline:not([data-intro="played"]) .stage-track .rail-out {
		animation: stage-rail-fill var(--seg) linear both;
		animation-delay: calc(var(--intro-wait) + (var(--k) - var(--k-skip, 0)) * var(--seg));
	}

	.stage-timeline:not([data-intro="played"]) .stage-track .is-current :is(.orbit-edge, .orbit-fill) {
		animation: stage-lane-fill 520ms cubic-bezier(.2, .7, .2, 1) both;
		animation-delay: calc(var(--intro-wait) + (var(--k) - var(--k-skip, 0)) * var(--seg));
	}

	.stage-timeline:not([data-intro="played"]) .stage-track .is-current .stage-bead {
		animation: stage-bead-run 520ms cubic-bezier(.2, .7, .2, 1) both;
		animation-delay: calc(var(--intro-wait) + (var(--k) - var(--k-skip, 0)) * var(--seg));
	}

	/* Over the typical length the bead does not run (its path would sweep past the day seal), and the tag must not
		appear before the lane is full: the bead, the dashed overtime lane and the tag fade in together once the
		lane fill has finished. */
	.stage-timeline:not([data-intro="played"]) .stage-track .is-over :is(.stage-bead, .orbit-over, .stage-over) {
		animation: stage-fade-in 240ms ease-out both;
		animation-delay: calc(var(--intro-wait) + (var(--k) - var(--k-skip, 0)) * var(--seg) + 520ms);
	}

	/* One expanding ring when the gold arrives: a single "you are here" beat. */
	.stage-timeline:not([data-intro="played"]) .stage-track .is-current .stage-node::after {
		content: "";
		position: absolute;
		inset: 6%;
		border: calc(2 * var(--u)) solid var(--primary-green);
		border-radius: 50%;
		opacity: 0;
		animation: stage-ping 900ms ease-out 1 both;
		animation-delay: calc(var(--intro-wait) + (var(--k) - var(--k-skip, 0)) * var(--seg));
		pointer-events: none;
	}

	/* One cycle each: the longest, sway, ends at 4.6s. Two cycles of even the shortest loop (twinkle, 2 x 2.6s) would
		run past five seconds. */
	:where(.stage-timeline) .stage-track .is-current .stage-node::before {
		animation: stage-breathe 3.4s ease-in-out 1;
	}

	:where(.stage-timeline) .stage-track .is-current .a-sway {
		animation: stage-sway 4.6s ease-in-out 1;
	}

	:where(.stage-timeline) .stage-track .is-current .a-rock {
		animation: stage-rock 3.8s ease-in-out 1;
	}

	:where(.stage-timeline) .stage-track .is-current .a-swing {
		animation: stage-swing 4.2s ease-in-out 1;
	}

	/* 5s started 1.2s in, so one cycle plays for 3.8s. */
	:where(.stage-timeline) .stage-track .is-current .a-swing-2 {
		animation-duration: 5s;
		animation-delay: -1.2s;
	}

	:where(.stage-timeline) .stage-track .is-current .a-twinkle {
		animation: stage-twinkle 2.6s ease-in-out 1;
	}

	:where(.stage-timeline) .stage-track .is-current .a-fall {
		animation: stage-fall 3.2s ease-in-out 1;
	}

	:where(.stage-timeline) .stage-track .is-current .a-snip {
		animation: stage-snip 3s ease-in-out 1;
	}

	:where(.stage-timeline) .stage-track .is-current .a-glint {
		animation: stage-glint 3.6s ease-in-out 1;
	}
}

@keyframes stage-rail-fill {
	from {
		transform: scaleY(0);
	}
}

/* Animates from an empty dash to the server's value (the presentation attribute is the end state). */
@keyframes stage-lane-fill {
	from {
		stroke-dasharray: 0 360;
	}
}

@keyframes stage-bead-run {
	from {
		transform: rotate(20deg);
	}
}

@keyframes stage-fade-in {
	from {
		opacity: 0;
	}
}

@keyframes stage-ping {
	0% {
		opacity: .9;
		transform: scale(.98);
	}

	100% {
		opacity: 0;
		transform: scale(1.32);
	}
}

/* Every idle loop starts and ends at the resting pose, so stopping after N cycles never leaves art mid-move. */
@keyframes stage-breathe {
	0%,
	100% {
		opacity: 1;
		transform: scale(1);
	}

	50% {
		opacity: .6;
		transform: scale(.95);
	}
}

@keyframes stage-sway {
	0%,
	100% {
		transform: rotate(0deg);
	}

	25% {
		transform: rotate(-2.4deg);
	}

	75% {
		transform: rotate(2.4deg);
	}
}

@keyframes stage-rock {
	0%,
	100% {
		transform: rotate(0deg);
	}

	30% {
		transform: rotate(-3deg);
	}

	70% {
		transform: rotate(2deg);
	}
}

@keyframes stage-swing {
	0%,
	100% {
		transform: rotate(0deg);
	}

	25% {
		transform: rotate(2.2deg);
	}

	75% {
		transform: rotate(-2.2deg);
	}
}

@keyframes stage-twinkle {
	0%,
	100% {
		opacity: 1;
		transform: scale(1);
	}

	50% {
		opacity: .35;
		transform: scale(.6);
	}
}

@keyframes stage-fall {
	0%,
	100% {
		transform: translateY(0);
	}

	50% {
		transform: translateY(1.6px);
	}
}

@keyframes stage-snip {
	0%,
	62%,
	100% {
		transform: rotate(0deg);
	}

	76% {
		transform: rotate(-9deg);
	}
}

@keyframes stage-glint {
	0%,
	100% {
		opacity: 1;
	}

	50% {
		opacity: .45;
	}
}

/* #endregion */