/* ============================================================
   3DGS · Foundations — stylesheet
   Mirrors ../3dgs-large-scale: academic, calm, content-first,
   sidebar TOC + 820px main column, burnt-orange / teal / mustard.
   ============================================================ */

: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 */
  --accent3:   #c08a2c;     /* mustard */
  --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;
}

/* ----- 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;
  color: var(--ink);
}
.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;
  border-bottom: none;
}
.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;
}

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

/* ----- Typographic primitives -------------------------------- */
h1, h2, h3, h4 { font-family: var(--font-ui); letter-spacing: -.012em; color: var(--ink); }
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; }
blockquote {
  margin: 18px 0; padding: 8px 14px 8px 18px;
  border-left: 3px solid var(--accent-soft);
  color: var(--ink-soft);
  font-style: italic;
}

/* ----- 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 h1 em {
  font-style: italic;
  color: var(--accent2);
}
.hero .lede {
  font-size: 21px;
  line-height: 1.5;
  color: var(--ink-soft);
  max-width: 720px;
  margin: 18px 0 10px;
}
.hero .lede em { color: var(--accent); font-style: italic; }
.hero .meta {
  font-family: var(--font-ui);
  color: var(--ink-faint);
  font-size: 13px;
  margin-top: 18px;
}

/* ----- Part dividers (mid-essay banners) ---------------------- */
.part-divider {
  margin: 80px 0 30px;
  padding: 36px 30px;
  background: var(--bg-soft);
  border-radius: var(--radius);
  border-left: 4px solid var(--accent);
}
.part-divider .part-tag {
  font-family: var(--font-ui);
  text-transform: uppercase;
  letter-spacing: .2em;
  font-size: 11px;
  color: var(--accent);
  font-weight: 700;
  margin: 0 0 8px;
}
.part-divider h2 {
  margin: 0 0 10px;
  font-size: 26px;
  border: 0;
  padding: 0;
  font-style: italic;
  font-weight: 500;
}
.part-divider p {
  color: var(--ink-soft); margin: 0;
  font-size: 15px; line-height: 1.55;
}

/* ----- 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; }

/* Abstract block (single-page essay opener) */
.abstract {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px 28px;
  margin: 28px 0 36px;
  box-shadow: var(--shadow);
}
.abstract .abstract-label {
  font-family: var(--font-ui);
  font-weight: 700;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .15em;
  color: var(--accent);
  margin: 0 0 12px;
}
.abstract p { margin: 0 0 0.8em; color: var(--ink-soft); font-size: 17px; }
.abstract p:last-child { margin-bottom: 0; }

/* ----- 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);
  border: 0;
}
pre code { background: transparent; color: inherit; padding: 0; font-size: inherit; border: 0; }

/* hljs (atom-one-dark) overrides to match our muted palette */
.hljs { background: transparent !important; color: var(--code-ink) !important; }
.hljs-keyword, .hljs-built_in, .hljs-meta { color: #f6c177; }
.hljs-string                              { color: #c4a7e7; }
.hljs-number, .hljs-literal               { color: #ebbcba; }
.hljs-comment                             { color: #6e6a86; font-style: italic; }
.hljs-function .hljs-title,
.hljs-title.function_, .hljs-title        { color: #91d1c2; }
.hljs-params                              { color: var(--code-ink); }
.hljs-attr, .hljs-property                { color: #9ccfd8; }
.hljs-operator                            { color: #eb6f92; }

/* ----- 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; }
.tbl code { font-size: 0.9em; }

/* ----- Demos ------------------------------------------------ */
.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);
}
.demo-caption {
  font-family: var(--font-ui);
  font-size: 13px;
  color: var(--ink-soft);
  margin-top: 12px;
  line-height: 1.5;
}
.demo-caption b {
  color: var(--ink);
}
.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;
}
.math-block {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 12px;
  background: var(--math-bg);
  border-radius: 6px;
  padding: 4px 14px 4px 4px;
  margin: 18px 0;
  overflow-x: auto;
}
.math-block .katex-display {
  background: transparent !important;
  padding: 6px 8px !important;
  margin: 0 !important;
}
.math-block .eq-num {
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--ink-faint);
  padding-right: 4px;
  white-space: nowrap;
}

/* ----- Comparison cards (2-up) ------------------------------- */
.cmp-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin: 22px 0;
}
.cmp {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 22px;
  box-shadow: var(--shadow);
}
.cmp h4 {
  font-family: var(--font-ui);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--accent);
  margin: 0 0 10px;
  font-weight: 700;
}
.cmp.alt h4 { color: var(--accent2); }
.cmp ul { padding-left: 18px; font-size: 14.5px; color: var(--ink-soft); margin: 0; }
.cmp li { margin: 4px 0; }
@media (max-width: 760px) { .cmp-grid { grid-template-columns: 1fr; } }

/* ----- Notation table -------------------------------------- */
.notation-block { margin: 28px 0; }
.notation-block h3 {
  font-family: var(--font-ui);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .15em;
  color: var(--accent);
  font-weight: 700;
  margin: 0 0 14px;
}
.notation {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 6px 22px;
  font-size: 15px;
  margin: 0 0 8px;
}
.notation dt {
  font-family: var(--font-mono);
  color: var(--accent2);
  font-size: 14px;
}
.notation dd { margin: 0; color: var(--ink-soft); }

/* ----- References ------------------------------------------ */
.references {
  margin: 80px 0 0;
  font-size: 14.5px;
}
.references h2 {
  font-family: var(--font-ui);
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: .15em;
  color: var(--accent);
  font-weight: 700;
  border: 0; padding: 0; margin: 0 0 14px;
}
.references ol { padding-left: 24px; color: var(--ink-soft); }
.references li { margin: 6px 0; padding-left: 4px; line-height: 1.5; }
.ref-tag {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--accent2);
  background: var(--bg-soft);
  padding: 1px 6px;
  border-radius: 3px;
  margin-right: 6px;
}

/* Citation superscript link */
.cite {
  font-family: var(--font-ui);
  font-size: 11px;
  vertical-align: super;
  color: var(--accent);
  border-bottom: none;
  font-weight: 600;
  padding: 0 1px;
  text-decoration: none;
}
.cite:hover { background: var(--accent-soft); border-bottom: none; }

/* paper rule (thematic break used at end of essay) */
hr.paper-rule {
  border: 0; height: 1px; background: var(--line);
  margin: 38px auto;
  max-width: 30ch;
  opacity: 0.7;
}

/* ----- 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 p { margin: 0 0 10px; }
footer .footer-meta { color: var(--ink-faint); font-size: 12.5px; margin-top: 14px; }

section { scroll-margin-top: 30px; }

/* ----- 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; }
}
@media (max-width: 640px) {
  body { font-size: 16.5px; }
  h1 { font-size: 32px; }
  h2 { font-size: 22px; margin-top: 44px; }
  .demo { padding: 14px; }
  .abstract { padding: 18px; }
  .part-divider { padding: 22px 18px; }
}
