@layer reset, tokens, base, layout, components, utilities, motion;

@layer reset {
  *, *::before, *::after { box-sizing: border-box; }
  html { color-scheme: light; }
  body, h1, h2, h3, p, figure, dl, dd, ol { margin: 0; }
  img { display: block; max-width: 100%; }
  button, input { font: inherit; }
}

@layer tokens {
  :root {
    --blue: #006fcf; --blue-deep: #0068c2; --blue-soft: #e6f4ff;
    --canvas: #ffffff; --quiet: #f7f7f7; --line: #f2f2f2;
    --ink: #2f3033; --muted: #62656d; --radius-sm: 4px; --radius: 16px;
    --radius-lg: 20px; --space-1: 4px; --space-2: 8px; --space-3: 12px;
    --space-4: 16px; --space-5: 20px; --space-6: 24px; --space-8: 32px;
    --font: -apple-system, BlinkMacSystemFont, "Source Sans Pro", "Segoe UI", Helvetica, Arial, sans-serif;
  }
}

@layer base {
  html { background: var(--canvas); scroll-behavior: smooth; }
  body { min-width: 320px; overflow-x: hidden; color: var(--ink); background: var(--canvas); font-family: var(--font); font-size: 18px; line-height: 1.45; padding-bottom: 124px; }
  a { color: var(--blue-deep); text-underline-offset: 3px; text-decoration-thickness: 1px; }
  a:hover { color: #006fcf; }
  h1, h2, h3 { line-height: 1.08; text-wrap: balance; }
  h1 { max-width: 720px; font-size: clamp(2.35rem, 7vw, 4.5rem); letter-spacing: -0.045em; font-weight: 700; }
  h2 { font-size: clamp(1.65rem, 4vw, 2.15rem); letter-spacing: -0.025em; font-weight: 700; }
  h3 { font-size: 1.14rem; letter-spacing: -0.01em; font-weight: 700; }
  strong, dt { font-weight: 700; }
  p, li, dd, a { font-size: 1rem; }
  :focus-visible { outline: 3px solid #003f78; outline-offset: 3px; }
}

@layer layout {
  main, .site-footer { width: min(100% - 32px, 760px); margin-inline: auto; }
  .site-header { position: sticky; top: 0; z-index: 20; background: rgba(255,255,255,.97); border-bottom: 1px solid var(--line); }
  .header-inner { width: min(100% - 32px, 760px); min-height: 66px; margin-inline: auto; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
  .welcome { padding: 56px 0 40px; }
  .page-stack { display: grid; gap: 56px; }
  .site-footer { margin-top: 64px; padding: 28px 0 36px; border-top: 1px solid var(--line); }
  .stack > * + * { margin-top: var(--space-4); }
  .content-section { scroll-margin-top: 140px; }
}

@layer components {
  .skip-link { position: fixed; top: 8px; left: 8px; z-index: 100; min-height: 44px; padding: 10px 16px; background: var(--ink); color: white; border-radius: 999px; transform: translateY(-160%); }
  .skip-link:focus { transform: translateY(0); }
  .brand { min-height: 52px; display: inline-flex; flex-direction: column; justify-content: center; color: var(--ink); text-decoration: none; }
  .brand span { font-weight: 700; letter-spacing: -.02em; }
  .brand small { color: var(--muted); font-size: .9rem; font-weight: 600; }
  .heart { color: var(--blue); font-size: 1.3rem; transform-origin: center; }
  .anchor-rail { width: min(100%, 792px); margin-inline: auto; display: flex; gap: 8px; overflow-x: auto; overscroll-behavior-inline: contain; padding: 4px 16px 12px; scrollbar-width: none; }
  .anchor-rail::-webkit-scrollbar { display: none; }
  .anchor-rail a { flex: 0 0 auto; min-height: 44px; display: inline-flex; align-items: center; padding: 0 16px; border-radius: 999px; background: var(--quiet); color: var(--ink); font-weight: 600; text-decoration: none; }
  .anchor-rail a[aria-current="page"] { background: var(--blue); color: white; }
  .eyebrow { color: var(--blue-deep); font-size: 1rem; font-weight: 700; letter-spacing: .025em; text-transform: none; }
  .dek { max-width: 680px; color: var(--muted); font-size: 1.15rem; line-height: 1.48; }
  .number-card { min-height: 220px; margin-top: 28px; padding: 28px; display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; border-radius: var(--radius-lg); color: white; background: linear-gradient(145deg, var(--blue), var(--blue-deep)); overflow: hidden; }
  .number-card strong { font-size: clamp(5.5rem, 24vw, 9rem); line-height: .75; letter-spacing: -.08em; font-variant-numeric: tabular-nums; }
  .number-card span { max-width: 120px; font-size: 1.05rem; font-weight: 700; text-align: right; }
  .editorial-photo { margin-top: 28px; aspect-ratio: 8 / 5; overflow: hidden; border-radius: var(--radius-lg); background: var(--blue-soft); }
  .editorial-photo img { width: 100%; height: 100%; object-fit: cover; }
  .soft-note, .callout { padding: 24px; border-radius: var(--radius-lg); }
  .soft-note { background: var(--blue-soft); }
  .callout { background: var(--quiet); border: 1px solid var(--line); }
  .soft-note p:not(.eyebrow), .callout p:not(.eyebrow), .section-intro { max-width: 68ch; }
  .feed { border-top: 1px solid var(--line); }
  .feed-row { min-height: 112px; padding: 20px 0; display: grid; grid-template-columns: 52px minmax(0, 1fr); gap: 16px; border-bottom: 1px solid var(--line); }
  .avatar { width: 52px; height: 52px; display: inline-grid; place-items: center; flex: 0 0 auto; border-radius: 50%; background: var(--blue-soft); color: var(--blue-deep); font-weight: 700; font-variant-numeric: tabular-nums; }
  .feed-copy { min-width: 0; }
  .feed-copy p { margin-top: 6px; color: var(--muted); }
  .row-action, .source-links a, .evidence-card a { min-height: 44px; display: inline-flex; align-items: center; gap: 8px; font-weight: 700; }
  .row-action { margin-top: 8px; }
  .checklist { list-style: none; padding: 0; border-top: 1px solid var(--line); }
  .checklist li { min-height: 104px; padding: 20px 0; display: grid; grid-template-columns: 36px minmax(0, 1fr); gap: 16px; border-bottom: 1px solid var(--line); }
  .checklist p { margin-top: 7px; color: var(--muted); }
  .check { width: 28px; height: 28px; margin-top: 1px; display: block; position: relative; border: 2px solid var(--blue); border-radius: 50%; }
  .check::after { content: ""; position: absolute; width: 10px; height: 5px; left: 7px; top: 7px; border-left: 2px solid var(--blue-deep); border-bottom: 2px solid var(--blue-deep); transform: rotate(-45deg) scale(0); }
  .definitions { display: grid; gap: 12px; }
  .definitions > div { padding: 20px; border-radius: var(--radius); background: var(--quiet); }
  .definitions dt { font-size: 1.12rem; }
  .definitions dd { margin-top: 6px; color: var(--muted); }
  .source-links { display: flex; flex-wrap: wrap; gap: 8px 16px; margin-top: 16px; }
  .source-links a { padding: 4px 0; }
  .evidence-grid { display: grid; gap: 16px; }
  .evidence-card { padding: 22px; border: 1px solid #dcebf7; border-radius: var(--radius); background: white; }
  .evidence-card h3 { margin-top: 6px; }
  .evidence-card p:not(.card-kicker) { margin-top: 10px; color: var(--muted); }
  .evidence-card a { margin-top: 10px; }
  .card-kicker { color: var(--blue-deep); font-size: .9rem; font-weight: 700; }
  .compare-toggle { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; padding: 4px; border-radius: 999px; background: var(--blue-soft); }
  .compare-toggle button { min-width: 0; min-height: 48px; padding: 8px 10px; border: 0; border-radius: 999px; background: transparent; color: var(--ink); font-size: .9rem; font-weight: 700; cursor: pointer; }
  .compare-toggle button[aria-pressed="true"] { background: var(--blue); color: white; }
  .compare-toggle button:active, .action-dock a:active { transform: scale(.98); }
  .compare-grid { display: grid; gap: 16px; }
  .compare-panel { padding: 24px; border: 1px solid #dcebf7; border-radius: var(--radius-lg); }
  .compare-panel h3 { margin-top: 16px; }
  .compare-panel p { margin-top: 12px; color: var(--muted); }
  .site-footer nav { display: flex; flex-wrap: wrap; gap: 8px 20px; }
  .site-footer a { min-height: 44px; display: inline-flex; align-items: center; font-weight: 700; }
  .site-footer p { margin-top: 16px; color: var(--muted); }
  .action-dock { position: fixed; z-index: 30; left: 50%; bottom: 16px; width: min(calc(100% - 32px), 728px); min-height: 66px; display: grid; grid-template-columns: 1fr 1fr; overflow: hidden; border-radius: 999px; background: var(--blue); box-shadow: 0 12px 32px rgba(0, 140, 255, .28); transform: translateX(-50%); }
  .action-dock a { min-width: 0; min-height: 66px; padding: 9px 18px; display: flex; flex-direction: column; justify-content: center; color: white; text-decoration: none; }
  .action-dock a + a { align-items: flex-end; border-left: 1px solid rgba(255,255,255,.35); text-align: right; }
  .action-dock span { font-size: .9rem; }
  .action-dock strong { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .9rem; letter-spacing: .01em; }
}

@layer utilities {
  [hidden] { display: none !important; }
  .u-muted { color: var(--muted); }
}

@layer motion {
  @media (prefers-reduced-motion: no-preference) {
    .welcome, .page-stack > * { animation: settle .36s ease both; }
    .page-stack > *:nth-child(2) { animation-delay: .05s; }
    .page-stack > *:nth-child(3) { animation-delay: .1s; }
    .check::after { animation: draw-check .3s .18s ease forwards; }
    .heart:hover, .heart:focus { animation: heart-pop .3s ease; }
    .compare-panel { transition: opacity .2s ease, transform .2s ease; }
    @keyframes settle { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
    @keyframes draw-check { to { transform: rotate(-45deg) scale(1); } }
    @keyframes heart-pop { 50% { transform: scale(1.2); } }
  }
  @media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
}

@media (min-width: 720px) {
  .welcome { padding-top: 72px; }
  .evidence-grid, .compare-grid { grid-template-columns: 1fr 1fr; }
  .number-card { min-height: 270px; }
}

@media (max-width: 520px) {
  body { padding-bottom: 112px; }
  main, .site-footer { width: min(100% - 28px, 760px); }
  .header-inner { width: calc(100% - 28px); }
  .anchor-rail { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); overflow: visible; padding-inline: 14px; }
  .anchor-rail a { min-width: 0; justify-content: center; padding-inline: 8px; }
  .welcome { padding-top: 40px; }
  .number-card { min-height: 190px; padding: 22px; }
  .soft-note, .callout, .compare-panel { padding: 20px; }
  .compare-toggle { grid-template-columns: 1fr 1fr; border-radius: 18px; }
  .compare-toggle button:last-child { grid-column: 1 / -1; }
  .action-dock { width: calc(100% - 24px); bottom: 12px; }
}