/* PPA Helper — a clean-energy markets & finance workbench.
   Identity: cool near-white surfaces, electric-blue accent, grotesque-sans
   display type, monospace data spine, soft elevation on cards.
   See docs/design.md. System fonts only; no web fonts, no frameworks. */

:root {
  --font-sans: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-display: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;

  /* cool surfaces + ink */
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-2: #eef1f6;
  --border: #dde3ec;
  --rule: #0b1220;            /* masthead / strong rule lines */
  --text: #101828;
  --text-muted: #5a6675;

  /* electric blue — the single brand accent */
  --accent: #2563eb;
  --accent-ink: #ffffff;
  --accent-soft: #e7effe;

  /* semantic money-flow — only ever on settlement direction */
  --flow-credit: #1a8f52;     /* party receives */
  --flow-debit: #d64545;      /* party pays */
  --warn: #d64545;

  /* supply-stack layers (Serve the load chart) — never for money flow */
  --stack-nuclear: #2563eb;
  --stack-solar: #d97706;
  --stack-wind: #0d9488;
  --stack-batt: #7c3aed;
  --stack-gas: #8a7357;
  --stack-grid: #c3ccd8;

  --shadow-card: 0 1px 2px rgba(16, 24, 40, 0.04), 0 1px 3px rgba(16, 24, 40, 0.08);
  --shadow-pop: 0 10px 30px rgba(16, 24, 40, 0.14);

  font-feature-settings: "tnum" 1;
}

