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

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 1rem;
  line-height: var(--leading-body);
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-feature-settings: "ss01", "cv11";
}

/* ---- Typography — editorial scale ---- */

h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 700;
  line-height: var(--leading-tight);
  letter-spacing: var(--tracking-tight);
  margin: 0 0 var(--sp-md) 0;
  color: var(--ink);
  font-variation-settings: "opsz" 96;
  text-wrap: balance;
}

h1 {
  font-size: clamp(2.25rem, 4.5vw + 0.5rem, 3.75rem);
  font-weight: 900;
  font-variation-settings: "opsz" 144;
  margin-bottom: var(--sp-lg);
}

h2 {
  font-size: clamp(1.75rem, 2.5vw + 0.5rem, 2.375rem);
  margin-top: var(--sp-2xl);
  margin-bottom: var(--sp-md);
}

h3 {
  font-size: 1.375rem;
  font-weight: 700;
  font-variation-settings: "opsz" 72;
  margin-bottom: var(--sp-sm);
}

h4 {
  font-size: 1.1rem;
  font-weight: 600;
  font-variation-settings: "opsz" 32;
}

p {
  margin: 0 0 var(--sp-lg) 0;
  max-width: var(--max-content);
}

.prose p { font-size: 1.0625rem; line-height: 1.65; color: var(--ink); }
.prose p + p { margin-top: -0.25rem; }

em, .italic { font-style: italic; }

/* Scoped story dek — serif italic, ember rule */
.story-dek {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 400;
  font-size: clamp(1.125rem, 1.2vw + 0.5rem, 1.375rem);
  line-height: 1.4;
  color: var(--ink-soft);
  max-width: 60ch;
  margin: 0 0 var(--sp-lg) 0;
  text-wrap: balance;
}

.story-dek::after {
  content: "";
  display: block;
  width: 48px;
  height: 3px;
  background: var(--grad-ember);
  border-radius: var(--radius-pill);
  margin-top: var(--sp-lg);
}

/* Links */
a {
  color: var(--steel-deep);
  text-decoration: none;
  border-bottom: 1px solid color-mix(in srgb, var(--steel) 30%, transparent);
  transition: border-color var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
}
a:hover { color: var(--ember); border-bottom-color: var(--ember); }

/* Inline code */
code, .mono {
  font-family: var(--font-mono);
  font-size: 0.9em;
  background: var(--paper-2);
  padding: 0.1em 0.35em;
  border-radius: var(--radius-sm);
}

/* Numerals */
table, .num, .stat, .chart-axis text, [data-num] {
  font-family: var(--font-mono);
  font-feature-settings: "tnum" on, "lnum" on;
  font-variant-numeric: tabular-nums;
}

/* Tables */
table {
  width: 100%;
  border-collapse: collapse;
  margin: var(--sp-lg) 0;
  font-size: 0.875rem;
}

th {
  background: var(--paper-2);
  color: var(--ink);
  font-family: var(--font-sans);
  font-weight: 600;
  text-align: left;
  padding: var(--sp-sm) var(--sp-md);
  border-bottom: 1px solid var(--hairline);
  letter-spacing: 0.02em;
  font-size: 0.75rem;
  text-transform: uppercase;
}

td {
  padding: var(--sp-sm) var(--sp-md);
  border-bottom: 1px solid var(--hairline);
}

tr:hover td { background: var(--paper-2); }

/* Focus — ember, always visible */
*:focus-visible {
  outline: 2px solid var(--ember);
  outline-offset: 2px;
  border-radius: 3px;
}

/* Skip link */
.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--ink);
  color: var(--paper);
  padding: var(--sp-sm) var(--sp-md);
  z-index: 1000;
  border: none;
}
.skip-link:focus { left: var(--sp-md); top: var(--sp-md); }

/* ---- Motion defaults ---- */
[data-reveal] {
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 460ms var(--ease-out), transform 460ms var(--ease-out);
  will-change: opacity, transform;
}
[data-reveal].is-in {
  opacity: 1;
  transform: none;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  [data-reveal] { opacity: 1; transform: none; }
}

/* Mobile type tune-down */
@media (max-width: 720px) {
  .prose p { font-size: 1rem; }
}
