@font-face {
  font-family: "Newsreader";
  font-style: normal;
  font-weight: 200 800;
  font-display: swap;
  src: url(../fonts/newsreader-latin-standard-normal.woff2) format("woff2-variations");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Newsreader";
  font-style: normal;
  font-weight: 200 800;
  font-display: swap;
  src: url(../fonts/newsreader-latin-ext-standard-normal.woff2) format("woff2-variations");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Newsreader";
  font-style: italic;
  font-weight: 200 800;
  font-display: swap;
  src: url(../fonts/newsreader-latin-standard-italic.woff2) format("woff2-variations");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Newsreader";
  font-style: italic;
  font-weight: 200 800;
  font-display: swap;
  src: url(../fonts/newsreader-latin-ext-standard-italic.woff2) format("woff2-variations");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Plex Mono";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url(../fonts/ibm-plex-mono-latin-400-normal.woff2) format("woff2");
}
@font-face {
  font-family: "Plex Mono";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url(../fonts/ibm-plex-mono-latin-500-normal.woff2) format("woff2");
}

:root {
  --paper: #f1ede4;
  --paper-2: #e8e3d7;
  --ink: #15140f;
  --ink-2: #4b473e;
  --ink-3: #8b8578;
  --rule: rgba(21, 20, 15, 0.14);
  --verm: #d0391b;

  --serif: "Newsreader", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --mono: "Plex Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;

  --gutter: clamp(20px, 4.2vw, 64px);
  --max: 1280px;
  --mast: 64px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: clamp(17px, 1.05vw + 10px, 20px);
  line-height: 1.5;
  font-optical-sizing: auto;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-feature-settings: "kern", "liga", "onum";
}

::selection { background: var(--verm); color: var(--paper); }

a { color: inherit; text-decoration-thickness: 1px; text-underline-offset: 0.18em; text-decoration-color: var(--rule); transition: text-decoration-color 0.2s; }
a:hover { text-decoration-color: currentColor; }
:focus-visible { outline: 2px solid var(--verm); outline-offset: 3px; }

i, em { font-style: italic; }
sub { font-size: 0.68em; line-height: 0; }

.kicker {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin: 0 0 1.4rem;
}

/* ---------- Masthead ---------- */

.masthead {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 20;
  height: var(--mast);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--gutter);
  pointer-events: none;
}
.masthead > * { pointer-events: auto; }
.masthead::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(var(--paper) 30%, rgba(241, 237, 228, 0));
  opacity: var(--mast-bg, 0);
  transition: opacity 0.3s;
  pointer-events: none;
  z-index: -1;
}
.wordmark {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  font-size: 21px;
  font-weight: 500;
  letter-spacing: -0.01em;
}
.wordmark .mark { width: 22px; height: 22px; }
.nav { display: flex; gap: clamp(16px, 2.4vw, 32px); }
.nav a {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--ink-2);
}
.nav a:hover { color: var(--ink); }

.analytics-notice {
  position: fixed;
  top: calc(var(--mast) + 12px);
  left: var(--gutter);
  right: var(--gutter);
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 16px;
  border: 1px solid var(--rule);
  background: var(--paper);
  font-family: var(--mono);
  font-size: 11px;
}
.analytics-notice button { border: 0; padding: 8px; background: transparent; color: var(--ink-2); font: inherit; cursor: pointer; }

/* ---------- Story ---------- */

.story { position: relative; }

.stage { position: relative; }
.js .stage {
  height: 100vh;
  height: 100svh;
  min-height: 560px;
  overflow: hidden;
}

.field {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: none;
}
.js .field { display: block; }

/* Without JS, beats read as a short essay. */
.beat { padding: 0 var(--gutter); max-width: var(--max); margin: 0 auto 3rem; }
.beat--question { padding-top: 18vh; }

