/* Self-hosted fonts (SIL Open Font License, see assets/fonts/LICENSE.txt) */
@font-face { font-family: 'Chakra Petch'; src: url('../assets/fonts/chakra-petch-700i.woff2') format('woff2'); font-weight: 700; font-style: italic; font-display: swap; }
@font-face { font-family: 'Chakra Petch'; src: url('../assets/fonts/chakra-petch-600.woff2') format('woff2'); font-weight: 600; font-style: normal; font-display: swap; }
@font-face { font-family: 'Barlow'; src: url('../assets/fonts/barlow-400.woff2') format('woff2'); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: 'Barlow'; src: url('../assets/fonts/barlow-500.woff2') format('woff2'); font-weight: 500; font-style: normal; font-display: swap; }

/* Fallback metrics computed by tools/make-fonts.py, so text does not jump when the fonts arrive. */
@font-face { font-family: 'Display Fallback'; src: local('Arial Bold Italic'), local('Arial-BoldItalicMT'), local('Arial'); size-adjust: 101.9%; ascent-override: 97.4%; descent-override: 30.2%; }
@font-face { font-family: 'Sans Fallback'; src: local('Arial'); size-adjust: 91.4%; ascent-override: 109.4%; descent-override: 21.9%; }

*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-padding-top: calc(var(--nav-h) + 16px);
  background: var(--black-900);
  color-scheme: dark;
}
html.lenis, html.lenis body { height: auto; }
.lenis.lenis-smooth { scroll-behavior: auto !important; }
.lenis.lenis-stopped { overflow: hidden; }
body {
  min-height: 100vh;
  background: var(--black-900);
  color: var(--white);
  font-family: var(--font-sans);
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  font-synthesis: none;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow-x: clip;
}
img, svg { display: block; max-width: 100%; }
img { height: auto; }
a { color: inherit; text-decoration: none; }
button, input, textarea, select { font: inherit; color: inherit; }
button { background: none; border: 0; padding: 0; cursor: pointer; }
ul, ol { list-style: none; padding: 0; }
h1, h2, h3, h4 {
  font-family: var(--font-display); font-weight: 700; font-style: italic; text-transform: uppercase;
  line-height: var(--lh-heading); letter-spacing: -0.01em; text-wrap: balance;
}
p { text-wrap: pretty; }
strong { font-weight: 500; }
::selection { background: var(--red-500); color: var(--black-900); }

/* Layout primitives */
.wrap { width: 100%; max-width: var(--wrap); margin-inline: auto; padding-inline: var(--gutter-x); }
.grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); column-gap: var(--gap); }
.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* Chapters */
.chapter { position: relative; padding-block: var(--chapter-y); }
.chapter--deep { background: var(--black-950); }
.chapter--dark { background: var(--black-900); }
.chapter--panel { background: var(--black-850); }
.chapter--light { background: var(--paper); color: var(--ink); color-scheme: light; }

/* Film grain over dark surfaces */
.grain { position: relative; isolation: isolate; }
.grain::before {
  content: '';
  position: absolute; inset: 0; z-index: -1;
  pointer-events: none;
  opacity: 0.06;
  mix-blend-mode: soft-light;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 1 0'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 200px 200px;
}

/* Focus: always visible. Red-400 on black, ink on paper. */
:focus-visible { outline: 2px solid var(--red-400); outline-offset: 3px; }
.chapter--light :focus-visible { outline-color: var(--ink); }

.skip-link {
  position: fixed; top: 12px; left: 12px; z-index: var(--z-skip);
  padding: 0.75rem 1.125rem;
  background: var(--white); color: var(--black-900);
  font-size: var(--fs-small); font-weight: 500;
  transform: translateY(-160%);
  transition: transform var(--dur-micro) var(--ease-out);
}
.skip-link:focus-visible { transform: none; }

/* Hidden-before-reveal states exist only when motion.js is going to run (html.motion-ok is set in <head>). */
.motion-ok [data-reveal],
.motion-ok [data-hero] { opacity: 0; }
.motion-ok [data-row] > * { opacity: 0; }

/* Safety net for anyone who asks for less 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;
  }
}
