/* ============================================================================
   02 · BASE, reset, document defaults, shared utilities.
   No brand values here; everything reads from tokens.css.
   ========================================================================== */

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

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

body {
  margin: 0;
  /* longhand, not the `background` shorthand: a shorthand transition driven by a
     custom property can stick at the old value when the theme swaps. */
  background-color: var(--bg-app);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: var(--text-md);
  line-height: var(--leading-normal);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background-color var(--dur-base) var(--ease), color var(--dur-base) var(--ease);
}

img, svg, video { max-width: 100%; height: auto; display: block; }
h1, h2, h3, h4, h5, h6, p, figure, dl, dd { margin: 0; }
ul, ol { margin: 0; padding: 0; list-style: none; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { background: none; border: 0; cursor: pointer; }

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

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--border-strong); border-radius: var(--radius-pill);
  border: 2px solid var(--bg-app);
}
::-webkit-scrollbar-thumb:hover { background: var(--text-subtle); }

/* Set for one frame while switching theme, so nothing interpolates between palettes. */
.theme-switching, .theme-switching *, .theme-switching *::before, .theme-switching *::after {
  transition: none !important;
}

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

/* ---- typography helpers ---- */
.t-2xs { font-size: var(--text-2xs); } .t-xs { font-size: var(--text-xs); }
.t-sm  { font-size: var(--text-sm); }  .t-md { font-size: var(--text-md); }
.t-lg  { font-size: var(--text-lg); }
.t-xl  { font-size: var(--text-xl);  line-height: var(--leading-tight); font-weight: var(--weight-medium); }
.t-2xl { font-size: var(--text-2xl); line-height: var(--leading-tight); font-weight: var(--weight-semi); letter-spacing: -.01em; }
.t-3xl { font-size: var(--text-3xl); line-height: var(--leading-tight); font-weight: var(--weight-semi); letter-spacing: -.015em; }
.t-4xl { font-size: var(--text-4xl); line-height: var(--leading-tight); font-weight: var(--weight-semi); letter-spacing: -.02em; }

.muted  { color: var(--text-muted); }
.subtle { color: var(--text-subtle); }
.mono   { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.medium { font-weight: var(--weight-medium); }
.semi   { font-weight: var(--weight-semi); }
.eyebrow {
  font-family: var(--font-mono); font-size: var(--text-2xs);
  letter-spacing: .1em; text-transform: uppercase; color: var(--text-subtle);
}

/* ---- layout helpers ---- */
.row     { display: flex; align-items: center; gap: var(--sp-3); }
.row-tight { display: flex; align-items: center; gap: var(--sp-2); }
.between { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); }
.wrap-row { flex-wrap: wrap; }
.col     { display: flex; flex-direction: column; }
.grow    { flex: 1; min-width: 0; }
.stack > * + * { margin-top: var(--sp-3); }
.stack-lg > * + * { margin-top: var(--sp-6); }
.grid { display: grid; gap: var(--sp-4); }
.hidden { display: none !important; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: var(--z-toast);
  background: var(--brand); color: var(--brand-on);
  padding: var(--sp-3) var(--sp-5); border-radius: 0 0 var(--radius-sm) 0;
  font-weight: var(--weight-medium);
}
.skip-link:focus { left: 0; }
