@layer foundation, letterpress, arrangement, furniture, utilities, print;

@layer foundation {
  *, *::before, *::after { box-sizing: border-box; }
  html { color-scheme: light; scroll-padding-top: 1.5rem; }
  body { margin: 0; }
  a { color: inherit; text-underline-offset: .2em; text-decoration-thickness: .07em; }
  button, input, select, textarea { font: inherit; }
  summary { cursor: pointer; }
  p, li, dd { overflow-wrap: anywhere; }
  [tabindex="-1"]:focus { outline: none; }
  a:focus-visible, summary:focus-visible { outline: 3px solid #155e5b; outline-offset: 4px; }
}

@layer letterpress {
  :root { --paper: #e7e4da; --ink: #252621; --petrol: #155e5b; --quiet: #52534b; --rule: #83857b; }
  body { background: var(--paper); color: var(--ink); font-family: Charter, "Bitstream Charter", Georgia, serif; font-size: 20px; line-height: 1.55; }
  h1, h2, h3, .question-label, p, ul, dl, figure { margin: 0; }
  h1, h2, h3, .question-label { font-family: inherit; text-wrap: balance; }
  h1 { font-size: clamp(2.45rem, 4.5vw, 4.65rem); line-height: 1.045; letter-spacing: -.025em; font-weight: 700; max-width: 23ch; }
  h2, h3 { font-size: clamp(1.75rem, 2.7vw, 2.45rem); line-height: 1.15; font-weight: 700; margin-bottom: 1.25rem; }
  .question-label { font-size: 1rem; line-height: 1.5; color: var(--petrol); font-weight: 700; margin-bottom: .4rem; }
  p + p { margin-top: 1rem; }
  .standfirst { font-size: clamp(1.18rem, 1.7vw, 1.45rem); line-height: 1.48; max-width: 52ch; margin-top: 1.65rem; }
  .running-head { font-size: 1rem; font-weight: 700; color: var(--petrol); margin-bottom: 1.25rem; }
  .margin-note p { font-size: 1.125rem; line-height: 1.5; color: var(--quiet); max-width: 25ch; }
  a:hover { color: var(--petrol); }
  ::selection { background: var(--petrol); color: var(--paper); }
}

@layer arrangement {
  .u-shell { width: min(100% - 5rem, 77rem); margin-inline: auto; }
  .opening-spread { display: grid; grid-template-columns: minmax(0, 1fr) 15rem; gap: clamp(2rem, 6vw, 7rem); align-items: end; padding-block: 3.5rem 3rem; }
  .reading-column { width: min(100%, 70ch); padding-bottom: 3.5rem; margin-inline: auto; }
  .reading-unit { padding-block: 2.5rem; border-bottom: 1px solid var(--rule); }
  .reading-unit > p { max-width: 66ch; }
  .reading-unit > p + .u-spaced { margin-top: 1.25rem; }
  .margin-note { padding-bottom: .2rem; }
  .home-leaf .reading-column { width: min(100%, 70ch); }
  .home-leaf .opening-spread { grid-template-columns: minmax(0, 1fr) 18rem; }
  @media (max-width: 760px) {
    .u-shell { width: calc(100% - 2.25rem); }
    .opening-spread, .home-leaf .opening-spread { grid-template-columns: minmax(0, 1fr); gap: 1.5rem; padding-block: 2rem; }
    .margin-note { display: grid; grid-template-columns: 5rem minmax(0, 1fr); gap: 1rem; align-items: center; }
    .margin-note p { max-width: none; }
    .reading-unit { padding-block: 2rem; }
    .reading-column { margin-inline: 0; }
  }
}

@layer furniture {
  .utility-strip { display: flex; align-items: center; justify-content: space-between; gap: 1rem; border-bottom: 1px solid var(--rule); min-height: 3.5rem; font-size: 1rem; }
  .utility-strip a { display: inline-flex; align-items: center; min-height: 48px; gap: 1rem; }
  .masthead { position: relative; display: flex; align-items: center; justify-content: space-between; padding-block: 1.1rem; border-bottom: 4px solid var(--ink); }
  .nameplate { font-size: 1.125rem; line-height: 1.15; display: block; text-decoration: none; padding-block: .25rem; min-height: 48px; }
  .nameplate strong { font-size: 1.75rem; }
  .page-menu { font-size: 1.125rem; }
  .page-menu > summary { min-height: 48px; display: flex; align-items: center; gap: 2rem; list-style: none; padding-inline: .75rem; border: 1px solid var(--ink); }
  .page-menu > summary::-webkit-details-marker { display: none; }
  .page-menu > summary span { font-size: 1.6rem; line-height: 1; }
  .page-menu[open] > summary { background: var(--petrol); color: var(--paper); }
  .page-menu nav { position: absolute; right: 0; top: calc(100% - .7rem); width: min(35rem, 100%); z-index: 10; border: 2px solid var(--ink); background: var(--paper); padding: 1rem; }
  .page-menu ul { list-style: none; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 0 1.25rem; }
  .page-menu a { min-height: 48px; display: flex; align-items: center; padding: .5rem .25rem; border-bottom: 1px solid var(--rule); }
  .page-menu a[aria-current="page"] { font-weight: 700; color: var(--petrol); text-decoration-thickness: .12em; }
  .printed-pieces { height: 13rem; position: relative; isolation: isolate; margin-bottom: 1.25rem; overflow: hidden; border-bottom: 3px solid var(--ink); }
  .printed-pieces i { display: block; position: absolute; background: var(--petrol); }
  .printed-pieces i:nth-child(1) { width: 73%; height: 82%; top: 0; left: 0; clip-path: polygon(0 0, 100% 0, 0 100%); }
  .printed-pieces i:nth-child(2) { width: 62%; height: 70%; bottom: 0; right: 0; background: repeating-linear-gradient(135deg, var(--ink) 0 1px, transparent 1px 7px); }
  .printed-pieces i:nth-child(3) { width: 35%; height: 39%; top: 19%; right: 12%; background: var(--paper); border: 8px solid var(--petrol); }
  .within-page { border-block: 1px solid var(--ink); padding-block: .3rem; font-size: 1.125rem; }
  .within-page summary { min-height: 48px; display: flex; align-items: center; gap: .75rem; }
  .within-page summary::before { content: "+"; color: var(--petrol); font-weight: 700; font-size: 1.5rem; width: 1rem; }
  .within-page details[open] summary::before { content: "−"; }
  .within-page summary::-webkit-details-marker { display: none; }
  .within-page ul { padding: .5rem 0 1rem 1.75rem; list-style: none; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .2rem 2rem; }
  .within-page a { display: flex; align-items: center; min-height: 48px; padding-block: .5rem; }
  .within-page a[aria-current="location"] { color: var(--petrol); font-weight: 700; }
  .keep-question { padding: 1.4rem 0 0 1.25rem; margin-top: 1.5rem; border-left: 3px solid var(--petrol); }
  .keep-question p { font-size: 1.25rem; line-height: 1.45; font-weight: 700; }
  .answer-rule { border-bottom: 1px dotted var(--rule); height: 2.25rem; }
  .kit-index { list-style: none; padding: 0; margin-top: 1.5rem; }
  .kit-index li { border-top: 1px solid var(--rule); }
  .kit-index a { display: grid; grid-template-columns: 1fr 1.2fr auto; align-items: baseline; gap: 1rem; padding-block: 1.1rem; min-height: 64px; text-decoration: none; }
  .kit-index strong { font-size: 1.4rem; line-height: 1.25; }
  .kit-index span { font-size: 1.0625rem; line-height: 1.45; }
  .kit-index b { font-weight: 400; color: var(--petrol); }
  .kit-index a:hover strong { text-decoration: underline; text-underline-offset: .2em; }
  .source-drawer { margin-top: 2.5rem; border-block: 2px solid var(--petrol); font-size: 1.125rem; }
  .source-drawer > summary { display: flex; align-items: center; justify-content: space-between; min-height: 60px; gap: 1rem; color: var(--petrol); font-weight: 700; list-style: none; }
  .source-drawer > summary::after { content: "+"; font-size: 1.75rem; font-weight: 400; }
  .source-drawer[open] > summary::after { content: "−"; }
  .source-drawer > summary::-webkit-details-marker { display: none; }
  .drawer-paper { border-top: 1px solid var(--rule); padding-block: 1rem; }
  .drawer-paper ul { padding: 0; list-style: none; margin-top: .75rem; }
  .drawer-paper a { min-height: 48px; display: block; padding-block: .65rem; }
  .drawer-paper li + li { border-top: 1px solid var(--rule); }
  .bill-parts { margin-block: 1.5rem; }
  .bill-parts > div { display: grid; grid-template-columns: 11rem 1fr; gap: 1rem; border-top: 1px solid var(--rule); padding-block: 1rem; }
  .bill-parts dt { font-weight: 700; }
  .bill-parts dd { margin: 0; }
  .next-leaf { margin-top: 2.5rem; border-bottom: 4px solid var(--ink); padding-bottom: 1rem; }
  .next-leaf p { font-size: 1rem; color: var(--quiet); }
  .next-leaf a { min-height: 48px; display: flex; align-items: center; justify-content: space-between; gap: 1rem; font-size: 1.5rem; font-weight: 700; }
  .cross-note { margin-top: 2rem; font-size: 1.125rem; }
  .publication-foot { border-top: 1px solid var(--ink); padding-block: 1.5rem 2rem; font-size: 1rem; }
  .publication-foot > p { max-width: 68ch; }
  .publication-foot nav { display: flex; flex-wrap: wrap; gap: .25rem 2rem; margin-top: .75rem; }
  .publication-foot a { display: flex; align-items: center; min-height: 48px; }
  .skip-ink { position: absolute; left: 1rem; top: -6rem; z-index: 20; background: var(--paper); color: var(--ink); padding: .75rem; font-size: 1.125rem; }
  .skip-ink:focus { top: 1rem; }
  @media (max-width: 760px) {
    .utility-strip { font-size: 1rem; align-items: flex-start; padding-top: .35rem; gap: .5rem; }
    .utility-strip p { max-width: 21ch; padding-block: .4rem; }
    .utility-strip a { white-space: nowrap; gap: .4rem; }
    .masthead { padding-block: .9rem; }
    .page-menu > summary { gap: .75rem; }
    .page-menu ul { grid-template-columns: minmax(0, 1fr); }
    .page-menu nav { max-height: min(70vh, 39rem); overflow-y: auto; }
    .printed-pieces { height: 5.25rem; margin: 0; }
    .printed-pieces i:nth-child(3) { border-width: 4px; }
    .within-page ul { grid-template-columns: minmax(0, 1fr); }
    .kit-index a { grid-template-columns: minmax(0, 1fr) auto; gap: .4rem .75rem; }
    .kit-index span { grid-column: 1; grid-row: 2; }
    .kit-index b { grid-column: 2; grid-row: 1 / 3; align-self: center; }
    .bill-parts > div { grid-template-columns: minmax(0, 1fr); gap: .4rem; }
  }
  @media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; animation: none !important; transition: none !important; }
  }
}

@layer utilities {
  .u-spaced { padding-left: 1.3em; }
  .u-spaced li { padding-left: .3rem; margin-block: .85rem; }
  .u-target { min-height: 48px; display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding-block: .6rem; }
}

@layer print {
  @media print {
    @page { margin: 18mm; }
    body { background: white; color: black; font-size: 12pt; line-height: 1.45; }
    .utility-strip, .page-menu, .within-page, .skip-ink, .margin-note, .next-leaf, .publication-foot nav { display: none; }
    .u-shell { width: 100%; }
    .opening-spread, .home-leaf .opening-spread { display: block; padding-block: 1.25rem; }
    .reading-column { width: 100%; padding-bottom: 1rem; }
    h1 { font-size: 29pt; max-width: none; }
    h2, h3 { font-size: 19pt; break-after: avoid; }
    .question-label, .running-head, .publication-foot { font-size: 12pt; }
    .reading-unit { padding-block: 1.2rem; }
    .keep-question { break-inside: avoid; }
    .keep-question p { font-size: 13pt; }
    .answer-rule { height: 2rem; border-color: black; }
    .source-drawer { break-inside: avoid; }
  }
}
