/* ═══════════════════════════════════════════════════════════
   Curves — Splines to NURBS  (Explorables)
   Dark minimal theme, echoing the Weaire–Phelan explorable
   ═══════════════════════════════════════════════════════════ */

:root {
  --bg: #0b0e14;
  --bg-2: #0d1119;
  --surface: rgba(255, 255, 255, 0.035);
  --surface-2: rgba(255, 255, 255, 0.06);
  --border: rgba(255, 255, 255, 0.09);
  --border-2: rgba(255, 255, 255, 0.16);
  --text: #e8ecf4;
  --text-2: #a9b3c6;
  --text-3: #6b7688;
  --blue: #60a5fa;
  --gold: #f3d27a;
  --red: #ef4444;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Kaku Gothic ProN", "Hiragino Sans", "Noto Sans JP", "Yu Gothic UI", sans-serif;
  --mono: "SF Mono", "Cascadia Code", Consolas, Menlo, monospace;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.9;
  -webkit-font-smoothing: antialiased;
}

::selection { background: rgba(96, 165, 250, 0.35); }

/* ── Top navigation ─────────────────────────────────────── */
.topnav {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.55rem 1.2rem;
  background: rgba(11, 14, 20, 0.82);
  backdrop-filter: blur(14px) saturate(1.4);
  -webkit-backdrop-filter: blur(14px) saturate(1.4);
  border-bottom: 1px solid var(--border);
  font-size: 0.8rem;
}
.topnav-home {
  color: var(--text-2);
  text-decoration: none;
  letter-spacing: 0.04em;
  white-space: nowrap;
  transition: color 0.2s;
}
.topnav-home:hover { color: var(--text); }
.topnav-title {
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--text-3);
  text-transform: uppercase;
  font-size: 0.7rem;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.topnav-links { display: flex; gap: 0.3rem; }
.topnav-links a {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1.7rem; height: 1.7rem;
  border-radius: 50%;
  color: var(--text-3);
  text-decoration: none;
  font-size: 0.72rem;
  font-family: var(--mono);
  border: 1px solid transparent;
  transition: all 0.2s;
}
.topnav-links a:hover { color: var(--text); border-color: var(--border-2); }
.topnav-links a.active {
  color: #0b0e14;
  background: var(--blue);
  font-weight: 700;
}

/* ── Hero ───────────────────────────────────────────────── */
.hero {
  position: relative;
  min-height: 92vh;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: radial-gradient(120% 90% at 50% 0%, #101625 0%, var(--bg) 65%);
}
#heroCanvas {
  position: absolute;
  inset: 0;
  width: 100%; height: 100%;
  opacity: 0.85;
}
.hero-inner {
  position: relative;
  z-index: 1;
  max-width: 780px;
  padding: 6rem 1.5rem 4rem;
  text-align: center;
}
.hero-eyebrow {
  font-size: 0.72rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--blue);
  margin-bottom: 1.4rem;
}
.hero h1 {
  font-size: clamp(1.7rem, 4.6vw, 2.9rem);
  font-weight: 700;
  letter-spacing: 0.03em;
  line-height: 1.45;
  margin-bottom: 1.6rem;
}
.hero-dash { margin: 0 0.35em; color: var(--text-3); font-weight: 300; }
.hero-lead {
  font-size: 0.95rem;
  color: var(--text-2);
  text-align: left;
  margin-bottom: 2.4rem;
}
.hero-lead strong { color: var(--gold); font-weight: 600; }
.hero-cta {
  display: inline-block;
  padding: 0.75rem 2.2rem;
  border: 1px solid var(--border-2);
  border-radius: 999px;
  color: var(--text);
  text-decoration: none;
  font-size: 0.85rem;
  letter-spacing: 0.08em;
  background: var(--surface);
  transition: all 0.25s;
}
.hero-cta:hover { background: var(--surface-2); border-color: var(--blue); }

/* ── Chapters ───────────────────────────────────────────── */
.content { max-width: 860px; margin: 0 auto; padding: 0 1.4rem; }

.chapter {
  padding: 5.5rem 0 3rem;
  border-bottom: 1px solid var(--border);
  opacity: 0;
  transform: translateY(18px);
  transition: opacity 0.7s ease, transform 0.7s ease;
}
.chapter.visible { opacity: 1; transform: none; }
.chapter:last-of-type { border-bottom: none; }

.ch-head { margin-bottom: 2rem; }
.ch-index {
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--blue);
}
.ch-head h2 {
  font-size: clamp(1.35rem, 3vw, 1.85rem);
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1.5;
  margin: 0.5rem 0 0.4rem;
}
.ch-sub { font-size: 0.9rem; color: var(--text-3); }

