@layer reset, fonts, base, layout, components, print;

@layer fonts {
  @font-face {
    font-family: "Ubuntu";
    src: url("fonts/ubuntu-regular.woff") format("woff");
    font-weight: 400;
    font-style: normal;
    font-display: swap;
  }
  @font-face {
    font-family: "Ubuntu Condensed";
    src: url("fonts/ubuntu-condensed.woff") format("woff");
    font-weight: 400;
    font-style: normal;
    font-display: swap;
  }
}

@layer reset {
  *, *::before, *::after { box-sizing: border-box; }
  body, h1, h2, h3, p, figure { margin: 0; }
  img { display: block; max-width: 100%; height: auto; }
  textarea, input { font: inherit; }
  textarea { max-width: 100%; }
}

@layer base {
  :root {
    color-scheme: light;
    --paper: #f7f7fb;
    --white: #ffffff;
    --fog: #e6e6f0;
    --periwinkle: #9fa8da;
    --ink: #303644;
    --quiet-ink: #515767;
    --link-ink: #344278;
    --rule: #9b9faf;
  }
  html { scroll-padding-block-start: 24px; }
  body {
    font-family: "Ubuntu", Arial, sans-serif;
    font-size: 18px;
    line-height: 1.65;
    color: var(--ink);
    background-color: var(--paper);
    overflow-wrap: break-word;
  }
  h1, h2, h3 {
    font-family: "Ubuntu Condensed", "Arial Narrow", Arial, sans-serif;
    font-weight: 400;
    line-height: 1.13;
    text-wrap: balance;
  }
  h1 { font-size: clamp(2.65rem, 5.1vw, 4.7rem); }
  h2 { font-size: clamp(1.9rem, 2.8vw, 2.4rem); }
  h3 { font-size: 1.55rem; }
  p { max-width: 68ch; }
  a { color: var(--link-ink); text-underline-offset: 5px; }
  a:focus-visible, input:focus-visible, textarea:focus-visible {
    outline: 3px solid var(--link-ink);
    outline-offset: 5px;
  }
  :target { scroll-margin-top: 24px; }
  main:focus, footer:focus { outline: none; }
  textarea {
    display: block;
    width: 100%;
    min-height: 126px;
    padding: 14px 16px;
    border: 1px solid var(--quiet-ink);
    border-radius: 12px;
    color: var(--ink);
    background-color: var(--white);
    line-height: 1.65;
    resize: vertical;
  }
}