.js .beat {
  position: absolute;
  margin: 0;
  max-width: none;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translate3d(0, var(--dy, 0px), 0);
  will-change: opacity, transform;
}
.js .beat--question {
  inset: 0;
  padding: 0 var(--gutter);
  display: grid;
  place-items: center;
  opacity: 1;
  visibility: visible;
}
.js .beat--top {
  left: 0;
  right: 0;
  top: calc(var(--mast) + 4vh);
}
.js .beat--top > * { max-width: 21ch; }
.js .beat--agents > *, .js .beat--source > .beat-sub { max-width: 34ch; }
.js .beat--side {
  left: 0;
  top: 50%;
  transform: translate3d(0, calc(-50% + var(--dy, 0px)), 0);
  width: min(46vw, 640px);
}
.js .beat--fig {
  right: var(--gutter);
  bottom: calc(5vh + 64px);
  width: min(38vw, 440px);
}

.q {
  margin: 0;
  font-weight: 340;
  font-size: clamp(42px, 6.6vw, 112px);
  line-height: 1.02;
  letter-spacing: -0.028em;
  text-align: center;
  max-width: 14ch;
  text-wrap: balance;
}
.js .q { grid-area: 1 / 1; }
.q--old { color: var(--ink); }
.js .q--new { opacity: 0; }
html:not(.js) .q--old { text-decoration: line-through; text-decoration-thickness: 2px; color: var(--ink-3); font-size: 0.6em; }

.beat-big {
  margin: 0 0 1rem;
  font-weight: 360;
  font-size: clamp(30px, 3.9vw, 62px);
  line-height: 1.06;
  letter-spacing: -0.022em;
  text-wrap: balance;
  text-shadow: 0 0 18px var(--paper), 0 0 6px var(--paper), 0 0 2px var(--paper);
}
.beat-sub {
  margin: 0;
  font-size: clamp(18px, 1.5vw, 24px);
  line-height: 1.4;
  color: var(--ink-2);
  text-wrap: pretty;
  text-shadow: 0 0 14px var(--paper), 0 0 4px var(--paper), 0 0 2px var(--paper);
}
.count {
  margin: 0;
  font-weight: 300;
  font-size: clamp(64px, 11vw, 176px);
  line-height: 0.9;
  letter-spacing: -0.045em;
  font-feature-settings: "lnum", "tnum";
  text-shadow: 0 0 22px var(--paper), 0 0 6px var(--paper);
}
.beat--agents .beat-sub { margin-top: 0.6rem; font-size: clamp(20px, 1.8vw, 28px); }
.beat--agents a { pointer-events: auto; }

.js .beat--tao > .beat-quote { margin: 0; max-width: none; }
.beat-quote p {
  margin: 0 0 1rem;
  max-width: 23ch;
  font-style: italic;
  font-weight: 340;
  font-size: clamp(28px, 3.3vw, 52px);
  line-height: 1.1;
  letter-spacing: -0.015em;
  text-wrap: balance;
  text-shadow: 0 0 18px var(--paper), 0 0 6px var(--paper), 0 0 2px var(--paper);
}
.beat-quote footer {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.phone-fan { display: none; }

.beat--fig figcaption {
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.55;
  color: var(--ink-2);
}
.beat--fig i { font-family: var(--serif); font-size: 14px; }
.fig-n { color: var(--verm); margin-right: 0.6em; }

.story-controls { display: none; }
.js .story-controls {
  position: absolute;
  left: var(--gutter);
  right: var(--gutter);
  bottom: max(20px, env(safe-area-inset-bottom));
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.02em;
  color: var(--ink-3);
}
.story-position { width: clamp(100px, 16vw, 200px); }
.story-track { display: block; height: 1px; margin-top: 10px; background: var(--rule); }
.story-track > span {
  display: block;
  height: 100%;
  background: var(--verm);
  transform: scaleX(0);
  transform-origin: left;
}
.story-actions { display: flex; align-items: center; gap: 20px; }
.story-actions button, .story-actions a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ink-2);
  font: inherit;
  letter-spacing: inherit;
  text-decoration: none;
  cursor: pointer;
}
.story-actions button:hover, .story-actions a:hover { color: var(--verm); }
.story-actions [hidden] { display: none; }
.story-actions a { color: var(--ink); }

