/* Geomag NZ — Learning program styles (Solmate "Southern Sun" palette).
   Uses the same theme tokens as the dashboard (src/index.css). */

:root,
:root[data-theme='dark'] {
  color-scheme: dark;
  --c-bg: 16 27 48;
  --c-panel: 23 36 61;
  --c-raised: 31 47 77;
  --c-line: 42 58 88;
  --c-ink: 246 238 223;
  --c-sub: 194 186 170;
  --c-mute: 150 145 135;
  --c-accent: 79 156 240;
  --c-good: 12 163 12;
  --c-warn: 250 178 25;
  --c-serious: 236 131 90;
  --c-critical: 224 82 82;
  --c-sun: 255 170 60;
  --c-earth: 63 150 230;
  --c-field: 144 133 233;
  --c-bznorth: 47 179 106;
  --c-space: 7 10 14;
}
:root[data-theme='light'] {
  color-scheme: light;
  --c-bg: 246 241 232;
  --c-panel: 255 252 246;
  --c-raised: 250 245 236;
  --c-line: 226 215 196;
  --c-ink: 16 27 48;
  --c-sub: 88 82 70;
  --c-mute: 122 115 102;
  --c-accent: 42 120 214;
  --c-good: 0 120 0;
  --c-warn: 176 118 0;
  --c-serious: 196 88 44;
  --c-critical: 208 59 59;
  --c-sun: 222 120 10;
  --c-earth: 30 110 200;
  --c-field: 74 58 167;
  --c-bznorth: 26 143 74;
  /* Animations keep a dark "space" backdrop in both themes. */
  --c-space: 11 15 20;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
body {
  margin: 0;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: rgb(var(--c-bg));
  color: rgb(var(--c-ink));
  font-family: Inter, system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  font-size: 16.5px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}
a { color: rgb(var(--c-accent)); text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }
img, svg, canvas { max-width: 100%; }
.num, .mono { font-variant-numeric: tabular-nums; }
.mono { font-family: ui-monospace, SFMono-Regular, 'Cascadia Mono', Consolas, Menlo, monospace; font-size: 0.92em; }
:focus-visible { outline: 2px solid rgb(var(--c-accent)); outline-offset: 2px; border-radius: 4px; }

/* ---------- Top bar (mirrors the dashboard header) ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  /* Installed app on phones: keep clear of the status bar (clock, notch / camera). */
  padding-top: env(safe-area-inset-top, 0px);
  padding-left: env(safe-area-inset-left, 0px);
  padding-right: env(safe-area-inset-right, 0px);
  border-bottom: 1px solid rgb(var(--c-line));
  background: rgb(var(--c-bg) / 0.82);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
.topbar-inner {
  max-width: 1280px; margin: 0 auto; padding: 8px 16px;
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 8px; color: rgb(var(--c-ink)); text-decoration: none; min-width: 0; }
.brand img { width: 22px; height: 22px; flex-shrink: 0; }
.brand-title { font-size: 14px; font-weight: 600; line-height: 1.15; white-space: nowrap; }
.brand-title span { color: rgb(var(--c-sub)); }
.brand-sub { font-size: 10px; letter-spacing: 0.09em; text-transform: uppercase; color: rgb(var(--c-mute)); line-height: 1.2; }
.topnav { margin-left: auto; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.btn {
  display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 10px;
  border: 1px solid rgb(var(--c-line)); border-radius: 6px;
  font: inherit; font-size: 12.5px; color: rgb(var(--c-ink)); background: transparent;
  text-decoration: none; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: rgb(var(--c-raised)); }
.btn.primary { border-color: rgb(var(--c-accent) / 0.7); background: rgb(var(--c-accent) / 0.14); }
.btn svg { width: 14px; height: 14px; }
.progressbar { height: 2px; background: transparent; }
.progressbar > div { height: 100%; width: 0; background: rgb(var(--c-accent)); transition: width 120ms linear; }

/* ---------- Layout ---------- */
.wrap { max-width: 1280px; margin: 0 auto; padding: 0 16px; }
.chapter-layout { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 40px; padding-top: 28px; padding-bottom: 64px; }
.chapter-layout > main { max-width: 780px; min-width: 0; }
@media (max-width: 960px) {
  .chapter-layout { grid-template-columns: minmax(0, 1fr); gap: 0; padding-top: 16px; }
  .fig-bar label { flex-wrap: wrap; }
  .sidebar { display: none; }
}
.sidebar { position: sticky; top: calc(72px + env(safe-area-inset-top, 0px)); align-self: start; max-height: calc(100vh - 90px); overflow: auto; padding-right: 4px; }
.sidebar h2 { font-size: 10.5px; letter-spacing: 0.1em; text-transform: uppercase; color: rgb(var(--c-mute)); margin: 0 0 8px; font-weight: 600; }
.toc { list-style: none; margin: 0; padding: 0; }
.toc li a {
  display: grid; grid-template-columns: 26px 1fr 14px; gap: 6px; align-items: center;
  padding: 6px 8px; border-radius: 6px; color: rgb(var(--c-sub)); text-decoration: none; font-size: 13.5px; line-height: 1.3;
}
.toc li a:hover { background: rgb(var(--c-raised)); color: rgb(var(--c-ink)); }
.toc li a.current { background: rgb(var(--c-accent) / 0.13); color: rgb(var(--c-ink)); }
.toc .n { font-variant-numeric: tabular-nums; font-size: 11.5px; color: rgb(var(--c-mute)); }
.toc .done { width: 8px; height: 8px; border-radius: 50%; background: rgb(var(--c-line)); justify-self: end; }
.toc .done.yes { background: rgb(var(--c-good)); }
.mobile-chapter { display: none; margin-bottom: 12px; }
@media (max-width: 960px) { .mobile-chapter { display: block; } }
.mobile-chapter select {
  width: 100%; height: 38px; border-radius: 6px; border: 1px solid rgb(var(--c-line));
  background: rgb(var(--c-panel)); color: rgb(var(--c-ink)); font: inherit; font-size: 14px; padding: 0 8px;
}

/* ---------- Chapter header ---------- */
.eyebrow { font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; color: rgb(var(--c-accent)); font-weight: 600; margin: 0 0 6px; }
h1 { font-size: clamp(28px, 4.2vw, 40px); line-height: 1.15; margin: 0 0 12px; letter-spacing: -0.01em; }
.lede { font-size: 18.5px; color: rgb(var(--c-sub)); margin: 0 0 20px; }
.meta { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; color: rgb(var(--c-mute)); margin-bottom: 24px; }
.meta span { display: inline-flex; gap: 6px; align-items: center; }
h2 { font-size: 23px; line-height: 1.25; margin: 44px 0 10px; letter-spacing: -0.005em; scroll-margin-top: 80px; }
h3 { font-size: 17.5px; margin: 28px 0 6px; }
p { margin: 0 0 14px; }
ul, ol { padding-left: 22px; margin: 0 0 14px; }
li { margin: 4px 0; }
strong { font-weight: 650; }

/* ---------- Panels & callouts ---------- */
.panel { background: rgb(var(--c-panel)); border: 1px solid rgb(var(--c-line)); border-radius: 10px; padding: 16px 18px; margin: 18px 0; }
.objectives { background: rgb(var(--c-panel)); border: 1px solid rgb(var(--c-line)); border-radius: 10px; padding: 14px 18px; margin: 4px 0 28px; }
.objectives h2 { margin: 0 0 6px; font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; color: rgb(var(--c-mute)); }
.objectives ul { margin: 0; }
.callout {
  border: 1px solid rgb(var(--c-line)); border-left: 3px solid rgb(var(--c-accent));
  background: rgb(var(--c-accent) / 0.07); border-radius: 8px; padding: 12px 16px; margin: 18px 0;
}
.callout .label { display: block; font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; font-weight: 650; color: rgb(var(--c-accent)); margin-bottom: 2px; }
.callout p:last-child { margin-bottom: 0; }
.callout.analogy { border-left-color: rgb(var(--c-sun)); background: rgb(var(--c-sun) / 0.08); }
.callout.analogy .label { color: rgb(var(--c-sun)); }
.callout.ops { border-left-color: rgb(var(--c-good)); background: rgb(var(--c-good) / 0.07); }
.callout.ops .label { color: rgb(var(--c-good)); }
.callout.caution { border-left-color: rgb(var(--c-warn)); background: rgb(var(--c-warn) / 0.08); }
.callout.caution .label { color: rgb(var(--c-warn)); }
.callout.nz { border-left-color: rgb(var(--c-field)); background: rgb(var(--c-field) / 0.08); }
.callout.nz .label { color: rgb(var(--c-field)); }

.takeaways { border: 1px solid rgb(var(--c-accent) / 0.45); background: rgb(var(--c-accent) / 0.06); border-radius: 10px; padding: 14px 18px; margin: 36px 0 18px; }
.takeaways h2 { margin: 0 0 6px; font-size: 18px; }
.takeaways ul { margin: 0; }

/* ---------- Figures & animations ---------- */
figure { margin: 22px 0; }
.fig {
  position: relative; border: 1px solid rgb(var(--c-line)); border-radius: 10px; overflow: hidden;
  background: rgb(var(--c-space));
}
.fig canvas, .fig svg.art { display: block; width: 100%; height: auto; }
.fig-bar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 8px 12px; border-top: 1px solid rgb(var(--c-line)); background: rgb(var(--c-panel));
  font-size: 12.5px; color: rgb(var(--c-sub));
}
.fig-bar label { display: inline-flex; align-items: center; gap: 8px; }
.fig-bar input[type='range'] { width: 160px; accent-color: rgb(var(--c-accent)); }
.fig-bar .spacer { flex: 1; }
.fig-bar .readout { font-variant-numeric: tabular-nums; color: rgb(var(--c-ink)); font-weight: 600; }
.chip {
  height: 28px; padding: 0 10px; border-radius: 999px; border: 1px solid rgb(var(--c-line)); background: transparent;
  color: rgb(var(--c-sub)); font: inherit; font-size: 12.5px; cursor: pointer;
}
.chip[aria-pressed='true'] { border-color: rgb(var(--c-accent)); background: rgb(var(--c-accent) / 0.16); color: rgb(var(--c-ink)); }
.chip.south[aria-pressed='true'] { border-color: rgb(var(--c-critical)); background: rgb(var(--c-critical) / 0.16); }
.chip.north[aria-pressed='true'] { border-color: rgb(var(--c-bznorth)); background: rgb(var(--c-bznorth) / 0.16); }
.playpause { width: 28px; height: 28px; display: inline-grid; place-items: center; border-radius: 6px; border: 1px solid rgb(var(--c-line)); background: transparent; color: rgb(var(--c-ink)); cursor: pointer; padding: 0; }
.playpause svg { width: 12px; height: 12px; }
figcaption { font-size: 13.5px; color: rgb(var(--c-sub)); margin-top: 8px; line-height: 1.5; }
figcaption b { color: rgb(var(--c-ink)); font-weight: 600; }
.live-img { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.live-img .fig img { display: block; width: 100%; aspect-ratio: 1 / 1; object-fit: cover; background: #000; }
.live-img .fig .fallback { display: none; aspect-ratio: 1/1; place-items: center; text-align: center; padding: 20px; color: rgb(var(--c-sub)); font-size: 13px; }
.live-img .fig.failed img { display: none; }
.live-img .fig.failed .fallback { display: grid; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; color: rgb(var(--c-sub)); margin-top: 6px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; margin: 16px 0; border: 1px solid rgb(var(--c-line)); border-radius: 10px; }
table { border-collapse: collapse; width: 100%; font-size: 14.5px; background: rgb(var(--c-panel)); }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid rgb(var(--c-line)); vertical-align: top; }
th { font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: rgb(var(--c-mute)); font-weight: 600; background: rgb(var(--c-raised)); }
tr:last-child td { border-bottom: 0; }
.pill { display: inline-block; min-width: 34px; text-align: center; padding: 1px 8px; border-radius: 5px; font-size: 12.5px; font-weight: 650; font-variant-numeric: tabular-nums; }
.pill.g1 { background: rgb(var(--c-warn) / 0.16); color: rgb(var(--c-warn)); }
.pill.g2 { background: rgb(var(--c-warn) / 0.24); color: rgb(var(--c-warn)); }
.pill.g3 { background: rgb(var(--c-serious) / 0.22); color: rgb(var(--c-serious)); }
.pill.g4 { background: rgb(var(--c-critical) / 0.2); color: rgb(var(--c-critical)); }
.pill.g5 { background: rgb(var(--c-critical)); color: #fff; }
.pill.ok { background: rgb(var(--c-good) / 0.18); color: rgb(var(--c-good)); }

/* ---------- Step lists ---------- */
.steps { list-style: none; padding: 0; counter-reset: step; margin: 18px 0; }
.steps li { position: relative; padding: 2px 0 12px 44px; margin: 0; counter-increment: step; }
.steps li::before {
  content: counter(step); position: absolute; left: 0; top: 0; width: 28px; height: 28px; border-radius: 50%;
  display: grid; place-items: center; font-size: 13px; font-weight: 650; font-variant-numeric: tabular-nums;
  background: rgb(var(--c-accent) / 0.16); color: rgb(var(--c-accent)); border: 1px solid rgb(var(--c-accent) / 0.5);
}
.steps li::after { content: ''; position: absolute; left: 13.5px; top: 30px; bottom: 0; width: 1px; background: rgb(var(--c-line)); }
.steps li:last-child::after { display: none; }

.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; margin: 16px 0; }
.card { background: rgb(var(--c-panel)); border: 1px solid rgb(var(--c-line)); border-radius: 10px; padding: 14px 16px; }
.card h3 { margin: 0 0 4px; font-size: 15.5px; }
.card p { margin: 0; font-size: 14.5px; color: rgb(var(--c-sub)); }
.card .tag { font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: rgb(var(--c-mute)); font-weight: 600; }
.card .big { font-size: 24px; font-weight: 650; font-variant-numeric: tabular-nums; color: rgb(var(--c-ink)); line-height: 1.2; margin: 2px 0 4px; }

/* ---------- Quiz ---------- */
.quiz { background: rgb(var(--c-panel)); border: 1px solid rgb(var(--c-line)); border-radius: 10px; padding: 16px 18px; margin: 18px 0; }
.quiz h2 { margin: 0 0 4px; font-size: 18px; }
.quiz .q { margin: 16px 0 0; }
.quiz .q > p { font-weight: 600; margin-bottom: 8px; }
.quiz .opts { display: grid; gap: 6px; }
.quiz button.opt {
  text-align: left; font: inherit; font-size: 14.5px; color: rgb(var(--c-ink)); cursor: pointer;
  border: 1px solid rgb(var(--c-line)); background: rgb(var(--c-raised)); border-radius: 8px; padding: 9px 12px;
}
.quiz button.opt:hover:not(:disabled) { border-color: rgb(var(--c-accent) / 0.7); }
.quiz button.opt.right { border-color: rgb(var(--c-good)); background: rgb(var(--c-good) / 0.14); }
.quiz button.opt.wrong { border-color: rgb(var(--c-critical)); background: rgb(var(--c-critical) / 0.12); }
.quiz button.opt:disabled { cursor: default; }
.quiz .why { display: none; margin-top: 8px; font-size: 14px; color: rgb(var(--c-sub)); padding-left: 10px; border-left: 2px solid rgb(var(--c-line)); }
.quiz .q.answered .why { display: block; }
.quiz .score { margin-top: 14px; font-size: 14px; color: rgb(var(--c-sub)); }

/* ---------- Prev / next ---------- */
.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 40px; }
.pager a {
  display: block; padding: 12px 14px; border: 1px solid rgb(var(--c-line)); border-radius: 10px; text-decoration: none;
  background: rgb(var(--c-panel)); color: rgb(var(--c-ink));
}
.pager a:hover { border-color: rgb(var(--c-accent) / 0.7); }
.pager small { display: block; font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: rgb(var(--c-mute)); }
.pager .next { text-align: right; grid-column: 2; }
.complete-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 28px; font-size: 14px; color: rgb(var(--c-sub)); }

