/* Second Draft - set as a galley proof: type, rules and space. */

:root {
  --paper: #e6e9e2;
  --sheet: #f3f4ef;
  --ink: #1c1e1b;
  --ink-soft: #4a4f48;
  --red: #b0101d;   /* proofreader's pen */
  --blue: #8cc6e0;  /* non-photo blue */
  --hair: rgba(28,30,27,.22);
  --serif: "Palatino Linotype", Palatino, "Book Antiqua", "TeX Gyre Pagella", Georgia, serif;
}

*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 1.0625rem/1.7 var(--serif);
  font-variant-numeric: oldstyle-nums;
}

a { color: inherit; text-decoration-color: var(--red); text-decoration-thickness: 1px; text-underline-offset: .2em; }
a:hover { color: var(--red); }
:focus-visible { outline: 2px solid var(--red); outline-offset: 3px; }

em, cite, .foreign { font-style: italic; }

.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.skip-link { position: absolute; left: 1rem; top: -4rem; z-index: 9; padding: .4rem .8rem; background: var(--ink); color: var(--paper); }
.skip-link:focus { top: 1rem; }

/* Layout: rail | galley | margin */
.page {
  display: grid;
  grid-template-columns: 15rem minmax(0, 35rem) 14rem;
  column-gap: 4.5rem;
  justify-content: center;
  padding: 0 2rem;
}

/* Rail */
.rail { grid-column: 1; grid-row: 1 / span 2; }
.rail-inner {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  height: 100vh;
  padding: 4.5rem 0 3rem;
}

/* Blue rule = the page; red rule = how far you've read */
.rail-inner::before, .rail-inner::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  right: -2.25rem;
  width: 1px;
  background: var(--blue);
}
.rail-inner::after {
  right: calc(-2.25rem - .5px);
  width: 2px;
  background: var(--red);
  transform: scaleY(0);
  transform-origin: top;
}
@supports (animation-timeline: scroll()) {
  .rail-inner::after { animation: read linear both; animation-timeline: scroll(root block); }
}
@keyframes read { to { transform: scaleY(1); } }

.wordmark { margin: 0; font-size: 3.75rem; line-height: .95; letter-spacing: -.02em; }
.wordmark span { display: block; }
.w1 { font-style: italic; }
.w2 {
  font-weight: bold;
  text-decoration: underline wavy var(--red) 2px;
  text-underline-offset: .16em;
  text-decoration-skip-ink: none;
}
.tagline { margin: 1.75rem 0 0; max-width: 11rem; font-style: italic; line-height: 1.45; color: var(--ink-soft); }

.rail nav { margin-top: auto; }
.toc { margin: 0; padding: 0; list-style: none; counter-reset: toc; }
.toc li { counter-increment: toc; }
.toc li::before { content: counter(toc, lower-roman) "."; display: inline-block; width: 2em; font-style: italic; color: var(--red); }
.toc a, .toc button {
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  color: var(--ink);
  text-decoration: none;
  cursor: pointer;
}
.toc a:hover, .toc button:hover { color: var(--red); }

/* Galley */
.galley { grid-column: 2; grid-row: 1; padding: 4.5rem 0 2rem; }
.galley p { text-wrap: pretty; }
section + section { margin-top: 6rem; }

h1, h2, h3 { font-weight: normal; line-height: 1.1; text-wrap: balance; }
h1 { margin: 0 0 2.25rem; font-size: clamp(2.75rem, 5.2vw, 4.25rem); font-weight: bold; letter-spacing: -.025em; }
h2 { margin: 0 0 2rem; font-size: 1.875rem; font-style: italic; }
h2::before { content: ""; display: block; width: 2.5rem; height: 2px; margin-bottom: 1.25rem; background: var(--red); }

.lead { margin: 0; font-size: 1.1875rem; line-height: 1.65; }
.lead::first-letter { float: left; margin: .06em .1em 0 0; font-size: 3.9em; line-height: .8; font-weight: bold; color: var(--red); }
@supports (initial-letter: 3) or (-webkit-initial-letter: 3) {
  .lead::first-letter { float: none; margin: 0 .12em 0 0; font-size: inherit; line-height: inherit; -webkit-initial-letter: 3; initial-letter: 3; }
}
.help { margin: 1.5rem 0 0; font-size: 1.5rem; font-style: italic; text-align: right; color: var(--red); }

