/* ============================================================
   3DGS · CUDA Story — stylesheet
   Aesthetic borrowed from ../3dgs-large-scale: academic, calm,
   content-first, cream background, burnt-orange accents.
   ============================================================ */

:root {
  --bg:         #fbf9f4;
  --bg-soft:    #f3efe5;
  --bg-card:    #ffffff;
  --ink:        #1f2024;
  --ink-soft:   #4a4d57;
  --ink-faint:  #8a8d97;
  --line:       #e5e0d3;
  --accent:     #b6552e;   /* burnt orange */
  --accent-soft:#ecd5c8;
  --accent2:    #2a6f6b;   /* teal */
  --accent2-soft:#d6e8e6;
  --accent3:    #c08a2c;   /* mustard */
  --accent3-soft:#f3e2bf;
  --accent4:    #5a7b3a;   /* moss green for "good" */
  --code-bg:    #1d1f24;
  --code-ink:   #e4e2db;
  --math-bg:    #f6f1e3;
  --shadow:     0 1px 2px rgba(0,0,0,.04), 0 6px 18px rgba(0,0,0,.04);
  --radius:     8px;
  --maxw:       820px;
  --font-body:  "Charter","Iowan Old Style","Source Serif Pro","Noto Serif SC",ui-serif,Georgia,serif;
  --font-ui:    "Inter","Helvetica Neue","Noto Sans SC",ui-sans-serif,system-ui,sans-serif;
  --font-mono:  "JetBrains Mono","Fira Code",ui-monospace,Menlo,monospace;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 24px; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 18px;
  line-height: 1.62;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
::selection { background: var(--accent-soft); color: var(--ink); }

/* ----- Language toggle --------------------------------------- */
/* Hide whichever language is not active. Default cn (set by inline script). */
html[data-lang="en"] [data-lang]:not([data-lang="en"]) { display: none !important; }
html[data-lang="cn"] [data-lang]:not([data-lang="cn"]) { display: none !important; }

.lang-toggle {
  display: inline-flex;
  margin: 12px 0 18px;
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
  background: var(--bg);
  font-family: var(--font-ui);
}
.lang-toggle button {
  border: 0;
  background: transparent;
  color: var(--ink-soft);
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  letter-spacing: .04em;
}
.lang-toggle button:hover { background: var(--accent-soft); color: var(--ink); }
html[data-lang="en"] .lang-toggle button[data-set-lang="en"],
html[data-lang="cn"] .lang-toggle button[data-set-lang="cn"] {
  background: var(--accent);
  color: #fff;
}

.sidebar-head { margin-bottom: 10px; }

/* ----- Layout ------------------------------------------------ */
.layout {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 0;
  max-width: 1440px;
  margin: 0 auto;
}
.sidebar {
  position: sticky;
  top: 0;
  align-self: start;
  height: 100vh;
  overflow-y: auto;
  padding: 28px 22px 40px;
  border-right: 1px solid var(--line);
  background: var(--bg-soft);
  font-family: var(--font-ui);
  font-size: 14px;
}
.sidebar h1 {
  font-family: var(--font-body);
  font-size: 18px;
  font-weight: 700;
  margin: 0 0 4px;
  letter-spacing: -.01em;
}
.sidebar .subtitle {
  color: var(--ink-faint);
  font-size: 12px;
  margin-bottom: 18px;
  line-height: 1.4;
}
.toc { list-style: none; padding: 0; margin: 14px 0 0; }
.toc > li { margin: 0; }
.toc a {
  display: block;
  padding: 5px 8px;
  border-radius: 4px;
  color: var(--ink-soft);
  text-decoration: none;
  line-height: 1.35;
}
.toc a:hover { background: var(--accent-soft); color: var(--ink); }
.toc a.active { color: var(--accent); font-weight: 600; }
.toc .group {
  text-transform: uppercase;
  font-size: 10.5px;
  letter-spacing: .12em;
  color: var(--ink-faint);
  padding: 14px 8px 4px;
  font-weight: 600;
}
.toc .nested { padding-left: 12px; font-size: 13px; }

main {
  padding: 56px 60px 120px;
  max-width: 100%;
}
.col {
  max-width: var(--maxw);
  margin: 0 auto;
}

/* ----- Typography -------------------------------------------- */
h1, h2, h3, h4 { font-family: var(--font-ui); letter-spacing: -.012em; }
h1 { font-size: 44px; line-height: 1.05; margin: 0 0 8px; font-weight: 800; }
h2 {
  font-size: 28px;
  line-height: 1.2;
  margin: 64px 0 12px;
  font-weight: 700;
  border-top: 1px solid var(--line);
  padding-top: 36px;
}
h2 .num {
  color: var(--accent);
  font-family: var(--font-mono);
  font-weight: 500;
  margin-right: 12px;
  font-size: 18px;
  vertical-align: 4px;
}
h3 { font-size: 22px; margin: 38px 0 8px; font-weight: 700; }
h4 { font-size: 16px; margin: 22px 0 6px; font-weight: 700; color: var(--ink-soft); text-transform: uppercase; letter-spacing: .05em; }
p { margin: 0 0 14px; }
a { color: var(--accent); text-decoration: none; border-bottom: 1px solid var(--accent-soft); }
a:hover { border-bottom-color: var(--accent); }
strong { color: var(--ink); font-weight: 700; }
em { font-style: italic; color: var(--ink-soft); }
hr { border: 0; height: 1px; background: var(--line); margin: 36px 0; }
ul, ol { margin: 0 0 14px; padding-left: 22px; }
li { margin: 4px 0; }

/* ----- Hero -------------------------------------------------- */
.hero {
  margin: 0 0 48px;
  padding: 18px 0 24px;
}
.hero .kicker {
  font-family: var(--font-ui);
  text-transform: uppercase;
  letter-spacing: .14em;
  font-size: 11px;
  color: var(--accent);
  font-weight: 600;
  margin-bottom: 14px;
}
.hero .lede {
  font-size: 21px;
  line-height: 1.5;
  color: var(--ink-soft);
  max-width: 720px;
  margin: 18px 0 10px;
}
.hero .meta {
  font-family: var(--font-ui);
  color: var(--ink-faint);
  font-size: 13px;
  margin-top: 18px;
}

/* ----- Callouts --------------------------------------------- */
.callout {
  background: var(--math-bg);
  border-radius: var(--radius);
  padding: 18px 22px;
  margin: 22px 0;
  border-left: 4px solid var(--accent3);
  font-family: var(--font-body);
}
.callout-title {
  font-family: var(--font-ui);
  font-weight: 700;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--accent3);
  margin-bottom: 8px;
}
.callout.intuition { border-left-color: var(--accent2); }
.callout.intuition .callout-title { color: var(--accent2); }
.callout.warn { border-left-color: var(--accent); background: #fbeee6; }
.callout.warn .callout-title { color: var(--accent); }
.callout p:last-child { margin-bottom: 0; }

/* ----- Paper-like cards (used by deep-dives) ----------------- */
.paper {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px 26px;
  margin: 22px 0 28px;
  box-shadow: var(--shadow);
}
.paper-head {
  display: flex; flex-wrap: wrap;
  align-items: baseline; gap: 10px;
  margin-bottom: 6px;
  font-family: var(--font-ui);
}
.paper-head .alias {
  font-size: 18px; font-weight: 700; color: var(--ink);
}
.paper-head .full {
  font-size: 14px; color: var(--ink-soft); font-weight: 400;
}
.paper-meta {
  font-family: var(--font-ui);
  font-size: 12px;
  color: var(--ink-faint);
  margin-bottom: 12px;
}
.paper-meta .tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--accent);
  margin-right: 6px;
  font-weight: 600;
  font-size: 11px;
  letter-spacing: .02em;
}
.paper-meta .tag.teal    { background: var(--accent2-soft); color: var(--accent2); }
.paper-meta .tag.mustard { background: var(--accent3-soft); color: #8a6512; }
.paper-meta a { color: var(--ink-soft); border-bottom: none; margin-right: 12px; }
.paper-meta a:hover { color: var(--accent); }
.paper .pain {
  font-style: italic;
  color: var(--ink-soft);
  margin: 4px 0 12px;
  padding-left: 12px;
  border-left: 3px solid var(--accent-soft);
}
.paper .idea { margin: 12px 0; }
.paper .idea-label {
  font-family: var(--font-ui);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--accent);
  font-weight: 700;
}
.paper .diff {
  font-family: var(--font-ui);
  font-size: 13.5px;
  color: var(--ink-soft);
  background: var(--bg-soft);
  border-radius: 6px;
  padding: 8px 12px;
  margin-top: 10px;
}
.paper .diff::before {
  content: "vs prior →";
  font-weight: 700;
  color: var(--accent2);
  margin-right: 8px;
}

