/* ==========================================================================
   Skylark — day replay

   A 24-hour scope. The day's observed traffic is drawn inside a disc, in the
   same token vocabulary as the rest of the product: amber for airborne,
   neutral for ground, one accent and nothing else.
   ========================================================================== */

:root {
  --bg: #04060a;
  --bg-sunk: #070a0f;
  --bg-raise: #0b0f16;
  --line: #141821;
  --line-strong: #232936;
  --text: #eaf0f7;
  --text-dim: #b0b7c1;
  --muted: #767f8c;
  --accent: #f5a524;
  --live: #35d07f;
  --neutral: #949ba6;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
  --font-prose: -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, "Segoe UI", Roboto, sans-serif;
  --fs-micro: 9.5px;
  --fs-sm: 11.5px;
  --fs-base: 13.5px;
  --fs-lg: 17px;
  --fs-clock: 40px;
  --panel: rgb(7 10 15 / 0.82);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: var(--fs-sm)/1.5 var(--font-mono);
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--text-dim); text-underline-offset: 3px; }
a:hover { color: var(--text); }
button { font: inherit; color: inherit; cursor: pointer; }
h2 { margin: 0; font-size: var(--fs-sm); font-weight: 600; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.skip {
  position: absolute;
  left: 24px;
  top: -80px;
  z-index: 20;
  padding: 10px 14px;
  background: var(--bg-raise);
  border: 1px solid var(--line-strong);
}
.skip:focus { top: 16px; }

.replay { position: fixed; inset: 0; overflow: hidden; }
.stage { position: absolute; inset: 0; }

#map { display: block; width: 100%; height: 100%; }

.stage-empty {
  position: absolute;
  inset: 0;
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-prose);
  color: var(--text-dim);
}
.stage-empty[hidden] { display: none; }

/* ---------------------------------------------------------------- panels -- */

.panel {
  position: absolute;
  z-index: 10;
  border: 1px solid var(--line);
  background: var(--panel);
  backdrop-filter: blur(8px);
  padding: 16px 18px;
}

.panel--north { left: 22px; top: 22px; min-width: 236px; }
.panel--east { right: 22px; top: 22px; width: 210px; text-align: right; }
.panel--south { left: 0; right: 0; bottom: 0; border-width: 1px 0 0; padding: 12px 22px 14px; }

.wordmark { display: flex; align-items: center; gap: 10px; }
.wordmark a { display: flex; align-items: center; gap: 8px; }
.brand-mark { width: 26px; height: 26px; }
.brand-wordmark { height: 15px; width: auto; }
.wordmark span { color: var(--muted); font-size: var(--fs-sm); }

.clock-block { margin: 16px 0 14px; }
.eyebrow {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.17em;
  font-size: var(--fs-micro);
  font-weight: 600;
  color: var(--muted);
}
.clock { margin: 4px 0 2px; font-size: var(--fs-clock); line-height: 1; font-weight: 500; letter-spacing: -0.03em; }
.subline { margin: 0; color: var(--muted); font-size: var(--fs-sm); }

.facts { margin: 0; display: grid; gap: 4px; }
.facts div { display: flex; justify-content: space-between; gap: 18px; font-size: var(--fs-sm); }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }

.counter { margin: 6px 0 14px; }
.counter span { display: block; font-size: var(--fs-lg); font-weight: 500; letter-spacing: -0.02em; }
.counter small { display: block; color: var(--muted); font-size: var(--fs-micro); letter-spacing: 0.06em; text-transform: uppercase; }
.counter--small span { font-size: var(--fs-base); }

.caveat { margin: 0 0 16px; color: var(--muted); font: var(--fs-micro)/1.5 var(--font-prose); }

.ghost {
  width: 100%;
  padding: 8px 10px;
  background: none;
  border: 1px solid var(--line-strong);
  border-radius: 2px;
  color: var(--text-dim);
  font-size: var(--fs-sm);
}
.ghost:hover { color: var(--text); border-color: var(--muted); }
.ghost[aria-pressed="true"] { color: var(--accent); border-color: var(--accent); }

/* The 3D replay of the same day. It lives in the summary panel because that
   panel has the room for it: the scope is framed from the panels' measured
   height, and a row added anywhere lower would push the map under the HUD on a
   phone. */
.replay-3d-link { display: block; margin-top: 14px; text-decoration: none; }

/* The consent banner, built by analytics.js. Self-contained because this page
   does not load the tracker stylesheet, and it uses this page's own tokens. */
.consent-banner {
  position: fixed;
  z-index: 80;
  left: 12px;
  right: 12px;
  bottom: 12px;
  max-width: 520px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px;
  padding: 14px 16px;
  background: var(--bg-raise);
  border: 1px solid var(--line-strong);
  border-radius: 2px;
  color: var(--text-dim);
  font: var(--fs-sm)/1.5 var(--font-prose);
}
.consent-banner[hidden] { display: none; }
/* A modal dialog is laid out by the UA with its block-start at the top, so the
   bottom anchor needs saying again in that state. */
.consent-banner:modal { top: auto; }
.consent-banner__body { flex: 1 1 240px; min-width: 0; }
.consent-banner__label {
  margin: 0 0 4px;
  font-size: var(--fs-micro);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted);
}
.consent-banner__copy { margin: 0; }
.consent-banner__actions { display: flex; gap: 8px; flex: none; }
.consent-banner__actions .btn {
  min-height: 40px;
  padding: 8px 12px;
  background: none;
  border: 1px solid var(--line-strong);
  border-radius: 2px;
  color: var(--text-dim);
  font-size: var(--fs-sm);
}
.consent-banner__actions .btn:hover { color: var(--text); border-color: var(--muted); }
.consent-banner__actions #consentAccept { color: var(--accent); border-color: var(--accent); }