.ch-prose p { margin-bottom: 1.3rem; font-size: 0.95rem; color: var(--text-2); }
.ch-prose strong { color: var(--text); font-weight: 600; }

/* formulas */
.eq {
  font-family: var(--mono);
  font-size: 0.95rem;
  color: var(--gold);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.9rem 1.2rem;
  margin: 0 0 1.3rem;
  text-align: center;
  overflow-x: auto;
  white-space: nowrap;
}
.eq-inline {
  font-family: var(--mono);
  font-size: 0.88em;
  color: var(--gold);
  white-space: nowrap;
}
.eq-name {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  text-align: left;
  white-space: normal;
  color: var(--text-2);
  font-size: 0.86rem;
}
.eq-name b { color: var(--gold); font-size: 1.05em; }

/* tool notes (Illustrator / Rhino) */
.toolnote {
  position: relative;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  padding: 1.1rem 1.3rem 1rem;
  margin: 1.6rem 0;
}
.toolnote p { margin: 0.35rem 0 0; font-size: 0.88rem; color: var(--text-2); }
.toolnote-tag {
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  padding: 0.18rem 0.7rem;
  border-radius: 999px;
}
.toolnote.il { border-left: 3px solid #f59e0b; }
.toolnote.il .toolnote-tag { background: rgba(245, 158, 11, 0.15); color: #fbbf24; }
.toolnote.rh { border-left: 3px solid #34d399; }
.toolnote.rh .toolnote-tag { background: rgba(52, 211, 153, 0.13); color: #34d399; }

/* lists */
.glist { margin: 0 0 1.3rem 1.2rem; }
.glist li { font-size: 0.92rem; color: var(--text-2); margin-bottom: 0.55rem; }
.glist strong { color: var(--text); }

/* comparison table */
.tool-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  margin: 0 0 1.5rem;
}
.tool-table th, .tool-table td {
  text-align: left;
  padding: 0.55rem 0.8rem;
  border-bottom: 1px solid var(--border);
  color: var(--text-2);
  vertical-align: top;
}
.tool-table th {
  color: var(--text-3);
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-weight: 600;
}
.tool-table td:first-child { color: var(--text); white-space: nowrap; }

/* ── Demos ──────────────────────────────────────────────── */
.demo { margin: 2.2rem 0; }
.demo-stage {
  position: relative;
  aspect-ratio: 16 / 9;
  max-height: 540px;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: #0a0d13;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
}
.demo-stage canvas {
  position: absolute;
  inset: 0;
  width: 100%; height: 100%;
  display: block;
  touch-action: none;
  cursor: crosshair;
}
.demo-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem;
  margin-top: 0.8rem;
  min-height: 2rem;
}
.demo-hint {
  margin-top: 0.7rem;
  font-size: 0.78rem;
  color: var(--text-3);
  line-height: 1.7;
}

/* control chips */
.chip {
  appearance: none;
  border: 1px solid var(--border-2);
  background: var(--surface);
  color: var(--text-2);
  font-family: var(--font);
  font-size: 0.76rem;
  letter-spacing: 0.03em;
  padding: 0.34rem 0.95rem;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.18s;
  white-space: nowrap;
}
.chip:hover { color: var(--text); border-color: rgba(255, 255, 255, 0.3); }
.chip.on {
  background: var(--blue);
  border-color: var(--blue);
  color: #0b0e14;
  font-weight: 600;
}
.chip.gold.on { background: var(--gold); border-color: var(--gold); }

.ctl-group {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.22rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
}
.ctl-label {
  font-size: 0.72rem;
  color: var(--text-3);
  letter-spacing: 0.04em;
  white-space: nowrap;
}
.ctl-value {
  font-family: var(--mono);
  font-size: 0.74rem;
  color: var(--gold);
  min-width: 2.6em;
  text-align: right;
  white-space: nowrap;
}
.ctl-sep { width: 1px; height: 1.1rem; background: var(--border-2); margin: 0 0.2rem; }

input[type="range"].ctl-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 120px;
  height: 3px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.18);
  outline: none;
  cursor: pointer;
}
input[type="range"].ctl-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 13px; height: 13px;
  border-radius: 50%;
  background: var(--text);
  box-shadow: 0 0 6px rgba(0, 0, 0, 0.4);
  cursor: pointer;
}
input[type="range"].ctl-slider::-moz-range-thumb {
  width: 13px; height: 13px;
  border: none;
  border-radius: 50%;
  background: var(--text);
  cursor: pointer;
}
input[type="range"].ctl-slider:disabled { opacity: 0.35; cursor: default; }

