/* ===========================================================================
   Reset, document rhythm and the input-hardware bifurcation.
   Everything here is device-ergonomics, not decoration.
   =========================================================================== */

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
  /* Pulling the page past its own edge on iOS detaches the fixed tab bar. */
  overscroll-behavior-y: none;
  background: var(--canvas);
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--canvas);
  color: var(--ink);
  font-family: var(--font);
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  /* Grey flash on every tap is the single loudest "this is a web page" tell. */
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: contain;
}

h1, h2, h3, h4, p, figure, blockquote, dl, dd { margin: 0; }
ul, ol { margin: 0; padding: 0; list-style: none; }
img, video, canvas { display: block; max-width: 100%; }
/* Icons are inline with the text they label, so they must NOT be display:block —
   that pushes the icon onto its own line inside every button, tag and meta row.
   Charts and standalone marks opt back into block themselves. */
svg { max-width: 100%; vertical-align: -0.125em; }
button, input, select, textarea { font: inherit; color: inherit; }
button { background: none; border: 0; padding: 0; cursor: pointer; }
a { color: inherit; text-decoration: none; }

h1 { font-size: var(--fs-h1); line-height: var(--lh-tight); letter-spacing: var(--tracking-tight); font-weight: 650; }
h2 { font-size: var(--fs-h2); line-height: var(--lh-snug); letter-spacing: var(--tracking-tight); font-weight: 640; }
h3 { font-size: var(--fs-h3); line-height: var(--lh-snug); font-weight: 620; }

/* --- Focus: visible for keyboards, silent for pointers -------------------- */
:focus { outline: none; }
:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
  border-radius: var(--r-xs);
}

.skip-link {
  position: fixed;
  top: 0; left: 0;
  z-index: 100;
  transform: translateY(-120%);
  padding: 0.7rem 1.1rem;
  background: var(--brand);
  color: var(--on-brand);
  font-weight: 650;
  border-bottom-right-radius: var(--r-sm);
  transition: transform var(--t-base) var(--ease);
}
.skip-link:focus-visible { transform: translateY(0); }

/* --- Scrollbars ----------------------------------------------------------- */
* { scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
  background: var(--line-strong);
  border: 3px solid transparent;
  background-clip: content-box;
  border-radius: var(--r-pill);
}
*::-webkit-scrollbar-thumb:hover { background: var(--ink-3); background-clip: content-box; }

/* --- Touch ergonomics ----------------------------------------------------- */
@media (pointer: coarse) {
  button, a[href], input, select, textarea, [role="button"], [role="tab"], .row-tap {
    min-height: 44px;
    /* Kills the 300ms double-tap-zoom wait on every control. */
    touch-action: manipulation;
  }
  /* iOS Safari zooms the viewport for any field under 16px. Never do that. */
  input, select, textarea { font-size: max(16px, 1rem); }
  .u-hover-only { display: none !important; }
}

@media (hover: hover) and (pointer: fine) {
  .u-touch-only { display: none !important; }
}

/* --- Selection & text helpers -------------------------------------------- */
::selection { background: var(--brand-glow); color: var(--ink); }

.num { font-variant-numeric: tabular-nums; font-feature-settings: "tnum" 1; }
.u-hide { display: none !important; }
.u-sr {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0;
}
.u-truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.u-clamp-2 {
  display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2;
  -webkit-box-orient: vertical; overflow: hidden;
}
.u-dim { color: var(--ink-2); }
.u-muted { color: var(--ink-3); }
.u-mono { font-family: var(--mono); }

.eyebrow {
  font-size: var(--fs-micro);
  font-weight: 680;
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
  color: var(--ink-3);
}