[data-theme="dark"] {
  --bg: #0b0f14;
  --surface: #12181f;
  --surface-2: #1b232c;
  --border: #29333e;
  --rule: #e6edf3;
  --text: #e6edf3;
  --text-muted: #97a4b2;
  --accent: #5b9bff;
  --accent-ink: #0b0f14;
  --accent-soft: #15202e;
  --flow-credit: #3fb27f;
  --flow-debit: #e06c6c;
  --warn: #e06c6c;

  --stack-nuclear: #5b9bff;
  --stack-solar: #f0a94a;
  --stack-wind: #45c4b5;
  --stack-batt: #a78bfa;
  --stack-gas: #b09a7d;
  --stack-grid: #3a4653;

  --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-pop: 0 10px 30px rgba(0, 0, 0, 0.55);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

[hidden] { display: none !important; }   /* the [hidden] trap guard */

h1, h2, h3 { font-family: var(--font-display); font-weight: 700; line-height: 1.15; letter-spacing: -0.02em; }
h1 { font-size: 2.05rem; margin: 0; }
h2 { font-size: 1.5rem; margin: 0 0 12px; }
h3 { font-size: 1.12rem; margin: 24px 0 8px; font-weight: 650; letter-spacing: -0.01em; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

p { margin: 0 0 14px; max-width: 68ch; }

.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.eyebrow { font-size: 11px; text-transform: uppercase; letter-spacing: 0.14em; color: var(--text-muted); font-weight: 600; }

/* skip link */
.skip-link {
  position: absolute; left: -999px; top: 0; z-index: 100;
  background: var(--accent); color: var(--accent-ink); padding: 8px 14px; border-radius: 0 0 8px 0;
}
.skip-link:focus { left: 0; }

/* screen-reader-only text (e.g. "(done)" on completed course tabs) */
.visually-hidden {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---- masthead ---- */
.masthead {
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(8px);
  position: sticky; top: 0; z-index: 40;
}
.masthead-inner {
  max-width: 1180px; margin: 0 auto; padding: 10px 22px;
  display: grid; align-items: center; gap: 8px 16px;
  grid-template-columns: auto 1fr auto;
  grid-template-areas: "brand controls theme";
}
.wordmark { grid-area: brand; font-family: var(--font-display); font-size: 1.3rem; font-weight: 800; letter-spacing: -0.03em; }
.wordmark .spark { color: var(--accent); }
.masthead-controls { grid-area: controls; justify-self: end; display: flex; align-items: center; gap: 10px; }
.theme-toggle { grid-area: theme; }

/* icon buttons in the masthead (theme toggle) */
.theme-toggle {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; padding: 0;
  background: none; border: 1px solid var(--border); border-radius: 8px;
  color: var(--text-muted); cursor: pointer;
}
.theme-toggle:hover { color: var(--text); border-color: var(--accent); }

/* masthead resume chip (appears once the course starts — jumps to first unfinished stop) */
.progress-chip {
  font-size: 12.5px; font-weight: 600; background: none;
  border: 1px solid var(--border); color: var(--text);
  border-radius: 8px; padding: 6px 12px; cursor: pointer; min-height: 34px;
}
.progress-chip:hover { border-color: var(--accent); color: var(--accent); }

/* masthead search button — reads as a search field (opens the quick-nav palette) */
.search-btn {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 12.5px; background: var(--surface); color: var(--text-muted);
  border: 1px solid var(--border); border-radius: 8px;
  padding: 6px 10px; cursor: pointer; min-height: 34px;
}
.search-btn:hover { color: var(--text); border-color: var(--accent); }
.search-btn svg { flex-shrink: 0; }
.search-btn .sb-key {
  font-family: var(--font-mono); font-size: 11px; line-height: 15px;
  border: 1px solid var(--border); border-radius: 5px; padding: 0 5px; color: var(--text-muted);
}

/* floating back-to-top (appears after scrolling; fast return without scrubbing) */
.to-top {
  position: fixed; right: 22px; bottom: 22px; z-index: 50;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; box-sizing: border-box;
  background: var(--accent); color: var(--accent-ink); border: none;
  border-radius: 999px; padding: 10px 18px; font-size: 13px; font-weight: 600;
  cursor: pointer; box-shadow: var(--shadow-pop);
  opacity: 0; transform: translateY(10px); pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
}
.to-top.show { opacity: 1; transform: none; pointer-events: auto; }
@media (max-width: 639px) { .to-top { right: 14px; bottom: 14px; } }

/* ---- nav (view switcher) ---- */
nav.views {
  max-width: 1180px; margin: 0 auto; padding: 0 14px;
  display: flex; gap: 2px; overflow-x: auto; -webkit-overflow-scrolling: touch;
}
.nav-btn {
  font-family: var(--font-sans); font-size: 13.5px; font-weight: 600;
  background: none; border: none; border-bottom: 2px solid transparent;
  color: var(--text-muted); padding: 12px 14px; cursor: pointer; white-space: nowrap;
  min-height: 44px;
}
.nav-btn:hover { color: var(--text); }
.nav-btn[aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); }

/* course order cues: numbers (both levels — the course order is canonical), done ticks, reference-group divider */
.nav-btn .course-num { font-family: var(--font-mono); font-size: 10.5px; color: var(--text-muted); margin-right: 6px; }
.nav-btn[aria-selected="true"] .course-num { color: var(--accent); }
.nav-btn .tick { display: none; color: var(--accent); font-weight: 700; margin-left: 5px; }
.nav-btn.done .tick { display: inline; }
.nav-sep { align-self: center; width: 1px; height: 18px; background: var(--border); margin: 0 6px; flex-shrink: 0; }
.nav-ref { color: color-mix(in srgb, var(--text-muted) 75%, transparent); }
.nav-ref:hover, .nav-ref[aria-selected="true"] { color: var(--text); }

/* Newcomer level stubs: slim in-place row where a practitioner section is hidden */
.level-stub {
  display: flex; align-items: baseline; gap: 10px 14px; flex-wrap: wrap;
  width: 100%; text-align: left; cursor: pointer; font: inherit;
  background: var(--surface-2); color: var(--text);
  border: 1px dashed var(--border); border-radius: 12px;
  padding: 12px 16px; margin: 18px 0;
  transition: border-color 120ms ease, background 120ms ease;
}
.level-stub:hover, .level-stub:focus-visible { border-color: var(--accent); background: var(--accent-soft); }
.level-stub:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.level-stub-eyebrow { font-family: var(--font-mono); font-size: 10.5px; letter-spacing: .04em; text-transform: uppercase; color: var(--accent); }
.level-stub-title { font-weight: 600; font-size: 15px; }
.level-stub-cta { color: var(--text-muted); font-size: 12.5px; margin-left: auto; }
@media (max-width: 560px) { .level-stub-cta { margin-left: 0; } }

/* Partial-state count line for level-filtered lists */
.level-count { font-family: var(--font-mono); font-size: 12px; color: var(--text-muted); margin: 4px 0 12px; }

/* ---- layout ---- */
main { max-width: 1180px; margin: 0 auto; padding: 28px 22px 80px; }
.view { animation: fade 200ms ease; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.lede {
  font-family: var(--font-sans); font-size: 1.16rem; font-weight: 400; line-height: 1.5; color: var(--text-muted);
  max-width: 64ch; margin: 8px 0 24px; letter-spacing: -0.005em;
}

.rule { border: none; border-top: 1px solid var(--border); margin: 28px 0; }

/* ---- cards / grid ---- */
.grid { display: grid; gap: 16px; }
@media (min-width: 640px) { .grid.cols-2 { grid-template-columns: 1fr 1fr; } }
@media (min-width: 1024px) { .grid.cols-3 { grid-template-columns: repeat(3, 1fr); } }

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 16px 18px;
  box-shadow: var(--shadow-card);
}
.card h3 { margin-top: 0; }
.card.flush { padding: 0; overflow: hidden; }

/* pills */
.pill {
  display: inline-block; padding: 1px 8px; border-radius: 999px;
  font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em;
  vertical-align: middle;
}
.pill.outline { border: 1px solid var(--border); color: var(--text-muted); background: none; }
.pill.verified { border: 1px solid var(--flow-credit); color: var(--flow-credit); background: none; }
.pill.secondary { border: 1px solid var(--accent); color: var(--accent); background: none; }
.pill.gap { border: 1px solid var(--warn); color: var(--warn); background: none; }

/* source trail */
.src { font-size: 12px; color: var(--text-muted); }
.src::before { content: "Source: "; }

/* ---- simulator ---- */
.sim-layout { display: grid; gap: 22px; }
@media (min-width: 1024px) { .sim-layout { grid-template-columns: 320px 1fr; align-items: start; } }

.controls { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 18px; }
.controls fieldset { border: none; margin: 0 0 18px; padding: 0; }
.controls legend { font-size: 11px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--text-muted); font-weight: 700; padding: 0; margin-bottom: 10px; }

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 4px; }
.field .hint { font-size: 11.5px; color: var(--text-muted); font-weight: 400; }
.field input[type="number"] {
  width: 100%; font-family: var(--font-mono); font-variant-numeric: tabular-nums;
  font-size: 16px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface-2); color: var(--text);
}
.field input[type="range"] { width: 100%; accent-color: var(--accent); }

