/* ==========================================================================
   THE VISUAL BRAIN — 3Blue1Brown-Inspired Interactive Neuroscience Book
   Pure static CSS, zero dependencies, dark luminous canvas aesthetic
   ========================================================================== */

:root {
  --bg-deep: #090c14;
  --bg-surface: #111626;
  --bg-elevated: #171e33;
  --bg-canvas: #070910;
  --border-subtle: rgba(130, 165, 220, 0.14);
  --border-glow: rgba(88, 196, 221, 0.35);

  --text-primary: #eef2fa;
  --text-secondary: #a8b5ce;
  --text-muted: #6e7d9b;

  /* 3Blue1Brown-inspired luminous palette */
  --cyan: #58c4dd;
  --cyan-soft: rgba(88, 196, 221, 0.16);
  --gold: #f4c542;
  --gold-soft: rgba(244, 197, 66, 0.16);
  --coral: #ff6b6b;
  --coral-soft: rgba(255, 107, 107, 0.16);
  --emerald: #4ade80;
  --emerald-soft: rgba(74, 222, 128, 0.16);
  --violet: #a78bfa;
  --violet-soft: rgba(167, 139, 250, 0.16);

  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-serif: 'Newsreader', 'Georgia', 'Times New Roman', serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', ui-monospace, monospace;

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --max-reading: 820px;
  --max-wide: 1140px;
}

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

html {
  scroll-behavior: smooth;
  background-color: var(--bg-deep);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 17px;
  line-height: 1.72;
  -webkit-font-smoothing: antialiased;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(ellipse 80% 50% at 50% -10%, rgba(88, 196, 221, 0.08), transparent 60%),
    radial-gradient(ellipse 60% 40% at 85% 20%, rgba(167, 139, 250, 0.06), transparent 60%),
    var(--bg-deep);
}

a {
  color: var(--cyan);
  text-decoration: none;
  transition: color 0.2s ease;
}
a:hover {
  color: #8be0f5;
}

/* ---------- Top Navigation Bar ---------- */
.site-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.8rem 1.5rem;
  background: rgba(9, 12, 20, 0.82);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border-subtle);
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  font-weight: 700;
  font-size: 1rem;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.nav-brand-dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 0 12px var(--cyan);
}

.nav-chapter-pill {
  font-size: 0.82rem;
  color: var(--text-secondary);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  padding: 0.3rem 0.75rem;
  border-radius: 999px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 45vw;
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.nav-btn {
  background: var(--bg-surface);
  color: var(--text-primary);
  border: 1px solid var(--border-subtle);
  border-radius: 999px;
  padding: 0.38rem 0.85rem;
  font-size: 0.84rem;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}
.nav-btn:hover {
  border-color: var(--border-glow);
  background: var(--bg-elevated);
  color: var(--cyan);
}

/* ---------- Slide-out Chapter Drawer ---------- */
.chapter-drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(3, 5, 10, 0.65);
  backdrop-filter: blur(4px);
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease;
}
.chapter-drawer-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.chapter-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(370px, 90vw);
  background: var(--bg-surface);
  border-left: 1px solid var(--border-subtle);
  z-index: 201;
  transform: translateX(100%);
  transition: transform 0.25s cubic-bezier(0.22, 1, 0.36, 1);
  display: flex;
  flex-direction: column;
}
.chapter-drawer.open {
  transform: translateX(0);
}

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.1rem 1.25rem;
  border-bottom: 1px solid var(--border-subtle);
}
.drawer-header h3 {
  margin: 0;
  font-size: 1rem;
  letter-spacing: 0.02em;
}
.drawer-list {
  overflow-y: auto;
  padding: 0.75rem;
  flex: 1;
}
.drawer-item {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 0.65rem 0.8rem;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  margin-bottom: 0.25rem;
  transition: all 0.18s ease;
  font-size: 0.9rem;
}
.drawer-item:hover {
  background: var(--bg-elevated);
  color: var(--text-primary);
}
.drawer-item.active {
  background: var(--cyan-soft);
  color: var(--cyan);
  font-weight: 600;
}
.drawer-num {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  opacity: 0.75;
  width: 24px;
  flex-shrink: 0;
}
.drawer-check {
  margin-left: auto;
  color: var(--emerald);
  font-size: 0.85rem;
}

/* ---------- Reading Progress Bar ---------- */
.reading-progress-track {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  z-index: 120;
  background: transparent;
}
.reading-progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--cyan), var(--violet), var(--gold));
  box-shadow: 0 0 10px var(--cyan);
  transition: width 0.08s linear;
}

/* ---------- Chapter Article Layout ---------- */
.chapter-container {
  max-width: var(--max-reading);
  margin: 0 auto;
  padding: 3rem 1.4rem 5rem;
}

.chapter-header {
  margin-bottom: 2.8rem;
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 2rem;
}

.chapter-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--cyan);
  margin-bottom: 0.8rem;
}

.chapter-title {
  font-family: var(--font-serif);
  font-size: clamp(2.1rem, 5vw, 3.2rem);
  line-height: 1.14;
  margin: 0 0 0.85rem;
  letter-spacing: -0.02em;
  color: #ffffff;
}

