/* ===== VideoSEAL — Design System ===== */
:root {
  --bg: #fbfaf7;
  --bg-elevated: #ffffff;
  --ink: #15212e;
  --ink-soft: #3a4a5c;
  --ink-muted: #6b7785;
  --rule: #e3e0d8;
  --upstream: #1f3a52;
  --midmarket: #4a7396;
  --downstream: #7aa6cc;
  --feedback: #16a085;
  --accent: #c8392c;
  --gold: #b8860b;
  --planner: #2c5f8a;
  --inspector: #16a085;
  --chapter-pad: 7rem;
}

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

html { scroll-behavior: smooth; font-size: 17px; }

body {
  font-family: 'Newsreader', Georgia, serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

/* ===== NAV ===== */
.nav-bar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  background: rgba(251,250,247,.94);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--rule);
  height: 52px;
}
.nav-inner {
  max-width: 920px; margin: 0 auto;
  padding: .55rem 1.5rem 0;
  display: flex; flex-direction: column;
}
.nav-paper { font-family: 'Inter', sans-serif; font-weight: 600; font-size: .82rem; color: var(--ink); }
.nav-sub { font-family: 'Inter', sans-serif; font-size: .68rem; color: var(--ink-muted); margin-left: .6rem; }
.nav-title { display: flex; align-items: baseline; gap: .2rem; }
.nav-progress { height: 2px; background: var(--rule); margin-top: .35rem; border-radius: 1px; }
.nav-progress-fill { height: 100%; width: 0%; background: var(--accent); border-radius: 1px; transition: width .1s; }

/* ===== CHAPTER RAIL ===== */
.chapter-rail {
  position: fixed; left: 1.2rem; top: 50%; transform: translateY(-50%);
  z-index: 90;
}
.chapter-rail ol { list-style: none; }
.chapter-rail li {
  display: flex; align-items: center; gap: .45rem;
  margin-bottom: .7rem; cursor: pointer;
  font-family: 'Inter', sans-serif; font-size: .65rem;
  color: var(--ink-muted);
  transition: color .2s;
}
.chapter-rail li:hover { color: var(--ink-soft); }
.chapter-rail li.active { color: var(--accent); }
.chapter-rail .dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--rule);
  transition: background .2s, transform .2s;
  flex-shrink: 0;
}
.chapter-rail li.active .dot { background: var(--accent); transform: scale(1.4); }
.chapter-rail .label { display: none; }
.chapter-rail li:hover .label,
.chapter-rail li.active .label { display: inline; }

@media (max-width: 1100px) { .chapter-rail { display: none; } }

/* ===== CHAPTERS ===== */
.chapter {
  max-width: 920px; margin: 0 auto;
  padding: var(--chapter-pad) 1.5rem 3rem;
}
.chapter + .chapter { border-top: 1px solid var(--rule); }

.chapter-num {
  font-family: 'Inter', sans-serif;
  font-size: .72rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: .12em;
  color: var(--accent);
  margin-bottom: .8rem;
}
.chapter h2 {
  font-size: 2.1rem; font-weight: 600;
  line-height: 1.18; margin-bottom: 1.2rem;
  color: var(--ink);
}
.chapter h3 {
  font-size: 1.35rem; font-weight: 600;
  margin: 2rem 0 .8rem; color: var(--upstream);
}
.lede {
  font-size: 1.08rem; color: var(--ink-soft);
  max-width: 680px; margin-bottom: 1.8rem;
}

/* ===== PLAIN CARD ===== */
.plain-card {
  background: var(--bg);
  border-left: 4px solid var(--gold);
  padding: 1.4rem 1.6rem;
  margin: 1.8rem 0;
  border-radius: 0 6px 6px 0;
}
.plain-label {
  font-family: 'Inter', sans-serif;
  font-size: .68rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: .1em;
  color: var(--gold); margin-bottom: .6rem;
}
.plain-card p {
  font-size: .95rem; color: var(--ink-soft);
  margin-bottom: .6rem; line-height: 1.65;
}
.plain-card p:last-child { margin-bottom: 0; }

/* ===== EQUATION BLOCK ===== */
.equation-block {
  background: var(--bg-elevated);
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 1.2rem 1.5rem;
  margin: 1.5rem 0;
  overflow-x: auto;
}
.equation-block .eq-label {
  font-family: 'Inter', sans-serif;
  font-size: .7rem; font-weight: 600;
  color: var(--ink-muted);
  margin-bottom: .5rem;
}

