/* Neural Forge (Mission 09 · Deep Learning): self-contained module stylesheet.
   Inherits the shared Neuronauts design tokens, then extends with the sage
   teal "layered neural brain" identity. */
@import url("../styles.css");

:root {
  --accent: #15746b;          /* sage teal */
  --accent-2: #0f5e57;        /* deep teal */
  --accent-soft: #dceeeb;
  --accent-soft-2: #d2e9e5;
  --accent-ink: #134e48;
  --accent-line: #c3ddd7;
  --radius: 10px;
  --max: 1180px;
  --rail-w: 168px;
}

body { line-height: 1.6; }
img, svg, canvas { max-width: 100%; }

/* ---------- topbar / nav (module-local) ---------- */
.topbar {
  position: sticky; top: 0; z-index: 40;
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 18px;
  padding: 12px max(18px, calc((100vw - var(--max)) / 2 + 18px));
  background: rgba(248, 250, 247, 0.92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
}
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 900; color: var(--ink); min-width: 0; }
.brand span { min-width: 0; }
.mark {
  width: 34px; height: 34px; display: grid; place-items: center;
  border-radius: 8px; color: #fff; font-weight: 900;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%);
}
.nav-links { display: flex; justify-content: flex-end; gap: 16px; color: var(--muted); font-size: 14px; font-weight: 750; }
.nav-links a:hover { color: var(--accent); }
.menu-button {
  display: none; border: 1px solid var(--line); border-radius: 8px;
  background: #fff; color: var(--ink); padding: 8px 12px; font-weight: 800;
}
.scroll-meter { position: absolute; left: 0; right: 0; bottom: -1px; height: 3px; background: #dde7d4; }
.scroll-meter span { display: block; width: 0; height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); }

/* ---------- buttons / generic ---------- */
.button, button.button {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 42px; border: 1px solid var(--line); border-radius: 8px;
  padding: 0 16px; background: #fff; color: var(--ink); font-weight: 850; cursor: pointer;
  transition: border-color .18s, transform .12s, background .18s;
}
.button:hover { border-color: var(--accent); transform: translateY(-1px); }
.button.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.button.primary:hover { background: var(--accent-2); }
.button-row { display: flex; gap: 10px; flex-wrap: wrap; }
.note { color: var(--muted); font-size: 13px; }
.muted { color: var(--muted); font-size: 13px; }
.mini-cap { margin: 0 0 6px; color: var(--muted); font-size: 12px; font-weight: 800; }

textarea, select, input {
  font: inherit; color: var(--ink); background: #fff;
  border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; width: 100%;
}
label { display: block; font-size: 13px; font-weight: 800; color: var(--ink); margin: 10px 0 6px; }
label .val { float: right; color: var(--accent-2); font-weight: 900; font-variant-numeric: tabular-nums; }
input[type="range"] { width: 100%; accent-color: var(--accent); padding: 0; }
.controls-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.check-row { display: flex; align-items: center; gap: 8px; font-weight: 700; margin: 12px 0; }
.check-row input { width: auto; }

canvas {
  display: block; width: 100%; background: #fff;
  border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); margin-top: 8px;
}
.canvas-cap { margin: 8px 0 0; color: var(--muted); font-size: 13px; }

/* canvas heights (width is 100%; JS reads getBoundingClientRect for DPR scaling) */
#heroCanvas { height: 360px; }
#lightCanvas { height: 240px; }
#actCanvas { height: 280px; }
#fwdCanvas { height: 340px; }
#xorCanvas { height: 360px; }
#bpCanvas { height: 320px; }
#optCanvas { height: 300px; }
#tbBoundary { height: 360px; }
#tbLossCanvas { height: 150px; }
#ofCanvas { height: 320px; }
#cnnImage, #cnnMap { height: 220px; }
#rnnCanvas { height: 240px; }
/* new concept canvases */
#flowCanvas { height: 300px; }
#initCanvas { height: 300px; }
#smxCanvas { height: 280px; }
#vgCanvas { height: 280px; }
#batchCanvas { height: 320px; }
#poolIn, #poolOut { height: 220px; }
#dropCanvas { height: 320px; }
#bnCanvas { height: 300px; }
#resCanvas { height: 280px; }
#aeIn, #aeOut { height: 200px; }
#embCanvas { height: 340px; }
#ganCanvas { height: 320px; }
/* new architecture canvases */
#s2sCanvas { height: 300px; }
#trCanvas { height: 360px; }
#unetCanvas { height: 340px; }
#ganLoopCanvas { height: 320px; }
#vaeCanvas { height: 300px; }
#nfCanvas { height: 320px; }
#gnnCanvas { height: 340px; }
#moeCanvas { height: 340px; }
@media (max-width: 720px) {
  #heroCanvas { height: 300px; }
  #tbBoundary, #xorCanvas, #fwdCanvas { height: 320px; }
  #flowCanvas, #batchCanvas, #dropCanvas, #ganCanvas, #embCanvas { height: 300px; }
  #poolIn, #poolOut, #cnnImage, #cnnMap, #aeIn, #aeOut { height: 180px; }
  #s2sCanvas, #vaeCanvas, #ganLoopCanvas, #nfCanvas { height: 280px; }
  #trCanvas, #unetCanvas, #gnnCanvas, #moeCanvas { height: 320px; }
}