.chapter-subtitle {
  font-size: 1.15rem;
  color: var(--text-secondary);
  margin: 0;
  line-height: 1.55;
}

.chapter-container h2 {
  font-family: var(--font-serif);
  font-size: 1.75rem;
  color: #ffffff;
  margin: 3rem 0 1rem;
  letter-spacing: -0.015em;
  line-height: 1.25;
}

.chapter-container h3 {
  font-size: 1.15rem;
  color: var(--cyan);
  margin: 2rem 0 0.65rem;
}

.chapter-container p {
  margin: 0 0 1.25rem;
  color: var(--text-primary);
}

.chapter-container strong {
  color: #ffffff;
  font-weight: 600;
}

.highlight-cyan { color: var(--cyan); font-weight: 600; }
.highlight-gold { color: var(--gold); font-weight: 600; }
.highlight-coral { color: var(--coral); font-weight: 600; }
.highlight-emerald { color: var(--emerald); font-weight: 600; }
.highlight-violet { color: var(--violet); font-weight: 600; }

/* ---------- Interactive Canvas Stage (3B1B Style) ---------- */
.interactive-stage {
  margin: 2.2rem 0;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
}

.stage-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.6rem;
  padding: 0.9rem 1.25rem;
  background: rgba(255, 255, 255, 0.02);
  border-bottom: 1px solid var(--border-subtle);
}

.stage-title {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-weight: 600;
  font-size: 0.95rem;
  color: #ffffff;
}

.stage-badge {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  background: var(--cyan-soft);
  color: var(--cyan);
}

.canvas-wrap {
  position: relative;
  width: 100%;
  background: var(--bg-canvas);
  border-bottom: 1px solid var(--border-subtle);
}

.canvas-wrap canvas {
  display: block;
  width: 100%;
  height: auto;
  cursor: pointer;
}

.stage-controls {
  padding: 1.1rem 1.25rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem 1.4rem;
}

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

.control-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.83rem;
  color: var(--text-secondary);
}

.control-value {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--gold);
}

/* Custom Range Sliders */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  background: rgba(168, 181, 206, 0.2);
  border-radius: 999px;
  outline: none;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  background: var(--cyan);
  border: 2px solid #090c14;
  box-shadow: 0 0 10px rgba(88, 196, 221, 0.6);
  cursor: pointer;
  transition: transform 0.15s ease;
}

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

/* Action Buttons */
.btn {
  background: var(--bg-elevated);
  color: var(--text-primary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 0.52rem 1rem;
  font-size: 0.88rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.18s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
}
.btn:hover {
  border-color: var(--cyan);
  color: var(--cyan);
  transform: translateY(-1px);
}
.btn:active {
  transform: translateY(0);
}
.btn-primary {
  background: var(--cyan);
  color: #061018;
  border-color: var(--cyan);
  box-shadow: 0 0 18px rgba(88, 196, 221, 0.3);
}
.btn-primary:hover {
  background: #7cd5ea;
  color: #061018;
}
.btn-gold {
  background: var(--gold-soft);
  color: var(--gold);
  border-color: rgba(244, 197, 66, 0.4);
}
.btn-gold:hover {
  background: rgba(244, 197, 66, 0.26);
  color: #ffe07d;
}
.btn-coral {
  background: var(--coral-soft);
  color: var(--coral);
  border-color: rgba(255, 107, 107, 0.4);
}
.btn-coral:hover {
  background: rgba(255, 107, 107, 0.26);
  color: #ff9494;
}
.btn.active {
  background: var(--cyan-soft);
  border-color: var(--cyan);
  color: var(--cyan);
}

.stage-caption {
  padding: 0 1.25rem 1.1rem;
  font-size: 0.88rem;
  color: var(--text-secondary);
  line-height: 1.55;
}

/* ---------- Callout Boxes ---------- */
.callout {
  margin: 1.8rem 0;
  padding: 1.15rem 1.35rem;
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  border-left: 4px solid var(--cyan);
}
.callout.gold { border-left-color: var(--gold); background: rgba(244, 197, 66, 0.06); }
.callout.violet { border-left-color: var(--violet); background: rgba(167, 139, 250, 0.06); }
.callout.emerald { border-left-color: var(--emerald); background: rgba(74, 222, 128, 0.06); }

.callout-title {
  font-weight: 700;
  font-size: 0.92rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 0.4rem;
  color: var(--cyan);
}
.callout.gold .callout-title { color: var(--gold); }
.callout.violet .callout-title { color: var(--violet); }
.callout.emerald .callout-title { color: var(--emerald); }

.callout p:last-child {
  margin-bottom: 0;
}

/* Relationship Comparison Strip */
.ratio-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 0.9rem;
  margin: 1.8rem 0;
}

.ratio-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1rem 1.15rem;
}
.ratio-card-label {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}
.ratio-card-value {
  font-family: var(--font-serif);
  font-size: 1.35rem;
  color: var(--gold);
  margin-bottom: 0.25rem;
}
.ratio-card-desc {
  font-size: 0.86rem;
  color: var(--text-secondary);
  line-height: 1.45;
}

