@layer reset, type, base, layout, components, responsive, accessibility;

@layer reset {
  *, *::before, *::after { box-sizing: border-box; }
  html { -webkit-text-size-adjust: 100%; }
  body, h1, h2, h3, p, ol, ul, dl, dd { margin: 0; }
  ol, ul { padding: 0; }
  button, input { font: inherit; }
  [hidden] { display: none !important; }
}

@layer type {
  @font-face {
    font-family: Rubik;
    src: url('../media/type/rubik.woff') format('woff');
    font-style: normal;
    font-weight: 400;
    font-display: swap;
  }
  @font-face {
    font-family: Roboto;
    src: url('../media/type/roboto-medium.woff') format('woff');
    font-style: normal;
    font-weight: 500;
    font-display: swap;
  }
}

@layer base {
  :root {
    --paper: #f5f6ef;
    --white: #fffef8;
    --ink: #233b3e;
    --muted: #4d605e;
    --blue: #244bc0;
    --mist: #e7ecdF;
    --lilac: #e8eaff;
    --citron: #eeefb7;
    --rule: #c1ccc0;
    color-scheme: light;
  }
  body { background: var(--paper); color: var(--ink); font-family: Roboto, Arial, sans-serif; font-size: 18px; font-weight: 500; line-height: 1.65; }
  a { color: var(--blue); text-decoration-thickness: 1.5px; text-underline-offset: .2em; }
  a:hover { text-decoration-thickness: 2.5px; }
  button { cursor: pointer; }
  h1, h2, h3 { font-family: Rubik, Arial, sans-serif; font-weight: 400; line-height: 1.12; text-wrap: balance; }
  h1 { font-size: clamp(46px, 5.2vw, 76px); letter-spacing: -.045em; max-width: 18ch; }
  h2, .c-section h3 { font-size: clamp(27px, 2.25vw, 34px); letter-spacing: -.025em; max-width: 29ch; }
  p, li, dd { overflow-wrap: break-word; }
  ::selection { background: var(--citron); color: var(--ink); }
  :target { scroll-margin-top: 24px; }
}

@layer layout {
  .c-masthead, .c-layout, .c-footer { width: min(1344px, calc(100% - 96px)); margin-inline: auto; }
  .c-masthead { display: flex; justify-content: space-between; align-items: center; gap: 32px; padding: 30px 0 28px; border-bottom: 3px solid var(--blue); }
  .c-layout { display: grid; grid-template-columns: 248px minmax(0, 1fr); column-gap: clamp(44px, 5vw, 88px); align-items: start; }
  .c-main { grid-column: 2; grid-row: 1; min-width: 0; padding-top: 42px; padding-bottom: 64px; }
  .c-index { grid-column: 1; grid-row: 1; padding: 42px 0 48px; min-width: 0; }
  .c-reading { margin-top: 40px; }
  .c-reading > p, .c-section > p, .c-section > ul, .c-deck { max-width: 65ch; }
  .c-section { padding: 36px 0 38px; border-top: 2px solid var(--rule); }
  .c-section h2, .c-section h3 { margin-bottom: 22px; }
  .c-section p + p, .c-section ul + p, .c-section p + ul { margin-top: 18px; }
  .c-section .c-route { margin-top: 26px; }
  .c-reading-end { margin-top: 12px; }
  .c-footer { border-top: 3px solid var(--blue); padding: 28px 0 36px; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 28px; align-items: start; font-size: 16px; }
  .c-footer > p { max-width: 52ch; }
  .c-footer > div { display: flex; flex-wrap: wrap; gap: 8px 24px; }
}