/* ------------------------------------------------------------- transport -- */

.transport-row { display: flex; align-items: center; gap: 16px; }
.transport-row .primary {
  min-width: 88px;
  padding: 9px 16px;
  background: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 2px;
  color: var(--bg);
  font-weight: 600;
}
.primary:hover { filter: brightness(1.08); }
.scrub-label { color: var(--muted); font-size: var(--fs-micro); text-transform: uppercase; letter-spacing: 0.14em; }

#scrubber { flex: 1; min-width: 120px; height: 22px; appearance: none; background: none; margin: 0; }
#scrubber::-webkit-slider-runnable-track { height: 3px; background: var(--line-strong); }
#scrubber::-webkit-slider-thumb { appearance: none; width: 12px; height: 12px; margin-top: -4.5px; border-radius: 50%; background: var(--accent); }
#scrubber::-moz-range-track { height: 3px; background: var(--line-strong); }
#scrubber::-moz-range-thumb { width: 12px; height: 12px; border: 0; border-radius: 50%; background: var(--accent); }

#progressLabel { min-width: 58px; text-align: right; color: var(--text-dim); }

.speed-row { display: flex; align-items: center; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.speed {
  min-width: 52px;
  padding: 5px 10px;
  background: none;
  border: 1px solid var(--line);
  border-radius: 2px;
  color: var(--muted);
  font-size: var(--fs-sm);
}
.speed:hover { color: var(--text); border-color: var(--line-strong); }
.speed[aria-pressed="true"] { color: var(--accent); border-color: var(--accent); }

.toggle { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: var(--fs-sm); margin-left: 8px; }
.toggle input { accent-color: var(--accent); }

/* One control, not two, because the south panel's height decides whether the
   scope is fitted or becomes an overlay. */
.pattern-mode {
  margin-left: 8px;
  padding: 4px 9px;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: var(--r);
  color: var(--muted);
  font: inherit;
  font-size: var(--fs-sm);
  cursor: pointer;
}
.pattern-mode[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); }

.disclosure { margin: 10px 0 0; color: var(--muted); font: var(--fs-micro)/1.6 var(--font-prose); max-width: 980px; }

.notice { margin: 14px; padding: 12px; border: 1px solid var(--line-strong); }

@media (max-width: 880px) {
  :root { --fs-clock: 30px; }
  .panel--north { left: 12px; top: 12px; min-width: 0; padding: 12px 14px; }
  .panel--east { right: 12px; top: 12px; width: 148px; padding: 12px 14px; }
  .panel--south { padding: 10px 12px 12px; }
  .facts, .wordmark span { display: none; }
  .clock-block { margin: 10px 0 0; }
  .transport-row { gap: 10px; }
  .transport-row .primary { min-width: 74px; padding: 8px 12px; }
  .scrub-label { display: none; }
  .counter { margin: 4px 0 10px; }
  /* The counters are candidate counts, so the caveat stays. The colour key and
     the section headings are the parts a phone can do without. */
  .panel--east .eyebrow, #colourKey { display: none; }
  .disclosure { font-size: var(--fs-micro); }
  #disclosureRest { display: none; }
}

/* Landscape phones and short windows: the screen is wider than it is tall, so
   the HUD has to become a strip rather than a column, or it covers the scope
   and runs off the bottom of the viewport. */
@media (max-height: 620px) {
  .wordmark { display: none; }
  .clock-block { display: flex; align-items: baseline; gap: 10px; margin: 0; }
  .clock { font-size: 24px; margin: 0; }
  #replayPhase { display: none; }
  .panel--north { padding: 8px 12px; }
  .panel--east { width: 138px; padding: 8px 12px; }
  .panel--east .caveat { display: none; }
  .counter { margin: 2px 0 6px; }
  .counter span { font-size: var(--fs-base); }
  .counter small { font-size: 8.5px; }
  .panel--south { padding: 6px 12px 8px; }
  .speed-row { margin-top: 6px; }
  .disclosure { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .stage-empty { font-style: italic; }
}

/* The day's story. One collapsed line inside the south panel, because the scope
   is fitted around the panels and a new floating panel would not be measured. */
.story { margin-top: 6px; border-top: 1px solid var(--line); padding-top: 6px; }
.story > summary {
  display: flex;
  gap: 10px;
  align-items: baseline;
  cursor: pointer;
  list-style: none;
}
.story > summary::-webkit-details-marker { display: none; }
.story .eyebrow { flex: none; }
.story-headline { color: var(--text-dim); font-size: var(--fs-sm); }

.story-body { margin-top: 10px; display: flex; flex-direction: column; gap: 12px; max-height: 46vh; overflow: auto; }
/* An explicit display on the body defeats the closed state, so hide it by name. */
details.story:not([open]) .story-body { display: none; }
.story-lead { margin: 0; color: var(--text); font: var(--fs-sm)/1.5 var(--font-prose); max-width: 980px; }
.story-copy { align-self: flex-start; }
.story-section { display: grid; gap: 4px; }
.story-section .facts { display: grid; gap: 2px; max-width: 640px; }
.story-section .facts div { display: flex; justify-content: space-between; gap: 18px; font-size: var(--fs-sm); }
.story-section .facts dt { color: var(--muted); }
.story-section .facts dd { margin: 0; text-align: right; }
.story-note { margin: 0; color: var(--muted); font: var(--fs-micro)/1.6 var(--font-prose); max-width: 980px; }

/* On a phone the collapsed line stays one line. The scope is fitted around the
   panels, and a second line here is the difference between a scope and an
   overlay that covers it. */
@media (max-width: 880px) {
  .story .eyebrow { display: none; }
  .story-headline { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .story-body { max-height: 34vh; }
}