.scenario-row { display: flex; flex-wrap: wrap; gap: 6px; }
.scenario-btn {
  font-size: 12px; font-weight: 600; padding: 7px 12px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text); cursor: pointer; min-height: 44px;
}
.scenario-btn[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); color: var(--text); }

.toggle-row { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.toggle-row button {
  font-size: 12.5px; font-weight: 600; padding: 8px 14px; border: none; background: var(--surface-2);
  color: var(--text-muted); cursor: pointer; min-height: 40px;
}
.toggle-row button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }

/* readout (data spine) */
.readout { display: grid; gap: 12px; }
.kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (min-width: 640px) { .kpis { grid-template-columns: repeat(3, 1fr); } }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; }
.kpi .k-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-muted); font-weight: 600; }
.kpi .k-val { font-family: var(--font-display); font-variant-numeric: tabular-nums; font-size: 1.7rem; margin-top: 2px; line-height: 1.1; }
.kpi .k-sub { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.k-val.credit { color: var(--flow-credit); }
.k-val.debit { color: var(--flow-debit); }

.direction-banner {
  font-family: var(--font-mono); font-size: 13.5px; padding: 12px 16px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface);
}
.direction-banner strong { font-weight: 700; }
.direction-banner.credit { border-color: var(--flow-credit); }
.direction-banner.debit { border-color: var(--flow-debit); }

/* chart */
.chart-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 14px 12px 6px; }
.chart-wrap svg { width: 100%; height: auto; display: block; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 12px; color: var(--text-muted); padding: 6px 6px 4px; }
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
.swatch { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }

