@font-face {
  font-family: "Geist";
  src: url("assets/fonts/GeistVF.woff") format("woff");
  font-weight: 100 900;
  font-display: swap;
}
@font-face {
  font-family: "Geist Mono";
  src: url("assets/fonts/GeistMonoVF.woff") format("woff");
  font-weight: 100 900;
  font-display: swap;
}

:root {
  color-scheme: dark;
  --bg-rgb: 10,10,10;
  --fg-rgb: 233,231,226;
  --accent-rgb: 255,91,46;
  --bg: #0a0a0a;
  --bg-2: #111110;
  --fg: #e9e7e2;
  --fg-2: #b4b1aa;
  --dim: #6d6a64;
  --line: rgba(var(--fg-rgb),0.1);
  --line-2: rgba(var(--fg-rgb),0.18);
  --accent: #ff5b2e;
  --pad: clamp(20px, 4vw, 56px);
  --nav-h: 56px;
  --maxw: 1240px;
  --sans: "Geist", ui-sans-serif, system-ui, -apple-system, sans-serif;
  --mono: "Geist Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f5f2eb;
  --bg-2: #ebe7de;
  --fg: #292722;
  --fg-2: #57534b;
  --dim: #746e63;
  --bg-rgb: 245,242,235;
  --fg-rgb: 41,39,34;
  --accent-rgb: 186,61,25;
  --line: rgba(41,39,34,.12);
  --line-2: rgba(41,39,34,.22);
  --accent: #ba3d19;
}

* { box-sizing: border-box; }
/* anchor jumps land exactly at the nav's bottom edge, so the only thing above a
   section's heading is that section's own top padding */
html { scroll-behavior: smooth; scroll-padding-top: var(--nav-h); }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  transition: background-color .3s, color .3s;
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
::selection { background: var(--accent); color: var(--bg); }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; padding: 0; }
.mono { font-family: var(--mono); font-feature-settings: "zero" 1; }
.dim { color: var(--dim); }
.accent { color: var(--accent); }
.key {
  display: inline-grid; place-items: center;
  min-width: 16px; height: 16px; padding: 0 3px;
  border: 1px solid var(--line-2); border-radius: 3px;
  font-size: 10px; color: var(--fg-2); line-height: 1;
}

/* ---------- nav ---------- */
.nav {
  position: fixed; inset: 0 0 auto 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 24px;
  height: var(--nav-h); padding: 0 var(--pad);
  background: linear-gradient(to bottom, rgba(var(--bg-rgb),0.85), rgba(var(--bg-rgb),0));
  border-bottom: 1px solid transparent;
  transition: background .3s, border-color .3s;
}
.nav.scrolled { background: var(--bg); border-bottom-color: var(--line); }
/* bc_ — the original logo; the underscore is a prompt cursor waiting at the base case */
.wordmark { display: flex; align-items: center; color: var(--fg); }
.wordmark .logo { height: var(--logo-h, 16px); width: auto; display: block; overflow: visible; }
.nav-links { display: flex; gap: 26px; font-size: 13px; color: var(--fg-2); }
.nav-links a { transition: color .2s; }
.nav-links a:hover { color: var(--fg); }
.nav-links .idx { font-family: var(--mono); font-size: 10px; color: var(--dim); margin-right: 2px; }
.nav-meta { font-size: 11px; color: var(--dim); display: flex; align-items: center; gap: 8px; }
.nav-meta .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 8px var(--accent); animation: pulse 2.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .35; } }

/* ---------- hero ---------- */
.hero {
  position: relative;
  height: 100vh; height: 100svh; min-height: 620px;
  overflow: hidden;
  border-bottom: 1px solid var(--line);
}
#recursion { position: absolute; inset: 0; width: 100%; height: 100%; display: block; cursor: crosshair; touch-action: pan-y; }
#recursion.dragging { cursor: grabbing; }

.hud { position: absolute; z-index: 2; font-size: 11px; color: var(--dim); }
.hud-tl { top: 84px; left: var(--pad); pointer-events: none; }
.hud-row { display: grid; grid-template-columns: 44px auto; gap: 12px; line-height: 1.9; }
.hud-row .k { color: var(--dim); }
.hud-row span:last-child { color: var(--fg-2); font-variant-numeric: tabular-nums; }
.hud-tr { top: 84px; right: var(--pad); text-align: right; }
.modes { display: inline-flex; border: 1px solid var(--line-2); border-radius: 6px; overflow: hidden; background: rgba(var(--bg-rgb),.5); }
.mode { padding: 6px 10px; font-size: 11px; color: var(--dim); display: flex; gap: 6px; align-items: center; transition: color .2s, background .2s; }
.mode + .mode { border-left: 1px solid var(--line-2); }
.mode:hover { color: var(--fg); }
.mode.is-active { color: var(--fg); background: rgba(var(--fg-rgb),0.06); }
.mode.is-active .key { border-color: var(--accent); color: var(--accent); }
.hint { margin-top: 10px; line-height: 1.8; white-space: pre-line; transition: opacity .6s; } /* one instruction per line */

