/* Core Portage microsite — shared styles.
   Tokens on :root; dark values under prefers-color-scheme (guarded so an explicit
   light choice wins) and again under [data-theme="dark"] for the manual toggle. */

:root {
  color-scheme: light;
  --bg: #f9f9f7;
  --surface: #fcfcfb;
  --surface-2: #f2f1ed;
  --surface-3: #e9e8e3;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #6f6d68;
  --line: #e1e0d9;
  --line-strong: #c3c2b7;
  --accent: #2a78d6;
  --accent-strong: #1c5cab;
  --accent-wash: #e8f1fc;
  --trad: #a9a79f;          /* the "army" / traditional series: de-emphasis gray */
  --good: #006300;
  --bad: #b42323;
  --warn-wash: #fdf3dc;
  --path-rescue: #2a78d6;
  --path-switch: #eb6834;
  --path-freedom: #1baf7a;
  --shadow: 0 1px 2px rgba(11, 11, 11, 0.04), 0 4px 16px rgba(11, 11, 11, 0.04);
  --radius: 10px;
  --radius-sm: 6px;
  --max: 1120px;
  --prose: 70ch;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --bg: #0d0d0d;
    --surface: #1a1a19;
    --surface-2: #222220;
    --surface-3: #2c2c2a;
    --ink: #f0efec;
    --ink-2: #c3c2b7;
    --muted: #9a988f;
    --line: #2c2c2a;
    --line-strong: #383835;
    --accent: #3987e5;
    --accent-strong: #86b6ef;
    --accent-wash: #15253a;
    --trad: #6b6a64;
    --good: #0ca30c;
    --bad: #e66767;
    --warn-wash: #2e2610;
    --path-rescue: #3987e5;
    --path-switch: #d95926;
    --path-freedom: #199e70;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 4px 16px rgba(0, 0, 0, 0.25);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0d0d0d;
  --surface: #1a1a19;
  --surface-2: #222220;
  --surface-3: #2c2c2a;
  --ink: #f0efec;
  --ink-2: #c3c2b7;
  --muted: #9a988f;
  --line: #2c2c2a;
  --line-strong: #383835;
  --accent: #3987e5;
  --accent-strong: #86b6ef;
  --accent-wash: #15253a;
  --trad: #6b6a64;
  --good: #0ca30c;
  --bad: #e66767;
  --warn-wash: #2e2610;
  --path-rescue: #3987e5;
  --path-switch: #d95926;
  --path-freedom: #199e70;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 4px 16px rgba(0, 0, 0, 0.25);
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.6;
  overflow-x: hidden;
}
img, svg { max-width: 100%; }
a { color: var(--accent-strong); text-underline-offset: 2px; }
a:hover { color: var(--accent); }
h1, h2, h3, h4 { line-height: 1.2; font-weight: 650; letter-spacing: -0.01em; margin: 0 0 0.5em; }
h1 { font-size: clamp(2rem, 4.5vw, 3.1rem); letter-spacing: -0.02em; }
h2 { font-size: clamp(1.45rem, 2.6vw, 1.95rem); margin-top: 1.6em; }
h3 { font-size: 1.2rem; margin-top: 1.4em; }
h4 { font-size: 1rem; margin-top: 1.2em; }
p, ul, ol { margin: 0 0 1em; }
li { margin-bottom: 0.35em; }
hr { border: 0; border-top: 1px solid var(--line); margin: 2.5rem 0; }
small, .small { font-size: 0.86rem; }
.muted { color: var(--muted); }
.ink-2 { color: var(--ink-2); }
code { font-family: var(--mono); font-size: 0.9em; background: var(--surface-2); padding: 0.1em 0.35em; border-radius: 4px; }
.num { font-variant-numeric: tabular-nums; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.wrap { max-width: var(--max); margin: 0 auto; padding: 0 16px; }
@media (min-width: 720px) { .wrap { padding: 0 28px; } }
.prose { max-width: var(--prose); }
.prose > :first-child { margin-top: 0; }
main { padding-bottom: 4rem; }

/* ---------- header / nav ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  -webkit-backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
}
.site-header .wrap { display: flex; align-items: center; gap: 1rem; min-height: 60px; }
.brand { display: flex; align-items: center; gap: 0.55rem; text-decoration: none; color: var(--ink); font-weight: 700; letter-spacing: -0.01em; white-space: nowrap; }
.brand:hover { color: var(--ink); }
.brand-mark { width: 26px; height: 26px; flex: none; }
.card .role { margin: -0.35rem 0 0.8rem; font-size: 0.88rem; font-weight: 500; color: var(--muted); }
.brand .co { font-family: Georgia, "Times New Roman", serif; font-style: italic; font-weight: 400; color: var(--ink-2); letter-spacing: 0; }
.nav { display: flex; align-items: center; gap: 0.15rem; margin-left: auto; }
.nav a, .nav button.navbtn {
  font: inherit; font-size: 0.93rem; color: var(--ink-2); text-decoration: none;
  padding: 0.45rem 0.7rem; border-radius: var(--radius-sm); background: none; border: 0; cursor: pointer;
  white-space: nowrap;
}
.nav a:hover, .nav button.navbtn:hover { background: var(--surface-2); color: var(--ink); }
.nav a[aria-current="page"], .nav a.active-section { color: var(--ink); font-weight: 600; }
.nav .cta { background: var(--ink); color: var(--bg); font-weight: 600; margin-left: 0.4rem; }
.nav a.cta, .nav a.cta[aria-current="page"] { color: var(--bg); }
.nav a.cta:hover { background: var(--accent-strong); color: #fff; }
.dropdown { position: relative; }
.dropdown-menu {
  display: none; position: absolute; top: calc(100% + 6px); left: 0; min-width: 270px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 0.4rem; z-index: 60;
}
.dropdown.open .dropdown-menu { display: block; }
.dropdown-menu a { display: flex; flex-direction: column; padding: 0.55rem 0.7rem; white-space: normal; }
.dropdown-menu a span { font-size: 0.82rem; color: var(--muted); font-weight: 400; }
.theme-toggle { margin-left: 0.3rem; width: 36px; height: 36px; display: inline-grid; place-items: center; border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--surface); color: var(--ink-2); cursor: pointer; flex: none; }
.theme-toggle:hover { color: var(--ink); background: var(--surface-2); }
.menu-toggle { display: none; margin-left: auto; width: 40px; height: 40px; border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer; }

@media (max-width: 980px) {
  .menu-toggle { display: inline-grid; place-items: center; }
  .nav {
    display: none; position: absolute; top: 60px; left: 0; right: 0;
    flex-direction: column; align-items: stretch; gap: 0;
    background: var(--surface); border-bottom: 1px solid var(--line); padding: 0.5rem 16px 1rem;
    max-height: calc(100vh - 60px); overflow-y: auto;
  }
  .site-header.nav-open .nav { display: flex; }
  .nav a, .nav button.navbtn { padding: 0.7rem 0.4rem; text-align: left; }
  .dropdown-menu { position: static; display: block; box-shadow: none; border: 0; padding: 0 0 0 0.8rem; min-width: 0; }
  .dropdown > button.navbtn { display: none; }
  .nav .cta { margin: 0.5rem 0 0; text-align: center; }
  .theme-toggle { margin: 0.5rem 0 0; }
}

/* ---------- section subnav (tabs) ---------- */
.subnav { border-bottom: 1px solid var(--line); background: var(--surface); }
.subnav .wrap { display: flex; gap: 0.25rem; overflow-x: auto; scrollbar-width: none; }
.subnav .wrap::-webkit-scrollbar { display: none; }
.subnav a { padding: 0.8rem 0.85rem; font-size: 0.92rem; color: var(--ink-2); text-decoration: none; border-bottom: 2px solid transparent; white-space: nowrap; }
.subnav a:hover { color: var(--ink); }
.subnav a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--accent); font-weight: 600; }
.subnav .label { padding: 0.8rem 0.85rem 0.8rem 0; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); align-self: center; white-space: nowrap; }