/* Buttons: ink text, red outline; fills red on hover */
.actions { display: flex; flex-wrap: wrap; gap: .75rem 1.25rem; margin: 2.25rem 0 0; }
.btn {
  display: inline-block;
  padding: .55em 1.2em .5em;
  border: 1.5px solid var(--red);
  border-radius: 2px;
  background: transparent;
  font: inherit;
  font-size: 1rem;
  line-height: 1.3;
  color: var(--ink);
  text-decoration: none;
  cursor: pointer;
  transition: background-color .15s, color .15s;
}
.btn:hover { background: var(--red); color: #fff; }

/* How it works */
.steps ol { margin: 0; padding: 0; list-style: none; counter-reset: step; }
.step { display: grid; grid-template-columns: 3.75rem minmax(0, 1fr); counter-increment: step; }
.step + .step { margin-top: 3rem; }
.step-num::before { content: counter(step, upper-roman) "."; font-size: 1.625rem; font-style: italic; line-height: 1.1; color: var(--red); }
.step h3 { margin: 0; font-size: 1.625rem; font-weight: bold; }
.step-lede { margin: .35rem 0 1rem; font-style: italic; color: var(--ink-soft); }

/* Accordion items set like contents lines: label, dotted leader, +/- */
.step summary { display: flex; align-items: baseline; gap: .5em; padding: .3rem 0; cursor: pointer; list-style: none; }
.step summary::-webkit-details-marker { display: none; }
.step summary::before { content: ""; order: 2; flex: 1; border-bottom: 1px dotted var(--ink-soft); transform: translateY(-.3em); }
.step summary::after { content: "+"; order: 3; width: 1ch; font-weight: bold; color: var(--red); }
.step summary span { order: 1; }
.step summary:hover span { color: var(--red); }
.step details[open] summary span { font-style: italic; }
.step details[open] summary::after { content: "\2212"; }
.step details p { margin: .25rem 0 1rem; padding-left: 1.5rem; font-size: 1rem; }

/* Progress */
.table-title { margin: 0 0 1.25rem; font-size: 1.375rem; font-style: italic; }
.scroll-x { overflow-x: auto; }
.ledger { width: 100%; border-collapse: collapse; table-layout: fixed; font-variant-numeric: lining-nums tabular-nums; }
.ledger th, .ledger td { padding: .45rem .5rem; text-align: center; white-space: nowrap; }
.ledger thead th { font-weight: normal; font-style: italic; color: var(--ink-soft); border-bottom: 1.5px solid var(--ink); }
.ledger thead td, .ledger tbody th { width: 0; padding: 0; }
.ledger td { position: relative; padding-top: .6rem; font-size: 1.75rem; line-height: 1.2; }
.dagger { position: absolute; top: .45em; margin-left: .05em; font-size: .7em; color: var(--red); }
.footnote {
  margin: 1.5rem 0 0;
  padding-top: .6rem;
  max-width: 22rem;
  font-size: .9375rem;
  font-style: italic;
  background: linear-gradient(var(--ink), var(--ink)) top left / 4rem 1px no-repeat;
}
.footnote span { font-style: normal; color: var(--red); }

/* Margin notes */
.margin { grid-column: 3; grid-row: 1; padding-top: 21rem; counter-reset: note; }
.margin h2 { margin-bottom: 1.5rem; font-size: 1.125rem; line-height: 1.3; }
.margin h2::before { width: 1.5rem; height: 1px; margin-bottom: .9rem; }
.note { position: relative; margin: 0 0 1.75rem; counter-increment: note; font-size: .875rem; line-height: 1.55; }
.note::before { content: counter(note); position: absolute; right: calc(100% + .6rem); top: 0; font-size: .8125rem; font-style: italic; color: var(--red); }
.note blockquote, .note p { margin: 0; }
.note figcaption { margin-top: .4rem; font-style: italic; color: var(--ink-soft); }
.note figcaption::before { content: "- "; }

/* Colophon */
.colophon { grid-column: 2; grid-row: 2; padding: 3rem 0 4.5rem; }
.colophon p { margin: 0; }
.colophon .end { margin-top: 2.5rem; text-align: center; letter-spacing: .3em; color: var(--ink-soft); }

/* Dialogs */
dialog {
  max-width: calc(100vw - 2rem);
  padding: 0;
  border: 0;
  overflow: visible;
  background: transparent;
  color: var(--ink);
}
dialog::backdrop { background: rgba(28,30,27,.55); }
.close {
  position: absolute;
  top: -.9rem;
  right: -.9rem;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--ink);
  color: var(--paper);
  font: 1.25rem/2rem var(--serif);
  cursor: pointer;
}

