/* ==========================================================================
   Seeing Language: A Visual Guide to Large Language Models
   3Blue1Brown-Inspired Dark Visual Design System
   ========================================================================== */

:root {
  --bg-deep: #090c12;
  --bg-page: #0d111a;
  --bg-card: #131926;
  --bg-elevated: #1a2234;
  --bg-stage: #080b10;
  --border-subtle: rgba(148, 163, 184, 0.14);
  --border-accent: rgba(88, 196, 221, 0.35);

  --text-primary: #edf2f7;
  --text-secondary: #a0aec0;
  --text-muted: #64748b;

  /* 3Blue1Brown-inspired luminous palette */
  --cyan: #58c4dd;
  --cyan-glow: rgba(88, 196, 221, 0.35);
  --gold: #f4c430;
  --gold-glow: rgba(244, 196, 48, 0.32);
  --coral: #ff6b6b;
  --coral-glow: rgba(255, 107, 107, 0.32);
  --emerald: #4ade80;
  --emerald-glow: rgba(74, 222, 128, 0.30);
  --violet: #a78bfa;
  --violet-glow: rgba(167, 139, 250, 0.32);
  --orange: #fb923c;

  --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, SFMono-Regular, Menlo, monospace;

  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --shadow-stage: 0 20px 50px rgba(0, 0, 0, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

*, *::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 65%),
    radial-gradient(ellipse 60% 40% at 85% 20%, rgba(167, 139, 250, 0.05), transparent 60%),
    var(--bg-page);
}

a {
  color: var(--cyan);
  text-decoration: none;
  transition: color 0.18s ease;
}

a:hover {
  color: #8ee0f2;
}

/* ---------- Top Navigation ---------- */
.book-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  background: rgba(13, 17, 26, 0.84);
  border-bottom: 1px solid var(--border-subtle);
}

.book-nav-inner {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0.72rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

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

.book-brand-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--cyan), var(--gold));
  box-shadow: 0 0 12px var(--cyan-glow);
  flex-shrink: 0;
}

.nav-center {
  color: var(--text-secondary);
  font-size: 0.85rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

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

.nav-btn {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  padding: 0.4rem 0.78rem;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  transition: all 0.16s ease;
}

.nav-btn:hover {
  background: rgba(88, 196, 221, 0.12);
  border-color: var(--border-accent);
  color: #fff;
}

.read-progress-track {
  height: 2px;
  width: 100%;
  background: transparent;
}

.read-progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--cyan), var(--gold));
  box-shadow: 0 0 8px var(--cyan-glow);
  transition: width 0.08s linear;
}

/* ---------- Slide-out Table of Contents Drawer ---------- */
.toc-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(4, 6, 10, 0.72);
  backdrop-filter: blur(4px);
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease;
}

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

.toc-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(390px, 92vw);
  background: var(--bg-card);
  border-left: 1px solid var(--border-subtle);
  z-index: 210;
  transform: translateX(100%);
  transition: transform 0.26s cubic-bezier(0.22, 1, 0.36, 1);
  display: flex;
  flex-direction: column;
  box-shadow: -16px 0 40px rgba(0, 0, 0, 0.6);
}

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

.toc-drawer-header {
  padding: 1.15rem 1.35rem;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.toc-drawer-header h3 {
  margin: 0;
  font-size: 1rem;
  font-weight: 650;
  color: var(--text-primary);
}

.toc-drawer-list {
  overflow-y: auto;
  padding: 1rem 1.1rem 2rem;
  flex: 1;
}

.toc-part-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--gold);
  margin: 1.2rem 0 0.45rem 0.5rem;
  font-weight: 700;
}

.toc-part-label:first-child {
  margin-top: 0.2rem;
}

.toc-item {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.58rem 0.7rem;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.88rem;
  line-height: 1.35;
  transition: all 0.15s ease;
  margin-bottom: 0.15rem;
}

.toc-item:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
}

.toc-item.active {
  background: rgba(88, 196, 221, 0.12);
  color: var(--cyan);
  border-left: 2px solid var(--cyan);
}

.toc-item-num {
  font-family: var(--font-mono);
  font-size: 0.76rem;
  color: var(--text-muted);
  min-width: 1.6rem;
  padding-top: 0.12rem;
}

.toc-item.active .toc-item-num {
  color: var(--cyan);
}

.toc-item-check {
  margin-left: auto;
  font-size: 0.75rem;
  color: var(--emerald);
}

/* ---------- Main Chapter Layout ---------- */
.chapter-shell {
  max-width: 860px;
  margin: 0 auto;
  padding: 3rem 1.35rem 5rem;
}

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

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

.chapter-eyebrow .part-pill {
  background: rgba(88, 196, 221, 0.12);
  border: 1px solid rgba(88, 196, 221, 0.28);
  padding: 0.18rem 0.6rem;
  border-radius: 999px;
}

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

.chapter-subtitle {
  font-size: 1.14rem;
  line-height: 1.55;
  color: var(--text-secondary);
  margin: 0 0 1.2rem;
  max-width: 680px;
}

