/* ============================================================
   CHAPTER PAGE — Seeing Theory inspired (light blue default)
   ============================================================ */

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


:root {
  --bg: #d8e9f3;
  --bg-card: #ffffff;
  --text: #1a2436;
  --text-soft: #4a5670;
  --text-mute: #8090a8;
  --accent: #2c7cb8;
  --accent-soft: #5a9dd4;
  --rule: rgba(26, 36, 54, 0.10);
  --shadow: 0 2px 12px rgba(26, 36, 54, 0.06);
}

body.theme-dark {
  --bg: #1a1d2e;
  --bg-card: #232639;
  --text: #e8e8ef;
  --text-soft: #b8bacc;
  --text-mute: #6b6d82;
  --accent: #85B7EB;
  --accent-soft: #5a9dd4;
  --rule: rgba(255, 255, 255, 0.10);
  --shadow: 0 2px 12px rgba(0, 0, 0, 0.25);
}

html, body { height: auto; }
body.chapter-page {
  background: var(--bg);
  color: var(--text);
  font-family: "Lato", -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
  overflow-x: hidden;
  transition: background 0.3s ease, color 0.3s ease;
  min-height: 100vh;
}

/* ============================================================
   PROGRESS BAR — top of page, grows on scroll
   ============================================================ */
.ch-progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 7px;
  width: 0%;
  background: var(--accent);
  z-index: 200;
  transition: width 0.1s ease-out;
}

/* ============================================================
   TOP BAR — menu icon + breadcrumb (sticky at top)
   ============================================================ */
.ch-topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 24px 40px;
  max-width: 1400px;
  margin: 0 auto;
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--bg);
  transition: background 0.3s ease;
}
.ch-menu-btn {
  background: none;
  border: none;
  color: var(--text-soft);
  cursor: pointer;
  font-size: 22px;
  display: flex;
  align-items: center;
  padding: 6px;
  border-radius: 6px;
  transition: background 0.2s, color 0.2s;
}
.ch-menu-btn:hover {
  background: rgba(26, 36, 54, 0.06);
  color: var(--text);
}
body.theme-dark .ch-menu-btn:hover { background: rgba(255, 255, 255, 0.06); }
.ch-breadcrumb {
  font-size: 14px;
  color: var(--text-soft);
}
.ch-breadcrumb a {
  color: var(--text-soft);
  text-decoration: none;
  transition: color 0.2s;
}
.ch-breadcrumb a:hover { color: var(--text); }
.ch-sep { margin: 0 8px; color: var(--text-mute); }
.ch-crumb-context { transition: color 0.3s ease; }

/* ============================================================
   INTRO SECTION — split layout: title left, sub-cards right
   ============================================================ */
.ch-intro {
  min-height: calc(100vh - 80px);
  display: flex;
  align-items: center;
  padding: 0 40px 60px;
  max-width: 1400px;
  margin: 0 auto;
}
.ch-intro-grid {
  display: grid;
  grid-template-columns: 1fr 1.3fr;
  gap: 80px;
  width: 100%;
  align-items: center;
}
.ch-intro-left {
  max-width: 520px;
}
.ch-intro-right {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.ch-sub-card {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 22px 28px;
  background: var(--bg-card);
  border-radius: 12px;
  box-shadow: var(--shadow);
  text-decoration: none;
  color: var(--text);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.ch-sub-card:hover {
  transform: translateX(-4px);
  box-shadow: 0 6px 20px rgba(26, 36, 54, 0.10);
}
body.theme-dark .ch-sub-card:hover {
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
}
.ch-sub-icon {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: #1a2436;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 24px;
  flex-shrink: 0;
}
body.theme-dark .ch-sub-icon {
  background: #0f1220;
}
.ch-sub-name {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
}
.ch-eyebrow {
  font-size: 13px;
  color: var(--text-mute);
  letter-spacing: 1.2px;
  margin-bottom: 18px;
  text-transform: uppercase;
}
.ch-title {
  font-family: "Lato", sans-serif;
  font-size: 56px;
  font-weight: 700;
  line-height: 1.1;
  color: var(--text);
  margin-bottom: 28px;
  letter-spacing: -0.8px;
}
.ch-lede {
  font-size: 19px;
  line-height: 1.6;
  color: var(--text-soft);
  margin-bottom: 60px;
  max-width: 600px;
}
.ch-scroll-hint {
  font-size: 13px;
  color: var(--text-mute);
  letter-spacing: 0.5px;
  display: flex;
  align-items: center;
  gap: 8px;
  animation: bob 2s ease-in-out infinite;
}
.ch-scroll-hint i { font-size: 16px; }
@keyframes bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(4px); }
}

/* ============================================================
   SCROLLY LAYOUT — text left, viz sticky right
   ============================================================ */
