/* Hallmark · genre: editorial · macrostructure: Stat-Led · theme: Sport
 * modes: light + dark, both SELECTED (each stepped for its own surface)
 * H4 stat-hero knobs: number=tabular display, qualifier=below, secondary=pair
 * F3 spec-sheet knobs: columns=3 (key/val/unit), rules=every row, numbers=tabular
 * T4 compare strip: 6 items, 3x2 · live band: status + 4 cells + hourly bars
 * nav: N6 masthead (issue-line=below, wordmark=2xl, rule=double) · footer: Ft4 dense colophon (mono, log-style)
 * enrichment: none (app page, function carries it)
 * outlier face (mono): 2 slots, masthead issue-line + colophon
 * motion: one pulse (live dot) · rail scaleX · hero counter
 * verified 2026-07-26 after the live band shipped:
 *   contrast pass (40–41) both modes · tokens pass (48) · mobile pass (34, 49–57)
 *   fonts pass (37, 38) · hit targets 44px on touch
 * pre-emit critique: P5 H5 E5 S5 R5 V5
 */

@import url("/tokens.css");

*, *::before, *::after { box-sizing: border-box; }

/* headings that belong in the outline but not on the page */
.vh {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip-path: inset(50%); white-space: nowrap; border: 0;
}
html, body { margin: 0; overflow-x: clip; }

body {
  background: var(--color-paper);
  color: var(--color-ink);
  font-family: var(--font-body);
  font-size: var(--text-md);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.shell {
  max-width: 78rem;
  margin: 0 auto;
  padding-inline: clamp(1rem, 4vw, 2rem);
}

h1, h2, h3 {
  font-family: var(--font-display);
  font-style: normal;
  font-weight: 700;
  letter-spacing: var(--track-display);
  margin: 0;
  overflow-wrap: anywhere;
  min-width: 0;
}

.tnum { font-variant-numeric: tabular-nums; }
/* a measured value must never break across lines. "29d 14h" reads as two
   different numbers the moment the line ends between them */
.nw { white-space: nowrap; }

a { color: var(--color-ink-2); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--color-accent); }
a:active { color: var(--color-accent-dim); }
:focus-visible {
  outline: var(--rule-bold) solid var(--color-focus);
  outline-offset: 2px;
}

/* ============ N6 · masthead ============ */
.masthead { border-bottom: var(--rule-bold) solid var(--color-ink); }
.masthead__top {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: var(--space-md); flex-wrap: wrap;
  padding-block: var(--space-md) var(--space-2xs);
}
.wordmark {
  font-family: var(--font-display);
  overflow-wrap: anywhere; min-width: 0;
  font-weight: 700;
  font-size: clamp(2rem, 6vw, 3.25rem);
  line-height: 1.0;
  letter-spacing: var(--track-display);
  text-transform: uppercase;
  margin: 0;
}
.wordmark em { font-style: normal; color: var(--color-accent); }
.masthead__sub {
  font-family: var(--font-body);
  font-size: var(--text-xs);
  color: var(--color-muted);
  letter-spacing: 0.04em;
  padding-bottom: var(--space-3xs);
}
.masthead__issue {
  display: flex; gap: var(--space-md); flex-wrap: wrap; align-items: center;
  border-top: var(--rule-hair) solid var(--color-rule);
  padding-block: var(--space-2xs);
  font-family: var(--font-outlier);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-muted);
}
.masthead__issue b { color: var(--color-ink-2); font-weight: 500; }

