/* ==========================================================================
   Statistics Without Numbers — Modern Editorial Design System
   Warm paper, crisp ink, calm editorial accents, tactile interactive canvases.
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Newsreader:ital,opsz,wght@0,6..72,400;0,6..72,500;0,6..72,600;1,6..72,400&family=Plus+Jakarta+Sans:wght@400;500;600;700&display=swap');

:root {
  /* Paper & Ink */
  --paper: #faf7f2;
  --paper-elevated: #ffffff;
  --paper-tint: #f2ece2;
  --paper-deep: #e7dfd1;
  --ink: #1c1917;
  --ink-soft: #44403c;
  --ink-muted: #78716c;
  --rule: #e4ddd2;
  --rule-strong: #cfc5b6;

  /* Editorial Accents */
  --terracotta: #c2593f;
  --terracotta-soft: rgba(194, 89, 63, 0.14);
  --sage: #3d7a68;
  --sage-soft: rgba(61, 122, 104, 0.14);
  --slate: #3b6998;
  --slate-soft: rgba(59, 105, 152, 0.14);
  --ochre: #c9942a;
  --ochre-soft: rgba(201, 148, 42, 0.16);
  --plum: #7d4e6d;
  --plum-soft: rgba(125, 78, 109, 0.14);

  /* Typography */
  --font-serif: 'Newsreader', Georgia, 'Times New Roman', serif;
  --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

  /* Layout */
  --max-prose: 720px;
  --max-stage: 920px;
  --max-wide: 1120px;
  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --shadow-card: 0 2px 12px rgba(28, 25, 23, 0.05), 0 1px 2px rgba(28, 25, 23, 0.04);
  --shadow-lift: 0 10px 28px rgba(28, 25, 23, 0.08), 0 2px 6px rgba(28, 25, 23, 0.04);
}

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

html {
  scroll-behavior: smooth;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  margin: 0;
  background-color: var(--paper);
  color: var(--ink);
  font-family: var(--font-sans);
  line-height: 1.72;
  min-height: 100vh;
  overflow-x: hidden;
}

/* ---------- Reading Progress Hairline ---------- */
.reading-progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  width: 0%;
  background: linear-gradient(90deg, var(--terracotta), var(--ochre), var(--sage));
  z-index: 200;
  transition: width 0.08s linear;
}

/* ---------- Top Navigation Shell ---------- */
.book-header {
  position: sticky;
  top: 0;
  z-index: 120;
  background: rgba(250, 247, 242, 0.92);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--rule);
}

.book-header-inner {
  max-width: var(--max-wide);
  margin: 0 auto;
  padding: 0.75rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.book-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  text-decoration: none;
  color: var(--ink);
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: 1.08rem;
  letter-spacing: -0.01em;
}

.book-brand-mark {
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.chapter-trail {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.trail-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--rule-strong);
  display: inline-block;
  transition: transform 0.2s ease, background-color 0.2s ease;
  text-decoration: none;
  position: relative;
}

.trail-dot:hover {
  transform: scale(1.45);
  background: var(--ink-soft);
}

.trail-dot.is-current {
  background: var(--terracotta);
  transform: scale(1.4);
  box-shadow: 0 0 0 3px var(--terracotta-soft);
}

.trail-dot.is-visited {
  background: var(--sage);
}

.menu-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  background: var(--paper-elevated);
  border: 1px solid var(--rule-strong);
  border-radius: 999px;
  padding: 0.4rem 0.9rem;
  font-family: var(--font-sans);
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--ink);
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.menu-toggle:hover {
  background: var(--paper-tint);
  border-color: var(--ink-muted);
}

/* ---------- Slide-out Chapter Drawer ---------- */
.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(28, 25, 23, 0.35);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease;
  z-index: 150;
}

.drawer-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.chapter-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(380px, 90vw);
  background: var(--paper);
  border-left: 1px solid var(--rule);
  transform: translateX(100%);
  transition: transform 0.26s cubic-bezier(0.22, 1, 0.36, 1);
  z-index: 160;
  display: flex;
  flex-direction: column;
  box-shadow: -12px 0 36px rgba(28, 25, 23, 0.12);
}

.chapter-drawer.open {
  transform: translateX(0);
}

