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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-padding-top: calc(var(--masthead-h) + var(--s3));
}

body {
  margin: 0;
  min-height: 100svh;
  background: var(--night);
  color: var(--ink);
  font-family: var(--font-text);
  font-size: var(--text-base);
  line-height: var(--leading-text);
  font-optical-sizing: auto;
  -webkit-font-smoothing: antialiased;
  overflow-x: clip;
}

/* The desk the book lies on: walnut grain under a warm lamp, falling off to night. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(ellipse 55% 45% at 50% 12%, rgb(255 196 120 / 0.2), transparent 72%),
    radial-gradient(ellipse 110% 85% at 50% 28%, transparent 30%, rgb(9 13 25 / 0.94) 100%),
    repeating-linear-gradient(180deg, transparent 0 calc(25vh - 2px), rgb(8 5 3 / 0.55) calc(25vh - 2px) 25vh, rgb(255 225 190 / 0.05) 25vh calc(25vh + 1px), transparent calc(25vh + 1px) 25vh),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='1400' height='900'%3E%3Cfilter id='g'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.0022 0.26' numOctaves='3' seed='3'/%3E%3CfeColorMatrix values='0 0 0 0 0.08 0 0 0 0 0.05 0 0 0 0 0.03 0 0 0 1.5 -0.45'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23g)'/%3E%3C/svg%3E") center / cover,
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='1400' height='900'%3E%3Cfilter id='w'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.0016 0.018' numOctaves='3' seed='11'/%3E%3CfeColorMatrix values='0 0 0 0 0.45 0 0 0 0 0.29 0 0 0 0 0.18 0 0 0 1.1 -0.3'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23w)'/%3E%3C/svg%3E") center / cover,
    var(--wood);
}

/* Paper grain sits above everything but never takes input. */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 90;
  pointer-events: none;
  opacity: 0.07;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0.11 0 0 0 0 0.1 0 0 0 0 0.18 0 0 0 0.9 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

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

h1, h2, h3, h4 {
  margin: 0;
  font-weight: 600;
  line-height: var(--leading-snug);
  text-wrap: balance;
}

p { margin: 0; text-wrap: pretty; }
ul, ol { margin: 0; padding: 0; }

a {
  color: inherit;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
}

a:hover { text-decoration-thickness: 2px; }

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

button { cursor: pointer; }

:focus-visible {
  outline: 3px solid var(--ink);
  outline-offset: 3px;
  box-shadow: 0 0 0 6px var(--gold);
  border-radius: 4px;
}

::selection { background: var(--gold-light); color: var(--ink); }

.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;
}

.skip-link {
  position: fixed;
  top: var(--s1);
  left: var(--s1);
  z-index: 100;
  padding: var(--s1) var(--s2);
  background: var(--ink);
  color: var(--paper);
  border-radius: var(--radius-pill);
  transform: translateY(-200%);
  transition: transform var(--duration-default) var(--ease-out);
}

.skip-link:focus { transform: none; }

.display {
  font-family: var(--font-display);
  font-weight: 700;
  font-variation-settings: "SOFT" 60, "WONK" 0;
  letter-spacing: -0.02em;
  line-height: var(--leading-tight);
}

.caps {
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: var(--tracking-caps);
  text-transform: uppercase;
}

.muted { color: var(--ink-2); }
.tabular { font-variant-numeric: tabular-nums; }

/* Buttons: gold is the only CTA fill in the book. */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5em;
  min-height: 48px;
  padding: 0 1.5em;
  border: 2px solid var(--ink);
  border-radius: var(--radius-pill);
  background: var(--paper);
  color: var(--ink);
  font-size: var(--text-sm);
  font-weight: 600;
  letter-spacing: 0.02em;
  text-decoration: none;
  white-space: nowrap;
  box-shadow: 3px 3px 0 var(--ink);
  transition:
    transform var(--duration-fast) var(--ease-out),
    box-shadow var(--duration-fast) var(--ease-out),
    background-color var(--duration-fast) var(--ease-out);
}

.btn:hover { transform: translate(-1px, -1px); box-shadow: 4px 4px 0 var(--ink); }
.btn:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); }
.btn--primary {
  background: linear-gradient(180deg, var(--gold-light), var(--gold) 55%, var(--accent-press));
}
.btn--primary:active { background: var(--accent-press); }
.btn--ghost { box-shadow: none; }
.btn--ghost:hover { box-shadow: none; transform: none; background: var(--paper-shade); }
.btn--sm { min-height: 40px; padding: 0 1.1em; font-size: var(--text-xs); }
.btn[disabled] { opacity: 0.45; cursor: not-allowed; transform: none; box-shadow: none; }

.btn svg { width: 1.1em; height: 1.1em; flex: none; }

/* Gold highlighter that draws itself when the beat comes into view. */
.hl {
  color: inherit;
  background: linear-gradient(transparent 52%, var(--highlight) 52%, var(--highlight) 92%, transparent 92%) no-repeat 0 0 / 0% 100%;
  transition: background-size 700ms var(--ease-out) 200ms;
}

.is-seen .hl, .no-js .hl { background-size: 100% 100%; }

@media (prefers-reduced-motion: reduce) {
  .hl { background-size: 100% 100%; transition: none; }
  html { scroll-behavior: auto; }
}