/* theme toggle, sits at the end of the issue row */
.themer {
  margin-left: auto;
  display: inline-flex; align-items: center; gap: var(--space-2xs);
  background: none; border: var(--rule-hair) solid var(--color-rule);
  color: var(--color-muted);
  font-family: inherit; font-size: inherit; letter-spacing: inherit;
  text-transform: inherit;
  padding: var(--space-3xs) var(--space-2xs);
  min-height: 28px;
  cursor: pointer;
  transition: color var(--dur-short) var(--ease-out),
              border-color var(--dur-short) var(--ease-out);
}
.themer:hover { color: var(--color-ink); border-color: var(--color-ink-2); }
.themer:focus-visible { outline: var(--rule-bold) solid var(--color-focus); outline-offset: 2px; }
.themer:active { color: var(--color-accent); }
.themer:disabled { opacity: 0.55; cursor: not-allowed; }
.themer__swatch {
  width: 10px; height: 10px; border-radius: 50%;
  border: var(--rule-hair) solid var(--color-ink-2);
  background: linear-gradient(90deg, var(--color-ink) 0 50%, var(--color-paper) 50% 100%);
}
.live { display: inline-flex; align-items: center; gap: var(--space-2xs); }
.dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--color-good);
  animation: pulse 2.4s var(--ease-in-out) infinite;
}
.dot.is-stale { background: var(--color-muted); animation: none; }
.dot.is-err { background: var(--color-bad); animation: none; }
@keyframes pulse { 0%,100% { opacity: 1 } 50% { opacity: 0.35 } }

/* ============ H4 · stat hero ============ */
.hero { padding-block: var(--space-lg) var(--space-2xl); }
/* paragraphs in the stat furniture carry their spacing from the scale, not from
   the UA's 1em default, otherwise the hero rhythm goes slack */
.hero__label, .margin-stat p, .rail__pct, .rail__ends, .masthead__sub { margin: 0; }

.hero__label {
  font-family: var(--font-body);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: var(--track-label);
  color: var(--color-muted);
}
.hero__figure {
  font-family: var(--font-display);
  overflow-wrap: anywhere; min-width: 0;
  font-weight: 700;
  font-size: var(--text-display);
  line-height: 0.82;
  letter-spacing: -0.03em;
  color: var(--color-accent);
  margin-block: var(--space-2xs) var(--space-sm);
}
.hero__figure .u { font-size: 0.42em; color: var(--color-ink-2); margin-left: 0.04em; }
.hero__headline {
  font-size: var(--text-3xl);
  line-height: 1.02;
  max-width: 20ch;
  text-transform: uppercase;
}
.hero__qual {
  color: var(--color-ink-2);
  margin: var(--space-sm) 0 0;
  max-width: 52ch;
}
.hero__qual b { color: var(--color-ink); font-weight: 600; }
/* the standing description of what this page is, static, so it is in the HTML
   for crawlers and readable before any data arrives */
.hero__lede {
  margin: var(--space-md) 0 0;
  max-width: 62ch;
  font-size: var(--text-sm);
  color: var(--color-muted);
}
.hero__lede strong { color: var(--color-ink-2); font-weight: 600; }

.hero__pair {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: var(--space-md);
  margin-top: var(--space-lg);
  border-top: var(--rule-hair) solid var(--color-rule);
  padding-top: var(--space-md);
}
.margin-stat .k {
  font-family: var(--font-body);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: var(--track-label);
  color: var(--color-muted);
}
.margin-stat .v {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(1.75rem, 4vw, 2.75rem);
  line-height: 1;
  margin-block: var(--space-3xs) var(--space-2xs);
}
.margin-stat .n { font-size: var(--text-sm); color: var(--color-muted); }
.is-under { color: var(--color-good); }
.is-over  { color: var(--color-bad); }