/* ---------- page hero ---------- */
.hero { padding: clamp(3rem, 8vw, 6rem) 0 clamp(2rem, 5vw, 3.5rem); }
.hero .eyebrow, .eyebrow { font-size: 0.8rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.1em; color: var(--accent-strong); margin-bottom: 0.9rem; display: block; }
.hero h1 { max-width: 20ch; }
.hero .lede { font-size: clamp(1.1rem, 2vw, 1.3rem); color: var(--ink-2); max-width: 60ch; margin-bottom: 1.6rem; }
.page-head { padding: clamp(2.2rem, 6vw, 4rem) 0 1.5rem; }
.page-head h1 { max-width: 24ch; }
.page-head .lede { font-size: 1.15rem; color: var(--ink-2); max-width: 64ch; }

.btns { display: flex; flex-wrap: wrap; gap: 0.6rem; }
.btn { display: inline-flex; align-items: center; gap: 0.4rem; padding: 0.7rem 1.1rem; border-radius: var(--radius-sm); font-weight: 600; font-size: 0.97rem; text-decoration: none; border: 1px solid var(--line-strong); color: var(--ink); background: var(--surface); }
.btn:hover { border-color: var(--ink-2); color: var(--ink); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); color: #fff; }
:root[data-theme="dark"] .btn.primary:hover { color: #0b0b0b; }

/* ---------- sections & layout ---------- */
.section { padding: clamp(2rem, 5vw, 3.5rem) 0; }
.section + .section { border-top: 1px solid var(--line); }
.section-head { max-width: var(--prose); margin-bottom: 1.6rem; }
.section-head h2 { margin-top: 0; }
.grid { display: grid; gap: 1rem; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); }
.grid.three { grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr)); }
.grid.four { grid-template-columns: repeat(auto-fit, minmax(min(100%, 210px), 1fr)); }
.split { display: grid; gap: 2rem; grid-template-columns: 1fr; }
@media (min-width: 900px) { .split { grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); align-items: start; } }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.3rem 1.3rem 1.1rem; box-shadow: var(--shadow); }
.card h3 { margin-top: 0; }
.card p:last-child, .card ul:last-child { margin-bottom: 0; }
.card.link { text-decoration: none; color: inherit; display: flex; flex-direction: column; transition: border-color 0.15s; }
.card.link:hover { border-color: var(--line-strong); color: inherit; }
.card .more { margin-top: auto; padding-top: 0.8rem; font-weight: 600; color: var(--accent-strong); font-size: 0.95rem; }
.card.flat { box-shadow: none; background: var(--surface-2); border-color: transparent; }

