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

@font-face {
  font-family: Calistoga;
  src: url('calistoga-regular.ttf') format('truetype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: Fraunces;
  src: url('fraunces-regular.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@layer reset {
  *, *::before, *::after { box-sizing: border-box; }
  body, h1, h2, h3, p, ul, ol { margin: 0; }
  ul, ol { padding: 0; }
  table { border-collapse: collapse; border-spacing: 0; }
  button, textarea { font: inherit; }
  a { color: inherit; }
}

@layer tokens {
  :root {
    color-scheme: dark;
    --carbon: #101216;
    --weave: #24282e;
    --lime: #c4f000;
    --paper: #f2f1e8;
    --muted: #bdc1bd;
    --line: #515963;
    --display: Calistoga, Georgia, serif;
    --text: Fraunces, Georgia, serif;
    --twill: repeating-linear-gradient(132deg, transparent 0 3px, #24282e66 3px 5px, transparent 5px 8px),
      repeating-linear-gradient(42deg, #101216 0 5px, #24282e55 5px 7px, #101216 7px 11px);
  }
}

@layer base {
  html { scroll-padding-top: 24px; }
  body {
    background: var(--carbon);
    color: var(--paper);
    font-family: var(--text);
    font-size: 18px;
    font-weight: 400;
    line-height: 1.58;
    -webkit-font-smoothing: antialiased;
    overflow-wrap: break-word;
  }
  h1, h2, h3 { font-weight: 400; text-wrap: balance; }
  h1 { font-family: var(--display); font-size: clamp(42px, 4.3vw, 66px); line-height: 1.09; letter-spacing: -.032em; }
  h2 { font-family: var(--display); font-size: clamp(25px, 2.3vw, 32px); line-height: 1.22; letter-spacing: -.012em; }
  h3 { font-size: 19px; line-height: 1.35; }
  p { max-width: 68ch; }
  a { text-decoration-thickness: 1px; text-underline-offset: 5px; }
  a:hover { color: var(--lime); }
  a, button, summary { touch-action: manipulation; }
  :focus-visible { outline: 3px solid var(--lime); outline-offset: 5px; }
  ::selection { background: var(--lime); color: var(--carbon); }
  main:focus { outline: none; }
  th { font-weight: 400; }
}

@layer layout {
  .shell { width: min(1240px, calc(100% - 80px)); margin-inline: auto; }
  .site-header {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 24px;
    min-height: 126px;
    border-bottom: 1px solid var(--line);
  }
  .header-links { display: flex; align-items: center; gap: 16px; }
  .header-links-end { justify-content: flex-end; }
  .hero { padding-block: 64px 42px; }
  .home-hero { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr); gap: 64px; align-items: start; }
  .chapter-hero { max-width: 880px; padding-block: 56px 44px; }
  .reading-layout { display: grid; grid-template-columns: minmax(0, 850px) minmax(0, 280px); gap: 64px; align-items: start; }
  .chapter { min-width: 0; }
  .chapter-depth { max-width: 68ch; padding-block: 26px 8px; }
  .home-chapter { max-width: 1020px; margin-inline: auto; }
  .home-content { max-width: 740px; margin-inline: auto; }
  .home-chapter > .keep-question, .home-chapter > .endnotes { max-width: 740px; margin-inline: auto; }
  .route-index { border-top: 2px solid var(--lime); padding-top: 20px; }
  .route-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 32px 56px; }
  .map-overview { padding-block: 72px 24px; }
  .section-head { margin-bottom: 32px; }
  .section-head h2 { font-size: clamp(30px, 3vw, 42px); margin-top: 12px; }
  .site-footer { margin-top: 60px; border-top: 1px solid var(--lime); padding-block: 28px 40px; }
  .site-footer nav { display: flex; flex-wrap: wrap; gap: 8px 24px; margin-top: 16px; }
}

@layer components {
  .skip-link { position: absolute; top: 12px; left: 12px; padding: 12px 20px; z-index: 10; background: var(--lime); color: var(--carbon); transform: translateY(-160%); }
  .skip-link:focus { transform: translateY(0); }
  .header-links a { display: inline-flex; align-items: center; justify-content: center; min-width: 48px; min-height: 48px; font-size: 16px; text-decoration: none; white-space: nowrap; }
  .header-links a[aria-current='page'] { color: var(--lime); box-shadow: inset 0 -2px var(--lime); }
  .masthead { display: flex; flex-direction: column; justify-content: center; align-items: center; min-height: 76px; text-decoration: none; }
  .masthead-place { font-family: var(--display); font-size: 30px; line-height: 1.1; letter-spacing: -.02em; }
  .masthead-detail { font-size: 16px; color: var(--muted); margin-top: 5px; }
  .eyebrow { color: var(--muted); font-size: 16px; line-height: 1.35; }
  .hero-copy > .eyebrow { display: flex; align-items: center; gap: 12px; }
  .hero-copy > .eyebrow::before { content: ''; flex: 0 0 20px; width: 20px; height: 3px; background: var(--lime); }
  .intro { font-size: 20px; line-height: 1.56; color: var(--muted); }
  .panel { background: var(--weave); border: 1px solid var(--line); }
  .hero-prompt { padding: 26px 24px 18px; border-top: 2px solid var(--lime); }
  .hero-prompt h2 { margin-block: 16px 24px; font-size: 32px; }
  .hero-table { width: 100%; font-size: 17px; line-height: 1.5; }
  .hero-table th, .hero-table td { text-align: left; vertical-align: top; padding-block: 14px; border-top: 1px solid var(--line); }
  .hero-table th { width: 37%; padding-right: 14px; color: var(--muted); }
  .text-link { display: inline-flex; align-items: center; gap: 12px; min-height: 48px; color: var(--lime); }
  .myth-fact { display: grid; grid-template-columns: minmax(0, .87fr) minmax(0, 1.13fr); border-top: 2px solid var(--lime); margin-bottom: 30px; }
  .myth-cell, .fact-cell { padding: 24px; min-width: 0; }
  .myth-cell { border-right: 1px solid var(--line); }
  .myth-fact .eyebrow { margin-bottom: 14px; }
  .myth-text { font-size: 22px; line-height: 1.4; }
  .fact-cell > .eyebrow { color: var(--lime); }
  .fact-cell > p:last-child { line-height: 1.58; }
  .chapter-summary { padding: 24px; margin-top: 32px; }
  .spec-table { width: 100%; table-layout: fixed; margin-top: 22px; font-size: 18px; line-height: 1.5; }
  .spec-table th, .spec-table td { padding: 17px 18px; text-align: left; vertical-align: top; border-top: 1px solid var(--line); overflow-wrap: break-word; }
  .spec-table thead th { color: var(--lime); border-top: none; padding-top: 0; }
  .spec-table th:first-child { border-right: 1px solid var(--line); }
  .spec-table th:first-child, .spec-table td:first-child { padding-left: 0; }
  .spec-table th:last-child, .spec-table td:last-child { padding-right: 0; }
  .spec-table tbody th { color: var(--muted); }
  .keep-question { border-left: 3px solid var(--lime); padding: 26px; margin-block: 38px 24px; }
  .keep-question h2 { font-family: var(--text); font-size: 28px; line-height: 1.4; }
  .route-group { margin-top: 22px; }
  .route-group h3 { color: var(--muted); margin-bottom: 8px; }
  .route-group ul { list-style: none; }
  .route-link { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 12px 0; border-bottom: 1px solid var(--line); min-height: 52px; text-decoration: none; font-size: 17px; line-height: 1.45; }
  .route-link[aria-current='page'] { color: var(--lime); }
  .route-arrow { color: var(--lime); font-size: 24px; }
  .route-name { display: block; }
  .route-detail { display: block; color: var(--muted); font-size: 16px; margin-top: 5px; }
  .route-grid .route-link { min-height: 84px; padding-block: 16px; }
  .route-grid .route-name { font-size: 20px; }
  .endnotes { border-top: 1px solid var(--line); padding-top: 26px; margin-top: 36px; }
  .endnotes h2 { margin-top: 12px; font-family: var(--text); font-size: 28px; }
  .note-list { list-style: none; margin-top: 18px; }
  .note-list li { display: grid; grid-template-columns: 24px minmax(0, 1fr); gap: 14px; padding-block: 8px 18px; border-bottom: 1px solid var(--line); }
  .note-marker { font-family: var(--display); color: var(--lime); font-size: 18px; padding-top: 12px; }
  .note-list a { display: flex; align-items: center; justify-content: space-between; gap: 14px; min-height: 48px; line-height: 1.45; font-size: 17px; }
  .note-list p, .source-context { color: var(--muted); font-size: 16px; line-height: 1.55; }
  .source-context { margin-top: 20px; }
  .next-routes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; margin-top: 32px; }
  .next-link { display: flex; align-items: center; min-height: 56px; padding: 12px 16px; border: 1px solid var(--line); text-decoration: none; font-size: 18px; }
  .next-link:hover { border-color: var(--lime); }
  .notes-panel { padding: 26px; margin-top: 30px; border-top: 2px solid var(--lime); }
  .notes-panel label { display: block; font-size: 18px; margin-top: 24px; }
  textarea { display: block; width: 100%; min-width: 0; min-height: 220px; resize: vertical; padding: 16px; border: 1px solid var(--muted); border-radius: 0; color: var(--paper); background: var(--carbon); font-size: 18px; line-height: 1.6; }
  textarea::placeholder { color: var(--muted); opacity: 1; }
  .notes-actions { display: flex; flex-wrap: wrap; gap: 12px; }
  button { min-height: 48px; padding: 12px 18px; border: 1px solid var(--lime); border-radius: 0; background: var(--lime); color: var(--carbon); cursor: pointer; font-size: 17px; line-height: 1.4; }
  button:hover { background: var(--paper); border-color: var(--paper); }
  .quiet-button { color: var(--paper); background: var(--carbon); border-color: var(--muted); }
  .quiet-button:hover { color: var(--carbon); }
  button:disabled { background: var(--weave); color: var(--muted); border-color: var(--line); cursor: default; }
  .notes-status { color: var(--lime); min-height: 28px; font-size: 17px; }
  .footer-line { font-size: 16px; line-height: 1.6; color: var(--muted); max-width: 80ch; }
  .site-footer a { display: inline-flex; align-items: center; min-height: 48px; font-size: 16px; }
}

@layer utilities {
  .flow > * + * { margin-top: 18px; }
  .flow > .eyebrow + h1 { margin-top: 18px; }
  .measure { max-width: 65ch; }
  @media (min-width: 1200px) {
    .home-hero h1 { max-width: 13ch; }
    .hero-prompt { margin-top: 44px; }
  }
  @media (max-width: 1080px) {
    .shell { width: calc(100% - 48px); }
    .site-header { gap: 16px; }
    .header-links { gap: 12px; }
    .masthead-place { font-size: 26px; }
    .home-hero { gap: 32px; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); }
    .reading-layout { grid-template-columns: minmax(0, 1fr) minmax(0, 245px); gap: 32px; }
  }
  @media (max-width: 820px) {
    .site-header { grid-template-columns: 1fr; gap: 0; padding-top: 14px; }
    .masthead { grid-row: 1; margin-bottom: 10px; }
    .header-links { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0; }
    .header-links a { justify-content: center; text-align: center; white-space: normal; padding: 6px; }
    .header-links-end { margin-bottom: 12px; }
    .home-hero { grid-template-columns: 1fr; }
    .hero { padding-block: 38px 30px; }
    .reading-layout { grid-template-columns: minmax(0, 1fr); gap: 48px; }
    .route-index { padding-bottom: 14px; }
    .route-index nav { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 28px; }
    .chapter-hero { max-width: 68ch; }
    .hero-prompt { max-width: 580px; }
  }
  @media (max-width: 480px) {
    .shell { width: calc(100% - 36px); }
    h1 { font-size: 42px; line-height: 1.12; }
    .intro { font-size: 19px; }
    .hero-copy > .eyebrow { font-size: 16px; align-items: flex-start; }
    .hero-copy > .eyebrow::before { margin-top: 9px; }
    .home-hero { gap: 28px; }
    .hero-prompt { padding: 24px 20px 16px; }
    .hero-prompt h2 { font-size: 30px; }
    .myth-fact { grid-template-columns: minmax(0, 1fr); }
    .myth-cell, .fact-cell { padding: 22px; }
    .myth-cell { border-right: none; border-bottom: 1px solid var(--line); }
    .myth-text { font-size: 22px; }
    .chapter-depth { padding-top: 24px; }
    .chapter-summary { padding: 22px 18px; }
    .spec-table { font-size: 17px; line-height: 1.5; }
    .spec-table th, .spec-table td { padding: 16px 12px; }
    .keep-question { padding: 22px; }
    .keep-question h2 { font-size: 26px; }
    .route-grid { grid-template-columns: minmax(0, 1fr); gap: 8px; }
    .map-overview { padding-top: 44px; }
    .route-index nav { grid-template-columns: minmax(0, 1fr); }
    .next-routes { gap: 12px; }
    .next-link { font-size: 17px; padding-inline: 12px; }
    .notes-panel { padding: 22px 18px; }
    .notes-actions { flex-direction: column; }
    .notes-actions button { width: 100%; }
    .site-footer { margin-top: 38px; }
    .site-footer nav { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 16px; }
  }
  @media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; animation: none !important; transition: none !important; }
  }
}