/* ============ progress rail ============ */
.rail { padding-block: var(--space-lg) var(--space-2xl); }
.rail__head {
  display: flex; justify-content: space-between; align-items: baseline;
  gap: var(--space-sm); flex-wrap: wrap;
  /* clearance for the record-pace pin label that hangs above the track */
  margin-bottom: var(--space-lg);
}
.rail__pct {
  font-family: var(--font-display); font-weight: 700;
  font-size: var(--text-2xl); line-height: 1;
}
.rail__pct span { color: var(--color-accent); }
.rail__ends {
  font-family: var(--font-body); font-size: var(--text-xs);
  color: var(--color-muted); letter-spacing: 0.03em;
}
.track {
  position: relative; height: 14px;
  background: var(--color-paper-2);
  border: var(--rule-hair) solid var(--color-rule);
}
.fill {
  position: absolute; inset: 0 0 0 0;
  background: var(--color-accent);
  transform-origin: left center;
  transform: scaleX(0);
  transition: transform var(--dur-medium) var(--ease-out);
}
.pin { position: absolute; top: -6px; bottom: -6px; width: var(--rule-bold); }
.pin::after {
  content: attr(data-label);
  position: absolute; left: 50%; transform: translateX(-50%);
  font-family: var(--font-body); font-size: 0.625rem;
  letter-spacing: 0.06em; text-transform: uppercase; white-space: nowrap;
}
.pin--record { background: var(--color-record); }
.pin--record::after { top: -1.15rem; color: var(--color-record); }
.pin--goal { background: var(--color-goal); }
.pin--goal::after { bottom: -1.15rem; color: var(--color-goal); }

/* ============ live "right now" band ============ */
.now {
  padding-block: var(--space-lg) var(--space-xl);
  border-top: var(--rule-bold) solid var(--color-accent);
}
.now__head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: var(--space-sm); flex-wrap: wrap; margin-bottom: var(--space-md);
}
.now__status {
  margin: 0;
  display: inline-flex; align-items: center; gap: var(--space-2xs);
  font-family: var(--font-body); font-weight: 600;
  font-size: var(--text-xs); text-transform: uppercase;
  letter-spacing: var(--track-label);
  /* ink, not accent: the accent reads 4.23:1 on the dark surface at 12px and
     the floor for small text is 4.5. The pip carries the accent instead. */
  color: var(--color-ink-2);
}
.now__pip {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--color-accent);
}
/* resting is a state, not a fault: drop the accent and stop the pulse */
.now.is-resting { border-top-color: var(--color-rule); }
.now.is-resting .now__status { color: var(--color-muted); }
.now.is-resting .now__pip { background: var(--color-muted); }

.now__stamp {
  /* body face, not the mono outlier: three registers of mono on one page turns
     a register into a third body font (gate 38) */
  margin: 0; font-family: var(--font-body);
  font-size: var(--text-xs); color: var(--color-muted); letter-spacing: 0.03em;
}

/* where he is, in words. Sits under the status line, above the figures. */
.now__where {
  margin: 0 0 var(--space-md);
  font-size: var(--text-lg);
  color: var(--color-ink);
  max-width: 60ch;
}
.now__where .place { font-weight: 600; }
.now__where .sep { color: var(--color-rule); margin-inline: var(--space-2xs); }
.now__where .meta { color: var(--color-muted); font-size: var(--text-sm); }

.now__grid {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--space-md) var(--space-lg);
}
.now__k {
  margin: 0; font-size: var(--text-xs); text-transform: uppercase;
  letter-spacing: var(--track-label); color: var(--color-muted);
}
.now__v {
  margin: var(--space-3xs) 0 0;
  font-family: var(--font-display); font-weight: 700;
  font-size: clamp(1.75rem, 3.6vw, 2.5rem); line-height: 1;
  overflow-wrap: anywhere; min-width: 0;
}
.now__v .u {
  font-size: 0.4em; color: var(--color-ink-2);
  margin-left: 0.15em; letter-spacing: 0;
}
.now__n {
  margin: var(--space-3xs) 0 0;
  font-size: var(--text-sm); color: var(--color-muted);
}
.now__figure { margin: var(--space-lg) 0 0; }
.now__cap {
  margin-top: var(--space-2xs);
  font-size: var(--text-xs); color: var(--color-muted);
}

/* ============ section rhythm ============ */
.band { padding-block: var(--space-2xl); border-top: var(--rule-hair) solid var(--color-rule); }
.band__head { margin-bottom: var(--space-lg); }
.band__head h2 {
  font-size: var(--text-3xl);
  line-height: 1.04;
  text-transform: uppercase;
}
.band__head p {
  color: var(--color-muted);
  margin: var(--space-2xs) 0 0;
  max-width: 62ch;
  font-size: var(--text-sm);
}

