@layer reset, tokens, type, frame, chapters, access, responsive;

@font-face {
  font-family: "STIX Two Text";
  src: url("/stix-two-text-variable.ttf") format("truetype");
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
}

@layer reset {
  *, *::before, *::after { box-sizing: border-box; }
  html { -webkit-text-size-adjust: 100%; }
  body, h1, h2, h3, p, ul, ol, dl, dd, figure { margin: 0; }
  a { color: inherit; }
  img { max-width: 100%; height: auto; }
}

@layer tokens {
  :root {
    --sapphire: #0a2463;
    --ink: #071b4a;
    --mid: #3b507c;
    --rule: #b5bdd0;
    --tint: #e6e9ef;
    --wash: #f3f4f7;
    --white: #fff;
    --serif: "STIX Two Text", Georgia, serif;
    --sans: ui-sans-serif, system-ui, sans-serif;
    --page: 76rem;
    --reading: 39rem;
    --gutter: clamp(1.25rem, 4.5vw, 4rem);
  }
}

@layer type {
  body { font-family: var(--serif); font-size: 1.1875rem; line-height: 1.6; color: var(--ink); background: var(--white); }
  h1, h2, h3 { font-weight: 500; line-height: 1.08; text-wrap: balance; }
  h1 { font-size: clamp(2.6rem, 5.3vw, 4.8rem); letter-spacing: -.035em; }
  h2 { font-size: clamp(2rem, 3.2vw, 2.8rem); letter-spacing: -.02em; }
  h3 { font-size: 1.625rem; line-height: 1.25; }
  p, li, dd { overflow-wrap: break-word; }
  p + p { margin-top: 1rem; }
  .eyebrow, .scenario-label, .note-label {
    font-family: var(--sans); font-size: 1rem; font-weight: 600;
    line-height: 1.4; letter-spacing: .045em;
  }
  .eyebrow { margin-bottom: 1.75rem; }
  .text-link, .source-link { font-family: var(--sans); font-size: 1rem; font-weight: 550; line-height: 1.5; }
  .text-link, .source-link { display: flex; align-items: center; width: fit-content; max-width: 100%; min-height: 44px; padding: .65rem 0; text-decoration-thickness: 1px; text-underline-offset: .23em; }
}

@layer frame {
  .site-header {
    display: grid; grid-template-columns: 1fr auto 1fr; gap: 2rem;
    align-items: center; max-width: calc(var(--page) + 2 * var(--gutter));
    padding: 1.35rem var(--gutter); margin-inline: auto;
    border-bottom: 1px solid var(--rule); font-family: var(--sans);
  }
  .site-header nav { display: flex; align-items: center; gap: clamp(.5rem, 2vw, 2rem); }
  .header-right { justify-content: flex-end; }
  .site-header nav a {
    display: inline-flex; align-items: center; min-height: 48px;
    padding: .6rem .35rem; font-size: 1rem; font-weight: 550;
    text-decoration: none; text-underline-offset: .25em;
  }
  .site-header nav a[aria-current="page"] { text-decoration: underline; text-decoration-thickness: 2px; }
  .guide-name { display: flex; gap: .85rem; align-items: center; min-height: 56px; text-decoration: none; font-size: 1rem; font-weight: 650; line-height: 1.2; }
  .guide-mark { display: grid; place-items: center; width: 44px; height: 44px; background: var(--sapphire); color: var(--white); font-size: 1.75rem; }
  main { max-width: calc(var(--page) + 2 * var(--gutter)); margin-inline: auto; padding-inline: var(--gutter); }
  .opening-hero { padding: clamp(4rem, 7vw, 7rem) 0 clamp(3.5rem, 6vw, 6rem); }
  .opening-hero h1 { max-width: 17ch; font-size: clamp(3.65rem, 7.8vw, 7.5rem); font-weight: 400; }
  .opening-hero .scenario { max-width: 35rem; margin-top: 2.5rem; }
  .scenario-label { margin-bottom: .75rem; color: var(--mid); }
  .scenario p:last-child { margin-top: 0; font-size: 1.375rem; line-height: 1.45; }
  .chapter-route { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding-top: 1.25rem; font-family: var(--sans); font-size: 1rem; color: var(--mid); }
  .chapter-hero { padding: clamp(2.5rem, 4.5vw, 4.5rem) 0 3.5rem; max-width: 52rem; }
  .chapter-hero h1 { max-width: 19ch; }
  .chapter-hero .scenario { margin-top: 2rem; max-width: var(--reading); }
  .inner-page .chapter-body { max-width: var(--reading); margin-left: clamp(0rem, 10vw, 9rem); }
  .site-footer {
    display: grid; grid-template-columns: 1.2fr 1fr; align-items: start; gap: 2rem 4rem;
    max-width: calc(var(--page) + 2 * var(--gutter)); margin: 5rem auto 0;
    border-top: 1px solid var(--rule); padding: 2.5rem var(--gutter) 3rem;
  }
  .site-footer p { max-width: 31rem; font-size: 1.0625rem; }
  .site-footer nav { display: flex; flex-wrap: wrap; gap: .25rem 1.5rem; }
}

