/* Layout: single reading column; the timeline is a three-column ledger (date | step | cost) that stacks on phones. */
:root {
  --paper: #f2f4f1;
  --surface: #ffffff;
  --ink: #16242a;
  --muted: #5a6a6c;
  --line: #d3dbd6;
  --accent: #2c6b5a;      /* eucalyptus */
  --accent-soft: #e1eee8;
  --stamp: #a84d18;       /* deadline / warning ink */
  --stamp-soft: #f7e7dc;

  --font-display: "Bricolage Grotesque", "Avenir Next", "Segoe UI", sans-serif;
  --font-body: "Public Sans", "Helvetica Neue", Arial, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;

  --step--1: 0.8125rem;
  --step-0: 1rem;
  --step-1: 1.25rem;
  --step-2: 1.75rem;
  --step-3: clamp(2rem, 5vw, 3.25rem);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #0f171a; --surface: #162126; --ink: #e4ebe8; --muted: #93a4a3; --line: #28363b;
    --accent: #72c2a8; --accent-soft: #1b3330; --stamp: #e8925c; --stamp-soft: #3a2519;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #0f171a; --surface: #162126; --ink: #e4ebe8; --muted: #93a4a3; --line: #28363b;
  --accent: #72c2a8; --accent-soft: #1b3330; --stamp: #e8925c; --stamp-soft: #3a2519;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 var(--step-0)/1.6 var(--font-body);
}
a { color: var(--accent); text-underline-offset: 2px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
h1, h2, h3 { font-family: var(--font-display); line-height: 1.15; text-wrap: balance; margin: 0; }
h2 { font-size: var(--step-2); font-weight: 700; }
h3 { font-size: var(--step-1); font-weight: 500; }
p { margin: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }

/* Layout: sticky table of contents on the left, content on the right; TOC folds into a collapsible box on narrow screens. */
html { scroll-behavior: smooth; }
.page {
  max-width: 84rem; margin-inline: auto; padding-inline: max(16px, 4vw);
  display: grid; grid-template-columns: 13.5rem minmax(0, 1fr); gap: 0 3.5rem;
}
.content { min-width: 0; max-width: 68rem; }
main { display: grid; gap: 4rem; padding-block: 1rem 4rem; }
[id] { scroll-margin-top: 1.5rem; }

/* Table of contents */
.toc {
  position: sticky; top: calc(env(safe-area-inset-top, 0px) + 2rem); align-self: start;
  max-height: calc(100vh - 4rem); overflow-y: auto; margin-top: 3.5rem;
}
.toc summary { display: none; }
.toc-title {
  font-family: var(--font-mono); font-size: 0.75rem; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--muted); font-weight: 600; margin-bottom: 0.75rem;
}
.toc ol { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.15rem; }
.toc ol ol { padding-left: 0.85rem; margin: 0.15rem 0 0.35rem; border-left: 1px solid var(--line); }
.toc a {
  display: block; padding: 0.3rem 0.6rem; border-radius: 6px; text-decoration: none;
  color: var(--muted); font-size: 0.9375rem; line-height: 1.35;
}
.toc ol ol a { font-size: 0.875rem; padding-block: 0.2rem; }
.toc a:hover { color: var(--ink); background: var(--accent-soft); }
.toc a[aria-current="true"] { color: var(--accent); font-weight: 600; background: var(--accent-soft); }

@media (max-width: 960px) {
  .page { grid-template-columns: minmax(0, 1fr); }
  .toc {
    position: static; max-height: none; overflow: visible; margin-top: 1rem;
    border: 1px solid var(--line); border-radius: 8px; background: var(--surface);
  }
  .toc summary { display: list-item; cursor: pointer; padding: 0.7rem 1rem; font-weight: 600; }
  .toc nav { padding: 0 0.5rem 0.75rem; }
  .toc-title { display: none; }
}