@layer components {
  .c-wordmark { display: flex; flex-direction: column; justify-content: center; min-height: 64px; color: var(--ink); text-decoration: none; font-family: Rubik, Arial, sans-serif; font-size: 25px; line-height: 1.13; letter-spacing: -.035em; }
  .c-wordmark span:last-child { color: var(--blue); }
  .c-masthead-links { display: flex; align-items: center; gap: 24px; }
  .c-masthead-links a, .c-footer a { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 48px; font-size: 16px; }
  .c-chapter-tag { display: flex; align-items: center; gap: 16px; color: var(--blue); margin-bottom: 24px; }
  .c-chapter-tag p { font-size: 18px; }
  .c-chapter-mark { display: grid; place-items: center; width: 48px; height: 48px; flex: 0 0 48px; background: var(--lilac); font-family: Rubik, Arial, sans-serif; font-size: 30px; line-height: 1; }
  .c-deck { font-size: 21px; line-height: 1.5; margin-top: 24px; }
  .c-dateline { font-size: 16px; color: var(--muted); line-height: 1.6; margin-bottom: 24px; }
  .c-index-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
  .c-index-head p { font-family: Roboto, Arial, sans-serif; font-size: 18px; letter-spacing: 0; line-height: 1.12; }
  .c-index-top { display: grid; place-items: center; min-width: 44px; min-height: 44px; text-decoration: none; font-size: 23px; }
  .c-index ol { list-style: none; }
  .c-index li { border-top: 1px solid var(--rule); }
  .c-index li:last-child { border-bottom: 1px solid var(--rule); }
  .c-index li a { min-height: 50px; display: flex; align-items: center; gap: 14px; padding: 10px 10px 10px 0; color: var(--ink); text-decoration: none; font-size: 16px; line-height: 1.35; }
  .c-index-letter { color: var(--muted); width: 25px; text-align: center; flex: 0 0 25px; font-family: Rubik, Arial, sans-serif; }
  .c-index [aria-current] { background: var(--lilac); color: var(--blue); }
  .c-index [aria-current] .c-index-letter { color: var(--blue); }
  .c-index li a:hover { background: var(--mist); }
  .c-index-note { font-size: 16px; line-height: 1.6; color: var(--muted); padding: 26px 0 0 4px; }
  .c-route { min-height: 58px; display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 16px 0; border-top: 2px solid var(--blue); font-size: 18px; line-height: 1.4; text-decoration: none; }
  .c-route > span:first-child { text-decoration: underline; text-underline-offset: .2em; }
  .c-route > span:last-child { font-family: Rubik, Arial, sans-serif; font-size: 28px; flex-shrink: 0; }
  .c-route-note { display: block; color: var(--muted); font-size: 16px; line-height: 1.5; margin-top: 6px; text-decoration: none; }
  .c-route:hover { background: var(--lilac); }
  .c-state-start { background: var(--mist); padding: 30px 32px 18px; border: 0; margin: 0 0 30px; }
  .c-state-start h2 { color: var(--ink); }
  .c-next { margin-top: 42px; background: var(--lilac); padding: 22px 28px 12px; }
  .c-next > p { font-size: 16px; margin-bottom: 6px; }
  .c-next .c-route { border: 0; padding-top: 8px; font-family: Rubik, Arial, sans-serif; font-size: 25px; }
  .c-list { padding-left: 24px; }
  .c-list li { padding-left: 6px; margin-block: 12px; }
  .c-list li::marker { color: var(--blue); }
  .c-urgent { background: var(--citron); border: 0; padding: 30px 32px; margin-bottom: 30px; }
  .c-filter { padding: 24px; background: var(--mist); margin-bottom: 28px; }
  .c-filter label { display: block; margin-bottom: 12px; }
  .c-filter-row { display: flex; gap: 12px; }
  .c-filter input { width: 100%; min-width: 0; min-height: 52px; border: 2px solid var(--muted); border-radius: 0; color: var(--ink); background: var(--white); padding: 10px 14px; font-size: 18px; }
  .c-filter button { background: var(--blue); border: 2px solid var(--blue); color: white; min-height: 52px; padding: 10px 18px; border-radius: 0; font-size: 18px; }
  .c-filter button:hover { background: var(--ink); border-color: var(--ink); }
  .c-filter-status { font-size: 16px; color: var(--muted); margin-top: 14px; }
  .c-term { display: grid; grid-template-columns: minmax(140px, 27%) minmax(0, 1fr); gap: 24px; border-top: 1px solid var(--rule); padding: 24px 0; }
  .c-term dt { font-family: Rubik, Arial, sans-serif; font-size: 21px; color: var(--blue); line-height: 1.3; }
  .c-term dd { font-size: 18px; line-height: 1.6; max-width: 48ch; }
  .c-empty { background: var(--citron); padding: 24px; }
  .c-source-list { list-style: none; }
  .c-source-list li { border-top: 1px solid var(--rule); }
  .c-source-link { min-height: 76px; display: flex; gap: 24px; align-items: center; justify-content: space-between; padding: 18px 0; font-size: 18px; line-height: 1.4; text-decoration: none; }
  .c-source-link > span:first-child { text-decoration: underline; text-underline-offset: .2em; }
  .c-source-link > span:last-child { font-size: 26px; }
  .c-source-link:hover { background: var(--lilac); }
  .c-source-purpose { display: block; margin-top: 8px; font-size: 16px; color: var(--muted); line-height: 1.5; }
}

