/* ============================================================================
   CARDSTOCK — BASE / COMPONENT KIT
   Shared primitives used by every page (landing + demo app). Built ONLY from
   the semantic tokens in tokens.css — never hard-coded colours. Re-skins for
   free when the theme changes. Load AFTER tokens.css.
   ============================================================================ */

/* ---- Reset ---------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html { scroll-behavior: smooth; }
html, body { min-height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: var(--fs-400);
  line-height: 1.6;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
img, svg { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; cursor: pointer; background: none; border: none; }
input { font: inherit; }

/* ---- Utilities ------------------------------------------------------------ */
.tnum { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--font-mono); }
.display { font-family: var(--font-display); }
.accent { color: var(--accent-text); }   /* accent-as-text: readable on light + dark */
.up { color: var(--pos); }
.down { color: var(--neg); }
.wrap { max-width: var(--content-max); margin-inline: auto; padding-inline: var(--space-5); }

.eyebrow {
  font-family: var(--font-mono);
  font-size: var(--fs-200);
  font-weight: 700;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--accent-text);
}

/* Headings default to display face + tight tracking on big sizes */
h1, h2, h3 { font-family: var(--font-display); letter-spacing: -.02em; line-height: 1.05; text-wrap: balance; }
h1 { font-size: var(--fs-900); font-weight: 900; letter-spacing: -.03em; line-height: 1.02; }
h2 { font-size: var(--fs-800); font-weight: 800; }
h3 { font-size: var(--fs-700); font-weight: 700; }
p  { max-width: 65ch; }

/* ---- Focus (visible, accessible) ----------------------------------------- */
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }

/* ---- Buttons -------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  font-weight: 700; font-size: var(--fs-400); line-height: 1;
  padding: 13px 22px; border-radius: var(--radius-sm);
  border: var(--hairline) solid transparent;
  transition: transform var(--dur-fast) var(--ease-std),
              box-shadow var(--dur-fast) var(--ease-std),
              background var(--dur-fast), border-color var(--dur-fast), color var(--dur-fast);
}
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn-primary:hover { transform: translateY(-2px); box-shadow: var(--accent-glow); background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-ghost { border-color: var(--border); color: var(--text); }
.btn-ghost:hover { border-color: var(--border-strong); background: var(--surface-2); }
.btn-sm { padding: 8px 14px; font-size: var(--fs-300); }

/* ---- Pills / chips -------------------------------------------------------- */
.pill {
  border-radius: var(--radius-pill); padding: 8px 16px;
  border: var(--hairline) solid var(--border); background: transparent;
  color: var(--text-muted); font-size: var(--fs-300); font-weight: 600; letter-spacing: .02em;
  transition: background var(--dur-fast), color var(--dur-fast), border-color var(--dur-fast);
}
.pill:hover { border-color: var(--border-strong); color: var(--text); }
.pill.active { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

.chip {
  background: var(--surface); border: var(--hairline) solid var(--border); color: var(--text-muted);
  border-radius: var(--radius-sm); padding: 9px 14px; font-size: var(--fs-300); font-weight: 700;
  font-family: var(--font-mono); transition: border-color var(--dur-fast), color var(--dur-fast);
}
.chip:hover { border-color: var(--border-strong); }
.chip.active { border-color: var(--accent); color: var(--accent-text); }

/* ---- Panels / cards ------------------------------------------------------- */
.panel {
  background: var(--surface); border: var(--hairline) solid var(--border);
  border-radius: var(--radius-md); padding: var(--space-5);
}
.panel-2 { background: var(--surface-2); }

/* ---- Inputs --------------------------------------------------------------- */
.input {
  width: 100%; background: var(--surface); border: var(--hairline) solid var(--border);
  color: var(--text); border-radius: var(--radius-sm); padding: 11px 14px; font-size: var(--fs-400);
  transition: border-color var(--dur-fast);
}
.input::placeholder { color: var(--text-dim); }
.input:focus { outline: none; border-color: var(--accent); }

/* ---- Stat tile ------------------------------------------------------------ */
.tile { border: var(--hairline) solid var(--border); border-radius: var(--radius-md); background: var(--surface); padding: 16px 18px; }
.tile .tile-label { font-family: var(--font-mono); font-size: var(--fs-200); letter-spacing: .1em; text-transform: uppercase; color: var(--text-dim); }
.tile .tile-value { font-family: var(--font-mono); font-size: var(--fs-600); font-weight: 700; margin-top: 6px; }

/* ---- Section rhythm ------------------------------------------------------- */
section { padding-block: var(--space-section); }

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