.path-tag { display: inline-flex; align-items: center; gap: 0.45rem; font-size: 0.78rem; font-weight: 650; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-2); margin-bottom: 0.6rem; }
.path-tag::before { content: ""; width: 10px; height: 10px; border-radius: 3px; background: var(--dot, var(--accent)); }
.path-tag.rescue { --dot: var(--path-rescue); }
.path-tag.switch { --dot: var(--path-switch); }
.path-tag.freedom { --dot: var(--path-freedom); }
.card.path { border-top: 3px solid var(--dot, var(--accent)); }
.card.path.rescue { --dot: var(--path-rescue); }
.card.path.switch { --dot: var(--path-switch); }
.card.path.freedom { --dot: var(--path-freedom); }

.callout { border-left: 3px solid var(--accent); background: var(--accent-wash); padding: 1rem 1.2rem; border-radius: 0 var(--radius-sm) var(--radius-sm) 0; margin: 1.5rem 0; max-width: var(--prose); }
.callout p:last-child { margin-bottom: 0; }
.callout.warn { border-left-color: #c98500; background: var(--warn-wash); }
.pullquote { font-size: clamp(1.2rem, 2.2vw, 1.5rem); line-height: 1.4; font-weight: 500; color: var(--ink); border-left: 3px solid var(--line-strong); padding-left: 1.2rem; margin: 2rem 0; max-width: 46ch; }
.pullquote cite { display: block; font-size: 0.9rem; font-style: normal; color: var(--muted); margin-top: 0.6rem; font-weight: 400; }

/* ---------- stat tiles ---------- */
.stats { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)); margin: 1.5rem 0; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.1rem; }
.stat .label { font-size: 0.85rem; color: var(--ink-2); display: block; }
.stat .value { font-size: 1.85rem; font-weight: 650; letter-spacing: -0.02em; display: block; margin: 0.15rem 0; line-height: 1.15; }
.stat .note { font-size: 0.82rem; color: var(--muted); display: block; }
.stat.accent { border-color: var(--accent); }
.stat.accent .value { color: var(--accent-strong); }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; margin: 1.2rem 0 1.6rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
table { width: 100%; border-collapse: collapse; font-size: 0.93rem; }
th, td { text-align: left; padding: 0.65rem 0.85rem; border-bottom: 1px solid var(--line); vertical-align: top; }
thead th { font-weight: 600; color: var(--ink-2); background: var(--surface-2); font-size: 0.85rem; }
tbody tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tr.total td { font-weight: 650; background: var(--surface-2); }
tr.ours td { background: var(--accent-wash); }

