/* ============================================================
   Permanent Secretary Readiness & Leadership — styles.
   Green and white, system fonts (no downloads), mobile first.
   ============================================================ */
:root {
  /* Palette from the author's reference: soft mint, rich green curves, white cards. */
  --brand: #05633A;        /* deep green: headings, links */
  --brand-2: #04A15C;      /* rich green: curved accents, highlights */
  --brand-btn: #057A44;    /* button green (white text passes contrast) */
  --brand-soft: #E3F7EC;   /* mint wash */
  --brand-line: #BFE8D2;
  --bg: #ECFAF2;           /* soft mint page background */
  --card: #FFFFFF;
  --ink: #143D2A;          /* dark green body text */
  --ink-2: #245A40;
  --ink-3: #4E7562;
  --rule: #CFEBDC;
  --warn-bg: #FFF8E1; --warn-ink: #6B4E00; --warn-line: #F0D88A;
  --bad: #A4262C; --bad-bg: #FDECEC;
  --good: #05633A; --good-bg: #E3F7EC;
  --focus: #F2B705;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(5,99,58,.06), 0 6px 18px rgba(5,99,58,.08);
  --font: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --fs: 1rem;
  color-scheme: light;
}
:root[data-size="l"] { --fs: 1.125rem; }
:root[data-size="xl"] { --fs: 1.25rem; }

