/* ==========================================================================
   TheCalculatory — Base
   Reset, document defaults, typography primitives, layout containers.
   Every value comes from tokens.css. No literals.
   ========================================================================== */

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

* { margin: 0; }

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

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

body {
  background: var(--canvas);
  background-image:
    radial-gradient(60rem 40rem at 50% -10rem,
      oklch(61% 0.191 258 / 0.05) 0%, transparent 70%);
  background-attachment: fixed;
  color: var(--on-surface);
  font-family: var(--font-sans);
  font-size: var(--text-body-lg);
  line-height: var(--lh-body-lg);
  font-weight: var(--weight-regular);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

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

/* Components set explicit display values (inline-flex, grid, …) which would
   otherwise beat the user-agent [hidden] rule and leave "hidden" elements
   visible. This makes the attribute authoritative everywhere. */
[hidden] { display: none !important; }

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

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

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

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

/* ---------- Numeric engine rule ----------
   Every numeral on the site uses tabular figures and a slashed zero so
   results never jitter horizontally while the user types. */
.num, input[type="number"], input[inputmode="decimal"],
table td, .readout, .metric-value, .mono {
  font-family: var(--font-mono);
  font-feature-settings: "tnum" 1, "zero" 1;
  font-variant-numeric: tabular-nums slashed-zero;
}

/* ---------- Typography primitives ---------- */
/* Sizes are fluid via clamp(), so no per-heading breakpoints are needed. */
h1, .headline-xl {
  font-size: var(--text-headline-xl);
  line-height: var(--lh-headline-xl);
  font-weight: var(--weight-bold);
  letter-spacing: var(--tracking-tighter);
  text-wrap: balance;
}
h2, .headline-lg {
  font-size: var(--text-headline-lg);
  line-height: var(--lh-headline-lg);
  font-weight: var(--weight-bold);
  letter-spacing: var(--tracking-tight);
  text-wrap: balance;
}
h3, .headline-md {
  font-size: var(--text-headline-md);
  line-height: var(--lh-headline-md);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-snug);
}

.body-md { font-size: var(--text-body-md); line-height: var(--lh-body-md); }
.body-sm { font-size: var(--text-body-sm); line-height: var(--lh-body-sm); }

.text-muted   { color: var(--on-surface-muted); }
.text-variant { color: var(--on-surface-variant); }

/* Mono eyebrow label — section kickers, metric captions */
.eyebrow {
  font-family: var(--font-mono);
  font-size: var(--text-mono-sm);
  line-height: var(--lh-mono-sm);
  font-weight: var(--weight-medium);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  color: var(--on-surface-muted);
}

.mono-label {
  font-family: var(--font-mono);
  font-size: var(--text-mono-md);
  line-height: var(--lh-mono-md);
  font-weight: var(--weight-medium);
  letter-spacing: var(--tracking-normal);
}

/* ---------- Layout ---------- */
.container {
  width: 100%;
  max-width: var(--container-max);
  margin-inline: auto;
  padding-inline: var(--gutter-lg);
}
@media (max-width: 30rem) { .container { padding-inline: var(--gutter); } }

.prose { max-width: var(--container-prose); }
.prose p + p { margin-top: var(--gutter); }
.prose p { color: var(--on-surface-variant); text-wrap: pretty; }

.stack > * + * { margin-top: var(--space-lg); }
.stack-sm > * + * { margin-top: var(--space-sm); }

.section { margin-top: var(--space-3xl); }

.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: var(--space-sm); top: var(--space-sm);
  transform: translateY(-200%);
  background: var(--surface); color: var(--on-surface);
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius);
  box-shadow: var(--elev-3);
  z-index: var(--z-modal);
  transition: transform var(--duration) var(--ease);
}
.skip-link:focus { transform: translateY(0); }
