/* ==========================================================================
   Organizational Architecture — learning site styles
   Design tokens first; components after. No external fonts or assets.
   ========================================================================== */

:root {
  /* Palette (from the project brief) */
  --navy: #172B4D;
  --navy-deep: #0D1B2A;
  --paper: #FAF8F2;
  --amber: #F0A34A;
  --blue-soft: #DCE7F5;
  --gray: #687386;
  --green: #287A55;
  --red: #B54747;

  /* Derived tokens */
  --ink: var(--navy-deep);
  --ink-2: #2A3B57;
  --muted: #566074;            /* darker than --gray so small text passes WCAG AA on paper */
  --line: #E4DFD2;
  --line-strong: #CFC8B6;
  --control-line: #8A8370;      /* borders of interactive controls: >= 3:1 on white, paper and blue-wash (WCAG 1.4.11) */
  --card: #FFFFFF;
  --amber-wash: #FDF1E1;
  --amber-deep: #8A5410;       /* amber-family text colour with AA contrast */
  --green-wash: #E6F2EC;
  --red-wash: #F8E9E9;
  --blue-wash: #EEF3FA;

  --font-display: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, "Times New Roman", serif;
  --font-body: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --font-mono: "Cascadia Mono", Consolas, "SF Mono", Menlo, monospace;

  --step--1: clamp(0.84rem, 0.82rem + 0.1vw, 0.9rem);
  --step-0: clamp(1rem, 0.97rem + 0.15vw, 1.08rem);
  --step-1: clamp(1.15rem, 1.08rem + 0.35vw, 1.35rem);
  --step-2: clamp(1.4rem, 1.25rem + 0.7vw, 1.85rem);
  --step-3: clamp(1.8rem, 1.5rem + 1.4vw, 2.7rem);
  --step-4: clamp(2.3rem, 1.8rem + 2.6vw, 4rem);

  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(13, 27, 42, .06), 0 8px 24px -12px rgba(13, 27, 42, .18);
  --shadow-lg: 0 2px 4px rgba(13, 27, 42, .06), 0 24px 48px -20px rgba(13, 27, 42, .28);
  --ease: cubic-bezier(.2, .7, .2, 1);
  --dur: 320ms;

  --topbar-h: 64px;
  --sidebar-w: 292px;
  --measure: none;          /* text fills its container; set e.g. 68ch to restore a narrower reading width */
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--step-0);
  line-height: 1.6;
  text-rendering: optimizeLegibility;
}
img, svg { max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--navy); text-underline-offset: 3px; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }
h1, h2, h3, h4 { font-family: var(--font-display); font-weight: 600; line-height: 1.15; letter-spacing: -0.01em; color: var(--navy-deep); margin: 0 0 .5em; }
p { margin: 0 0 1em; }
strong { font-weight: 650; }

