/* Attention Arcade (Mission 04): self-contained module stylesheet.
   Inherits the shared Neuronauts design tokens, then extends with the
   sage "aim the attention beam" identity. */
@import url("../styles.css");

:root {
  --accent: #4f7d39;          /* sage accent */
  --accent-soft: #e8efdd;
  --accent-ink: #243a13;
  --beam: #0e7c8a;
  --beam-2: #15856f;
  --radius: 10px;
  --max: 1180px;
  --rail-w: 168px;
}

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

/* ---------- topbar / nav (module-local, overrides shared flex topbar) ---------- */
.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; background: var(--accent); font-weight: 900;
}
.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: #dde5cf; }
.scroll-meter span { display: block; width: 0; height: 100%; background: linear-gradient(90deg, var(--accent), var(--green)); }

/* ---------- 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); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.button.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.button.primary:hover { background: var(--accent-ink); }
.button-row { display: flex; gap: 10px; flex-wrap: wrap; }
.note { color: var(--muted); font-size: 13px; }
.muted { color: var(--muted); font-size: 13px; }
.hint { color: var(--accent-ink); background: var(--accent-soft); border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; }

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; }
input[type="range"] { width: 100%; accent-color: var(--accent); padding: 0; }
.inline-control { display: inline-flex; align-items: center; gap: 10px; margin: 0; min-width: min(220px, 100%); flex-wrap: wrap; max-width: 100%; }
.inline-control input[type="range"] { flex: 1 1 120px; min-width: 0; }
.controls-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 12px; }

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; }
#beamCanvas { height: 320px; }
#heatCanvas { height: 420px; }
#headCanvas { height: 400px; }
#attentionCanvas { height: 480px; }
#positionCanvas { height: 280px; }
#kvCanvas { height: 220px; }
@media (max-width: 720px) {
  #heroCanvas, #beamCanvas, #heatCanvas, #headCanvas { height: 300px; }
  #attentionCanvas { height: 560px; }
}

/* ---------- 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-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); }
.token-strip { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.token-strip span {
  border: 1px solid var(--line); border-radius: 8px; background: var(--accent-soft);
  color: var(--accent-ink); padding: 7px 11px; font-weight: 800; font-size: 14px;
}

/* ---------- 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, #f1f5ec 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(--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); }

/* ---------- 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(--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(--muted); }

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

/* ---------- analogy grid (beginner) ---------- */
.analogy-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-top: 18px; }
.analogy-grid article { border: 1px solid var(--line); border-radius: 10px; padding: 16px; background: var(--panel); box-shadow: var(--shadow); }
.analogy-grid p { margin: 0; color: var(--muted); }
.analogy-grid em { color: var(--accent-ink); font-style: normal; font-weight: 800; background: var(--accent-soft); padding: 0 4px; border-radius: 4px; }

