/* ============================================================
   3DGS · Foundations — visual essay stylesheet
   Cool, scholarly palette: blue/violet on near-black
   ============================================================ */

:root {
  --bg:         #0b0d14;
  --bg-soft:    #131724;
  --bg-card:    #181d2c;
  --bg-deep:    #07080d;
  --line:       #252b3f;
  --line-soft:  #1c2236;
  --text:       #e8ebf3;
  --text-dim:   #a7adc0;
  --text-muted: #6c7388;
  --accent:     #8ab0ff;       /* cool blue */
  --accent-2:   #b894ff;       /* violet */
  --accent-3:   #6fe7d1;       /* teal */
  --accent-4:   #ffd180;       /* sunlit warm contrast */
  --good:       #69d6a0;
  --warn:       #ffc874;
  --bad:        #ff7088;

  --ff-display: "Fraunces", Georgia, serif;
  --ff-body:    "Inter", system-ui, sans-serif;
  --ff-mono:    "JetBrains Mono", ui-monospace, Menlo, monospace;

  --measure:    72ch;
  --gutter:     24px;
  --nav-h:      56px;
  --radius:     14px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--ff-body);
  font-size: 17px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

::selection { background: var(--accent); color: #07090f; }

a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid rgba(138,176,255,0.25);
  transition: color 0.15s, border-color 0.15s;
}
a:hover { color: var(--accent-2); border-color: var(--accent-2); }

em { font-style: italic; color: var(--text); }
strong { color: #fff; font-weight: 600; }

code, pre { font-family: var(--ff-mono); font-size: 0.92em; }
code {
  background: rgba(255,255,255,0.05);
  padding: 0.1em 0.35em;
  border-radius: 4px;
  border: 1px solid var(--line-soft);
  color: #cce2ff;
}
pre {
  background: var(--bg-deep) !important;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px !important;
  overflow-x: auto;
  margin: 1.4em 0;
  font-size: 13.5px;
  line-height: 1.55;
}
pre code { background: none; border: none; padding: 0; color: inherit; }

h1, h2, h3, h4 {
  font-family: var(--ff-display);
  font-weight: 600;
  letter-spacing: -0.01em;
  color: #fff;
  line-height: 1.15;
}
h1 { font-size: clamp(2.4rem, 5.5vw, 4.6rem); }
h2 { font-size: clamp(1.7rem, 3vw, 2.4rem); margin: 0 0 0.4em; }
h3 { font-size: 1.3rem; margin: 2.5em 0 0.5em; color: var(--accent); }
h4 { font-size: 1.0rem; margin: 1.4em 0 0.4em; color: #fff; }

p { margin: 0 0 1em; }
ul, ol { padding-left: 1.4em; margin: 0 0 1.2em; }
li { margin: 0.4em 0; }

/* ===== NAV ===== */
#topnav {
  position: sticky; top: 0; z-index: 50;
  background: rgba(11,13,20,0.85);
  backdrop-filter: blur(12px) saturate(140%);
  border-bottom: 1px solid var(--line);
  height: var(--nav-h);
}
.nav-inner {
  max-width: 1100px; margin: 0 auto; height: 100%;
  padding: 0 var(--gutter);
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  font-family: var(--ff-mono); font-size: 13px; font-weight: 700;
  color: #fff; letter-spacing: 0.04em; border: none;
}
.brand:hover { color: var(--accent); }
.logo-dot {
  display: inline-block; width: 11px; height: 11px; border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, var(--accent) 0%, var(--accent-2) 60%, transparent 100%);
  box-shadow: 0 0 12px var(--accent);
}
#navlinks { display: flex; gap: 22px; list-style: none; margin: 0; padding: 0; }
#navlinks a { font-size: 13.5px; color: var(--text-dim); border: none; font-weight: 500; }
#navlinks a:hover { color: var(--accent); }
#navtoggle { display: none; background: none; border: none; color: var(--text); font-size: 22px; cursor: pointer; }
#progress-bar {
  position: absolute; bottom: -1px; left: 0;
  height: 2px; width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
}

