/* ============================================================
   Nested Learning — Interactive Companion Site
   ============================================================ */

: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;
  --max-w: 920px;
  --nav-h: 56px;
}

/* ---------- Reset & Base ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-be-behavior: smooth; font-size: 17px; }
body {
  font-family: 'Newsreader', Georgia, serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.72;
  -webkit-font-smoothing: antialiased;
}

/* ---------- Fixed Nav ---------- */
.nav-bar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  height: var(--nav-h);
  background: rgba(251,250,247,.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--rule);
  display: flex; align-items: center;
}
.nav-inner {
  max-width: var(--max-w);
  width: 100%; margin: 0 auto; padding: 0 1.5rem;
  display: flex; align-items: center; gap: 1rem;
}
.nav-paper {
  font-family: 'Inter', sans-serif;
  font-weight: 600; font-size: .82rem;
  color: var(--upstream);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.nav-sub {
  font-family: 'Inter', sans-serif;
  font-size: .72rem; color: var(--ink-muted); margin-left: .6rem;
}
.nav-progress {
  flex: 1; height: 3px; background: var(--rule); border-radius: 2px;
  min-width: 60px;
}
.nav-progress-fill {
  height: 100%; width: 0; background: var(--accent); border-radius: 2px;
  transition: width .15s;
}

/* ---------- Chapter Rail (left) ---------- */
.chapter-rail {
  position: fixed; left: 0; top: 50%; transform: translateY(-50%);
  z-index: 90; padding: 0 0 0 1rem;
}
.chapter-rail ol {
  list-style: none; display: flex; flex-direction: column; gap: 10px;
}
.chapter-rail li {
  display: flex; align-items: center; gap: 8px; cursor: pointer;
}
.chapter-rail .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--rule); transition: background .2s;
}
.chapter-rail li.active .dot { background: var(--accent); }
.chapter-rail .label {
  font-family: 'Inter', sans-serif;
  font-size: .68rem; color: var(--ink-muted);
  max-width: 0; overflow: hidden; white-space: nowrap;
  transition: max-width .25s, opacity .25s; opacity: 0;
}
.chapter-rail li:hover .label,
.chapter-rail li.active .label { max-width: 180px; opacity: 1; }

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

/* ---------- Chapter Sections ---------- */
.chapter {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 7rem 1.5rem 3rem;
}
.chapter + .chapter { border-top: 1px solid var(--rule); }

.chapter-num {
  font-family: 'Inter', sans-serif;
  font-size: .72rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .12em;
  color: var(--accent); margin-bottom: .5rem;
}
.chapter h2 {
  font-size: 2.1rem; font-weight: 700; line-height: 1.2;
  margin-bottom: 1rem; color: var(--ink);
}
.lede {
  font-size: 1.15rem; line-height: 1.65;
  color: var(--ink-soft); margin-bottom: 1.5rem;
  max-width: 780px;
}

/* ---------- Plain English Card ---------- */
.plain-card {
  background: var(--bg);
  border-left: 4px solid var(--gold);
  padding: 1.3rem 1.5rem;
  margin: 1.8rem 0;
  border-radius: 0 6px 6px 0;
}
.plain-label {
  font-family: 'Inter', sans-serif;
  font-size: .72rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .1em;
  color: var(--gold); margin-bottom: .6rem;
}
.plain-card p {
  font-size: .95rem; line-height: 1.65; color: var(--ink-soft);
  margin-bottom: .6rem;
}
.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: 2rem 0;
  padding: 1.5rem;
  background: var(--bg-elevated);
  border: 1px solid var(--rule);
  border-radius: 8px;
}
.interactive-section .hint {
  font-family: 'Inter', sans-serif;
  font-size: .72rem; color: var(--ink-muted);
  margin-top: .5rem; font-style: italic;
}
.slider-row {
  display: flex; flex-wrap: wrap; gap: 1.2rem;
  margin-bottom: 1rem; align-items: center;
}
.slider-group {
  flex: 1 1 200px; min-width: 180px;
}
.slider-group label {
  display: block;
  font-family: 'Inter', sans-serif;
  font-size: .78rem; font-weight: 500;
  color: var(--ink-soft); margin-bottom: .25rem;
}
.slider-group input[type="range"] {
  width: 100%; accent-color: var(--accent);
}
.slider-val {
  font-family: 'JetBrains Mono', monospace;
  font-size: .75rem; color: var(--ink-muted);
}
.chart-grid {
  display: grid; gap: 1rem;
}
.chart-grid.cols-2 { grid-template-columns: 1fr 1fr; }
.chart-grid.cols-1 { grid-template-columns: 1fr; }
.chart-cell { min-height: 320px; }

