/* =====================================================================
   PhilMates — shared design system & slide engine styles
   16-bit console reference aesthetic. Load once per lesson.
   ===================================================================== */

/* Self-hosted so lessons work offline / on restricted networks (no CDN dependency).
   Press Start 2P by CodeMan38, SIL Open Font License 1.1. */
@font-face {
  font-family: 'Press Start 2P';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('assets/fonts/press-start-2p.woff2') format('woff2');
}

:root {
  /* ---- palette (NES/SNES-ish) ---- */
  --bg:        #11131f;
  --panel:     #1d2235;
  --panel-2:   #262c44;
  --ink:       #eef1ff;
  --muted:     #9aa3c7;
  --accent:    #46e07a;   /* progress / "go" green   */
  --accent-2:  #ff6ad5;   /* highlight magenta        */
  --accent-3:  #4cc2ff;   /* info blue                */
  --good:      #46e07a;
  --bad:       #ff5d6c;
  --border:    #050610;
  --shadow:    #00000080;

  --pixel: 'Press Start 2P', system-ui, sans-serif;
  --body:  'Segoe UI', system-ui, -apple-system, sans-serif;

  --stage-max: 1100px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--body);
  font-size: 18px;
  line-height: 1.55;
}

/* image-rendering for retro raster art */
img[src$=".png"], img[data-pixel] { image-rendering: pixelated; }

/* =====================================================================
   App shell (built by the engine around <phil-lesson>)
   ===================================================================== */
.phil-app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  max-width: var(--stage-max);
  margin: 0 auto;
  padding: 10px;
  gap: 10px;
}

/* ---- top bar: title + progress ---- */
.phil-top { display: flex; flex-direction: column; gap: 6px; }
.phil-top__row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.phil-top__right { display: flex; align-items: center; gap: 12px; }
.phil-reset { font-size: 9px; padding: 8px 10px; }
/* LMS packages: a retake is open, so the button stops being a ghost */
.phil-btn--ghost.phil-reset--ready { background: var(--accent-3); color: var(--bg); }
/* LMS packages: when a retake opens, once the lesson is finished */
.phil-notice {
  margin: 0;
  padding: 4px 10px;
  font-size: 14px;
  line-height: 1.4;
  color: var(--ink);
  background: var(--panel);
  border: 2px solid var(--border);
  border-left: 6px solid var(--accent-3);
}
.phil-notice[hidden] { display: none; }

/* narration script is data for the TTS generator, not shown on screen */
phil-narration { display: none; }
.phil-title {
  font-family: var(--pixel);
  font-size: 14px;
  color: var(--accent-2);
  text-shadow: 2px 2px 0 var(--border);
  margin: 0;
  letter-spacing: .5px;
}
/* slide counter + score tally sit together in the top-right; both are status
   text, so they share one look */
.phil-tally, .phil-counter { font-family: var(--pixel); font-size: 9px; color: var(--muted); white-space: nowrap; }
.phil-counter { color: var(--ink); }

/* Progress is a thin strip, not a second bar: the stage is the point of the
   page, and every band above it is height the slide can't use. */