/* capital-stack bar (project finance) */
/* case studies (Data centers tab) */
.case-history { margin: 0 0 12px; padding-left: 18px; font-size: 13.5px; }
.case-history li { margin: 3px 0; }
.case-date { color: var(--text-muted); font-size: 12px; white-space: nowrap; margin-right: 4px; }
.case-meta { margin: 0 0 8px; }
.case-participants { font-size: 13.5px; color: var(--text-muted); max-width: none; }

.cap-stack { display: flex; width: 100%; height: 40px; border-radius: 8px; overflow: hidden; border: 1px solid var(--border); }
.cap-seg { display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; color: #fff; white-space: nowrap; transition: width 220ms ease; letter-spacing: 0.02em; }
.cap-seg.cap-tax { background: var(--text-muted); }
.cap-seg.cap-debt { background: var(--accent); }
.cap-seg.cap-equity { background: var(--flow-credit); }
.cap-stack-legend { display: flex; flex-wrap: wrap; gap: 16px; font-size: 12.5px; color: var(--text-muted); margin-top: 10px; }
.cap-stack-legend span { display: inline-flex; align-items: center; gap: 6px; }
.swatch.cap-tax { background: var(--text-muted); }
.swatch.cap-debt { background: var(--accent); }
.swatch.cap-equity { background: var(--flow-credit); }

/* settlement table */
.table-wrap { overflow-x: auto; }
table.settle { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.settle th, table.settle td { padding: 7px 10px; text-align: right; border-bottom: 1px solid var(--border); }
table.settle th:first-child, table.settle td:first-child { text-align: left; }
table.settle th { font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); font-weight: 700; }
table.settle td.num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
table.settle td.credit { color: var(--flow-credit); }
table.settle td.debit { color: var(--flow-debit); }
table.settle tfoot td { font-weight: 700; border-top: 2px solid var(--rule); border-bottom: none; }

/* ---- glossary ---- */
.glossary-controls { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 18px; align-items: center; }
#glossary-search {
  flex: 1; min-width: 200px; font-size: 16px; padding: 9px 12px; border: 1px solid var(--border);
  border-radius: 8px; background: var(--surface); color: var(--text);
}
.cat-filter { display: flex; gap: 6px; flex-wrap: wrap; }
.cat-btn { font-size: 12px; font-weight: 600; padding: 6px 10px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); color: var(--text-muted); cursor: pointer; min-height: 36px; }
.cat-btn[aria-pressed="true"] { border-color: var(--accent); color: var(--text); background: var(--accent-soft); }

.term {
  background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--accent);
  border-radius: 8px; padding: 13px 16px;
}
.term dt { font-family: var(--font-display); font-size: 1.08rem; font-weight: 600; display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.term dd { margin: 6px 0 0; color: var(--text); font-size: 14px; }
.term .term-cat { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-muted); font-weight: 700; }

/* ---- coverage scorecard ---- */
table.coverage { width: 100%; border-collapse: collapse; font-size: 14px; }
table.coverage th, table.coverage td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
table.coverage th { font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); }

/* per-view "On this page" contents bar */
.toc { margin: 14px 0 4px; }
.toc ol { list-style: none; counter-reset: toc; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 4px 16px; }
.toc li { counter-increment: toc; }
.toc-link {
  font: inherit; font-size: 13px; background: none; border: none; padding: 0;
  color: var(--text-muted); cursor: pointer; border-bottom: 1px dotted transparent;
}
.toc-link::before { content: counter(toc); color: var(--accent); font-weight: 700; margin-right: 5px; font-feature-settings: "tnum" 1; }
.toc-link:hover, .toc-link:focus-visible { color: var(--text); border-bottom-color: var(--accent); }
.toc-link.active { color: var(--text); border-bottom-style: solid; border-bottom-color: var(--accent); }
h2[id] { scroll-margin-top: 96px; }

/* on wide screens the contents bar sticks just under the masthead (scroll-spy highlights the section) */
@media (min-width: 900px) {
  .toc { position: sticky; top: 96px; z-index: 20; background: var(--bg); padding: 8px 0; border-bottom: 1px solid var(--border); }
  h2[id] { scroll-margin-top: 150px; }
}