@media (max-width: 700px) {
  .chart-grid.cols-2 { grid-template-columns: 1fr; }
}

/* ---------- Readout Cards ---------- */
.readout-row {
  display: flex; flex-wrap: wrap; gap: .8rem;
  margin-top: .8rem;
}
.readout-card {
  background: var(--bg);
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: .6rem 1rem;
  text-align: center; min-width: 100px;
}
.readout-card .rc-label {
  font-family: 'Inter', sans-serif;
  font-size: .65rem; text-transform: uppercase;
  letter-spacing: .08em; color: var(--ink-muted);
}
.readout-card .rc-value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 1.15rem; font-weight: 600;
  color: var(--upstream);
}

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

/* ---------- Chapter Foot Link ---------- */
.chapter-foot {
  display: inline-block;
  font-family: 'Inter', sans-serif;
  font-size: .82rem; font-weight: 600;
  color: var(--upstream); text-decoration: none;
  margin-top: 1.5rem;
  transition: color .2s, transform .2s;
}
.chapter-foot .arrow {
  display: inline-block; transition: transform .2s;
}
.chapter-foot:hover { color: var(--accent); }
.chapter-foot:hover .arrow { transform: translateX(4px); }

/* ---------- Cover ---------- */
.cover { text-align: center; padding-top: 5rem; }
.cover-inner { max-width: 740px; margin: 0 auto; }
.cover-eyebrow {
  font-family: 'Inter', sans-serif;
  font-size: .72rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .14em;
  color: var(--accent); margin-bottom: .8rem;
}
.cover-title {
  font-size: 2.8rem; font-weight: 700; line-height: 1.18;
  margin-bottom: .5rem;
}
.cover-title em { color: var(--accent); }
.cover-subtitle {
  font-size: 1.1rem; color: var(--ink-soft);
  font-style: italic; margin-bottom: 1rem;
}
.cover-byline {
  font-family: 'Inter', sans-serif;
  font-size: .82rem; color: var(--ink-soft);
  line-height: 1.5; margin-bottom: 2rem;
}
.cover-byline .muted { color: var(--ink-muted); }

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

/* Pillar Cards */
.cover-pillars {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 1rem; max-width: 740px; margin: 2rem auto 0;
  text-align: left;
}
.pillar {
  background: var(--bg-elevated);
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 1rem 1.1rem;
}
.pillar-num {
  font-family: 'Inter', sans-serif;
  font-size: .68rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .1em;
  color: var(--accent); margin-bottom: .3rem;
}
.pillar-title {
  font-family: 'Inter', sans-serif;
  font-weight: 600; font-size: .85rem;
  color: var(--upstream); margin-bottom: .35rem;
}
.pillar-text {
  font-size: .82rem; line-height: 1.55;
  color: var(--ink-soft);
}

@media (max-width: 640px) {
  .cover-pillars { grid-template-columns: 1fr; }
  .cover-title { font-size: 2rem; }
}

/* ---------- Strategy Cards ---------- */
.strat-cards {
  display: flex; flex-wrap: wrap; gap: .6rem;
  margin-bottom: 1rem;
}
.strat-card {
  font-family: 'Inter', sans-serif;
  font-size: .78rem; font-weight: 500;
  padding: .45rem .9rem;
  border: 1px solid var(--rule);
  border-radius: 20px;
  cursor: pointer;
  background: var(--bg);
  color: var(--ink-soft);
  transition: all .2s;
}
.strat-card:hover { border-color: var(--midmarket); }
.strat-card.selected {
  background: var(--upstream);
  color: #fff; border-color: var(--upstream);
}

/* ---------- Button ---------- */
.btn-toggle {
  font-family: 'Inter', sans-serif;
  font-size: .78rem; font-weight: 600;
  padding: .5rem 1.1rem;
  border: 1px solid var(--accent);
  border-radius: 4px;
  background: transparent;
  color: var(--accent);
  cursor: pointer;
  transition: all .2s;
}
.btn-toggle:hover, .btn-toggle.active {
  background: var(--accent); color: #fff;
}

/* ---------- Prose ---------- */
.prose p {
  margin-bottom: .8rem;
  color: var(--ink-soft);
}
.prose strong { color: var(--ink); font-weight: 600; }
.prose em { font-style: italic; }

/* ---------- Utility ---------- */
.mt-2 { margin-top: 2rem; }
.mb-2 { margin-bottom: 2rem; }
.text-center { text-align: center; }
.flex-center { display: flex; justify-content: center; gap: .8rem; flex-wrap: wrap; }
