/* ============================================================================
   Base: reset, typography, and the accessibility primitives every screen relies
   on (focus ring, skip link, screen-reader-only text, reduced motion).
   ============================================================================ */

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

html { -webkit-text-size-adjust: 100%; }
html, body { height: 100%; }

body {
  font-family: var(--font);
  font-size: var(--fs-base);
  line-height: var(--lh);
  color: var(--body);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4 { color: var(--ink); font-weight: 800; line-height: var(--lh-tight); letter-spacing: -.01em; text-wrap: balance; }
h1 { font-size: var(--fs-2xl); }
h2 { font-size: var(--fs-xl); }
h3 { font-size: var(--fs-lg); }
h4 { font-size: var(--fs-md); }
p  { max-width: 68ch; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
svg { display: block; }
img { max-width: 100%; height: auto; }

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: none; }

/* ---- Focus: one visible, high-contrast ring everywhere. Only shows for
   keyboard users (:focus-visible), never swallowed. ---- */
:focus { outline: none; }
:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ---- The one exception, and why it is safe -------------------------------
   The router moves focus to each page's <h1> on navigation, and the skip link
   moves it to <main>. Both targets carry tabindex="-1", which means they are
   NOT in the tab order and can only ever be focused by that code — a user
   cannot Tab onto them.

   So the ring on them never tells anyone anything they did: it appeared after
   a page change nobody asked to focus, drew a box around a heading, and made
   it read as an editable field. Suppressing it here loses nothing, because the
   thing that matters — focus actually moving, so a screen reader announces the
   new page and the next Tab starts from the right place — is unaffected.

   This is deliberately scoped to [tabindex="-1"]. Do not widen it: every real
   control still needs its ring, and removing those would make the app
   unusable by keyboard. */
[tabindex="-1"]:focus,
[tabindex="-1"]:focus-visible { outline: none; }

/* ---- Skip link: first tab stop, visually hidden until focused. ---- */
.skip-link {
  position: fixed; top: 8px; left: 8px; z-index: 1000;
  transform: translateY(-150%);
  background: var(--accent); color: var(--accent-ink);
  padding: 10px 16px; border-radius: var(--radius-sm); font-weight: 700;
  transition: transform var(--dur) var(--ease);
}
.skip-link:focus-visible { transform: translateY(0); text-decoration: none; }

/* ---- Screen-reader-only, but focusable when needed. ---- */
.visually-hidden {
  position: absolute !important; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}

/* ---- Honour a user's reduced-motion preference across the whole app. ---- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
  }
}

/* ---- Utility layout helpers used across modules. ---- */
.stack { display: flex; flex-direction: column; }
.row   { display: flex; align-items: center; }
.gap-1{gap:var(--sp-1)} .gap-2{gap:var(--sp-2)} .gap-3{gap:var(--sp-3)} .gap-4{gap:var(--sp-4)} .gap-6{gap:var(--sp-6)}
.wrap  { flex-wrap: wrap; }
.grow  { flex: 1 1 auto; min-width: 0; }
.muted { color: var(--muted); }
.nowrap{ white-space: nowrap; }
.tnum  { font-variant-numeric: tabular-nums; }
.center{ text-align: center; }