.chapter-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  font-size: 0.82rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

/* ---------- Prose Typography ---------- */
.chapter-body h2 {
  font-family: var(--font-serif);
  font-size: 1.72rem;
  line-height: 1.25;
  color: #fff;
  margin: 3rem 0 1rem;
  letter-spacing: -0.015em;
}

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

.chapter-body p {
  margin: 0 0 1.25rem;
  color: #d6deeb;
  max-width: 74ch;
}

.chapter-body strong {
  color: #ffffff;
  font-weight: 650;
}

.chapter-body em {
  color: var(--gold);
  font-style: italic;
}

.chapter-body ul, .chapter-body ol {
  margin: 0 0 1.35rem;
  padding-left: 1.4rem;
  color: #d6deeb;
  max-width: 72ch;
}

.chapter-body li {
  margin-bottom: 0.5rem;
}

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

.token-chip {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.86em;
  padding: 0.08rem 0.45rem;
  border-radius: 5px;
  background: rgba(88, 196, 221, 0.14);
  border: 1px solid rgba(88, 196, 221, 0.35);
  color: #b9eef9;
  vertical-align: baseline;
}

/* ---------- Callouts ---------- */
.callout {
  margin: 1.8rem 0;
  padding: 1.2rem 1.4rem;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-subtle);
  border-left: 3px solid var(--cyan);
}

.callout.gold { border-left-color: var(--gold); background: rgba(244, 196, 48, 0.05); }
.callout.coral { border-left-color: var(--coral); background: rgba(255, 107, 107, 0.05); }
.callout.emerald { border-left-color: var(--emerald); background: rgba(74, 222, 128, 0.05); }
.callout.violet { border-left-color: var(--violet); background: rgba(167, 139, 250, 0.05); }

.callout-title {
  font-family: var(--font-mono);
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 0.45rem;
  color: var(--cyan);
  font-weight: 700;
}

.callout.gold .callout-title { color: var(--gold); }
.callout.coral .callout-title { color: var(--coral); }
.callout.emerald .callout-title { color: var(--emerald); }
.callout.violet .callout-title { color: var(--violet); }

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

/* ---------- Interactive Visualization Card ---------- */
.viz-card {
  margin: 2.2rem 0;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-stage);
}

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

.viz-title {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-size: 0.9rem;
  font-weight: 650;
  color: #fff;
}

.viz-badge {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: 0.18rem 0.52rem;
  border-radius: 999px;
  background: rgba(88, 196, 221, 0.15);
  color: var(--cyan);
  border: 1px solid rgba(88, 196, 221, 0.3);
}

.viz-stage {
  position: relative;
  background: var(--bg-stage);
  padding: 1.2rem;
  min-height: 260px;
}

.viz-stage canvas {
  display: block;
  width: 100%;
  border-radius: var(--radius-sm);
}

.viz-controls {
  padding: 0.95rem 1.25rem;
  background: rgba(255, 255, 255, 0.025);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1.15rem;
}

.viz-caption {
  padding: 0.78rem 1.25rem;
  font-size: 0.86rem;
  color: var(--text-secondary);
  border-top: 1px solid var(--border-subtle);
  background: rgba(0, 0, 0, 0.18);
  line-height: 1.55;
}

/* Interactive Controls */
.ctrl-group {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-size: 0.84rem;
  color: var(--text-secondary);
}

.ctrl-label {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--text-secondary);
  white-space: nowrap;
}

.ctrl-value {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--gold);
  min-width: 2.6rem;
  text-align: right;
  font-weight: 600;
}

.btn {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  padding: 0.45rem 0.9rem;
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  font-size: 0.84rem;
  font-weight: 550;
  cursor: pointer;
  transition: all 0.16s ease;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.btn:hover {
  background: rgba(88, 196, 221, 0.16);
  border-color: var(--cyan);
  color: #fff;
}

.btn.active, .btn-primary {
  background: rgba(88, 196, 221, 0.2);
  border-color: var(--cyan);
  color: #fff;
  box-shadow: 0 0 14px rgba(88, 196, 221, 0.22);
}

.btn-gold {
  background: rgba(244, 196, 48, 0.16);
  border-color: var(--gold);
  color: #fff4cc;
}

.btn-gold:hover {
  background: rgba(244, 196, 48, 0.28);
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 145px;
  height: 5px;
  background: rgba(148, 163, 184, 0.25);
  border-radius: 999px;
  outline: none;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 0 10px var(--cyan-glow);
  border: 2px solid #0b0e14;
  transition: transform 0.12s ease;
}

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

.text-input {
  background: var(--bg-stage);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  padding: 0.5rem 0.8rem;
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  font-size: 0.92rem;
  outline: none;
  transition: border-color 0.16s ease;
}

.text-input:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 0 3px rgba(88, 196, 221, 0.12);
}