/* ============ F3 · tabular spec sheet ============ */
.sheet { width: 100%; border-collapse: collapse; }
.sheet caption { text-align: left; }
.sheet tr { border-bottom: var(--rule-hair) solid var(--color-rule-soft); }
.sheet tr:first-child { border-top: var(--rule-hair) solid var(--color-rule); }
.sheet th, .sheet td { text-align: left; padding-block: var(--space-xs); vertical-align: baseline; }
.sheet th {
  font-family: var(--font-body); font-weight: 500;
  font-size: var(--text-xs); text-transform: uppercase;
  letter-spacing: var(--track-label); color: var(--color-muted);
  width: 34%;
}
.sheet .val {
  font-family: var(--font-display); font-weight: 700;
  font-size: var(--text-xl); line-height: 1;
  white-space: nowrap;
}
.sheet .unit {
  font-family: var(--font-body); font-weight: 500;
  font-size: var(--text-sm); color: var(--color-ink-2);
  margin-left: var(--space-3xs);
}
.sheet .note {
  font-size: var(--text-sm); color: var(--color-muted);
  text-align: right; width: 34%;
}

/* ============ charts ============ */
.figure { margin: 0; }
.figure--stacked { margin-top: var(--space-md); }
.chart__cap {
  margin-top: var(--space-2xs);
  font-size: var(--text-xs);
  color: var(--color-muted);
}
.chart { position: relative; width: 100%; }
canvas { display: block; width: 100% !important; }
.duo { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr); gap: var(--space-xl); }
.duo .band__head { margin-bottom: var(--space-md); }

#map { height: 22rem; border: var(--rule-hair) solid var(--color-rule); }
.leaflet-container { background: var(--color-paper-2); font-family: var(--font-body); }
/* Leaflet ships Lucida Console on its zoom controls, a fourth family on the
   page. Fold it back into the body face. */
.leaflet-container .leaflet-control-zoom-in,
.leaflet-container .leaflet-control-zoom-out {
  font-family: var(--font-body);
  /* Leaflet ships black-on-white controls, which strand on the dark basemap */
  background: var(--color-paper);
  color: var(--color-ink);
  border-color: var(--color-rule);
}
.leaflet-container .leaflet-control-zoom-in:hover,
.leaflet-container .leaflet-control-zoom-out:hover { background: var(--color-paper-2); }
.leaflet-container .leaflet-control-attribution {
  background: var(--color-paper);
  color: var(--color-muted);
}
.leaflet-container .leaflet-control-attribution a { color: var(--color-ink-2); }

.key {
  display: flex; gap: var(--space-md); flex-wrap: wrap;
  margin-top: var(--space-sm);
  font-family: var(--font-body); font-size: var(--text-xs);
  color: var(--color-ink-2); letter-spacing: 0.03em;
}
.key span { display: inline-flex; align-items: center; gap: var(--space-2xs); }
.key i { width: 16px; height: 2px; background: currentColor; display: inline-block; }
.key i.dash { background: repeating-linear-gradient(90deg, currentColor 0 5px, transparent 5px 9px); }

/* ============ sleep strip ============ */
.nights { display: flex; flex-direction: column; }
.night {
  display: grid; grid-template-columns: 9rem minmax(0,1fr) 7rem;
  align-items: center; gap: var(--space-sm);
  padding-block: var(--space-xs);
  border-bottom: var(--rule-hair) solid var(--color-rule-soft);
}
.night:first-child { border-top: var(--rule-hair) solid var(--color-rule); }
.night__day { font-family: var(--font-body); font-size: var(--text-xs); color: var(--color-ink-2); letter-spacing: 0.04em; }
.night__strip { position: relative; height: 14px; background: var(--color-paper-2); }
.seg { position: absolute; top: 0; bottom: 0; }
.seg--move { background: var(--color-accent-dim); }
.seg--rest { background: repeating-linear-gradient(45deg, var(--color-paper-3) 0 5px, var(--color-paper-2) 5px 10px); }
.night--now .night__km { color: var(--color-accent-text); }
.night__est {
  font-size: 0.85em; color: var(--color-muted);
  border-bottom: 1px dotted var(--color-rule); cursor: help;
  text-decoration: none;
}
.night__km { font-family: var(--font-body); font-size: var(--text-xs); color: var(--color-muted); text-align: right; }

