/* Filing cabinet — every chapter a manila folder in an open drawer, its title the folder's tab. Shows off
   scroll-state container queries. Each tab is position: sticky and a scroll-state container, so CSS can ask whether
   it is stuck: @container scroll-state(stuck: top) lifts the stuck tab off the page with a shadow and shows which
   folder of seven you are in. The tabs step across the drawer, one position per folder, the way real ones are cut.
   Without scroll-state queries the tabs still stick; they just don't change. Nothing moves on its own.
   Designed by machine for the Slopwright. */
:root {
  color-scheme: light;
  --steel: #5d6670; --steel-2: #4a525b; --manila: #ecdcae; --manila-2: #e2cd92; --ink: #24211b; --dim: #5a5140; --red: #9d2a1e; --label: #fffdf6; --link: #1f4a86;
  --type: "Courier New", Courier, "Nimbus Mono PS", monospace;
}
* { 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; color: var(--ink); font: 17px/1.6 Arial, Helvetica, sans-serif;
  background: linear-gradient(90deg, var(--steel-2), var(--steel) 12% 88%, var(--steel-2)); }
a { color: var(--link); text-underline-offset: 3px; }
:where(a, [tabindex]):focus-visible { outline: 3px solid var(--red); outline-offset: 3px; }
img { max-width: 100%; height: auto; }
.skip { position: absolute; left: 12px; top: -80px; z-index: 10; padding: 10px 16px; background: var(--label); color: var(--ink); font-weight: 700; }
.skip:focus { top: 12px; }
.extra { display: none; }
.main:focus { outline: none; }