/* ---------- Check Your Intuition Quiz ---------- */
.intuition-check {
  margin: 3rem 0 2rem;
  padding: 1.5rem 1.6rem;
  background: linear-gradient(145deg, rgba(88, 196, 221, 0.06), rgba(167, 139, 250, 0.05));
  border: 1px solid rgba(88, 196, 221, 0.25);
  border-radius: var(--radius-lg);
}

.intuition-check h3 {
  margin: 0 0 0.5rem;
  color: var(--gold);
  font-size: 1rem;
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.intuition-question {
  font-size: 1.05rem;
  color: #fff;
  margin-bottom: 1rem;
  font-weight: 550;
}

.intuition-options {
  display: grid;
  gap: 0.55rem;
}

.intuition-opt {
  text-align: left;
  background: rgba(13, 17, 26, 0.7);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  padding: 0.72rem 1rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.92rem;
  font-family: var(--font-sans);
  transition: all 0.16s ease;
}

.intuition-opt:hover {
  border-color: var(--cyan);
  background: rgba(88, 196, 221, 0.09);
}

.intuition-opt.correct {
  border-color: var(--emerald);
  background: rgba(74, 222, 128, 0.14);
  color: #e6ffef;
}

.intuition-opt.wrong {
  border-color: var(--coral);
  background: rgba(255, 107, 107, 0.12);
  color: #ffd6d6;
}

.intuition-feedback {
  margin-top: 0.9rem;
  font-size: 0.9rem;
  color: var(--text-secondary);
  min-height: 1.2rem;
}

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

.chapter-nav-card {
  display: flex;
  flex-direction: column;
  padding: 1.1rem 1.25rem;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  transition: all 0.18s ease;
}

.chapter-nav-card:hover {
  border-color: var(--cyan);
  transform: translateY(-2px);
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.35);
}

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

.chapter-nav-dir {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-bottom: 0.3rem;
}

.chapter-nav-title {
  color: #fff;
  font-weight: 600;
  font-size: 0.98rem;
}

/* ---------- Landing Page Specific ---------- */
.hero-section {
  max-width: 1120px;
  margin: 0 auto;
  padding: 3.5rem 1.35rem 2.5rem;
}

.hero-grid {
  display: grid;
  grid-template-columns: 1.15fr 1fr;
  gap: 2.5rem;
  align-items: center;
}

.hero-title {
  font-family: var(--font-serif);
  font-size: clamp(2.5rem, 5.2vw, 3.85rem);
  line-height: 1.08;
  letter-spacing: -0.025em;
  color: #fff;
  margin: 0.6rem 0 1.1rem;
}

.hero-title span {
  background: linear-gradient(120deg, var(--cyan), var(--gold));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.hero-lead {
  font-size: 1.1rem;
  color: var(--text-secondary);
  margin: 0 0 1.7rem;
  max-width: 52ch;
}

.hero-cta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.85rem;
  align-items: center;
}

.cta-primary {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.8rem 1.45rem;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, #2b8ba3, #42adc7);
  color: #061018;
  font-weight: 700;
  font-size: 0.96rem;
  box-shadow: 0 8px 28px rgba(88, 196, 221, 0.3);
  transition: transform 0.16s ease, box-shadow 0.16s ease;
}

.cta-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 34px rgba(88, 196, 221, 0.45);
  color: #061018;
}

.hero-canvas-wrap {
  background: var(--bg-stage);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-stage);
  position: relative;
}

.course-grid-section {
  max-width: 1120px;
  margin: 0 auto;
  padding: 1rem 1.35rem 5rem;
}

.part-block {
  margin-top: 2.8rem;
}

.part-header {
  display: flex;
  align-items: baseline;
  gap: 0.85rem;
  margin-bottom: 1.15rem;
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 0.6rem;
}

.part-num {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--gold);
  font-weight: 700;
}

.part-title {
  font-family: var(--font-serif);
  font-size: 1.45rem;
  color: #fff;
  margin: 0;
}

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

.chapter-card {
  display: flex;
  flex-direction: column;
  padding: 1.3rem 1.35rem;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  transition: all 0.2s ease;
  position: relative;
}

.chapter-card:hover {
  border-color: var(--cyan);
  transform: translateY(-3px);
  box-shadow: 0 14px 32px rgba(0, 0, 0, 0.4);
}

.chapter-card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.65rem;
}

.chapter-card-num {
  font-family: var(--font-mono);
  font-size: 0.76rem;
  color: var(--cyan);
  background: rgba(88, 196, 221, 0.12);
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
}

.chapter-card-status {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--emerald);
}

.chapter-card h3 {
  margin: 0 0 0.45rem;
  font-size: 1.12rem;
  color: #fff;
  font-weight: 650;
}

.chapter-card p {
  margin: 0 0 1rem;
  font-size: 0.88rem;
  color: var(--text-secondary);
  line-height: 1.5;
  flex: 1;
}

.chapter-card-foot {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  color: var(--text-muted);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

@media (max-width: 820px) {
  .hero-grid {
    grid-template-columns: 1fr;
  }
  .chapter-footer {
    grid-template-columns: 1fr;
  }
  .nav-center {
    display: none;
  }
}