/* inline glossary tooltip terms */
.gterm { border-bottom: 1px dotted var(--accent); cursor: help; }
.gterm-auto { border-bottom-color: var(--border); }
.gterm:hover, .gterm:focus-visible { border-bottom-color: var(--accent); border-bottom-style: solid; }

/* hover explainer card (shared, positioned by app.js) */
.term-card {
  position: fixed; z-index: 60; max-width: 340px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  padding: 12px 14px; box-shadow: var(--shadow-pop);
  font-size: 13.5px; line-height: 1.5;
}
.term-card p { margin: 0 0 6px; max-width: none; }
.term-card .term-card-name { font-weight: 700; font-family: var(--font-display); }
.term-card .term-card-name .term-cat { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-muted); font-weight: 700; margin-left: 4px; }
.term-card .term-card-src { font-size: 12px; color: var(--text-muted); }
.term-card .term-card-src a { color: var(--accent); }
.term-card .term-card-hint { font-size: 11.5px; color: var(--text-muted); margin-bottom: 0; border-top: 1px solid var(--border); padding-top: 6px; }

/* ---- footer ---- */
footer {
  border-top: 1px solid var(--border); margin-top: 40px;
  font-size: 12.5px; color: var(--text-muted);
}
.footer-inner { max-width: 1180px; margin: 0 auto; padding: 20px 22px; }
.footer-inner a { color: var(--text-muted); text-decoration: underline; }

/* focus */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button, a, input, [tabindex] { touch-action: manipulation; }

@media (prefers-reduced-motion: reduce) {
  .view { animation: none; }
  * { transition: none !important; }
}

@media (max-width: 639px) {
  h1 { font-size: 1.6rem; }
  main { padding: 20px 16px 70px; }
  .lede { font-size: 1.06rem; }
  /* brand + theme share the top row; controls flow to their own row below */
  .masthead-inner { grid-template-columns: 1fr auto; grid-template-areas: "brand theme" "controls controls"; }
  .masthead-controls { justify-self: stretch; width: 100%; justify-content: space-between; }
}

/* ---- level filter + inline nav links ---- */
.lvl-hidden { display: none !important; }
.level-filter { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.level-filter button { font-size: 12px; font-weight: 600; padding: 6px 10px; border: none; background: var(--surface); color: var(--text-muted); cursor: pointer; min-height: 32px; }
.level-filter button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }
.nav-link-btn { background: none; border: none; color: var(--accent); font: inherit; cursor: pointer; padding: 0; text-decoration: underline; }

/* ---- example PPAs (annotated) ---- */
.example-pills { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.example-pill { font-family: var(--font-display); font-size: 15px; font-weight: 600; padding: 9px 14px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); cursor: pointer; min-height: 44px; }
.example-pill[aria-selected="true"] { border-color: var(--accent); background: var(--accent-soft); }
.example-summary { font-size: 15px; color: var(--text-muted); max-width: 72ch; margin: 0 0 18px; }

.annotate { display: grid; gap: 16px; }
@media (min-width: 860px) { .annotate { grid-template-columns: 304px 1fr; align-items: start; } }

.clause-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.clause-row { width: 100%; text-align: left; display: flex; flex-direction: column; gap: 2px; padding: 9px 12px; border: 1px solid var(--border); border-left: 3px solid transparent; border-radius: 8px; background: var(--surface); color: var(--text); cursor: pointer; min-height: 44px; }
.clause-row:hover { border-color: var(--accent); }
.clause-row[aria-selected="true"] { border-left-color: var(--accent); background: var(--accent-soft); }
.clause-label { font-size: 13px; font-weight: 600; }
.clause-val { font-size: 11.5px; color: var(--text-muted); }

.clause-detail { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 18px 20px; }
.clause-detail h3 { margin: 8px 0 6px; }
.clause-detail-val { font-size: 14px; color: var(--accent); margin: 0 0 12px; }
@media (min-width: 860px) {
  .clause-detail { position: sticky; top: 116px; }
}

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.chip { font-size: 12px; font-weight: 600; padding: 5px 10px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); cursor: pointer; min-height: 32px; }
.chip:hover { border-color: var(--accent); color: var(--accent); }
.gloss-chip::before { content: "\21AA\00A0"; color: var(--accent); }

