/*
 * Lesson template — base layer.
 * Colours, type, page layout and the chapter hero.
 *
 * Every v2 chapter links this file first, then blocks.css,
 * interactive.css and code.css. Chapters must NOT carry their own
 * <style> block. That is how we keep every chapter looking the same.
 *
 * The palette matches the original site (dark default, teal accent),
 * so the new chapters still feel like llamasearch.dev.
 */

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

:root {
  /* Surfaces and text — same values as the original chapters. */
  --bg: #0a0a0f;
  --bg-nav: rgba(10, 10, 15, 0.92);
  --bg-card: #12121a;
  --bg-card-alt: #181825;
  --border: #2a2a3a;
  --text: #e0e0e8;
  --text-dim: #8888a0;

  /* Brand accents (unchanged from the original site). */
  --accent: #498a9b;
  --accent2: #a78bfa;
  --accent3: #34d399;
  --accent4: #f472b6;
  --accent5: #fbbf24;
  --danger: #f87171;

  /*
   * Role colours. One fixed colour per idea, on EVERY page.
   * (Borrowed technique: Jay Alammar's colour-coded vectors.)
   * A learner who sees purple anywhere on the site should think "key".
   */
  --role-q: var(--accent);      /* queries */
  --role-k: var(--accent2);     /* keys */
  --role-v: var(--accent3);     /* values */
  --role-cache: var(--accent5); /* anything stored / cached / memory */
  --role-new: var(--accent4);   /* the token or item being computed right now */

  --radius: 12px;
  --sans: 'Inter Variable', system-ui, 'Segoe UI', sans-serif;
  --serif: 'Source Serif 4 Variable', Georgia, 'Times New Roman', serif;
  --mono: 'IBM Plex Mono', ui-monospace, 'SF Mono', Menlo, monospace;
}

[data-theme='light'] {
  --bg: #f5f5f8;
  --bg-nav: rgba(245, 245, 248, 0.95);
  --bg-card: #ffffff;
  --bg-card-alt: #ededf4;
  --border: #dddde8;
  --text: #1a1a2e;
  --text-dim: #5a5a7a;
  --accent: #025c74;
  --accent2: #7040c0;
  --accent3: #0f9a6a;
  --accent4: #c0307a;
  --accent5: #a16207;
}

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.75;
  overflow-x: hidden;
}

/* ── Type ─────────────────────────────────────────────── */
h1, h2, h3, h4 { font-weight: 700; line-height: 1.25; color: var(--text); }
h1 { font-family: var(--serif); font-size: clamp(2.1rem, 5vw, 3.2rem); }
h2 { font-size: clamp(1.45rem, 3vw, 1.95rem); margin-bottom: 0.6em; }
h3 { font-size: 1.15rem; color: var(--accent); margin: 1.8em 0 0.5em; }

p { margin-bottom: 1em; color: var(--text-dim); }
strong { color: var(--text); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

ul, ol { color: var(--text-dim); margin: 0 0 1em 1.4em; }
li { margin-bottom: 0.35em; }

/* Inline code in prose. */
:not(pre) > code {
  font-family: var(--mono);
  font-size: 0.88em;
  background: var(--bg-card-alt);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 1px 6px;
  color: var(--text);
  overflow-wrap: anywhere; /* long identifiers wrap on phones instead of widening the page */
}

/* Role colour helpers for inline words: <span class="q">query</span>. */
.q { color: var(--role-q); font-weight: 600; }
.k { color: var(--role-k); font-weight: 600; }
.v { color: var(--role-v); font-weight: 600; }
.cache { color: var(--role-cache); font-weight: 600; }
.new { color: var(--role-new); font-weight: 600; }

/* ── Layout ───────────────────────────────────────────── */
.container { max-width: 820px; margin: 0 auto; padding: 0 24px; }

.lesson-section {
  padding: 64px 0;
  border-bottom: 1px solid var(--border);
}

/* Small mono label above each section title: "03 · THE KV CACHE". */
.section-label {
  display: block;
  font-family: var(--mono);
  font-size: 0.8rem;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 10px;
}

/* ── Hero ─────────────────────────────────────────────── */
/* Short on purpose: title, one-line hook, three facts. No stat counters. */
.lesson-hero {
  padding: 96px 24px 56px;
  text-align: center;
  border-bottom: 1px solid var(--border);
  background: radial-gradient(circle at 50% -10%, rgba(73, 138, 155, 0.16), transparent 60%);
}
.lesson-hero .series-tag {
  font-family: var(--mono);
  font-size: 0.8rem;
  letter-spacing: 2px;
  color: var(--accent);
  margin-bottom: 14px;
}
.lesson-hero h1 { margin-bottom: 14px; }
.lesson-hero .hook {
  font-size: 1.15rem;
  max-width: 620px;
  margin: 0 auto 24px;
  color: var(--text-dim);
}
.lesson-hero .meta {
  display: flex;
  justify-content: center;
  gap: 24px;
  flex-wrap: wrap;
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--text-dim);
}
.lesson-hero .meta span::before { content: '◆ '; color: var(--accent); }

/* Gentle reveal on scroll (lesson.js adds .visible). */
.fade-in { opacity: 0; transform: translateY(16px); transition: opacity 0.5s, transform 0.5s; }
.fade-in.visible { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) {
  .fade-in { opacity: 1; transform: none; transition: none; }
}