/* ---------- Program home ---------- */
.hero { position: relative; border-bottom: 1px solid rgb(var(--c-line)); overflow: hidden; background: rgb(var(--c-space)); }
.hero canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.hero-inner { position: relative; max-width: 1280px; margin: 0 auto; padding: 72px 16px 64px; }
.hero h1 { color: #e6edf3; max-width: 760px; font-size: clamp(30px, 5vw, 50px); }
.hero .lede { color: #a0acba; max-width: 640px; }
.hero .eyebrow { color: #6aa8ef; }
.chain { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 18px; font-size: 13px; color: #c6d0da; }
.chain span { padding: 4px 10px; border-radius: 999px; border: 1px solid rgba(160,172,186,0.35); background: rgba(11,15,20,0.55); }
.chain b { color: #6e7a88; font-weight: 400; }
.chapters { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; margin: 18px 0 40px; }
.chapter-card {
  display: grid; grid-template-rows: auto 1fr auto; gap: 6px; padding: 16px 16px 14px; border-radius: 10px; text-decoration: none;
  border: 1px solid rgb(var(--c-line)); background: rgb(var(--c-panel)); color: rgb(var(--c-ink)); min-height: 170px;
}
.chapter-card:hover { border-color: rgb(var(--c-accent) / 0.7); background: rgb(var(--c-raised)); }
.chapter-card .top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.chapter-card .n { font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; color: rgb(var(--c-accent)); font-weight: 650; }
.chapter-card h3 { margin: 2px 0 0; font-size: 17px; line-height: 1.3; }
.chapter-card p { margin: 0; color: rgb(var(--c-sub)); font-size: 14px; line-height: 1.5; }
.chapter-card .foot { display: flex; justify-content: space-between; font-size: 12px; color: rgb(var(--c-mute)); }
.status-dot { font-size: 11.5px; color: rgb(var(--c-mute)); display: inline-flex; align-items: center; gap: 5px; }
.status-dot::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: rgb(var(--c-line)); }
.status-dot.yes { color: rgb(var(--c-good)); }
.status-dot.yes::before { background: rgb(var(--c-good)); }
.section-title { font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; color: rgb(var(--c-mute)); margin: 36px 0 0; font-weight: 600; }

/* ---------- Glossary ---------- */
.gloss { display: grid; gap: 0; border: 1px solid rgb(var(--c-line)); border-radius: 10px; overflow: hidden; background: rgb(var(--c-panel)); }
.gloss div { display: grid; grid-template-columns: 200px 1fr; gap: 16px; padding: 10px 14px; border-bottom: 1px solid rgb(var(--c-line)); }
.gloss div:last-child { border-bottom: 0; }
.gloss dt { font-weight: 650; }
.gloss dd { margin: 0; color: rgb(var(--c-sub)); font-size: 15px; }
@media (max-width: 600px) { .gloss div { grid-template-columns: 1fr; gap: 2px; } }
.search { width: 100%; max-width: 420px; height: 38px; border-radius: 6px; border: 1px solid rgb(var(--c-line)); background: rgb(var(--c-panel)); color: rgb(var(--c-ink)); font: inherit; font-size: 14.5px; padding: 0 12px; margin: 8px 0 16px; }

footer.site { border-top: 1px solid rgb(var(--c-line)); color: rgb(var(--c-mute)); font-size: 12.5px; }
footer.site .wrap { padding: 18px 16px 28px; display: flex; gap: 16px; flex-wrap: wrap; justify-content: space-between; }

@media (max-width: 600px) {
  body { font-size: 16px; }
  .lede { font-size: 17px; }
  .brand-sub { display: none; }
  .btn .hide-sm { display: none; }
  .fig-bar input[type='range'] { width: 120px; }
  .pager { grid-template-columns: 1fr; }
  .pager .next { grid-column: 1; }
}
@media print {
  .topbar, .sidebar, .pager, .fig-bar, .complete-row, .mobile-chapter { display: none !important; }
  .chapter-layout { display: block; }
}

/* Fold-away quizzes and takeaways (8 Nov 2026) */
section.folded { padding: 0; }
details.fold > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-radius: 10px; }
details.fold > summary::-webkit-details-marker { display: none; }
details.fold > summary h2 { margin: 0; flex: 1; }
details.fold > summary::after { content: ''; width: 9px; height: 9px; border: solid rgb(var(--c-sub)); border-width: 0 2px 2px 0; transform: rotate(45deg); margin: -4px 4px 0 0; transition: transform .15s; flex: none; }
details.fold > summary::after { order: 3; }
details.fold[open] > summary::after { transform: rotate(-135deg); margin-top: 4px; }
details.fold > summary:hover h2 { color: rgb(var(--c-accent)); }
details.fold > summary:focus-visible { outline: 2px solid rgb(var(--c-accent)); outline-offset: 2px; }
details.fold > .fold-body { padding: 0 18px 16px; }
details.fold:not([open]) > summary::before { content: 'Tap to open'; order: 2; font-size: 12px; color: rgb(var(--c-mute)); }