/* ---- data centers ---- */
.dc-structure { border: 1px solid var(--border); border-radius: 10px; margin-bottom: 8px; background: var(--surface); overflow: hidden; }
.dc-structure > summary { list-style: none; cursor: pointer; padding: 13px 16px; display: flex; align-items: center; gap: 10px; min-height: 44px; }
.dc-structure > summary::-webkit-details-marker { display: none; }
.dc-structure > summary .pill { margin-left: auto; }
.dc-structure > summary::after { content: "+"; color: var(--text-muted); font-size: 18px; width: 14px; text-align: center; }
.dc-structure[open] > summary::after { content: "\2212"; }
.dc-structure[open] > summary { border-bottom: 1px solid var(--border); }
.dc-s-name { font-family: var(--font-display); font-size: 1.05rem; font-weight: 600; }
.dc-s-body { padding: 14px 16px; }
.dc-s-body p { font-size: 14px; margin: 0 0 10px; max-width: none; }

.dc-filter { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0 14px; }
.dc-filter-btn { font-size: 12px; font-weight: 600; padding: 6px 12px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); color: var(--text-muted); cursor: pointer; min-height: 36px; }
.dc-filter-btn[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); color: var(--text); }

table.dc-table td, table.dc-table th { text-align: left; vertical-align: top; font-size: 13px; }
table.dc-table td.mono { white-space: nowrap; }

/* ---- perspectives ---- */
.voice-card .eyebrow { color: var(--accent); }
.voice-role { font-size: 12.5px; color: var(--text-muted); margin: 2px 0 10px; }
.voice-card p { font-size: 14px; }
.voice-takeaway { background: var(--accent-soft); border-radius: 8px; padding: 10px 12px; font-size: 13.5px; }
.resource-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.resource { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); font-size: 14px; min-height: 44px; }
.resource .pill { flex-shrink: 0; }

/* ---- stage number badges (Learn h2s) ---- */
.stage-n { display: inline-flex; align-items: center; justify-content: center; width: 1.5em; height: 1.5em; border-radius: 999px; background: var(--accent); color: var(--accent-ink); font-size: 0.78em; margin-right: 10px; vertical-align: middle; }

/* ---- course flow: first-visit chooser ---- */
.chooser {
  position: relative; background: var(--surface); border: 1px solid var(--border);
  border-left: 3px solid var(--accent); border-radius: 12px; box-shadow: var(--shadow-card);
  padding: 14px 52px 14px 16px; margin: 0 0 20px;
}
.chooser-choices { display: grid; gap: 10px; }
@media (min-width: 640px) { .chooser-choices { grid-template-columns: 1fr 1fr; } }
.chooser-opt {
  text-align: left; font: inherit; display: grid; gap: 2px; padding: 12px 14px;
  border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2);
  color: var(--text); cursor: pointer; min-height: 44px;
}
.chooser-opt:hover { border-color: var(--accent); background: var(--accent-soft); }
.chooser-opt span { font-size: 13px; color: var(--text-muted); }
.chooser-dismiss {
  position: absolute; top: 2px; right: 2px; width: 44px; height: 44px;
  border: none; background: none; color: var(--text-muted); font-size: 20px;
  cursor: pointer; border-radius: 10px;
}
.chooser-dismiss:hover { color: var(--text); }

/* ---- course flow: practitioner jump index (level 2 only) ---- */
#prac-index { margin: 0 0 20px; }
.prac-groups { display: grid; gap: 10px; margin-top: 8px; }
.prac-group { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; }
.prac-group-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--text-muted); font-weight: 700; min-width: 118px; }
.prac-chip { min-height: 36px; display: inline-flex; align-items: center; }
@media (max-width: 860px) { .prac-chip { min-height: 44px; } }