.hero-def {
  position: absolute; z-index: 2;
  left: var(--pad); right: var(--pad); bottom: clamp(72px, 12vh, 120px);
  max-width: 460px;
  text-shadow: 0 0 24px rgba(var(--bg-rgb),1);
}
/* compact figure readout under the visualization (mobile only) */
.hero-fig { display: none; justify-content: space-between; gap: 12px; margin: 0 0 14px; font-size: 11px; color: var(--dim); font-variant-numeric: tabular-nums; }
.hero-fig #hud-n-m { color: var(--fg-2); }
.hero-def .term { font-size: clamp(26px, 2.6vw, 34px); letter-spacing: -0.03em; margin: 0 0 18px; }
.hero-def .pron { font-size: 12px; color: var(--dim); letter-spacing: 0; margin-left: 6px; }
.hero-def .pos { font-size: 12px; color: var(--accent); letter-spacing: 0; font-style: italic; }
.hero-def ol { margin: 0; padding-left: 20px; color: var(--fg-2); font-size: 14.5px; line-height: 1.6; }
.hero-def li { padding-left: 6px; margin-bottom: 10px; }
.hero-def li::marker { font-family: var(--mono); font-size: 11px; color: var(--dim); }
.hero-def em { font-style: normal; font-weight: 600; font-size: 11.5px; color: var(--fg); margin-right: 4px; }

.hero-foot {
  position: absolute; z-index: 2; left: var(--pad); right: var(--pad); bottom: 24px;
  display: flex; align-items: center; gap: 14px; font-size: 11px; color: var(--dim);
  pointer-events: none;
}
.hero-foot .line { flex: 1; height: 1px; background: var(--line); }
#hud-cursor { font-variant-numeric: tabular-nums; min-width: 190px; text-align: right; }

/* ---------- sections ---------- */
.section { max-width: var(--maxw); margin: 0 auto; padding: clamp(56px, 6vw, 80px) var(--pad) 0; }
/* the last section needs room to scroll all the way up, like the others */
#notes { min-height: calc(100vh - var(--nav-h)); min-height: calc(100svh - var(--nav-h)); }
.section-head { display: flex; align-items: baseline; gap: 16px; margin-bottom: 32px; }
.section-head .sec { font-size: 12px; color: var(--accent); }
.section-head h2 { font-weight: 400; letter-spacing: -0.025em; font-size: clamp(24px, 2.6vw, 34px); margin: 0; white-space: nowrap; }
.section-head .rule { flex: 1; height: 1px; background: var(--line); transform: translateY(-6px); }
.section-head .dim { font-size: 11px; white-space: nowrap; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: clamp(32px, 6vw, 96px); align-items: start; }

/* notes */
.notes { border-top: 1px solid var(--line-2); }
.note.hidden { display: none; }
.note {
  display: grid; grid-template-columns: 110px 1fr 90px 60px; gap: 20px; align-items: baseline;
  padding: 16px 0; border-bottom: 1px solid var(--line); position: relative;
  transition: background .2s;
}
.note::before {
  content: ""; position: absolute; left: -12px; top: 0; bottom: 0; width: 2px;
  background: var(--accent); transform: scaleY(0); transition: transform .25s;
}
.note:hover { background: linear-gradient(to right, rgba(var(--fg-rgb),0.035), transparent 80%); }
.note:hover::before { transform: scaleY(1); }
.note .date, .note .cat, .note .len { font-family: var(--mono); font-size: 11px; color: var(--dim); }
.note .len { text-align: right; }
.note .title { font-size: 17px; letter-spacing: -0.01em; }
.note .title .arrow { display: inline-block; font-size: 12px; color: var(--accent); opacity: 0; transform: translate(-4px, 0); transition: all .25s; margin-left: 6px; }
.note:hover .title .arrow { opacity: 1; transform: translate(0, 0); }