@media (max-width: 760px), (max-height: 540px) {
  .js .stage {
    height: 100svh;
    height: 100dvh;
    min-height: 0;
  }
  .js .field { display: none; }
  .js .phone-fan {
    display: block;
    width: min(78vw, 100%);
    height: auto;
    aspect-ratio: 1;
    max-height: calc(100dvh - 17.5rem);
    max-width: calc(100dvh - 17.5rem);
    margin: 0 auto;
  }

  .js .beat--question { padding: calc(var(--mast) + 8px) var(--gutter) 4.5rem; }
  .q { font-size: clamp(32px, 8.4vw, 42px); }

  .js .beat--top,
  .js .beat--side {
    left: 0;
    right: 0;
    top: 50%;
    width: auto;
    transform: translate3d(0, calc(-50% + var(--dy, 0px)), 0);
  }
  .js .beat--top > *,
  .js .beat--agents > *,
  .js .beat--source > .beat-sub { max-width: 22ch; }
  .js .beat--tao > .beat-quote p { max-width: 20ch; }

  .js .beat--yenolab {
    top: calc(var(--mast) + 1.6rem);
    transform: translate3d(0, var(--dy, 0px), 0);
  }
  .js .beat--fig {
    left: var(--gutter);
    right: var(--gutter);
    top: auto;
    bottom: var(--fig-bottom, calc(4.8rem + env(safe-area-inset-bottom, 0px)));
    width: auto;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    gap: 10px;
  }

  .beat-big,
  .beat-sub,
  .count,
  .beat-quote p { text-shadow: none; }
  .beat-big { font-size: clamp(28px, 7.4vw, 36px); }
  .beat-quote p { font-size: clamp(24px, 6.4vw, 32px); }
  .count { font-size: clamp(56px, 18vw, 88px); }

  .js .story-controls {
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 16px;
    bottom: max(10px, env(safe-area-inset-bottom));
  }
  .story-position { width: 100%; display: flex; align-items: center; gap: 12px; }
  .story-track { flex: 1; margin: 0; }
  .story-actions { width: 100%; gap: 16px; }
  .story-actions button,
  .story-actions a { min-height: 40px; }
  .story-actions a { margin-left: auto; }
}

@media (min-width: 761px) and (max-height: 700px) {
  .beat-big { font-size: clamp(30px, 3.5vw, 46px); }
  .beat-quote p { font-size: clamp(28px, 3vw, 40px); }
}

/* ---------- Sections ---------- */

.record, .now, .about {
  position: relative;
  max-width: var(--max);
  margin: 0 auto;
  padding: clamp(96px, 14vh, 180px) var(--gutter) 0;
  scroll-margin-top: var(--mast);
}

.section-head h2, .now h2, .about h2 {
  margin: 0;
  font-weight: 340;
  font-size: clamp(38px, 5vw, 80px);
  line-height: 1.02;
  letter-spacing: -0.026em;
  max-width: 16ch;
  text-wrap: balance;
}
.lede {
  max-width: 40ch;
  margin: 1.6rem 0 0;
  font-size: clamp(19px, 1.5vw, 23px);
  color: var(--ink-2);
  text-wrap: pretty;
}

