/* Canadian Paragliding Exam Study Guide — mobile-first stylesheet */
:root {
  --ink: #17232b;
  --ink-soft: #4a5a66;
  --bg: #fbfbf9;
  --panel: #ffffff;
  --line: #d9dfe3;
  --brand: #0b3d5c;
  --brand-soft: #e3eef5;
  --accent: #d9731a;
  --good: #1f7a3d;
  --bad: #b3261e;
  --nepal: #7a1f5c;
  --nepal-soft: #f7e9f2;
  --numbers-soft: #eef6e9;
  --trap-soft: #fff3e0;
  --dagger-soft: #fdeaea;
  --think-soft: #eaf2fb;
  --regs-soft: #f1f1f6;
  --radius: 10px;
  --fs: 17px;
  --lh: 1.6;
  --maxw: 46rem;
}
@media (prefers-color-scheme: dark) {
  :root {
    --ink: #e8ecef; --ink-soft: #a9b4bd; --bg: #12181d; --panel: #1a222a; --line: #2c3742;
    --brand: #7fb6d9; --brand-soft: #1c2f3d; --accent: #f0a05a; --good: #6fcf8f; --bad: #ff8a80;
    --nepal: #e39ad0; --nepal-soft: #2d1a28; --numbers-soft: #1b2a1b; --trap-soft: #2f2416;
    --dagger-soft: #34191b; --think-soft: #172231; --regs-soft: #1f1f2a;
  }
}
html[data-font="large"] { --fs: 20px; }
html[data-font="xlarge"] { --fs: 23px; }

* { box-sizing: border-box; }
html { font-size: var(--fs); }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: -apple-system, "Segoe UI", Roboto, "Noto Sans", "Noto Sans Devanagari", Ubuntu, sans-serif;
  line-height: var(--lh);
}
a { color: var(--brand); }
img, svg { max-width: 100%; height: auto; }

