/* The Ma Files: guide styles. Mobile first; all sizes in rem so the text-size control scales everything. */

:root {
  --font-head: "Newsreader", "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
  --font-body: "Public Sans", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

  --bg: #ffffff;
  --bg-soft: #f1faf8;
  --bg-hero-a: #e3f7f4;
  --bg-hero-b: #ffffff;
  --glow: #a6e9e2;
  --card: #ffffff;
  --card-money: #eaf6fb;
  --ink: #0b2a45;
  --ink-soft: #35536b;
  --ocean: #0b5c7d;
  --ocean-strong: #084a66;
  --turquoise: #0a6f72;
  --aqua: #7fdcd6;
  --seafoam: #d6f1ec;
  --line: #cfe6e6;
  --coral: #b63a28;
  --coral-bg: #fdece8;
  --on-accent: #ffffff;
  --shadow: 0 0.125rem 0.375rem rgba(11, 42, 69, 0.06), 0 0.75rem 2rem rgba(11, 92, 125, 0.08);
  --focus: #0b5c7d;
  --pad-x: clamp(1rem, 4vw, 4.5rem);
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #061a2c;
  --bg-soft: #0a2338;
  --bg-hero-a: #0b2c45;
  --bg-hero-b: #061a2c;
  --glow: #0f5e6b;
  --card: #0d2a42;
  --card-money: #0f3350;
  --ink: #e8f6f5;
  --ink-soft: #b2cdd9;
  --ocean: #7fd6ea;
  --ocean-strong: #a4e5f2;
  --turquoise: #6ddccf;
  --aqua: #2fa7a0;
  --seafoam: #11364f;
  --line: #1d4462;
  --coral: #ff9f8a;
  --coral-bg: #3a1f22;
  --on-accent: #062033;
  --shadow: 0 0.125rem 0.375rem rgba(0, 0, 0, 0.25), 0 0.75rem 2rem rgba(0, 0, 0, 0.3);
  --focus: #7fd6ea;
  color-scheme: dark;
}

html { font-size: 100%; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-padding-top: calc(5rem + env(safe-area-inset-top, 0px)); }
html[data-font-size="sm"] { font-size: 87.5%; }
html[data-font-size="md"] { font-size: 100%; }
html[data-font-size="lg"] { font-size: 112.5%; }
html[data-font-size="xl"] { font-size: 125%; }

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 1.0625rem;
  line-height: 1.6;
  text-align: center;
  overflow-wrap: break-word;
}

h1, h2, h3 { font-family: var(--font-head); color: var(--ink); line-height: 1.12; margin: 0; font-weight: 600; text-wrap: balance; }
h1 { font-size: clamp(2.25rem, 1.2rem + 4.2vw, 5rem); letter-spacing: -0.015em; font-weight: 600; }
h2 { font-size: clamp(1.75rem, 1.2rem + 2vw, 2.875rem); letter-spacing: -0.01em; }
h3 { font-size: 1.375rem; }
p { margin: 0 0 1rem; }
a { color: var(--ocean); text-underline-offset: 0.2em; }
a:hover { color: var(--ocean-strong); }
ul, ol, dl { text-align: left; }

:focus-visible { outline: 0.1875rem solid var(--focus); outline-offset: 0.1875rem; border-radius: 0.25rem; }

.skip { position: absolute; left: 1rem; top: -10rem; z-index: 50; padding: 0.75rem 1rem; background: var(--ocean); color: var(--on-accent); border-radius: 0.5rem; }
.skip:focus { top: calc(0.5rem + env(safe-area-inset-top, 0px)); }

.wrap {
  width: 100%;
  padding-left: calc(var(--pad-x) + env(safe-area-inset-left, 0px));
  padding-right: calc(var(--pad-x) + env(safe-area-inset-right, 0px));
}