/* ---------- tags & badges ---------- */
.badge { display: inline-block; font-size: 0.72rem; font-weight: 650; letter-spacing: 0.04em; text-transform: uppercase; padding: 0.15rem 0.45rem; border-radius: 4px; vertical-align: middle; }
.badge.sourced { background: color-mix(in srgb, var(--good) 14%, transparent); color: var(--good); }
.badge.assumption { background: var(--surface-3); color: var(--ink-2); }
.badge.judgment { background: var(--surface-3); color: var(--ink-2); }

/* ---------- steps / timeline ---------- */
.steps { counter-reset: step; list-style: none; padding: 0; margin: 1.5rem 0; display: grid; gap: 0.8rem; }
.steps > li { counter-increment: step; position: relative; padding: 1rem 1.1rem 1rem 3.4rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); margin: 0; }
.steps > li::before { content: counter(step); position: absolute; left: 1rem; top: 1rem; width: 1.6rem; height: 1.6rem; border-radius: 50%; background: var(--ink); color: var(--bg); font-size: 0.85rem; font-weight: 700; display: grid; place-items: center; }
.steps > li h4 { margin: 0 0 0.25rem; }
.steps > li p:last-child { margin-bottom: 0; }

/* ---------- comparison columns ---------- */
.versus { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); margin: 1.5rem 0; }
.versus .card h3 { display: flex; align-items: center; gap: 0.5rem; }
.versus .card.trad h3::before, .versus .card.ours h3::before { content: ""; width: 12px; height: 12px; border-radius: 3px; flex: none; }
.versus .card.trad h3::before { background: var(--trad); }
.versus .card.ours h3::before { background: var(--accent); }
.versus .card.ours { border-color: var(--accent); }

/* ---------- footer ---------- */
.site-footer { border-top: 1px solid var(--line); padding: 2.5rem 0 3rem; font-size: 0.9rem; color: var(--muted); background: var(--surface); }
.site-footer .wrap { display: grid; gap: 1.5rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)); }
.site-footer h4 { color: var(--ink); font-size: 0.9rem; margin: 0 0 0.6rem; }
.site-footer ul { list-style: none; padding: 0; margin: 0; }
.site-footer a { color: var(--ink-2); text-decoration: none; }
.site-footer a:hover { color: var(--ink); text-decoration: underline; }

/* ---------- references ---------- */
.refs { font-size: 0.88rem; color: var(--ink-2); padding-left: 1.2rem; }
.refs li { margin-bottom: 0.5rem; word-break: break-word; }
sup.ref a { text-decoration: none; font-size: 0.75em; padding: 0 1px; }

/* ---------- next/prev ---------- */
.pager { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-top: 3rem; padding-top: 1.5rem; border-top: 1px solid var(--line); }
.pager a { text-decoration: none; display: flex; flex-direction: column; font-weight: 600; }
.pager a span { font-size: 0.8rem; font-weight: 400; color: var(--muted); }
.pager a.next { margin-left: auto; text-align: right; }

@media print {
  .site-header, .subnav, .site-footer, .theme-toggle, .pager { display: none !important; }
  body { background: #fff; color: #000; }
  .card, .stat, .table-wrap { box-shadow: none; }
}