/* ----- Code ------------------------------------------------- */
pre {
  background: var(--code-bg);
  color: var(--code-ink);
  padding: 18px 22px;
  border-radius: var(--radius);
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 13.5px;
  line-height: 1.55;
  margin: 18px 0;
}
code {
  font-family: var(--font-mono);
  font-size: 0.92em;
  background: var(--bg-soft);
  padding: 1px 5px;
  border-radius: 3px;
  color: var(--accent);
}
pre code { background: transparent; color: inherit; padding: 0; font-size: inherit; }
/* highlight.js: override its theme background so our card bg shows */
.hljs { background: transparent !important; padding: 0 !important; }

/* ----- Tables ----------------------------------------------- */
.tbl {
  width: 100%;
  border-collapse: collapse;
  margin: 18px 0;
  font-family: var(--font-ui);
  font-size: 14px;
}
.tbl th, .tbl td {
  text-align: left;
  padding: 9px 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
.tbl th {
  background: var(--bg-soft);
  font-weight: 700;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.tbl tr:hover td { background: #fffaf2; }

/* ----- Demos / Visualizations -------------------------------- */
.demo {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
  margin: 26px 0;
  box-shadow: var(--shadow);
}
.demo-title {
  font-family: var(--font-ui);
  font-weight: 700;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--accent);
  margin-bottom: 12px;
}
.demo-stage {
  position: relative;
  width: 100%;
  background: #f8f6ef;
  border-radius: 6px;
  border: 1px solid var(--line);
  overflow: hidden;
}
.demo canvas { display: block; width: 100%; height: auto; touch-action: none; cursor: crosshair; }
.demo-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 14px 22px;
  align-items: center;
  font-family: var(--font-ui);
  font-size: 13px;
  margin-top: 14px;
}
.demo-controls label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  color: var(--ink-soft);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .05em;
  font-weight: 600;
  min-width: 130px;
}
.demo-controls input[type=range] { width: 160px; accent-color: var(--accent); }
.demo-controls button {
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 600;
  background: var(--ink);
  color: var(--bg);
  border: 0;
  border-radius: 4px;
  padding: 7px 14px;
  cursor: pointer;
  letter-spacing: .02em;
}
.demo-controls button:hover { background: var(--accent); }
.demo-controls .toggle {
  display: inline-flex; align-items: center; gap: 6px;
  text-transform: none; font-size: 13px; letter-spacing: 0; font-weight: 400;
  color: var(--ink);
  min-width: 0;
}
.demo-caption {
  font-family: var(--font-ui);
  font-size: 13px;
  color: var(--ink-soft);
  margin-top: 12px;
  line-height: 1.5;
}
.readout {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--accent2);
  background: var(--bg-soft);
  padding: 4px 8px;
  border-radius: 3px;
  display: inline-block;
  white-space: pre;
}

