/* Marginalia — a reading copy of the manual with notes in the margins. Shows off anchor positioning. The text runs
   in one column, which names itself an anchor (--col); the edition line, the subtitle, the plate's caption, the
   warning about the stairs and the Slopwright's saying are taken out of the column and set in the margins, each
   level with the line it belongs to: left or right of anchor(--col) across, the top of its own anchor down. Nothing
   in the HTML moved. Without anchor positioning, or on a screen too narrow for margins, the notes stay in the text as
   boxed asides. Nothing moves.
   Designed by machine for the Slopwright. */
:root {
  color-scheme: light;
  --paper: #f7f3ea; --ink: #1d1b17; --dim: #57514a; --rust: #8f3417; --rule: #d8cfbf; --link: #23488f;
  --note: 13.5em;
}
* { box-sizing: border-box; }
html { overflow-x: clip; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
body { min-width: 320px; margin: 0; background: var(--paper); color: var(--ink); font: 18px/1.7 "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif; }
a { color: var(--link); text-decoration-thickness: 1px; text-underline-offset: 3px; }
:where(a, [tabindex]):focus-visible { outline: 3px solid var(--rust); outline-offset: 3px; }
img { max-width: 100%; height: auto; }
.skip { position: absolute; left: 12px; top: -80px; z-index: 10; padding: 10px 16px; background: var(--ink); color: var(--paper); }
.skip:focus { top: 12px; }
.extra { display: none; }
.main:focus { outline: none; }

.page { position: relative; padding: 0 20px; }
.site-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px 20px; max-width: 1180px; margin: 0 auto; padding: 18px 0; border-bottom: 1px solid var(--rule); font-family: Georgia, serif; }
.masthead { display: flex; align-items: center; }
.masthead .brand img { display: block; height: 24px; width: auto; }
.site-name { margin-left: 12px; padding-left: 12px; border-left: 1px solid var(--rule); color: var(--ink); font-variant: small-caps; letter-spacing: .06em; text-decoration: none; }
.site-nav { display: flex; flex-wrap: wrap; gap: 0 20px; font-size: 16px; font-style: italic; }
.site-nav a { color: var(--ink); text-decoration: none; }
.site-nav a:hover { text-decoration: underline; }

/* the column */
.manual, .outfits, .site-foot { max-width: 36em; margin-inline: auto; }
.manual { padding: 30px 0 10px; }
.title-block { padding: 40px 0 26px; border-bottom: 1px solid var(--rule); }
.edition { margin: 0 0 10px; color: var(--rust); font-style: italic; font-size: 15px; }
h1, h2 { margin: 0; font-weight: 400; }
.title { font-size: clamp(40px, 6vw, 64px); line-height: 1.05; letter-spacing: -.01em; }
.subtitle { margin: 14px 0 0; color: var(--dim); font-style: italic; }
.contents { padding: 22px 0; border-bottom: 1px solid var(--rule); }
.contents-title { margin: 0 0 6px; font-size: 15px; font-variant: small-caps; letter-spacing: .12em; }
.contents-list { margin: 0; padding: 0; list-style: none; counter-reset: c; }
.contents-list li { counter-increment: c; }
.contents-list a { justify-content: flex-start; gap: 12px; color: var(--ink); text-decoration: none; }
.contents-list a::before { content: counter(c, upper-roman) "."; min-width: 2.4em; color: var(--rust); font-variant-numeric: oldstyle-nums; }
.contents-list a:hover { text-decoration: underline; }
.chapter { padding: 30px 0 6px; scroll-margin-top: 16px; }
.chapter-title { position: relative; font-size: clamp(26px, 3.4vw, 34px); line-height: 1.15; }
/* chapter numbers hang just outside the column: plain absolute positioning, no anchors needed */
.chapter-num { position: absolute; right: calc(100% + 18px); top: .15em; color: var(--rust); font-size: .7em; font-variant-numeric: oldstyle-nums; white-space: nowrap; }
.chapter-num::before { content: "§ "; }
.chapter-body { margin-top: 12px; }
.chapter-body > :first-child { margin-top: 0; }
.first::first-line { font-variant: small-caps; letter-spacing: .03em; }
.plate { margin: 24px 0 0; }
.plate img { display: block; width: 100%; filter: grayscale(.4) sepia(.15); }
.plate figcaption { margin-top: 8px; }
.tools, .rules { padding-left: 1.3em; }
.tools li, .rules li { margin: 6px 0; }
.rules li::marker { color: var(--rust); }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 16px; }
caption { padding-bottom: 6px; color: var(--dim); font-style: italic; text-align: left; }
th, td { padding: 6px 12px 6px 0; border-top: 1px solid var(--rule); text-align: left; vertical-align: top; }
thead th { border-top: 0; border-bottom: 1px solid var(--ink); font-weight: 400; font-variant: small-caps; letter-spacing: .06em; }
tbody th { font-weight: 400; font-style: italic; }
.hazards { margin: 0; }
.hazard { margin: 0 0 10px; }
.hazard dt { font-variant: small-caps; letter-spacing: .05em; }
.hazard dd { margin: 0 0 0 1.4em; }
.glossary dt { font-style: italic; }
.glossary dd { margin: 0 0 8px 1.4em; }
.sign-off { margin-top: 22px; font-style: italic; }