/* ---- course flow: footer on every stop (prev / mark done / next) ---- */
.course-footer { border-top: 1px solid var(--border); margin-top: 36px; padding-top: 18px; display: grid; gap: 14px; align-items: center; }
@media (min-width: 640px) { .course-footer { grid-template-columns: auto 1fr auto; } }
.cf-prev-btn { font: inherit; font-size: 13.5px; font-weight: 600; background: none; border: none; color: var(--text-muted); cursor: pointer; padding: 10px 0; min-height: 44px; }
.cf-prev-btn:hover { color: var(--accent); }
.cf-mid { display: grid; gap: 4px; justify-items: start; }
@media (min-width: 640px) { .cf-mid { justify-items: center; } }
.cf-mark {
  font: inherit; font-size: 12.5px; font-weight: 600; padding: 8px 14px;
  border: 1px solid var(--border); border-radius: 999px; background: var(--surface);
  color: var(--text-muted); cursor: pointer; min-height: 40px;
}
.cf-mark:hover { border-color: var(--accent); color: var(--text); }
.cf-mark[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.cf-reset { font: inherit; font-size: 11.5px; background: none; border: none; color: var(--text-muted); cursor: pointer; text-decoration: underline; padding: 4px 0; }
.cf-reset:hover { color: var(--text); }
.cf-next-btn {
  display: grid; gap: 3px; text-align: left; font: inherit;
  background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--accent);
  border-radius: 10px; box-shadow: var(--shadow-card); padding: 12px 16px;
  color: var(--text); cursor: pointer; min-height: 44px; max-width: 420px;
}
.cf-next-btn:hover { border-color: var(--accent); background: var(--accent-soft); }
.cf-next-label { font-weight: 700; font-size: 14px; }
.cf-next-teaser { font-size: 12.5px; color: var(--text-muted); }

/* slim reference footer (glossary / coverage): route back into the course */
.ref-footer { border-top: 1px solid var(--border); margin-top: 36px; padding-top: 14px; display: flex; gap: 12px; align-items: baseline; flex-wrap: wrap; }
.ref-resume { font: inherit; font-size: 13.5px; font-weight: 600; background: none; border: none; color: var(--accent); cursor: pointer; padding: 8px 0; min-height: 44px; }
.ref-resume:hover { text-decoration: underline; }

/* ---- generic accordion (foundations on-ramp) ---- */
details.acc { border: 1px solid var(--border); border-radius: 10px; margin-bottom: 8px; background: var(--surface); overflow: hidden; }
details.acc > summary { list-style: none; cursor: pointer; padding: 12px 16px; min-height: 44px; display: flex; align-items: center; font-family: var(--font-display); font-weight: 600; font-size: 1.02rem; }
details.acc > summary::-webkit-details-marker { display: none; }
details.acc > summary::after { content: "+"; margin-left: auto; color: var(--text-muted); font-size: 18px; width: 14px; text-align: center; }
details.acc[open] > summary::after { content: "\2212"; }
details.acc[open] > summary { border-bottom: 1px solid var(--border); }
.acc-body { padding: 12px 16px; }
.acc-body p { font-size: 14px; margin: 0; max-width: none; }

/* ---- numbered process list (drafting steps) ---- */
ol.steps { margin: 0 0 6px; padding-left: 0; list-style: none; counter-reset: step; }
ol.steps li { counter-increment: step; position: relative; padding: 9px 0 9px 40px; border-bottom: 1px solid var(--border); font-size: 15px; max-width: 74ch; }
ol.steps li:last-child { border-bottom: none; }
ol.steps li::before { content: counter(step); position: absolute; left: 0; top: 8px; width: 26px; height: 26px; border-radius: 999px; background: var(--accent); color: var(--accent-ink); font-family: var(--font-display); font-weight: 700; font-size: 14px; display: flex; align-items: center; justify-content: center; }

/* ---- PPA draft generator ---- */
.draft-layout { display: grid; gap: 22px; }
@media (min-width: 1024px) { .draft-layout { grid-template-columns: 340px 1fr; align-items: start; } }