.drawer-head {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--rule);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.drawer-title {
  font-family: var(--font-serif);
  font-size: 1.2rem;
  font-weight: 600;
  margin: 0;
}

.drawer-close {
  background: transparent;
  border: 1px solid var(--rule-strong);
  border-radius: 50%;
  width: 32px;
  height: 32px;
  cursor: pointer;
  color: var(--ink);
  font-size: 1.1rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.drawer-list {
  list-style: none;
  margin: 0;
  padding: 0.75rem 1rem 2rem;
  overflow-y: auto;
  flex: 1;
}

.drawer-group-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ink-muted);
  font-weight: 700;
  padding: 1rem 0.65rem 0.35rem;
}

.drawer-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0.75rem;
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--ink);
  transition: background 0.15s ease;
}

.drawer-link:hover {
  background: var(--paper-tint);
}

.drawer-link.is-current {
  background: var(--terracotta-soft);
  color: var(--terracotta);
  font-weight: 600;
}

.drawer-swatch {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.drawer-link-text {
  display: flex;
  flex-direction: column;
  line-height: 1.3;
}

.drawer-link-title {
  font-size: 0.93rem;
}

.drawer-link-sub {
  font-size: 0.76rem;
  color: var(--ink-muted);
}

/* ---------- Main Article & Typography ---------- */
.chapter-shell {
  max-width: var(--max-wide);
  margin: 0 auto;
  padding: 3rem 1.5rem 5rem;
}

.chapter-hero {
  max-width: var(--max-prose);
  margin: 0 auto 3rem;
  text-align: left;
}

.chapter-kicker {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--terracotta);
  margin-bottom: 0.9rem;
}

.chapter-kicker-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}

h1, h2, h3, h4 {
  font-family: var(--font-serif);
  color: var(--ink);
  letter-spacing: -0.02em;
  line-height: 1.18;
}

.chapter-hero h1 {
  font-size: clamp(2.25rem, 4.8vw, 3.45rem);
  font-weight: 500;
  margin: 0 0 1.1rem;
}

.chapter-lead {
  font-family: var(--font-serif);
  font-size: clamp(1.18rem, 2vw, 1.38rem);
  line-height: 1.55;
  color: var(--ink-soft);
  margin: 0;
}

.prose {
  max-width: var(--max-prose);
  margin: 0 auto 2.2rem;
}

.prose h2 {
  font-size: clamp(1.55rem, 2.8vw, 2rem);
  font-weight: 500;
  margin: 3rem 0 0.85rem;
}

.prose h3 {
  font-size: 1.28rem;
  font-weight: 600;
  margin: 2rem 0 0.55rem;
}

.prose p {
  font-size: 1.04rem;
  color: var(--ink-soft);
  margin: 0 0 1.2rem;
}

.prose strong {
  color: var(--ink);
  font-weight: 600;
}

.prose em {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 1.06em;
}

/* ---------- Editorial Callouts ---------- */
.principle-card {
  max-width: var(--max-prose);
  margin: 2rem auto;
  background: var(--paper-elevated);
  border: 1px solid var(--rule);
  border-left: 4px solid var(--terracotta);
  border-radius: var(--radius-md);
  padding: 1.35rem 1.5rem;
  box-shadow: var(--shadow-card);
}

.principle-card.sage { border-left-color: var(--sage); }
.principle-card.slate { border-left-color: var(--slate); }
.principle-card.ochre { border-left-color: var(--ochre); }
.principle-card.plum { border-left-color: var(--plum); }

.principle-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ink-muted);
  margin-bottom: 0.4rem;
}

.principle-card p {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 1.16rem;
  line-height: 1.55;
  color: var(--ink);
}

/* ---------- Interactive Stage / Playground ---------- */
.interactive-stage {
  max-width: var(--max-stage);
  margin: 2.4rem auto 2.8rem;
  background: var(--paper-elevated);
  border: 1px solid var(--rule);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}

