/* ==========================================================================
   Opcraft — the desktop
   Light and dark tokens, desktop chrome, windows, phone layout, content.
   ========================================================================== */
@font-face { font-family: "Martina Plantijn"; src: url("/fonts/martina-plantijn-light.woff2") format("woff2"); font-weight: 300; font-display: swap; }
@font-face { font-family: "Martina Plantijn"; src: url("/fonts/martina-plantijn-regular.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Martina Plantijn"; src: url("/fonts/martina-plantijn-italic.woff2") format("woff2"); font-weight: 400; font-style: italic; font-display: swap; }
@font-face { font-family: "Martina Plantijn"; src: url("/fonts/martina-plantijn-medium.woff2") format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "IBM Plex Mono"; src: url("/fonts/IBMPlexMono-Regular.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "IBM Plex Mono"; src: url("/fonts/IBMPlexMono-Medium.woff2") format("woff2"); font-weight: 500; font-display: swap; }

/* ------------------------------------------------------------------
   Tokens
   ------------------------------------------------------------------ */
:root {
  --serif: "Martina Plantijn", "Iowan Old Style", Palatino, Georgia, serif;
  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;

  --bg: #ebe8e0;
  --topo: rgba(22, 24, 29, 0.32);
  --topo-water: rgba(31, 75, 255, 0.34);
  --surface: #f8f7f3;
  --surface-2: #f1efe8;
  --ink: #16181d;
  --ink-2: #4a4e57;
  --muted: #80848c;
  --line: #cfcbc0;
  --line-strong: #16181d;
  --accent: #1f4bff;
  --accent-ink: #ffffff;
  --accent-wash: rgba(31, 75, 255, 0.08);
  --compass: rgba(22, 24, 29, 0.34);
  --shadow: 6px 6px 0 rgba(22, 24, 29, 0.10);
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #0a0c0f;
  --topo: rgba(230, 232, 235, 0.45);
  --topo-water: rgba(96, 140, 255, 0.55);
  --surface: #111418;
  --surface-2: #161a1f;
  --ink: #e4e6e9;
  --ink-2: #b4b9c1;
  --muted: #747b85;
  --line: #262b32;
  --line-strong: #3a414a;
  --accent: #4d7dff;
  --accent-ink: #05070a;
  --accent-wash: rgba(77, 125, 255, 0.10);
  --compass: rgba(228, 230, 233, 0.30);
  --shadow: 0 0 0 1px rgba(0,0,0,0.4), 0 24px 48px rgba(0, 0, 0, 0.5);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 18px;
  line-height: 1.5;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
::selection { background: var(--accent); color: var(--accent-ink); }
a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 3px; }

.mono, .label {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* ------------------------------------------------------------------
   Menu bar
   ------------------------------------------------------------------ */
.menubar {
  position: fixed; inset: 0 0 auto 0; height: 34px; z-index: 10000;
  display: flex; align-items: stretch;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase;
}
.menubar > * { white-space: nowrap; display: flex; align-items: center; padding: 0 14px; border-right: 1px solid var(--line); }
.menubar .brand { gap: 10px; color: var(--ink); font-weight: 500; }
.menubar .brand svg { width: 16px; height: 16px; }
.menubar button {
  font: inherit; letter-spacing: inherit; text-transform: inherit;
  background: none; border: 0; color: var(--ink-2); cursor: pointer; height: 100%;
  padding: 0 14px; border-right: 1px solid var(--line);
}
.menubar button:hover, .menubar button[aria-pressed="true"] { color: var(--accent); background: var(--accent-wash); }
.menubar .nav { padding: 0; }
.menubar .spacer { flex: 1; border-right: 0; }
.menubar .meta { color: var(--muted); border-left: 1px solid var(--line); border-right: 0; }
.menubar .theme { border-left: 1px solid var(--line); border-right: 0; }
.menubar .theme b { color: var(--accent); font-weight: 500; }

/* ------------------------------------------------------------------
   Desktop
   ------------------------------------------------------------------ */
.desktop {
  position: fixed; inset: 34px 0 28px 0;
}

/* The map: the North Shore around the Temperance River and Carlton Peak,
   drawn by art/northshore.py as two mask layers so the theme colours them:
   land (contours, trail) in ink, water (shore, depths, streams) in blue */
.topo {
  position: absolute; inset: 0; pointer-events: none;
  -webkit-mask-position: 50% 45%; mask-position: 50% 45%;
  -webkit-mask-size: cover; mask-size: cover;
  -webkit-mask-repeat: no-repeat; mask-repeat: no-repeat;
}
.topo-land  { background: var(--topo); -webkit-mask-image: url("/topo-land.svg"); mask-image: url("/topo-land.svg"); }
.topo-water { background: var(--topo-water); -webkit-mask-image: url("/topo-water.svg"); mask-image: url("/topo-water.svg"); }

/* Compass rose: no labels; desktop.js turns the needle toward the pointer */
.compass {
  position: absolute; top: 34px; right: 44px; width: 150px; height: 150px;
  color: var(--compass); pointer-events: none;
}
.compass svg { width: 100%; height: 100%; display: block; overflow: visible; }
.compass .shade { fill: currentColor; fill-opacity: .45; }
.compass .needle .n { fill: var(--accent); stroke: var(--accent); }
.compass .needle .s { fill: var(--bg); stroke: var(--accent); stroke-opacity: .7; }
.compass .needle .pivot { fill: var(--bg); stroke: var(--accent); }
.compass .needle { opacity: .85; }
.poem {
  position: absolute; right: 0; bottom: 0; margin: 0; text-align: right;
  /* wide top/left padding is the fade zone; the text sits where it did before */
  padding: 56px 28px 24px 96px; background: var(--bg);
  -webkit-mask-image: linear-gradient(to right, transparent, #000 88px), linear-gradient(to bottom, transparent, #000 52px);
  -webkit-mask-composite: source-in;
  mask-image: linear-gradient(to right, transparent, #000 88px), linear-gradient(to bottom, transparent, #000 52px);
  mask-composite: intersect;
  pointer-events: none;
}
.poem blockquote { margin: 0 0 8px; }
.poem p { font-family: var(--serif); font-style: italic; font-size: 21px; line-height: 1.35; color: var(--ink-2); margin: 0; }
.poem figcaption { color: var(--muted); }
.poem figcaption::before { content: "— "; }

/* Icons */
.intro { position: absolute; left: 156px; top: 40px; width: min(580px, calc(100% - 200px)); z-index: 1; }
/* a sheet of paper behind the intro, so the map's lines fade out under the text. Two crossed
   linear masks make a rectangle with feathered edges, so the solid part reaches the corners of
   the text block (an ellipse can't).
   Right and bottom open onto the map, so they fade over a long eased ramp; a short linear one
   reads as the edge of a box. Left and top are short: the icons and the menu bar are there */
.intro::before {
  --fade-x: linear-gradient(to right, transparent, #000 52px, #000 calc(100% - 170px), rgba(0,0,0,.75) calc(100% - 120px),
                            rgba(0,0,0,.35) calc(100% - 65px), rgba(0,0,0,.1) calc(100% - 25px), transparent);
  --fade-y: linear-gradient(to bottom, transparent, #000 44px, #000 calc(100% - 124px), rgba(0,0,0,.75) calc(100% - 88px),
                            rgba(0,0,0,.35) calc(100% - 48px), rgba(0,0,0,.1) calc(100% - 18px), transparent);
  content: ""; position: absolute; inset: -36px -80px -100px -44px; z-index: -1; pointer-events: none;
  background: var(--bg); opacity: .92;
  -webkit-mask-image: var(--fade-x), var(--fade-y);
  -webkit-mask-composite: source-in;
  mask-image: var(--fade-x), var(--fade-y);
  mask-composite: intersect;
}
.intro .label { color: var(--muted); display: flex; flex-wrap: wrap; gap: 4px 14px; margin-bottom: 14px; }
.intro .label span + span::before { content: "/"; margin-right: 14px; color: var(--line); }
.intro h1.intro-title { font-size: 42px; line-height: 1.1; margin-bottom: 18px; }
.intro p { font-size: 20px; line-height: 1.45; font-weight: 300; color: var(--ink-2); margin: 0 0 20px; max-width: 34em; }
.intro-links { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.intro-links .xref { font-size: 18px; }

.icons {
  position: absolute; left: 20px; top: 20px;
  display: grid; grid-auto-flow: row; gap: 10px;
}
.icon {
  width: 104px; padding: 10px 6px 8px; display: flex; flex-direction: column; align-items: center; gap: 8px;
  background: none; border: 1px solid transparent; color: var(--ink); cursor: pointer;
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase;
}
.icon svg { width: 56px; height: 56px; color: var(--ink); }
.icon .glyph {
  display: grid; place-items: center; width: 72px; height: 72px;
  --glyph-bg: var(--surface);
  background: var(--glyph-bg); border: 1px solid var(--line);
}
.apple .f { fill: var(--glyph-bg); }
.icon .n { color: var(--muted); font-size: 10px; }
.icon:hover .glyph, .icon:focus-visible .glyph { border-color: var(--accent); }
.icon:hover svg, .icon:focus-visible svg { color: var(--accent); }
.icon.selected .glyph { --glyph-bg: var(--accent); border-color: var(--accent); }
.icon.selected svg { color: var(--accent-ink); }
.icon.selected span.t { background: var(--accent); color: var(--accent-ink); padding: 0 4px; }
.icon:focus { outline: none; }

/* ------------------------------------------------------------------
   Windows
   ------------------------------------------------------------------ */
.win {
  position: absolute; display: none; flex-direction: column;
  width: 620px; max-width: calc(100vw - 40px);
  height: 560px; max-height: calc(100% - 40px);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow);
}
.win.open { display: flex; }
.win:not(.focused) { border-color: var(--line); }
.titlebar {
  height: 32px; flex: none; display: flex; align-items: stretch;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
  cursor: grab; user-select: none; touch-action: none;
}
.titlebar:active { cursor: grabbing; }
.titlebar .path { flex: 1; display: flex; align-items: center; gap: 8px; padding: 0 12px; color: var(--muted); white-space: nowrap; overflow: hidden; }
.titlebar .path b { color: var(--ink); font-weight: 500; }
.win.focused .titlebar .path::before {
  content: ""; width: 8px; height: 8px; background: var(--accent); flex: none;
}
.win:not(.focused) .titlebar .path::before {
  content: ""; width: 8px; height: 8px; border: 1px solid var(--muted); flex: none;
}
.titlebar button {
  width: 32px; border: 0; border-left: 1px solid var(--line); background: none; color: var(--muted);
  font-family: var(--mono); font-size: 14px; cursor: pointer; padding: 0;
}
.titlebar button:hover { background: var(--accent); color: var(--accent-ink); }
.titlebar button svg { width: 11px; height: 11px; display: block; margin: auto; }
.titlebar [data-max] .restore { display: none; }
.win.max .titlebar [data-max] .grow { display: none; }
.win.max .titlebar [data-max] .restore { display: block; }

/* Maximized: fill the desktop, keep the icon column visible.
   Desktop widths only; on phones every window is already a full-width sheet. */
@media (min-width: 761px) {
  .win.max {
    left: 136px !important; top: 0 !important;
    width: calc(100% - 136px) !important; max-width: none; height: 100% !important; max-height: none;
    box-shadow: none; border-top: 0; border-right: 0; border-bottom: 0;
  }
  .win.max .body { padding-left: max(32px, calc((100% - 760px) / 2)); padding-right: max(32px, calc((100% - 760px) / 2)); }
}
.win.max .titlebar { cursor: default; }

/* Resize grip: bottom-right corner only */
.grip {
  position: absolute; right: 0; bottom: 0; width: 18px; height: 18px;
  cursor: nwse-resize; touch-action: none; color: var(--muted);
  background: var(--surface);
  border-left: 1px solid var(--line); border-top: 1px solid var(--line);
}
.grip svg { position: absolute; right: 3px; bottom: 3px; width: 10px; height: 10px; }
.grip:hover, .win.resizing .grip { color: var(--accent-ink); background: var(--accent); border-color: var(--accent); }
.win.resizing { user-select: none; }
.win.max .grip { display: none; }

.body { flex: 1; overflow: auto; padding: 28px 32px 36px; scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
.body > *:first-child { margin-top: 0; }

.head { margin-bottom: 22px; }
.head .label { color: var(--muted); display: flex; gap: 14px; margin-bottom: 10px; }
.head .label span + span::before { content: "/"; margin-right: 14px; color: var(--line); }

/* Typing + blinking block cursor (after joeldueck.com) */
h1.typed {
  font-family: var(--serif); font-weight: 400;
  font-size: 44px; line-height: 1.05; margin: 0; letter-spacing: -0.01em;
  display: inline-block; overflow: hidden; white-space: nowrap; vertical-align: bottom;
  /* bottom padding keeps descenders (y, g, p) inside the overflow clip */
  padding: 0.04em 0.08em 0.2em 0;
  border-right: 0.45em solid transparent;
}
h1.typed.run {
  animation:
    /* no forwards fill: when typing ends, the title returns to its natural width,
       so a stale measurement (font swap, reflow) can never clip it */
    typing var(--dur, 0.9s) steps(var(--n, 20), end) backwards,
    blink-cursor .5s step-end 5;
}
@keyframes typing { from { width: 0.5em; } to { width: var(--w); } }
@keyframes blink-cursor {
  from, to { border-color: transparent; }
  50% { border-color: var(--accent); }
}

/* Hover the title to expand the window */
.head { position: relative; }
.title-row { display: block; }
.title-row h1.typed { cursor: pointer; flex: none; max-width: 100%; }
.expand {
  position: absolute; right: 0; top: -4px;
  display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--accent); background: var(--accent-wash); border: 1px solid var(--accent);
  padding: 5px 10px; cursor: pointer;
  opacity: 0; transform: translateX(-6px);
  transition: opacity .15s ease, transform .15s ease;
}
.expand svg { width: 11px; height: 11px; }
.expand .less, .win.max .expand .more { display: none; }
.win.max .expand .less { display: inline; }
.head:hover .expand, .expand:focus-visible { opacity: 1; transform: none; }
.expand:hover { background: var(--accent); color: var(--accent-ink); }
.title-row:hover h1.typed { color: var(--accent); }
@media (max-width: 760px) { .expand { display: none; } .title-row h1.typed { cursor: auto; } }

/* Services → related know-how */
.related { margin-top: 10px; display: grid; grid-template-columns: auto 1fr; gap: 0 14px; align-items: baseline; }
.related:empty { display: none; }
.related .label { color: var(--muted); }
.related .links { display: flex; flex-wrap: wrap; gap: 2px 18px; }

/* Cross-references between pages.
   At rest: ink-grey text, a dotted rule, a faint pilcrow, like a marginal reference.
   On hover: the text is "selected" in steps, a character at a time, and the
   block cursor from the window titles appears at the end and blinks. */
.xref {
  position: relative;
  font: inherit; font-family: var(--serif); font-size: 16px; line-height: 1.45;
  color: var(--ink-2); border: 0; padding: 0 1px; cursor: pointer; text-align: left;
  background: linear-gradient(var(--accent-wash), var(--accent-wash)) no-repeat 0 0 / 0% 100%;
  text-decoration: underline dotted var(--muted); text-decoration-thickness: 1px; text-underline-offset: 4px;
  transition: background-size .12s steps(8, end), color .06s;
}
.xref::before { content: "¶"; color: var(--muted); margin-right: 5px; font-size: .85em; transition: color .06s; }
.xref::after {
  content: ""; position: absolute; left: 100%; top: 0; bottom: 0; width: .42em; /* same box as the selection wash */
  background: var(--accent); visibility: hidden;
}
.xref:hover, .xref:focus-visible {
  color: var(--accent); background-size: 100% 100%;
  text-decoration-color: transparent; outline: none;
}
.xref:hover::before, .xref:focus-visible::before { color: var(--accent); }
.xref:hover::after, .xref:focus-visible::after { animation: xref-cursor 1s step-end .12s infinite; }
@keyframes xref-cursor { 0% { visibility: visible; } 50% { visibility: hidden; } }
/* Plain variant for titles in lists: no pilcrow, no dotted rule, full ink */
.xref.plain { color: var(--ink); text-decoration: none; }
.xref.plain::before { content: none; }
.xref.plain:hover, .xref.plain:focus-visible { color: var(--accent); }
@media (prefers-reduced-motion: reduce) { .xref { transition: none; } .xref:hover::after { animation: none; visibility: visible; } }

/* Know-How index */
.pieces { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.pieces li { display: grid; grid-template-columns: 92px 1fr; gap: 4px 16px; padding: 16px 0; border-bottom: 1px solid var(--line); }
.pieces time { font-family: var(--mono); font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); padding-top: 6px; }
.pieces .t.xref { font-size: 21px; font-weight: 500; line-height: 1.25; }
.pieces p { margin: 4px 0 8px; font-size: 16px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase;
  border: 1px solid var(--line); background: none; color: var(--ink-2); padding: 3px 7px; cursor: pointer;
}
.chip:hover { border-color: var(--accent); color: var(--accent); }
.chip.none { cursor: default; color: var(--muted); border-style: dashed; }
.chip.none:hover { border-color: var(--line); color: var(--muted); }

/* Reader */
h1.piece-title { font-family: var(--serif); font-weight: 400; font-size: 36px; line-height: 1.12; margin: 0; letter-spacing: -0.01em; }
h1.piece-title .cur { display: inline-block; width: 0.42em; height: 0.9em; vertical-align: -0.08em; margin-left: 0.06em; background: var(--accent); }
h1.piece-title .cur.off { visibility: hidden; }
.placeholder { color: var(--muted); border: 1px dashed var(--line); padding: 40px 0; text-align: center; margin: 8px 0 22px; }
.applies { border: 1px solid var(--line); background: var(--surface-2); padding: 14px 16px; }
.applies .label { color: var(--muted); display: block; margin-bottom: 8px; }
.applies .btn { margin: 4px 6px 0 0; padding: 8px 12px; }
.lead.small { font-size: 19px; }
.lead:empty, .pieces p:empty { display: none; }

.lead { font-size: 22px; line-height: 1.4; font-weight: 300; margin: 0 0 18px; color: var(--ink); }
p { margin: 0 0 14px; color: var(--ink-2); }
h2 { font-family: var(--mono); font-weight: 500; font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); margin: 30px 0 12px; display: flex; align-items: center; gap: 10px; }
h2::after { content: ""; flex: 1; border-top: 1px solid var(--line); }

/* Spec table (Oxide-ish) */
.spec { width: 100%; border-collapse: collapse; border-top: 1px solid var(--line); margin: 6px 0 22px; }
.spec th, .spec td { border-bottom: 1px solid var(--line); padding: 9px 0; text-align: left; vertical-align: top; }
.spec th { font-family: var(--mono); font-size: 11px; font-weight: 400; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); width: 42%; }
.spec td { font-family: var(--mono); font-size: 13px; color: var(--ink); }
.spec td em { font-style: normal; color: var(--accent); }

/* Services list */
.numbered { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.numbered li { display: grid; grid-template-columns: 52px 1fr; gap: 0 14px; padding: 18px 0; border-bottom: 1px solid var(--line); }
.numbered .num { font-family: var(--serif); font-size: 28px; line-height: 1; color: var(--accent); font-style: italic; }
.numbered h3 { margin: 0 0 6px; font-weight: 500; font-size: 21px; line-height: 1.2; }
.numbered p { margin: 0 0 8px; font-size: 17px; }
.numbered .best { font-family: var(--mono); font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.numbered .best b { color: var(--ink); font-weight: 500; }

/* Numbered lists: services, principles */
.principles { margin-bottom: 22px; }
.numbered h3 .xref { font-size: inherit; font-weight: inherit; line-height: inherit; }
.xref .arr { color: var(--muted); margin-left: .35em; font-weight: 400; }
.xref:hover .arr, .xref:focus-visible .arr { color: var(--accent); }
#win-service .applies { margin: 0 0 20px; }
.kinds { display: flex; flex-wrap: wrap; gap: 6px; margin: 2px 0 10px; }
.kinds span { font-family: var(--mono); font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--accent); border: 1px solid var(--accent); padding: 3px 8px; }
#service-kinds .kinds { margin: -6px 0 16px; }
#win-service #service-signs { font-size: 17px; color: var(--ink); }
#win-service .related { margin: 0 0 8px; }

.figure { display: flex; gap: 18px; align-items: center; border: 1px solid var(--line); padding: 14px; margin: 0 0 22px; background: var(--surface-2); }
.figure svg { width: 120px; height: 120px; flex: none; color: var(--ink-2); }
.figure p { margin: 0; font-size: 16px; }
.figure .label { color: var(--muted); display: block; margin-bottom: 6px; }

.portrait { float: right; width: 150px; margin: 4px 0 12px 20px; border: 1px solid var(--line); filter: grayscale(1) contrast(1.05); }
.aside { font-size: 16px; border-left: 2px solid var(--accent); padding-left: 14px; color: var(--muted); }

.btn {
  display: inline-flex; align-items: center; gap: 10px;
  font-family: var(--mono); font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase;
  padding: 11px 16px; border: 1px solid var(--accent); background: var(--accent); color: var(--accent-ink);
  text-decoration: none;
}
.btn.ghost { background: none; color: var(--accent); }
.btn:hover { filter: brightness(1.1); }
.row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 18px; }

/* ------------------------------------------------------------------
   Status bar
   ------------------------------------------------------------------ */
.statusbar {
  position: fixed; inset: auto 0 0 0; height: 28px; z-index: 10000;
  display: flex; align-items: stretch; background: var(--surface); border-top: 1px solid var(--line);
  color: var(--muted);
}
.statusbar > * { display: flex; align-items: center; padding: 0 12px; border-right: 1px solid var(--line); }
.statusbar .tasks { padding: 0; flex: 1; border-right: 0; overflow: hidden; }
.statusbar .task {
  font: inherit; letter-spacing: inherit; text-transform: inherit; background: none; border: 0;
  border-right: 1px solid var(--line); color: var(--ink-2); padding: 0 12px; height: 100%; cursor: pointer;
}
.statusbar .task.focused { color: var(--accent); background: var(--accent-wash); }
.statusbar .right { border-right: 0; border-left: 1px solid var(--line); }

/* ------------------------------------------------------------------
   Card peek: hold Cmd (Ctrl elsewhere) and a Card link fades in under the
   right end of the menu bar; it opens the og:image card of the page in
   front in .cardview. See desktop.js
   ------------------------------------------------------------------ */
#peek {
  position: fixed; top: 42px; right: 8px; z-index: 10001;
  display: inline-flex; align-items: center; gap: 8px; padding: 5px 10px;
  color: var(--accent); background: var(--surface); border: 1px solid var(--accent);
  text-decoration: none; cursor: pointer;
  opacity: 0; visibility: hidden; transform: translateY(-4px);
  transition: opacity .2s ease, transform .2s ease, visibility .2s;
}
#peek::before { content: ""; width: 8px; height: 8px; background: currentColor; flex: none; }
body.peek #peek { opacity: 1; visibility: visible; transform: none; }
#peek:hover { background: var(--accent); color: var(--accent-ink); }
#peek.none, #peek.none:hover { color: var(--muted); background: var(--surface); border-color: var(--line); cursor: default; }
@media (prefers-reduced-motion: reduce) { #peek { transition: none; transform: none; } }

.cardview {
  position: fixed; inset: 0; z-index: 20000;
  display: grid; place-items: center; padding: 24px;
  background: color-mix(in srgb, var(--bg) 72%, transparent);
  cursor: zoom-out;
}
.cardview .frame {
  margin: 0; cursor: auto;
  /* 81px = the padding and the bar, so the whole card fits the height too */
  width: min(1200px, 100%, calc((100vh - 81px) * 1200 / 630));
  background: var(--surface); border: 1px solid var(--line-strong); box-shadow: var(--shadow);
}
.cardview .bar { height: 32px; display: flex; align-items: stretch; border-bottom: 1px solid var(--line); background: var(--surface-2); }
.cardview .path { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; padding: 0 12px; color: var(--muted); white-space: nowrap; overflow: hidden; }
.cardview .path::before { content: ""; width: 8px; height: 8px; background: var(--accent); flex: none; }
.cardview .path b { color: var(--ink); font-weight: 500; overflow: hidden; text-overflow: ellipsis; }
.cardview .bar a, .cardview .bar button {
  display: flex; align-items: center; justify-content: center; padding: 0 12px;
  border: 0; border-left: 1px solid var(--line); background: none; color: var(--muted);
  font: inherit; letter-spacing: inherit; text-transform: inherit; text-decoration: none; cursor: pointer;
}
.cardview .bar button { width: 32px; padding: 0; font-size: 14px; }
.cardview .bar a:hover, .cardview .bar button:hover, .cardview .bar button:focus-visible { background: var(--accent); color: var(--accent-ink); outline: none; }
.cardview img { display: block; width: 100%; height: auto; }

/* "Where next" footer at the end of each window */
.next {
  margin-top: 34px; padding-top: 16px; border-top: 1px solid var(--line);
  display: grid; grid-template-columns: auto 1fr auto; gap: 10px 18px; align-items: center;
}
.next > .label { color: var(--muted); }
.next .links { display: flex; flex-wrap: wrap; gap: 4px 18px; }
.next .btn { justify-self: end; }

/* Know-How: tag selector, year groups, tags on each piece */
.tagbar {
  position: sticky; top: -28px; z-index: 2;   /* -28px = the body's top padding: stick flush to the edge */
  margin: 0 -32px 6px; padding: 10px 32px;
  background: var(--surface); border-bottom: 1px solid var(--line);
  display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
}
.tagbar .label { color: var(--muted); margin-right: 4px; }
.tagopt {
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase;
  background: none; color: var(--ink-2); border: 1px solid var(--line); padding: 4px 8px; cursor: pointer;
  display: inline-flex; gap: 6px; align-items: baseline; white-space: nowrap;
}
.tagopt sup { font-size: 9px; color: var(--muted); vertical-align: baseline; }
.tagopt:hover { border-color: var(--accent); color: var(--accent); }
.tagopt[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.tagopt[aria-pressed="true"] sup { color: var(--accent-ink); opacity: .75; }
.year-group h2 { margin: 26px 0 0; }
.year-group:first-child h2 { margin-top: 14px; }
.year-group h2::after { content: none; }
.year-group .pieces { border-top: 0; }
.pieces .meta { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; }
.tag {
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.04em; color: var(--muted);
  background: none; border: 0; padding: 2px 0; cursor: pointer;
}
.tag:hover, .tag.on { color: var(--accent); }
.pieces .meta .chip { margin-left: 2px; }

/* "Show desktop": the brand and the status-bar button */
.menubar .brand { cursor: pointer; }
.menubar .brand:hover { background: var(--accent-wash); }
.statusbar .deskbtn {
  font: inherit; letter-spacing: inherit; text-transform: inherit; background: none; border: 0;
  border-right: 1px solid var(--line); color: var(--ink-2); cursor: pointer; gap: 7px;
}
.statusbar .deskbtn svg { width: 11px; height: 11px; }
.statusbar .deskbtn:hover { color: var(--accent); background: var(--accent-wash); }
.desktop:not(.has-windows) ~ .statusbar .deskbtn { color: var(--muted); }

/* ------------------------------------------------------------------
   Small screens: no dragging; windows become stacked sheets
   ------------------------------------------------------------------ */
@media (max-width: 760px) {
  body { overflow: auto; font-size: 17px; }
  .menubar .nav, .menubar .meta { display: none; }
  .desktop { position: static; padding: 50px 16px 48px; min-height: 100vh; }
  /* Sticky header: the icon row sticks under the menu bar; once the page
     scrolls it folds into a compact toolbar (smaller tiles, same labels). */
  body { overflow-anchor: none; }
  .icons {
    position: sticky; top: 34px; z-index: 900;
    display: flex; gap: 6px; justify-content: space-between;
    margin: -16px -16px 16px; padding: 12px 16px 8px;
    background: var(--bg); border-bottom: 1px solid transparent;
    transition: padding .2s ease, border-color .2s ease, box-shadow .2s ease;
  }
  body.compact .icons { padding: 6px 16px 5px; border-bottom-color: var(--line); box-shadow: 0 8px 16px -14px rgba(0,0,0,.35); }
  .icon .glyph, .icon svg { transition: height .2s ease, width .2s ease; }
  body.compact .icon { gap: 3px; padding: 0 2px; }
  body.compact .icon .glyph { height: 30px; }
  body.compact .icon svg { width: 22px; height: 22px; }
  body.compact .icon span.t { font-size: 10px; }
  .icon { width: auto; flex: 1; padding: 6px 2px; }
  .icon .glyph { width: 100%; height: 64px; }
  .icon svg { width: 44px; height: 44px; }
  .desktop { display: flex; flex-direction: column; }
  .intro { position: relative; left: auto; top: auto; width: auto; margin: 6px 0 24px; }
  /* edge to edge across the 16px gutters, so only the top and bottom fade */
  .intro::before {
    inset: -30px -16px;
    -webkit-mask-image: linear-gradient(to bottom, transparent, #000 24px, #000 calc(100% - 24px), transparent);
    mask-image: linear-gradient(to bottom, transparent, #000 24px, #000 calc(100% - 24px), transparent);
  }
  /* open windows cover the desktop content, as they do on wider screens */
  .desktop.has-windows .intro { display: none; }
  .intro h1.intro-title { font-size: 30px; }
  .intro p { font-size: 18px; }
  .poem { position: relative; z-index: 1; order: 99; text-align: left; margin: auto 0 0; padding: 22px 2px 0; border-top: 1px solid var(--line); background: none; -webkit-mask-image: none; mask-image: none; }
  /* the same paper as the intro, from the rule down to the status bar, edge to edge */
  .poem::before { content: ""; position: absolute; inset: 1px -16px -20px; z-index: -1; background: var(--bg); opacity: .92; }
  .topo { position: fixed; z-index: -1; -webkit-mask-position: 62% 30%; mask-position: 62% 30%; }
  .compass { display: none; }
  .win { position: relative !important; left: auto !important; top: auto !important; width: 100%; max-width: none; height: auto; max-height: none; margin-bottom: 16px; }
  .titlebar { cursor: default; }
  .titlebar [data-max] { display: none; }
  .grip { display: none; }
  /* maximized on a phone: edge to edge, past the 16px gutter */
  .win.max { margin-left: -16px; margin-right: -16px; width: calc(100% + 32px) !important; max-width: none;
             border-left: 0; border-right: 0; box-shadow: none; }
  .win { width: 100% !important; height: auto !important; }
  .body { padding: 22px 18px 26px; }
  h1.typed { font-size: 34px; }
  .portrait { width: 110px; }
  .pieces li { grid-template-columns: 1fr; }
  .pieces time { padding-top: 0; }
  h1.piece-title { font-size: 28px; }
  .statusbar .tasks { display: none; }
  .statusbar { justify-content: space-between; }
  .statusbar .mock { display: none; }
  .win .body { overflow: visible; }       /* lets the tag bar stick to the page */
  .tagbar { top: 93px; margin: 0 -18px 6px; padding: 8px 18px; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .tagbar::-webkit-scrollbar { display: none; }
  .next { grid-template-columns: 1fr; }
  .next .btn { justify-self: start; }
}

@media (max-width: 1000px) { .menubar .meta { display: none; } }

@media (prefers-reduced-motion: reduce) {
  h1.typed.run { animation: none; width: auto; }
}

/* ==========================================================================
   Multi-page prototype layer (appended to the mockup's CSS by build.py)
   Real links replace the mockup's buttons; window titles share one style.
   ========================================================================== */
.menubar a {
  font: inherit; letter-spacing: inherit; text-transform: inherit; text-decoration: none;
  color: var(--ink-2); display: flex; align-items: center; height: 100%;
  padding: 0 14px; border-right: 1px solid var(--line);
}
.menubar .nav a:hover, .menubar .nav a[aria-current] { color: var(--accent); background: var(--accent-wash); }
.menubar a.brand { color: var(--ink); font-weight: 500; gap: 10px; }

.titlebar .close {
  width: 32px; flex: none; border-left: 1px solid var(--line); color: var(--muted);
  font-family: var(--mono); font-size: 14px; display: grid; place-items: center; text-decoration: none;
}
.titlebar .close:hover { background: var(--accent); color: var(--accent-ink); }

a.icon, a.tagopt, a.tag, a.chip, a.deskbtn, a.btn { text-decoration: none; }
a.chip { display: inline-block; }
.tagopt[aria-current] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.tagopt[aria-current] sup { color: var(--accent-ink); opacity: .75; }
.tag[aria-current] { color: var(--accent); }
.statusbar a.deskbtn { display: flex; align-items: center; }
.piece-tags { margin: 0 0 14px; }
.applies .signs-text { font-size: 17px; color: var(--ink); }

/* Window titles: one style for all. The script types them in; without the
   script they are plain text. */
h1.wtitle { font-family: var(--serif); font-weight: 400; font-size: 44px; line-height: 1.08; margin: 0; letter-spacing: -0.01em; }
h1.wtitle.long { font-size: 36px; line-height: 1.12; }
h1 .cur { display: inline-block; width: 0.42em; height: 0.9em; vertical-align: -0.08em; margin-left: 0.06em; background: var(--accent); }
h1 .cur.off { visibility: hidden; }
.title-row h1.wtitle { cursor: pointer; }
.title-row:hover h1.wtitle { color: var(--accent); }

/* Without the script, the page's one window still sits in a sensible spot */
.win { left: 156px; top: 20px; width: min(880px, calc(100% - 180px)); height: calc(100% - 40px); }
.win[data-size="small"] { width: 560px; height: 540px; }
.desktop.loading, .desktop.loading a { cursor: progress; }

@media (max-width: 760px) {
  h1.wtitle { font-size: 32px; }
  h1.wtitle.long { font-size: 28px; }
  .title-row h1.wtitle { cursor: auto; }
  .related { grid-template-columns: 1fr; gap: 4px; }
}

/* ==========================================================================
   Site content inside windows
   ========================================================================== */
[hidden] { display: none !important; }

/* Roman numerals from a counter, so lists need no hand-numbering */
.numbered { counter-reset: n; }
.numbered > li { counter-increment: n; }
.numbered > li::before {
  content: counter(n, lower-roman) ".";
  font-family: var(--serif); font-size: 28px; line-height: 1; font-style: italic; color: var(--accent);
}
.numbered li > div > h3:first-child { margin-top: 0; }   /* beats .prose h3 on About */
.numbered li > div > p:last-child { margin-bottom: 0; }
.principles { margin: 8px 0 26px; }

.prose { line-height: 1.6; }
.prose > :first-child { margin-top: 0; }
.prose p { margin: 0 0 14px; color: var(--ink-2); }
.prose h2 {
  display: block; font-family: var(--serif); font-weight: 500; font-size: 25px; line-height: 1.2;
  letter-spacing: 0; text-transform: none; color: var(--ink); margin: 34px 0 12px;
}
.prose h2::after { content: none; }
.prose h3 { font-weight: 500; font-size: 20px; line-height: 1.25; margin: 26px 0 8px; }
.prose ul, .prose ol:not(.numbered) { margin: 0 0 14px; padding-left: 1.3em; color: var(--ink-2); }
.prose li { margin-bottom: .35em; }
.prose blockquote { margin: 22px 0; padding: 0 0 0 16px; border-left: 2px solid var(--accent); color: var(--ink); font-size: 19px; }
.prose blockquote p { color: inherit; }
.prose hr { border: 0; text-align: center; margin: 30px 0; line-height: 1; }
.prose hr::before { content: "• • •"; color: var(--accent); letter-spacing: .5em; }
.prose code { font-family: var(--mono); font-size: .84em; background: var(--surface-2); border: 1px solid var(--line); padding: .05em .3em; }
.prose pre { font-family: var(--mono); font-size: 13px; line-height: 1.5; background: var(--surface-2); border: 1px solid var(--line); padding: 12px 14px; overflow-x: auto; }
.prose pre code { border: 0; background: none; padding: 0; }
.prose img:not(.portrait) { max-width: 100%; height: auto; }
.prose sup { font-size: .7em; line-height: 0; }
.prose .footnotes { font-size: 15px; border-top: 1px solid var(--line); margin-top: 28px; padding-top: 12px; }
.prose .footnotes p { font-size: inherit; }
.prose .row { margin: 22px 0 6px; }

kbd {
  display: inline-block; font-family: var(--mono); font-size: .78em; line-height: 1.2; color: var(--ink);
  padding: .1em .4em; margin: 0 1px; background: var(--surface-2); border: 1px solid var(--line);
  box-shadow: inset 0 -1px 0 var(--line); white-space: nowrap; vertical-align: .05em;
}
.inline-note { font-style: italic; font-size: 16px; color: var(--ink-2); border-left: 2px solid var(--accent); background: var(--accent-wash); padding: 10px 14px; margin: 20px 0; }
.inline-note p { margin: 0; color: inherit; }
.personal {
  font-size: 18px; color: var(--ink); background: var(--surface-2); border: 1px solid var(--line);
  padding: 16px 20px 6px; max-width: 32rem; margin: 6px 0 20px; transform: rotate(-.6deg); box-shadow: var(--shadow);
}
.personal p { color: inherit; }
.aside p { margin: 0; }
.placeholder p { margin: 0; color: inherit; }
.spec td p { margin: 0; }
.piece-tags { margin: 18px 0 14px; }

/* Know-How: the by-tag index is the no-script fallback for the tag selector */
.by-tag { margin-top: 30px; }
.by-tag h3 { font-family: var(--mono); font-size: 12px; font-weight: 500; letter-spacing: .06em; color: var(--accent); margin: 16px 0 6px; }
.by-tag ul { margin: 0; padding-left: 1.2em; font-size: 16px; }
.js .by-tag { display: none; }

.statusbar a.mock { color: var(--muted); text-decoration: none; }
.statusbar a.mock:hover { color: var(--accent); background: var(--accent-wash); }

.portrait { height: auto; }
