/* The chapter pages of the Governance Academy (scripts/training/aigp_chapter.py), on top of training.css and
   aigp.css: a hub, one page per part, and the flashcards, practice and lab pages. A reading column in a serif face
   with a contents rail, a sticky bar with the reading progress, concepts folded under their term with tabs inside,
   a flashcard deck and a practice stepper. Everything reads without the script; chapter.js adds the behaviour. */
.chapter-page { --rail: 250px; --col: 72ch; }
.chapter-page .wrap { max-width: 1180px; }

/* Hero */
.chapter-hero .wrap { padding-block: 34px 36px; gap: 14px; }
.chapter-hero .eyebrow { margin: 0; color: #a7f3d0; font-weight: 600; letter-spacing: .02em; }
.chapter-hero .eyebrow a { color: inherit; text-decoration: none; }
.chapter-hero h1 { max-width: 20ch; font-size: clamp(2rem, 5vw, 3rem); }
.chapter-hero .facts { list-style: none; margin: 4px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px 18px; color: #c9d6ea; font-size: .95rem; }
.chapter-hero .facts b { color: #fff; font-size: 1.15rem; margin-right: 4px; }
.chapter-hero .ctas { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 6px; }

/* The slimmer hero of a part, flashcards, practice or lab page */
.chapter-hero.slim .wrap { padding-block: 26px 28px; gap: 8px; }
.chapter-hero.slim h1 { font-size: clamp(1.7rem, 4vw, 2.5rem); max-width: 26ch; }
.chapter-hero.slim .meta { margin: 0; color: #c9d6ea; font-size: .98rem; }
.chapter-hero.slim .meta a { color: #a7f3d0; }

/* The parts on the hub */
.parts { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; max-width: var(--col); }
.parts a { display: flex; gap: 14px; align-items: center; padding: 14px 16px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); color: var(--ink); text-decoration: none; }
.parts a:hover { border-color: var(--accent); }
.parts.plain li { display: flex; gap: 14px; align-items: center; padding: 14px 16px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); color: var(--ink); }
.parts .num { flex: 0 0 36px; height: 36px; border-radius: 10px; background: var(--accent-soft); color: var(--accent); display: inline-flex; align-items: center; justify-content: center; font: 800 1rem var(--display); }
.parts .t { display: grid; gap: 2px; }
.parts .t b { font-size: 1.05rem; }
.parts .m { color: var(--muted); font-size: .9rem; }

/* Previous and next */
.pager { display: grid; gap: 10px; grid-template-columns: 1fr 1fr; max-width: var(--col); margin-top: 8px; }
.pager a { display: grid; gap: 2px; padding: 14px 16px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); color: var(--ink); text-decoration: none; font-weight: 600; line-height: 1.3; }
.pager a span { font-size: .78rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.pager a.next { text-align: right; }
.pager a:hover { border-color: var(--accent); color: var(--accent); }
.pager a.next:only-child { grid-column: 2; }
@media (max-width: 560px) { .pager { grid-template-columns: 1fr; } .pager a.next { text-align: left; } .pager a.next:only-child { grid-column: 1; } }

/* Sticky bar with the progress line */
.chapter-bar { position: sticky; top: 0; z-index: 5; background: var(--surface); border-bottom: 1px solid var(--line); }
.chapter-bar .progress { height: 3px; background: var(--soft); }
.chapter-bar .progress i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .15s linear; }
.chapter-bar .wrap { display: flex; align-items: center; gap: 12px; padding-block: 8px; min-height: 44px; }
.chapter-bar .now { flex: 1 1 auto; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: .95rem; }
.chapter-bar .toc-toggle { font: 600 .9rem var(--body); padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer; }
.chapter-bar .toc-toggle[aria-expanded="true"] { background: var(--accent-soft); border-color: var(--accent); }
.chapter-bar .top { color: var(--muted); text-decoration: none; font-size: .9rem; }
@media (min-width: 1024px) { .chapter-bar .toc-toggle { display: none; } }

/* Layout: the rail and the column */
.layout { display: grid; gap: 28px; padding-block: 24px 80px; align-items: start; }
@media (min-width: 1024px) { .layout { grid-template-columns: var(--rail) minmax(0, 1fr); } }
.layout main { display: grid; gap: 40px; min-width: 0; counter-reset: task; }
.sec { scroll-margin-top: 64px; }
.sec > .reading-body, .sec > .lead, .sec > .chips, .sec > .task, .sec > .also, .sec > .more, .sec > h3, .sec > figure.wide, .quiz-set, .deck { max-width: var(--col); }
.sec > h3 { margin-top: 20px; font-size: 1.25rem; }

/* The contents rail */
.toc { display: none; }
.toc.open { display: block; }
@media (min-width: 1024px) { .toc { display: block; position: sticky; top: 60px; max-height: calc(100vh - 72px); overflow: auto; padding-right: 6px; } }
.toc nav { font-size: .92rem; }
.toc-title { margin: 0 0 8px; font: 700 .8rem var(--body); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.toc ol { list-style: none; margin: 0; padding: 0; }
.toc > nav > ol > li { margin: 0 0 2px; }
.toc a { display: flex; gap: 8px; align-items: baseline; padding: 6px 10px; border-radius: 8px; color: var(--muted); text-decoration: none; line-height: 1.3; }
.toc a:hover { background: var(--soft); color: var(--ink); }
.toc a.current { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.toc .n { flex: 0 0 18px; font-weight: 700; color: var(--accent); }
.toc .count { margin-left: auto; font-size: .8rem; color: var(--muted); background: var(--soft); border-radius: 999px; padding: 0 7px; }
.toc .terms { display: none; margin: 2px 0 6px 18px; border-left: 1px solid var(--line); }
.toc li.current > .terms { display: block; }
.toc .terms a { padding: 3px 10px; font-size: .86rem; }
@media (max-width: 1023px) { .toc.open { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 14px; } .toc .terms { display: none !important; } }

/* Section heads and reading */
.sec-head { display: flex; gap: 14px; align-items: flex-start; margin-bottom: 14px; }
.sec-head .num { flex: 0 0 40px; height: 40px; border-radius: 12px; background: var(--accent); color: var(--accent-ink); display: inline-flex; align-items: center; justify-content: center; font: 800 1.05rem var(--display); }
.sec-head h2 { font-size: clamp(1.45rem, 3vw, 1.9rem); }
.sec-meta { margin: 4px 0 0; color: var(--muted); font-size: .92rem; }
.reading-body { font-size: 1.06rem; line-height: 1.72; }
.reading-body p { margin: 0 0 14px; }
.reading-body h4 { margin: 24px 0 8px; font: 700 1.15rem var(--display); }
/* The reading face: a serif at a book's size and leading, as on the long-form sites people read for pleasure. */
.serif, .serif p, .serif li, .serif td, .serif th, .serif dd, .serif dt { font-family: "Source Serif 4", Georgia, "Times New Roman", serif; }
.reading-body.serif { font-size: 1.18rem; line-height: 1.78; letter-spacing: .003em; color: var(--ink); }
.reading-body.serif p { margin: 0 0 1.1em; }
.reading-body.serif li { margin-bottom: .35em; }
.reading-body.serif h4 { font-family: var(--display); font-size: 1.3rem; margin: 1.6em 0 .5em; }
.reading-body.serif b { font-weight: 600; }
.reading-body.serif code { font: .88em ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--soft); border-radius: 4px; padding: 1px 5px; }
.lead.serif { font-size: 1.25rem; line-height: 1.6; max-width: var(--col); margin-bottom: 18px; }
.panel .big, .fcard .def { font-family: "Source Serif 4", Georgia, serif; }
@media (max-width: 640px) { .reading-body.serif { font-size: 1.08rem; line-height: 1.7; } .lead.serif { font-size: 1.12rem; } }

/* Tables in the reading */
.table-wrap { overflow-x: auto; margin: 0 0 1.2em; border: 1px solid var(--line); border-radius: 12px; -webkit-overflow-scrolling: touch; }
.table-wrap table { border-collapse: collapse; width: 100%; min-width: 480px; font-size: .95em; line-height: 1.5; }
.table-wrap th, .table-wrap td { text-align: left; vertical-align: top; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.table-wrap th { background: var(--soft); font-weight: 600; font-family: var(--body); font-size: .88em; letter-spacing: .01em; }
.table-wrap tr:last-child td { border-bottom: 0; }
.table-wrap td:empty::after { content: "\00a0"; }
.reading-body ul, .reading-body ol { margin: 0 0 14px; padding-left: 1.3em; }
.reading-body li { margin-bottom: 4px; }
figure.wide { margin: 18px 0 8px; }
figure.wide img, .concept figure img { width: 100%; height: auto; border-radius: 12px; border: 1px solid var(--line); background: #fff; }
figcaption { color: var(--muted); font-size: .9rem; margin-top: 6px; }

/* Concept chips */
.chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 18px 0 6px; }
.chips span { font-size: .8rem; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin-right: 4px; }
.chips a { font-size: .88rem; padding: 4px 10px; border-radius: 999px; background: var(--soft); color: var(--ink); text-decoration: none; border: 1px solid transparent; }
.chips a:hover { border-color: var(--accent); color: var(--accent); }

/* Concepts: folded under the term, a line of the gist showing; open one and its tabs appear */
.concept { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; margin: 10px 0; max-width: var(--col); scroll-margin-top: 64px; }
.concept > summary { list-style: none; cursor: pointer; padding: 14px 44px 14px 18px; position: relative; display: grid; gap: 4px; border-radius: 16px; }
.concept > summary::-webkit-details-marker { display: none; }
.concept > summary::after { content: ""; position: absolute; right: 18px; top: 22px; width: 9px; height: 9px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(45deg); transition: transform .2s; }
.concept[open] > summary::after { transform: rotate(-135deg); top: 26px; }
.concept > summary:hover { background: var(--soft); }
.concept[open] > summary { border-bottom: 1px solid var(--line); border-radius: 16px 16px 0 0; }
.concept[open] > summary:hover { background: none; }
.concept > summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.c-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.c-head h3 { margin: 0; font-size: 1.2rem; }
.gist { color: var(--muted); font-family: "Source Serif 4", Georgia, serif; font-size: 1rem; line-height: 1.5; }
.concept[open] .gist { display: none; }
.c-body { padding: 12px 18px 18px; }
.c-body .panel { font-family: "Source Serif 4", Georgia, serif; font-size: 1.06rem; line-height: 1.65; }
.c-body .panel b { font-family: var(--body); font-size: .92em; }
.c-body figure { margin: 14px 0 0; }
html.no-js .concept > summary::after { display: none; }
.c-head .dom { font-size: .75rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--lantern); background: var(--lantern-soft); border-radius: 999px; padding: 2px 9px; }
.tabs { display: flex; flex-wrap: wrap; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 12px; }
@media (max-width: 640px) { .tabs { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; } .tabs button { white-space: nowrap; } }
.tabs button { font: 600 .9rem var(--body); padding: 8px 12px; border: 0; border-bottom: 2px solid transparent; margin-bottom: -1px; background: none; color: var(--muted); cursor: pointer; border-radius: 6px 6px 0 0; }
.tabs button:hover { color: var(--ink); background: var(--soft); }
.tabs button[aria-selected="true"] { color: var(--accent); border-bottom-color: var(--accent); }
.panel p { margin: 0 0 10px; }
.panel .big { font-size: 1.08rem; font-weight: 500; }
.panel .precise { color: var(--muted); font-size: .95rem; }
.panel ol, .panel ul { margin: 0 0 10px; padding-left: 1.3em; }
.panel .traps li { margin-bottom: 6px; }
.panel[data-panel="check"] li { margin-bottom: 6px; }
html.no-js .panel[hidden] { display: block; }
html.no-js .tabs { display: none; }
html.no-js .panel::before { content: attr(data-panel); display: block; font: 700 .78rem var(--body); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 10px 0 4px; }

/* Also know */
.also { margin-top: 20px; background: var(--soft); border-radius: 14px; padding: 14px 18px; }
.also h3 { margin: 0 0 10px; font-size: 1.05rem; }
.also dl { margin: 0; display: grid; gap: 10px; }
.also dt { font-weight: 700; }
.also dd { margin: 0; }
.also dd.trap { font-size: .9rem; color: var(--muted); }

/* Remember */
.callout .reading-body { background: var(--accent-soft); border-left: 4px solid var(--accent); border-radius: 0 14px 14px 0; padding: 14px 18px; }
.more { padding-left: 1.2em; }

/* Flashcard deck */
.deck-stage { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
html.js .deck-stage { display: block; min-height: 260px; }
.fcard { position: relative; min-height: 230px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); cursor: pointer; perspective: 1200px; outline-offset: 3px; }
html.js .fcard { display: none; max-width: var(--col); margin: 0 auto; }
html.js .fcard.on { display: block; }
.fcard .face { position: absolute; inset: 0; display: flex; flex-direction: column; gap: 8px; padding: 20px; border-radius: 16px; backface-visibility: hidden; transition: transform .5s; }
.fcard .front { background: linear-gradient(160deg, var(--accent-soft), var(--surface) 70%); }
.fcard .back { background: var(--surface); transform: rotateY(180deg); }
.fcard.turned .front { transform: rotateY(180deg); }
.fcard.turned .back { transform: rotateY(0); }
.fcard .kind { font-size: .75rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); }
.fcard .word { font: 700 1.5rem var(--display); color: var(--ink); }
.fcard .hint { margin-top: auto; font-size: .85rem; color: var(--muted); }
.fcard .def { font-size: 1.05rem; line-height: 1.55; }
.deck-nav { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 14px; }
.deck-nav .counter, .quiz-nav .counter { font-weight: 700; min-width: 70px; text-align: center; }
.deck-nav .keys { margin-left: auto; }
.btn.ghost { color: var(--ink); border-color: var(--line); }

/* Practice */
.quiz-set { margin-top: 20px; }
.quiz-set h3 { font-size: 1.2rem; margin-bottom: 4px; }
.count { font-size: .8rem; font-weight: 700; color: var(--muted); background: var(--soft); border-radius: 999px; padding: 1px 8px; vertical-align: middle; }
.quiz { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; }
.quiz .q { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 16px 18px; }
html.js .quiz .q { display: none; }
html.js .quiz .q.on { display: block; }
.quiz .stem { margin: 0 0 10px; font-weight: 600; font-size: 1.04rem; display: flex; gap: 10px; }
.quiz .qn { flex: 0 0 28px; height: 28px; border-radius: 50%; background: var(--soft); color: var(--muted); display: inline-flex; align-items: center; justify-content: center; font-size: .85rem; font-weight: 700; }
.quiz .opts { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.quiz .opt { width: 100%; text-align: left; font: 1rem var(--body); padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer; }
.quiz .opt b { margin-right: 6px; color: var(--muted); }
.quiz .opt:hover { border-color: var(--accent); }
.quiz .opt.right { background: var(--good-soft); border-color: var(--good); }
.quiz .opt.wrong { background: var(--bad-soft); border-color: var(--bad); }
.quiz .opt[disabled] { cursor: default; }
.quiz .why { display: block; font-size: .92rem; color: var(--muted); padding: 4px 12px 2px; }
.quiz .answer { margin-top: 10px; }
.quiz .answer summary { cursor: pointer; font-weight: 600; color: var(--accent); }
.quiz-nav { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 8px 0 12px; }
.quiz-nav .score { margin-left: auto; color: var(--muted); font-weight: 600; }

/* Teaser */
.teaser .task-foot { display: flex; flex-wrap: wrap; gap: 8px; }

@media (prefers-reduced-motion: reduce) { .fcard .face { transition: none; } .chapter-bar .progress i { transition: none; } }

/* A citation ([S4], Source(s): S4) links to the document it names, in a new tab */
a.cite { color: var(--accent); text-decoration: none; border-bottom: 1px dotted currentColor; font-family: var(--body); font-size: .85em; font-weight: 600; letter-spacing: .02em; }
a.cite:hover { border-bottom-style: solid; }
.reading-body a, .panel a, .fcard .def a, .quiz .why a, .quiz .answer a { color: var(--accent); overflow-wrap: anywhere; }

/* From the wider world: the papers, books and discussions tied to the chapter, grouped by source. */
.sec > ul.wider { max-width: var(--col); }
.wider { list-style: none; margin: 0 0 18px; padding: 0; display: grid; gap: 10px; }
.wider .wr { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: start; padding: 14px 16px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.wider .kind { margin-top: 3px; font: 700 .66rem/1 inherit; letter-spacing: .06em; text-transform: uppercase; border-radius: 999px; padding: 4px 8px; background: var(--accent-soft); color: var(--accent); }
.wider .kind.paper { background: #0f2340; color: #60a5fa; } .wider .kind.book { background: #3a1230; color: #f472b6; } .wider .kind.discussion { background: #3a1f07; color: #fb923c; }
.wider .t { display: grid; gap: 3px; min-width: 0; }
.wider .t a { color: var(--ink); font-weight: 600; text-decoration: none; } .wider .t a:hover { color: var(--accent); }
.wider .m { color: var(--muted); font-size: .85rem; }
.wider .why { font-size: 1rem; line-height: 1.55; margin-top: 4px; }
.wider .part { font-size: .8rem; font-weight: 700; color: var(--accent); background: var(--accent-soft); border-radius: 999px; padding: 4px 10px; white-space: nowrap; }
@media (max-width: 640px) { .wider .wr { grid-template-columns: auto 1fr; } .wider .part { grid-column: 2; justify-self: start; } }