/* Top bar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  padding-top: env(safe-area-inset-top, 0px);
  background: var(--bg);
  border-bottom: 0.0625rem solid var(--line);
}
@supports ((-webkit-backdrop-filter: blur(1px)) or (backdrop-filter: blur(1px))) {
  .topbar {
    background: rgba(255, 255, 255, 0.86);
    -webkit-backdrop-filter: saturate(1.4) blur(0.75rem);
    backdrop-filter: saturate(1.4) blur(0.75rem);
  }
  :root[data-theme="dark"] .topbar { background: rgba(6, 26, 44, 0.86); }
}
.topbar-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.5rem 1.25rem;
  padding: 0.625rem calc(var(--pad-x) + env(safe-area-inset-right, 0px)) 0.625rem calc(var(--pad-x) + env(safe-area-inset-left, 0px));
}
.brand { font-family: var(--font-head); font-weight: 700; font-size: 1.375rem; color: var(--ink); text-decoration: none; }
.nav { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.25rem 1rem; min-width: 0; }
.nav a { color: var(--ink-soft); text-decoration: none; font-size: 0.9375rem; font-weight: 500; padding: 0.375rem 0; }
.nav a:hover { color: var(--ocean); text-decoration: underline; }
.nav a.nav-engine { color: var(--ocean); font-weight: 600; }

.prefs { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 0.5rem; }
.size-group { display: inline-flex; border: 0.0625rem solid var(--line); border-radius: 62rem; overflow: hidden; }
.pref-btn {
  font: inherit;
  font-weight: 600;
  color: var(--ink);
  background: var(--card);
  border: 0;
  min-width: 2.25rem;
  min-height: 2.25rem;
  padding: 0 0.625rem;
  cursor: pointer;
  line-height: 1;
}
.size-group .pref-btn + .pref-btn { border-left: 0.0625rem solid var(--line); }
.size-group .pref-btn[data-font-size-set="sm"] { font-size: 0.8125rem; }
.size-group .pref-btn[data-font-size-set="md"] { font-size: 0.9375rem; }
.size-group .pref-btn[data-font-size-set="lg"] { font-size: 1.0625rem; }
.size-group .pref-btn[data-font-size-set="xl"] { font-size: 1.1875rem; }
.size-group .pref-btn[aria-pressed="true"] { background: var(--ocean); color: var(--on-accent); }
.theme-btn { display: inline-flex; align-items: center; gap: 0.4rem; border: 0.0625rem solid var(--line); border-radius: 62rem; font-size: 0.875rem; }
.theme-icon { width: 0.875rem; height: 0.875rem; border-radius: 50%; background: var(--ink); box-shadow: inset -0.25rem -0.125rem 0 0 var(--aqua); }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.875rem;
  padding: 0.625rem 1.375rem;
  border-radius: 62rem;
  font-weight: 600;
  text-decoration: none;
  background: var(--ocean);
  color: var(--on-accent);
  border: 0.125rem solid var(--ocean);
}
.btn:hover { background: var(--ocean-strong); border-color: var(--ocean-strong); color: var(--on-accent); }
.btn.quiet { background: transparent; color: var(--ocean); }
.btn.quiet:hover { background: var(--seafoam); color: var(--ocean-strong); }

/* Hero */
.hero {
  background: var(--bg-hero-b);
  background: radial-gradient(60rem 30rem at 85% -10%, var(--glow), transparent 70%), linear-gradient(180deg, var(--bg-hero-a), var(--bg-hero-b));
  padding: clamp(3rem, 8vw, 7rem) 0 clamp(2.5rem, 6vw, 5rem);
}
.hero-grid { display: grid; gap: 1.5rem; align-items: end; }
.hero-grid > * { min-width: 0; }
.dek { font-size: 1.1875rem; color: var(--ink-soft); }
.hero-actions { display: flex; flex-wrap: wrap; gap: 0.75rem; justify-content: center; margin-top: 1.5rem; }

/* Sections */
.section { padding: clamp(3rem, 7vw, 6rem) 0; background: var(--bg); }
.section.soft { background: var(--bg-soft); }
.section-head { display: grid; gap: 0.75rem; margin-bottom: 2.25rem; }
.section-head > * { min-width: 0; }
.section-head p { color: var(--ink-soft); margin: 0; }

