/* ============================================================================
   Shared stylesheet for Ekatra's routed content pages (/how-it-works,
   /security, /privacy, /statement-guides/*).

   The landing page (landing.html) deliberately keeps its CSS inline: it is a
   single-document marketing page where inlining removes a render-blocking
   round-trip on the one URL that matters most. The content pages are the
   opposite case — there are dozens of them, they share one layout, and they
   are cached across a browsing session, so a shared external file is the right
   trade. Tokens below MUST stay in sync with landing.html's inline block and
   with src/lib/data.ts baseTokens.
   ========================================================================== */

:root, :root[data-theme="light"] {
  --bg: #faf8f4;
  --surface: #ffffff;
  --surface-alt: #f3efe7;
  --ink: #1a1612;
  --ink-soft: #3a342c;
  --muted: #7a7268;
  --line: #e8e2d6;
  --line-soft: #f0ebe0;
  --accent: #1f6b48;
  --accent-soft: #e7f0eb;
  --warn: #b8541a;
  --warn-soft: #fbeee2;
  --neg: #a8341d;
  --pos: #1f6b48;
  --chip: #efeae0;
  --shadow: 0 1px 2px rgba(26,22,18,.04), 0 12px 40px -18px rgba(26,22,18,.18);
  --shadow-lg: 0 2px 6px rgba(26,22,18,.05), 0 30px 80px -30px rgba(26,22,18,.28);
}
:root[data-theme="dark"] {
  --bg: #0c0c0a;
  --surface: #161512;
  --surface-alt: #1f1d18;
  --ink: #f4f1ea;
  --ink-soft: #cfcabd;
  --muted: #867f72;
  --line: #262320;
  --line-soft: #1d1b18;
  --accent: #5dd49a;
  --accent-soft: #1a2c22;
  --warn: #e4a572;
  --warn-soft: #2a1f16;
  --neg: #e57a63;
  --pos: #5dd49a;
  --chip: #1f1d18;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 12px 40px -18px rgba(0,0,0,.6);
  --shadow-lg: 0 2px 6px rgba(0,0,0,.35), 0 30px 80px -30px rgba(0,0,0,.7);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: "Geist", -apple-system, system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  transition: background .35s ease, color .35s ease;
}
::selection { background: var(--accent); color: var(--bg); }
a { color: inherit; text-decoration: none; }
.serif { font-family: "Newsreader", "Iowan Old Style", Georgia, serif; }
.mono { font-family: "Geist Mono", "SF Mono", ui-monospace, monospace; }
.wrap { max-width: 1160px; margin: 0 auto; padding: 0 28px; }

/* ============ Nav (static, not fixed — content pages scroll long) ============ */
nav { border-bottom: 1px solid var(--line); background: var(--bg); }
.nav-inner { display: flex; align-items: center; justify-content: space-between; height: 66px; }
.nav-logo { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 19px; letter-spacing: -0.02em; }
.nav-links { display: flex; gap: 28px; font-size: 14px; color: var(--muted); }
.nav-links a { transition: color .2s; }
.nav-links a:hover { color: var(--ink); }
.nav-right { display: flex; align-items: center; gap: 12px; }

.btn {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: "Geist", sans-serif; font-size: 14px; font-weight: 500;
  padding: 10px 20px; border-radius: 999px; cursor: pointer;
  border: 1px solid transparent;
  transition: transform .15s ease, box-shadow .2s ease, background .2s ease, border-color .2s;
}
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--accent); color: var(--bg); }
.btn-primary:hover { box-shadow: 0 6px 24px -6px color-mix(in srgb, var(--accent) 55%, transparent); transform: translateY(-1px); }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { background: var(--surface-alt); }
.btn-sm { padding: 8px 16px; font-size: 13px; }

.theme-toggle {
  width: 36px; height: 36px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); cursor: pointer;
  display: grid; place-items: center; transition: background .2s, transform .15s;
}
.theme-toggle:hover { background: var(--surface-alt); }
.theme-toggle:active { transform: scale(.92); }
.theme-toggle svg { width: 16px; height: 16px; }
:root[data-theme="light"] .icon-moon { display: none; }
:root[data-theme="dark"] .icon-sun { display: none; }

/* ============ Article layout ============ */
.doc { max-width: 760px; margin: 0 auto; padding: 0 28px; }
.doc-head { padding: 64px 0 40px; border-bottom: 1px solid var(--line); margin-bottom: 40px; }
.eyebrow {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 12px; letter-spacing: .1em; text-transform: uppercase;
  color: var(--muted); margin-bottom: 20px;
}
.eyebrow .dot { width: 6px; height: 6px; border-radius: 999px; background: var(--accent); }
.doc-head h1 { font-size: clamp(34px, 5vw, 52px); line-height: 1.1; letter-spacing: -0.03em; font-weight: 500; }
.doc-head h1 em { font-style: italic; color: var(--accent); }
.doc-head .lede { margin-top: 18px; font-size: 19px; color: var(--ink-soft); line-height: 1.6; }

.crumbs { font-size: 13px; color: var(--muted); margin-bottom: 22px; }
.crumbs a:hover { color: var(--ink); }
.crumbs span { opacity: .5; margin: 0 6px; }