.scrolly {
  display: grid;
  grid-template-columns: 1fr 1.1fr;
  gap: 80px;
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 40px 80px;
  align-items: start;
}

.scrolly-text {
  padding: 40px 0;
}

.scrolly-viz {
  position: sticky;
  top: 90px;
}
.viz-frame {
  position: relative;
  height: calc(100vh - 130px);
  border-radius: 8px;
  background: var(--bg-card);
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: background 0.3s ease, box-shadow 0.3s ease;
}

/* ============================================================
   STEPS — one per subsection
   ============================================================ */
.step {
  max-width: 560px;
  margin-bottom: 30vh;
  scroll-margin-top: 90px;
}
.step:last-child { margin-bottom: 0; }
.step-num {
  font-size: 13px;
  color: var(--accent);
  letter-spacing: 1.2px;
  margin-bottom: 10px;
  font-weight: 700;
}
.step-title {
  font-family: "Lato", sans-serif;
  font-size: 36px;
  font-weight: 700;
  line-height: 1.2;
  color: var(--text);
  margin-bottom: 28px;
  letter-spacing: -0.4px;
}
.step-h3 {
  font-family: "Lato", sans-serif;
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  margin-top: 36px;
  margin-bottom: 16px;
}
.step p {
  font-size: 17px;
  line-height: 1.7;
  color: var(--text);
  margin-bottom: 18px;
}
.step strong { font-weight: 700; color: var(--text); }
.step em {
  font-style: italic;
  color: var(--text-soft);
}

/* ============================================================
   VIZ PANELS — placeholders for now
   ============================================================ */
.viz-panel {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.5s ease;
  pointer-events: none;
}
.viz-panel.active {
  opacity: 1;
  pointer-events: auto;
}
.viz-placeholder { text-align: center; padding: 40px; }
.viz-tag {
  font-size: 12px;
  color: var(--text-mute);
  letter-spacing: 1.5px;
  margin-bottom: 14px;
  text-transform: uppercase;
}
.viz-headline {
  font-family: "Lato", sans-serif;
  font-size: 24px;
  color: var(--text);
  margin-bottom: 24px;
  font-weight: 700;
}
.viz-note {
  font-size: 12px;
  color: var(--text-mute);
  padding: 6px 12px;
  border: 1px dashed var(--rule);
  border-radius: 14px;
  display: inline-block;
}

/* ============================================================
   END SECTION (recap)
   ============================================================ */
.step-end { margin-bottom: 20vh; }
.ch-recap {
  list-style: none;
  padding: 0;
  margin-bottom: 40px;
}
.ch-recap li {
  font-size: 17px;
  line-height: 1.6;
  color: var(--text);
  padding: 14px 0 14px 28px;
  border-bottom: 0.5px solid var(--rule);
  position: relative;
}
.ch-recap li:before {
  content: "→";
  position: absolute;
  left: 0;
  color: var(--accent);
  font-weight: 700;
}
.ch-recap li:last-child { border-bottom: none; }
.ch-end-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 30px;
  padding-top: 24px;
  border-top: 0.5px solid var(--rule);
}
.ch-end-link {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-soft);
  text-decoration: none;
  font-size: 14px;
  padding: 10px 16px;
  border-radius: 22px;
  transition: all 0.2s;
}
.ch-end-link:hover {
  background: rgba(26, 36, 54, 0.06);
  color: var(--text);
}
body.theme-dark .ch-end-link:hover { background: rgba(255, 255, 255, 0.06); }
.ch-end-link.next { color: var(--accent); font-weight: 600; }

/* ============================================================
   THEME TOGGLE (floating bottom right)
   ============================================================ */
.ch-theme-toggle {
  position: fixed;
  bottom: 30px;
  right: 30px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--bg-card);
  border: 0.5px solid var(--rule);
  color: var(--text-soft);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  box-shadow: var(--shadow);
  z-index: 100;
  transition: all 0.2s;
}
.ch-theme-toggle:hover {
  color: var(--text);
  transform: scale(1.08);
}



/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 900px) {
  .scrolly {
    grid-template-columns: 1fr;
    gap: 30px;
    padding: 0 24px 60px;
  }
  .scrolly-viz {
    position: sticky;
    top: 60px;
    order: -1;
  }
  .viz-frame { height: 320px; }
  .step { max-width: none; margin-bottom: 60px; }
  .ch-title { font-size: 36px; }
  .ch-intro { padding: 40px 24px; min-height: auto; }
  .ch-topbar { padding: 18px 24px; }
  .ch-theme-toggle { bottom: 20px; right: 20px; width: 40px; height: 40px; }
  .ch-intro-grid { grid-template-columns: 1fr; gap: 40px; }
  .ch-sub-card { padding: 18px 22px; }
}