/* ============ T4 · comparison strip ============ */
/* six items, so 3×2 sits square, a 4-wide grid strands two empty cells */
.compare {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-xl) var(--space-lg);
}
.compare__v {
  font-family: var(--font-display); font-weight: 700;
  font-size: clamp(2.25rem, 4.5vw, 3.25rem); line-height: 0.95;
  letter-spacing: var(--track-display);
  color: var(--color-accent);
  overflow-wrap: anywhere; min-width: 0;
}
.compare__v .u {
  font-size: 0.42em; color: var(--color-ink-2);
  margin-left: 0.15em; letter-spacing: 0;
}
.compare__k {
  font-size: var(--text-md); font-weight: 600;
  margin-top: var(--space-2xs);
}
.compare__n {
  font-size: var(--text-sm); color: var(--color-muted);
  margin-top: var(--space-3xs); max-width: 34ch;
}

/* ============ method ============ */
.methods { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: var(--space-lg); }
.method { border-top: var(--rule-bold) solid var(--color-rule); padding-top: var(--space-sm); }
/* the one the headline actually uses carries the accent rule */
.method--lead { border-top-color: var(--color-accent); }
/* .method p is (0,1,1) and would otherwise win on specificity, leaving this
   marker muted grey instead of accent */
.method .method__lead {
  font-family: var(--font-body); font-size: var(--text-xs);
  text-transform: uppercase; letter-spacing: var(--track-label);
  color: var(--color-accent-text);
}
.method h3 {
  font-size: var(--text-lg); text-transform: uppercase; line-height: 1.05;
}
.method .d {
  font-family: var(--font-display); font-weight: 700;
  font-size: var(--text-2xl); line-height: 1; margin-top: var(--space-2xs);
}
.method p { font-size: var(--text-sm); color: var(--color-muted); margin: var(--space-2xs) 0 0; }

/* ============ Ft4 · dense colophon ============ */
.colophon {
  border-top: var(--rule-bold) solid var(--color-ink);
  margin-top: var(--space-2xl);
  padding-block: var(--space-lg) var(--space-2xl);
  font-family: var(--font-outlier);
  font-size: var(--text-xs);
  line-height: 1.7;
  color: var(--color-muted);
}
/* the measure lives on the paragraphs, the element itself stays full-width so
   the colophon keeps the page's shell alignment */
.colophon p { max-width: 72ch; }
.colophon b { color: var(--color-ink-2); font-weight: 500; }

/* ============ responsive ============ */
@media (max-width: 60rem) {
  .duo { grid-template-columns: minmax(0,1fr); gap: var(--space-2xl); }
  .methods { grid-template-columns: minmax(0,1fr); gap: var(--space-md); }
  .compare { grid-template-columns: repeat(2, minmax(0,1fr)); gap: var(--space-lg); }
  .now__grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
}
@media (max-width: 40rem) {
  .hero__pair { grid-template-columns: minmax(0,1fr); gap: var(--space-md); }
  .sheet th { width: 44%; }
  .sheet .note { display: none; }
  .night { grid-template-columns: 5.5rem minmax(0,1fr) 4.5rem; }
  .compare { grid-template-columns: minmax(0,1fr); gap: var(--space-md); }
  .now__grid { grid-template-columns: repeat(2, minmax(0,1fr)); gap: var(--space-md); }
  #map { height: 16rem; }
  /* WCAG AA hit targets. Leaflet ships 30px controls; the theme toggle sits
     at 28px, which is under the 44px floor for touch. */
  .leaflet-touch .leaflet-bar a { width: 44px; height: 44px; line-height: 44px; }
  .themer { min-height: 44px; padding-inline: var(--space-sm); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 150ms !important;
  }
}