.phil-progress {
  position: relative;
  height: 10px;
  background: var(--panel);
  border: 2px solid var(--border);
  overflow: hidden;
}
.phil-progress__fill {
  height: 100%;
  width: 0%;
  background: repeating-linear-gradient(45deg, var(--accent) 0 6px, #38c466 6px 12px);
  transition: width .25s steps(8);
}

/* ---- stage: holds slides, one visible at a time ---- */
.phil-stage {
  position: relative;
  flex: 1 1 auto;
  background: var(--panel);
  border: 4px solid var(--border);
  box-shadow: inset 0 0 0 2px #ffffff10, 0 6px 0 var(--shadow);
  overflow: hidden;
}

phil-slide {
  position: absolute;
  inset: 0;
  display: none;
  grid-template-columns: 1fr;
  align-content: safe center;          /* vertically center the content block */
  gap: 20px;
  /* The stage is capped at --stage-max, so 4vw on a wide monitor bought
     nothing but a 52px frame around the words. Cap it low. */
  padding: clamp(18px, 2.6vw, 32px);
  overflow: auto;
  animation: phil-in .18s ease-out;
}
phil-slide.is-current { display: grid; }
/* content overflows: pin to top (Chrome ignores `safe` centering and starts mid-scroll) */
phil-slide.is-tall { align-content: start; }
phil-slide.is-tall.has-art { align-items: start; }   /* art slides also center rows — undo that when tall */
phil-slide.has-art { grid-template-columns: 1fr minmax(200px, 340px); align-items: center; }

@keyframes phil-in { from { opacity: 0; transform: translateX(12px); } to { opacity: 1; transform: none; } }

.phil-slide__body { min-width: 0; }
.phil-slide__art {
  display: flex; align-items: center; justify-content: center;
  align-self: stretch;
}
.phil-slide__art img, .phil-slide__art svg { max-width: 100%; height: auto; max-height: 60vh; }

phil-slide h1 { font-family: var(--pixel); font-size: clamp(18px, 3.6vw, 30px); color: var(--accent); line-height: 1.4; margin: 0 0 .55em; text-shadow: 2px 2px 0 var(--border); }
phil-slide h2 { font-family: var(--pixel); font-size: clamp(13px, 2.4vw, 17px); color: var(--accent-3); margin: 1.2em 0 .5em; }
phil-slide p, phil-slide li { max-width: 62ch; font-size: clamp(18px, 2.1vw, 23px); line-height: 1.65; }

/* A diagram in the slide body, as opposed to the portrait in the slot="art"
   column. An explanatory picture — a route, a tree, a stack of layers — needs
   the full text width; the art column is about 46 characters wide and squeezes
   one into illegibility. Use <figure class="phil-figure"> for those, and keep
   slot="art" for scene art and thinker cards.

   Never let the picture carry meaning the prose does not: the alt text and the
   surrounding bullets have to say the same thing, because a diagram is the one
   element a screen-reader user gets nothing from. */
phil-slide .phil-figure { margin: 12px 0; max-width: 100%; }
phil-slide .phil-figure img, phil-slide .phil-figure svg {
  display: block; width: 100%; height: auto; max-height: 44vh;
}
phil-slide .phil-figure figcaption {
  font-size: clamp(15px, 1.3vw, 17px); color: var(--muted); line-height: 1.4; margin-top: 6px; max-width: none;
}

/* Dense widget text. A widget that sets font-size on its own root does NOT get
   it: the rule above is more specific than inheritance, so every <p> and <li>
   inside snaps back to 23px at 1.65. Three widgets shipped oversized that way
   before anyone noticed, because the estimate in check-density.mjs reads markup
   and cannot see it. Put `phil-dense` on the widget host instead.

   The size matches .phil-belief__text below, which is the same projector and
   the same reading distance, and stays above the 15px floor for widget text. */
.phil-dense p, .phil-dense li, .phil-dense label {
  max-width: none; font-size: clamp(16px, 1.5vw, 19px); line-height: 1.35;
}
phil-slide .lead { font-size: clamp(21px, 2.7vw, 28px); line-height: 1.5; color: var(--ink); }
phil-slide .muted { color: var(--muted); }
phil-slide .dream { color: var(--accent-2); font-style: italic; }

/* bullet lists — chunky pixel markers, roomy spacing */
phil-slide ul, phil-slide ol { padding-left: 0; list-style: none; margin: .6em 0; }
phil-slide ul > li, phil-slide ol > li { position: relative; padding-left: 1.6em; margin: .55em 0; }
phil-slide ul > li::before { content: "▸"; position: absolute; left: 0; color: var(--accent-2); }
phil-slide ol { counter-reset: phil-ol; }
phil-slide ol > li { counter-increment: phil-ol; }
phil-slide ol > li::before { content: counter(phil-ol); position: absolute; left: 0; font-family: var(--pixel); font-size: .7em; color: var(--bg); background: var(--accent-3); padding: 2px 5px; top: .15em; }

/* incremental reveal (engine adds .phil-show as you press Next)
   `visibility` matters as much as `opacity` here: with opacity alone the pending
   bullets stay in the accessibility tree, so a screen reader reads the whole
   slide — punchlines included — before the reveal happens, and any control
   inside one is focusable while invisible. visibility:hidden still reserves the
   layout box, so nothing shifts when a step appears. */
.phil-step {
  opacity: 0; visibility: hidden; transform: translateY(10px);
  transition: opacity .25s ease-out, transform .25s ease-out, visibility 0s linear .25s;
}
.phil-step.phil-show { opacity: 1; visibility: visible; transform: none; transition-delay: 0s; }
.phil-date { display: inline-block; font-family: var(--pixel); font-size: 9px; color: var(--bg); background: var(--accent-3); padding: 4px 6px; margin-bottom: 10px; }

/* ---- bottom bar: navigation ---- */
.phil-bottom { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.phil-nav { display: flex; gap: 10px; }

/* ---- narrated player (only in lessons with <phil-narration>) ---- */
.phil-player { align-items: center; gap: 6px; }
/* wide enough for its longest label, so the bar doesn't shift as it changes */
.phil-player__play { min-width: 14em; text-align: center; }
.phil-player__extra { padding: 12px 10px; }
.phil-player__extra[aria-pressed="false"] { color: var(--muted); text-decoration: line-through; }
/* captions sit between the stage and the controls, never over the slide */
.phil-caption {
  min-height: 3.2em; padding: 8px 14px;
  background: var(--border); color: var(--ink);
  border-left: 4px solid var(--accent-2);
  font-size: clamp(16px, 1.6vw, 19px); line-height: 1.45;
}
/* the closing "For Further Reading" slide: a reference list, set smaller than slide prose */
phil-slide .phil-reading li { max-width: none; font-size: clamp(15px, 1.35vw, 18px); line-height: 1.45; margin: .5em 0; }
.phil-reading a { color: var(--accent-3); }
phil-slide p.phil-ai-note { max-width: none; margin-top: 1.2em; font-size: clamp(14px, 1.2vw, 16px); line-height: 1.45; color: var(--muted); }
/* author and license, on every lesson's opening slide */
phil-slide p.phil-credit { margin-top: 1.4em; font-size: clamp(14px, 1.2vw, 16px); line-height: 1.4; color: var(--muted); }
.phil-credit a { color: var(--accent-3); }
.phil-play-cta { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; margin-top: 1.2em; }
.phil-play-cta[hidden] { display: none; }
phil-slide .phil-play-cta .phil-btn { font-size: 13px; padding: 14px 18px; }
.phil-play-cta .muted { font-size: clamp(15px, 1.4vw, 17px); }

/* =====================================================================
   Focus
   The UA default happens to be visible on this dark theme in Chromium, but it
   varies by browser and sits tight against the 3px black borders. Own it.
   ===================================================================== */
:where(a, button, input, select, textarea, [tabindex]):focus-visible {
  outline: 3px solid var(--accent-3);
  outline-offset: 2px;
}
/* phil-slide gets tabindex="0" when it overflows (so it can be scrolled by
   keyboard). Offset inward — an outset ring would be clipped by the stage. */
phil-slide[tabindex="0"]:focus-visible { outline: 3px solid var(--accent-3); outline-offset: -3px; }

/* Slide headings take focus on navigation so the change is announced and focus
   follows the content. They're tabindex="-1": not operable, not in the tab
   order, so no ring — otherwise every slide title wears a blue box, including
   on first paint. Anything a user can actually tab to keeps its indicator. */
phil-slide :is(h1, h2)[tabindex="-1"]:focus,
phil-slide[tabindex="-1"]:focus { outline: none; }

/* Screen-reader-only: the live region that announces slide changes. */
.phil-sr-only {
  position: absolute; width: 1px; height: 1px;
  margin: -1px; padding: 0; border: 0;
  clip-path: inset(50%); overflow: hidden; white-space: nowrap;
}

/* =====================================================================
   Buttons (chunky pixel)
   ===================================================================== */
.phil-btn, phil-slide button {
  font-family: var(--pixel);
  font-size: 10px;
  color: var(--ink);
  background: var(--panel-2);
  border: 3px solid var(--border);
  box-shadow: 0 4px 0 var(--shadow);
  padding: 12px 14px;
  cursor: pointer;
  transition: transform .04s, box-shadow .04s, background .1s;
  text-align: left;
}
.phil-btn:hover, phil-slide button:hover { background: #313a5e; }
.phil-btn:active, phil-slide button:active { transform: translateY(4px); box-shadow: 0 0 0 var(--shadow); }
.phil-btn:disabled { opacity: .5; cursor: default; transform: none; box-shadow: 0 4px 0 var(--shadow); }
.phil-btn--primary { background: var(--accent-3); color: var(--bg); }
.phil-btn--ghost { background: transparent; }
.phil-btn--danger { background: var(--bad); color: var(--bg); }

/* confirmation modal */
.phil-modal { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; background: #000000aa; }
.phil-modal__box { max-width: 440px; margin: 16px; padding: 24px; background: var(--panel); border: 4px solid var(--border); box-shadow: 0 8px 0 var(--shadow); }
.phil-modal__title { font-family: var(--pixel); font-size: 13px; color: var(--accent-2); margin: 0 0 12px; }
.phil-modal__box p { font-size: 16px; line-height: 1.5; }
.phil-modal__actions { display: flex; gap: 12px; justify-content: flex-end; margin-top: 20px; }

/* ---------------------------------------------------------------------
   Un-upgraded widgets.

   A <phil-*> element whose class never registered is just an inline box,
   so the browser dumps its authored children onto the slide as loose run-on
   text and drops the prompt entirely (it lives in an attribute). That is what
   a stale cached phil-core.js looks like — the lesson references a widget the
   cached engine has never heard of.

   Modules are deferred, so every widget is briefly undefined on a normal load.
   Hide the raw children immediately (no flash, content just appears a moment
   later), but hold the warning back 3s so it only ever shows when the engine
   genuinely didn't arrive. Bump the ?v= on the engine URL when adding a widget.

   TWO selector groups, because there are two different failures.

   The named list catches a dead ENGINE. If phil-core.js itself never arrives
   there is no .phil-slide__body — the engine builds that — so a selector
   depending on it would match nothing precisely when it is needed most. These
   rules are written against the authored markup and work with no JS at all.

   `.phil-slide__body > :not(:defined)` catches a dead LESSON WIDGET: the engine
   ran, built the slide, and some lesson-local element like <phil-balance> or
   <phil-trial> never registered. Those used to fail silently as an empty box
   with nothing to explain it. Matching the wrapper's direct children is what
   keeps authored inner elements out of it — <phil-choice>, <phil-cond>,
   <phil-statement> and friends are deliberately never registered, and they
   always sit one level deeper inside the widget that consumes them.
   --------------------------------------------------------------------- */
phil-mcq:not(:defined), phil-poll:not(:defined), phil-checkset:not(:defined),
phil-cloze:not(:defined), phil-compare:not(:defined), phil-branch:not(:defined),
phil-beliefs:not(:defined), phil-beliefs-review:not(:defined),
.phil-slide__body > :not(:defined) { display: block; }

phil-mcq:not(:defined) > *, phil-poll:not(:defined) > *,
phil-checkset:not(:defined) > *, phil-cloze:not(:defined) > *,
phil-compare:not(:defined) > *, phil-branch:not(:defined) > *,
phil-beliefs:not(:defined) > *, phil-beliefs-review:not(:defined) > *,
.phil-slide__body > :not(:defined) > * { display: none; }

phil-mcq:not(:defined)::after, phil-poll:not(:defined)::after,
phil-checkset:not(:defined)::after, phil-cloze:not(:defined)::after,
phil-compare:not(:defined)::after, phil-branch:not(:defined)::after,
phil-beliefs:not(:defined)::after, phil-beliefs-review:not(:defined)::after,
.phil-slide__body > :not(:defined)::after {
  content: "\26A0 This activity didn't load. Hard-refresh the page \2014 Ctrl+Shift+R (\2318\21E7R on a Mac).";
  display: block;
  visibility: hidden;                       /* ...until the delay below elapses */
  animation: phil-undefined 1ms linear 3s forwards;
  margin: 18px 0;
  padding: 14px 16px;
  background: #3a1620;
  border: 3px solid var(--bad);
  color: var(--bad);
  font-size: .85em;
  line-height: 1.5;
}
@keyframes phil-undefined { to { visibility: visible; } }

/* =====================================================================
   Widgets
   ===================================================================== */
.phil-widget {
  display: block;            /* custom elements default to inline; force block so the card border wraps cleanly */
  margin: 18px 0;
  padding: 18px;
  background: var(--panel-2);
  border: 3px solid var(--border);
  box-shadow: 0 5px 0 var(--shadow);
}
.phil-widget__prompt { font-weight: 700; margin: 0 0 14px; }
.phil-widget__prompt::before { content: "▸ "; color: var(--accent-2); }

.phil-feedback { margin-top: 14px; padding: 12px; border: 3px solid var(--border); font-size: .95em; display: none; }
.phil-feedback.show { display: block; }
.phil-feedback.good { background: #133a24; color: var(--good); }
.phil-feedback.bad  { background: #3a1620; color: var(--bad); }
.phil-feedback.note { background: #16283a; color: var(--accent-3); }   /* ungraded: recorded, not judged */
.phil-feedback strong { font-family: var(--pixel); font-size: 10px; display: block; margin-bottom: 6px; }

/* MCQ + checkset choices */
.phil-options { display: flex; flex-direction: column; gap: 10px; }
.phil-choice {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px;
  background: var(--panel);
  border: 3px solid var(--border);
  cursor: pointer;
  transition: background .1s;
}
.phil-choice:hover { background: #2b3252; }
.phil-choice input { width: 18px; height: 18px; accent-color: var(--accent-3); flex: none; }
.phil-choice.correct { background: #133a24; border-color: var(--good); }
.phil-choice.wrong   { background: #3a1620; border-color: var(--bad); }
.phil-choice.picked  { background: #16283a; border-color: var(--accent-3); }   /* poll: your position, not a verdict */
/* pointer-events blocks the mouse; the widget's _locked flag blocks the keyboard.
   The input stays enabled (not disabled) so the chosen answer keeps its colour
   and a screen-reader user can still reach it to review what they picked. */
.phil-choice.locked { cursor: default; pointer-events: none; }
/* a wrong option already tried: struck through, and it can't be picked again */
.phil-choice.tried { cursor: not-allowed; }
.phil-choice.tried > span { text-decoration: line-through; }

/* ---- <phil-classify>: a grid of items × columns ---- */
.phil-cl-wrap { overflow-x: auto; }
.phil-cl { border-collapse: collapse; width: 100%; font-size: clamp(15px, 1.35vw, 18px); line-height: 1.35; }
.phil-cl th, .phil-cl td { border: 2px solid var(--border); padding: 0; }
.phil-cl thead th { font-family: var(--pixel); font-size: clamp(9px, .8vw, 11px); line-height: 1.5; color: var(--accent-3);
                    background: var(--panel); padding: 6px 4px; text-align: center; vertical-align: bottom; }
.phil-cl thead th.phil-cl-unsure { color: var(--muted); }
.phil-cl .phil-cl-text { text-align: left; font-weight: 600; padding: 4px 10px 4px 2em; position: relative; background: var(--panel-2); }
.phil-cl td { width: 1%; }   /* radio columns shrink to their headers; the item text takes the rest */
.phil-cl thead th:not(.phil-cl-item-h) { width: 1%; min-width: 64px; }
.phil-cl-cell { display: flex; align-items: center; justify-content: center; min-height: 34px; min-width: 56px; padding: 0 6px; cursor: pointer; }
.phil-cl-cell:hover { background: #2b3252; }
.phil-cl-cell input { width: 20px; height: 20px; accent-color: var(--accent-3); cursor: pointer; }
.phil-cl td.phil-cl-unsure { background: #00000022; }
/* row results: marker + border, never colour alone */
.phil-cl-row.correct .phil-cl-text::before,
.phil-cl-row.wrong .phil-cl-text::before,
.phil-cl-row.missing .phil-cl-text::before { position: absolute; left: .55em; font-weight: bold; }
.phil-cl-row.correct .phil-cl-text::before { content: "✔"; color: var(--good); }
.phil-cl-row.wrong .phil-cl-text::before { content: "✘"; color: var(--bad); }
.phil-cl-row.missing .phil-cl-text::before { content: "?"; color: #ffcf5a; }
.phil-cl-row.correct .phil-cl-text { box-shadow: inset 4px 0 0 var(--good); }
.phil-cl-row.wrong .phil-cl-text { box-shadow: inset 4px 0 0 var(--bad); }
.phil-cl-row.missing .phil-cl-text { box-shadow: inset 4px 0 0 #ffcf5a; }
.phil-classify.is-locked .phil-cl-cell { cursor: default; pointer-events: none; }
.phil-cl-why td { padding: 4px 10px 6px 2em; color: var(--ink); background: var(--panel); font-size: .92em; }
.phil-cl-why[hidden] { display: none; }
.phil-classify > .phil-btn { margin-top: 12px; margin-right: 8px; }
.phil-cl-whybtn[hidden] { display: none; }

/* after a miss: the review link or cooldown under the feedback */
.phil-retry { margin: 10px 0 0; color: var(--ink); font-size: 1em; }
phil-slide .phil-retry__go { margin-left: 6px; padding: 8px 10px; background: var(--accent-3); color: var(--bg); }
.phil-review-return[hidden] { display: none; }
.phil-review-return { background: var(--accent-2); color: var(--bg); }

/* Cloze */
.phil-cloze { line-height: 2.9; font-size: clamp(18px, 2.1vw, 23px); }
.phil-cloze .phil-blank {
  display: inline-block;
  vertical-align: baseline;
  line-height: 1.3;
  min-width: 90px;
  font-family: var(--body);
  font-size: .9em;
  color: var(--ink);
  background: var(--panel);
  border: none;
  border-bottom: 3px solid var(--accent-3);
  padding: 3px 8px;
  margin: 0 3px;
  text-align: center;
}
.phil-cloze .phil-blank.correct { border-color: var(--good); color: var(--good); }
.phil-cloze .phil-blank.wrong   { border-color: var(--bad); color: var(--bad); }
select.phil-blank { cursor: pointer; }

/* Branch */
.phil-branch .phil-options { gap: 12px; }
.phil-branch .phil-btn { font-size: 11px; }
.phil-back { margin-top: 22px; align-self: start; }

/* =====================================================================
   <phil-compare> — reusable side-by-side comparison (teaching layout)
   ===================================================================== */
.phil-compare { position: relative; display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: stretch; margin: 20px 0; }
phil-side {
  display: flex; flex-direction: column; gap: 6px;
  background: var(--panel-2); border: 3px solid var(--border);
  box-shadow: 0 5px 0 var(--shadow); padding: 14px 14px 0;
}
.phil-side__head { display: flex; flex-direction: column; gap: 6px; margin-bottom: 2px; }
.phil-side__label { font-family: var(--pixel); font-size: clamp(11px, 1.1vw, 13px); line-height: 1.5; color: var(--accent-3); }
.phil-side__tag { align-self: flex-start; font-family: var(--pixel); font-size: 9px; color: var(--bg); background: var(--accent-3); padding: 3px 6px; }
phil-side:nth-of-type(2) .phil-side__label { color: var(--accent); }
phil-side:nth-of-type(2) .phil-side__tag { background: var(--accent); }
phil-side p { font-size: clamp(16px, 1.4vw, 20px); line-height: 1.45; max-width: none; margin: .2em 0; }
phil-side .cake, phil-side .case { margin-top: auto; margin-bottom: 14px; background: var(--panel); border-left: 4px solid var(--accent-2); padding: 9px 11px; }
phil-side .cake::before { content: "🍰 "; }
phil-side .case { border-left-color: var(--accent-3); }
phil-side .case::before { content: "🩺 "; }

/* ---- thinker card: stands in for a portrait of a real thinker ---- */
.phil-thinker {
  --phil-thinker-accent: var(--accent-3);
  display: block; width: 100%; max-width: 340px;
  background: var(--panel-2); border: 4px solid var(--border);
  box-shadow: inset 0 0 0 3px var(--phil-thinker-accent), 0 6px 0 var(--shadow);
  padding: 12px;
}
.phil-thinker__head { text-align: center; }
.phil-slide__art .phil-thinker__img, .phil-thinker__img {
  display: block; width: 100%; height: auto; max-height: 30vh; object-fit: cover; aspect-ratio: 1;
  border: 3px solid var(--border); image-rendering: pixelated; margin: 0 auto 10px;
}
phil-slide .phil-thinker p { max-width: none; margin: 0 0 6px; }
phil-slide .phil-thinker .phil-thinker__name {
  font-family: var(--pixel); font-size: clamp(11px, 1vw, 14px); line-height: 1.5;
  color: var(--phil-thinker-accent); text-shadow: 2px 2px 0 var(--border); margin-bottom: 4px;
}
phil-slide .phil-thinker .phil-thinker__meta { font-size: clamp(14px, 1.15vw, 16px); line-height: 1.35; color: var(--muted); }
.phil-thinker__text { border-top: 2px solid var(--border); margin-top: 8px; padding-top: 8px; }
phil-slide .phil-thinker__text p { font-size: clamp(15px, 1.3vw, 18px); line-height: 1.4; font-weight: 600; color: var(--ink); }
phil-slide .phil-thinker blockquote {
  margin: 8px 0 0; padding: 6px 10px; border-left: 4px solid var(--phil-thinker-accent);
  background: var(--panel); font-style: italic; font-size: clamp(15px, 1.25vw, 17px); line-height: 1.4; color: var(--ink);
}

/* VS badge — the two principle colors meeting, with a dark center plate */
.phil-vs {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: 56px; height: 56px; border-radius: 50%;
  display: grid; place-items: center;
  font-family: var(--pixel); font-size: 13px; color: var(--ink);
  border: 3px solid var(--border); box-shadow: 0 4px 0 var(--shadow); z-index: 2;
  background:
    radial-gradient(circle at center, var(--bg) 0 15px, transparent 16px),
    linear-gradient(90deg, var(--accent-2) 0 50%, var(--accent) 50% 100%);
}

/* "one side, then the other" entrance, replays whenever the slide is shown */
phil-slide.is-current .phil-compare > phil-side { animation: .4s ease-out both; }
phil-slide.is-current .phil-compare > phil-side:nth-of-type(1) { animation-name: phil-side-l; animation-delay: .05s; }
phil-slide.is-current .phil-compare > phil-side:nth-of-type(2) { animation-name: phil-side-r; animation-delay: .45s; }
phil-slide.is-current .phil-vs { animation: phil-vs-pop .42s ease-out .3s both; }
@keyframes phil-side-l { from { opacity: 0; transform: translateX(-28px); } to { opacity: 1; transform: none; } }
@keyframes phil-side-r { from { opacity: 0; transform: translateX(28px); } to { opacity: 1; transform: none; } }
@keyframes phil-vs-pop {
  0%   { opacity: 0; transform: translate(-50%, -50%) scale(0); }
  70%  { opacity: 1; transform: translate(-50%, -50%) scale(1.18); }
  100% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

@media (max-width: 760px) {
  .phil-compare { grid-template-columns: 1fr; }
  .phil-vs { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  phil-slide.is-current .phil-compare > phil-side,
  phil-slide.is-current .phil-vs { animation: none; }
  /* Everything else that moves: the slide-in on every navigation, the step
     fade-ups, and the completion toast. Steps still need their visibility flip
     to be instant rather than absent. */
  phil-slide { animation: none; }
  .phil-step { transition: none; transform: none; }
  .phil-toast { transition: none; }
}

/* =====================================================================
   <phil-beliefs> / <phil-beliefs-review> — Likert belief probe
   ===================================================================== */
.phil-beliefs.phil-widget { padding: 14px 16px; }
.phil-beliefs .phil-widget__prompt { margin-bottom: 8px; }
.phil-belief { margin: 12px 0 0; }
.phil-belief__text { font-size: clamp(16px, 1.5vw, 19px); font-weight: 600; line-height: 1.35; margin: 0 0 6px; }
.phil-belief__then { font-size: 13px; color: var(--muted); margin: 0 0 5px; }
.phil-scale-legend { display: flex; justify-content: space-between; max-width: 540px; font-size: 12px; color: var(--muted); margin: 0 0 8px; }
.phil-scale { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; max-width: 540px; }
.phil-scale button {
  font-family: var(--pixel); font-size: 12px; color: var(--ink);
  background: var(--panel); border: 3px solid var(--border); box-shadow: 0 3px 0 var(--shadow);
  padding: 9px 0; cursor: pointer; transition: background .1s;
}
.phil-scale button:hover { background: #2b3252; }
.phil-scale button:active { transform: translateY(3px); box-shadow: none; }
.phil-scale button.sel { background: var(--accent-3); color: var(--bg); }
.phil-belief__delta { font-size: 13px; margin: 6px 0 0; min-height: 1.1em; color: var(--accent); }
.phil-belief__delta.none { color: var(--muted); }
.phil-belief__submit { margin-top: 16px; }
.phil-belief__status { font-size: 13px; color: var(--muted); margin: 10px 0 0; }
.phil-belief__status.done { color: var(--good); }

/* completion toast */
.phil-toast {
  position: fixed; left: 50%; bottom: 30px; transform: translateX(-50%) translateY(120%);
  background: var(--accent); color: var(--bg);
  font-family: var(--pixel); font-size: 11px;
  padding: 16px 22px; border: 4px solid var(--border); box-shadow: 0 6px 0 var(--shadow);
  transition: transform .3s ease-out; z-index: 50;
}
.phil-toast.show { transform: translateX(-50%) translateY(0); }
.phil-toast__sub { display: block; margin-top: 8px; font-family: var(--body); font-size: 15px; }

/* small screens / projector portrait */
@media (max-width: 760px) {
  phil-slide.has-art { grid-template-columns: 1fr; }
  .phil-slide__art { order: -1; max-height: 32vh; }
  .phil-slide__art img, .phil-slide__art svg { max-height: 32vh; }
  /* A thinker card is taller than a picture, so the 32vh cap would clip it.
     On a phone it goes compact instead: a small image beside the name. */
  .phil-slide__art:has(.phil-thinker) { max-height: none; }
  .phil-thinker { max-width: none; padding: 10px; }
  .phil-thinker__head {
    display: grid; grid-template-columns: 84px 1fr; column-gap: 12px;
    align-items: center; text-align: left;
  }
  .phil-slide__art .phil-thinker__img, .phil-thinker__img { grid-row: 1 / span 2; width: 84px; max-height: none; margin: 0; }
  phil-slide .phil-thinker .phil-thinker__name { margin: 0; align-self: end; }
  phil-slide .phil-thinker .phil-thinker__meta { align-self: start; }
}

/* =====================================================================
   Short-viewport tier — laptops (1366x768 minus browser chrome) and
   projectors. Width is plentiful; height is what runs out. Everything that
   isn't the slide gets tighter, and the slide's own frame shrinks too.
   ===================================================================== */
@media (max-height: 820px) {
  .phil-app { padding: 6px; gap: 6px; }
  .phil-top { gap: 4px; }
  .phil-progress { height: 8px; }
  .phil-reset { padding: 7px 9px; }
  .phil-sfx { padding: 6px 8px; }
  .phil-caption { min-height: 2.9em; padding: 6px 12px; }
  .phil-bottom .phil-btn { padding: 9px 13px; }
  phil-slide { padding: clamp(14px, 2vw, 22px); gap: 14px; }
  phil-slide h1 { font-size: clamp(16px, 3vw, 24px); margin-bottom: .45em; }
  .phil-slide__art img, .phil-slide__art svg { max-height: 52vh; }
  phil-slide .phil-figure img, phil-slide .phil-figure svg { max-height: 40vh; }
}

/* =====================================================================
   Phone tier — mobile-only refinements. Everything here lives inside a
   max-width query, so the desktop / projector layout is untouched.
   ===================================================================== */
@media (max-width: 600px) {
  /* base font down one notch so clamped content sizes settle smaller */
  html, body { font-size: 16px; }

  /* dvh tracks the *visible* viewport (excludes the mobile URL bar), so the
     bottom nav stays on-screen and reachable. vh would push it under the bar. */
  .phil-app { height: 100dvh; padding: 8px; gap: 8px; }

  /* let the title wrap to its own line instead of crushing the controls */
  .phil-top__row { flex-wrap: wrap; row-gap: 6px; }
  /* counter + tally + two buttons share one 374px line: tighter gap and text,
     and labels never break (a wrapped Reset costs a whole extra row) */
  .phil-top__right { gap: 8px; flex-wrap: wrap; row-gap: 6px; }
  .phil-reset { white-space: nowrap; }
  .phil-title { font-size: 12px; }
  .phil-tally, .phil-counter { font-size: 8px; }
  .phil-reset { font-size: 8px; padding: 7px 8px; }

  /* tighter slide padding reclaims horizontal room for text */
  phil-slide { padding: 16px; gap: 16px; }
  phil-slide h1 { line-height: 1.5; }

  /* full-width, thumb-reachable bottom navigation */
  .phil-bottom { gap: 8px; }
  .phil-nav { flex: 1; }
  .phil-nav .phil-btn { flex: 1; text-align: center; }
  /* the player takes its own row above Back and Next */
  .phil-bottom:has(.phil-player) { flex-wrap: wrap; }
  .phil-player { order: -1; flex-basis: 100%; }
  .phil-nav .phil-player__extra { flex: 0 0 auto; }
  .phil-player__play { min-width: 0; }
  .phil-caption { font-size: 15px; }

  /* modal hugs the screen edges */
  .phil-modal__box { margin: 12px; }

  /* belief Likert: keep 5 columns but shrink so they don't overflow */
  .phil-scale button { font-size: 10px; padding: 10px 0; }
}