/* ===== INTERACTIVE SECTION ===== */
.interactive-section {
  margin: 2.5rem 0;
  background: var(--bg-elevated);
  border: 1px solid var(--rule);
  border-radius: 8px;
  padding: 1.5rem;
}
.interactive-section .hint {
  font-family: 'Inter', sans-serif;
  font-size: .72rem; color: var(--ink-muted);
  margin-bottom: 1rem;
  font-style: italic;
}
.slider-group {
  display: flex; flex-wrap: wrap; gap: 1.2rem;
  margin-bottom: 1.5rem;
}
.slider-item {
  flex: 1 1 200px; min-width: 200px;
}
.slider-item label {
  display: block;
  font-family: 'Inter', sans-serif;
  font-size: .78rem; font-weight: 500;
  color: var(--ink-soft);
  margin-bottom: .3rem;
}
.slider-item input[type="range"] {
  width: 100%; height: 4px;
  -webkit-appearance: none; appearance: none;
  background: var(--rule); border-radius: 2px;
  outline: none;
}
.slider-item input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: 2px solid var(--bg-elevated);
  box-shadow: 0 1px 3px rgba(0,0,0,.15);
}
.slider-item .slider-val {
  font-family: 'JetBrains Mono', monospace;
  font-size: .72rem; color: var(--ink-muted);
  margin-top: .15rem;
}
.chart-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}
.chart-grid.single { grid-template-columns: 1fr; }
@media (max-width: 700px) { .chart-grid { grid-template-columns: 1fr; } }
.chart-cell { min-height: 260px; }

/* ===== CALLOUT ===== */
.callout {
  border-left: 4px solid var(--accent);
  padding: 1.1rem 1.4rem;
  margin: 2rem 0;
  background: rgba(200,57,44,.04);
  border-radius: 0 6px 6px 0;
}
.callout p {
  font-size: .92rem; color: var(--ink-soft);
  line-height: 1.6;
}

/* ===== CHAPTER FOOT ===== */
.chapter-foot {
  display: inline-flex; align-items: center; gap: .4rem;
  font-family: 'Inter', sans-serif;
  font-size: .82rem; font-weight: 500;
  color: var(--midmarket);
  text-decoration: none;
  margin-top: 2rem;
  transition: color .2s, gap .2s;
}
.chapter-foot:hover { color: var(--accent); gap: .7rem; }
.chapter-foot .arrow { transition: transform .2s; }
.chapter-foot:hover .arrow { transform: translateX(4px); }

/* ===== COVER ===== */
.cover { padding-top: 5rem; text-align: center; }
.cover-inner { max-width: 720px; margin: 0 auto; }
.cover-eyebrow {
  font-family: 'Inter', sans-serif;
  font-size: .72rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: .15em;
  color: var(--accent);
  margin-bottom: 1rem;
}
.cover-title {
  font-size: 2.6rem; font-weight: 700;
  line-height: 1.15; margin-bottom: .6rem;
  color: var(--ink);
}
.cover-title em { color: var(--accent); font-style: italic; }
.cover-subtitle {
  font-size: 1.15rem; color: var(--ink-soft);
  margin-bottom: 1rem;
}
.cover-byline {
  font-size: .85rem; color: var(--ink-muted);
  margin-bottom: 2.5rem;
  line-height: 1.6;
}
.cover-byline .muted { font-size: .78rem; }

/* cover abstract */
.cover-abstract {
  background: var(--bg);
  border-left: 4px solid var(--gold);
  padding: 1.4rem 1.8rem;
  margin: 2rem auto;
  text-align: left;
  border-radius: 0 6px 6px 0;
  max-width: 680px;
}
.cover-abstract-label {
  font-family: 'Inter', sans-serif;
  font-size: .68rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: .1em;
  color: var(--gold); margin-bottom: .6rem;
}
.cover-abstract p {
  font-size: .95rem; color: var(--ink-soft);
  margin-bottom: .7rem; line-height: 1.65;
}
.cover-abstract p:last-child { margin-bottom: 0; }