.stage-header {
  padding: 1.15rem 1.5rem;
  border-bottom: 1px solid var(--rule);
  background: linear-gradient(180deg, #fffdf9, var(--paper));
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.stage-title-group {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.stage-eyebrow {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--sage);
}

.stage-title {
  font-family: var(--font-serif);
  font-size: 1.25rem;
  font-weight: 600;
  margin: 0;
  color: var(--ink);
}

.stage-instruction {
  font-size: 0.85rem;
  color: var(--ink-muted);
  margin: 0;
}

.stage-canvas-wrap {
  padding: 1.25rem 1.5rem 1rem;
  position: relative;
  background: var(--paper-elevated);
}

.stage-canvas-wrap svg,
.stage-canvas-wrap canvas {
  width: 100%;
  display: block;
  user-select: none;
  touch-action: none;
}

.stage-controls {
  padding: 1rem 1.5rem 1.25rem;
  background: var(--paper);
  border-top: 1px solid var(--rule);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem 1.5rem;
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-width: 180px;
  flex: 1 1 200px;
}

.control-label-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.5rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--ink-soft);
}

.control-qual {
  font-weight: 500;
  color: var(--terracotta);
  font-size: 0.78rem;
}

.slider-poles {
  display: flex;
  justify-content: space-between;
  font-size: 0.72rem;
  color: var(--ink-muted);
  margin-top: -0.1rem;
}

/* Custom Editorial Range Slider */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 999px;
  background: var(--paper-deep);
  outline: none;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--ink);
  border: 3px solid var(--paper-elevated);
  box-shadow: 0 1px 5px rgba(28, 25, 23, 0.28);
  transition: transform 0.14s ease, background-color 0.14s ease;
}

input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.15);
  background: var(--terracotta);
}

input[type="range"]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--ink);
  border: 3px solid var(--paper-elevated);
  box-shadow: 0 1px 5px rgba(28, 25, 23, 0.28);
}

/* Buttons & Pill Toggles */
.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  font-family: var(--font-sans);
  font-size: 0.84rem;
  font-weight: 600;
  padding: 0.5rem 1rem;
  border-radius: 999px;
  border: 1px solid var(--rule-strong);
  background: var(--paper-elevated);
  color: var(--ink);
  cursor: pointer;
  transition: all 0.15s ease;
  text-decoration: none;
}

.btn:hover {
  background: var(--paper-tint);
  border-color: var(--ink-muted);
}

.btn.is-active,
.btn-primary {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}

.btn-primary:hover {
  background: var(--terracotta);
  border-color: var(--terracotta);
}

.btn-accent {
  background: var(--terracotta);
  color: #fff;
  border-color: var(--terracotta);
}

.btn-accent:hover {
  background: #a94a33;
  border-color: #a94a33;
}

/* Live Qualitative Readout Strip */
.stage-readout {
  padding: 0.9rem 1.5rem;
  background: var(--paper-tint);
  border-top: 1px solid var(--rule);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1.5rem;
  font-size: 0.9rem;
  color: var(--ink-soft);
}

.readout-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-weight: 600;
  color: var(--ink);
}

.swatch {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

.swatch.terracotta { background: var(--terracotta); }
.swatch.sage { background: var(--sage); }
.swatch.slate { background: var(--slate); }
.swatch.ochre { background: var(--ochre); }
.swatch.plum { background: var(--plum); }
.swatch.ink { background: var(--ink); }

/* ---------- Visual Check / Reflection Prompts ---------- */
.visual-check {
  max-width: var(--max-prose);
  margin: 2.5rem auto;
  background: var(--paper-tint);
  border: 1px solid var(--rule);
  border-radius: var(--radius-md);
  padding: 1.4rem 1.5rem;
}

.visual-check-title {
  font-family: var(--font-serif);
  font-size: 1.15rem;
  font-weight: 600;
  margin: 0 0 0.5rem;
}

.visual-check p {
  margin: 0 0 0.9rem;
  font-size: 0.96rem;
  color: var(--ink-soft);
}

.check-options {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
}

.check-feedback {
  margin-top: 0.85rem;
  font-size: 0.92rem;
  padding: 0.7rem 0.95rem;
  border-radius: var(--radius-sm);
  display: none;
}

.check-feedback.show {
  display: block;
}

.check-feedback.good {
  background: var(--sage-soft);
  color: #245144;
}

.check-feedback.nudge {
  background: var(--ochre-soft);
  color: #6f4e10;
}

/* ---------- Chapter Footer Navigation ---------- */
.chapter-footer {
  max-width: var(--max-stage);
  margin: 4rem auto 0;
  padding-top: 2rem;
  border-top: 1px solid var(--rule);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.footer-nav-card {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 1.2rem 1.35rem;
  background: var(--paper-elevated);
  border: 1px solid var(--rule);
  border-radius: var(--radius-md);
  text-decoration: none;
  color: var(--ink);
  transition: transform 0.16s ease, box-shadow 0.16s ease, border-color 0.16s ease;
}

.footer-nav-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lift);
  border-color: var(--rule-strong);
}