.readout {
  font-family: var(--mono);
  font-size: 0.74rem;
  color: var(--text-2);
  padding: 0.3rem 0.8rem;
  border-radius: 999px;
  border: 1px dashed var(--border-2);
  white-space: nowrap;
}

/* ── Takeaway box ───────────────────────────────────────── */
.takeaway {
  margin-top: 2.4rem;
  border: 1px solid rgba(96, 165, 250, 0.25);
  background: rgba(96, 165, 250, 0.05);
  border-radius: 14px;
  padding: 1.3rem 1.6rem 1.1rem;
}
.takeaway h3 {
  font-size: 0.75rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--blue);
  margin-bottom: 0.7rem;
}
.takeaway ul { margin-left: 1.2rem; }
.takeaway li { font-size: 0.88rem; color: var(--text-2); margin-bottom: 0.4rem; }
.takeaway strong { color: var(--text); }

/* ── Cases (architecture) ───────────────────────────────── */
.cases {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 1rem;
  margin: 0 0 1.5rem;
}
.case-card {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  padding: 1.2rem 1.3rem;
}
.case-card h3 { font-size: 0.98rem; font-weight: 700; line-height: 1.5; }
.case-meta { font-size: 0.74rem; color: var(--gold); margin: 0.25rem 0 0.6rem; }
.case-card p:last-child { font-size: 0.82rem; color: var(--text-2); margin: 0; }

/* ── Timeline ───────────────────────────────────────────── */
.timeline {
  list-style: none;
  margin: 1.8rem 0 1rem;
  border-left: 2px solid rgba(96, 165, 250, 0.3);
  padding-left: 0;
}
.timeline li {
  position: relative;
  display: flex;
  gap: 1.1rem;
  padding: 0 0 1.05rem 1.6rem;
  font-size: 0.88rem;
}
.timeline li::before {
  content: "";
  position: absolute;
  left: -6px; top: 0.5em;
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--bg);
  border: 2px solid var(--blue);
}
.tl-year {
  font-family: var(--mono);
  color: var(--gold);
  min-width: 4.2em;
  flex-shrink: 0;
}
.tl-body { color: var(--text-2); }

/* ── Playground ─────────────────────────────────────────── */
.playground-window {
  position: relative;
  width: 100%;
  height: min(78vh, 680px);
  min-height: 480px;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: #0a0a14;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
}

/* ── Q&A ────────────────────────────────────────────────── */
.qa {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  margin-bottom: 0.8rem;
  overflow: hidden;
}
.qa summary {
  cursor: pointer;
  padding: 1rem 1.3rem;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text);
  list-style: none;
  position: relative;
  padding-right: 3rem;
  transition: background 0.2s;
}
.qa summary::-webkit-details-marker { display: none; }
.qa summary::after {
  content: "+";
  position: absolute;
  right: 1.2rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--blue);
  font-size: 1.2rem;
  font-weight: 400;
  transition: transform 0.25s;
}
.qa[open] summary::after { transform: translateY(-50%) rotate(45deg); }
.qa summary:hover { background: var(--surface-2); }
.qa-body { padding: 0 1.3rem 1.1rem; }
.qa-body p { font-size: 0.88rem; color: var(--text-2); margin: 0 0 0.6rem; }
.qa-body strong { color: var(--text); }

/* ── Footer ─────────────────────────────────────────────── */
.site-footer {
  margin-top: 4rem;
  padding: 2.4rem 1.5rem 3rem;
  border-top: 1px solid var(--border);
  text-align: center;
  font-size: 0.78rem;
  color: var(--text-3);
}
.site-footer nav { margin-top: 0.6rem; display: flex; gap: 1.4rem; justify-content: center; }
.site-footer a { color: var(--text-2); text-decoration: none; }
.site-footer a:hover { color: var(--text); }

/* ── Responsive ─────────────────────────────────────────── */
@media (max-width: 640px) {
  body { font-size: 15px; }
  .topnav { padding: 0.5rem 0.8rem; gap: 0.6rem; }
  .topnav-title { display: none; }
  .demo-stage { aspect-ratio: 4 / 3; }
  .chapter { padding-top: 4rem; }
  input[type="range"].ctl-slider { width: 90px; }
  .playground-window { height: 76vh; min-height: 420px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .chapter { opacity: 1; transform: none; transition: none; }
}
