/* ══════════════════════════════════════════════════════════════ scene ══
   The hero's explainer, drawn by home.js: sources stream into one product's
   tag, and its adverts drop onto a pile as parcels, one per shop. Its own
   sheet so home.css stays the page's layout.                               */
.stage { margin: 0; min-width: 0; }
.stage-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin-bottom: 8px; }
.stage-title { font-size: 1rem; }
.stage-title b { font-weight: 650; }

/* Pause while it plays, Play while it is paused, as an icon: the word is in a .sr span the scripts
   write, so the button still says what a press does without a word on the page. 32px, so the icon
   alone is still a target a thumb finds (WCAG 2.5.8). */
.scene-toggle {
  position: relative;
  display: inline-grid;
  place-items: center;
  flex: none;
  align-self: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--ink-soft);
  cursor: pointer;
}
.scene-toggle[hidden] { display: none; }
.scene-toggle:hover { color: var(--ink); background: var(--well); }
.scene-toggle .i-play,
.scene-toggle.is-paused .i-pause { display: none; }
.scene-toggle.is-paused .i-play { display: block; }

/* A fixed shape before the script draws in it, so nothing below moves when it does. */
.scene-box { position: relative; width: 100%; aspect-ratio: 10 / 7; max-height: 540px; }
/* Capped so a wide stacked scene (a small tablet) does not open an empty band mid-way. */
.stage.is-portrait .scene-box { aspect-ratio: 5 / 7; max-height: 580px; }
/* Phones: one shape from the first paint, so the page no longer jumps when home.js turns the
   scene portrait (below a 480px stage, which is a 539px screen), and the list comes sooner.
   360px is what the tally and the notes beside the pile need: at 340 the last note ran 5px over.
   Measured at 320 and 375px wide, in both languages. */
@media (max-width: 539px) {
  .scene-box,
  .stage.is-portrait .scene-box { aspect-ratio: 1; min-height: 360px; max-height: none; }
}
#scene { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }

#scene text { font-family: var(--font); }
.t-name { font-size: 15px; font-weight: 650; fill: var(--ink); }
.t-tag { font-size: 18px; font-weight: 650; fill: var(--ink); }
.t-note { font-size: 13.5px; font-weight: 600; fill: var(--ink); }
.t-note2 { font-size: 13px; fill: var(--ink-soft); }
.rail { fill: none; stroke: var(--line-hi); stroke-width: 1.5; }
.gate { fill: none; stroke: var(--ink-soft); stroke-width: 1.25; stroke-dasharray: 2 3; }
.tag-body { fill: var(--card); stroke: var(--ink); stroke-width: 1.5; stroke-linejoin: round; }
.tag-perf { stroke: var(--line-hi); stroke-width: 1; stroke-dasharray: 2 3; }
/* A metal ring round the hole, so it reads as an eyelet and never as a letter "o". */
.tag-eyelet { fill: var(--line-hi); stroke: var(--ink); stroke-width: .75; }
.tag-hole { fill: var(--panel); stroke: var(--ink); stroke-width: .75; }
.floor { stroke: var(--line-hi); stroke-width: 1.5; }
/* Shape tells the sources apart, so colour is left for meaning: kraft is a shop, and only
   the advert squares carry it. */
.d-ad { fill: var(--parcel); }
.d-ws { fill: none; stroke: var(--ink); stroke-width: 1.5; }
/* Last month's shops: the same kraft, paler, so the pile shows the rise at a glance. The figure
   is always in words beside it. */
#scene .was { opacity: .5; }

/* The number sits on its pile; home.js places it. It is the finished figure in the markup. */
.tally { position: absolute; top: 0; left: 58%; pointer-events: none; }
.tally-top { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 4px 12px; }
.tally-num {
  display: inline-block;
  font-size: clamp(3.25rem, 2rem + 3vw, 5rem);
  font-weight: 650;
  line-height: .82;
  letter-spacing: -.05em;
  font-variant-numeric: tabular-nums;
  transform-origin: 30% 90%;
}
.tally-unit { font-size: 1rem; line-height: 1.25; max-width: 15ch; }
.tally-grow { margin-top: 10px; font-size: 1rem; font-weight: 600; color: var(--ink-soft); }
.tally-grow.grew { color: var(--grow); }
.tally-grow > span { margin-inline-end: .25em; }
.tally-grow.pending { opacity: 0; transform: translateY(4px); }
.tally-grow { transition: opacity 420ms ease-out, transform 420ms cubic-bezier(.3, 1.4, .6, 1); }

/* Held back until the scene plays it in. If the script never arrives, a timer gives up and shows
   it — visible by default (docs/design/README.md). */
@media (prefers-reduced-motion: no-preference) {
  .js .tally:not(.live) { opacity: 0; animation: tally-show 0s 2.5s forwards; }
}
@keyframes tally-show { to { opacity: 1; } }

/* A real sequence, so numbered; home.js fills each bar as its phase plays. */
.steps { list-style: none; margin: 20px 0 0; padding: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 24px; }
.step { position: relative; padding-top: 16px; opacity: var(--o, 1); transition: opacity 280ms ease-out; }
.step-bar { position: absolute; inset: 0 0 auto 0; height: 2px; border-radius: 2px; background: var(--line-hi); overflow: hidden; }
.step-bar::after { content: ""; position: absolute; inset: 0; background: var(--ink); transform-origin: left; transform: scaleX(var(--p, 1)); }
.step-t { margin-bottom: 4px; font-weight: 650; }
.step-t span { margin-inline-end: 6px; color: var(--ink-soft); font-weight: 600; font-variant-numeric: tabular-nums; }
.step p:last-child { font-size: var(--t-small); line-height: 1.45; color: var(--ink-soft); }
@media (max-width: 560px) { .steps { grid-template-columns: minmax(0, 1fr); gap: 14px; } }

/* The hero's scene once home.js runs: one caption carries the step's sentence, and the steps keep
   only their bars, so the picture is not ringed with text. The words stay for screen readers. */
.scene-cap {
  min-height: 2.6em;
  margin-top: 10px;
  max-width: 46ch;
  font-size: 1.0625rem;
  font-weight: 600;
  line-height: 1.3;
  text-wrap: balance;
  opacity: var(--in, 1);
  transform: translateY(calc((1 - var(--in, 1)) * 4px));
}
.scene-cap[hidden] { display: none; }
/* Wide: in the picture's empty lower-left corner, under the lanes and left of the pile. */
.stage-scene:not(.is-portrait) .scene-cap { position: relative; max-width: 46%; margin-top: -2.9em; }
.stage-scene.live .steps { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-top: 14px; }
.stage-scene.live .step { padding-top: 3px; }
.stage-scene.live .step-bar { height: 3px; }
.stage-scene.live .step > p { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* From the picture to the product's row in the list. Shown once the pile is done; a keyboard that
   reaches it early still sees it. */
.stage-next { margin-top: 12px; font-weight: 600; transition: opacity 400ms ease-out; }
.stage-next a { text-underline-offset: 3px; }
.stage-next.pending:not(:focus-within) { opacity: 0; }