.footer-nav-card.next {
  text-align: right;
  align-items: flex-end;
}

.footer-nav-dir {
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.11em;
  color: var(--ink-muted);
}

.footer-nav-title {
  font-family: var(--font-serif);
  font-size: 1.2rem;
  font-weight: 600;
}

.footer-nav-sub {
  font-size: 0.84rem;
  color: var(--ink-muted);
}

/* ---------- Landing Page Specific ---------- */
.home-hero {
  max-width: var(--max-wide);
  margin: 0 auto;
  padding: 4rem 1.5rem 2.5rem;
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  gap: 3rem;
  align-items: center;
}

.home-title {
  font-size: clamp(2.6rem, 5.4vw, 4.1rem);
  font-weight: 500;
  margin: 0 0 1.2rem;
  line-height: 1.08;
}

.home-subtitle {
  font-family: var(--font-serif);
  font-size: clamp(1.18rem, 2vw, 1.42rem);
  color: var(--ink-soft);
  line-height: 1.55;
  margin: 0 0 1.8rem;
}

.home-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-bottom: 2rem;
}

.home-pill {
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.35rem 0.8rem;
  border-radius: 999px;
  background: var(--paper-tint);
  border: 1px solid var(--rule);
  color: var(--ink-soft);
}

.toc-section {
  max-width: var(--max-wide);
  margin: 1rem auto 5rem;
  padding: 0 1.5rem;
}

.toc-part {
  margin-top: 2.75rem;
}

.toc-part-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  border-bottom: 1px solid var(--rule);
  padding-bottom: 0.65rem;
  margin-bottom: 1.35rem;
}

.toc-part-title {
  font-family: var(--font-serif);
  font-size: 1.5rem;
  font-weight: 500;
  margin: 0;
}

.toc-part-theme {
  font-size: 0.82rem;
  color: var(--ink-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 600;
}

.toc-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.25rem;
}

.toc-card {
  display: flex;
  flex-direction: column;
  background: var(--paper-elevated);
  border: 1px solid var(--rule);
  border-radius: var(--radius-md);
  padding: 1.4rem;
  text-decoration: none;
  color: var(--ink);
  box-shadow: var(--shadow-card);
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.toc-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lift);
  border-color: var(--rule-strong);
}

.toc-card-glyph {
  width: 100%;
  height: 76px;
  margin-bottom: 1rem;
  border-radius: var(--radius-sm);
  background: var(--paper);
  border: 1px solid var(--rule);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.toc-card-title {
  font-family: var(--font-serif);
  font-size: 1.28rem;
  font-weight: 600;
  margin: 0 0 0.4rem;
}

.toc-card-desc {
  font-size: 0.9rem;
  color: var(--ink-soft);
  margin: 0;
  line-height: 1.55;
  flex: 1;
}

.toc-card-foot {
  margin-top: 1rem;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--terracotta);
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

/* ---------- Site Footer ---------- */
.site-colophon {
  max-width: var(--max-wide);
  margin: 3rem auto 0;
  padding: 2rem 1.5rem 3.5rem;
  border-top: 1px solid var(--rule);
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 1rem;
  font-size: 0.85rem;
  color: var(--ink-muted);
}

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .home-hero {
    grid-template-columns: 1fr;
    padding-top: 2.5rem;
  }
  .toc-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 640px) {
  .chapter-trail {
    display: none;
  }
  .toc-grid {
    grid-template-columns: 1fr;
  }
  .chapter-footer {
    grid-template-columns: 1fr;
  }
  .footer-nav-card.next {
    text-align: left;
    align-items: flex-start;
  }
  .stage-canvas-wrap,
  .stage-header,
  .stage-controls,
  .stage-readout {
    padding-left: 1rem;
    padding-right: 1rem;
  }
}