@layer responsive {
  @media (min-width: 1600px) { .c-layout { column-gap: 88px; } }
  @media (max-width: 1050px) {
    .c-masthead, .c-layout, .c-footer { width: calc(100% - 56px); }
    .c-layout { grid-template-columns: 210px minmax(0, 1fr); column-gap: 36px; }
    .c-index li a { gap: 8px; }
    .c-footer { grid-template-columns: 1fr; gap: 16px; }
  }
  @media (max-width: 790px) {
    .c-masthead, .c-layout, .c-footer { width: calc(100% - 40px); }
    .c-masthead { align-items: start; padding: 22px 0 20px; gap: 16px; }
    .c-wordmark { font-size: 23px; min-height: 56px; }
    .c-masthead-links { display: block; }
    .c-masthead-links a { min-height: 44px; font-size: 16px; gap: 12px; }
    .c-masthead-links a:last-child { display: none; }
    .c-layout { display: flex; flex-direction: column; }
    .c-main { width: 100%; padding-top: 28px; padding-bottom: 44px; }
    .c-chapter-tag { margin-bottom: 18px; gap: 12px; }
    .c-chapter-tag p { font-size: 16px; }
    h1 { font-size: clamp(42px, 10.8vw, 65px); line-height: 1.06; letter-spacing: -.04em; }
    h2, .c-section h3 { font-size: 28px; line-height: 1.16; }
    .c-deck { font-size: 20px; line-height: 1.5; margin-top: 20px; }
    .c-reading { margin-top: 30px; }
    .c-section { padding: 28px 0; }
    .c-section h2, .c-section h3 { margin-bottom: 18px; }
    .c-state-start, .c-urgent { padding: 24px 22px 16px; margin-bottom: 26px; }
    .c-dateline { font-size: 16px; }
    .c-route { gap: 18px; }
    .c-next { padding: 20px 22px 12px; }
    .c-index { width: 100%; padding: 28px 0 36px; border-top: 3px solid var(--blue); }
    .c-index-head { margin-bottom: 14px; }
    .c-index-head p { font-size: 25px; font-family: Rubik, Arial, sans-serif; line-height: 1.16; }
    .c-index li a { min-height: 52px; font-size: 18px; gap: 16px; }
    .c-index-note { display: none; }
    .c-filter { padding: 20px; }
    .c-filter-row { gap: 8px; }
    .c-filter input { padding-inline: 10px; }
    .c-filter button { padding-inline: 12px; }
    .c-term { grid-template-columns: 1fr; gap: 12px; padding-block: 22px; }
    .c-term dd { max-width: 65ch; }
    .c-footer { padding-top: 24px; padding-bottom: 28px; }
    .c-footer > div { display: grid; grid-template-columns: 1fr; gap: 4px; }
    .c-footer a { justify-content: start; }
  }
  @media print {
    body { background: white; color: black; }
    .c-masthead-links, .c-index, .c-reading-end, .c-filter, .c-footer > div { display: none; }
    .c-layout { display: block; }
    .c-main { padding-top: 24px; }
    .c-masthead, .c-layout, .c-footer { width: 100%; }
    h1 { font-size: 40px; }
    .c-section { break-inside: avoid; }
  }
}

@layer accessibility {
  :focus-visible { outline: 3px solid var(--blue); outline-offset: 4px; }
  .c-skip { position: absolute; z-index: 5; left: 20px; top: -100px; min-height: 48px; display: flex; align-items: center; padding: 10px 20px; background: var(--white); border: 2px solid var(--blue); }
  .c-skip:focus { top: 12px; }
  @media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
  }
  @media (forced-colors: active) {
    .c-index [aria-current] { border-left: 4px solid LinkText; }
    .c-chapter-mark, .c-filter, .c-urgent { border: 1px solid CanvasText; }
  }
}
