/* ==========================================================================
   Fovea — reset, typography, layout primitives
   ========================================================================== */

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

* { margin: 0; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

:root[data-reduce-motion] *,
:root[data-reduce-motion] *::before,
:root[data-reduce-motion] *::after {
  animation-duration: 0.01ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.01ms !important;
  scroll-behavior: auto !important;
}

body {
  min-height: 100dvh;
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  color: var(--text-1);
  background: var(--surface-0);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-synthesis-weight: none;
  text-rendering: optimizeLegibility;
  /* The old build pinned body to 100vh with overflow:hidden, which made the
     whole site unusable on a phone. Never again. */
  overflow-x: hidden;
}

img, picture, svg, canvas, video {
  display: block;
  max-width: 100%;
}

input, button, textarea, select { font: inherit; color: inherit; }

button { background: none; border: none; padding: 0; cursor: pointer; }

p, h1, h2, h3, h4, h5, h6 { overflow-wrap: break-word; }

ul, ol { padding: 0; list-style: none; }

a { color: var(--text-brand); text-decoration-thickness: 1px; text-underline-offset: 0.18em; }
a:hover { text-decoration-thickness: 2px; }

hr { border: none; border-top: var(--border-width) solid var(--border-1); margin: var(--space-8) 0; }

/* ------------------------------------------------------------------ focus
   Focus is how a keyboard user knows where they are. In an app used by people
   with low vision it gets a thick, high-contrast, double ring that survives any
   background — including the mid-grey test field. */
:focus { outline: none; }

:focus-visible {
  outline: 3px solid var(--brand-500);
  outline-offset: 2px;
  border-radius: var(--radius-xs);
}

:root[data-test-mode] :focus-visible {
  outline: 3px solid #000;
  box-shadow: 0 0 0 6px #fff;
}

/* --------------------------------------------------------------- headings */

h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: var(--weight-semibold);
  line-height: var(--leading-tight);
  letter-spacing: var(--tracking-tight);
  color: var(--text-1);
  text-wrap: balance;
}

h1 { font-size: var(--text-4xl); }
h2 { font-size: var(--text-2xl); letter-spacing: var(--tracking-snug); }
h3 { font-size: var(--text-xl);  letter-spacing: var(--tracking-snug); }
h4 { font-size: var(--text-lg);  letter-spacing: 0; font-weight: var(--weight-semibold); }

@media (max-width: 40rem) {
  h1 { font-size: var(--text-3xl); }
  h2 { font-size: var(--text-xl); }
}

p { text-wrap: pretty; }

/* ------------------------------------------------------------- utilities */

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* Visible when focused — the skip link. */
.skip-link {
  position: absolute;
  top: var(--space-2);
  left: var(--space-2);
  z-index: var(--z-toast);
  padding: var(--space-3) var(--space-5);
  background: var(--surface-0);
  color: var(--text-1);
  border: 2px solid var(--brand-500);
  border-radius: var(--radius-md);
  font-weight: var(--weight-semibold);
  box-shadow: var(--shadow-lg);
  transform: translateY(-200%);
  transition: transform var(--dur-fast) var(--ease-out);
}
.skip-link:focus { transform: translateY(0); }

.muted    { color: var(--text-2); }
.subtle   { color: var(--text-3); }
.mono     { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.tabular  { font-variant-numeric: tabular-nums; }
.measure  { max-width: var(--measure); }
.center   { text-align: center; }
.nowrap   { white-space: nowrap; }

.eyebrow {
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-caps);
  text-transform: uppercase;
  color: var(--text-3);
}

.lede {
  font-size: var(--text-lg);
  line-height: var(--leading-relaxed);
  color: var(--text-2);
  max-width: var(--measure);
}

/* --------------------------------------------------------------- layout */

.container {
  width: 100%;
  max-width: var(--container-lg);
  margin-inline: auto;
  padding-inline: var(--space-5);
}
.container--sm { max-width: var(--container-sm); }
.container--md { max-width: var(--container-md); }
.container--xl { max-width: var(--container-xl); }

@media (min-width: 48rem) {
  .container { padding-inline: var(--space-8); }
}

.stack > * + * { margin-top: var(--flow, var(--space-4)); }
.stack--sm { --flow: var(--space-2); }
.stack--lg { --flow: var(--space-6); }
.stack--xl { --flow: var(--space-10); }

.row {
  display: flex;
  align-items: center;
  gap: var(--gap, var(--space-3));
  flex-wrap: wrap;
}
.row--between { justify-content: space-between; }
.row--end     { justify-content: flex-end; }
.row--center  { justify-content: center; }
.row--top     { align-items: flex-start; }

.grid { display: grid; gap: var(--gap, var(--space-5)); }
.grid--auto { grid-template-columns: repeat(auto-fill, minmax(min(100%, 17rem), 1fr)); }
.grid--2 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 20rem), 1fr)); }

.section { padding-block: var(--space-16); }
.section--tight { padding-block: var(--space-10); }

@media (min-width: 48rem) {
  .section { padding-block: var(--space-24); }
}

.spacer { flex: 1 1 auto; }

/* Screen wrapper used by every routed view. */
.view {
  display: block;
  animation: view-in var(--dur-normal) var(--ease-out);
}

@keyframes view-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}

/* -------------------------------------------------------------- printing */

@media print {
  /* Reports go to paper or PDF. Force the light palette, drop all chrome. */
  :root, :root[data-theme="dark"] {
    --surface-0: #fff; --surface-1: #fff; --surface-2: #fff; --surface-3: #fff;
    --text-1: #000; --text-2: #222; --text-3: #444;
    --border-1: #bbb; --border-2: #888; --border-3: #666;
  }
  body { background: #fff; color: #000; }
  .no-print, .site-header, .site-footer nav, .skip-link { display: none !important; }
  .view { animation: none; }
  a[href^="http"]::after { content: " (" attr(href) ")"; font-size: 0.85em; color: #555; }
  h1, h2, h3 { break-after: avoid; }
  .card, .result-card, table { break-inside: avoid; }
  @page { size: A4; margin: 15mm; }
}