@layer chapters {
  .chapter-section { padding-block: 2.5rem; border-top: 1px solid var(--rule); }
  .chapter-section h2 { margin-bottom: 1.5rem; max-width: 23ch; }
  .opening-page .chapter-section { display: grid; grid-template-columns: minmax(15rem, .8fr) minmax(0, 1.4fr); column-gap: 5rem; }
  .opening-page .chapter-section h2 { grid-column: 1; grid-row: 1 / span 12; }
  .opening-page .chapter-section > :not(h2) { grid-column: 2; max-width: var(--reading); }
  .question-list { padding: 1.1rem 0 0 1.35rem; }
  .question-list li { padding-left: .25rem; margin-block: .5rem; }
  .chapter-button {
    display: flex; align-items: center; justify-content: space-between;
    min-height: 52px; width: fit-content; max-width: 100%; gap: 1.5rem;
    margin-top: 1.5rem; padding: .8rem 1.25rem; background: var(--sapphire);
    color: var(--white); font-family: var(--sans); font-size: 1rem; font-weight: 600; text-decoration: none;
  }
  .bill-map { margin-top: 1.75rem; border: 1px solid var(--sapphire); }
  .bill-map figcaption { padding: 1rem 1.25rem; color: var(--white); background: var(--sapphire); font-family: var(--sans); font-size: 1rem; font-weight: 600; }
  .bill-parts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .bill-part { padding: 1.1rem 1.25rem; min-width: 0; }
  .bill-part:nth-child(2) { background: var(--wash); }
  .bill-part:nth-child(3) { background: var(--tint); border-top: 1px solid var(--rule); }
  .bill-part:nth-child(4) { background: var(--wash); border-top: 1px solid var(--rule); }
  .bill-part:nth-child(even) { border-left: 1px solid var(--rule); }
  .bill-part dt { font-size: 1.5rem; font-weight: 550; }
  .bill-part dd { font-family: var(--sans); font-size: 1rem; line-height: 1.5; margin-top: .4rem; }
  .chapter-index { margin-top: 2rem; padding-top: 2.5rem; border-top: 1px solid var(--rule); }
  .index-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 2rem; margin-bottom: 2rem; }
  .index-heading .eyebrow { max-width: 16rem; }
  .index-heading h2 { max-width: 23ch; }
  .chapter-rows { list-style: none; }
  .chapter-rows li { border-top: 1px solid var(--rule); }
  .chapter-rows li:last-child { border-bottom: 1px solid var(--rule); }
  .chapter-rows a { display: grid; grid-template-columns: minmax(15rem, .85fr) minmax(0, 1.4fr) 2rem; align-items: center; gap: 2rem; min-height: 100px; padding: 1.25rem .5rem; text-decoration: none; }
  .row-title { font-size: 1.625rem; line-height: 1.25; }
  .row-description { font-family: var(--sans); font-size: 1rem; line-height: 1.5; color: var(--mid); }
  .row-arrow { font-family: var(--sans); font-size: 1.5rem; }
  .source-note { padding: 1.5rem; margin-top: 2.5rem; background: var(--wash); font-size: 1.0625rem; line-height: 1.5; }
  .source-note .note-label { margin-bottom: .75rem; color: var(--mid); }
  .opening-page .source-note { max-width: var(--reading); margin-left: auto; }
  .source-note .source-link { margin-top: .25rem; }
  .quote-flow { margin: 1.75rem 0; padding: 1.25rem; background: var(--tint); }
  .quote-flow figcaption { font-family: var(--sans); font-size: 1rem; font-weight: 600; }
  .quote-flow ol { list-style: none; margin-top: 1rem; }
  .quote-flow li { padding: .7rem 0 .7rem 1.1rem; border-left: 2px solid var(--sapphire); font-size: 1.125rem; }
  .quote-flow li + li { border-top: 1px solid var(--rule); }
  .answers { border-top: 1px solid var(--rule); padding-top: 2.5rem; }
  .answers > h2 { margin-bottom: 2rem; }
  .answer { padding: 1.75rem 0; border-top: 1px solid var(--rule); }
  .answer h3 { margin-bottom: 1rem; }
  .source-entry { padding: 1.75rem 0; border-top: 1px solid var(--rule); }
  .source-entry h3 { margin-bottom: .5rem; }
  .source-entry p { margin-top: .5rem; }
  .source-entries { margin-top: 2rem; }
  .urgent-line { padding: 1.25rem; margin-block: 1.5rem; background: var(--sapphire); color: var(--white); font-size: 1.375rem; line-height: 1.4; font-weight: 600; }
  .next-chapter { display: flex; justify-content: space-between; align-items: center; gap: 1.5rem; padding-top: 1.5rem; margin-top: 2.5rem; border-top: 1px solid var(--rule); font-family: var(--sans); font-size: 1rem; }
}

