@layer reset, base, frame, type, parts, print;

@layer reset {
  *, *::before, *::after { box-sizing: border-box; }
  body, h1, h2, h3, p, ul { margin: 0; }
  button, input { font: inherit; }
  [hidden] { display: none !important; }
}

@layer base {
  :root {
    color-scheme: light;
    --ink: #182b35;
    --muted: #405762;
    --paper: #f5f7f2;
    --blue: #e1edf4;
    --lime: #d8ee94;
    --line: #70838c;
    --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  }
  html { font-size: 16px; scroll-padding-top: 1rem; }
  body { background: var(--paper); color: var(--ink); font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; font-size: 18px; line-height: 1.65; }
  a { color: inherit; text-underline-offset: .23em; }
  button { cursor: pointer; }
  :focus-visible { outline: 3px solid #235672; outline-offset: 4px; }
  h1, h2, h3, p, li, a { overflow-wrap: break-word; }
  input { accent-color: var(--ink); }
}

@layer frame {
  .wrap { width: min(1184px, calc(100% - 80px)); margin-inline: auto; }
  .top { display: flex; justify-content: space-between; align-items: center; gap: 1rem; min-height: 96px; border-bottom: 1px solid var(--line); }
  .row { display: flex; flex-wrap: wrap; align-items: center; gap: .75rem; }
  .hero { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); align-items: center; gap: 3.5rem; padding: 64px 0 48px; }
  .flow { min-width: 0; }
  .tabs { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; padding-bottom: 28px; border-bottom: 1px solid var(--line); }
  .read { width: min(100%, 720px); margin: 24px auto 0; }
  .bit { padding: 40px 0; border-bottom: 1px solid var(--line); }
  .head { justify-content: space-between; align-items: center; margin-bottom: 10px; }
  .links { display: flex; flex-wrap: wrap; gap: .5rem 1rem; margin-top: 14px; }
  .next { padding: 32px 0 48px; }
  .foot { border-top: 1px solid var(--line); padding: 30px 0 42px; display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 2rem; align-items: start; }
  .foot .row { justify-content: end; }
  @media (max-width: 700px) {
    .wrap { width: calc(100% - 36px); }
    .top { min-height: 88px; flex-wrap: wrap; justify-content: flex-start; gap: 0 1rem; padding: 12px 0; }
    .hero { display: block; padding: 32px 0 30px; }
    .tabs { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
    .tabs .tab:last-child { grid-column: 1 / -1; }
    .read { margin-top: 8px; }
    .bit { padding: 28px 0; }
    .foot { grid-template-columns: 1fr; gap: 12px; }
    .foot .row { justify-content: flex-start; }
  }
}

@layer type {
  h1 { font-size: clamp(38px, 4.3vw, 60px); font-weight: 650; line-height: 1.08; letter-spacing: -.045em; max-width: 18ch; margin: 14px 0 22px; }
  h2, .question { font-size: clamp(25px, 2.6vw, 32px); font-weight: 620; line-height: 1.22; letter-spacing: -.025em; margin-bottom: 18px; }
  h3:not(.question), .note-label { font-size: 18px; font-family: var(--mono); font-weight: 500; line-height: 1.5; }
  .question { font-family: inherit; }
  .lead { font-size: 20px; line-height: 1.55; max-width: 55ch; color: var(--muted); }
  .key, .tag, .sig { font-family: var(--mono); font-size: 16px; font-weight: 400; line-height: 1.5; }
  .key { color: var(--muted); }
  .head h2.key { margin: 0; letter-spacing: normal; }
  .tag { color: var(--muted); }
  .bit > p + p, .endnotes p:not(.note-label) + p { margin-top: 12px; }
  .foot p { max-width: 62ch; font-size: 16px; line-height: 1.7; }
}

@layer parts {
  .mark { display: inline-flex; align-items: center; min-height: 48px; font-family: var(--mono); font-size: 18px; letter-spacing: -.035em; text-decoration: none; }
  .skip { position: absolute; z-index: 10; top: 8px; left: 8px; display: flex; align-items: center; min-height: 48px; padding: 8px 18px; background: var(--ink); color: white; transform: translateY(-160%); }
  .skip:focus { transform: translateY(0); }
  .lex { display: flex; flex-direction: column; gap: 12px; padding: 26px; background: var(--blue); border: 1px solid var(--line); border-radius: 40px 40px 40px 8px; transform: rotate(-2deg); }
  .sig { display: block; color: var(--muted); }
  .end { padding-top: 12px; }
  .word { display: block; width: fit-content; max-width: 100%; padding: 1px 14px 6px; background: var(--paper); font-family: var(--mono); font-size: clamp(24px, 3vw, 38px); line-height: 1.25; border: 1px solid var(--line); border-radius: 13px; letter-spacing: -.06em; }
  .word:nth-of-type(3) { align-self: end; background: var(--lime); }
  .tab { display: flex; align-items: center; min-height: 64px; padding: 12px 16px; border: 1px solid var(--line); border-radius: 18px 18px 6px 6px; text-decoration: none; font-size: 16px; line-height: 1.4; }
  .tab[aria-current="page"] { background: var(--ink); color: var(--paper); border-color: var(--ink); box-shadow: inset 0 -5px 0 var(--lime); }
  .tab:hover { background: var(--blue); }
  .tab[aria-current="page"]:hover { background: var(--ink); }
  .go, .note { display: inline-flex; align-items: center; justify-content: flex-start; min-height: 48px; min-width: 48px; padding: 10px 0; font-size: 16px; line-height: 1.45; }
  .go:hover { text-decoration-thickness: 2px; }
  .note { padding: 9px 14px; font-family: var(--mono); border: 1px solid var(--line); border-radius: 999px; background: var(--blue); text-decoration: none; }
  .ink { padding: 13px 20px; background: var(--ink); color: var(--paper); border: 1px solid var(--ink); border-radius: 999px; text-decoration: none; margin-top: 12px; }
  .ink:hover { background: #2e4652; }
  .ink:disabled { cursor: default; }
  .list { padding-left: 24px; margin-top: 18px; }
  .list li + li { margin-top: 10px; }
  .notes { padding: 36px 0 8px; }
  .notes > h2 { margin-top: 10px; }
  .endnotes { padding: 0; list-style: none; }
  .endnotes > li { padding: 20px 0; border-bottom: 1px dashed var(--line); scroll-margin-top: 24px; }
  .endnotes .links { margin-top: 0; }
  .endnotes p { margin-top: 10px; }
  .endnotes .note-label { margin-top: 0; }
  .sheet { margin-top: 32px; padding: 28px; background: var(--lime); border: 1px solid var(--line); border-radius: 28px 28px 8px 28px; }
  .sheet h2 { margin-top: 12px; }
  .print-hint { margin-top: 16px; font-size: 16px; }
  .check { list-style: none; padding: 0; margin-top: 20px; }
  .check > li { padding: 12px 0; border-bottom: 1px solid var(--line); }
  .tick { display: flex; align-items: start; gap: 14px; min-height: 48px; cursor: pointer; }
  .tick input { flex: 0 0 40px; width: 40px; height: 40px; margin: 0; }
  .line { min-height: 34px; margin-left: 54px; }
  .lines { height: 100px; margin-top: 8px; background: repeating-linear-gradient(to bottom, transparent 0 32px, var(--line) 32px 33px); }
  @media (max-width: 700px) {
    .lex { display: none; }
    .mark { font-size: 17px; }
    .tab { min-height: 72px; padding: 12px; }
    .sheet { padding: 20px; }
  }
  @media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
  }
}

@layer print {
  @media print {
    @page { size: auto; margin: 16mm; }
    body { background: white; color: black; font-size: 16px; line-height: 1.45; }
    .wrap, .read { width: 100%; margin: 0; }
    .skip, .tabs, .lex, .foot, .next, .go, .note, .top { display: none; }
    .hero { display: block; padding: 0 0 16px; }
    h1 { font-size: 32px; }
    h2, .question { font-size: 24px; }
    .head h2.key { font-size: 16px; }
    .bit { padding: 18px 0; }
    .sheet { background: white; border: 0; padding: 0; margin: 0; }
    .sheet h2 { font-size: 26px; }
    .print-hint { display: none; }
    .check > li { break-inside: avoid; padding: 8px 0; }
    .tick { min-height: 0; }
    .tick input { appearance: none; flex-basis: 22px; width: 22px; height: 22px; border: 1px solid black; border-radius: 0; }
    .tick input:checked::after { content: "✓"; display: block; text-align: center; line-height: 20px; }
    .line { border-bottom: 1px solid #666; min-height: 20px; margin-left: 36px; }
    .lines { border-bottom: 1px solid #666; background: none; height: 50px; }
    body:has(.sheet) .hero, body:has(.sheet) .bit, body:has(.sheet) .notes { display: none; }
  }
}