/* ===== HERO ===== */
.hero {
  position: relative; min-height: 88vh;
  display: flex; align-items: center;
  padding: 120px var(--gutter) 80px;
  overflow: hidden;
  border-bottom: 1px solid var(--line);
}
#hero-canvas {
  position: absolute; inset: 0;
  width: 100%; height: 100%; z-index: 0; opacity: 0.55;
}
.hero-content { position: relative; z-index: 1; max-width: 880px; margin: 0 auto; }
.kicker {
  font-family: var(--ff-mono); font-size: 12px;
  letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--accent); margin: 0 0 24px;
}
.hero h1 { margin: 0 0 28px; }
.hero h1 em {
  font-style: italic;
  background: linear-gradient(120deg, var(--accent), var(--accent-2) 60%, var(--accent-3));
  background-clip: text; -webkit-background-clip: text; color: transparent;
}
.subtitle {
  font-size: clamp(1.05rem, 1.6vw, 1.35rem);
  color: var(--text-dim);
  max-width: 60ch; margin: 0 0 36px; line-height: 1.55;
}
.hero-cta { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 50px; }
.btn {
  display: inline-block; padding: 12px 22px; border-radius: 999px;
  font-family: var(--ff-mono); font-size: 13px; font-weight: 600;
  letter-spacing: 0.04em; text-transform: uppercase;
  border: 1px solid var(--line);
  transition: transform 0.15s, background 0.15s;
}
.btn.primary { background: var(--accent); color: #07090f; border-color: var(--accent); }
.btn.primary:hover { transform: translateY(-1px); background: #aac6ff; }
.btn.ghost { background: transparent; color: var(--text); }
.btn.ghost:hover { background: rgba(255,255,255,0.06); color: var(--accent); border-color: var(--accent); }
.hero-meta { font-size: 13.5px; color: var(--text-muted); max-width: 50ch; font-style: italic; }

/* ===== SECTIONS / PROSE ===== */
section { padding: 100px var(--gutter); border-bottom: 1px solid var(--line-soft); }
.prose { max-width: var(--measure); margin: 0 auto; }
.section-kicker {
  font-family: var(--ff-mono); font-size: 12px;
  color: var(--accent); letter-spacing: 0.14em;
  text-transform: uppercase; margin: 0 0 8px;
}

.callout {
  margin: 2em 0; padding: 18px 22px;
  background: var(--bg-card);
  border-left: 3px solid var(--accent);
  border-radius: 8px;
  font-size: 0.96em; color: var(--text-dim);
}
.callout.subtle { border-left-color: var(--accent-3); }
.callout strong { color: var(--accent); }

/* ===== MATH ===== */
.math-block {
  margin: 1.6em 0; padding: 18px;
  background: var(--bg-card);
  border: 1px solid var(--line); border-radius: var(--radius);
  font-size: 1.05em; overflow-x: auto; text-align: center;
}
.katex-display { margin: 0 !important; }

/* ===== VIZ BLOCKS ===== */
.viz-block {
  margin: 2em 0; padding: 24px;
  background: var(--bg-card);
  border: 1px solid var(--line); border-radius: var(--radius);
}
.viz-block.big { padding: 28px; }
.viz-header h4 {
  margin: 0 0 4px; color: var(--accent);
  font-family: var(--ff-mono); font-weight: 700;
  letter-spacing: 0.06em; text-transform: uppercase; font-size: 12px;
}
.viz-header p { margin: 0 0 16px; font-size: 0.95em; color: var(--text-dim); }
.viz-block canvas {
  display: block; width: 100%; max-width: 100%; height: auto;
  border-radius: 10px; background: var(--bg-deep);
  cursor: crosshair; touch-action: none;
}
.viz-readout {
  margin-top: 12px;
  font-family: var(--ff-mono); font-size: 12.5px; color: var(--text-dim);
  background: var(--bg-deep);
  padding: 8px 12px; border-radius: 6px;
  white-space: pre; overflow-x: auto;
}
.viz-controls {
  margin-top: 14px; display: flex; gap: 16px;
  align-items: center; flex-wrap: wrap;
  font-family: var(--ff-mono); font-size: 12.5px; color: var(--text-dim);
}
.viz-controls input[type="range"] {
  flex: 1; min-width: 180px; accent-color: var(--accent);
}
.viz-controls button {
  background: var(--bg-deep); color: var(--text);
  border: 1px solid var(--line); padding: 6px 14px; border-radius: 6px;
  font-family: var(--ff-mono); font-size: 12px; cursor: pointer;
  text-transform: uppercase; letter-spacing: 0.06em;
}
.viz-controls button:hover { background: var(--accent); color: #07090f; border-color: var(--accent); }
.viz-controls label { display: flex; gap: 8px; align-items: center; flex: 1; min-width: 160px; }

/* ===== PIPELINE LIST ===== */
.pipeline-list { counter-reset: step; list-style: none; padding: 0; margin: 2em 0; }
.pipeline-list li {
  counter-increment: step;
  position: relative;
  padding: 14px 16px 14px 60px;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 10px;
  margin: 8px 0;
}
.pipeline-list li::before {
  content: counter(step);
  position: absolute; left: 16px; top: 50%; transform: translateY(-50%);
  width: 32px; height: 32px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--accent); color: #07090f;
  font-family: var(--ff-mono); font-weight: 700; font-size: 14px;
}

/* ===== STAT GRID ===== */
.stat-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px; margin: 2em 0;
}
.stat { background: var(--bg-card); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px 20px; }
.stat-num {
  font-family: var(--ff-display); font-size: 2.6rem; font-weight: 700;
  color: var(--accent); line-height: 1.05;
}
.stat-num small {
  font-size: 0.45em; color: var(--text-dim); margin-left: 4px;
  font-weight: 500; font-family: var(--ff-mono); letter-spacing: 0.04em;
}
.stat-lbl { font-size: 13px; color: var(--text-dim); margin-top: 8px; line-height: 1.4; }

/* ===== TIMELINE ===== */
.timeline-section {
  padding-bottom: 60px;
  background:
    radial-gradient(ellipse at top, rgba(138,176,255,0.06), transparent 60%),
    var(--bg);
}
.timeline-wrap {
  max-width: 1100px; margin: 40px auto 0; padding: 0 var(--gutter);
  display: grid; grid-template-columns: 1fr 1.1fr; gap: 40px;
  align-items: start;
}
#timeline-rail { position: relative; border-left: 2px solid var(--line); padding: 0; }
.tl-item {
  position: relative; padding: 14px 16px 14px 32px;
  cursor: pointer; border-radius: 8px; margin-left: -2px;
  transition: background 0.15s, border-left-color 0.15s;
  border-left: 2px solid transparent;
}
.tl-item:hover { background: var(--bg-card); }
.tl-item.active { background: var(--bg-card); border-left-color: var(--accent); }
.tl-item::before {
  content: ''; position: absolute; left: -8px; top: 22px;
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--bg); border: 2px solid var(--line);
}
.tl-item.active::before {
  background: var(--accent); border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(138,176,255,0.18);
}
.tl-year { font-family: var(--ff-mono); font-size: 11px; letter-spacing: 0.1em; color: var(--accent); text-transform: uppercase; }
.tl-title { font-family: var(--ff-display); font-weight: 600; font-size: 1.05rem; color: #fff; margin: 2px 0; }
.tl-tag { font-family: var(--ff-mono); font-size: 11px; color: var(--text-dim); }
#timeline-detail {
  position: sticky; top: calc(var(--nav-h) + 20px);
  background: var(--bg-card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 30px; min-height: 360px;
}
#timeline-detail h3 { margin-top: 0; color: var(--accent); }
.td-meta {
  font-family: var(--ff-mono); font-size: 12px; color: var(--text-dim);
  margin-bottom: 18px; border-bottom: 1px dashed var(--line); padding-bottom: 14px;
}
.td-meta span { display: inline-block; margin-right: 14px; }
.td-meta b { color: var(--accent-2); }

/* ===== COMPARISONS (two-column side-by-side cards) ===== */
.cmp-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin: 2em 0;
}
.cmp {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
}
.cmp h4 {
  margin: 0 0 10px;
  color: var(--accent);
  font-family: var(--ff-mono);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.cmp.alt h4 { color: var(--accent-2); }
.cmp p { font-size: 0.95em; color: var(--text-dim); margin: 0 0 0.7em; }
.cmp ul { padding-left: 1.2em; font-size: 0.93em; color: var(--text-dim); }

/* ===== DEEP DIVES ===== */
.deepdive {
  padding-top: 60px;
  padding-bottom: 60px;
  border-bottom: 1px dashed var(--line-soft);
}
.dd-meta {
  font-family: var(--ff-mono); font-size: 12.5px;
  color: var(--text-muted); margin: -8px 0 14px;
}

/* ===== FOOTER ===== */
footer {
  padding: 80px var(--gutter);
  background: var(--bg-deep);
  border-top: 1px solid var(--line);
}
footer h3 { color: var(--accent); }
.refs { list-style: none; padding: 0; }
.refs li { padding: 6px 0; border-bottom: 1px solid var(--line-soft); }
.footer-meta { margin-top: 30px; font-size: 13px; color: var(--text-muted); }

/* ===== RESPONSIVE ===== */
@media (max-width: 760px) {
  body { font-size: 16px; }
  section { padding: 60px var(--gutter); }
  .hero { padding: 90px var(--gutter) 60px; }
  #navtoggle { display: block; }
  #navlinks {
    display: none;
    position: absolute;
    top: var(--nav-h);
    right: 0; left: 0;
    flex-direction: column;
    background: var(--bg-soft);
    padding: 14px var(--gutter);
    border-bottom: 1px solid var(--line);
  }
  #navlinks.open { display: flex; }
  .timeline-wrap { grid-template-columns: 1fr; }
  #timeline-detail { position: static; }
  .cmp-grid { grid-template-columns: 1fr; }
  #lang-toggle { margin-left: 8px; padding: 4px 8px; font-size: 10px; }
}

/* ===== LANG TOGGLE ===== */
#lang-toggle {
  background: transparent;
  color: var(--text-dim);
  border: 1px solid var(--line);
  padding: 5px 11px;
  border-radius: 6px;
  font-family: var(--ff-mono);
  font-size: 11px;
  cursor: pointer;
  letter-spacing: 0.08em;
  margin-left: 14px;
  flex-shrink: 0;
  transition: color 0.15s, border-color 0.15s;
}
#lang-toggle:hover { color: var(--accent); border-color: var(--accent); }
[lang="zh"] { display: none; }
html[data-lang="zh"] [lang="en"] { display: none; }
html[data-lang="zh"] [lang="zh"] { display: revert; }