/* Money line ladder */
.ladder { list-style: none; margin: 0; padding: 0; display: grid; gap: 1rem; counter-reset: rung; }
.rung {
  counter-increment: rung;
  position: relative;
  min-width: 0;
  background: var(--card);
  border: 0.0625rem solid var(--line);
  border-radius: 1rem;
  padding: 1.25rem 1.25rem 1.5rem;
  box-shadow: var(--shadow);
  text-align: center;
}
.rung[data-side="money"] { background: var(--card-money); border-color: var(--ocean); }
.rung-side { display: inline-block; font-size: 0.8125rem; font-weight: 600; color: var(--turquoise); margin-bottom: 0.5rem; }
.rung[data-side="money"] .rung-side { color: var(--ocean); }
.rung-title::before { content: counter(rung) ". "; color: var(--ink-soft); }
.rung-built { color: var(--ink-soft); font-size: 0.9375rem; margin: 0.375rem 0 1rem; }
.rung-facts { margin: 0 0 1.25rem; display: grid; gap: 0.625rem; }
.rung-facts dt { font-size: 0.8125rem; font-weight: 600; color: var(--ink-soft); }
.rung-facts dd { margin: 0; }
.meter { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.25rem; }
.meter span { height: 0.5rem; border-radius: 62rem; background: var(--seafoam); }
.meter span.on { background: var(--turquoise); }
.rung[data-side="money"] .meter span.on { background: var(--ocean); }

/* Timeline */
.timeline { display: grid; gap: 1rem; }
.moment {
  min-width: 0;
  background: var(--card);
  border: 0.0625rem solid var(--line);
  border-radius: 1rem;
  padding: 1.25rem;
  box-shadow: var(--shadow);
}
.moment.money { border-color: var(--ocean); }
.moment-date { font-family: var(--font-head); font-size: 1.125rem; font-weight: 600; color: var(--ocean); margin: 0 0 0.375rem; }
.moment-head > *, .moment-body > * { min-width: 0; }
.moment-summary { color: var(--ink-soft); margin: 0.5rem 0 1rem; }
.moment-body p { margin-bottom: 0.875rem; }

.details { margin: 0.5rem 0 0; padding: 0.875rem 1rem; display: grid; gap: 0.5rem; background: var(--bg-soft); border-radius: 0.75rem; }
.detail-row { display: grid; gap: 0.125rem; min-width: 0; }
.details dt { font-size: 0.8125rem; font-weight: 600; color: var(--ink-soft); }
.details dd { margin: 0; font-size: 0.9375rem; }

/* Lessons */
.lessons { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(min(100%, 22rem), 1fr)); }
.lesson {
  min-width: 0;
  background: var(--card);
  border: 0.0625rem solid var(--line);
  border-top: 0.25rem solid var(--turquoise);
  border-radius: 1rem;
  padding: 1.5rem 1.25rem;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
}
.lesson-summary { font-weight: 500; margin: 0.75rem 0 1rem; }
.lesson-body { color: var(--ink-soft); }
.lesson .details { margin-top: auto; }

/* Claims table: stacked label/value cards on small screens */
.table-scroll { min-width: 0; }
.claims { width: 100%; border-collapse: separate; border-spacing: 0; text-align: left; }
.claims thead { position: absolute; width: 0.0625rem; height: 0.0625rem; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }
.claims tbody { display: grid; gap: 0.875rem; }
.claims tr { display: grid; gap: 0.625rem; background: var(--card); border: 0.0625rem solid var(--line); border-radius: 1rem; padding: 1rem 1.125rem; box-shadow: var(--shadow); min-width: 0; }
.claims td { display: grid; gap: 0.125rem; min-width: 0; }
.claims td::before { content: attr(data-label); font-size: 0.8125rem; font-weight: 600; color: var(--ink-soft); }
.status { display: inline-block; justify-self: start; padding: 0.125rem 0.625rem; border-radius: 62rem; font-size: 0.875rem; font-weight: 600; border: 0.0625rem solid currentColor; }
.status-verified { color: var(--turquoise); background: var(--seafoam); }
.status-corrected { color: var(--ocean); background: var(--card-money); }
.status-unverified, .status-flagged { color: var(--coral); background: var(--coral-bg); }