@layer access {
  a:hover { text-decoration: underline; text-underline-offset: .2em; }
  .chapter-rows a:hover { background: var(--wash); }
  :focus-visible { outline: 3px solid var(--sapphire); outline-offset: 5px; }
  .chapter-button:focus-visible { outline-offset: 4px; }
  .skip-link { position: absolute; top: -8rem; left: var(--gutter); z-index: 3; min-height: 48px; padding: .75rem 1rem; background: var(--white); color: var(--sapphire); font-family: var(--sans); font-size: 1rem; }
  .skip-link:focus { top: 1rem; }
  #main { scroll-margin-top: 1rem; }
}

@layer responsive {
  @media (max-width: 900px) {
    .opening-page .chapter-section { grid-template-columns: minmax(12rem, .7fr) minmax(0, 1.3fr); column-gap: 2rem; }
    .inner-page .chapter-body { margin-left: 0; }
    .chapter-rows a { grid-template-columns: minmax(11rem, .9fr) minmax(0, 1.2fr) 1.5rem; gap: 1rem; }
  }
  @media (max-width: 640px) {
    .site-header { grid-template-columns: 1fr 1fr; gap: .75rem 1rem; padding-block: 1rem .5rem; }
    .guide-name { grid-column: 1 / -1; grid-row: 1; justify-self: start; }
    .site-header nav { gap: 1rem; justify-content: space-between; }
    .site-header nav a { padding-inline: 0; font-weight: 500; }
    .opening-hero { padding: 3.5rem 0; }
    .opening-hero h1 { font-size: clamp(3.35rem, 14vw, 5.5rem); max-width: 15ch; }
    .eyebrow { letter-spacing: .025em; margin-bottom: 1.5rem; }
    .scenario p:last-child { font-size: 1.25rem; }
    .chapter-route { align-items: flex-start; }
    .chapter-route span { display: none; }
    .chapter-hero { padding-top: 2.5rem; }
    .chapter-hero h1 { max-width: 17ch; }
    .opening-page .chapter-section { display: block; }
    .chapter-section { padding-block: 2rem; }
    .opening-page .chapter-section h2 { max-width: 20ch; }
    .bill-part { padding: 1rem; }
    .index-heading { display: block; }
    .index-heading .eyebrow { max-width: none; }
    .chapter-rows a { grid-template-columns: minmax(0, 1fr) 1.5rem; gap: .5rem 1rem; padding-block: 1.5rem; }
    .row-description { grid-column: 1; grid-row: 2; }
    .row-arrow { grid-column: 2; grid-row: 1 / span 2; }
    .site-footer { display: block; margin-top: 3.5rem; padding-block: 2rem; }
    .site-footer nav { display: block; margin-top: 1.25rem; }
    .source-note { padding: 1.25rem; }
    .next-chapter { align-items: flex-start; flex-direction: column; gap: .25rem; }
  }
  @media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto; animation: none; transition: none; }
  }
  @media print {
    .site-header, .site-footer, .skip-link, .chapter-route, .next-chapter { display: none; }
    body { font-size: 12pt; color: #0a2463; }
    main { max-width: none; padding: 0; }
    .chapter-hero { padding: 0 0 1.5rem; }
    .chapter-hero h1, .opening-hero h1 { font-size: 30pt; }
    .inner-page .chapter-body { max-width: none; }
    .chapter-section, .answer, .source-entry { break-inside: avoid; }
  }
}