@layer layout {
  .fog-bank {
    position: absolute;
    inset: 0 0 auto;
    height: 840px;
    z-index: -1;
    pointer-events: none;
    background: radial-gradient(ellipse at 85% 8%, #9fa8da66, transparent 64%), linear-gradient(165deg, #e6e6f0, #f7f7fb 78%);
  }
  .site-wrap { width: min(1152px, calc(100% - 64px)); margin-inline: auto; }
  .masthead { display: flex; justify-content: space-between; gap: 20px; align-items: center; padding-block: 28px; }
  .masthead p { font-size: 18px; }
  .opening-sheet { display: grid; grid-template-columns: minmax(0, 1.8fr) minmax(240px, 1fr); gap: 32px; align-items: center; }
  .opening-copy { min-width: 0; padding: 40px; background-color: var(--white); border-radius: 28px; }
  .opening-copy h1 { max-width: 16ch; margin-block: 18px 22px; }
  .opening-copy h1 span { display: block; margin-top: 18px; font-size: 0.57em; line-height: 1.2; }
  .opening-lead { font-size: 20px; line-height: 1.6; max-width: 53ch; }
  .quiet-picture { min-width: 0; }
  .quiet-picture figcaption { padding: 18px 12px; font-size: 16px; color: var(--quiet-ink); background-color: var(--paper); }
  .first-check-heading { padding-block: 58px 24px; }
  .first-check-heading h2 { margin-top: 10px; }
  .reading-sheets { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 24px; align-items: start; }
  .reading-sheets > :nth-child(n+3) { grid-column: 1 / -1; }
  .reading-sheets > :nth-child(n+3) { max-width: 848px; width: 100%; margin-inline: auto; }
  .check-sheet, .question-sheet, .next-sheet { padding: 32px; min-width: 0; background-color: var(--white); border: 1px solid #d5d6e2; border-radius: 22px; }
  .check-sheet > p, .question-sheet > p, .next-sheet > p { margin-top: 16px; }
  .check-sheet > h3, .question-sheet > h3 { margin-top: 28px; }
  .check-sheet > h2 + h3 { margin-top: 20px; }
  .next-sheet { max-width: 848px; margin: 32px auto 0; }
  .worksheet-opening { max-width: 848px; margin-inline: auto; padding: 40px; border-radius: 28px; background-color: var(--white); }
  .worksheet-opening h1 { margin-block: 18px 24px; }
  .worksheet-opening > p + p { margin-top: 18px; }
  .worksheet-opening > .back-link { margin-top: 14px; }
  .question-grid { display: grid; gap: 24px; max-width: 848px; margin: 32px auto 0; }
  .comparison-spaces { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 24px; }
  .guide-footer { margin-top: 64px; padding: 32px; background-color: var(--fog); border-radius: 24px 24px 0 0; }
  .directory-heading { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 12px 32px; align-items: baseline; margin-bottom: 24px; }
  .footer-directory { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; }
  .guide-sentence { margin-top: 28px; max-width: 70ch; font-size: 16px; }
  .missing-page .worksheet-opening { margin-block: 38px; }
  @media (max-width: 760px) {
    .site-wrap { width: calc(100% - 32px); }
    .masthead { padding-block: 16px; gap: 12px; }
    .masthead p { font-size: 16px; }
    .opening-sheet, .reading-sheets, .comparison-spaces, .footer-directory { grid-template-columns: minmax(0, 1fr); }
    .opening-sheet { gap: 20px; }
    .opening-copy, .worksheet-opening { padding: 24px; border-radius: 22px; }
    .opening-copy h1 { max-width: 16ch; }
    .opening-lead { font-size: 18px; }
    .quiet-picture { display: grid; grid-template-columns: 96px minmax(0, 1fr); align-items: center; padding: 8px; border-radius: 16px; background-color: var(--paper); }
    .quiet-picture figcaption { padding: 12px 16px; }
    .first-check-heading { padding-top: 36px; }
    .check-sheet, .question-sheet, .next-sheet { padding: 24px; border-radius: 18px; }
    .reading-sheets { gap: 18px; }
    .reading-sheets > :nth-child(n+3) { grid-column: auto; }
    .guide-footer { padding: 24px; margin-top: 40px; }
    .question-grid { margin-top: 24px; gap: 18px; }
    .comparison-spaces { gap: 0; }
  }
}

@layer components {
  .eyebrow { font-size: 16px; letter-spacing: 0.045em; color: var(--quiet-ink); }
  .masthead a, .back-link, .source-link { display: inline-flex; align-items: center; min-height: 48px; padding-block: 10px; font-size: 16px; line-height: 1.5; }
  .masthead a { padding-inline: 12px; border: 1px solid var(--rule); border-radius: 999px; gap: 10px; white-space: nowrap; }
  .route-link { display: flex; justify-content: space-between; gap: 24px; align-items: center; width: fit-content; max-width: 100%; min-height: 56px; margin-top: 24px; padding: 14px 20px; border-radius: 16px; background-color: var(--ink); color: var(--white); font-size: 18px; line-height: 1.4; text-decoration: none; }
  .route-link:hover { background-color: #434c60; }
  .back-link { gap: 12px; }
  .picture-mat { aspect-ratio: 1; padding: 12px; overflow: hidden; border-radius: 40px; background: radial-gradient(circle at 20% 12%, #ffffff, #e6e6f0 55%, #9fa8da); }
  .picture-mat img { width: 100%; height: 100%; object-fit: contain; font-size: 16px; line-height: 1.5; color: var(--ink); border-radius: 28px; }
  .source-note { font-size: 16px; line-height: 1.6; color: var(--quiet-ink); }
  .source-link { margin-top: 4px; }
  .check-mark { display: flex; align-items: center; gap: 16px; margin-top: 24px; padding-top: 20px; border-top: 1px solid #d5d6e2; font-size: 18px; line-height: 1.45; cursor: pointer; }
  .check-mark input { flex: 0 0 44px; width: 44px; height: 44px; margin: 0; accent-color: var(--link-ink); cursor: pointer; }
  .pause-sheet { background-color: #eeeff9; border-color: var(--periwinkle); }
  .writing-space { margin-top: 24px; }
  .writing-space label { display: block; margin-bottom: 10px; font-size: 18px; line-height: 1.45; }
  .bill-sheet { border-left: 6px solid var(--periwinkle); }
  .footer-directory a { display: block; min-height: 102px; padding: 20px; background-color: var(--white); border-radius: 16px; text-decoration: none; font-size: 16px; line-height: 1.55; }
  .footer-directory a:hover { box-shadow: 0 0 0 2px var(--link-ink); }
  .footer-directory a span { display: block; }
  .directory-title { font-family: "Ubuntu Condensed", "Arial Narrow", Arial, sans-serif; font-size: 25px; margin-bottom: 8px; }
  .skip-link { position: absolute; left: 16px; top: 8px; z-index: 4; min-height: 48px; padding: 10px 18px; background-color: var(--white); border: 2px solid var(--link-ink); border-radius: 12px; transform: translateY(-180%); font-size: 18px; }
  .skip-link:focus { transform: translateY(0); }
}

@layer print {
  @media print {
    @page { margin: 16mm; }
    body { font-size: 16px; background-color: white; color: black; }
    .site-wrap { width: 100%; }
    .fog-bank, .masthead, .quiet-picture, .skip-link, .route-link, .back-link, .footer-directory, .directory-heading { display: none; }
    .opening-sheet, .reading-sheets, .question-grid, .comparison-spaces { display: block; }
    .opening-copy, .worksheet-opening { padding: 0 0 20px; }
    h1 { font-size: 34px; }
    h2 { font-size: 26px; }
    h3 { font-size: 21px; }
    .check-sheet, .question-sheet, .next-sheet { padding: 18px; margin: 0 0 22px; border: 1px solid #777; background-color: white; break-inside: avoid; }
    .source-link { color: black; }
    .writing-space label, .check-mark, .source-link { font-size: 16px; }
    textarea { min-height: 110px; font-size: 16px; border-color: #777; }
    .guide-footer { margin-top: 24px; padding: 0; border-radius: 0; background-color: white; }
    .guide-sentence { margin-top: 0; }
  }
}