.doc article h2 {
  font-family: "Newsreader", Georgia, serif; font-weight: 500;
  font-size: 28px; letter-spacing: -0.02em; line-height: 1.25;
  margin: 44px 0 14px; scroll-margin-top: 24px;
}
.doc article h3 { font-size: 17px; font-weight: 600; margin: 28px 0 10px; letter-spacing: -0.01em; }
.doc article p { margin-bottom: 16px; color: var(--ink-soft); }
.doc article ul, .doc article ol { margin: 0 0 18px 22px; color: var(--ink-soft); }
.doc article li { margin-bottom: 8px; }
.doc article strong { color: var(--ink); font-weight: 600; }
.doc article a.link { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }

code.kbd {
  font-family: "Geist Mono", ui-monospace, monospace; font-size: 13px;
  background: var(--chip); border: 1px solid var(--line);
  padding: 2px 7px; border-radius: 6px; color: var(--ink);
}

.callout {
  border: 1px solid var(--line); background: var(--surface);
  border-radius: 14px; padding: 20px 22px; margin: 26px 0;
  box-shadow: var(--shadow);
}
.callout.accent { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 24%, transparent); }
.callout.warn { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 26%, transparent); }
.callout h3 { margin-top: 0; }
.callout p:last-child { margin-bottom: 0; }

table.facts { width: 100%; border-collapse: collapse; margin: 22px 0; font-size: 15px; }
table.facts th, table.facts td { text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.facts th { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 500; }
table.facts td { color: var(--ink-soft); }
.table-scroll { overflow-x: auto; }

/* ============ Guide index grid ============ */
.guide-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; margin: 28px 0; }
.guide-card {
  display: block; border: 1px solid var(--line); background: var(--surface);
  border-radius: 14px; padding: 18px 20px; transition: transform .15s ease, box-shadow .2s ease, border-color .2s;
}
.guide-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: color-mix(in srgb, var(--accent) 30%, var(--line)); }
.guide-card b { display: block; font-size: 16px; font-weight: 600; letter-spacing: -0.01em; }
.guide-card span { display: block; font-size: 13px; color: var(--muted); margin-top: 4px; }

/* ============ CTA + footer ============ */
.cta-band {
  border: 1px solid var(--line); background: var(--surface-alt);
  border-radius: 18px; padding: 32px; margin: 48px 0 24px; text-align: center;
}
.cta-band h2 { font-family: "Newsreader", Georgia, serif; font-weight: 500; font-size: 26px; letter-spacing: -0.02em; margin-bottom: 10px; }
.cta-band p { color: var(--ink-soft); margin-bottom: 20px; }

footer { border-top: 1px solid var(--line); margin-top: 64px; padding: 40px 0; font-size: 14px; color: var(--muted); }
.foot-inner { display: flex; flex-wrap: wrap; gap: 18px; justify-content: space-between; align-items: center; }
.foot-links { display: flex; flex-wrap: wrap; gap: 20px; }
.foot-links a:hover { color: var(--ink); }

/* ============================================================================
   Responsive
   ----------------------------------------------------------------------------
   The desktop rules above are the base; these narrow them. Two breakpoints:
   860px drops the nav link row (it cannot fit beside the logo + CTA), and
   600px is the phone pass — gutters, type scale and the block paddings that
   read as generous on a desktop column but eat a 360px screen.

   `.doc-head h1` already uses clamp() so it needs no override. Long content
   (tables) stays readable via .table-scroll rather than by shrinking text.
   ========================================================================== */
@media (max-width: 860px) {
  .nav-links { display: none; }
}

@media (max-width: 600px) {
  /* Gutters: 28px of padding on each side of a 360px screen leaves ~300px of
     text. 18px is the smallest that still keeps text off the bezel. */
  .wrap, .doc { padding: 0 18px; }

  .nav-inner { height: 58px; }
  .nav-logo { font-size: 17px; }
  /* Keep the primary CTA tappable while it shares the row with the toggle. */
  .nav-right { gap: 8px; }

  .doc-head { padding: 40px 0 28px; margin-bottom: 30px; }
  .doc-head .lede { font-size: 17px; }

  .doc article h2 { font-size: 24px; margin: 34px 0 12px; }
  .doc article h3 { font-size: 16px; margin: 22px 0 8px; }
  /* Lists sit closer to the margin so nested text keeps its measure. */
  .doc article ul, .doc article ol { margin-left: 18px; }

  .callout { padding: 16px 17px; margin: 20px 0; border-radius: 12px; }

  /* Single column below 600px: two 240px tracks + gap cannot fit, and
     auto-fill would otherwise leave one stretched card per row. */
  .guide-grid { grid-template-columns: 1fr; gap: 12px; margin: 22px 0; }

  .cta-band { padding: 26px 20px; margin: 36px 0 20px; border-radius: 16px; }
  .cta-band h2 { font-size: 22px; }

  /* `table.facts` is width:100%, so inside .table-scroll it shrinks to the
     container instead of overflowing and the scroll never engages — columns
     just get crushed. A min-width makes the table wider than a phone viewport
     so .table-scroll does its job; -webkit-overflow-scrolling keeps the pan
     from feeling stuck on iOS. Tightened cell padding buys back a little
     width without touching the desktop layout. */
  table.facts { min-width: 460px; font-size: 14px; }
  table.facts th, table.facts td { padding: 10px 12px; }
  .table-scroll { -webkit-overflow-scrolling: touch; }

  /* Stack the footer rows; centred, since the desktop space-between collapses
     to a ragged left edge once the two groups wrap onto separate lines. */
  footer { margin-top: 48px; padding: 32px 0; }
  .foot-inner { flex-direction: column; gap: 14px; text-align: center; }
  .foot-links { justify-content: center; gap: 14px 18px; }
}