.sheet {
  width: 32rem;
  max-width: 100%;
  padding: 2.25rem 2.5rem 2rem;
  background: var(--sheet);
  border-top: 3px solid var(--red);
  box-shadow: 0 20px 50px rgba(0,0,0,.35);
}
.field { margin: 0 0 1.25rem; }
.field label { display: block; font-size: .875rem; font-style: italic; color: var(--ink-soft); }
.field input, .field textarea {
  display: block;
  width: 100%;
  padding: .3rem 0;
  border: 0;
  border-bottom: 1px solid var(--ink);
  border-radius: 0;
  background: transparent;
  font: inherit;
  color: var(--ink);
}
.field textarea { resize: vertical; }
.field input:focus, .field textarea:focus { outline: none; border-bottom: 2px solid var(--red); }
.field [aria-invalid="true"] { border-bottom-color: var(--red); background: rgba(176,16,29,.06); }
.form-foot { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-top: .5rem; }
.form-note { margin: 0; font-style: italic; color: var(--red); }

.mad::backdrop { background: rgba(230,233,226,.97); }
.mad-word { margin: 0; font-size: clamp(5rem, 22vw, 15rem); font-style: italic; font-weight: bold; line-height: 1; letter-spacing: -.04em; color: var(--red); }
.mad .close { top: 0; right: -2.5rem; }

.video-frame { width: min(640px, 90vw); aspect-ratio: 4 / 3; background: #000; }
.video-frame iframe { display: block; width: 100%; height: 100%; border: 0; }

/* Narrower screens */
@media (max-width: 1180px) {
  .page { grid-template-columns: 13rem minmax(0, 35rem); column-gap: 4rem; }
  .rail { grid-row: 1 / span 3; }
  .margin { grid-column: 2; grid-row: 2; padding-top: 4rem; }
  .colophon { grid-row: 3; }
  .wordmark { font-size: 3.25rem; }
}

@media (max-width: 760px) {
  .page { display: block; padding: 0 1.25rem; }
  .rail-inner { position: static; height: auto; padding: 2.5rem 0 0; }
  .rail-inner::before, .rail-inner::after { display: none; }
  .wordmark { font-size: 2.75rem; }
  .wordmark span { display: inline; }
  .tagline { max-width: none; margin-top: .75rem; }
  .rail nav { margin-top: 0; }
  .toc { display: flex; flex-wrap: wrap; gap: .25rem 1.25rem; margin-top: 1.5rem; padding-bottom: 1.25rem; border-bottom: 1px solid var(--hair); }
  .toc li::before { width: auto; margin-right: .35em; }
  .galley { padding-top: 2.5rem; }
  .step { grid-template-columns: 2.5rem minmax(0, 1fr); }
  .step details p { padding-left: 0; }
  .note { padding-left: 1.25rem; }
  .note::before { right: auto; left: 0; }
  .sheet { padding: 1.75rem 1.25rem; }
  .mad .close { top: -2.5rem; right: 0; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition: none !important; }
}

/* Print: a plain galley proof */
@media print {
  body { background: #fff; }
  .page { display: block; padding: 0; }
  .rail-inner { position: static; height: auto; padding: 0 0 1rem; }
  .rail-inner::before, .rail-inner::after, .rail nav, .actions, .skip-link { display: none; }
  .wordmark span { display: inline; }
  .margin { padding-top: 2rem; }
  .note { padding-left: 1.25rem; }
  .note::before { right: auto; left: 0; }
}