:focus-visible { outline: 3px solid var(--navy); outline-offset: 2px; box-shadow: 0 0 0 7px var(--amber); border-radius: 6px; }
/* Headings receive focus programmatically after navigation (for screen readers); no ring needed. */
h1[tabindex="-1"]:focus, h2[tabindex="-1"]:focus, legend[tabindex="-1"]:focus, main:focus { outline: none; }
.skip-link { position: absolute; left: 12px; top: -60px; z-index: 100; background: var(--navy); color: #fff; padding: 10px 14px; border-radius: 8px; }
.skip-link:focus { top: 12px; }
.sr-only { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.noscript { padding: 2rem; text-align: center; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 40;
  height: var(--topbar-h);
  display: flex; align-items: center; gap: 12px;
  padding: 0 20px;
  background: rgba(250, 248, 242, .92);
  backdrop-filter: saturate(1.2) blur(8px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; color: var(--ink); min-width: 0; }
.brand-mark {
  flex: none; width: 36px; height: 36px; border-radius: 10px;
  display: grid; place-items: center;
  background: var(--navy); color: #fff;
  font-family: var(--font-display); font-weight: 700; font-size: 1.05rem;
  box-shadow: inset 0 -3px 0 var(--amber);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.brand-text strong { font-family: var(--font-display); font-size: 1.05rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-text span { font-size: .78rem; color: var(--muted); }
.topbar-actions { margin-left: auto; display: flex; gap: 8px; }

.icon-btn {
  display: inline-grid; place-items: center;
  width: 40px; height: 40px; border-radius: 10px;
  border: 1px solid transparent; background: transparent; color: var(--navy); cursor: pointer;
}
.icon-btn:hover { background: var(--blue-wash); }
.pill-btn {
  display: inline-flex; align-items: center; gap: 8px;
  height: 38px; padding: 0 14px; border-radius: 999px;
  border: 1px solid var(--line-strong); background: var(--card); color: var(--navy);
  font-size: .9rem; font-weight: 600; cursor: pointer;
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.pill-btn:hover { border-color: var(--navy); }
.pill-btn[aria-pressed="true"] { background: var(--navy); color: #fff; border-color: var(--navy); }
.pill-btn.small { height: 32px; padding: 0 12px; font-size: .82rem; }
.menu-btn { display: none; }
.link-btn { background: none; border: 0; padding: 6px 0; color: var(--muted); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; font-size: .88rem; }
.link-btn:hover { color: var(--red); }

/* ---------- Shell & sidebar ---------- */
.shell { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: calc(100vh - var(--topbar-h)); }
.sidebar {
  position: sticky; top: var(--topbar-h); align-self: start;
  height: calc(100vh - var(--topbar-h)); overflow-y: auto;
  padding: 22px 16px 24px 20px;
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 18px;
}
.sidebar-progress { padding: 16px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
.sp-label { display: flex; justify-content: space-between; align-items: baseline; font-size: .85rem; color: var(--muted); margin-bottom: 8px; }
.sp-label strong { color: var(--ink); font-size: 1rem; }
.bar { height: 8px; background: var(--blue-soft); border-radius: 99px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--amber); border-radius: 99px; transition: width 600ms var(--ease); }

.nav-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.nav-group { margin: 14px 0 4px; padding: 0 10px; font-size: .72rem; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); font-weight: 650; }
.nav-item a {
  display: grid; grid-template-columns: 28px 1fr; gap: 10px; align-items: center;
  padding: 9px 10px; border-radius: 10px;
  text-decoration: none; color: var(--ink-2); line-height: 1.3;
}
.nav-item a:hover { background: var(--blue-wash); }
.nav-item a[aria-current="page"] { background: var(--navy); color: #fff; }
.nav-item a[aria-current="page"] .nav-meta { color: #C9D4E6; }
.nav-title { font-weight: 600; font-size: .93rem; }
.nav-meta { display: block; font-size: .76rem; color: var(--muted); font-weight: 400; }
.status-dot {
  width: 26px; height: 26px; border-radius: 50%;
  display: grid; place-items: center;
  border: 1.5px solid var(--line-strong); background: var(--card);
  font-size: .75rem; font-weight: 700; color: var(--muted);
}
.status-dot.done { background: var(--green); border-color: var(--green); color: #fff; }
.status-dot.current { border-color: var(--amber); box-shadow: 0 0 0 3px var(--amber-wash); color: var(--navy); }
[aria-current="page"] .status-dot { border-color: #fff; }
.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 6px; padding: 0 10px; font-size: .88rem; }
.nav-sub { color: var(--ink-2); }
.scrim { position: fixed; inset: var(--topbar-h) 0 0 0; background: rgba(13, 27, 42, .35); z-index: 30; }

main { min-width: 0; outline: none; }
.view { padding: clamp(20px, 4vw, 56px) clamp(16px, 4vw, 56px) 96px; max-width: 1080px; margin: 0 auto; }

/* ---------- Generic UI ---------- */
.eyebrow { font-size: .74rem; letter-spacing: .14em; text-transform: uppercase; font-weight: 700; color: var(--amber-deep); margin: 0 0 .6rem; }
.lede { font-size: var(--step-1); color: var(--ink-2); max-width: var(--measure); line-height: 1.55; }
.muted { color: var(--muted); }
.small { font-size: var(--step--1); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 46px; padding: 0 22px; border-radius: 12px;
  border: 1.5px solid var(--navy); background: var(--navy); color: #fff;
  font-weight: 650; font-size: .98rem; text-decoration: none; cursor: pointer;
  transition: transform 160ms var(--ease), background var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.btn:hover { background: var(--navy-deep); box-shadow: var(--shadow); }
.btn:active { transform: translateY(1px); }
.btn.accent { background: var(--amber); border-color: var(--amber); color: var(--navy-deep); }
.btn.accent:hover { background: #E8953A; }
.btn.ghost { background: transparent; color: var(--navy); border-color: var(--line-strong); }
.btn.ghost:hover { border-color: var(--navy); background: var(--card); box-shadow: none; }
.btn.danger { background: var(--red); border-color: var(--red); }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .45; cursor: not-allowed; box-shadow: none; }
.btn .arrow { transition: transform 200ms var(--ease); }
.btn:hover .arrow { transform: translateX(3px); }
.btn-row { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: clamp(18px, 2.4vw, 28px); box-shadow: var(--shadow); }

/* Source chips: provenance is shown in text and icon, not colour alone */
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 14px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: 999px;
  font-size: .78rem; font-weight: 600; line-height: 1.5;
  border: 1px solid var(--line-strong); background: var(--card); color: var(--ink-2);
  text-decoration: none;
}
.chip svg { flex: none; }
.chip.tb { border-color: var(--navy); color: var(--navy); }
.chip.ext { background: var(--blue-wash); border-color: #B9CBE4; color: var(--navy); }
.chip.ill { background: var(--amber-wash); border-color: #EBC48F; color: var(--amber-deep); }
.chip.unv { border-style: dashed; color: var(--red); border-color: var(--red); }
a.chip:hover { text-decoration: underline; }

.tag-illustrative { display: inline-flex; align-items: center; gap: 6px; font-size: .74rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--amber-deep); background: var(--amber-wash); padding: 4px 10px; border-radius: 6px; }
.tag-textbook { display: inline-flex; align-items: center; gap: 6px; font-size: .74rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--navy); background: var(--blue-soft); padding: 4px 10px; border-radius: 6px; }
.tag-external { display: inline-flex; align-items: center; gap: 6px; font-size: .74rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--navy); background: var(--blue-wash); border: 1px solid #B9CBE4; padding: 3px 10px; border-radius: 6px; }

/* ---------- Landing ---------- */
.hero { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: clamp(24px, 4vw, 56px); align-items: center; padding: clamp(8px, 2vw, 24px) 0 clamp(28px, 4vw, 48px); }
.hero h1 { font-size: var(--step-4); letter-spacing: -0.025em; margin-bottom: .3em; }
.hero h1 em { font-style: italic; color: var(--navy); }
.hook {
  position: relative; margin: 1.4rem 0 1.6rem; padding: 18px 22px 18px 24px;
  background: var(--card); border-radius: var(--radius); border: 1px solid var(--line);
  font-family: var(--font-display); font-size: var(--step-1); line-height: 1.4; color: var(--navy);
}
.hook::before { content: ""; position: absolute; left: 0; top: 14px; bottom: 14px; width: 4px; border-radius: 4px; background: var(--amber); }
.hook small { display: block; margin-top: 8px; font-family: var(--font-body); font-size: .78rem; color: var(--muted); }
.hero-art { background: var(--navy-deep); border-radius: 22px; padding: clamp(18px, 3vw, 30px); box-shadow: var(--shadow-lg); }
.hero-art svg { display: block; width: 100%; height: auto; }

.meta-row { display: flex; flex-wrap: wrap; gap: 10px 22px; margin: 0 0 1.6rem; font-size: .9rem; color: var(--muted); }
.meta-row span { display: inline-flex; align-items: center; gap: 8px; }

.section { margin-top: clamp(36px, 5vw, 64px); }
.section-head { display: flex; justify-content: space-between; align-items: end; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.section-head h2 { font-size: var(--step-3); margin: 0; }

.objectives { counter-reset: obj; list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; }
.objectives li { counter-increment: obj; position: relative; padding: 18px 18px 18px 58px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); line-height: 1.5; }
.objectives li::before { content: counter(obj); position: absolute; left: 18px; top: 18px; width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; background: var(--blue-soft); color: var(--navy); font-weight: 700; font-size: .85rem; }
.objectives .lo-map { display: block; margin-top: 6px; font-size: .78rem; color: var(--muted); }

.lesson-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.lesson-card {
  position: relative; display: flex; flex-direction: column; gap: 10px;
  padding: 22px; min-height: 230px;
  background: var(--card); border: 1px solid var(--line); border-radius: 18px;
  text-decoration: none; color: inherit;
  transition: transform 240ms var(--ease), box-shadow 240ms var(--ease), border-color 240ms var(--ease);
}
.lesson-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); border-color: var(--line-strong); }
.lesson-card .num { font-family: var(--font-display); font-size: 2.4rem; line-height: 1; color: var(--navy); }
.lesson-card h3 { font-size: 1.3rem; margin: 0; }
.lesson-card p { margin: 0; color: var(--ink-2); font-size: .95rem; line-height: 1.5; }
.lesson-card .card-foot { margin-top: auto; display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: .8rem; color: var(--muted); padding-top: 12px; border-top: 1px solid var(--line); }
.state-label { display: inline-flex; align-items: center; gap: 6px; font-weight: 650; }
.state-label.done { color: var(--green); }
.state-label.resume { color: var(--amber-deep); }
.lesson-card.extra { background: var(--blue-wash); border-color: #CBD9EC; }

.scope { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; }
.scope ul { margin: 0; padding-left: 1.1rem; }
.scope li { margin-bottom: 4px; }

.progress-ring { display: flex; align-items: center; gap: 16px; }
.progress-ring svg { flex: none; }
.progress-ring .pr-text strong { display: block; font-family: var(--font-display); font-size: 1.6rem; line-height: 1.1; }

/* ---------- Lesson view ---------- */
.lesson-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px 24px; align-items: end; margin-bottom: 18px; }
.lesson-head h1 { font-size: var(--step-3); margin: 0; }
.crumbs { font-size: .85rem; color: var(--muted); margin-bottom: 6px; }
.crumbs a { color: var(--muted); }

.stepper { display: flex; gap: 6px; flex-wrap: wrap; margin: 0 0 22px; padding: 0; list-style: none; }
.stepper button {
  height: 30px; min-width: 30px; padding: 0 8px; border-radius: 8px;
  border: 1px solid var(--line-strong); background: var(--card); color: var(--muted);
  font-size: .78rem; font-weight: 650; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 4px;
  font-variant-numeric: tabular-nums;
}
.stepper button.seen { border-color: var(--navy); color: var(--navy); }
.stepper button.answered::after { content: "✓"; font-size: .7rem; color: var(--green); }
.stepper button[aria-current="step"] { background: var(--navy); border-color: var(--navy); color: #fff; }
.stepper button[aria-current="step"].answered::after { color: #9FE0BF; }

.stage { position: relative; min-height: 420px; }
.screen { background: var(--card); border: 1px solid var(--line); border-radius: 20px; padding: clamp(22px, 4vw, 48px); box-shadow: var(--shadow); }
.screen.enter { animation: screenIn 420ms var(--ease) both; }
.screen.enter-back { animation: screenInBack 420ms var(--ease) both; }
@keyframes screenIn { from { opacity: 0; transform: translateX(18px); } to { opacity: 1; transform: none; } }
@keyframes screenInBack { from { opacity: 0; transform: translateX(-18px); } to { opacity: 1; transform: none; } }

.screen h2 { font-size: var(--step-3); max-width: none; }
.screen h2.wide { max-width: none; }
.screen h3 { font-size: var(--step-1); margin-top: 1.4em; }
.screen .body { max-width: var(--measure); }
.screen .body p, .screen .body li { color: var(--ink-2); }
.screen .body ul, .screen .body ol { padding-left: 1.2rem; }
.screen .body li { margin-bottom: .5em; }
.kicker { display: inline-flex; align-items: center; gap: 8px; margin-bottom: 14px; }

.question-hero { font-family: var(--font-display); font-size: var(--step-2); line-height: 1.3; color: var(--navy); max-width: var(--measure); margin: 1rem 0 1.2rem; }
.scenario-box { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; margin: 1rem 0; max-width: var(--measure); }
.scenario-box p:last-child { margin-bottom: 0; }

.objective-box { display: flex; gap: 14px; align-items: flex-start; padding: 14px 16px; border-radius: 12px; background: var(--blue-wash); border: 1px solid #CBD9EC; margin-bottom: 1.4rem; max-width: var(--measure); font-size: .95rem; }
.objective-box strong { color: var(--navy); }

.def-list { display: grid; gap: 14px; margin: 1rem 0 0; }
.def { padding: 18px 20px; border-radius: var(--radius); background: var(--paper); border: 1px solid var(--line); border-left: 4px solid var(--navy); }
.def dt { font-family: var(--font-display); font-size: 1.2rem; font-weight: 600; color: var(--navy); margin-bottom: 4px; }
.def dd { margin: 0; color: var(--ink-2); }
.def .chips { margin-top: 10px; }

.econ-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 12px; margin-top: 1rem; }
.econ-cell { padding: 16px 18px; border-radius: 12px; border: 1px solid var(--line); background: var(--paper); }
.econ-cell h3 { font-family: var(--font-body); font-size: .74rem; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); margin: 0 0 6px; display: flex; align-items: center; gap: 8px; }
.econ-cell p { margin: 0; font-size: .95rem; color: var(--ink-2); }
.econ-cell.limits { border-style: dashed; }

.takeaway {
  position: relative; padding: clamp(22px, 3vw, 34px); border-radius: 18px;
  background: var(--navy); color: #fff;
}
.takeaway .takeaway-label { color: var(--amber); font-family: var(--font-body); font-size: .76rem; letter-spacing: .14em; text-transform: uppercase; margin: 0 0 10px; }
.takeaway .big { font-family: var(--font-display); font-size: var(--step-2); line-height: 1.3; margin: 0 0 14px; color: #fff; max-width: none; }
.takeaway ul { margin: 0; padding-left: 1.1rem; color: #DCE5F2; }
.takeaway li { margin-bottom: 6px; }

.lesson-nav { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 20px; }
.lesson-nav .count { font-size: .85rem; color: var(--muted); }

/* ---------- Knowledge checks ---------- */
.check { margin-top: .5rem; }
.check fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
.check legend { font-family: var(--font-display); font-size: var(--step-1); font-weight: 600; color: var(--navy-deep); margin-bottom: 14px; line-height: 1.35; padding: 0; max-width: var(--measure); }
.options { display: grid; gap: 10px; }
.option {
  position: relative; display: grid; grid-template-columns: 28px 1fr; gap: 12px; align-items: start;
  padding: 14px 16px; border-radius: 12px; border: 1.5px solid var(--line-strong); background: var(--card);
  cursor: pointer; transition: border-color 200ms var(--ease), background 200ms var(--ease);
}
.option:hover { border-color: var(--navy); }
.option input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.option .mark { width: 26px; height: 26px; border-radius: 50%; border: 1.5px solid var(--line-strong); display: grid; place-items: center; font-size: .78rem; font-weight: 700; color: var(--muted); background: var(--paper); }
.option input:checked ~ .mark { background: var(--navy); color: #fff; border-color: var(--navy); }
.option:has(input:checked) { border-color: var(--navy); background: var(--blue-wash); }
.option:has(input:focus-visible) { outline: 3px solid var(--navy); outline-offset: 2px; box-shadow: 0 0 0 7px var(--amber); }
.option.locked.is-correct { border-color: var(--green); background: var(--green-wash); }
.option.is-correct .mark { background: var(--green); border-color: var(--green); color: #fff; }
.option.locked.is-wrong { border-color: var(--red); background: var(--red-wash); }
.option.is-wrong .mark { background: var(--red); border-color: var(--red); color: #fff; }
.option.locked { cursor: default; }
.option .opt-feedback { grid-column: 2; font-size: .9rem; color: var(--ink-2); margin-top: 6px; }
.option .opt-feedback strong { display: inline-flex; gap: 6px; align-items: center; }

.check-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-top: 16px; }
.feedback { margin-top: 16px; padding: 16px 18px; border-radius: 12px; border: 1px solid; max-width: var(--measure); }
.feedback.ok { background: var(--green-wash); border-color: #A9D3BF; }
.feedback.no { background: var(--red-wash); border-color: #E3B5B5; }
.feedback .fb-title { font-family: var(--font-body); font-size: 1rem; margin: 0 0 6px; display: flex; align-items: center; gap: 8px; }
.feedback.ok .fb-title { color: var(--green); }
.feedback.no .fb-title { color: var(--red); }
.feedback p { margin: 0 0 .5em; color: var(--ink-2); }
.feedback p:last-child { margin-bottom: 0; }
.feedback .note { font-size: .85rem; color: var(--muted); }

.match-table { display: grid; gap: 10px; }
.match-row { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(180px, 1fr) 28px; gap: 12px; align-items: center; padding: 12px 14px; border: 1.5px solid var(--line-strong); border-radius: 12px; background: var(--card); }
.match-row label { color: var(--ink-2); font-size: .96rem; }
.match-row select { width: 100%; min-height: 42px; padding: 8px 10px; border-radius: 9px; border: 1.5px solid var(--line-strong); background: var(--paper); }
.match-row select:focus-visible { outline: 3px solid var(--navy); outline-offset: 2px; box-shadow: 0 0 0 7px var(--amber); }
.match-row .res { font-weight: 700; text-align: center; }
.match-row.is-correct { border-color: var(--green); background: var(--green-wash); }
.match-row.is-correct .res { color: var(--green); }
.match-row.is-wrong { border-color: var(--red); background: var(--red-wash); }
.match-row.is-wrong .res { color: var(--red); }
.match-row .why { grid-column: 1 / -1; font-size: .88rem; color: var(--ink-2); }

.reveal { border: 1px solid var(--line); border-radius: 12px; background: var(--paper); margin-top: 12px; }
.reveal > summary { list-style: none; cursor: pointer; padding: 14px 18px; font-weight: 650; color: var(--navy); display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.reveal > summary::-webkit-details-marker { display: none; }
.reveal > summary::after { content: "+"; font-size: 1.3rem; line-height: 1; color: var(--navy); transition: transform 200ms var(--ease); }
.reveal[open] > summary::after { transform: rotate(45deg); }
.reveal > summary:focus-visible { outline-offset: -3px; }
.reveal .reveal-body { padding: 0 18px 16px; color: var(--ink-2); }
.reveal .reveal-body p:last-child { margin-bottom: 0; }

/* ---------- Diagrams ---------- */
.diagram { margin: 1rem 0 0; }
.diagram figcaption { font-size: .88rem; color: var(--muted); margin-top: 12px; max-width: var(--measure); }
.diagram svg { display: block; width: 100%; height: auto; }
.diagram svg text { font-family: var(--font-body); }
.diagram .serif { font-family: var(--font-display); }
.diagram-wrap { background: var(--paper); border: 1px solid var(--line); border-radius: 16px; padding: clamp(12px, 2.4vw, 24px); }
.seg { display: inline-flex; flex-wrap: wrap; gap: 6px; padding: 4px; border-radius: 12px; background: var(--blue-wash); border: 1px solid #CBD9EC; margin-bottom: 14px; }
.seg button { border: 0; background: transparent; padding: 8px 14px; border-radius: 9px; font-weight: 600; font-size: .88rem; color: var(--navy); cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--navy); color: #fff; }
.diagram-detail { margin-top: 14px; padding: 16px 18px; border-radius: 12px; background: var(--card); border: 1px solid var(--line); min-height: 88px; }
.diagram-detail h3 { font-family: var(--font-body); font-size: 1rem; margin: 0 0 6px; color: var(--navy); }
.diagram-detail p { margin: 0 0 .4em; color: var(--ink-2); font-size: .95rem; }
.diagram-detail p:last-child { margin-bottom: 0; }

.node { cursor: pointer; }
.node rect, .node circle { transition: fill 240ms var(--ease), stroke 240ms var(--ease); }
.node:focus { outline: none; }
.node:focus-visible rect, .node:focus-visible circle { stroke: var(--amber); stroke-width: 4; }
.node.active rect { fill: var(--navy); }
.node.active text { fill: #fff; }

.venn circle { transition: opacity 400ms var(--ease), fill 400ms var(--ease); }
.flow-step { transition: opacity 420ms var(--ease), transform 420ms var(--ease); }
.flow-step.off { opacity: .14; }

.stepper-ctrl { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.stepper-ctrl .count { font-size: .85rem; color: var(--muted); min-width: 92px; }

.alt-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.alt-card { text-align: left; padding: 18px; border-radius: 14px; border: 1.5px solid var(--line-strong); background: var(--card); cursor: pointer; transition: border-color 200ms var(--ease), transform 200ms var(--ease); }
.alt-card:hover { border-color: var(--navy); transform: translateY(-2px); }
.alt-card[aria-pressed="true"] { border-color: var(--navy); background: var(--blue-wash); box-shadow: inset 0 0 0 1px var(--navy); }
.alt-card .alt-n { font-family: var(--font-display); font-size: 1.6rem; color: var(--navy); line-height: 1; }
.alt-card strong { display: block; margin: 8px 0 4px; font-size: 1rem; }
.alt-card span { font-size: .88rem; color: var(--muted); }
.pro-con { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 12px; }
.pro-con > div { padding: 14px 16px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); }
.pro-con h3 { margin: 0 0 6px; font-size: .78rem; letter-spacing: .1em; text-transform: uppercase; display: flex; align-items: center; gap: 6px; }
.pro-con .pro h3 { color: var(--green); }
.pro-con .con h3 { color: var(--red); }
.pro-con p { margin: 0; font-size: .94rem; color: var(--ink-2); }

.slider-row { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; margin-top: 12px; font-size: .85rem; color: var(--muted); }
input[type="range"] { width: 100%; accent-color: var(--navy); min-height: 32px; }

.compare { display: grid; grid-template-columns: minmax(110px, .8fr) 1fr 1fr; border: 1px solid var(--line); border-radius: 14px; overflow: hidden; background: var(--card); }
.compare > div { padding: 12px 14px; border-top: 1px solid var(--line); font-size: .93rem; color: var(--ink-2); }
.compare .ch { background: var(--navy); color: #fff; font-weight: 650; border-top: 0; font-size: .88rem; }
.compare .ch.firm { background: var(--navy-deep); }
.compare .rh { font-weight: 650; color: var(--navy); background: var(--paper); font-size: .86rem; }

.timeline { list-style: none; margin: 1rem 0 0; padding: 0; position: relative; }
.timeline::before { content: ""; position: absolute; left: 11px; top: 6px; bottom: 6px; width: 2px; background: var(--line-strong); }
.timeline li { position: relative; padding: 0 0 18px 40px; }
.timeline li::before { content: ""; position: absolute; left: 4px; top: 6px; width: 16px; height: 16px; border-radius: 50%; background: var(--card); border: 3px solid var(--navy); }
.timeline li.hl::before { border-color: var(--amber); background: var(--amber); }
.timeline .when { font-size: .78rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--amber-deep); }
.timeline .what { display: block; color: var(--ink-2); }

.flow-q { display: grid; gap: 10px; }
.flow-card { padding: 16px 18px; border-radius: 12px; border: 1.5px solid var(--line-strong); background: var(--card); }
.flow-card.current { border-color: var(--navy); box-shadow: var(--shadow); }
.flow-card.past { opacity: .75; }
.flow-card .q { font-weight: 650; color: var(--navy); margin-bottom: 10px; }
.flow-card .ans { font-size: .86rem; color: var(--muted); }
.flow-card .btn-row .btn { min-height: 38px; padding: 0 16px; font-size: .9rem; }
.flow-result { padding: 16px 18px; border-radius: 12px; }
.flow-result.go { background: var(--green-wash); border: 1px solid #A9D3BF; }
.flow-result.stop { background: var(--amber-wash); border: 1px solid #EBC48F; }
.flow-result h3 { margin: 0 0 4px; font-family: var(--font-body); font-size: 1rem; }

/* Figure 11.1 (HTML so it reflows on small screens) */
.fig111 { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.fenv { width: 100%; padding: 12px; border: 1.5px dashed var(--line-strong); border-radius: 14px; }
.fenv-label { margin: 0 0 10px; text-align: center; font-size: .74rem; letter-spacing: .14em; text-transform: uppercase; font-weight: 700; color: var(--muted); }
.fenv-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.fnode {
  display: flex; flex-direction: column; gap: 4px; align-items: center; text-align: center;
  padding: 12px 14px; border-radius: 12px; border: 1.5px solid var(--navy); background: var(--card); color: var(--navy-deep); cursor: pointer;
  transition: background 220ms var(--ease), color 220ms var(--ease), transform 220ms var(--ease);
}
.fnode strong { font-family: var(--font-display); font-size: 1.08rem; }
.fnode span { font-size: .8rem; color: var(--muted); line-height: 1.35; }
.fnode:hover { transform: translateY(-1px); background: var(--blue-wash); }
.fnode.wide { width: min(100%, 460px); }
.fnode.key { border-width: 2.5px; box-shadow: inset 0 -4px 0 var(--amber); }
.fnode.soft { border-style: dashed; }
.fnode.value { background: var(--blue-soft); }
.fnode[aria-pressed="true"] { background: var(--navy); color: #fff; }
.fnode[aria-pressed="true"] span { color: #C9D4E6; }
.farrow { display: flex; align-items: center; gap: 8px; height: 40px; }
.farrow span { font-size: .72rem; color: var(--muted); letter-spacing: .06em; text-transform: uppercase; }
@media (max-width: 560px) { .fenv-row { grid-template-columns: 1fr; } }

/* Concept map */
.cmap { display: flex; flex-direction: column; align-items: stretch; gap: 0; max-width: 760px; margin: 0 auto; }
.cnode { display: block; padding: 16px 18px 16px 58px; position: relative; border-radius: 14px; border: 1.5px solid var(--line-strong); background: var(--card); text-decoration: none; color: inherit; transition: border-color 200ms var(--ease), transform 200ms var(--ease); }
.cnode:hover { border-color: var(--navy); transform: translateY(-2px); }
.cnode strong { display: block; font-family: var(--font-display); font-size: 1.15rem; color: var(--navy); }
.cnode span:not(.cn) { font-size: .92rem; color: var(--ink-2); }
.cnode .cn { position: absolute; left: 16px; top: 16px; width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; background: var(--blue-soft); color: var(--navy); font-weight: 700; font-size: .85rem; }
.cnode.core { background: var(--navy); border-color: var(--navy); }
.cnode.core strong, .cnode.core span:not(.cn) { color: #fff; }
.cnode.core .cn { background: var(--amber); color: var(--navy-deep); }
.cnode.key { box-shadow: inset 0 -4px 0 var(--amber); }
.cnode.right { margin-left: auto; width: calc(50% - 8px); }
.crow { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.cbranch { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.clink { position: relative; display: flex; justify-content: center; padding: 10px 0; }
.clink::before { content: ""; position: absolute; left: 50%; top: 0; bottom: 0; border-left: 2px solid var(--line-strong); }
.clink span { position: relative; background: var(--paper); border: 1px solid var(--line); border-radius: 999px; padding: 2px 12px; font-size: .78rem; font-weight: 650; color: var(--muted); }
.card .clink span { background: var(--card); }
.clink.right { margin-left: auto; width: calc(50% - 8px); }
@media (max-width: 640px) {
  .crow, .cbranch { grid-template-columns: 1fr; gap: 0; }
  .cbranch .clink:last-child { display: none; }
  .cbranch .clink span { white-space: normal; }
  .crow .cnode + .cnode { margin-top: 16px; }
  .cnode.right, .clink.right { width: 100%; }
}

/* Notes-only window */
body.notes-window .shell { display: block; }
body.notes-window .view { max-width: 720px; padding-top: 28px; }

/* ---------- Review, quiz, references ---------- */
.review-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; }
.review-grid .card h3 { font-size: 1.15rem; }
.review-grid .card p { font-size: .95rem; color: var(--ink-2); margin: 0 0 .6em; }
.terms-tools { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px; }
.terms-tools input[type="search"] { flex: 1 1 220px; min-height: 42px; padding: 0 14px; border-radius: 10px; border: 1.5px solid var(--line-strong); background: var(--card); }
.terms { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.term { padding: 16px 18px; border-radius: 12px; background: var(--card); border: 1px solid var(--line); }
.term h3 { font-family: var(--font-display); font-size: 1.12rem; margin: 0 0 6px; color: var(--navy); }
.term p { margin: 0; font-size: .93rem; color: var(--ink-2); }
.term .pg { display: block; margin-top: 8px; font-size: .78rem; color: var(--muted); }
.terms.hide-defs .term p { display: none; }
.term-reveal { margin-top: 6px; }
.terms:not(.hide-defs) .term-reveal { display: none; }

.quiz-head { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.qcount { font-size: .9rem; color: var(--muted); }
.quiz-progress { display: flex; gap: 4px; margin-bottom: 18px; }
.quiz-progress span { flex: 1; height: 6px; border-radius: 3px; background: var(--blue-soft); }
.quiz-progress span.done { background: var(--navy); }
.quiz-progress span.now { background: var(--amber); }

.score-hero { display: grid; grid-template-columns: auto 1fr; gap: 24px; align-items: center; }
.score-hero .big-score { font-family: var(--font-display); font-size: clamp(3rem, 8vw, 5rem); line-height: 1; color: var(--navy); }
.result-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.result-list li { padding: 14px 16px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); display: grid; grid-template-columns: 28px 1fr; gap: 12px; }
.result-list .ri { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; color: #fff; font-size: .8rem; }
.result-list .ri.ok { background: var(--green); }
.result-list .ri.no { background: var(--red); }
.result-list p { margin: 0 0 .4em; color: var(--ink-2); font-size: .94rem; }

.complete-card { text-align: center; padding: clamp(28px, 5vw, 64px); border-radius: 24px; background: var(--navy-deep); color: #fff; box-shadow: var(--shadow-lg); }
.complete-card h1 { color: #fff; font-size: var(--step-4); }
.complete-card p { color: #C9D4E6; }
.complete-card .seal { width: 96px; height: 96px; margin: 0 auto 18px; }

.ref-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 12px; }
.ref-list li { display: grid; grid-template-columns: 4.25rem minmax(0, 1fr); column-gap: 14px; align-items: start; padding: 16px 18px; border-radius: 12px; background: var(--card); border: 1px solid var(--line); }
.ref-list li .ref-type { grid-column: 1; grid-row: 1 / span 3; }
.ref-list li .ref-type .chip { min-height: 0; padding: 3px 10px; }
.ref-list li > :not(.ref-type) { grid-column: 2; }
.ref-status { justify-self: start; }
.ref-apa { padding-left: 2em; text-indent: -2em; color: var(--ink); }
.ref-note { display: block; margin-top: 6px; font-size: .86rem; color: var(--muted); }
.ref-status { display: inline-flex; align-items: center; gap: 6px; font-size: .78rem; font-weight: 650; margin-top: 8px; }
.ref-status.ok { color: var(--green); }
.ref-status.warn { color: var(--amber-deep); }

table.pagemap { width: 100%; border-collapse: collapse; background: var(--card); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; font-size: .93rem; }
table.pagemap th, table.pagemap td { padding: 12px 14px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
table.pagemap th { background: var(--navy); color: #fff; font-weight: 650; font-size: .85rem; }
table.pagemap tr:last-child td { border-bottom: 0; }
.table-scroll { overflow-x: auto; }

/* ---------- Notes panel ---------- */
.notes-panel {
  position: fixed; right: 0; top: var(--topbar-h); bottom: 0; z-index: 45;
  width: min(440px, 100vw);
  background: #fff; border-left: 1px solid var(--line); box-shadow: -20px 0 40px -24px rgba(13, 27, 42, .35);
  display: flex; flex-direction: column;
  animation: notesIn 320ms var(--ease) both;
}
@keyframes notesIn { from { transform: translateX(24px); opacity: 0; } to { transform: none; opacity: 1; } }
.notes-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; padding: 18px 18px 12px 22px; border-bottom: 1px solid var(--line); background: var(--amber-wash); }
.notes-head h2 { font-size: 1.25rem; margin: 0; }
.notes-head .eyebrow { margin-bottom: 4px; }
.notes-head-actions { display: flex; gap: 6px; align-items: center; }
.notes-body { padding: 18px 22px 40px; overflow-y: auto; font-size: .95rem; }
.notes-body h3 { font-family: var(--font-body); font-size: .76rem; letter-spacing: .12em; text-transform: uppercase; color: var(--amber-deep); margin: 1.4em 0 .4em; }
.notes-body h3:first-child { margin-top: 0; }
.notes-body p, .notes-body li { color: var(--ink-2); }
.notes-body ul { padding-left: 1.1rem; margin: 0 0 1em; }
.notes-body .slide-cue { padding: 10px 12px; border-radius: 10px; background: var(--blue-wash); font-size: .88rem; margin-bottom: 14px; }
body.notes-open .view { margin-right: min(440px, 40vw); }

/* ---------- Presentation mode ---------- */
.present-bar {
  position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); z-index: 60;
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px 8px 8px; border-radius: 999px;
  background: rgba(13, 27, 42, .92); color: #fff; box-shadow: var(--shadow-lg);
}
.present-bar .icon-btn { color: #fff; }
.present-bar .icon-btn:hover { background: rgba(255, 255, 255, .12); }
.present-bar .pill-btn { background: transparent; color: #fff; border-color: rgba(255, 255, 255, .35); }
.present-count { font-variant-numeric: tabular-nums; font-size: .85rem; min-width: 92px; text-align: center; }
.present-track { width: 120px; height: 4px; border-radius: 2px; background: rgba(255, 255, 255, .2); overflow: hidden; }
.present-track span { display: block; height: 100%; width: 0; background: var(--amber); transition: width 400ms var(--ease); }

body.present .topbar, body.present .sidebar, body.present .scrim, body.present .stepper, body.present .lesson-nav, body.present .crumbs, body.present .present-hide { display: none !important; }
body.present .shell { display: block; }
body.present .view { max-width: 1240px; min-height: 100vh; display: flex; flex-direction: column; justify-content: center; padding: 40px clamp(24px, 5vw, 80px) 96px; }
body.present .screen { border: 0; box-shadow: none; background: transparent; padding: 0; }
body.present .stage { min-height: 0; }
body.present { font-size: clamp(1.05rem, 0.9rem + 0.55vw, 1.45rem); }
body.present .screen h2 { font-size: clamp(2.2rem, 1.6rem + 2.4vw, 4rem); }
body.present .lesson-head { margin-bottom: 8px; }
body.present .lesson-head h1 { font-size: 1rem; font-family: var(--font-body); letter-spacing: .12em; text-transform: uppercase; color: var(--muted); font-weight: 650; }
body.present .notes-panel { top: 0; }
body.present.notes-open .view { margin-right: min(440px, 40vw); }

/* ---------- Toast & modal ---------- */
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 80; background: var(--navy-deep); color: #fff; padding: 12px 18px; border-radius: 12px; box-shadow: var(--shadow-lg); font-size: .92rem; max-width: calc(100vw - 32px); }
.modal { border: 0; border-radius: 18px; padding: 26px; max-width: 440px; width: calc(100vw - 32px); box-shadow: var(--shadow-lg); color: var(--ink); }
.modal::backdrop { background: rgba(13, 27, 42, .45); }
.modal h2 { font-size: 1.4rem; }
.modal p { color: var(--ink-2); }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; flex-wrap: wrap; }

.error-box { padding: 24px; border-radius: 14px; background: var(--red-wash); border: 1px solid #E3B5B5; }

/* ---------- Responsive ---------- */
@media (max-width: 1080px) {
  .hero { grid-template-columns: 1fr; }
  .hero-art { max-width: 560px; width: 100%; margin: 0 auto; }
  body.notes-open .view { margin-right: 0; }
}
@media (max-width: 960px) {
  .menu-btn { display: inline-grid; }
  .shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; left: 0; top: var(--topbar-h); bottom: 0; z-index: 35;
    width: min(320px, 88vw); height: auto;
    background: var(--paper); box-shadow: var(--shadow-lg);
    transform: translateX(-105%); transition: transform 320ms var(--ease);
    visibility: hidden;
  }
  body.nav-open .sidebar { transform: none; visibility: visible; }
}
@media (max-width: 640px) {
  .topbar { padding: 0 10px; gap: 6px; }
  .brand-text span { display: none; }
  .brand-text strong { font-size: .95rem; }
  .topbar-actions .pill-btn span { display: none; }
  .topbar-actions .pill-btn { width: 38px; padding: 0; justify-content: center; }
  .view { padding: 18px 16px 110px; }
  .screen { padding: 20px 16px; border-radius: 16px; }
  .compare { grid-template-columns: 1fr; }
  .compare .rh { border-top: 2px solid var(--line-strong); }
  .compare .ch { display: none; }
  .compare .trow:nth-child(2) .rh { border-top: 0; }
  .compare .cell::before { content: attr(data-col); display: block; font-size: .72rem; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); font-weight: 700; }
  .pro-con { grid-template-columns: 1fr; }
  .match-row { grid-template-columns: 1fr 28px; }
  .match-row select { grid-column: 1; }
  .match-row .res { grid-row: 2; grid-column: 2; }
  .score-hero { grid-template-columns: 1fr; }
  .present-track { display: none; }
  .lesson-nav .count { display: none; }
}
@media (min-width: 641px) {
  .compare .cell::before { content: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important; scroll-behavior: auto !important; }
}
body.reduce-motion *, body.reduce-motion *::before, body.reduce-motion *::after { animation-duration: 1ms !important; transition-duration: 1ms !important; }

@media print {
  .topbar, .sidebar, .lesson-nav, .stepper, .notes-panel, .present-bar { display: none !important; }
  .shell { display: block; }
  .screen { box-shadow: none; }
}

.diagram svg.swatch, .diagram .farrow svg { display: inline-block; width: auto; vertical-align: middle; }
.pill-btn, .present-bar .pill-btn { white-space: nowrap; }
body.present .toast { bottom: 88px; }
body.present.notes-open .present-bar { left: calc((100vw - min(440px, 100vw)) / 2); }
@media (max-width: 1080px) { body.present.notes-open .view { margin-right: 0; } }
.byline { margin: -.2rem 0 0; font-size: 1rem; color: var(--ink-2); letter-spacing: .01em; }
.byline strong { color: var(--navy); }
/* Avoid a lone word on the last line of headings and questions */
h1, h2, h3, legend, .question-hero { text-wrap: pretty; }
.hero-head { grid-column: 1 / -1; margin-bottom: -.5rem; }
.hero-head .hook { display: inline-block; max-width: 100%; margin-bottom: 0; }
.hero { row-gap: 18px; }
/* One-sentence prompts use the full card width instead of the paragraph measure */
.check legend, .question-hero { max-width: none; }

/* Touch-friendly targets on phones, tablets and any touch screen */
.tap-link { display: inline-block; padding: 10px 0; }
.result-list p a, .crumbs a { display: inline-block; padding: 6px 0; }
@media (max-width: 960px), (pointer: coarse) {
  .stepper { gap: 8px; }
  .stepper button { height: 44px; min-width: 44px; font-size: .85rem; }
  .seg button { min-height: 44px; }
  .icon-btn { width: 44px; height: 44px; }
  .pill-btn { height: 44px; }
  .pill-btn.small { height: 40px; }
  .reveal > summary { min-height: 48px; }
  .match-row select { min-height: 46px; }
  .link-btn { padding: 10px 0; }
  .nav-item a { padding: 11px 10px; }
}
@media (max-width: 960px), (pointer: coarse) {
  .flow-card .btn-row .btn { min-height: 44px; min-width: 64px; }
  a.chip { min-height: 36px; padding: 6px 12px; }
}
@media (max-width: 640px) {
  .topbar-actions .pill-btn { width: 44px; }
}
/* Labels that replaced headings keep their bold look */
.feedback .fb-title, .takeaway .takeaway-label { font-weight: 700; }
.diagram-detail h3, .flow-result h3, .pro-con h3, .econ-cell h3 { line-height: 1.35; }
.compare .trow { display: contents; }

/* WCAG 2.4.11: keep focused elements clear of the sticky header and the presentation bar */
:focus { scroll-margin-top: calc(var(--topbar-h) + 16px); scroll-margin-bottom: 96px; }

/* WCAG 1.4.11 non-text contrast: control boundaries must reach 3:1 */
.option, .option .mark, .match-row select, .terms-tools input[type="search"],
.stepper button, .btn.ghost, .pill-btn, .alt-card, .flow-card.current .btn.ghost,
.seg, .reveal > summary { border-color: var(--control-line); }
.reveal { border-color: var(--control-line); }
.stepper button.seen { border-color: var(--navy); }
.option:hover, .alt-card:hover, .btn.ghost:hover, .pill-btn:hover { border-color: var(--navy); }
/* Range slider track: give the unfilled part a visible edge */
input[type="range"] { accent-color: var(--navy); }
/* Phones: reference badge sits above the citation instead of beside it */
@media (max-width: 480px) {
  .ref-list li { grid-template-columns: minmax(0, 1fr); row-gap: 8px; }
  .ref-list li .ref-type { grid-row: auto; }
  .ref-list li > :not(.ref-type) { grid-column: 1; }
}

/* ==========================================================================
   Enter page — campus photo slideshow with slow zoom ("Ken Burns") and crossfades
   ========================================================================== */
body.intro-open { overflow: hidden; }
body.intro-open > :not(.intro):not(.toast):not(script) { visibility: hidden; }
.intro { display: none; }
body.intro-open .intro, .intro.leaving {
  display: grid; position: fixed; inset: 0; z-index: 200;
  background: var(--navy-deep); color: #fff; overflow: hidden;
}
.intro.leaving { animation: introOut 700ms var(--ease) forwards; }
@keyframes introOut { to { opacity: 0; transform: scale(1.02); } }

.intro-slides { position: absolute; inset: 0; }
.intro-slide {
  position: absolute; inset: -4%; width: 108%; height: 108%;
  object-fit: cover; opacity: 0;
  transition: opacity 1600ms ease-in-out;
  will-change: transform, opacity;
}
.intro-slide.on { opacity: 1; }
.intro-slide.kb-a.on { animation: kbA 9s linear both; }
.intro-slide.kb-b.on { animation: kbB 9s linear both; }
@keyframes kbA { from { transform: scale(1) translate(0, 0); } to { transform: scale(1.12) translate(-2%, -1.5%); } }
@keyframes kbB { from { transform: scale(1.12) translate(2%, 1%); } to { transform: scale(1) translate(0, 0); } }
.intro.paused .intro-slide.on { animation-play-state: paused; }

/* Navy shade: darker at the bottom-left where the text sits, so contrast stays high on any photo */
.intro-shade {
  position: absolute; inset: 0;
  background:
    linear-gradient(180deg, rgba(13,27,42,.55) 0%, rgba(13,27,42,.35) 35%, rgba(13,27,42,.88) 100%),
    linear-gradient(90deg, rgba(13,27,42,.75) 0%, rgba(13,27,42,.15) 70%);
}

.intro-content {
  position: relative; align-self: end;
  padding: clamp(24px, 6vw, 80px) clamp(20px, 6vw, 96px) clamp(84px, 11vh, 120px);
  max-width: 1100px;
  animation: introIn 1100ms var(--ease) 200ms both;
}
@keyframes introIn { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }
.intro-uni { font-size: clamp(.78rem, .7rem + .3vw, .95rem); letter-spacing: .16em; text-transform: uppercase; font-weight: 700; color: var(--amber); margin: 0 0 .5rem; }
.intro-course { font-size: clamp(.95rem, .85rem + .4vw, 1.15rem); color: #DCE5F2; margin: 0 0 clamp(14px, 3vh, 28px); }
.intro-chapter { display: inline-flex; align-items: center; gap: 12px; margin: 0 0 6px; font-family: var(--font-body); font-weight: 650; font-size: clamp(1rem, .9rem + .5vw, 1.3rem); color: #fff; }
.intro-chapter .num { display: inline-grid; place-items: center; min-width: 2.2em; height: 2.2em; padding: 0 .4em; border-radius: 12px; background: var(--amber); color: var(--navy-deep); font-family: var(--font-display); font-weight: 700; }
.intro h1 { color: #fff; font-size: clamp(2.6rem, 1.6rem + 5.2vw, 6rem); line-height: 1.02; letter-spacing: -0.025em; margin: .15em 0 .35em; text-shadow: 0 2px 24px rgba(0,0,0,.35); }
.intro-people { display: flex; flex-wrap: wrap; gap: 6px 28px; margin: 0 0 clamp(22px, 4vh, 36px); color: #DCE5F2; font-size: clamp(.98rem, .9rem + .35vw, 1.15rem); }
.intro-people strong { color: #fff; font-weight: 650; }
.intro-people span { display: block; font-size: .72em; letter-spacing: .12em; text-transform: uppercase; color: #AFC0D8; font-weight: 650; margin-bottom: 2px; }
.intro-enter { min-height: 56px; padding: 0 30px; font-size: 1.08rem; border-radius: 14px; box-shadow: 0 10px 30px -10px rgba(240,163,74,.65); }
.intro-enter:hover { background: #F5B266; }
.intro-hint { margin: 12px 0 0; font-size: .85rem; color: #AFC0D8; }

.intro-bar { position: absolute; left: 0; right: 0; bottom: 0; display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px clamp(16px, 4vw, 40px); font-size: .74rem; color: #AFC0D8; background: linear-gradient(0deg, rgba(13,27,42,.85), rgba(13,27,42,0)); }
.intro-bar a { color: #DCE5F2; }
.intro-credit { margin: 0; max-width: 72ch; line-height: 1.45; }
.intro-pause { flex: none; display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 12px; border-radius: 999px; border: 1px solid rgba(255,255,255,.45); background: rgba(13,27,42,.4); color: #fff; font-size: .8rem; font-weight: 600; cursor: pointer; }
.intro-pause:hover { background: rgba(255,255,255,.12); }
.intro-dots { display: flex; gap: 6px; margin-top: 18px; }
.intro-dots span { width: 22px; height: 3px; border-radius: 2px; background: rgba(255,255,255,.3); transition: background 400ms; }
.intro-dots span.on { background: var(--amber); }

@media (max-width: 640px) {
  .intro-content { padding-bottom: 120px; }
  .intro-bar { flex-direction: column; align-items: flex-start; }
  .intro-enter { width: 100%; }
}
@media (prefers-reduced-motion: reduce) {
  .intro-slide.on { animation: none !important; }
  .intro-slide { transition-duration: 1ms; }
}
.intro-chapter { letter-spacing: .06em; font-size: clamp(1.1rem, .95rem + .7vw, 1.5rem); }
.intro-chapter .rule { display: inline-block; width: 40px; height: 4px; border-radius: 2px; background: var(--amber); }
/* Credit bar gets its own grid row so it never covers the title or the Enter button */
body.intro-open .intro, .intro.leaving { grid-template-rows: minmax(0, 1fr) auto; overflow-y: auto; }
.intro-content { grid-row: 1; padding-bottom: clamp(20px, 4vh, 40px); }
.intro-bar { position: relative; grid-row: 2; background: rgba(13,27,42,.82); }
.intro-slides, .intro-shade { position: fixed; }
@media (max-width: 640px) {
  .intro-content { padding: 72px 20px 20px; }
  .intro h1 { font-size: clamp(2.3rem, 11vw, 3rem); }
  .intro-people { gap: 10px 24px; }
  .intro-bar { padding: 12px 20px 16px; gap: 10px; }
}
@media (max-height: 560px) {
  .intro-content { padding-top: 24px; }
  .intro h1 { font-size: clamp(2rem, 7vh, 3.4rem); margin: .1em 0 .25em; }
}
.ref-apa, .ref-apa a { overflow-wrap: anywhere; } /* long URLs in citations wrap instead of widening the page */
/* Phones: the page-map table becomes one labelled card per section, so nothing scrolls sideways */
@media (max-width: 640px) {
  table.pagemap, table.pagemap tbody, table.pagemap tr, table.pagemap th, table.pagemap td { display: block; width: 100%; }
  table.pagemap thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  table.pagemap { border: 0; background: transparent; }
  table.pagemap tr { background: var(--card); border: 1px solid var(--line); border-radius: 12px; margin-bottom: 10px; padding: 6px 0; }
  table.pagemap th[scope="row"] { font-size: 1rem; padding: 10px 14px 4px; border-bottom: 0; }
  table.pagemap td { border-bottom: 0; padding: 4px 14px; }
  table.pagemap td::before { content: attr(data-label); display: block; font-size: .72rem; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); font-weight: 700; }
  .table-scroll { overflow: visible; }
}
/* Phones: screens fade up instead of sliding sideways, so the page never widens mid-animation */
@media (max-width: 640px) {
  .screen.enter, .screen.enter-back { animation-name: screenInUp; }
  table.pagemap th, table.pagemap td { overflow-wrap: anywhere; }
}
@keyframes screenInUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
/* Enter-page video: fades in over the photos once it is actually playing */
.intro-video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity 1200ms ease; }
.intro.has-video .intro-video { opacity: 1; }
.intro.has-video .intro-dots { visibility: hidden; }
/* Short dip between video segments */
.intro.has-video .intro-video { transition: opacity 400ms ease; }
.intro.has-video .intro-video.switching { opacity: 0; transition-duration: 250ms; }
/* Once the video is playing, hide the photos underneath so the dip between excerpts goes to navy, not a still photo */
.intro.has-video .intro-slide { opacity: 0 !important; transition: opacity 600ms ease; }

/* ==========================================================================
   Usability fixes (Oct 2026 audit)
   ========================================================================== */
/* Back / Next bar stays at the bottom of the screen while reading */
.sticky-nav {
  position: sticky; bottom: 0; z-index: 20;
  margin: 20px calc(-1 * clamp(16px, 4vw, 56px)) 0;
  padding: 12px clamp(16px, 4vw, 56px) calc(12px + env(safe-area-inset-bottom, 0px));
  background: rgba(250, 248, 242, .94);
  backdrop-filter: blur(6px);
  border-top: 1px solid var(--line);
  box-shadow: 0 -10px 24px -18px rgba(13, 27, 42, .35);
}
.sticky-nav .count { flex: 1; text-align: center; font-size: .86rem; color: var(--muted); }
.sticky-nav .count strong { color: var(--ink-2); font-weight: 650; }
#qHint { text-align: left; }
@media (hover: none), (max-width: 960px) { .key-hint { display: none; } }
@media (max-width: 640px) {
  .sticky-nav { margin-left: -16px; margin-right: -16px; padding-left: 16px; padding-right: 16px; }
  .sticky-nav .count { display: block !important; font-size: .78rem; }
  .sticky-nav .btn { padding: 0 16px; }
}
body.present .sticky-nav { display: none !important; }

/* Overview: the main action sits right under the opening question */
.hero-cta { margin-top: 18px; gap: 12px 18px; }
.hero-cta .muted { max-width: 46ch; }
.meta-row a { color: var(--ink-2); }
.progress-ring { flex-wrap: wrap; }

/* Quiz header: "Start over" lives away from "Next question" */
.quiz-head-side { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
@media (max-width: 640px) { .quiz-head-side { align-items: flex-start; } }

/* Phones: the screen list is one swipeable row instead of two rows of buttons */
@media (max-width: 640px) {
  .stepper { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding-bottom: 4px; margin-left: -16px; margin-right: -16px; padding-left: 16px; padding-right: 16px; }
  .stepper::-webkit-scrollbar { display: none; }
  .stepper li { flex: none; }
}
/* The screen list scrolls sideways on phones; make it the positioning context so the
   absolutely-positioned screen-reader labels inside it stay clipped instead of widening the page. */
.stepper { position: relative; }
.stepper button { position: relative; }

/* ==========================================================================
   Market vs. firm — interactive comparison (Lesson 3)
   ========================================================================== */
.mvf-bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; }
.mvf-instr { margin: 0; }
.mvf-body { display: grid; grid-template-columns: minmax(220px, 0.85fr) minmax(0, 2fr); gap: 16px; align-items: start; }
.mvf-body:has(.mvf-all:not([hidden])) { grid-template-columns: 1fr; }

.mvf-tabs { display: flex; flex-direction: column; gap: 8px; }
.mvf-tab {
  display: grid; grid-template-columns: 28px 1fr; gap: 10px; align-items: center; text-align: left;
  min-height: 52px; padding: 10px 14px; border-radius: 12px;
  border: 1.5px solid var(--control-line); background: var(--card); color: var(--ink-2);
  font-size: .93rem; font-weight: 600; line-height: 1.3; cursor: pointer;
  transition: background 200ms var(--ease), border-color 200ms var(--ease), transform 200ms var(--ease);
}
.mvf-tab:hover { border-color: var(--navy); transform: translateX(2px); }
.mvf-tab[aria-selected="true"] { background: var(--navy); border-color: var(--navy); color: #fff; }
.mvf-num { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 8px; background: var(--blue-soft); color: var(--navy); font-size: .8rem; font-weight: 700; }
.mvf-tab[aria-selected="true"] .mvf-num { background: var(--amber); color: var(--navy-deep); }

.mvf-panel { background: var(--paper); border: 1px solid var(--line); border-radius: 16px; padding: clamp(14px, 2.4vw, 22px); min-width: 0; }
.mvf-panel.mvf-in { animation: mvfIn 320ms var(--ease) both; }
@keyframes mvfIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.mvf-q { display: flex; align-items: center; gap: 12px; margin: 0 0 14px; font-family: var(--font-display); font-size: var(--step-1); font-weight: 600; color: var(--navy-deep); line-height: 1.3; }
.mvf-icon { flex: none; display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; background: var(--navy); color: var(--amber); font-size: 1.15rem; }

.mvf-pair { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); gap: 10px; align-items: stretch; }
.mvf-vs { align-self: center; font-family: var(--font-display); font-style: italic; color: var(--muted); font-size: 1.05rem; }
.mvf-card { position: relative; padding: 16px 16px 14px; border-radius: 14px; border: 1.5px solid; display: flex; flex-direction: column; gap: 6px; }
.mvf-card p { margin: 0; color: var(--ink-2); font-size: .97rem; line-height: 1.5; }
.mvf-card.market { background: var(--blue-wash); border-color: #B9CBE4; }
.mvf-card.firm { background: var(--amber-wash); border-color: #EBC48F; }
.mvf-col { font-family: var(--font-display); font-size: 1.15rem; margin: 2px 0 2px; color: var(--navy-deep); }
.mvf-badge { align-self: flex-start; display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: .72rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.mvf-badge.auto { background: var(--card); color: var(--navy); border: 1px solid #B9CBE4; }
.mvf-badge.auto::before { content: "⚙"; }
.mvf-badge.design { background: var(--card); color: var(--amber-deep); border: 1px solid #EBC48F; }
.mvf-badge.design::before { content: "✎"; }
.mvf-part { margin-top: auto !important; padding-top: 8px; border-top: 1px dashed #E1B77B; font-size: .85rem !important; color: var(--amber-deep) !important; }
.mvf-why { margin: 14px 0 0; padding: 12px 14px; border-radius: 12px; background: var(--card); border-left: 4px solid var(--amber); color: var(--ink-2); font-size: .97rem; }
.mvf-step { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 14px; }
.mvf-step .btn { min-height: 40px; padding: 0 14px; font-size: .88rem; }

/* Compare-all view */
.mvf-all { display: grid; gap: 10px; }
.mvf-all-head { display: grid; grid-template-columns: minmax(180px, .8fr) 1fr 1fr; gap: 10px; }
.mvf-all-head .mvf-badge { justify-self: start; }
.mvf-all-row { display: grid; grid-template-columns: minmax(180px, .8fr) 1fr 1fr; gap: 10px; align-items: stretch; }
.mvf-all-row h3 { display: flex; gap: 10px; align-items: flex-start; margin: 0; padding: 12px 0; font-family: var(--font-body); font-size: .95rem; font-weight: 650; color: var(--navy); line-height: 1.35; }
.mvf-all-cell { padding: 12px 14px; border-radius: 12px; font-size: .93rem; color: var(--ink-2); line-height: 1.45; border: 1px solid; display: flex; flex-direction: column; gap: 6px; }
.mvf-all-cell.market { background: var(--blue-wash); border-color: #CBD9EC; }
.mvf-all-cell.firm { background: var(--amber-wash); border-color: #EBC48F; }
.mvf-all-cell .mvf-part { margin-top: auto; border-top: 1px dashed #E1B77B; padding-top: 6px; font-size: .8rem; font-weight: 650; color: var(--amber-deep); }
.mvf-tag { display: none; font-size: .7rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }

/* Tablet and phone: questions become a swipeable row; market and firm stack */
@media (max-width: 860px) {
  .mvf-body { grid-template-columns: 1fr; }
  .mvf-tabs { flex-direction: row; overflow-x: auto; scrollbar-width: none; padding-bottom: 4px; position: relative; }
  .mvf-tabs::-webkit-scrollbar { display: none; }
  .mvf-tab { flex: none; width: min(240px, 72vw); }
  .mvf-tab:hover { transform: none; }
}
@media (max-width: 560px) {
  .mvf-pair { grid-template-columns: 1fr; }
  .mvf-vs { justify-self: center; }
  .mvf-bar { flex-wrap: wrap; }
  .mvf-step .small { display: none; }
  .mvf-all-head { display: none; }
  .mvf-all-row { grid-template-columns: 1fr; gap: 6px; padding-bottom: 6px; border-bottom: 1px solid var(--line); }
  .mvf-all-row h3 { padding: 6px 0 0; }
  .mvf-tag { display: block; }
}

/* ==========================================================================
   Flip cards — definition screens
   ========================================================================== */
.flip-bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin: 4px 0 14px; }
.flip-bar .flip-count { margin: 0; }
.flip-bar .flip-count strong { color: var(--navy); }
.flip-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.flip-grid.odd > .flip:last-child { grid-column: 1 / -1; }
.flip { perspective: 1400px; }
.flip-inner {
  display: grid; width: 100%; height: 100%; min-height: 190px;
  padding: 0; border: 0; background: none; text-align: left; cursor: pointer;
  border-radius: 16px; color: inherit;
  transform-style: preserve-3d; transition: transform 650ms cubic-bezier(.3,.7,.2,1);
}
.flip.flipped .flip-inner { transform: rotateY(180deg); }
/* Both faces share one grid cell, so the card is as tall as its longer side */
.flip-face {
  grid-area: 1 / 1; display: flex; flex-direction: column; gap: 8px;
  padding: 20px 22px; border-radius: 16px;
  backface-visibility: hidden; -webkit-backface-visibility: hidden;
}
.flip-front {
  justify-content: center; background: var(--navy); color: #fff;
  box-shadow: var(--shadow); position: relative; overflow: hidden;
}
.flip-front::after { content: ""; position: absolute; right: -40px; bottom: -40px; width: 140px; height: 140px; border-radius: 50%; border: 18px solid rgba(240,163,74,.14); }
.flip-n { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 9px; background: var(--amber); color: var(--navy-deep); font-weight: 700; font-size: .85rem; }
.flip-term { font-family: var(--font-display); font-size: clamp(1.25rem, 1.05rem + .8vw, 1.6rem); font-weight: 600; line-height: 1.25; color: #fff; }
.flip-hint { margin-top: auto; font-size: .78rem; font-weight: 650; letter-spacing: .04em; color: #C9D4E6; }
.flip-back {
  transform: rotateY(180deg);
  background: var(--card); border: 1.5px solid var(--line); border-left: 5px solid var(--amber);
  box-shadow: var(--shadow);
}
.flip-term-sm { font-size: .72rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--amber-deep); }
.flip-def { color: var(--ink-2); font-size: .97rem; line-height: 1.55; }
.flip-back .chips { margin-top: 4px; }
.flip-back .flip-hint { color: var(--muted); }
.flip-inner:hover .flip-front { background: #1D3560; }
.flip-inner:focus-visible { outline: 3px solid var(--navy); outline-offset: 3px; box-shadow: 0 0 0 7px var(--amber); }
@media (max-width: 640px) {
  .flip-grid { grid-template-columns: 1fr; }
  .flip-inner { min-height: 150px; }
}
/* Reduced motion: no rotation — the faces simply swap */
@media (prefers-reduced-motion: reduce) {
  .flip-inner, .flip.flipped .flip-inner { transform: none !important; transition: none !important; }
  .flip-back { transform: none; visibility: hidden; }
  .flip.flipped .flip-back { visibility: visible; }
  .flip.flipped .flip-front { visibility: hidden; }
}
