/*
 * Lesson template — content blocks.
 * These are the only boxes a chapter may use. One look per job:
 *   .learn-box      "What you'll learn" + "Before you start"
 *   .note           callouts: .intuition / .key / .pitfall
 *   details.deep-dive   optional depth, closed by default
 *   .notation       symbol table for the chapter
 *   .formula-block  KaTeX equation + plain-English "read it as" line
 *   .data-table     shape tables, comparison tables, result tables
 *   .figure         diagram + caption
 *   .recap / .quiz  end-of-chapter summary and self-check
 *   .build-it       link to the matching Evolving Transformer stop
 */

/* ── What you'll learn ───────────────────────────────── */
.learn-box {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 24px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 28px;
  margin: 40px 0 0;
}
.learn-box h4 {
  font-family: var(--mono);
  font-size: 0.78rem;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 10px;
}
.learn-box ul { margin-bottom: 0; }
.learn-box li { font-size: 0.95rem; }
@media (max-width: 680px) { .learn-box { grid-template-columns: 1fr; } }

/* ── Callouts ─────────────────────────────────────────── */
/* Three kinds only. The label is added by CSS so every page says it the same way. */
.note {
  border-left: 3px solid var(--accent);
  background: var(--bg-card);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 16px 20px;
  margin: 24px 0;
}
.note p:last-child, .note ul:last-child { margin-bottom: 0; }
.note p { color: var(--text); }
.note::before {
  display: block;
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  margin-bottom: 6px;
}
.note.intuition { border-left-color: var(--accent2); }
.note.intuition::before { content: 'Intuition'; color: var(--accent2); }
.note.key { border-left-color: var(--accent); background: rgba(73, 138, 155, 0.08); }
.note.key::before { content: 'Key idea'; color: var(--accent); }
.note.pitfall { border-left-color: var(--accent5); background: rgba(251, 191, 36, 0.06); }
.note.pitfall::before { content: 'Pitfall'; color: var(--accent5); }

/* ── Deep dive (optional depth) ──────────────────────── */
details.deep-dive {
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 0 20px;
  margin: 24px 0;
}
details.deep-dive > summary {
  cursor: pointer;
  list-style: none;
  padding: 14px 0;
  font-weight: 600;
  color: var(--text);
}
details.deep-dive > summary::-webkit-details-marker { display: none; }
details.deep-dive > summary::before {
  content: 'DEEP DIVE ▸ ';
  font-family: var(--mono);
  font-size: 0.75rem;
  letter-spacing: 1.5px;
  color: var(--accent2);
}
details.deep-dive[open] > summary::before { content: 'DEEP DIVE ▾ '; }
details.deep-dive[open] { padding-bottom: 12px; }

/* ── Formulas ─────────────────────────────────────────── */
/* KaTeX renders into .formula.tex (see /_shared/katex-init.js). */
.formula-block {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin: 24px 0;
  overflow: hidden;
}
.formula-block .formula.tex { padding: 20px 24px 12px; text-align: center; overflow-x: auto; }
.formula-block .read-as {
  border-top: 1px solid var(--border);
  background: var(--bg-card-alt);
  padding: 10px 20px;
  font-size: 0.92rem;
  color: var(--text-dim);
}
.formula-block .read-as::before {
  content: 'Read it as: ';
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--accent);
}

/* ── Tables (notation, shapes, comparisons) ──────────── */
.data-table {
  width: 100%;
  border-collapse: collapse;
  margin: 20px 0 28px;
  font-size: 0.9rem;
}
.table-wrap { overflow-x: auto; position: relative; } /* relative: KaTeX's hidden MathML is absolutely positioned and would otherwise escape the scroll box */
.data-table th, .data-table td {
  border: 1px solid var(--border);
  padding: 9px 12px;
  text-align: left;
  vertical-align: top;
}
.data-table th { background: var(--bg-card-alt); color: var(--accent); font-weight: 600; }
.data-table td { background: var(--bg-card); color: var(--text-dim); }
.data-table td strong { color: var(--text); }
.data-table .mono, .data-table code { font-family: var(--mono); font-size: 0.85rem; }
.data-table tr.highlight td { background: rgba(73, 138, 155, 0.1); }
.data-table caption {
  caption-side: bottom;
  text-align: left;
  font-size: 0.82rem;
  color: var(--text-dim);
  padding-top: 8px;
}

