/* Layout: fixed top bar, lesson list on the left (drawer on phones), one reading column. */

/* ===== BRAND: change these to rebrand the course ===== */
:root {
  --brand-navy: #003366;
  --brand-green: #6FBF8C;
  --brand-coral: #FF6F61;
  --brand-cream: #FFF5E1;

  --bg: #FAFAF7;
  --surface: #FFFFFF;
  --ink: #18222E;
  --muted: #56616E;
  --line: #DEE2E3;
  --primary: var(--brand-navy);       /* buttons, links */
  --on-primary: #FFFFFF;
  --accent: var(--brand-green);       /* progress, success */
  --accent-ink: #2C6B45;              /* green text on light ground */
  --highlight: var(--brand-coral);    /* small markers only */
  --say-bg: var(--brand-cream);
  --say-ink: #4A3A1A;
  --good-bg: #E6F4EB;
  --bad-bg: #FDECEA;
  --bad-ink: #9B2B20;
  --shadow: 0 1px 2px rgb(0 30 60 / .06), 0 4px 16px rgb(0 30 60 / .06);

  --font-display: "Bricolage Grotesque", "Segoe UI", system-ui, sans-serif;
  --font-body: "Atkinson Hyperlegible", "Segoe UI", system-ui, -apple-system, sans-serif;

  --step--1: .875rem;
  --step-0: 1.0625rem;
  --step-1: 1.25rem;
  --step-2: 1.6rem;
  --step-3: 2.2rem;
  --radius: 10px;
  --topbar: 64px;
  --side: 280px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0D1823; --surface: #14222F; --ink: #E7ECF1; --muted: #A3AFBB; --line: #263747;
    --primary: #8DB4E2; --on-primary: #0D1823; --accent: #7FCB9C; --accent-ink: #8FD6AA;
    --highlight: #FF8A7E; --say-bg: #2A2416; --say-ink: #F3E3BE;
    --good-bg: #173326; --bad-bg: #3A1D1A; --bad-ink: #FFB4AA;
    --shadow: 0 1px 2px rgb(0 0 0 / .3), 0 4px 16px rgb(0 0 0 / .25);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0D1823; --surface: #14222F; --ink: #E7ECF1; --muted: #A3AFBB; --line: #263747;
  --primary: #8DB4E2; --on-primary: #0D1823; --accent: #7FCB9C; --accent-ink: #8FD6AA;
  --highlight: #FF8A7E; --say-bg: #2A2416; --say-ink: #F3E3BE;
  --good-bg: #173326; --bad-bg: #3A1D1A; --bad-ink: #FFB4AA;
  --shadow: 0 1px 2px rgb(0 0 0 / .3), 0 4px 16px rgb(0 0 0 / .25);
  color-scheme: dark;
}

/* ===== Base ===== */
*, *::before, *::after { box-sizing: border-box; }
html { height: 100%; }
body {
  margin: 0; min-height: 100%;
  background: var(--bg); color: var(--ink);
  font-family: var(--font-body); font-size: var(--step-0); line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
img, video { max-width: 100%; display: block; }
h1, h2, h3 { font-family: var(--font-display); line-height: 1.15; text-wrap: balance; margin: 0; letter-spacing: -.01em; }
p { margin: 0; }
a { color: var(--primary); }
button { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--highlight); outline-offset: 2px; border-radius: 4px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: 16px; top: -60px; z-index: 50; background: var(--primary); color: var(--on-primary); padding: .5rem 1rem; border-radius: 6px; }
.skip:focus { top: 8px; }
[hidden] { display: none !important; }