.draft-output {
  font-family: var(--font-mono); font-size: 12.5px; line-height: 1.6;
  white-space: pre-wrap; word-break: break-word;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  padding: 20px 22px; min-height: 400px; max-height: 72vh; overflow-y: auto;
  color: var(--text);
}
.draft-output:empty::before {
  content: "Fill the form and click Generate PPA →";
  color: var(--text-muted); font-style: italic;
}
.draft-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.draft-actions button { font-size: 13px; font-weight: 600; padding: 9px 16px; border-radius: 8px; cursor: pointer; min-height: 40px; }
.btn-primary { background: var(--accent); color: var(--accent-ink); border: none; }
.btn-primary:hover { opacity: 0.9; }
.btn-secondary { background: var(--surface); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { border-color: var(--accent); }
.btn-secondary:disabled { opacity: 0.4; cursor: default; }

/* --- self-check quiz --- */
.quiz { display: grid; gap: 16px; margin-top: 8px; }
.quiz-q { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 16px 18px; }
.quiz-q .q-prompt { font-weight: 600; margin: 0 0 12px; }
.quiz-q .q-num { color: var(--text-muted); font-variant-numeric: tabular-nums; margin-right: 6px; }
.quiz-opts { display: grid; gap: 8px; }
.quiz-opt {
  text-align: left; font: inherit; font-size: 14.5px; line-height: 1.4;
  padding: 10px 14px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface-2); color: var(--text); cursor: pointer; min-height: 44px;
  display: flex; gap: 10px; align-items: baseline;
}
.quiz-opt:hover:not(:disabled) { border-color: var(--accent); }
.quiz-opt:disabled { cursor: default; }
.quiz-opt .opt-key { font-family: var(--font-mono); font-weight: 700; color: var(--text-muted); }
.quiz-opt.correct { border-color: var(--flow-credit); background: var(--accent-soft); }
.quiz-opt.correct .opt-key { color: var(--flow-credit); }
.quiz-opt.wrong { border-color: var(--flow-debit); }
.quiz-opt.wrong .opt-key { color: var(--flow-debit); }
.quiz-explain { margin: 12px 0 0; font-size: 13.5px; color: var(--text-muted); border-left: 3px solid var(--accent); padding-left: 12px; }
.quiz-score { font-weight: 700; font-variant-numeric: tabular-nums; color: var(--text); }
.quiz-note { font-size: 13px; color: var(--text-muted); margin: -4px 0 14px; }
.quiz-foot { display: flex; gap: 12px; align-items: center; font-size: 12.5px; color: var(--text-muted); margin: 0; }
.quiz-foot .btn-secondary, .quiz-result .btn-secondary { font-size: 12.5px; padding: 7px 14px; border-radius: 8px; cursor: pointer; min-height: 38px; }
.quiz-result { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; font-size: 14px; font-weight: 600; }

/* ---- quick-nav palette (/ or Ctrl-K) ---- */
.palette-backdrop {
  position: fixed; inset: 0; z-index: 70;
  background: color-mix(in srgb, var(--rule) 32%, transparent);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 12vh 16px 16px;
}
.palette {
  width: 100%; max-width: 560px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 12px;
  box-shadow: var(--shadow-pop); overflow: hidden;
}
.palette input {
  width: 100%; font: inherit; font-size: 15px; padding: 14px 16px;
  border: none; border-bottom: 1px solid var(--border);
  background: var(--surface); color: var(--text); outline: none;
}
.palette-list { list-style: none; margin: 0; padding: 6px; max-height: 46vh; overflow-y: auto; }
.palette-list li[role="option"] {
  display: flex; gap: 10px; align-items: baseline; justify-content: space-between;
  padding: 9px 10px; border-radius: 8px; cursor: pointer; min-height: 40px;
}
.palette-list li[aria-selected="true"] { background: var(--accent-soft); }
.pal-label { font-size: 14px; font-weight: 600; }
.pal-ctx { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.08em; flex-shrink: 0; }
.palette-empty { padding: 14px 12px; font-size: 13px; color: var(--text-muted); }

/* mobile nav scroll affordance — fade right edge to hint at off-screen tabs */
@media (max-width: 860px) {
  nav.views {
    -webkit-mask-image: linear-gradient(to right, black calc(100% - 48px), transparent 100%);
    mask-image: linear-gradient(to right, black calc(100% - 48px), transparent 100%);
  }
}