/* Photo viewer: a panel docked to the right that the page reflows around, so photos and text are visible together. */
:root { --viewer-w: min(44vw, 640px); }
.viewer {
  position: fixed; top: 0; right: 0; bottom: 0; width: var(--viewer-w); z-index: 20;
  display: flex; flex-direction: column; background: var(--surface); border-left: 1px solid var(--line);
  padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px);
}
.viewer-head {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem;
  padding: 1rem 1.25rem; border-bottom: 1px solid var(--line);
}
.viewer-kicker { font-family: var(--font-mono); font-size: 0.75rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--accent); font-weight: 600; }
.viewer-head h2 { font-size: var(--step-1); }
.viewer-close {
  font: 600 0.875rem var(--font-body); color: var(--ink); background: var(--paper);
  border: 1px solid var(--line); border-radius: 999px; padding: 0.35rem 0.9rem; cursor: pointer; flex: none;
}
.viewer-close:hover { border-color: var(--accent); }
.viewer-body { overflow-y: auto; padding: 1.25rem; display: grid; gap: 1.75rem; align-content: start; }
.viewer figure { margin: 0; display: grid; gap: 0.6rem; }
.viewer img { width: 100%; height: auto; border-radius: 6px; border: 1px solid var(--line); background: var(--paper); }
.viewer figcaption { font-size: 0.875rem; color: var(--muted); max-width: 60ch; }
body.viewer-open .page { max-width: none; margin-right: var(--viewer-w); }
@media (max-width: 1500px) {
  body.viewer-open .page { grid-template-columns: minmax(0, 1fr); }
  body.viewer-open .toc { display: none; }
}
@media (max-width: 720px) {
  :root { --viewer-h: 55vh; }
  .viewer { top: auto; left: 0; width: 100%; height: var(--viewer-h); border-left: 0; border-top: 1px solid var(--line); box-shadow: 0 -8px 24px rgb(0 0 0 / 0.12); }
  body.viewer-open .page { margin-right: auto; padding-bottom: var(--viewer-h); }
}

/* Photo thumbnails inside a step */
.shots { display: grid; gap: 0.4rem; margin-top: 0.25rem; }
.shots-label { font-size: 0.6875rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); font-weight: 600; }
.shot-row { display: flex; flex-wrap: wrap; gap: 0.75rem; }
.shot {
  display: grid; gap: 0.35rem; width: 8.5rem; padding: 0.35rem; text-align: left; cursor: pointer;
  font: 600 0.8125rem var(--font-body); color: var(--ink); background: var(--surface);
  border: 1px solid var(--line); border-radius: 8px;
}
.shot img { width: 100%; aspect-ratio: 3 / 4; object-fit: cover; object-position: top; border-radius: 4px; }
.shot .pages { font-weight: 400; color: var(--muted); font-size: 0.75rem; }
.shot-doc img { aspect-ratio: 3 / 4; object-position: top; background: #fff; }
.viewer figure.doc { gap: 0.75rem; }
.viewer figure.doc figcaption b { color: var(--ink); }
.shot:hover { border-color: var(--accent); }
.shot[aria-pressed="true"] { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }

/* Masthead */
.masthead {
  padding-block: 3.5rem 2rem; display: grid; gap: 1.5rem 2.5rem;
  grid-template-columns: minmax(0, 1fr) minmax(14rem, 20rem);
  grid-template-areas: "text hero" "facts facts";
  align-items: start;
}
.masthead-text { grid-area: text; display: grid; gap: 1.25rem; align-content: start; min-width: 0; }
.hero { grid-area: hero; margin: 0; display: grid; gap: 0.5rem; }
.hero img { width: 100%; height: auto; border-radius: 10px; border: 1px solid var(--line); }
.hero figcaption { font-size: var(--step--1); color: var(--muted); }
.masthead .facts { grid-area: facts; }
@media (max-width: 860px) {
  .masthead { grid-template-columns: minmax(0, 1fr); grid-template-areas: "text" "hero" "facts"; }
  .hero { max-width: 22rem; }
}
.route {
  font-family: var(--font-mono); font-weight: 600; letter-spacing: 0.18em;
  color: var(--accent); font-size: var(--step--1);
}
.masthead h1 { font-size: var(--step-3); font-weight: 700; max-width: 18ch; }
.lede { max-width: 62ch; font-size: 1.0625rem; color: var(--muted); }
.lede strong { color: var(--ink); font-weight: 600; }
.facts {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr));
  gap: 0; margin: 0.5rem 0 0; border-block: 1px solid var(--line);
}
.facts div { padding: 0.9rem 1rem 0.9rem 0; }
.facts dt { font-size: var(--step--1); color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.facts dd { margin: 0.15rem 0 0; font-family: var(--font-display); font-size: var(--step-1); font-weight: 700; font-variant-numeric: tabular-nums; }

/* Step-by-step intro */
.steps-wrap { display: grid; gap: 2rem; }
.intro { display: grid; gap: 0.5rem; }

/* Timeline */
.timeline { display: grid; gap: 3rem; }
.phase { display: grid; gap: 1rem; }
.phase-head { display: grid; gap: 0.35rem; max-width: 62ch; }
.phase-head .eyebrow { font-family: var(--font-mono); font-size: 0.75rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--accent); }
.phase-head p { color: var(--muted); }
.steps { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--ink); }
.step {
  display: grid; grid-template-columns: minmax(0, 1fr) 9rem; gap: 0.75rem 1.5rem;
  padding: 1.25rem 0; border-bottom: 1px solid var(--line);
}
.body { display: grid; gap: 0.5rem; min-width: 0; }
.body h3 { font-size: 1.125rem; }
.rule { max-width: 65ch; }
.deps { display: block; font-size: var(--step--1); color: var(--muted); }
.deps a { color: var(--accent); }
td .deps { margin-top: 0.25rem; }
.did {
  max-width: 65ch; font-size: 0.9375rem; color: var(--muted);
  padding-left: 0.85rem; border-left: 2px solid var(--line);
}
.did b { color: var(--ink); font-weight: 600; }
.step-cost { text-align: right; font-variant-numeric: tabular-nums; display: grid; gap: 0.2rem; align-content: start; font-size: 0.9375rem; }
.step-cost .amt { font-family: var(--font-mono); font-weight: 600; }
.step-cost .tbc { color: var(--muted); font-size: var(--step--1); }
.step-cost .cost-line { display: grid; gap: 0; }
.step-cost .what { font-size: var(--step--1); color: var(--muted); }