/* ---------- beam game ---------- */
.beam-words { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 6px; }
.beam-words button {
  border: 1px solid var(--line); border-radius: 999px; background: #fff; color: var(--ink);
  padding: 8px 16px; font-weight: 800; cursor: pointer; transition: .15s;
}
.beam-words button:hover { border-color: var(--accent); transform: translateY(-1px); }
.beam-words button.active { background: var(--accent); color: #fff; border-color: var(--accent); box-shadow: 0 6px 16px rgba(79, 125, 57,.32); }

/* ---------- QKV cards ---------- */
.qkv-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin: 8px 0 16px; }
.qkv-card { border: 1px solid var(--line); border-radius: 10px; padding: 16px; background: var(--panel); box-shadow: var(--shadow); border-top: 4px solid var(--line); }
.qkv-card.q { border-top-color: var(--accent); }
.qkv-card.k { border-top-color: var(--green); }
.qkv-card.v { border-top-color: var(--amber); }
.qkv-card p { margin: 0; color: var(--muted); }
.qkv-card em { color: var(--ink); font-style: italic; font-weight: 700; }
.match-line { background: #f0f4e8; border: 1px solid var(--line); border-radius: 10px; padding: 14px; }

/* ---------- 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-box { fill: #fff; stroke: var(--line); stroke-width: 1.5; }
.svg-box.x { fill: #e7eddc; }
.svg-box.q { fill: var(--accent-soft); stroke: var(--accent); }
.svg-box.k { fill: #e2f3ee; stroke: var(--green); }
.svg-box.v { fill: #fdf0d6; stroke: var(--amber); }
.svg-box.score { fill: #f0f4e8; }
.svg-box.attn { fill: var(--accent-soft); stroke: var(--accent); }
.svg-box.ffn { fill: #fdf0d6; stroke: var(--amber); }
.svg-box.norm { fill: #e2f3ee; stroke: var(--green); }
.svg-box.out { fill: #e7eddc; }
.svg-lbl { fill: var(--ink); font: 800 12px Inter, system-ui, sans-serif; }
.svg-w { fill: var(--muted); font: 700 11px Inter, system-ui, sans-serif; }
.svg-arrow { stroke: var(--muted); stroke-width: 1.6; }
.svg-arrow.blue { stroke: var(--accent); stroke-width: 2; }
.svg-arrow.svg-dash { stroke-dasharray: 4 4; }
.svg-skip { stroke: var(--rose); stroke-width: 1.8; stroke-dasharray: 5 4; }
.svg-skip-lbl { fill: var(--rose); font: 800 10px Inter, system-ui, sans-serif; }
.svg-box[data-floor].lit { stroke-width: 3; filter: drop-shadow(0 0 6px rgba(79, 125, 57,.5)); }

/* ---------- 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-render {
  padding: 22px 18px; background: #f1f5ec; 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(--muted); }
.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); }

/* ---------- beam runner lab ---------- */
.lab-layout { display: grid; grid-template-columns: 270px 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; }
.scale-row { display: flex; justify-content: space-between; color: var(--muted); font-size: 12px; margin: 6px 0 10px; }
.scale-row strong { color: var(--ink); }
.check-row { display: flex; align-items: center; gap: 8px; font-weight: 700; }
.check-row input { width: auto; }
.lab-panel { min-height: 560px; }

/* ---------- multi-head ---------- */
.segmented { display: flex; flex-wrap: wrap; gap: 8px; }
.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; }
.note-list { display: grid; gap: 12px; margin-top: 14px; }
.note-list.four { grid-template-columns: repeat(2, 1fr); }
.note-list article { border: 1px solid var(--line); border-radius: 8px; padding: 12px; background: #f0f4e8; }
.note-list strong { display: block; color: var(--ink); }
.note-list span { display: block; color: var(--muted); font-size: 13px; }

/* ---------- 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); }

/* ---------- block ---------- */
.block-layout { display: grid; grid-template-columns: 280px 1fr; gap: 22px; align-items: start; }
.block-svg { margin: 0; }
.block-steps { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.block-steps button { border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink); padding: 8px 12px; font-weight: 800; cursor: pointer; }
.block-steps button.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.block-walk { align-self: stretch; }

.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 18px; }
.two-col .panel h4 { margin-top: 0; }