/* Subtle "Real-World Name" Pill (Optional Jargon Reveal) */
.name-note {
  margin: 1.6rem 0;
  padding: 0.85rem 1.1rem;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.025);
  border: 1px dashed var(--border-subtle);
  font-size: 0.88rem;
  color: var(--text-secondary);
}
.name-note strong {
  color: var(--violet);
}

/* ---------- Chapter Footer Navigation ---------- */
.chapter-footer {
  margin-top: 4rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.complete-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  background: var(--bg-surface);
  padding: 1.1rem 1.35rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
}

.nav-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.nav-card {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 1.1rem 1.25rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  transition: all 0.2s ease;
}
.nav-card:hover {
  border-color: var(--cyan);
  background: var(--bg-elevated);
  transform: translateY(-2px);
}
.nav-card.next {
  text-align: right;
}
.nav-card-dir {
  font-size: 0.78rem;
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}
.nav-card-title {
  font-weight: 600;
  font-size: 1rem;
  color: #ffffff;
}

/* ---------- Homepage Specific Styles ---------- */
.hero-section {
  position: relative;
  overflow: hidden;
  border-bottom: 1px solid var(--border-subtle);
}

.hero-canvas-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0.55;
  pointer-events: none;
}

.hero-inner {
  position: relative;
  z-index: 2;
  max-width: var(--max-wide);
  margin: 0 auto;
  padding: 5.5rem 1.5rem 4.5rem;
  text-align: center;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.9rem;
  border-radius: 999px;
  background: var(--cyan-soft);
  border: 1px solid var(--border-glow);
  color: var(--cyan);
  font-size: 0.82rem;
  font-weight: 600;
  margin-bottom: 1.4rem;
}

.hero-title {
  font-family: var(--font-serif);
  font-size: clamp(2.6rem, 6.5vw, 4.4rem);
  line-height: 1.08;
  margin: 0 auto 1.2rem;
  max-width: 820px;
  color: #ffffff;
  letter-spacing: -0.025em;
}

.hero-subtitle {
  font-size: clamp(1.05rem, 2vw, 1.25rem);
  color: var(--text-secondary);
  max-width: 650px;
  margin: 0 auto 2rem;
  line-height: 1.6;
}

.hero-cta-row {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.9rem;
  margin-bottom: 2.5rem;
}

.course-progress-banner {
  display: inline-flex;
  align-items: center;
  gap: 1rem;
  padding: 0.65rem 1.2rem;
  background: rgba(17, 22, 38, 0.85);
  border: 1px solid var(--border-subtle);
  border-radius: 999px;
  font-size: 0.88rem;
  color: var(--text-secondary);
}

.progress-pill-bar {
  width: 120px;
  height: 7px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 999px;
  overflow: hidden;
}
.progress-pill-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--cyan), var(--emerald));
  width: 0%;
  transition: width 0.35s ease;
}

.home-section {
  max-width: var(--max-wide);
  margin: 0 auto;
  padding: 3.5rem 1.5rem;
}

.section-heading {
  font-family: var(--font-serif);
  font-size: 2rem;
  margin: 0 0 0.5rem;
  color: #ffffff;
}
.section-sub {
  color: var(--text-secondary);
  margin: 0 0 2rem;
}

.chapter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
  gap: 1.25rem;
}

.chapter-card {
  position: relative;
  display: flex;
  flex-direction: column;
  padding: 1.45rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  transition: all 0.22s ease;
  color: inherit;
}
.chapter-card:hover {
  border-color: var(--border-glow);
  transform: translateY(-4px);
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.4);
}
.chapter-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.8rem;
}
.chapter-card-num {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--cyan);
  background: var(--cyan-soft);
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
}
.chapter-card-status {
  font-size: 0.78rem;
  color: var(--emerald);
  font-weight: 600;
}
.chapter-card h3 {
  margin: 0 0 0.45rem;
  font-family: var(--font-serif);
  font-size: 1.35rem;
  color: #ffffff;
}
.chapter-card p {
  margin: 0 0 1.1rem;
  font-size: 0.92rem;
  color: var(--text-secondary);
  line-height: 1.55;
  flex: 1;
}
.chapter-card-toy {
  font-size: 0.8rem;
  color: var(--gold);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.principles-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.1rem;
  margin-top: 1.5rem;
}

.principle-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1.3rem;
}
.principle-card h4 {
  margin: 0 0 0.45rem;
  color: var(--cyan);
  font-size: 1rem;
}
.principle-card p {
  margin: 0;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.site-footer {
  text-align: center;
  padding: 2.5rem 1.5rem;
  border-top: 1px solid var(--border-subtle);
  color: var(--text-muted);
  font-size: 0.88rem;
}

@media (max-width: 640px) {
  .nav-cards {
    grid-template-columns: 1fr;
  }
  .nav-card.next {
    text-align: left;
  }
  .site-nav {
    padding: 0.7rem 1rem;
  }
  .chapter-container {
    padding: 2rem 1.05rem 4rem;
  }
}
