/* ═══════════════════════════════════════════════════════════════════════════
   BASE — reset, typography, the measured-number primitive, focus, scrollbars.
   Load order: tokens → base → shell → controls → content → overlays.
   ═══════════════════════════════════════════════════════════════════════════ */

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "tnum" 1; /* columns of measurements align */
}

h1, h2, h3, h4, p { margin: 0; }

a { color: var(--accent); }

img, svg { max-width: 100%; }

/* ── Typography scale ── */
.page-title {
  font-family: var(--font-display);
  font-size: 32px;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.02em;
  color: var(--brand);
}
.page-subtitle { font-size: 16px; color: var(--text-muted); max-width: 100ch; margin-top: 4px; }
.card-title { font-size: 18px; font-weight: 600; letter-spacing: -0.01em; margin-bottom: 12px; }
.hero-title { font-size: 26px; font-weight: 700; letter-spacing: -0.02em; }
.hero-text { font-size: 16px; line-height: 1.6; max-width: 52ch; }
.stat-value { font-family: var(--font-display); font-size: 30px; font-weight: 600; }
.stat-label { font-size: 13px; color: var(--text-muted); }
.stat-change { font-size: 13px; font-weight: 600; }
.muted { color: var(--text-muted); }

/* THE most distinctive typographic move in the product: a measured number looks
   measured. Every genuinely-measured value renders in mono with tabular
   numerals — never forget the class, and never put prose in it. */
.num, .stat-value {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}

@media (max-width: 768px) {
  .page-title { font-size: 26px; }
}

/* ── Focus: the GOV.UK convention, three treatments; the DIFFERENCE is the point.

   A — things you ACTIVATE flood yellow with the black underline. */
a:focus-visible,
button:focus-visible,
.nav-item:focus-visible,
.mode-btn:focus-visible,
.view-btn:focus-visible,
.tab:focus-visible,
.scale-btn:focus-visible,
/* GOV.UK-style skip link: visually hidden until keyboard focus lands on it, then unmissable. */
.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 100;
  padding: 10px 16px;
  background: var(--focus, #FFDD00);
  color: var(--focus-ink, #212B32);
  font-weight: 600;
  text-decoration: none;
}
.skip-link:focus {
  left: 0;
  outline: 3px solid var(--focus-ink, #212B32);
}

.onboard-option:focus-within,
.onboard-option:focus-visible,
.post-reaction:focus-visible,
.patient-row:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 0;
  box-shadow: 0 4px 0 0 var(--focus-ink);
  background-color: var(--focus) !important;
  color: var(--focus-ink) !important;
  border-radius: 0;
}
.nav-item:focus-visible .nav-icon { color: var(--focus-ink) !important; }

/* B — things you TYPE INTO get the ring, never the flood: flooding a field
   yellow turns the value you're reading yellow underneath you. */
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 0;
  box-shadow: 0 4px 0 0 var(--focus-ink);
  border-color: var(--focus-ink) !important;
}

/* C — large surfaces get outline + underline without the fill: flooding a card
   blacks out its content. */
.card:focus-visible,
[role="button"]:focus-visible:not(a):not(button):not(.nav-item):not(.mode-btn):not(.view-btn) {
  outline: 3px solid var(--focus);
  outline-offset: 0;
  box-shadow: 0 4px 0 0 var(--focus-ink);
}

input:hover, select:hover, textarea:hover,
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  outline: none;
}
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid var(--focus); }

/* ── Form controls: ONE global rule so a text input and a select sitting next
      to each other cannot look different for no reason. ── */
input, select, textarea {
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: var(--font);
  font-size: 15px;
  padding: 10px 12px;
  background: var(--bg-card);
  color: var(--text);
}
label { display: block; font-weight: 600; margin-bottom: 4px; }
.field { margin-bottom: 16px; }
.field input, .field select, .field textarea { width: 100%; }

/* ── Scrollbars ── */
* { scrollbar-width: thin; scrollbar-color: var(--scroll-thumb) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
  background: var(--scroll-thumb);
  border-radius: 8px;
  border: 2px solid transparent;
  background-clip: padding-box;
}
*::-webkit-scrollbar-thumb:hover { background: var(--scroll-thumb-hover); }

/* ── Reduced motion: everything stops — EXCEPT the anatomy glyph, which freezes
      at the far end of its travel: a frozen extreme still says what the
      movement is; a frozen rest position says nothing. ── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .g-anim {
    animation-duration: 3.6s !important;
    animation-iteration-count: infinite !important;
    animation-delay: -1.8s !important;
    animation-play-state: paused !important;
  }
}