/* method */
.sub { font-size: 12px; font-weight: 400; color: var(--dim); margin: 0 0 18px; }
.axioms { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.axioms li { display: grid; grid-template-columns: 56px 1fr; gap: 12px; padding: 14px 0; border-bottom: 1px solid var(--line); color: var(--fg-2); transition: color .2s; }
.axioms li:hover { color: var(--fg); }
.axioms .ax { font-size: 11px; color: var(--dim); padding-top: 3px; }
.axioms li:hover .ax { color: var(--accent); }

/* portfolio */
.filters { display: flex; gap: 6px; margin-bottom: 18px; font-size: 11px; }
.filter { padding: 5px 10px; border: 1px solid var(--line); border-radius: 999px; color: var(--dim); transition: all .2s; }
.filter:hover { color: var(--fg); border-color: var(--line-2); }
.filter.is-active { color: var(--bg); background: var(--fg); border-color: var(--fg); }

.table { border-top: 1px solid var(--line-2); }
.tr {
  display: grid; grid-template-columns: 56px minmax(150px, 1.1fr) 3fr minmax(170px, 1fr);
  gap: 20px; align-items: baseline;
  padding: 14px 0; border-bottom: 1px solid var(--line);
  position: relative;
}
.th { font-size: 11px; color: var(--dim); padding: 10px 0; }
.tr { transition: background .2s; }
.tr::before {
  content: ""; position: absolute; left: -12px; top: 0; bottom: 0; width: 2px;
  background: var(--accent); transform: scaleY(0); transition: transform .25s;
}
.tr:hover { background: linear-gradient(to right, rgba(var(--fg-rgb),0.035), transparent 80%); }
.tr:hover::before { transform: scaleY(1); }
.tr .i { font-family: var(--mono); font-size: 11px; color: var(--dim); }
.tr .name { font-size: 16px; letter-spacing: -0.01em; }
.tr .name a, .tr .status a { color: inherit; text-decoration: none; }
.tr .name a:hover, .tr .status a:hover { color: var(--accent); }
.tr .name .arrow { display: inline-block; font-size: 12px; color: var(--accent); opacity: 0; transform: translate(-4px, 0); transition: all .25s; margin-left: 6px; }
.tr:hover .name .arrow { opacity: 1; transform: translate(0, 0); }
.tr .desc { color: var(--dim); font-size: 13.5px; transition: color .2s; }
.tr:hover .desc { color: var(--fg-2); }
.tr .status { font-family: var(--mono); font-size: 11px; color: var(--dim); }
.tr .status.acq { color: var(--fg-2); }
.tr .status.acq::before { content: "↳ "; color: var(--accent); }
.tr.hidden { display: none; }

/* proofs */
.proof { max-width: 900px; }
.proof-label { font-size: 12px; color: var(--dim); font-style: italic; margin: 0 0 18px; }
.proof blockquote {
  margin: 0; font-size: clamp(20px, 2.3vw, 30px); line-height: 1.38; letter-spacing: -0.02em;
  min-height: 4.2em; transition: opacity .35s;
}
.proof blockquote.fade { opacity: 0; }
.proof-foot { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-top: 28px; padding-top: 18px; border-top: 1px solid var(--line); }
#proof-author { margin: 0; font-size: 12px; color: var(--fg-2); }
#proof-author .dim { color: var(--dim); }
.proof-nav { display: flex; align-items: center; gap: 18px; font-size: 12px; color: var(--dim); }
.proof-nav button { display: flex; gap: 6px; align-items: center; transition: color .2s; color: var(--dim); }
.proof-nav button:hover { color: var(--fg); }
.proof blockquote .qed { margin-left: .25em; font-size: .68em; color: var(--accent); }

/* footer: an endlessly zooming sierpinski triangle, full bleed, cropped by the page */
.site-footer { margin-top: clamp(32px, 5vw, 64px); overflow: hidden; } /* #notes' min-height already leaves room */
#sierpinski { display: block; width: 100%; height: clamp(240px, 28vw, 420px); }

.footer {
  max-width: var(--maxw); margin: 0 auto;
  display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  padding: 22px var(--pad) 32px; font-size: 11px; color: var(--fg-2);
  border-top: 1px solid var(--line);
}
.footer a:hover { color: var(--accent); }
.footer sub, .footer sup { font-size: 0.75em; line-height: 0; }

/* ---------- responsive ---------- */
@media (max-width: 900px) {
  .nav-links { display: none; }
  .grid-2 { grid-template-columns: 1fr; }
  .tr { grid-template-columns: 36px 1fr auto; }
  .tr .col-desc, .tr .desc { display: none; }
  .note { grid-template-columns: 1fr auto; gap: 4px 16px; }
  .note .date { grid-column: 1 / -1; }
  .note .cat { display: none; }
  .section-head h2 { white-space: normal; }
  .section-head .rule { display: none; }
}
@media (max-width: 640px) {
  .hud-tl { display: none; }
  .hud-tr { top: 70px; }
  .mode .key { display: none; }
  .hint { display: none; }
  /* tighten the definition so the figures have room to breathe above it */
  .hero-def { bottom: clamp(56px, 9vh, 100px); }
  .hero-fig { display: flex; }
  .hero-def .term { font-size: 24px; margin-bottom: 14px; }
  .hero-def ol { font-size: 13.5px; line-height: 1.55; }
  .hero-def li { margin-bottom: 7px; }
  .tr .col-status, .tr .status:not(.acq) { visibility: hidden; }
  #hud-cursor { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .nav-meta .dot { animation: none; }
}

/* A quiet footer utility; the clock keeps the top-right corner. */
.footer, .note-end { align-items: center; }
.footer-tools { display: flex; align-items: center; gap: 20px; }
.theme-toggle { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 28px; padding: 2px 0; color: var(--dim); font: 11px var(--mono); }
.theme-toggle:hover { color: var(--accent); }
.theme-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }
.theme-icon { width: 12px; height: 12px; }
@media (max-width: 900px) { .theme-toggle { display: none; } }