/* ---------- architecture family map (clickable tiles) ---------- */
.fam-map {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 150px), 1fr));
  gap: 12px; margin: 18px 0 14px;
}
.fam-map button {
  display: grid; gap: 4px; text-align: left; cursor: pointer;
  border: 1px solid var(--line); border-left: 4px solid var(--accent);
  border-radius: 10px; background: var(--panel); padding: 12px 14px;
  box-shadow: var(--shadow); transition: border-color .15s, transform .12s, background .15s;
}
.fam-map button:hover { border-color: var(--accent); transform: translateY(-2px); }
.fam-map button.active { background: var(--accent-soft); border-left-color: var(--accent-2); }
.fam-map button .fam-name { font-weight: 900; color: var(--accent-ink); font-size: 15px; }
.fam-map button .fam-tag { font-size: 12px; color: var(--muted); font-weight: 700; }

/* ---------- level rail (sticky difficulty ladder) ---------- */
.level-rail {
  position: fixed; left: 16px; top: 50%; transform: translateY(-50%);
  z-index: 35; display: grid; gap: 8px; width: var(--rail-w);
}
.level-rail a {
  display: grid; grid-template-columns: 26px 1fr; align-items: center; gap: 10px;
  padding: 9px 12px; border: 1px solid var(--line); border-radius: 10px;
  background: rgba(255,255,255,.85); backdrop-filter: blur(6px);
  color: var(--muted); font-weight: 800; font-size: 13px; transition: .2s;
}
.level-rail a b {
  display: grid; place-items: center; width: 26px; height: 26px; border-radius: 7px;
  background: #e7eddc; color: var(--muted); font-weight: 900;
}
.level-rail a:hover { border-color: var(--accent); color: var(--ink); }
.level-rail a.active { border-color: var(--accent); background: #fff; color: var(--accent-ink); box-shadow: var(--shadow); }
.level-rail a.active b { background: var(--accent); color: #fff; }

/* ---------- hero ---------- */
.hero {
  max-width: var(--max); margin: 0 auto; min-height: auto;
  padding: 64px 18px 56px;
  display: grid; grid-template-columns: .95fr 1.05fr; gap: 40px; align-items: center;
}
.hero-copy h1 { margin: 0; font-size: clamp(38px, 6.5vw, 70px); line-height: 1.03; letter-spacing: 0; }
.hero-copy .lead { margin-top: 16px; }
.eyebrow { margin: 0 0 10px; color: var(--rose); font-size: 12px; font-weight: 900; letter-spacing: .1em; text-transform: uppercase; }
.lead { color: var(--muted); font-size: clamp(16px, 1.8vw, 19px); line-height: 1.7; max-width: 720px; }
.hero-copy em { color: var(--accent-ink); font-style: normal; font-weight: 800; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 12px; margin: 24px 0 14px; }
.hero-visual { padding: 16px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }

/* ---------- level sections ---------- */
.level {
  max-width: var(--max);
  margin: 0 auto; padding: 72px 18px 56px;
  border-top: 1px solid var(--line);
}
.level[data-level="2"], .level[data-level="4"] { background: linear-gradient(180deg, #eef4e6 0%, var(--paper) 240px); }
.level-head { max-width: 860px; margin-bottom: 8px; }
.level-head h2 { margin: 4px 0 0; font-size: clamp(28px, 4.4vw, 46px); line-height: 1.08; }

.concept { margin-top: 34px; }
.step-chip {
  display: inline-block; margin-bottom: 12px; padding: 5px 12px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent-ink); border: 1px solid var(--accent-line);
  font-size: 12px; font-weight: 900; letter-spacing: .04em; text-transform: uppercase;
}
.step-chip.game { background: #e6f5f1; color: #0c4f43; border-color: #c2e8df; }
.step-chip.worked { background: #f1ecd6; color: #6a4700; border-color: #f3dcab; }
.concept h3 { margin: 0 0 10px; font-size: clamp(20px, 2.6vw, 28px); }
.concept h4 { margin: 0 0 6px; font-size: 16px; }
.concept p { color: var(--ink); }
.concept a { color: var(--accent-2); font-weight: 800; }

/* ---------- panels / cards ---------- */
.panel {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; min-width: 0;
}
.panel-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.panel-title h3 { margin: 0; }

.example-box {
  margin-top: 16px; border: 1px solid var(--accent-line); border-left: 4px solid var(--accent);
  border-radius: 8px; padding: 14px; background: var(--accent-soft);
}
.example-box strong { color: var(--accent-ink); }
.example-box p { margin: 6px 0 0; color: var(--ink); }

.narration {
  margin: 14px 0 0; padding: 13px 14px; border: 1px solid var(--line);
  border-radius: 8px; background: #f1f6ec; color: var(--ink); line-height: 1.6; min-height: 1px;
}
.narration strong { color: var(--ink); }
.narration.win { background: #e6f5f1; border-color: #c2e8df; color: #0c4f43; }

/* ---------- analogy / arch grids ---------- */
.analogy-grid, .arch-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-top: 18px; }
.analogy-grid article, .arch-grid article { border: 1px solid var(--line); border-radius: 10px; padding: 16px; background: var(--panel); box-shadow: var(--shadow); }
.analogy-grid p, .arch-grid p { margin: 0; color: var(--muted); }
.arch-grid h4 { color: var(--accent-ink); }

/* ---------- toggles (input switches) ---------- */
.toggle {
  width: 100%; min-height: 42px; border: 1px solid var(--line); border-radius: 8px;
  background: #fff; color: var(--muted); font-weight: 900; font-size: 18px; cursor: pointer; transition: .15s;
}
.toggle[aria-pressed="true"] { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ---------- segmented control ---------- */
.segmented { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 4px; }
.segmented button { border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink); padding: 8px 12px; font-weight: 800; cursor: pointer; min-width: 0; overflow-wrap: anywhere; }
.segmented button.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.segmented.two button { flex: 1 1 160px; }

/* ---------- truth table (gate game) ---------- */
.truth-table { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 14px 0 4px; }
.truth-table .tt-cell { border: 1px solid var(--line); border-radius: 8px; padding: 10px; text-align: center; background: #f4f8ee; }
.truth-table .tt-cell .tt-in { font-weight: 800; color: var(--ink); }
.truth-table .tt-cell .tt-out { font-size: 13px; color: var(--muted); margin-top: 4px; }
.truth-table .tt-cell.ok { background: #e6f5f1; border-color: #79c9b6; }
.truth-table .tt-cell.bad { background: #fbe4ec; border-color: #e79bb6; }

/* ---------- SVG figures ---------- */
.svg-figure { margin: 18px 0 0; border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; background: var(--panel); box-shadow: var(--shadow); }
.svg-figure svg { width: 100%; height: auto; }
.svg-figure figcaption { margin-top: 10px; color: var(--muted); font-size: 13px; text-align: center; }
.svg-node { stroke-width: 2; }
.svg-node.in { fill: var(--accent-soft); stroke: var(--accent); }
.svg-node.hid { fill: #dceeeb; stroke: var(--accent-2); }
.svg-node.out { fill: #fdf0d6; stroke: var(--amber); }
.svg-lbl { fill: var(--muted); font: 800 13px Inter, system-ui, sans-serif; }

/* ---------- math cards (KaTeX) ---------- */
.math-card {
  margin: 0; border: 1px solid var(--line); border-left: 5px solid var(--accent);
  border-radius: var(--radius); background: var(--panel); box-shadow: var(--shadow); overflow: hidden;
}
.math-card.compact { margin: 14px 0; box-shadow: none; }
.math-render {
  padding: 22px 18px; background: #f2f7ee; border-bottom: 1px solid var(--line);
  overflow-x: auto; text-align: center; font-size: 1.05rem;
}
.math-card figcaption { padding: 16px 18px; }
.math-card figcaption p { margin: 0 0 12px; color: var(--ink); }
.math-card figcaption p strong { color: var(--accent-ink); }
.legend { margin: 0; padding-left: 0; list-style: none; display: grid; gap: 7px; }
.legend li { color: var(--muted); padding-left: 14px; position: relative; }
.legend li::before { content: ""; position: absolute; left: 0; top: 9px; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.legend strong { color: var(--ink); }

/* ---------- train-a-brain lab ---------- */
.lab-layout { display: grid; grid-template-columns: 280px 1fr; gap: 18px; align-items: start; }
.control-panel {
  position: sticky; top: 80px; padding: 18px; background: var(--panel);
  border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
}
.control-panel h3 { margin: 0 0 6px; }
.control-panel .button-row { margin-top: 14px; }
.lab-panel { min-height: 540px; }
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 16px; }
.stat-grid div { border: 1px solid var(--line); border-radius: 8px; padding: 10px; background: #f4f8ee; text-align: center; }
.stat-label { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 800; }
.stat-grid strong { font-size: 18px; color: var(--accent-ink); font-variant-numeric: tabular-nums; }

/* ---------- CNN stage ---------- */
.cnn-stage { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 8px; }

/* ---------- worked example ---------- */
.worked-list { margin: 8px 0 0; padding-left: 20px; }
.worked-list li { margin-bottom: 10px; color: var(--ink); }
.worked-list strong { color: var(--accent-ink); }

/* ---------- code ---------- */
.code-block {
  margin: 0; border-radius: 8px; padding: 16px; background: #15241f; color: #dfeee6;
  overflow-x: auto; font: 13px/1.6 "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}
.code-explanation { display: grid; gap: 8px; margin-top: 14px; }
.code-explanation p { margin: 0; color: var(--ink); }
.code-explanation strong, .code-explanation code { color: var(--accent-ink); font-family: "SFMono-Regular", Consolas, monospace; }

/* ---------- quiz ---------- */
.quiz-panel .q { margin-bottom: 18px; }
.quiz-panel .q-text { font-weight: 800; margin: 0 0 10px; }
.quiz-opts { display: grid; gap: 8px; }
.quiz-opts button {
  text-align: left; border: 1px solid var(--line); border-radius: 8px; background: #fff;
  color: var(--ink); padding: 11px 14px; font-weight: 700; cursor: pointer; transition: .15s;
}
.quiz-opts button:hover:not(:disabled) { border-color: var(--accent); }
.quiz-opts button.correct { background: #e2f3ee; border-color: var(--green); color: #0c4f43; }
.quiz-opts button.wrong { background: #fbe4ec; border-color: var(--rose); color: #7a1538; }
.quiz-opts button:disabled { cursor: default; }
.quiz-feedback { margin: 8px 0 0; font-size: 13px; color: var(--muted); }
.quiz-feedback.show { color: var(--accent-ink); }

/* ---------- practice ---------- */
.practice-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.practice-card { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--panel); box-shadow: var(--shadow); }
.practice-card button { width: 100%; text-align: left; border: 0; background: transparent; color: var(--ink); padding: 16px; font-weight: 850; cursor: pointer; }
.practice-card p { display: none; margin: 0; padding: 0 16px 16px; color: var(--muted); }
.practice-card.open p { display: block; }

/* ---------- back to top + footer ---------- */
.back-to-top {
  position: fixed; right: 18px; bottom: 18px; opacity: 0; transform: translateY(12px);
  transition: .2s; border: 1px solid var(--line); border-radius: 8px; background: #fff;
  color: var(--ink); padding: 10px 12px; font-weight: 800; cursor: pointer; z-index: 30;
}
.back-to-top.show { opacity: 1; transform: translateY(0); }
.footer { display: grid; gap: 6px; justify-items: center; text-align: center; padding: 30px 18px; color: var(--muted); border-top: 1px solid var(--line); }
.footer a { color: var(--accent); font-weight: 800; }

/* ---------- reveal-on-scroll ---------- */
.reveal { opacity: 0; transform: translateY(18px); transition: opacity .6s ease, transform .6s ease; }
.reveal.in { opacity: 1; transform: none; }

/* ============================ responsive ============================
   The shared root stylesheet already hardens images/canvas/code/KaTeX/
   tables/range inputs. This builds the module-specific grid collapses
   and small-phone tightening on top. Verified at 1280, 1024, 960, 820,
   768, 600, 480, 360, 320. */

/* Below desktop max: level rail becomes a horizontal bar above content. */
@media (max-width: 1280px) {
  .level-rail {
    position: static; transform: none; width: auto; max-width: var(--max);
    margin: 14px auto -10px; padding: 0 18px;
    grid-template-columns: repeat(4, 1fr); gap: 8px;
  }
  .level-rail a { background: #fff; }
}

/* Tablet: collapse the wide two-column layouts. */
@media (max-width: 1024px) {
  .lab-layout { grid-template-columns: 1fr; }
  .control-panel { position: static; top: auto; }
}
@media (max-width: 960px) {
  .hero { grid-template-columns: 1fr; }
  .analogy-grid, .arch-grid { grid-template-columns: repeat(2, 1fr); }
}

/* Phone: single-column everything, mobile nav, full-width buttons. */
@media (max-width: 768px) {
  .topbar {
    grid-template-columns: 1fr auto; gap: 12px; row-gap: 10px;
    padding: 12px clamp(14px, 4vw, 18px);
  }
  .menu-button { display: inline-flex; }
  .nav-links {
    display: none; grid-column: 1 / -1; flex-direction: column;
    align-items: stretch; gap: 8px; text-align: left;
  }
  .nav-links.open { display: flex; }
  .controls-row { grid-template-columns: 1fr; }
  .practice-grid, .analogy-grid, .arch-grid, .cnn-stage { grid-template-columns: 1fr; }
  .truth-table { grid-template-columns: repeat(2, 1fr); }
  .level-rail { grid-template-columns: repeat(4, 1fr); gap: 6px; padding: 0 14px; }
  .level-rail a { grid-template-columns: 22px 1fr; padding: 7px 9px; font-size: 12px; gap: 7px; }
  .level-rail a b { width: 22px; height: 22px; }
  .button { width: 100%; }
  .button-row .button { width: auto; flex: 1 1 auto; }
  .hero { padding: 40px 18px 40px; gap: 28px; }
  .level { padding: 48px 18px 44px; }
  .concept { margin-top: 26px; }
}

/* Compact phones: hide rail text labels (keep numbered chips), tighten type. */
@media (max-width: 600px) {
  .level-rail a span { display: none; }
  .level-rail a { grid-template-columns: 1fr; justify-items: center; padding: 8px 6px; }
  .level-rail a b { width: 26px; height: 26px; }
  .panel { padding: 14px; }
  .math-render { padding: 18px 12px; font-size: 1rem; }
  .math-card figcaption { padding: 14px; }
  .svg-figure { padding: 12px; }
  .hero { padding: 32px 16px 36px; }
  .level { padding: 40px 16px 38px; }
  .hero-visual { padding: 12px; }
  .stat-grid strong { font-size: 16px; }
}

/* Very small phones (480 -> 320): final tightening, no overflow. */
@media (max-width: 480px) {
  .hero, .level { padding-left: 14px; padding-right: 14px; }
  .hero { padding-top: 28px; padding-bottom: 32px; }
  .level { padding-top: 34px; padding-bottom: 34px; }
  .hero-copy h1 { font-size: clamp(28px, 9vw, 40px); }
  .level-head h2 { font-size: clamp(22px, 7vw, 32px); }
  .concept h3 { font-size: clamp(18px, 6vw, 24px); }
  .lead { font-size: clamp(15px, 4.4vw, 18px); }
  .segmented button { padding: 7px 10px; font-size: 13px; }
  .panel-title { gap: 8px; }
  .code-block { padding: 12px; font-size: 12px; }
  .practice-card button { padding: 14px; }
  .truth-table { grid-template-columns: 1fr 1fr; }
}

/* Narrowest supported width. Guarantee no horizontal overflow at 320px. */
@media (max-width: 360px) {
  .hero, .level { padding-left: 12px; padding-right: 12px; }
  .panel { padding: 12px; }
  .level-rail { padding: 0 12px; gap: 5px; }
  .segmented, .button-row { gap: 6px; }
  .segmented.two button { flex: 1 1 100%; }
  .stat-grid { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  .reveal { opacity: 1; transform: none; transition: none; }
  html { scroll-behavior: auto; }
}

/* ---------- Beautiful-math callouts (additive) ---------- */
.beauty-note {
  margin: 16px 0 0;
  padding: 16px 18px 14px;
  background: var(--accent-soft, #dceeeb);
  border: 1px solid var(--accent-line, #c3ddd7);
  border-left: 4px solid var(--accent, #15746b);
  border-radius: var(--radius, 10px);
}
.beauty-note .beauty-label {
  display: inline-block;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--accent-2, #0f5e57);
  margin-bottom: 6px;
}
.beauty-note h4 {
  margin: 2px 0 8px;
  font-size: 16px;
  color: var(--accent-ink, #134e48);
}
.beauty-note .math-render {
  margin: 4px 0 8px;
  overflow-x: auto;
}
.beauty-note p {
  margin: 0;
  color: var(--ink, #1f2a22);
  font-size: 14px;
  line-height: 1.6;
}
.beauty-note code {
  background: var(--panel, #fbfcf5);
  border: 1px solid var(--accent-line, #c3ddd7);
  border-radius: 5px;
  padding: 1px 5px;
  font-size: 13px;
}

/* ============================================================
   POLISH LAYER (additive, non-destructive): keyboard focus,
   gentle card hover, micro-feedback, narrow-screen hardening.
   Reuses existing class names + the --accent palette only.
   ============================================================ */

/* --- Accessible keyboard focus for the room's custom controls.
   The root stylesheet only rings a / .button / .mission-card, so the
   segmented control, toggles, quiz options, fam tiles, practice cards
   and sliders previously had no visible keyboard focus. --- */
.segmented button:focus-visible,
.toggle:focus-visible,
.quiz-opts button:focus-visible,
.fam-map button:focus-visible,
.practice-card button:focus-visible,
.check-row input:focus-visible,
input[type="range"]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.fam-map button:focus-visible,
.practice-card button:focus-visible {
  border-radius: inherit;
}

/* --- Gentle hover lift on currently-static content cards, reusing the
   translateY(-2px) + accent-border idiom already used by .fam-map. --- */
.analogy-grid article,
.arch-grid article {
  transition: border-color .18s ease, transform .18s ease, box-shadow .18s ease;
}
.analogy-grid article:hover,
.arch-grid article:hover {
  border-color: var(--accent-line);
  transform: translateY(-2px);
}

.practice-card { transition: border-color .18s ease, transform .18s ease, box-shadow .18s ease; }
.practice-card:hover { border-color: var(--accent-line); transform: translateY(-2px); }
.practice-card.open { border-color: var(--accent-line); transform: none; }
.practice-card button { transition: color .15s ease; }
.practice-card button:hover { color: var(--accent-ink); }

/* Math cards get a whisper of depth on hover without moving (they sit
   beside live canvases, so keep them still, only the shadow warms). */
.math-card { transition: box-shadow .2s ease, border-color .2s ease; }
.math-card:not(.compact):hover { border-color: var(--accent-line); }

/* The callout boxes already carry an accent edge; soften their arrival. */
.example-box { transition: box-shadow .2s ease; }

/* --- Micro-feedback: quiz option press + narration entrance ease. --- */
.quiz-opts button:active:not(:disabled) { transform: translateY(1px); }
.quiz-opts button { transition: border-color .15s ease, background .2s ease, color .2s ease, transform .08s ease; }
.quiz-feedback { transition: color .2s ease; }
.narration { transition: background .25s ease, border-color .25s ease, color .25s ease; }
.stat-grid div { transition: border-color .18s ease; }
.stat-grid strong { font-variant-numeric: tabular-nums; }

/* --- Narrow-screen hardening for wide media that can overflow.
   Defensive only; complements the existing responsive cascade. --- */
@media (max-width: 480px) {
  .math-render { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .code-block  { -webkit-overflow-scrolling: touch; }
  .quiz-opts button { padding: 10px 12px; }
  .fam-map { gap: 10px; }
}

/* --- Respect reduced-motion: disable every transform/transition added
   above (mirrors the room's existing reduced-motion guard). --- */
@media (prefers-reduced-motion: reduce) {
  .analogy-grid article,
  .arch-grid article,
  .practice-card,
  .practice-card button,
  .math-card,
  .example-box,
  .quiz-opts button,
  .quiz-feedback,
  .narration,
  .stat-grid div { transition: none; }
  .analogy-grid article:hover,
  .arch-grid article:hover,
  .practice-card:hover,
  .quiz-opts button:active:not(:disabled) { transform: none; }
}