/* ----- Math (KaTeX overrides) ------------------------------- */
.katex { font-size: 1.04em; }
.katex-display {
  background: var(--math-bg);
  padding: 12px 18px;
  border-radius: 6px;
  overflow-x: auto;
  margin: 16px 0;
}

/* ----- Pipeline numbered list (§3) -------------------------- */
.pipeline-list {
  counter-reset: step;
  list-style: none;
  padding: 0;
  margin: 22px 0;
}
.pipeline-list li {
  counter-increment: step;
  position: relative;
  padding: 12px 16px 12px 52px;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 6px;
  margin: 6px 0;
  font-family: var(--font-ui);
  font-size: 14.5px;
}
.pipeline-list li::before {
  content: counter(step);
  position: absolute;
  left: 14px; top: 50%;
  transform: translateY(-50%);
  width: 26px; height: 26px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--accent);
  color: #fff;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 12px;
}

/* ----- Stat grid (§5 baseline numbers) ---------------------- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 14px;
  margin: 22px 0;
}
.stat {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
}
.stat-num {
  font-family: var(--font-ui);
  font-size: 2.2rem;
  font-weight: 800;
  color: var(--accent);
  line-height: 1.05;
  letter-spacing: -.02em;
}
.stat-num small {
  font-size: 0.45em;
  color: var(--ink-faint);
  margin-left: 4px;
  font-weight: 500;
  font-family: var(--font-mono);
  letter-spacing: .04em;
}
.stat-lbl {
  font-family: var(--font-ui);
  font-size: 12.5px;
  color: var(--ink-soft);
  margin-top: 8px;
  line-height: 1.4;
}

/* ----- Timeline (§6) ---------------------------------------- */
.timeline-wrap {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr);
  gap: 28px;
  align-items: start;
  margin: 22px 0 0;
}
#timeline-rail {
  position: relative;
  border-left: 2px solid var(--line);
  padding: 0;
  max-height: 640px;
  overflow-y: auto;
}
.tl-item {
  position: relative;
  padding: 12px 14px 12px 24px;
  cursor: pointer;
  border-radius: 6px;
  margin-left: -2px;
  transition: background 0.15s, border-left-color 0.15s;
  border-left: 2px solid transparent;
  font-family: var(--font-ui);
}
.tl-item:hover { background: var(--bg-soft); }
.tl-item.active {
  background: var(--bg-card);
  border-left-color: var(--accent);
  box-shadow: var(--shadow);
}
.tl-item::before {
  content: '';
  position: absolute;
  left: -7px; top: 19px;
  width: 10px; height: 10px;
  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 3px var(--accent-soft);
}
.tl-year {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: .1em;
  color: var(--accent);
  text-transform: uppercase;
}
.tl-title {
  font-family: var(--font-ui);
  font-weight: 700;
  font-size: 15px;
  color: var(--ink);
  margin: 2px 0;
}
.tl-tag {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-faint);
}
#timeline-detail {
  position: sticky;
  top: 24px;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px 26px;
  min-height: 380px;
  box-shadow: var(--shadow);
}
#timeline-detail h3 {
  margin: 0 0 10px;
  color: var(--ink);
  font-size: 20px;
}
.td-meta {
  font-family: var(--font-ui);
  font-size: 12px;
  color: var(--ink-faint);
  margin-bottom: 14px;
  border-bottom: 1px dashed var(--line);
  padding-bottom: 10px;
  line-height: 1.7;
}
.td-meta span { display: inline-block; margin-right: 12px; }
.td-meta b { color: var(--accent2); font-weight: 600; }
.td-idea {
  font-family: var(--font-body);
  font-size: 16px;
  color: var(--ink);
}
.td-gains {
  display: flex; gap: 10px; flex-wrap: wrap;
  margin: 16px 0;
}
.td-gain {
  flex: 1;
  min-width: 110px;
  background: var(--bg-soft);
  border-radius: 6px;
  padding: 10px 12px;
}
.td-gain .g-val {
  font-family: var(--font-ui);
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--accent2);
  line-height: 1.1;
}
.td-gain .g-lbl {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--ink-faint);
  margin-top: 4px;
  line-height: 1.3;
}
.td-intuition {
  font-style: italic;
  color: var(--ink-soft);
  padding-top: 12px;
  border-top: 1px dashed var(--line);
  margin-top: 14px;
  font-size: 14.5px;
  font-family: var(--font-body);
}
.td-intuition strong { color: var(--accent2); font-style: normal; }

/* ----- Footer ------------------------------------------------ */
footer {
  margin-top: 80px;
  padding: 30px 0;
  border-top: 1px solid var(--line);
  font-family: var(--font-ui);
  font-size: 13px;
  color: var(--ink-faint);
}
footer a { color: var(--ink-soft); border-bottom: 1px dotted var(--line); }
footer ul { padding-left: 0; list-style: none; }
footer li { padding: 5px 0; }

/* ----- Responsive ------------------------------------------- */
@media (max-width: 1024px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar {
    position: relative; height: auto; border-right: none;
    border-bottom: 1px solid var(--line); padding: 18px 22px;
  }
  main { padding: 32px 22px 80px; }
  .timeline-wrap { grid-template-columns: 1fr; }
  #timeline-detail { position: static; }
  #timeline-rail { max-height: none; }
}
@media (max-width: 640px) {
  body { font-size: 16.5px; }
  h1 { font-size: 32px; }
  h2 { font-size: 22px; margin-top: 44px; }
  .paper { padding: 16px 18px; }
  .demo { padding: 14px; }
}

/* Smooth scrolling anchors with a tiny indicator */
section { scroll-margin-top: 30px; }