/* ── Figures ──────────────────────────────────────────── */
.figure { margin: 28px 0; text-align: center; }
.figure svg { max-width: 100%; height: auto; }
.figure img { max-width: 100%; height: auto; border-radius: var(--radius); }
.figure figcaption { font-size: 0.85rem; color: var(--text-dim); margin-top: 8px; }

/* Manim / narrative video clips — same figure chrome as images. */
.figure video {
  display: block;
  width: 100%;
  max-width: 720px;
  height: auto;
  margin: 0 auto;
  border-radius: var(--radius);
  background: #0f1419;
  border: 1px solid var(--border);
}
.figure.manim-clip figcaption .kind {
  display: inline-block;
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 1px;
  color: var(--accent);
  margin-right: 6px;
}

/* Beat scrubber under a Manim clip — jumps video + lights formula terms. */
.manim-beats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin: 14px 0 6px;
}
.manim-beats button {
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.4px;
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-dim);
  cursor: pointer;
}
.manim-beats button:hover { border-color: var(--accent); color: var(--text); }
.manim-beats button.active {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(73, 138, 155, 0.12);
}

/* Formula terms lit while the matching Manim beat plays. */
.manim-formula-sync {
  text-align: center;
  font-size: 1.05rem;
  color: var(--text-dim);
  margin: 10px 0 4px;
  line-height: 1.7;
}
.manim-formula-sync .beat-term {
  padding: 1px 4px;
  border-radius: 4px;
  transition: color 0.2s, background 0.2s;
}
/* Generic active term — NATWD and future clips use data-beat + .on */
.manim-formula-sync .beat-term.on {
  color: var(--accent);
  background: rgba(73, 138, 155, 0.12);
}
.manim-formula-sync .beat-term.on-scores {
  color: var(--accent5);
  background: rgba(251, 191, 36, 0.12);
}
.manim-formula-sync .beat-term.on-weights {
  color: var(--accent3);
  background: rgba(52, 211, 153, 0.12);
}
.manim-formula-sync .beat-term.on-mix {
  color: var(--accent3);
  background: rgba(52, 211, 153, 0.12);
}
.manim-formula-sync .beat-term.on-qkv,
.manim-formula-sync .beat-term.on-grid {
  color: var(--accent);
  background: rgba(73, 138, 155, 0.12);
}
.manim-formula-sync .beat-term.on-wrong {
  color: var(--accent4);
  background: rgba(244, 114, 182, 0.12);
}
.manim-formula-sync .beat-term.on-right,
.manim-formula-sync .beat-term.on-hold {
  color: var(--accent3);
  background: rgba(52, 211, 153, 0.12);
}

/* ── Recap + self-check ──────────────────────────────── */
.recap { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px 28px; }
.recap li { color: var(--text); }
.quiz details { border-bottom: 1px solid var(--border); padding: 12px 0; }
.quiz summary { cursor: pointer; color: var(--text); font-weight: 600; }
.quiz details p { margin: 10px 0 0; }

/* ── Build it + where next ───────────────────────────── */
.next-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 16px; margin: 24px 0; }
.next-card {
  display: block;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  color: var(--text-dim);
  transition: border-color 0.2s;
}
.next-card:hover { border-color: var(--accent); text-decoration: none; }
.next-card .kind { display: block; font-family: var(--mono); font-size: 0.72rem; letter-spacing: 1.5px; color: var(--accent); margin-bottom: 4px; }
.next-card strong { display: block; margin-bottom: 4px; }
.next-card.build { border-color: rgba(52, 211, 153, 0.4); }
.next-card.build .kind { color: var(--accent3); }