/* the notes, inline (narrow screens, and browsers without anchor positioning): boxed asides in the rust pencil */
.plate figcaption, .note, .saying { padding: 10px 14px; border-left: 2px solid var(--rust); background: rgb(143 52 23 / .05); color: var(--rust); font-style: italic; font-size: 16px; line-height: 1.5; }
.note { margin: 18px 0; }
.note p, .saying p { margin: 0; }
.note strong { font-weight: 700; }
.saying { margin: 20px 0 0; }
.saying footer { margin-top: 4px; font-size: 14px; }
.saying footer::before { content: "— "; }

/* the margins: wide screens with anchor positioning only */
@media (min-width: 1100px) {
  @supports (anchor-name: --a) {
    .manual { anchor-name: --col; }
    .title { anchor-name: --title; }
    #lamp .first { anchor-name: --lamp-text; }
    .plate img { anchor-name: --plate; }
    .rules { anchor-name: --rules; }
    .edition, .subtitle, .plate figcaption, .note, .saying {
      position: absolute; width: var(--note); margin: 0;
      padding: 0; border: 0; background: none;
    }
    /* left margin: the edition line beside the title, the caption beside its plate */
    .edition, .plate figcaption { right: calc(anchor(--col left) + 30px); text-align: right; }
    .edition { top: calc(anchor(--title top) + .5em); }
    .plate figcaption { top: anchor(--plate top); }
    /* right margin: the subtitle beside the title, the warning beside its paragraph, the saying beside the rules */
    .subtitle, .note, .saying { left: calc(anchor(--col right) + 30px); }
    .subtitle { top: calc(anchor(--title top) + .5em); color: var(--rust); font-size: 17px; }
    .note { top: anchor(--lamp-text top); }
    .saying { top: anchor(--rules top); }
    /* a pencil leader from each note back to the column */
    .edition::after, .plate figcaption::after, .subtitle::before, .note::before, .saying::before { content: ""; position: absolute; top: .8em; width: 22px; border-top: 1px solid var(--rust); }
    .edition::after, .plate figcaption::after { left: calc(100% + 4px); }
    .subtitle::before, .note::before, .saying::before { right: calc(100% + 4px); }
    /* the column keeps its rhythm where the notes left it */
    .title-block { padding-top: 30px; }
  }
}

/* the other outfits */
.outfits { padding: 36px 0 20px; border-top: 1px solid var(--rule); }
.outfits-title { font-size: clamp(24px, 3vw, 30px); }
.outfits-lede { color: var(--dim); font-style: italic; }
.outfit-list { margin: 12px 0 0; padding: 0; list-style: none; columns: 2 14em; column-gap: 28px; font-size: 15px; }
.outfit { break-inside: avoid; padding: 2px 0 8px; }
.outfit-link { justify-content: flex-start; color: var(--ink); font-size: 17px; text-decoration: none; }
.outfit-link:hover { text-decoration: underline; }
.outfit-by, .outfit-note { display: none; }
.outfit-technique { display: block; color: var(--dim); font-style: italic; }
#th-annotated .outfit-link { color: var(--rust); }
#th-annotated .outfit-link::after { content: "  \2190 you are reading this one"; margin-left: .4em; font-size: 14px; font-style: italic; }
.site-foot { padding: 18px 0 40px; border-top: 1px solid var(--rule); color: var(--dim); font-size: 15px; }
.site-foot p { margin: 0 0 6px; }

@media (max-width: 760px) {
  .site-head { padding: 12px 0; }
  .chapter-num { position: static; margin-right: .4em; }
  .glossary dd, .hazard dd { margin-left: .8em; }
}

/* moving between outfits: a cross-document view transition where the browser has them, with the masthead and the
   title carried across; an ordinary page load elsewhere, and under reduced motion */
@view-transition { navigation: auto; }
.masthead { view-transition-name: masthead; }
.title { view-transition-name: manual-title; }
@media (prefers-reduced-motion: reduce) { @view-transition { navigation: none; } }

/* targets: every link outside running text is at least 44 px tall (the accessibility skill). The display has no
   specificity, so the outfit's own wins; the minimum size is made to stick over any outfit rule */
:where(.masthead, .site-nav, .contents-list) :where(a), :where(.outfit-link) { display: inline-flex; align-items: center; justify-content: center; }
:root:root body :is(.masthead, .site-nav, .contents-list) a, :root:root body .outfit-link { min-width: 44px; min-height: 44px; }