/* Header */
.top {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: .6rem;
  background: var(--brand); color: #fff; padding: .55rem .8rem;
}
@media (prefers-color-scheme: dark) { .top { background: #0d2a3d; } }
.top .brand { color: #fff; text-decoration: none; font-weight: 600; font-size: 1rem; flex: 1; }
.menu-btn, .font-btn {
  background: transparent; color: #fff; border: 1px solid rgba(255,255,255,.5); border-radius: 8px;
  font-size: 1.1rem; padding: .25rem .6rem; cursor: pointer;
}

/* Side navigation */
.sidenav {
  position: fixed; top: 0; left: 0; bottom: 0; width: min(85vw, 20rem); background: var(--panel);
  border-right: 1px solid var(--line); transform: translateX(-100%); transition: transform .2s ease;
  z-index: 30; overflow-y: auto; padding: 1rem;
}
.sidenav.open { transform: none; }
.scrim { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 25; display: none; }
.scrim.show { display: block; }
.nav-section { margin-bottom: 1.2rem; }
.nav-section h3 { margin: 0 0 .4rem; font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-soft); }
.nav-section ol, .nav-section ul { list-style: none; margin: 0; padding: 0; }
.nav-section li a { display: block; padding: .4rem .3rem; text-decoration: none; color: var(--ink); border-radius: 6px; }
.nav-section li a:hover, .nav-section li a.current { background: var(--brand-soft); }
.nav-section .num { display: inline-block; min-width: 2.1em; color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.nav-home { font-weight: 600; text-decoration: none; }
.nav-section.small p { color: var(--ink-soft); font-size: .8rem; }

@media (min-width: 64rem) {
  .sidenav { transform: none; top: 3.1rem; width: 18rem; }
  .scrim { display: none !important; }
  .menu-btn { display: none; }
  .content, .foot { margin-left: 18rem; }
}

/* Content */
.content { padding: 1rem; }
.page { max-width: var(--maxw); margin: 0 auto; }
.page-head { margin-bottom: 1.2rem; }
.kicker { margin: 0; color: var(--accent); font-weight: 700; text-transform: uppercase; letter-spacing: .06em; font-size: .8rem; }
h1 { font-size: 1.75rem; line-height: 1.2; margin: .2rem 0 .6rem; }
h2 { font-size: 1.35rem; margin: 2rem 0 .6rem; padding-top: .4rem; border-top: 2px solid var(--line); }
h3 { font-size: 1.1rem; margin: 1.4rem 0 .4rem; }
.summary { font-size: 1.05rem; color: var(--ink-soft); }
.muted { color: var(--ink-soft); font-size: .92rem; }
.prose p, .prose li { max-width: 40rem; }
.prose table { border-collapse: collapse; width: 100%; margin: 1rem 0; font-size: .95rem; display: block; overflow-x: auto; }
.prose th, .prose td { border: 1px solid var(--line); padding: .45rem .6rem; text-align: left; vertical-align: top; }
.prose th { background: var(--brand-soft); }
.prose blockquote { border-left: 4px solid var(--line); margin: 1rem 0; padding: .2rem 1rem; color: var(--ink-soft); }
.prose code { background: var(--regs-soft); padding: .05rem .3rem; border-radius: 4px; font-size: .95em; }
.prose hr { border: 0; border-top: 1px solid var(--line); margin: 2rem 0; }
.prose figure { margin: 1.2rem 0; }
.prose figcaption { font-size: .9rem; color: var(--ink-soft); }
dfn { font-style: normal; font-weight: 600; border-bottom: 2px dotted var(--accent); }

.toc { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: .6rem .9rem; margin-bottom: 1rem; }
.toc summary { cursor: pointer; font-weight: 600; }
.toc ul { padding-left: 1.2rem; margin: .4rem 0; }

/* Exam tags */
.tag { display: inline-block; font-size: .72rem; font-weight: 700; padding: .1rem .5rem; border-radius: 999px; margin-right: .3rem; background: var(--brand-soft); color: var(--brand); }
.tag-hagar { background: #efe4c9; color: #6a4b00; }
.tag-p4 { background: #e2e6ff; color: #2b3a9e; }
@media (prefers-color-scheme: dark) { .tag-hagar { background: #3a3120; color: #f1d78f; } .tag-p4 { background: #26305c; color: #c5cdff; } }

/* Callout boxes (Python-Markdown admonitions) */
.admonition { border-radius: var(--radius); padding: .8rem 1rem; margin: 1.2rem 0; border-left: 6px solid var(--brand); background: var(--panel); }
.admonition > p:first-child.admonition-title { margin: 0 0 .4rem; font-weight: 700; }
.admonition-title::before { margin-right: .4rem; }
.admonition.nepal { border-color: var(--nepal); background: var(--nepal-soft); }
.admonition.nepal .admonition-title::before { content: "🇳🇵"; }
.admonition.numbers { border-color: var(--good); background: var(--numbers-soft); }
.admonition.numbers .admonition-title::before { content: "🔢"; }
.admonition.trap { border-color: var(--accent); background: var(--trap-soft); }
.admonition.trap .admonition-title::before { content: "⚠️"; }
.admonition.dagger { border-color: var(--bad); background: var(--dagger-soft); }
.admonition.dagger .admonition-title::before { content: "†"; font-weight: 900; font-size: 1.2em; }
.admonition.think { border-color: var(--brand); background: var(--think-soft); }
.admonition.think .admonition-title::before { content: "🧠"; }
.admonition.regs { border-color: #55607a; background: var(--regs-soft); }
.admonition.regs .admonition-title::before { content: "📜"; }
.admonition.words { border-color: #6b7f2a; background: var(--numbers-soft); }
.admonition.words .admonition-title::before { content: "🔤"; }
.admonition.example { border-color: var(--ink-soft); }
.admonition.example .admonition-title::before { content: "✈️"; }
.admonition.correction { border-color: var(--bad); background: var(--dagger-soft); }
.admonition.correction .admonition-title::before { content: "❗"; }
.admonition p:last-child { margin-bottom: 0; }

/* Diagrams */
.diagram { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: .6rem; margin: 1rem 0; }
.diagram svg { display: block; margin: 0 auto; max-height: 24rem; }
.diagram svg text { fill: var(--ink); font-family: inherit; }
.diagram svg .stroke { stroke: var(--ink); fill: none; stroke-width: 2; }
.diagram svg .thin { stroke: var(--ink-soft); fill: none; stroke-width: 1.2; }
.diagram svg .wind { stroke: var(--brand); fill: none; stroke-width: 2; }
.diagram svg .warm { stroke: var(--accent); fill: none; stroke-width: 2; }
.diagram svg .ground { fill: #cfe3c4; stroke: none; }
.diagram svg .sky { fill: var(--brand-soft); stroke: none; }
.diagram svg .danger { fill: var(--dagger-soft); stroke: var(--bad); stroke-width: 1.5; }
.diagram svg .wing { fill: var(--panel); stroke: var(--ink); stroke-width: 2; }
@media (prefers-color-scheme: dark) { .diagram svg .ground { fill: #2c3f26; } }

/* Quiz */
.quiz-section { margin-top: 2.5rem; }
.q { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: .9rem 1rem; margin: 1rem 0; }
.q .q-head { display: flex; gap: .5rem; align-items: baseline; }
.q .q-num { color: var(--ink-soft); font-weight: 700; }
.q .q-text { font-weight: 600; margin: 0 0 .6rem; }
.q .q-tags { margin-left: auto; white-space: nowrap; }
.q .options { list-style: none; padding: 0; margin: 0; }
.q .options li { margin: .3rem 0; }
.q .opt { width: 100%; text-align: left; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: .55rem .7rem; cursor: pointer; font: inherit; color: var(--ink); display: flex; gap: .6rem; }
.q .opt .letter { font-weight: 700; color: var(--ink-soft); min-width: 1.4em; }
.q .opt:hover { border-color: var(--brand); }
.q .opt.correct { border-color: var(--good); background: var(--numbers-soft); }
.q .opt.wrong { border-color: var(--bad); background: var(--dagger-soft); }
.q .opt[disabled] { cursor: default; }
.q .explain { margin-top: .7rem; padding: .6rem .8rem; border-radius: 8px; background: var(--think-soft); }
.q .explain .verdict { font-weight: 700; }
.q .explain .verdict.ok { color: var(--good); }
.q .explain .verdict.no { color: var(--bad); }
.quiz-summary { padding: .8rem 1rem; border-radius: var(--radius); background: var(--brand-soft); margin: 1rem 0; }

/* Buttons and forms */
.btn { font: inherit; padding: .5rem 1rem; border-radius: 8px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); cursor: pointer; }
.btn.primary { background: var(--brand); color: #fff; border-color: var(--brand); }
.btn.good { border-color: var(--good); color: var(--good); }
.btn.bad { border-color: var(--bad); color: var(--bad); }
.search, select { font: inherit; padding: .5rem .7rem; border-radius: 8px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); width: 100%; max-width: 30rem; }
select { width: auto; }
.pe-form, .fc-controls { display: flex; flex-wrap: wrap; gap: 1rem; align-items: end; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: .9rem 1rem; }
.pe-form label, .fc-controls label { display: flex; flex-direction: column; gap: .3rem; font-size: .9rem; color: var(--ink-soft); }
.pe-form label.check { flex-direction: row; align-items: center; }
.pe-timer { font-variant-numeric: tabular-nums; font-weight: 700; }

/* Flashcards */
.flashcard { margin: 1.2rem 0; min-height: 11rem; border-radius: var(--radius); border: 1px solid var(--line); background: var(--panel); display: flex; align-items: center; justify-content: center; text-align: center; padding: 1.4rem; font-size: 1.15rem; cursor: pointer; }
.fc-back { color: var(--brand); font-weight: 600; }
.fc-buttons { display: flex; gap: .7rem; flex-wrap: wrap; }

/* Glossary */
.glossary .term { padding: .7rem 0; border-bottom: 1px solid var(--line); }
.glossary .term h3 { margin: 0 0 .2rem; font-size: 1.05rem; }
.glossary .term .syn { color: var(--ink-soft); font-size: .9rem; }
.glossary .term .ne { color: var(--nepal); margin-top: .2rem; }
.glossary .term .mod { font-size: .8rem; color: var(--ink-soft); }

/* Home */
.module-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); gap: .8rem; }
.module-card { display: grid; grid-template-columns: 2.4rem 1fr; gap: .2rem .6rem; text-decoration: none; color: var(--ink); background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: .8rem; }
.module-card:hover { border-color: var(--brand); }
.module-card .num { grid-row: span 3; font-size: 1.4rem; font-weight: 800; color: var(--brand); }
.module-card .mtitle { font-weight: 600; }
.module-card .progress { font-size: .8rem; color: var(--ink-soft); }
.tool-list li { margin: .4rem 0; }

/* Pager, footer */
.pager { display: flex; justify-content: space-between; gap: 1rem; margin: 2.5rem 0 1rem; }
.pager a { text-decoration: none; padding: .6rem .9rem; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); }
.foot { padding: 1.5rem 1rem 3rem; color: var(--ink-soft); font-size: .85rem; max-width: var(--maxw); }
.foot p { margin: 0 auto; max-width: 40rem; }

/* Print */
@media print {
  .top, .sidenav, .scrim, .pager, .quiz-section, .font-btn, .menu-btn, .foot { display: none !important; }
  .content { margin: 0; padding: 0; }
  body { background: #fff; color: #000; font-size: 11pt; }
  h2 { break-before: auto; }
  .admonition { break-inside: avoid; border: 1px solid #999; }
  a { color: inherit; text-decoration: none; }
}

/* HAGAR "just learn the answer" boxes */
.admonition.hagar { border-color: #6a4b00; background: #fbf3dc; }
.admonition.hagar .admonition-title::before { content: "🎯"; }
@media (prefers-color-scheme: dark) { .admonition.hagar { background: #3a3120; border-color: #f1d78f; } }
.cram { border-collapse: collapse; width: 100%; }
.cram td:first-child { width: 55%; }