/* Sources */
.two-col { display: grid; gap: 1.5rem; }
.two-col > * { min-width: 0; }
.sources { margin: 0; padding-left: 1.25rem; display: grid; gap: 0.5rem; }
.sources a { overflow-wrap: anywhere; }

/* Engine call to action */
.engine-cta { background: var(--bg-hero-a); background: radial-gradient(50rem 24rem at 10% 120%, var(--glow), transparent 70%), var(--bg-hero-a); }
.cta-grid { display: grid; gap: 1rem; align-items: center; }
.cta-grid > * { min-width: 0; }
.cta-grid p { color: var(--ink-soft); }

.footer { padding: 2.5rem 0 calc(2.5rem + env(safe-area-inset-bottom, 0px)); border-top: 0.0625rem solid var(--line); color: var(--ink-soft); font-size: 0.9375rem; }
.footer-note { margin: 0; }
.noscript, .load-error { color: var(--coral); background: var(--coral-bg); padding: 1rem; border-radius: 0.75rem; margin: 1rem; }

/* Tablet */
@media (min-width: 48rem) {
  body { text-align: left; }
  .topbar-inner { justify-content: space-between; }
  .hero-actions { justify-content: flex-start; }
  .rung { text-align: left; }
  .ladder { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .section-head { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: end; gap: 2rem; }
  .two-col { grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); gap: 3rem; }
  .sources { grid-template-columns: repeat(auto-fill, minmax(min(100%, 18rem), 1fr)); column-gap: 2.5rem; }
  .cta-grid { grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 3rem; }
  .moment { padding: 1.5rem 1.75rem; }

  .claims { display: table; border-collapse: collapse; background: var(--card); border-radius: 1rem; box-shadow: var(--shadow); }
  .claims thead { position: static; width: auto; height: auto; overflow: visible; clip: auto; clip-path: none; white-space: normal; display: table-header-group; }
  .claims tbody { display: table-row-group; }
  .claims tr { display: table-row; background: none; border: 0; border-radius: 0; padding: 0; box-shadow: none; }
  .claims th, .claims td { display: table-cell; padding: 0.875rem 1rem; vertical-align: top; border-bottom: 0.0625rem solid var(--line); }
  .claims th { font-size: 0.875rem; color: var(--ink-soft); font-weight: 600; background: var(--bg-soft); }
  .claims td::before { content: none; }
  .claims tbody tr:last-child td { border-bottom: 0; }
}

/* Small desktop */
@media (min-width: 64rem) {
  .hero-grid { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 4rem; }
  .ladder { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .timeline { gap: 0; border-left: 0.1875rem solid var(--aqua); margin-left: 0.5rem; }
  .moment {
    display: grid;
    grid-template-columns: 10rem minmax(0, 1fr) minmax(0, 1.5fr);
    gap: 2rem;
    border-radius: 0;
    border: 0;
    border-bottom: 0.0625rem solid var(--line);
    box-shadow: none;
    background: transparent;
    padding: 1.75rem 0 1.75rem 2rem;
    position: relative;
  }
  .moment::before { content: ""; position: absolute; left: -0.6875rem; top: 2.125rem; width: 1.1875rem; height: 1.1875rem; border-radius: 50%; background: var(--bg); border: 0.1875rem solid var(--turquoise); }
  .moment.money::before { background: var(--ocean); border-color: var(--ocean); }
  .moment:last-child { border-bottom: 0; }
  .moment-summary { margin-bottom: 0; }
}

/* Wide desktop */
@media (min-width: 90rem) {
  .moment-body { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 0 2rem; align-items: start; }
  .moment-body .details { grid-column: 2; grid-row: 1 / span 6; margin-top: 0; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}
