/* ============ Triangulation — 3b1b-flavoured interactive essay ============ */

:root {
  --bg: #0b0d10;
  --panel: #0e1218;
  --ink: #c9cdd3;
  --white: #eceef0;
  --blue: #58C4DD;
  --yellow: #FFD64D;
  --green: #83C167;
  --red: #FC6255;
  --teal: #5CD0B3;
  --grey: #828a94;
  --hair: rgba(255, 255, 255, 0.08);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "KaTeX_Main", Georgia, "Times New Roman", serif;
  font-size: 19px;
  line-height: 1.7;
  overflow-x: hidden;
}

::selection { background: rgba(88, 196, 221, 0.35); }

a { color: var(--blue); text-decoration: none; border-bottom: 1px solid rgba(88,196,221,.35); }
a:hover { border-bottom-color: var(--blue); }

em { color: var(--white); }
b { font-weight: 600; }

.y { color: var(--yellow); }
.b { color: var(--blue); }
.g { color: var(--green); }
.t { color: var(--teal); }
.r { color: var(--red); }
.w { color: var(--white); }

/* ---------------- hero ---------------- */

.hero {
  position: relative;
  height: 100vh;
  height: 100svh;
  overflow: hidden;
}

.hero canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.hero-text {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  pointer-events: none;
  padding: 0 20px;
  background: radial-gradient(ellipse at center, rgba(11,13,16,0) 30%, rgba(11,13,16,.55) 100%);
}

.hero-text .kicker {
  font-family: "KaTeX_SansSerif", system-ui, sans-serif;
  font-size: 13px;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--grey);
  margin: 0 0 18px;
  animation: fadeUp 1.2s .2s ease both;
}

.hero-text h1 {
  font-size: clamp(52px, 9vw, 96px);
  font-weight: 400;
  color: var(--white);
  letter-spacing: 2px;
  margin: 0;
  animation: fadeUp 1.2s .45s ease both;
}

.hero-text .subtitle {
  font-style: italic;
  font-size: clamp(18px, 2.6vw, 24px);
  color: var(--blue);
  margin: 14px 0 0;
  animation: fadeUp 1.2s .7s ease both;
}

.hero-text .scroll-hint {
  position: absolute;
  bottom: 28px;
  left: 0; right: 0;
  color: var(--grey);
  font-size: 15px;
  animation: fadeUp 1.2s 1.4s ease both, bob 2.2s 2.6s ease-in-out infinite;
}

@keyframes fadeUp { from { opacity: 0; transform: translateY(22px); } to { opacity: 1; transform: none; } }
@keyframes bob { 0%,100% { transform: translateY(0); } 50% { transform: translateY(7px); } }

/* ---------------- chapters ---------------- */

.chapter {
  max-width: 1000px;
  margin: 0 auto;
  padding: 96px 16px 8px;
  opacity: 0;
  transform: translateY(26px);
  transition: opacity .9s ease, transform .9s ease;
}
.chapter.on { opacity: 1; transform: none; }

.prose {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 8px;
}

.chapter-num {
  font-family: "KaTeX_SansSerif", system-ui, sans-serif;
  font-size: 13px;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--yellow);
  margin: 0 0 6px;
}

h2 {
  font-size: clamp(30px, 5vw, 42px);
  font-weight: 400;
  color: var(--white);
  margin: 0 0 26px;
  line-height: 1.2;
}

.math-block { text-align: center; margin: 26px 0; overflow-x: auto; overflow-y: hidden; }
.katex { font-size: 1.12em; }

ul { padding-left: 24px; }
li { margin: 14px 0; }

.fin {
  text-align: center;
  color: var(--grey);
  font-style: italic;
  margin-top: 56px;
}

/* ---------------- demo figures ---------------- */

figure.demo {
  margin: 40px auto;
  max-width: 960px;
  background: var(--panel);
  border: 1px solid var(--hair);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
}

figure.demo canvas {
  display: block;
  width: 100%;
  height: auto;
  touch-action: none;
  background: #0a0d12;
}

figcaption {
  font-size: 15px;
  font-style: italic;
  color: var(--grey);
  padding: 11px 18px 13px;
  border-top: 1px solid var(--hair);
}
figcaption em { color: var(--ink); }

/* controls & readouts */

.controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 26px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--hair);
  font-family: "KaTeX_SansSerif", system-ui, sans-serif;
  font-size: 15px;
}

.controls label { display: flex; align-items: center; gap: 10px; }
.controls label > span { font-family: "KaTeX_Math", Georgia, serif; font-style: italic; font-size: 18px; }
.controls b { font-weight: 600; min-width: 62px; }
.controls .ctrl-label { color: var(--grey); }
.controls .spacer { flex: 1; }

input[type="range"] {
  accent-color: var(--blue);
  width: 130px;
  cursor: pointer;
}

button {
  font-family: "KaTeX_SansSerif", system-ui, sans-serif;
  font-size: 14px;
  color: var(--ink);
  background: #171d26;
  border: 1px solid #2a323d;
  border-radius: 999px;
  padding: 5px 16px;
  cursor: pointer;
  transition: all .15s ease;
}
button:hover { border-color: var(--grey); color: var(--white); }
button.active { border-color: var(--blue); color: var(--blue); background: rgba(88,196,221,.08); }

.readout {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 28px;
  padding: 11px 18px;
  border-top: 1px solid var(--hair);
  font-size: 16.5px;
  color: var(--grey);
}
.readout b { font-weight: 600; }
.readout .sep { color: var(--grey); }

/* ---------------- footer ---------------- */

footer {
  max-width: 720px;
  margin: 70px auto 0;
  padding: 26px 24px 60px;
  border-top: 1px solid var(--hair);
  text-align: center;
  color: var(--grey);
  font-size: 15px;
}

@media (max-width: 640px) {
  body { font-size: 17px; }
  .controls { gap: 8px 16px; }
  input[type="range"] { width: 100px; }
}