/* ===== Top bar ===== */
.topbar {
  position: fixed; inset: 0 0 auto 0; z-index: 20;
  height: calc(var(--topbar) + env(safe-area-inset-top, 0px));
  padding: env(safe-area-inset-top, 0px) 16px 0;
  display: flex; align-items: center; gap: 14px;
  background: var(--surface); border-bottom: 1px solid var(--line);
}
.menu-btn { display: none; width: 40px; height: 40px; border: 1px solid var(--line); border-radius: 8px; background: transparent; cursor: pointer; place-items: center; flex: none; }
.menu-icon, .menu-icon::before, .menu-icon::after { display: block; width: 18px; height: 2px; background: var(--ink); border-radius: 2px; position: relative; }
.menu-icon::before, .menu-icon::after { content: ""; position: absolute; left: 0; }
.menu-icon::before { top: -6px; } .menu-icon::after { top: 6px; }
.topbar-title { min-width: 0; flex: 1; display: flex; flex-direction: column; }
.series { font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.course-name { font-family: var(--font-display); font-weight: 700; font-size: 1.05rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.progress { display: flex; align-items: center; gap: 10px; flex: none; }
.progress-track { width: 140px; height: 8px; border-radius: 99px; background: var(--line); overflow: hidden; }
.progress-fill { height: 100%; width: 0; background: var(--accent); border-radius: 99px; transition: width .4s ease; }
.progress-label { font-size: var(--step--1); color: var(--muted); font-variant-numeric: tabular-nums; min-width: 3ch; text-align: right; }

/* ===== Sidebar ===== */
.sidebar {
  position: fixed; z-index: 15; left: 0; bottom: 0;
  top: calc(var(--topbar) + env(safe-area-inset-top, 0px));
  width: var(--side); overflow-y: auto;
  background: var(--surface); border-right: 1px solid var(--line);
  padding: 20px 12px calc(20px + env(safe-area-inset-bottom, 0px));
}
.lesson-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.lesson-link {
  width: 100%; display: grid; grid-template-columns: 28px 1fr; align-items: center; gap: 10px;
  padding: 10px 10px; border: 0; border-radius: 8px; background: transparent; text-align: left; cursor: pointer;
}
.lesson-link:hover:not(:disabled) { background: color-mix(in srgb, var(--primary) 8%, transparent); }
.lesson-link[aria-current="page"] { background: color-mix(in srgb, var(--primary) 12%, transparent); font-weight: 700; }
.lesson-link:disabled { cursor: not-allowed; color: var(--muted); }
.mark {
  width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center;
  font-size: .8rem; font-weight: 700; border: 2px solid var(--line); color: var(--muted); font-variant-numeric: tabular-nums;
}
.lesson-link[data-state="done"] .mark { background: var(--accent); border-color: var(--accent); color: #0D2A18; }
.lesson-link[aria-current="page"] .mark { border-color: var(--primary); color: var(--primary); }
.lesson-link[data-state="done"][aria-current="page"] .mark { color: #0D2A18; }
.lock { font-size: .72rem; color: var(--muted); display: block; font-weight: 400; }

/* ===== Main column ===== */
.main { padding-top: calc(var(--topbar) + env(safe-area-inset-top, 0px)); margin-left: var(--side); outline: none; }
.lesson { max-width: 760px; margin: 0 auto; padding: 40px 24px calc(80px + env(safe-area-inset-bottom, 0px)); display: grid; gap: 36px; }
.lesson > * { min-width: 0; }

.eyebrow { font-size: var(--step--1); font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--accent-ink); }
.block-heading { display: grid; gap: 8px; }
.block-heading h1 { font-size: var(--step-3); font-weight: 800; }
h2.section { font-size: var(--step-2); font-weight: 700; }
.prose { display: grid; gap: 14px; max-width: 65ch; }
.prose ul { margin: 0; padding-left: 1.2rem; display: grid; gap: 8px; }
.prose li::marker { color: var(--highlight); }

/* Cover (welcome) */
.cover { border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.cover img { width: 100%; height: auto; }

/* Banner */
.banner { position: relative; border-radius: var(--radius); overflow: hidden; min-height: 240px; display: flex; align-items: flex-end; }
.banner img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.banner::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, rgb(0 20 40 / 0) 25%, rgb(0 20 40 / .82) 100%); }
.banner-text { position: relative; z-index: 1; padding: 28px; color: #FFFFFF; display: grid; gap: 6px; }
.banner-text .eyebrow { color: #A9E3BE; }
.banner-text h1 { font-size: var(--step-3); font-weight: 800; color: #FFFFFF; }

/* Objectives */
.objectives { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; display: grid; gap: 14px; }
.objectives h2 { font-size: var(--step-1); }
.objectives ol { margin: 0; padding: 0; list-style: none; counter-reset: obj; display: grid; gap: 12px; }
.objectives li { counter-increment: obj; display: grid; grid-template-columns: 32px 1fr; gap: 12px; align-items: start; }
.objectives li::before { content: counter(obj); width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: var(--primary); color: var(--on-primary); font-weight: 700; font-family: var(--font-display); }

/* Video */
.video { display: grid; gap: 12px; }
.video-frame { border-radius: var(--radius); overflow: hidden; background: #000; aspect-ratio: 16 / 9; max-width: 100%; }
.video-frame video { width: 100%; height: 100%; }
.video-meta { font-size: var(--step--1); color: var(--muted); }
details.transcript { border: 1px solid var(--line); border-radius: 8px; padding: 10px 14px; background: var(--surface); }
details.transcript summary { cursor: pointer; font-weight: 700; }
details.transcript div { margin-top: 10px; white-space: pre-wrap; max-height: 320px; overflow-y: auto; }

/* Accordion */
.accordion { display: grid; gap: 10px; }
.acc-item { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.acc-btn { width: 100%; display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 16px 18px; background: transparent; border: 0; cursor: pointer; text-align: left; font-weight: 700; font-size: var(--step-0); }
.acc-btn .chev { flex: none; width: 10px; height: 10px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(45deg); transition: transform .2s; margin-top: -4px; }
.acc-btn[aria-expanded="true"] .chev { transform: rotate(-135deg); margin-top: 4px; }
.acc-btn .seen { font-size: .75rem; color: var(--accent-ink); font-weight: 400; margin-left: auto; }
.acc-panel { padding: 0 18px 18px; display: grid; gap: 12px; }
.acc-panel img { border-radius: 8px; width: 100%; max-height: 260px; object-fit: cover; }

/* "Try saying" phrase card: the course's signature element */
.say {
  position: relative; background: var(--say-bg); color: var(--say-ink);
  padding: 12px 16px 12px 16px; border-radius: 4px 14px 14px 14px; font-style: italic; max-width: 55ch;
}
.say::before { content: "Try saying"; display: block; font-style: normal; font-size: .7rem; letter-spacing: .1em; text-transform: uppercase; font-weight: 700; color: var(--highlight); margin-bottom: 2px; }

/* Activity shell (scenario, sort, quiz, commit) */
.activity { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; display: grid; gap: 16px; box-shadow: var(--shadow); }
.activity-tag { font-size: .72rem; letter-spacing: .1em; text-transform: uppercase; font-weight: 700; color: var(--highlight); }
.activity h2 { font-size: var(--step-1); }
.setup { padding-left: 14px; border-left: 3px solid var(--line); }
.choices { display: grid; gap: 10px; }
.choice {
  display: block; width: 100%; text-align: left; padding: 14px 16px; border-radius: 8px; cursor: pointer;
  background: var(--bg); border: 2px solid var(--line); line-height: 1.45;
}
.choice:hover:not(:disabled) { border-color: var(--primary); }
.choice[aria-pressed="true"] { border-color: var(--primary); background: color-mix(in srgb, var(--primary) 8%, var(--bg)); }
.choice.is-best { border-color: var(--accent); }
.result { border-radius: 8px; padding: 14px 16px; display: grid; gap: 6px; }
.result.good { background: var(--good-bg); }
.result.bad { background: var(--bad-bg); }
.result strong { font-family: var(--font-display); }

/* Sort */
.sort-list { display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; }
.sort-item { border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; display: grid; gap: 10px; background: var(--bg); }
.sort-item.right { border-color: var(--accent); }
.sort-item.wrong { border-color: var(--highlight); }
.bin-btns { display: flex; flex-wrap: wrap; gap: 8px; }
.bin-btn { padding: 6px 12px; border-radius: 99px; border: 1.5px solid var(--line); background: var(--surface); cursor: pointer; font-size: var(--step--1); }
.bin-btn[aria-pressed="true"] { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.verdict { font-size: var(--step--1); font-weight: 700; }
.verdict.ok { color: var(--accent-ink); } .verdict.no { color: var(--bad-ink); }

/* Reflect */
.reflect { display: grid; gap: 10px; padding: 22px 24px; border-radius: var(--radius); background: color-mix(in srgb, var(--accent) 14%, var(--surface)); }
.reflect h2 { font-size: var(--step-1); }
.reflect textarea, .field { width: 100%; min-height: 96px; padding: 12px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); font: inherit; resize: vertical; }
.hint { font-size: var(--step--1); color: var(--muted); }

/* Quiz */
.question { display: grid; gap: 12px; border: 0; padding: 0; margin: 0; }
.question legend { font-weight: 700; padding: 0; margin-bottom: 4px; }
.q-num { font-size: var(--step--1); color: var(--muted); font-weight: 400; display: block; }
.opt { display: grid; grid-template-columns: 22px 1fr; gap: 12px; align-items: start; padding: 12px 14px; border: 2px solid var(--line); border-radius: 8px; background: var(--bg); cursor: pointer; }
.opt input { margin: 3px 0 0; width: 18px; height: 18px; accent-color: var(--primary); }
.opt:has(input:checked) { border-color: var(--primary); }
.opt.right, .opt.right:has(input:checked) { border-color: var(--accent); background: var(--good-bg); }
.opt.wrong, .opt.wrong:has(input:checked) { border-color: var(--highlight); background: var(--bad-bg); }
.opt-fb { grid-column: 2; font-size: var(--step--1); color: var(--muted); }
.score { display: grid; gap: 8px; padding: 20px; border-radius: var(--radius); text-align: left; }
.score.good { background: var(--good-bg); } .score.bad { background: var(--bad-bg); }
.score .big { font-family: var(--font-display); font-size: var(--step-3); font-weight: 800; font-variant-numeric: tabular-nums; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 22px; border-radius: 8px; border: 2px solid var(--primary);
  background: var(--primary); color: var(--on-primary); font-weight: 700; cursor: pointer;
}
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.ghost { background: transparent; color: var(--primary); }
.btn-row { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.lesson-nav { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding-top: 12px; border-top: 1px solid var(--line); }
.gate-note { font-size: var(--step--1); color: var(--muted); }

/* Finish */
.finish-card { display: grid; gap: 14px; padding: 28px; border-radius: var(--radius); background: var(--primary); color: var(--on-primary); }
.finish-card h2 { font-size: var(--step-2); }
.finish-card .btn { background: var(--on-primary); color: var(--primary); border-color: var(--on-primary); justify-self: start; }
.commit-echo { padding: 12px 16px; border-radius: 8px; background: color-mix(in srgb, var(--on-primary) 14%, transparent); }

/* ===== Phone ===== */
@media (max-width: 860px) {
  .menu-btn { display: grid; }
  .sidebar { transform: translateX(-100%); transition: transform .25s ease; width: min(86vw, 320px); box-shadow: var(--shadow); }
  .app.nav-open .sidebar { transform: none; }
  .main { margin-left: 0; }
  .progress-track { width: 64px; }
  .lesson { padding: 28px 16px calc(64px + env(safe-area-inset-bottom, 0px)); gap: 28px; }
  :root { --step-3: 1.8rem; --step-2: 1.4rem; }
  .banner { min-height: 200px; }
  .banner-text { padding: 20px; }
  .activity, .objectives { padding: 18px; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
