/* ============================================================
   3DGS Ray Tracing — stylesheet
   Aesthetic: academic, calm, content-first, with interactive
   demos that pop. Inspired by Distill.pub + thesis monographs,
   palette aligned with the sibling 3dgs-large-scale survey.
   ============================================================ */

: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;
  --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: 0;
}
.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;
}

/* ----- 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: 14.5px;
  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;
  position: relative;
}
.hero canvas#hero-canvas {
  position: absolute;
  inset: -18px 0 0 0;
  width: 100%;
  height: calc(100% + 18px);
  opacity: 0.7;
  pointer-events: none;
  z-index: 0;
}
.hero > *:not(canvas) { position: relative; z-index: 1; }
.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;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 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 p { margin: 0; }
.callout p + p { margin-top: 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.detail { border-left-color: var(--accent3); }

/* ----- Paper cards ------------------------------------------ */
.paper {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 22px;
  margin: 14px 0;
  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: 17px;
  font-weight: 700;
  color: var(--ink);
}
.paper-head .full {
  font-size: 13.5px;
  color: var(--ink-soft);
  font-weight: 400;
}
.paper-meta {
  font-family: var(--font-ui);
  font-size: 12px;
  color: var(--ink-faint);
  margin-bottom: 8px;
}
.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: 10px;
}
.paper-meta a:hover { color: var(--accent); }
.paper p { margin: 6px 0; font-size: 16px; }

/* ----- 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;
  position: relative;
}
pre .lang-tag {
  position: absolute;
  top: 8px;
  right: 12px;
  font-family: var(--font-ui);
  font-size: 10.5px;
  color: rgba(228, 226, 219, 0.55);
  text-transform: uppercase;
  letter-spacing: .08em;
}
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 token overrides for our cream theme */
.hljs        { background: transparent; color: var(--code-ink); }
.hljs-keyword,.hljs-built_in,.hljs-type   { color: #f6c177; }
.hljs-title,.hljs-function .hljs-title    { color: #91d1c2; }
.hljs-string,.hljs-meta-string             { color: #c4a7e7; }
.hljs-number,.hljs-literal                 { color: #ebbcba; }
.hljs-comment,.hljs-quote                  { color: #6e6a86; font-style: italic; }
.hljs-symbol,.hljs-operator,.hljs-punctuation { color: #eb6f92; }
.hljs-attr,.hljs-attribute,.hljs-name      { color: #f6c177; }
.hljs-params,.hljs-variable                { color: var(--code-ink); }

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

/* ----- 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: 6px;
}
.demo-sub {
  font-family: var(--font-ui);
  font-size: 13.5px;
  color: var(--ink-soft);
  margin: 0 0 14px;
  line-height: 1.5;
}
.demo-stage {
  position: relative;
  width: 100%;
  background: #f6f1e3;
  border-radius: 6px;
  border: 1px solid var(--line);
  overflow: hidden;
}
.demo canvas {
  display: block;
  width: 100%;
  height: auto;
  background: #f6f1e3;
  touch-action: none;
  cursor: crosshair;
}
.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 14px 22px;
  align-items: center;
  font-family: var(--font-ui);
  font-size: 13px;
  margin-top: 14px;
}
.controls label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  color: var(--ink-soft);
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: .05em;
  font-weight: 600;
  min-width: 130px;
}
.controls label > input[type="checkbox"] {
  align-self: flex-start;
  margin-top: 4px;
  accent-color: var(--accent);
}
.controls input[type="range"] {
  width: 160px;
  accent-color: var(--accent);
}
.controls .val {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--accent);
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0;
}
.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;
}
.controls button:hover { background: var(--accent); }
.controls button.active { background: var(--accent); }
.controls .btn-group {
  display: inline-flex;
  gap: 0;
  align-items: stretch;
  border-radius: 4px;
  overflow: hidden;
  box-shadow: 0 0 0 1px var(--line);
}
.controls .btn-group button { border-radius: 0; }
.controls .btn-group button:not(:last-child) { border-right: 1px solid rgba(255,255,255,0.15); }
.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 18px;
  font-family: var(--font-ui);
  font-size: 12px;
  color: var(--ink-soft);
  margin-top: 12px;
}
.legend .sw {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 2px;
  margin-right: 6px;
  vertical-align: -2px;
}

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

/* ----- References ------------------------------------------- */
.ref-list {
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 1.55;
  color: var(--ink-soft);
  padding-left: 22px;
}
.ref-list li { margin: 10px 0; }
.ref-list .ref-title { color: var(--ink); }
.ref-list .ref-meta { color: var(--ink-faint); font-size: 12.5px; margin-top: 2px; }

/* ----- Footer ------------------------------------------------ */
footer, .colophon {
  margin-top: 80px;
  padding: 30px 0 10px;
  border-top: 1px solid var(--line);
  font-family: var(--font-ui);
  font-size: 13px;
  color: var(--ink-faint);
}
footer a, .colophon a { color: var(--ink-soft); border-bottom: 1px dotted var(--line); }

/* anchors get a bit of breathing room */
section { scroll-margin-top: 30px; }
h2, h3 { 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; }
  .paper { padding: 14px 16px; }
  .demo { padding: 14px; }
  .controls input[type="range"] { width: 130px; }
}