/* pillar cards */
.cover-pillars {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 1rem; margin-top: 2.5rem; text-align: left;
}
.pillar {
  background: var(--bg-elevated);
  border: 1px solid var(--rule);
  border-radius: 8px;
  padding: 1.1rem 1.2rem;
}
.pillar-num {
  font-family: 'Newsreader', serif;
  font-size: 1.4rem; font-weight: 700;
  color: var(--accent); margin-bottom: .3rem;
}
.pillar-title {
  font-family: 'Inter', sans-serif;
  font-size: .82rem; font-weight: 600;
  color: var(--ink); margin-bottom: .4rem;
}
.pillar-text {
  font-size: .82rem; color: var(--ink-muted);
  line-height: 1.55;
}
@media (max-width: 700px) { .cover-pillars { grid-template-columns: 1fr; } }

/* ===== ARCHITECTURE DIAGRAM ===== */
.arch-diagram {
  margin: 1.5rem 0;
  display: flex; gap: 2rem; flex-wrap: wrap;
  justify-content: center;
}
.arch-col {
  flex: 1 1 320px; max-width: 400px;
  background: var(--bg-elevated);
  border: 1px solid var(--rule);
  border-radius: 8px;
  padding: 1.2rem;
}
.arch-col-title {
  font-family: 'Inter', sans-serif;
  font-size: .78rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: .08em;
  color: var(--ink-muted);
  margin-bottom: .8rem; text-align: center;
}
.arch-node {
  padding: .6rem .9rem;
  border-radius: 6px;
  margin-bottom: .5rem;
  font-family: 'Inter', sans-serif;
  font-size: .78rem; font-weight: 500;
  text-align: center;
  transition: transform .15s, box-shadow .15s;
  cursor: default;
}
.arch-node:hover { transform: translateY(-1px); box-shadow: 0 2px 8px rgba(0,0,0,.1); }
.arch-node.planner { background: rgba(44,95,138,.12); color: var(--planner); border: 1px solid rgba(44,95,138,.3); }
.arch-node.inspector { background: rgba(22,160,133,.12); color: var(--inspector); border: 1px solid rgba(22,160,133,.3); }
.arch-node.tool { background: rgba(74,115,150,.08); color: var(--midmarket); border: 1px solid rgba(74,115,150,.2); }
.arch-node.answer { background: rgba(200,57,44,.08); color: var(--accent); border: 1px solid rgba(200,57,44,.25); }
.arch-arrow {
  text-align: center; font-size: 1.2rem; color: var(--ink-muted);
  margin: .3rem 0; line-height: 1;
}
.arch-node.active-node { transform: scale(1.04); box-shadow: 0 0 0 2px var(--accent); }

/* ===== BUTTON GROUP ===== */
.btn-group {
  display: flex; gap: .6rem; flex-wrap: wrap;
  margin-bottom: 1.2rem;
}
.btn {
  font-family: 'Inter', sans-serif;
  font-size: .78rem; font-weight: 500;
  padding: .45rem 1rem;
  border-radius: 5px;
  border: 1px solid var(--rule);
  background: var(--bg);
  color: var(--ink-soft);
  cursor: pointer;
  transition: all .15s;
}
.btn:hover { border-color: var(--midmarket); color: var(--ink); }
.btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ===== READOUT CARDS ===== */
.readout-cards {
  display: flex; gap: .8rem; flex-wrap: wrap;
  margin-bottom: 1.2rem;
}
.readout-card {
  flex: 1 1 140px;
  background: var(--bg);
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: .7rem .9rem;
  text-align: center;
}
.readout-card .rc-label {
  font-family: 'Inter', sans-serif;
  font-size: .65rem; font-weight: 500;
  text-transform: uppercase; letter-spacing: .08em;
  color: var(--ink-muted);
  margin-bottom: .2rem;
}
.readout-card .rc-value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 1.1rem; font-weight: 500;
  color: var(--ink);
}

/* ===== PROSE ===== */
.prose { max-width: 680px; margin-bottom: 1rem; }
.prose p { margin-bottom: .8rem; color: var(--ink-soft); }

/* ===== RESPONSIVE ===== */
@media (max-width: 600px) {
  .chapter { padding-left: 1rem; padding-right: 1rem; }
  .cover-title { font-size: 1.8rem; }
  .chapter h2 { font-size: 1.6rem; }
  .slider-group { flex-direction: column; }
  .chart-grid { grid-template-columns: 1fr; }
  .readout-cards { flex-direction: column; }
}
