/* Gaining Freedom v2 — base styles. Brand: blue #2E5A88, yellow #FFE699, green #C6E0B4 */
:root {
  --blue: #2E5A88;
  --blue-dark: #234668;
  --yellow: #FFE699;
  --green: #C6E0B4;
  --green-dark: #3d7a3d;
  --red: #b3402e;
  --bg: #f4f6f9;
  --card: #ffffff;
  --ink: #1c2733;
  --muted: #5a6b7c;
  --line: #dde5ee;
  --pop-bg: #1c2733;
  --pop-ink: #ffffff;
  --focus: #9dbede;
}
:root[data-theme="dark"] {
  --blue: #7fa8d0;
  --blue-dark: #a9c6e4;
  --yellow: #4a4632;
  --green: #2e4425;
  --green-dark: #9ccb8a;
  --red: #e08573;
  --bg: #121820;
  --card: #1b2430;
  --ink: #e6edf5;
  --muted: #9db0c3;
  --line: #2c3947;
  --pop-bg: #e6edf5;
  --pop-ink: #121820;
  --focus: #4a6f96;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --blue: #7fa8d0; --blue-dark: #a9c6e4; --yellow: #4a4632; --green: #2e4425;
    --green-dark: #9ccb8a; --red: #e08573; --bg: #121820; --card: #1b2430;
    --ink: #e6edf5; --muted: #9db0c3; --line: #2c3947;
    --pop-bg: #e6edf5; --pop-ink: #121820; --focus: #4a6f96;
  }
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 17px; }
:root[data-bigtext="1"] { font-size: 21px; }
body {
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg); color: var(--ink); line-height: 1.5;
}
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.skip-link { position: absolute; left: -9999px; top: 0; background: var(--yellow); color: #1c2733; padding: 10px 16px; z-index: 50; }
.skip-link:focus { left: 8px; }
a { color: var(--blue); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 1px; }

/* header */
.site-header { background: #2E5A88; color: #fff; padding: 10px 14px 0; }
:root[data-theme="dark"] .site-header { background: #16283c; }
.site-header-row { display: flex; align-items: center; justify-content: space-between; max-width: 760px; margin: 0 auto; }
.site-name { color: #fff; text-decoration: none; font-weight: 800; font-size: 1.15rem; }
.header-tools { display: flex; gap: 8px; }
.tool-btn {
  min-height: 44px; min-width: 44px; border: 1px solid rgba(255,255,255,.4); border-radius: 10px;
  background: transparent; color: #fff; font-size: .95rem; cursor: pointer; padding: 6px 10px;
  display: inline-flex; align-items: center; justify-content: center; text-decoration: none;
}
.tool-btn .bigA { font-size: 1.25rem; }
.site-nav { max-width: 760px; margin: 8px auto 0; display: flex; gap: 4px; overflow-x: auto; padding-bottom: 8px; }
.site-nav a {
  color: #fff; text-decoration: none; font-weight: 700; font-size: .92rem;
  padding: 8px 12px; min-height: 40px; border-radius: 10px 10px 0 0; background: rgba(255,255,255,.12);
  white-space: nowrap; display: inline-flex; align-items: center;
}
.site-nav a[aria-current="true"] { background: var(--bg); color: var(--blue); }

main { max-width: 760px; margin: 0 auto; padding: 16px 12px 32px; }

/* cards + lesson bones */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  padding: 16px 14px; margin: 14px 0; box-shadow: 0 1px 3px rgba(20,40,60,.06);
}
h1 { font-size: 1.55rem; line-height: 1.2; margin: 6px 0 8px; }
h2 { font-size: 1.2rem; color: var(--blue); margin: 18px 0 8px; }
h3 { font-size: 1.02rem; margin: 12px 0 6px; }
p { margin: 0 0 10px; }
ul, ol { padding-left: 22px; margin: 0 0 10px; }
li { margin-bottom: 6px; }
.small { font-size: .88rem; color: var(--muted); }
.lesson-intro { font-size: 1.05rem; color: var(--muted); margin-bottom: 4px; }
.leg-tag { display: inline-block; font-weight: 800; font-size: .8rem; letter-spacing: .04em; text-transform: uppercase; color: var(--blue); }

/* collapsible sections */
details.fold { background: var(--card); border: 1px solid var(--line); border-radius: 14px; margin: 12px 0; overflow: hidden; }
details.fold > summary {
  list-style: none; cursor: pointer; padding: 14px; min-height: 48px;
  font-weight: 700; color: var(--blue); font-size: 1.05rem;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
details.fold > summary::-webkit-details-marker { display: none; }
details.fold > summary::after { content: "+"; font-size: 1.4rem; font-weight: 400; }
details.fold[open] > summary::after { content: "–"; }
details.fold > .fold-body { padding: 0 14px 14px; }

/* mini menu */
.minimenu {
  position: sticky; top: 0; z-index: 20; background: var(--bg);
  padding: 8px 0; margin: 4px 0 8px; border-bottom: 1px solid var(--line);
  font-size: .88rem; overflow-x: auto; white-space: nowrap;
}
.minimenu-label { color: var(--muted); margin-right: 6px; }
.minimenu a { display: inline-block; padding: 6px 8px; min-height: 36px; }

/* character voice boxes */
.example { border-left: 4px solid var(--green-dark); background: var(--card); border-radius: 0 12px 12px 0; padding: 12px 14px; margin: 12px 0; }
.example .who { font-weight: 800; color: var(--green-dark); }
.tip { background: var(--yellow); color: #1c2733; border-radius: 12px; padding: 12px 14px; margin: 12px 0; font-size: .95rem; }
:root[data-theme="dark"] .tip { color: var(--ink); }
.warn-card { background: #fdeeea; color: #b3402e; border-radius: 12px; padding: 12px 14px; margin: 12px 0; }
:root[data-theme="dark"] .warn-card { background: #3a221d; color: #e08573; }

/* glossary term */
.term {
  text-decoration: underline dotted 2px; text-underline-offset: 3px; cursor: pointer;
  background: none; border: none; font: inherit; color: inherit; padding: 0;
}
.glossary-pop {
  position: absolute; z-index: 60; max-width: 320px; background: var(--pop-bg); color: var(--pop-ink);
  border-radius: 12px; padding: 12px 14px; font-size: .92rem; box-shadow: 0 4px 16px rgba(0,0,0,.3);
}
.glossary-pop strong { display: block; margin-bottom: 4px; }
.glossary-pop .pop-close { position: absolute; top: 4px; right: 8px; background: none; border: none; color: inherit; font-size: 1.1rem; cursor: pointer; min-width: 32px; min-height: 32px; }

/* quiz */
.quiz { margin: 16px 0; }
.quiz h2 { margin-top: 0; }
.quiz .q { margin-bottom: 14px; }
.quiz .q p.qtext { font-weight: 700; margin-bottom: 6px; }
.quiz .opts { display: grid; gap: 8px; }
.quiz .opts button {
  text-align: left; padding: 10px 12px; min-height: 44px; border-radius: 10px;
  border: 2px solid var(--line); background: var(--card); color: var(--ink); font: inherit; cursor: pointer;
}
.quiz .opts button[data-state="right"] { border-color: var(--green-dark); background: var(--green); color: #1c2733; }
.quiz .opts button[data-state="wrong"] { border-color: var(--red); background: #fdeeea; color: #b3402e; }
.quiz .why { font-size: .9rem; margin-top: 6px; color: var(--muted); }
.quiz .retry { margin-top: 6px; background: none; border: none; color: var(--blue); font: inherit; cursor: pointer; text-decoration: underline; min-height: 40px; }

/* calculators */
.calc { }
.calc .row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.calc .row label { flex: 1; font-weight: 500; }
.money-wrap { position: relative; width: 140px; flex-shrink: 0; }
.money-wrap span { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--muted); font-weight: 600; }
.calc input[type=number], .calc input[type=date], .calc input[type=text], .calc select {
  width: 100%; min-height: 48px; font-size: 1.05rem; padding: 10px 10px 10px 24px;
  border: 2px solid var(--line); border-radius: 10px; background: var(--yellow); color: #1c2733;
}
.calc select, .calc input[type=date], .calc input[type=text] { padding-left: 10px; background: var(--card); color: var(--ink); }
:root[data-theme="dark"] .calc input[type=number] { color: var(--ink); }
.totals { background: var(--bg); border-radius: 10px; padding: 10px 12px; margin-top: 10px; }
.totals .trow { display: flex; justify-content: space-between; padding: 6px 0; font-size: 1.02rem; }
.big-result {
  margin-top: 10px; border-radius: 10px; padding: 12px; text-align: center;
  font-size: 1.1rem; font-weight: 700; background: var(--green); color: #1c3a1e;
}
:root[data-theme="dark"] .big-result { color: #d9f2cf; }
.big-result.bad { background: #f6d3cc; color: #b3402e; }
button.btn {
  font: inherit; font-weight: 600; min-height: 48px; border: none; border-radius: 10px;
  padding: 10px 16px; cursor: pointer; background: #2E5A88; color: #fff;
}
button.btn.light { background: var(--bg); color: var(--blue); border: 1px solid var(--line); }

/* invest banner + disclaimers */
.invest-banner { background: var(--yellow); color: #1c2733; border-radius: 12px; padding: 12px 14px; margin: 10px 0; }
:root[data-theme="dark"] .invest-banner { color: var(--ink); }
.disclaimer-firm { border: 2px solid var(--red); color: var(--red); border-radius: 12px; padding: 12px 14px; margin: 16px 0; font-size: .95rem; }

/* done + prevnext + footer */
.lesson-done label { display: flex; gap: 10px; align-items: center; font-weight: 600; min-height: 44px; }
.lesson-done input[type=checkbox] { width: 26px; height: 26px; accent-color: #2E5A88; }
.prevnext { display: flex; justify-content: space-between; gap: 10px; margin: 18px 0; }
.prevnext a { display: inline-flex; align-items: center; min-height: 44px; }
.site-footer { border-top: 1px solid var(--line); padding: 18px 14px 26px; text-align: center; }
.site-footer .small { max-width: 700px; margin: 0 auto 8px; }

/* hub */
.hub-hero { text-align: center; padding: 18px 0 6px; }
.hub-hero h1 { font-size: 1.7rem; }
.track-grid { display: grid; gap: 12px; grid-template-columns: 1fr; }
@media (min-width: 640px) { .track-grid { grid-template-columns: 1fr 1fr; } }
.progressbar { background: var(--line); border-radius: 99px; height: 18px; overflow: hidden; margin: 8px 0; }
.progressbar .fill { background: var(--green-dark); height: 100%; border-radius: 99px; min-width: 6px; transition: width .3s; }

img { max-width: 100%; height: auto; border-radius: 12px; }
.diagram { margin: 12px 0; }
.diagram svg { max-width: 100%; height: auto; }
table { border-collapse: collapse; width: 100%; margin: 10px 0; }
th, td { border: 1px solid var(--line); padding: 8px; text-align: left; font-size: .95rem; }
th { background: var(--bg); }
.table-scroll { overflow-x: auto; }