/* Ledger */
.ledger {
  margin: clamp(56px, 8vh, 96px) 0 0;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border-top: 1px solid var(--ink);
}
.ledger > div { padding: 18px 20px 22px 0; border-bottom: 1px solid var(--rule); }
.ledger dt {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.ledger dd {
  margin: 10px 0 0;
  font-weight: 300;
  font-size: clamp(36px, 4vw, 60px);
  line-height: 1;
  letter-spacing: -0.03em;
  font-feature-settings: "lnum", "tnum";
}
.ledger dd small { font-size: 0.36em; letter-spacing: 0; color: var(--ink-2); margin-left: 0.2em; }
.ledger-axioms { grid-column: 1 / -1; display: flex; align-items: baseline; justify-content: space-between; gap: 24px; flex-wrap: wrap; }
.ledger-axioms dd { margin: 0; font-size: clamp(15px, 1.4vw, 19px); display: flex; gap: 0.5em 1.4em; flex-wrap: wrap; }
.ledger-axioms code { font-family: var(--mono); letter-spacing: 0; }
@media (max-width: 760px) {
  .ledger { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* Entries */
.entries { list-style: none; margin: clamp(48px, 7vh, 88px) 0 0; padding: 0; counter-reset: e; }
.entry {
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr) minmax(0, 0.92fr);
  gap: 24px clamp(24px, 3.4vw, 56px);
  padding: clamp(40px, 6vh, 72px) 0;
  border-top: 1px solid var(--rule);
}
.entry:last-child { border-bottom: 1px solid var(--rule); }
.entry-meta {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.06em;
  color: var(--ink-3);
}
.entry-n {
  font-family: var(--serif);
  font-size: 44px;
  line-height: 1;
  letter-spacing: -0.03em;
  color: var(--ink);
  font-weight: 300;
  margin-bottom: 8px;
  font-feature-settings: "lnum";
}
.entry-src a { text-decoration: none; color: var(--ink-2); }
.entry-src a:hover { color: var(--ink); text-decoration: underline; }
.tag {
  align-self: flex-start;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 11px;
  color: var(--ink-2);
  border: 1px solid var(--rule);
  border-radius: 99px;
  padding: 3px 10px 2px;
}
.tag--new { color: var(--verm); border-color: currentColor; }

.entry-body h3 {
  margin: 0 0 1.1rem;
  font-weight: 400;
  font-size: clamp(26px, 2.3vw, 36px);
  line-height: 1.1;
  letter-spacing: -0.015em;
  text-wrap: balance;
}
.claim { margin: 0 0 0.8rem; max-width: 46ch; text-wrap: pretty; }
.display {
  margin: 1rem 0 1.1rem;
  font-size: clamp(24px, 2.2vw, 32px);
  letter-spacing: -0.01em;
  line-height: 1.2;
}
.display--num { font-feature-settings: "lnum", "tnum"; font-weight: 300; font-size: clamp(30px, 3vw, 44px); letter-spacing: -0.02em; }
.binom {
  display: inline-flex;
  flex-direction: column;
  vertical-align: middle;
  line-height: 1;
  font-size: 0.82em;
  text-align: center;
  margin: 0 0.12em;
  position: relative;
  padding: 0 0.32em;
}
.binom::before, .binom::after {
  content: "";
  position: absolute;
  top: -0.08em;
  bottom: -0.08em;
  width: 0.3em;
  border: 1px solid currentColor;
  border-radius: 50%;
}
.binom::before { left: 0; border-right-color: transparent; border-top-color: transparent; border-bottom-color: transparent; }
.binom::after { right: 0; border-left-color: transparent; border-top-color: transparent; border-bottom-color: transparent; }

.scope {
  margin: 1.4rem 0 0;
  max-width: 48ch;
  font-size: 0.86em;
  color: var(--ink-2);
  text-wrap: pretty;
}
.scope span {
  display: block;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: 4px;
}
.artifacts {
  list-style: none;
  padding: 0;
  margin: 1.6rem 0 0;
  display: flex;
  flex-wrap: wrap;
  gap: 10px 28px;
  font-family: var(--mono);
  font-size: 13px;
}
.artifacts a { text-decoration: none; border-bottom: 1px solid var(--ink); padding-bottom: 1px; }
.artifacts a::after { content: " ↗"; color: var(--ink-3); }
.artifacts a:hover { color: var(--verm); border-color: var(--verm); }
.artifacts span { color: var(--ink-3); margin-left: 6px; }

.compare { margin: 1.4rem 0 0; max-width: 420px; font-family: var(--mono); font-size: 12px; }
.compare > div {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2px 12px;
  padding: 6px 0;
  color: var(--ink-2);
}
.compare dt, .compare dd { margin: 0; }
.compare dd { font-feature-settings: "tnum"; }
.compare i {
  grid-column: 1 / -1;
  height: 3px;
  background: var(--ink-3);
  opacity: 0.35;
  width: calc(var(--w) * 100%);
  transform-origin: left;
}
.compare .is-ours { color: var(--ink); }
.compare .is-ours i { background: var(--verm); opacity: 1; }

.entry-fig { margin: 0; align-self: start; }
.entry-fig canvas, .entry-fig svg { display: block; width: 100%; }
.entry-fig figcaption {
  margin-top: 14px;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.6;
  color: var(--ink-2);
  max-width: 52ch;
}
.entry-fig figcaption i { font-family: var(--serif); font-size: 14px; }
.entry-fig--keich canvas { aspect-ratio: 1 / 1; cursor: crosshair; }
[data-fig="lebesgue"] { aspect-ratio: 4 / 3; touch-action: none; }
.fig-primes { aspect-ratio: 5 / 2; overflow: visible; }
.fig-sums { aspect-ratio: 5 / 2; overflow: visible; }

.svg-mono { font-family: var(--mono); font-size: 11px; fill: currentColor; }
.svg-small { font-size: 9.5px; }
.svg-serif { font-family: var(--serif); font-style: italic; font-size: 15px; fill: currentColor; }
.frac { display: block; margin-top: 4px; word-break: break-all; color: var(--ink); }

.key { display: inline-block; width: 9px; height: 12px; vertical-align: -1px; margin: 0 2px; }
.key--double { border-left: 2px solid var(--ink); border-right: 2px solid var(--ink); width: 7px; }
.key--removed { border-left: 2px solid var(--verm); width: 2px; }

.entry-fig--type { align-self: center; }
.vs { display: grid; gap: 28px; }
.vs > div { display: grid; gap: 6px; }
.vs-num {
  font-weight: 300;
  font-size: clamp(64px, 7vw, 112px);
  line-height: 0.9;
  letter-spacing: -0.04em;
  font-feature-settings: "lnum", "frac" 0;
}
.vs-num--hot { color: var(--verm); }
.vs-lab { font-family: var(--mono); font-size: 12px; color: var(--ink-2); letter-spacing: 0.04em; }

@media (max-width: 1000px) {
  .entry { grid-template-columns: minmax(0, 1fr); }
  .entry-meta { flex-direction: row; flex-wrap: wrap; align-items: baseline; gap: 10px 16px; }
  .entry-n { font-size: 32px; margin: 0; }
  .entry-fig { max-width: 560px; }
}

/* Now */
.now {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
  gap: clamp(32px, 5vw, 80px);
  align-items: center;
}
.now-fig canvas { display: block; width: 100%; aspect-ratio: 1 / 1; }
.now-text p:not(.kicker) { max-width: 42ch; color: var(--ink-2); text-wrap: pretty; }
.now-text h2 { margin-bottom: 2rem; max-width: 13ch; }
@media (max-width: 860px) {
  .now { grid-template-columns: minmax(0, 1fr); }
  .now-text { order: -1; }
}

/* About */
.about h2 { font-size: clamp(34px, 4vw, 64px); margin-bottom: 0; max-width: 16ch; }

.contact {
  list-style: none;
  padding: 0;
  margin: clamp(56px, 8vh, 96px) 0 0;
  display: flex;
  flex-wrap: wrap;
  gap: 12px 40px;
  border-top: 1px solid var(--ink);
  padding-top: 24px;
}
.contact a {
  font-size: clamp(22px, 2vw, 30px);
  text-decoration: none;
  letter-spacing: -0.01em;
}
.contact a:hover { color: var(--verm); }

.colophon {
  max-width: var(--max);
  margin: 0 auto;
  padding: clamp(80px, 12vh, 140px) var(--gutter) 40px;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink-3);
}
.colophon p { margin: 0; }

/* Reveal on scroll */
.js .reveal { opacity: 0; transform: translateY(18px); transition: opacity 0.9s cubic-bezier(.2,.7,.2,1), transform 0.9s cubic-bezier(.2,.7,.2,1); }
.js .reveal.is-in { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) {
  .js .reveal { opacity: 1; transform: none; transition: none; }
}