.page { max-width: 980px; margin: 0 auto; padding: 0 16px 30px; }
/* the drawer front: a label holder with the masthead in it */
.site-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px 18px; margin: 18px 0 0; padding: 12px 20px; border-radius: 10px; background: linear-gradient(#5f6973, #4b535c); box-shadow: inset 0 2px 0 rgb(255 255 255 / .2), 0 6px 0 #3c434a; }
.masthead { display: flex; align-items: center; padding: 2px 12px; border: 3px solid #b9c0c7; border-radius: 4px; background: var(--label); }
.masthead .brand img { display: block; height: 22px; width: auto; }
.site-name { margin-left: 10px; padding-left: 10px; border-left: 1px solid #b9c0c7; color: var(--ink); font: 700 16px var(--type); text-decoration: none; }
.site-nav { display: flex; flex-wrap: wrap; gap: 0 18px; font: 700 15px var(--type); }
.site-nav a { color: #fff; text-decoration: none; }
.site-nav a:hover { text-decoration: underline; }

/* the drawer's first folder: the title and contents on one card */
.title-block, .contents { padding: 24px clamp(18px, 4vw, 34px); background: var(--manila); }
.title-block { margin-top: 26px; border-radius: 4px 4px 0 0; }
.edition { margin: 0; font: 700 13px var(--type); letter-spacing: .1em; text-transform: uppercase; }
h1, h2 { margin: 0; }
.title { margin-top: 8px; font: 700 clamp(38px, 6.4vw, 72px)/1 var(--type); letter-spacing: -.03em; }
.subtitle { max-width: 34em; margin: 14px 0 0; color: var(--dim); }
.contents { border-top: 1px dashed var(--manila-2); }
.contents-title { margin: 0 0 6px; font: 700 15px var(--type); text-transform: uppercase; }
.contents-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 0 18px; margin: 0; padding: 0; list-style: none; counter-reset: c; }
.contents-list li { counter-increment: c; }
.contents-list a { justify-content: flex-start; gap: 10px; color: var(--ink); font-weight: 700; text-decoration: none; }
.contents-list a::before { content: counter(c); display: inline-grid; place-items: center; width: 1.6em; height: 1.6em; border-radius: 3px; background: var(--label); color: var(--red); font: 700 14px var(--type); box-shadow: 0 1px 0 var(--manila-2); }
.contents-list a:hover { text-decoration: underline; }

/* the folders: each chapter, its title a tab that sticks to the top of the screen */
.chapter { margin-top: 6px; scroll-margin-top: 0; }
.chapter-title {
  position: sticky; top: 0; z-index: 2;
  container-type: scroll-state;         /* lets its children ask whether it is stuck */
  padding-left: calc((var(--i, 1) - 1) * 13%);
  font: 700 clamp(18px, 2.4vw, 22px)/1.2 var(--type);
}
.chapter-1 .chapter-title { --i: 1; } .chapter-2 .chapter-title { --i: 2; } .chapter-3 .chapter-title { --i: 3; } .chapter-4 .chapter-title { --i: 4; }
.chapter-5 .chapter-title { --i: 5; } .chapter-6 .chapter-title { --i: 6; } .chapter-7 .chapter-title { --i: 7; }
.chapter-name { display: inline-block; max-width: 100%; padding: 12px 18px 8px; border-radius: 10px 10px 0 0; background: var(--manila); transition: box-shadow .2s, background-color .2s; }
.chapter-num { display: inline-block; margin-right: 8px; padding: 2px 8px; border-radius: 3px; background: var(--label); color: var(--red); vertical-align: 2px; font-size: 14px; }
.chapter-num::after { content: " of 7"; color: var(--dim); }
.chapter-name { margin-left: 0; }
.chapter-title { display: flex; align-items: flex-end; }
.chapter-num { order: 2; margin: 0 0 8px 10px; visibility: hidden; }
.chapter-body { padding: 22px clamp(18px, 4vw, 34px) 30px; border-radius: 0 4px 4px 4px; background: var(--manila); box-shadow: 0 -1px 0 var(--manila-2), 0 3px 0 rgb(0 0 0 / .18); }
.chapter-1 .chapter-body { border-top-left-radius: 0; }

@container scroll-state(stuck: top) {
  /* the tab is stuck: it lifts, darkens a shade and says which folder this is */
  .chapter-name { background: var(--manila-2); box-shadow: 0 8px 14px rgb(0 0 0 / .35); }
  .chapter-num { visibility: visible; box-shadow: 0 6px 12px rgb(0 0 0 / .3); }
}
@media (prefers-reduced-motion: reduce) { .chapter-name { transition: none; } }

.chapter-body > :first-child { margin-top: 0; }
.first { font-size: 19px; }
.plate { margin: 22px 0 0; padding: 8px 8px 10px; background: #fff; box-shadow: 0 2px 6px rgb(0 0 0 / .2); }
.plate::before { content: ""; display: block; width: 70px; height: 14px; margin: -16px auto 6px; background: rgb(255 255 255 / .6); border: 1px solid rgb(0 0 0 / .08); }
.plate img { display: block; width: 100%; }
.plate figcaption { margin-top: 6px; color: var(--dim); font: 14px var(--type); }
.tools, .rules { padding-left: 1.4em; }
.tools li, .rules li { padding: 4px 0; }
.rules li::marker { color: var(--red); font-family: var(--type); font-weight: 700; }
.note { margin: 18px 0; padding: 12px 16px; border: 2px solid var(--red); background: #fff7e4; }
.note p { margin: 0; }
.note::before { content: "ATTACHED"; display: block; color: var(--red); font: 700 12px var(--type); letter-spacing: .2em; }
.saying { margin: 22px 0 0; padding: 12px 16px; background: var(--label); font-family: var(--type); }
.saying p { margin: 0; font-size: 19px; }
.saying footer { margin-top: 6px; color: var(--dim); font-size: 14px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 15px; background: var(--label); }
caption { padding-bottom: 6px; font: 700 14px var(--type); text-align: left; text-transform: uppercase; }
th, td { padding: 8px 10px; border: 1px solid var(--manila-2); text-align: left; vertical-align: top; }
thead th { font: 700 13px var(--type); text-transform: uppercase; }
.hazards { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin: 0; }
.hazard { padding: 12px 14px; background: var(--label); border-top: 4px solid var(--red); }
.hazard dt { font: 700 15px var(--type); }
.hazard dd { margin: 4px 0 0; font-size: 15px; }
.glossary { display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px; }
.glossary dt { font: 700 16px/1.6 var(--type); }
.glossary dd { margin: 0; }
.sign-off { margin-top: 20px; font-weight: 700; }

/* the other outfits: the drawer's index card */
.outfits, .site-foot { margin-top: 26px; padding: 24px clamp(18px, 4vw, 34px); background: var(--label); background-image: repeating-linear-gradient(transparent 0 27px, #d5e3ee 27px 28px); border-radius: 4px; }
.outfits-title { font: 700 clamp(22px, 3vw, 28px)/1.2 var(--type); color: var(--red); }
.outfits-lede { color: var(--dim); }
.outfit-list { margin: 12px 0 0; padding: 0; list-style: none; columns: 2 220px; column-gap: 24px; font-size: 14px; }
.outfit { break-inside: avoid; padding: 2px 0 8px; }
.outfit-link { justify-content: flex-start; color: var(--ink); font: 700 16px var(--type); text-decoration: none; }
.outfit-link:hover { text-decoration: underline; }
.outfit-by, .outfit-note { display: none; }
.outfit-technique { display: block; color: var(--dim); }
#th-cabinet .outfit-link { padding: 0 8px; background: var(--manila); }
#th-cabinet .outfit-link::after { content: " \2014 open"; margin-left: .3em; color: var(--red); }
.site-foot { color: var(--dim); font-size: 14px; }
.site-foot p { margin: 0 0 6px; }

@media (max-width: 640px) {
  .page { padding-inline: 10px; }
  .chapter-title { padding-left: calc((var(--i, 1) - 1) * 5%); }
  .chapter-num { display: none; }
  .glossary { grid-template-columns: 1fr; gap: 2px; }
  .glossary dd { margin-bottom: 8px; }
}
@media (forced-colors: active) { .chapter-name, .chapter-body, .title-block, .contents { border: 1px solid CanvasText; } }

/* 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; }