/* Costs */
.costs, .tips, .resources { display: grid; gap: 1rem; }
.section-note { color: var(--muted); max-width: 65ch; }
.table-scroll { overflow-x: auto; }
.filters { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.filter {
  font: 600 0.875rem var(--font-body); color: var(--ink); background: var(--surface);
  border: 1px solid var(--line); border-radius: 999px; padding: 0.35rem 0.85rem; cursor: pointer;
}
.filter:hover { border-color: var(--accent); }
.filter[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--paper); }
.filter .count { font-family: var(--font-mono); font-weight: 400; font-size: 0.75rem; opacity: 0.75; margin-left: 0.15rem; }
table { width: 100%; border-collapse: collapse; font-size: 0.9375rem; min-width: 40rem; }
th, td { text-align: left; padding: 0.6rem 0.75rem 0.6rem 0; border-bottom: 1px solid var(--line); vertical-align: top; }
thead th { font-size: var(--step--1); text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); font-weight: 600; border-bottom-color: var(--ink); }
td.src { color: var(--muted); }
td.paid { font-family: var(--font-mono); font-size: 0.875rem; white-space: nowrap; font-variant-numeric: tabular-nums; }
td .activity { display: block; font-weight: 600; }
td .sub { display: block; color: var(--muted); font-size: 0.8125rem; font-family: var(--font-body); white-space: normal; }
.num { text-align: right; font-family: var(--font-mono); font-variant-numeric: tabular-nums; white-space: nowrap; padding-right: 0; }
tr.missing td { color: var(--muted); }
tfoot td { font-weight: 600; border-bottom: 0; border-top: 1px solid var(--ink); }
tfoot tr + tr td { border-top: 0; }

/* Tips */
.tip-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 19rem), 1fr)); gap: 1.75rem 2rem; }
.tip { display: grid; gap: 0.35rem; align-content: start; }
.tip h3 { font-size: 1.0625rem; font-weight: 700; }
.tip p { color: var(--muted); font-size: 0.9375rem; }
.tip ol { color: var(--muted); font-size: 0.9375rem; margin: 0.5rem 0 0; padding-left: 1.25rem; display: grid; gap: 0.25rem; }

/* Resources */
.res-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 18rem), 1fr)); gap: 2rem; }
.res-group { display: grid; gap: 0.75rem; align-content: start; }
.res-group h3 { font-family: var(--font-mono); font-size: 0.75rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.res-group ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.9rem; }
.res-group a { font-weight: 600; }
.res-group p { color: var(--muted); font-size: 0.9375rem; }

.foot { padding-block: 2rem 3rem; border-top: 1px solid var(--line); color: var(--muted); font-size: var(--step--1); }
.foot p { max-width: 75ch; }

@media (max-width: 720px) {
  .step { grid-template-columns: minmax(0, 1fr); gap: 0.6rem; }
  .step-cost { text-align: left; }
  }
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; } }