/* ---------- code ---------- */
.code-panel { }
.code-block {
  margin: 0; border-radius: 8px; padding: 16px; background: #0f1b30; color: #dbe7ff;
  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 { color: var(--accent-ink); font-family: "SFMono-Regular", Consolas, monospace; }
.metric { color: var(--accent-ink); font-weight: 850; font-size: 17px; }

/* ---------- 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 ============================
   Layered, mobile-down adaptation. 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.
   Tested mentally at: 1280, 1024, 820, 768, 600, 480, 414, 375, 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 lab/block/hero layouts. */
@media (max-width: 1024px) {
  .lab-layout, .block-layout { grid-template-columns: 1fr; }
  .control-panel { position: static; top: auto; }
}
@media (max-width: 960px) {
  .hero, .two-col { grid-template-columns: 1fr; }
  .analogy-grid, .qkv-cards { grid-template-columns: 1fr; }
  .control-panel { position: static; }
  /* Side-by-side complexity / note grids relax to two then one column. */
}

/* Small tablet / large phone landscape. */
@media (max-width: 820px) {
  .analogy-grid, .qkv-cards { grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 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, .note-list.four { grid-template-columns: 1fr; }
  .practice-grid { grid-template-columns: 1fr; }
  .analogy-grid, .qkv-cards { grid-template-columns: 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; }
}

/* 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); }
  .token-strip span { font-size: 13px; padding: 6px 9px; }
  .beam-words button { padding: 7px 13px; }
  .segmented button, .block-steps button { padding: 7px 10px; font-size: 13px; }
  .panel-title { gap: 8px; }
  .code-block { padding: 12px; font-size: 12px; }
  .practice-card button { padding: 14px; }
}

/* 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, .block-steps, .button-row { gap: 6px; }
  .segmented.two button { flex: 1 1 100%; }
  .metric { font-size: 15px; }
}

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

/* ---------- beauty notes (✦ Beautiful math highlight callouts) ---------- */
.beauty-note {
  margin: 14px 0 0; padding: 14px 16px 15px;
  border: 1px solid var(--line); border-left: 4px solid var(--accent);
  border-radius: 10px;
  background: linear-gradient(180deg, #f4f8ee 0%, var(--accent-soft) 100%);
  box-shadow: var(--shadow);
}
.beauty-note .beauty-label {
  margin: 0 0 8px; font-size: 11px; font-weight: 900; letter-spacing: .08em;
  text-transform: uppercase; color: var(--accent-ink);
}
.beauty-note .beauty-eq {
  margin: 0 0 10px; text-align: center; color: var(--accent-ink); font-size: 1.02rem; overflow-x: auto;
}
.beauty-note p { margin: 0; color: var(--ink); line-height: 1.65; }
.beauty-note p + p { margin-top: 10px; }
@media (max-width: 600px) {
  .beauty-note { padding: 12px 13px; }
  .beauty-note .beauty-eq { font-size: .96rem; }
}

/* attention pipeline (advanced): animated four-stage canvas */
#pipeCanvas { height: 340px; }
@media (max-width: 720px) { #pipeCanvas { height: 380px; } }

/* ============================ micro-interaction polish ============================
   Additive, CSS-only. Reuses existing class names + accent tokens. No layout
   geometry of canvases/grids is altered (only paint: shadow, border-color,
   small translateY). All motion is gated off under prefers-reduced-motion at
   the end of this block. Safe to drop in; nothing here is read by JS. */

/* Soft, consistent hover lift on the room's static content cards. These are
   non-interactive display cards (no JS listeners), so a transform is safe. */
.qkv-card,
.analogy-grid article,
.note-list article,
.example-box {
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
.qkv-card:hover,
.analogy-grid article:hover,
.note-list article:hover {
  transform: translateY(-2px);
  box-shadow: 0 20px 44px rgba(31, 42, 34, .14);
}

/* Panels + math cards: a whisper of elevation on hover ties the page together
   without moving anything (shadow only, no transform, since these can wrap widgets). */
.panel,
.math-card,
.svg-figure {
  transition: box-shadow .2s ease, border-color .2s ease;
}
.math-card:hover,
.svg-figure:hover {
  box-shadow: 0 22px 48px rgba(31, 42, 34, .15);
}

/* Segmented / block-step toggle buttons: add the same calm accent affordance
   the .button and .beam-words buttons already use, for visual consistency. */
.segmented button,
.block-steps button,
.quiz-opts button {
  transition: border-color .15s ease, background .15s ease, color .15s ease, transform .12s ease, box-shadow .15s ease;
}
.segmented button:hover:not(.active),
.block-steps button:hover:not(.active) {
  border-color: var(--accent);
  color: var(--accent-ink);
}
.segmented button:active,
.block-steps button:active,
.beam-words button:active,
.quiz-opts button:not(:disabled):active {
  transform: translateY(1px);
}
/* Active toggles get the room's signature sage glow (matches .beam-words.active). */
.segmented button.active,
.block-steps button.active {
  box-shadow: 0 6px 16px rgba(79, 125, 57, .28);
}

/* Practice recall cards: gentle hover cue + smooth open, reusing .practice-card. */
.practice-card {
  transition: box-shadow .18s ease, border-color .18s ease, transform .18s ease;
}
.practice-card:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
  box-shadow: 0 18px 40px rgba(31, 42, 34, .12);
}
.practice-card button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

/* Quiz feedback: fade in instead of snapping when it gains .show. */
.quiz-feedback {
  transition: color .2s ease, opacity .2s ease;
}

/* Legend + worked-list readability nudge: tighter rhythm, no reflow risk. */
.legend li { line-height: 1.55; }
.worked-list li { line-height: 1.6; }

/* Token chips (hero + strips) get a subtle interactive shimmer on hover. */
.token-strip span {
  transition: background .15s ease, border-color .15s ease, transform .12s ease;
}
.token-strip span:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}

/* Smoother stagger for reveal-on-scroll: a touch more easing on the existing
   .reveal so long Advanced/Expert sections glide rather than pop. (Same
   property the room already animates, purely a curve refinement.) */
.reveal { transition: opacity .55s cubic-bezier(.22,.61,.36,1), transform .55s cubic-bezier(.22,.61,.36,1); }

/* ---------- responsive hardening for wide media ---------- */
/* Keep the dark code block from forcing horizontal page scroll on tiny phones
   (root already sets overflow-x; this softens the inner padding/scroll feel). */
.code-block { overflow-x: auto; scrollbar-width: thin; }
/* On narrow viewports, let the two-pane block/lab walkthroughs breathe and
   never overflow - reinforces the existing 1024/960 collapses at edge widths. */
@media (max-width: 1024px) {
  .block-walk, .lab-panel { min-width: 0; }
}
@media (max-width: 600px) {
  .lab-panel { min-height: 0; }
  .qkv-cards, .analogy-grid { gap: 12px; }
}

/* Respect reduced motion: disable every transform/lift introduced above. */
@media (prefers-reduced-motion: reduce) {
  .qkv-card, .analogy-grid article, .note-list article,
  .panel, .math-card, .svg-figure, .practice-card,
  .segmented button, .block-steps button, .quiz-opts button,
  .token-strip span, .quiz-feedback {
    transition: none;
  }
  .qkv-card:hover, .analogy-grid article:hover, .note-list article:hover,
  .practice-card:hover, .token-strip span:hover,
  .segmented button:active, .block-steps button:active,
  .beam-words button:active, .quiz-opts button:not(:disabled):active {
    transform: none;
  }
}