* { box-sizing: border-box; }
html { font-size: 100%; -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 400 var(--fs)/1.65 var(--font); min-height: 100vh; position: relative; }
body::before { content: ""; position: fixed; left: 0; right: 0; bottom: 0; height: 38vh; z-index: -1; pointer-events: none;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1440 400' preserveAspectRatio='none'%3E%3Cpath d='M0 120 C 360 330 820 360 1440 300 L1440 400 L0 400 Z' fill='%2304A15C' fill-opacity='.16'/%3E%3Cpath d='M0 230 C 420 390 900 380 1440 350 L1440 400 L0 400 Z' fill='%2304A15C' fill-opacity='.22'/%3E%3C/svg%3E") bottom / 100% 100% no-repeat; }
a { color: var(--brand); text-underline-offset: 2px; }
a:hover { color: var(--brand-2); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
img, svg { max-width: 100%; }
h1, h2, h3, h4 { line-height: 1.25; color: var(--brand); }
h1 { font-size: 1.75rem; margin: .2rem 0 .6rem; }
h2 { font-size: 1.35rem; margin: 1.6rem 0 .6rem; }
h3 { font-size: 1.1rem; margin: 1.4rem 0 .4rem; }
p { margin: 0 0 .9rem; }
ul, ol { padding-left: 1.3rem; margin: 0 0 1rem; }
li { margin: .25rem 0; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 0; background: var(--card); padding: .5rem 1rem; z-index: 50; }
.skip:focus { left: .5rem; top: .5rem; }

/* ---------- top bar ---------- */
.topbar { position: sticky; top: 0; z-index: 20; background: var(--card); border-bottom: 3px solid var(--brand-2); }
.topbar-in { max-width: 72rem; margin: 0 auto; display: flex; align-items: center; gap: .45rem; padding: .5rem .75rem; }
@media (max-width: 26rem) { .lockup-name { display: none; } }
.lockup { display: flex; align-items: center; gap: .55rem; text-decoration: none; color: var(--ink); min-width: 0; }
.lockup-name { font-weight: 700; font-size: .95rem; line-height: 1.2; }
.lockup-name small { display: block; font-weight: 400; font-size: .75rem; color: var(--ink-3); }
.topbar .spacer { flex: 1; }
.short { display: none; }
@media (max-width: 47.99rem) { .long, .lockup-name small.long { display: none; } .short { display: inline; } .lockup-name { font-size: .9rem; } }
.iconbtn { white-space: nowrap; display: inline-flex; align-items: center; gap: .35rem; border: 1px solid var(--rule); background: var(--card); color: var(--ink); border-radius: 999px; padding: .4rem .75rem; font: inherit; font-size: .875rem; cursor: pointer; min-height: 2.5rem; }
.iconbtn:hover { border-color: var(--brand); }
.menu-btn { display: inline-flex; }
@media (min-width: 64rem) { .menu-btn { display: none; } }

/* ---------- layout ---------- */
.shell { max-width: 72rem; margin: 0 auto; display: grid; grid-template-columns: 1fr; gap: 1.5rem; padding: 1rem; }
@media (min-width: 64rem) { .shell { grid-template-columns: 17rem 1fr; } }
.nav { display: none; }
.nav.open { display: block; position: fixed; inset: 3.6rem 0 0 0; z-index: 15; background: var(--card); overflow: auto; padding: 1rem; }
@media (min-width: 64rem) { .nav, .nav.open { display: block; position: sticky; top: 4.5rem; inset: auto; align-self: start; max-height: calc(100vh - 5.5rem); overflow: auto; background: transparent; padding: 0; } }
.nav h2 { font-size: .75rem; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-3); margin: 1rem 0 .3rem; }
.nav ul { list-style: none; padding: 0; margin: 0; }
.nav a { display: flex; gap: .5rem; align-items: baseline; padding: .35rem .5rem; border-radius: 8px; text-decoration: none; color: var(--ink-2); font-size: .9rem; }
.nav a:hover { background: var(--brand-soft); }
.nav a[aria-current="page"] { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.nav .tick { color: var(--brand); font-weight: 700; min-width: 1rem; }
.nav .nav-t { flex: 1; }
.nav .nav-pc { font-size: .75rem; color: var(--ink-3); }
.nav a.is-done .nav-t { color: var(--brand); }
.nav .nav-sub { margin: .1rem 0 .4rem 1.1rem; border-left: 2px solid var(--brand-line); padding-left: .3rem; }
.nav .nav-sub a { font-size: .84rem; padding: .25rem .5rem; }
.nav .nav-sub .tick { font-size: .8rem; }
.nav .nav-progress { justify-content: space-between; align-items: center; font-weight: 600; color: var(--brand); border: 1px solid var(--brand-line); background: var(--card); padding: .5rem .7rem; }
.nav .nav-progress strong { font-size: 1rem; }
.nav .nav-bar { margin: .45rem .2rem .25rem; }
.nav .nav-sum { font-size: .75rem; color: var(--ink-3); margin: 0 .2rem; }
main { min-width: 0; }

.card { background: var(--card); border: 1px solid var(--rule); border-radius: var(--radius); padding: 1.25rem; box-shadow: var(--shadow); }
.card + .card { margin-top: 1rem; }
.page { background: var(--card); border: 1px solid var(--rule); border-radius: var(--radius); padding: 1.25rem 1.1rem 1.5rem; box-shadow: var(--shadow); }
@media (min-width: 40rem) { .page { padding: 1.75rem 2rem 2rem; } }
.crumbs { font-size: .8125rem; color: var(--ink-3); margin-bottom: .4rem; }
.crumbs a { color: var(--ink-3); }
.meta { font-size: .8125rem; color: var(--ink-3); }
.lede { font-size: 1.05rem; color: var(--ink-2); }

/* ---------- hero (overview) ---------- */
.hero { background: var(--card); color: var(--ink); border: 1px solid var(--rule); border-radius: 18px; padding: 2rem 1.25rem 5.5rem; position: relative; overflow: hidden; box-shadow: var(--shadow); }
.hero::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 5rem; pointer-events: none;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1200 160' preserveAspectRatio='none'%3E%3Cpath d='M0 40 C 300 150 700 170 1200 110 L1200 160 L0 160 Z' fill='%2304A15C'/%3E%3Cpath d='M0 95 C 380 175 820 170 1200 140 L1200 160 L0 160 Z' fill='%23057A44'/%3E%3C/svg%3E") bottom / 100% 100% no-repeat; }
.hero h1 { color: var(--brand); font-size: 1.85rem; margin: .5rem 0; max-width: 36rem; }
.hero p { color: var(--ink-2); max-width: 40rem; font-size: 1.05rem; }
.hero .k { text-transform: uppercase; letter-spacing: .1em; font-size: .75rem; font-weight: 700; color: var(--brand-2); }
@media (min-width: 40rem) { .hero { padding: 2.5rem 2.25rem 6rem; } .hero h1 { font-size: 2.4rem; } }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; min-height: 2.75rem; padding: .6rem 1.2rem; border-radius: 10px; border: 1px solid transparent; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; }
.btn-primary { background: var(--brand-btn); color: #fff; }
.btn-primary:hover { background: var(--brand); color: #fff; }
.btn-light { background: #fff; color: var(--brand); border-color: var(--brand-line); }
.btn-light:hover { background: var(--brand-soft); color: var(--brand); }
.btn-ghost { background: transparent; border-color: var(--rule); color: var(--ink); }
.btn-ghost:hover { border-color: var(--brand); color: var(--brand); }
.btn-danger { background: var(--bad); color: #fff; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.row { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; }

.grid { display: grid; gap: 1rem; grid-template-columns: 1fr; }
@media (min-width: 40rem) { .grid.two { grid-template-columns: 1fr 1fr; } }
@media (min-width: 56rem) { .grid.three { grid-template-columns: repeat(3, 1fr); } }
.mod-card { display: block; text-decoration: none; color: inherit; background: var(--card); border: 1px solid var(--rule); border-radius: var(--radius); padding: 1rem 1.1rem; }
.mod-card:hover { border-color: var(--brand); }
.mod-num { font-size: .75rem; font-weight: 700; color: var(--brand); text-transform: uppercase; letter-spacing: .08em; }
.mod-card h3 { margin: .2rem 0 .3rem; font-size: 1.02rem; }
.mod-card p { font-size: .9rem; color: var(--ink-2); margin: 0 0 .5rem; }
.bar { height: 6px; background: var(--brand-soft); border-radius: 99px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--brand-2); }

/* ---------- progress dashboard ---------- */
.stats { display: grid; gap: .75rem; grid-template-columns: 1fr 1fr; margin: 1rem 0; }
@media (min-width: 56rem) { .stats { grid-template-columns: repeat(4, 1fr); } }
.stat { background: var(--brand-soft); border: 1px solid var(--brand-line); border-radius: var(--radius); padding: .9rem 1rem; display: flex; flex-direction: column; gap: .2rem; }
.stat strong { font-size: 1.6rem; color: var(--brand); line-height: 1.1; }
.stat span { font-size: .84rem; color: var(--ink-2); }
.stat .bar { margin-top: .35rem; background: var(--card); }
.resume-card { border-color: var(--brand-line); }
.progress-card { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; justify-content: space-between; }
.progress-card > div { flex: 1 1 16rem; }
.sync { font-size: .84rem; margin: .8rem 0 0; color: var(--ink-2); }
.sync-saved { color: var(--good); }
.sync-offline, .sync-signedout { color: var(--warn-ink); background: var(--warn-bg); border: 1px solid var(--warn-line); border-radius: 8px; padding: .4rem .6rem; }
.dash-tbl .bar { min-width: 5rem; margin-bottom: .2rem; }
.pill-warn { background: var(--warn-bg); color: var(--warn-ink); }
.ach-list { list-style: none; padding: 0; }
.ach-list li { padding: .3rem 0; border-bottom: 1px solid var(--rule); }
.ach { display: inline-block; width: 1.4rem; height: 1.4rem; line-height: 1.4rem; text-align: center; border-radius: 99px; background: var(--brand-btn); color: #fff; font-size: .8rem; margin-right: .3rem; }
.rules { margin-top: 1.25rem; }
.rules summary { cursor: pointer; }

/* ---------- labels, notes ---------- */
.badge { display: inline-block; font-size: .72rem; font-weight: 700; letter-spacing: .02em; padding: .08rem .45rem; border-radius: 99px; border: 1px solid currentColor; vertical-align: .08em; white-space: nowrap; }
.b-binding { color: #05633A; } .b-rule { color: #1F5FA8; } .b-policy { color: #6A47A8; } .b-judicial { color: #8A4B08; }
.b-practice { color: #55605A; } .b-draft { color: #A4262C; } .b-historical { color: #7A6A3A; } .b-secondary { color: #7A5A00; } .b-fictional { color: #B4533B; }
.cite { font-size: .78rem; text-decoration: none; background: var(--brand-soft); color: var(--brand); border: 1px solid var(--brand-line); border-radius: 6px; padding: 0 .3rem; white-space: nowrap; vertical-align: .05em; }
.cite:hover { background: var(--brand-line); }
.src { font-size: .85rem; color: var(--ink-3); }
.note { font-size: .9rem; color: var(--ink-3); }
.keypoint { border-left: 4px solid var(--brand); background: var(--brand-soft); padding: .75rem 1rem; border-radius: 0 10px 10px 0; margin: 1rem 0; font-weight: 500; }
.example { border: 1px dashed var(--brand-line); background: color-mix(in srgb, var(--brand-soft) 45%, var(--card)); border-radius: 10px; padding: .75rem 1rem; margin: 1rem 0; }
.example h4 { margin: 0 0 .4rem; font-size: .95rem; color: var(--brand); }
.state-note { border: 1px solid var(--warn-line); background: var(--warn-bg); color: var(--warn-ink); border-radius: 10px; padding: .7rem 1rem; margin: 1rem 0; font-size: .92rem; }
.draft-banner { background: var(--warn-bg); color: var(--warn-ink); border-bottom: 1px solid var(--warn-line); font-size: .82rem; text-align: center; padding: .35rem 1rem; }
.draft-banner a { color: inherit; font-weight: 600; }
.alert { border-radius: 10px; padding: .75rem 1rem; margin: .75rem 0; }
.alert-good { background: var(--good-bg); color: var(--good); border: 1px solid var(--brand-line); }
.alert-bad { background: var(--bad-bg); color: var(--bad); border: 1px solid var(--bad); }
.alert-warn { background: var(--warn-bg); color: var(--warn-ink); border: 1px solid var(--warn-line); }

/* ---------- tables ---------- */
.tbl-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: .75rem 0 1rem; }
.tbl { border-collapse: collapse; width: 100%; font-size: .9rem; }
.tbl th, .tbl td { border: 1px solid var(--rule); padding: .45rem .6rem; text-align: left; vertical-align: top; }
.tbl thead th { background: var(--brand-soft); color: var(--ink); }

/* ---------- figures ---------- */
.figure { margin: 1.2rem 0; text-align: center; }
.figure svg { width: 100%; height: auto; max-width: 40rem; }
.figure figcaption { font-size: .85rem; color: var(--ink-3); margin-top: .3rem; }
.fig-box { fill: var(--card); stroke: var(--brand); stroke-width: 1.5; }
.fig-core { fill: var(--brand-soft); stroke: var(--brand); stroke-width: 2; }
.fig-line { stroke: var(--brand); stroke-width: 1.5; fill: none; }
.fig-strong { fill: var(--ink); font: 600 14px var(--font); }
.fig-small { fill: var(--ink-3); font: 400 11px var(--font); }
/* the part of a diagram being explained by the narrator */
.fig-active rect, .fig-active circle { fill: #FFF3BF; stroke: #B7860B; stroke-width: 3; transition: fill .2s, stroke .2s; }
path.fig-active { stroke: #B7860B; stroke-width: 3.5; }
.figure.seg-reading { outline-offset: 6px; }
.fig-desc { text-align: left; max-width: 40rem; margin: .5rem auto 0; font-size: .92rem; }
.fig-desc summary { cursor: pointer; color: var(--brand); font-weight: 600; text-align: center; }
.fig-desc ol { margin: .5rem 0 0; }
tr.seg-reading { outline: 2px dashed var(--brand-line); outline-offset: -2px; background: var(--brand-soft); }
th .w.reading { box-shadow: 0 0 0 2px #FFE58A; }

/* ---------- pager ---------- */
.pager { display: flex; justify-content: space-between; gap: .75rem; margin-top: 2rem; padding-top: 1rem; border-top: 1px solid var(--rule); }
.pager a { flex: 1; max-width: 48%; text-decoration: none; border: 1px solid var(--rule); border-radius: 10px; padding: .6rem .8rem; color: var(--ink); background: var(--card); }
.pager a:hover { border-color: var(--brand); }
.pager .dir { display: block; font-size: .75rem; color: var(--ink-3); text-transform: uppercase; letter-spacing: .06em; }
.pager .next { text-align: right; margin-left: auto; }

/* ---------- quiz ---------- */
.q { border: 1px solid var(--rule); border-radius: 10px; padding: .9rem 1rem; margin: 0 0 1rem; }
.q legend { font-weight: 600; padding: 0 .2rem; }
.q label { display: flex; gap: .55rem; align-items: flex-start; padding: .35rem .4rem; border-radius: 8px; cursor: pointer; }
.q label:hover { background: var(--brand-soft); }
.q input { margin-top: .35rem; width: 1.05rem; height: 1.05rem; accent-color: var(--brand); }
.q .why { font-size: .9rem; margin: .3rem 0 0 2rem; }
.q.correct { border-color: var(--brand); }
.q.wrong { border-color: var(--bad); }
.opt-correct { background: var(--good-bg); }
.opt-wrong { background: var(--bad-bg); }
.score { font-size: 1.4rem; font-weight: 700; color: var(--brand); }

/* ---------- forms ---------- */
textarea, input[type="text"], input[type="search"], select { width: 100%; font: inherit; color: var(--ink); background: var(--card); border: 1px solid var(--rule); border-radius: 10px; padding: .6rem .75rem; }
textarea { min-height: 8rem; resize: vertical; }
textarea:focus, input:focus, select:focus { border-color: var(--brand); }
.saved { font-size: .8rem; color: var(--ink-3); }
.rubric { width: 100%; }
.rubric select { width: auto; }

/* ---------- audio bar ---------- */
.audio { position: sticky; bottom: 0; z-index: 10; margin-top: 1rem; background: var(--card); border: 1px solid var(--rule); border-radius: 12px; padding: .5rem .75rem; display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; box-shadow: var(--shadow); }
.audio .voice { font-size: .78rem; color: var(--ink-3); flex-basis: 100%; }
@media (max-width: 39.99rem) {
  .audio { padding: .35rem .5rem; gap: .35rem; }
  .audio .btn { min-height: 2.5rem; padding: .35rem .7rem; }
  .audio select { padding: .25rem .35rem; }
  .audio .voice { display: none; }
}
@media (min-width: 40rem) { .audio .voice { flex-basis: auto; margin-left: auto; } }
.audio select { width: auto; padding: .3rem .5rem; }
/* Listen button: top right of every narrated page */
.page-top { display: flex; align-items: flex-start; justify-content: space-between; gap: .75rem; }
.page-top > :first-child { margin-top: .35rem; min-width: 0; }
.listen-top { flex: none; min-height: 2.5rem; padding: .4rem .95rem; border-radius: 999px; font-size: .92rem; white-space: nowrap; }
.listen-top[aria-pressed="true"] { background: var(--brand); }
.hero .page-top { margin-top: -.75rem; }
/* Back to course, on publication references */
.back-row { margin-bottom: .75rem; }
.back-course { border-radius: 999px; gap: 0; }
.back-float { position: fixed; right: 1rem; bottom: 1rem; z-index: 30; }
.back-float .back-course { box-shadow: var(--shadow); }
.back-float .back-where { display: none; }
@media (max-width: 30rem) { .back-course .back-where { display: none; } }
.w.reading { background: #FFE58A; color: #143D2A; border-radius: 3px; box-shadow: 0 0 0 2px #FFE58A; }
.seg-reading { outline: 2px dashed var(--brand-line); outline-offset: 4px; border-radius: 4px; }

/* ---------- ask ---------- */
.ask-log { display: grid; gap: .75rem; margin-top: 1rem; }
.bubble { border-radius: 12px; padding: .75rem 1rem; }
.bubble.me { background: var(--brand-soft); justify-self: end; max-width: 90%; }
.bubble.bot { background: var(--card); border: 1px solid var(--rule); }
.bubble .tag { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); }

/* ---------- misc ---------- */
.kbd { font-family: ui-monospace, Consolas, monospace; font-size: .85em; }
.check-list { list-style: none; padding: 0; }
.check-list li { display: flex; gap: .55rem; align-items: flex-start; padding: .3rem 0; }
.check-list input { margin-top: .35rem; accent-color: var(--brand); width: 1.05rem; height: 1.05rem; }
.pill { display: inline-block; padding: .1rem .55rem; border-radius: 99px; background: var(--brand-soft); color: var(--brand); font-size: .78rem; font-weight: 600; }
.toast { position: fixed; left: 50%; bottom: 1.25rem; transform: translateX(-50%); background: var(--brand); color: #fff; padding: .6rem 1rem; border-radius: 10px; z-index: 60; font-size: .9rem; box-shadow: var(--shadow); }
.modal-bg { position: fixed; inset: 0; background: rgba(5,99,58,.35); z-index: 70; display: grid; place-items: center; padding: 1rem; }
.modal { background: var(--card); color: var(--ink); max-width: 38rem; width: 100%; max-height: 90vh; overflow: auto; border-radius: 14px; padding: 1.5rem; }
details summary { cursor: pointer; font-weight: 600; }
hr { border: 0; border-top: 1px solid var(--rule); margin: 1.5rem 0; }
@media print {
  .topbar, .nav, .audio, .pager, .draft-banner, .no-print { display: none !important; }
  .shell { display: block; } .page { border: 0; box-shadow: none; }
  body { background: #fff; color: #000; }
}
