/* Project document pages under /work/. Built on home.css; two layouts, picked per
   section: .split puts the text left and the picture right (sticky while the text
   scrolls), .flow runs text and then a full-width picture, one under the other. */
body.doc main { max-width:1120px; }
.crumb { margin-bottom:72px; font:400 12px/1.6 var(--mono); }
.crumb a { color:var(--muted); text-decoration:none; }
.crumb a::before { content:'← '; }
.crumb a:hover { color:#fff; }

.doc-head { max-width:640px; }
.doc-head h1 { margin:0 0 20px; font-size:28px; font-weight:600; letter-spacing:-.01em; }
.lede { font-size:18px; line-height:1.75; }
.meta { display:grid; grid-template-columns:repeat(2, minmax(0, 1fr)); gap:16px 32px; margin:40px 0 0; }
.meta dt { font:400 12px/1.6 var(--mono); color:var(--muted); }
.meta dd { margin:2px 0 0; }

figure { margin:0; }
figure img { display:block; width:100%; height:auto; border-radius:8px; }
.hero { margin:72px 0 0; }
.hero img { border-radius:0; }

.stats { list-style:none; display:grid; grid-template-columns:repeat(3, 1fr); gap:32px; margin:56px 0 0; padding:0; }
.stats strong { display:block; font-size:28px; font-weight:600; font-variant-numeric:tabular-nums; }
.stats span { color:var(--muted); }

section.split, section.flow { margin-top:144px; }
.text h2 { margin:0 0 20px; font:600 20px/1.5 var(--sans); color:var(--ink); letter-spacing:-.005em; }
.text p { color:#cfcfcf; }
.text em { color:var(--ink); }

.split { display:grid; grid-template-columns:minmax(0, 5fr) minmax(0, 7fr); gap:64px; align-items:start; }
.split figure { position:sticky; top:12vh; }
.flow .text { max-width:640px; }
.flow figure { margin-top:40px; }

.figures { list-style:none; margin:28px 0; padding:0; display:grid; gap:16px; }
.figures li { display:grid; grid-template-columns:1fr auto; align-items:baseline; column-gap:16px; padding-bottom:16px; border-bottom:1px solid #2c2c2c; }
.figures span { color:var(--muted); }
.figures strong { font-size:22px; font-weight:600; font-variant-numeric:tabular-nums; }
.figures small { grid-column:1 / -1; color:#777; font-size:13px; font-variant-numeric:tabular-nums; }
.note { font-size:13px; color:#777 !important; }

.lessons p { margin-bottom:1.6em; }
.doc-foot { display:flex; gap:32px; margin-top:144px; padding-top:32px; border-top:1px solid #2c2c2c; }

@media (max-width:800px) {
  .split { grid-template-columns:1fr; gap:32px; }
  .split figure { position:static; }
  section.split, section.flow { margin-top:96px; }
  .meta, .stats { grid-template-columns:1fr 1fr; }
}

/* Text-only write-up: one readable column. */
.essay blockquote { margin:28px 0; padding:2px 0 2px 18px; border-left:2px solid var(--line); color:var(--ink); }
.essay h3[id] { scroll-margin-top:32px; }
.essay section[id] { scroll-margin-top:32px; }
.toc { margin:56px 0 0; font-size:15px; }
.toc ol { list-style:none; margin:0; padding:0; display:grid; gap:6px; }
.toc ol ol { margin:6px 0 4px 16px; }
.toc a { color:var(--muted); text-decoration-color:transparent; }
.toc a:hover { color:#fff; text-decoration-color:var(--muted); }
.essay { max-width:680px; }
.essay section { margin-top:128px; }
.essay p { margin-bottom:1.6em; }
.essay h2 { margin:0 0 20px; font:600 22px/1.5 var(--sans); letter-spacing:-.005em; }
.essay h3 { margin:72px 0 16px; font:600 17px/1.6 var(--sans); }
.essay h2 + h3, .essay p + h3:first-of-type { margin-top:48px; }
.essay p, .essay li, .essay dd, .essay td { color:#cfcfcf; }
.step { display:block; margin-bottom:12px; font:400 12px/1.6 var(--mono); color:var(--muted); }
.plain { list-style:none; margin:0 0 1.4em; padding:0; display:grid; gap:8px; }
.plain li { padding-left:16px; position:relative; }
.plain li::before { content:'–'; position:absolute; left:0; color:var(--muted); }
.plain strong { color:var(--ink); font-weight:600; }
.qa { margin:24px 0 0; display:grid; gap:4px; }
.qa dt { color:var(--ink); }
.qa dt::before { content:'Q. '; color:var(--muted); font-family:var(--mono); font-size:13px; }
.qa dd { margin:0 0 20px; }
.numbers { width:100%; margin:20px 0 12px; border-collapse:collapse; font-variant-numeric:tabular-nums; }
.numbers th { font:400 12px/1.6 var(--mono); color:var(--muted); text-align:left; padding:0 12px 8px 0; }
.numbers td { padding:10px 12px 10px 0; border-top:1px solid #2c2c2c; }
.numbers td:not(:first-child), .numbers th:not(:first-child) { text-align:right; }

@keyframes page-in { from { opacity:0; } }
@media (prefers-reduced-motion: no-preference) { body.doc { animation:page-in 360ms ease-out backwards; } }

/* On wide screens the table of contents leaves the column and becomes a rail of short
   marks on the left edge (one per heading, the current one brighter). Hovering it opens
   a panel of titles over the rail. site.js splits the list in two: .toc-marks (the rail,
   hidden from assistive tech) and .toc-panel (the real list). The rail never changes
   size; the panel is its own layer, so opening it moves nothing.

   Opening waits 80ms so a pointer just passing by does not flash it, then fades and
   slides 6px in from the rail over 200ms. Closing is softer and waits 120ms, so a
   pointer slipping off the edge for a moment does not shut it. Both are transitions,
   so a change of mind mid-way reverses smoothly. */
@media (prefers-reduced-motion: no-preference) { html:has(body.doc) { scroll-behavior:smooth; } }
.toc--rail { display:none; }
.toc .toc-marks { display:none; }
@media (min-width:1100px) {
  .toc--rail { display:block; }
  .toc { --ease-out:cubic-bezier(.2, 0, 0, 1); position:fixed; z-index:5; left:12px; top:50%; translate:0 -50%; margin:0; padding:12px; font-size:13px; line-height:1.4; }
  .toc ol { gap:0; margin:0; }

  /* The rail: 8px dashes (5px for sub-items), 9px apart, 16px between topics. */
  .toc .toc-marks { display:block; transition:opacity 160ms var(--ease-out) 120ms; }
  .toc-marks a { display:block; position:relative; width:12px; height:9px; }
  .toc-marks a span { display:none; }
  .toc-marks a::after { content:''; position:absolute; left:0; top:50%; width:8px; height:1.5px; translate:0 -50%; border-radius:1px; background:#4a4a4a; transition:background-color 160ms ease-out; }
  .toc-marks ol ol a::after { width:5px; }
  .toc-marks a[aria-current="true"]::after { background:var(--ink); }
  .toc-marks > li + li { margin-top:7px; }

  /* The panel: titles only, over the rail, centred on it. */
  .toc-panel { position:absolute; left:0; top:50%; min-width:180px; max-height:80vh; overflow:auto; padding:12px 16px 12px 12px; border-radius:10px; background:#202020; box-shadow:0 0 0 1px rgba(255,255,255,.06), 0 12px 32px rgba(0,0,0,.45); opacity:0; translate:-6px -50%; pointer-events:none;
    transition:opacity 160ms var(--ease-out) 120ms, translate 200ms var(--ease-out) 120ms; }
  .toc:hover .toc-panel, .toc:focus-within .toc-panel { opacity:1; translate:0 -50%; pointer-events:auto; transition-delay:80ms; }
  .toc:hover .toc-marks, .toc:focus-within .toc-marks { opacity:0; transition-delay:80ms; }
  .toc-panel a { display:block; padding:3px 8px; margin:0 -8px; border-radius:6px; white-space:nowrap; color:#8f8f8f; transition:color 120ms ease-out, background-color 120ms ease-out; }
  .toc-panel a:hover { color:var(--ink); background:#2a2a2a; }
  .toc-panel a[aria-current="true"] { color:var(--ink); }
  /* Topics read as headings; the principles under them are indented and quieter. */
  .toc-panel > li > a { color:#c8c8c8; font-weight:500; }
  .toc-panel ol ol a, .toc-panel ol a { font-weight:400; }
  .toc-panel ol a { padding-left:22px; font-size:12px; color:#8a8a8a; }
  .toc-panel > li + li { margin-top:4px; }
}
@media (min-width:1100px) and (prefers-reduced-motion: reduce) {
  .toc-panel, .toc-marks { transition:none; }
}

/* ---------------------------------------------------------------------------------
   Reading aids shared by every document page: the section rail on the left, a
   back-to-top button in the lower left, and the Home link floating in the top-left
   corner once the one at the top of the page has scrolled away. */
.to-top, .home-float { position:fixed; z-index:6; opacity:0; visibility:hidden; transition:opacity 180ms ease-out, visibility 0s 180ms, color 120ms ease-out, border-color 120ms ease-out, background-color 120ms ease-out; }
.to-top.is-shown, .home-float.is-shown { opacity:1; visibility:visible; transition-delay:0s; }
.to-top { left:16px; bottom:16px; width:40px; height:40px; display:grid; place-items:center; padding:0; border:0; border-radius:8px; background:none; color:var(--muted); cursor:pointer; }
.to-top:hover { color:#fff; background:#222; }
.to-top svg { width:16px; height:16px; }
.home-float { left:20px; top:16px; padding:6px 10px; border-radius:6px; font:400 12px/1.6 var(--mono); color:var(--muted); text-decoration:none; background:rgba(26,26,26,.85); backdrop-filter:blur(8px); }
.home-float::before { content:'← '; }
.home-float:hover { color:#fff; background:#222; }

/* ---------------------------------------------------------------------------------
   Pictures beside the text. Each <figure class="media"> sits in the text where it
   belongs. On wide screens site.js moves the figures into a sticky stage on the right
   and shows the one for the passage being read, sliding in from the right; below the
   breakpoint they stay inline at that spot. */
.media { margin:40px 0; }
.media img, .media video { display:block; width:100%; height:auto; }
.media figcaption { margin-top:12px; font-size:13px; line-height:1.6; color:var(--muted); }
.media--card img, .media--card video { border-radius:12px; background:#202020; }
.media--phone { display:flex; flex-direction:column; align-items:center; }
.media--phone img { width:auto; max-width:100%; max-height:min(78vh, 760px); }
.media--wide img { border-radius:12px; }

/* A drawn phone for recordings and the live site (renders from Figma already have one). */
.device { position:relative; width:min(100%, 340px); aspect-ratio:390 / 844; padding:10px; border-radius:52px; background:#0b0b0b; box-shadow:0 0 0 1px #3a3a3a, 0 30px 80px rgba(0,0,0,.5); }
.device::before { content:''; position:absolute; z-index:2; top:20px; left:50%; translate:-50% 0; width:30%; height:26px; border-radius:14px; background:#000; }
/* The page starts below a status bar (time, signal, battery) like a real phone, so the
   island never sits on top of the site's own header. */
.device { --bar:44px; }
.device::after { content:'9:41'; position:absolute; z-index:1; top:10px; left:10px; right:10px; height:var(--bar); box-sizing:border-box; padding:0 0 0 34px; display:flex; align-items:center; border-radius:42px 42px 0 0; font:600 14px/1 -apple-system, 'Helvetica Neue', sans-serif; letter-spacing:-.01em; color:#000; background:#fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='66' height='12' viewBox='0 0 66 12'%3E%3Cg fill='%23000'%3E%3Crect x='0' y='8' width='3' height='4' rx='.7'/%3E%3Crect x='4.5' y='6' width='3' height='6' rx='.7'/%3E%3Crect x='9' y='3.5' width='3' height='8.5' rx='.7'/%3E%3Crect x='13.5' y='1' width='3' height='11' rx='.7'/%3E%3Cpath d='M28 3.2a9 9 0 0 1 6.2 2.5l1.1-1.2A10.6 10.6 0 0 0 28 1.6a10.6 10.6 0 0 0-7.3 2.9l1.1 1.2A9 9 0 0 1 28 3.2zm0 3.3a5.6 5.6 0 0 1 3.9 1.6l1.1-1.2A7.2 7.2 0 0 0 28 4.9a7.2 7.2 0 0 0-5 2l1.1 1.2A5.6 5.6 0 0 1 28 6.5zm0 3.2a2.4 2.4 0 0 1 1.6.6L28 12l-1.6-1.7a2.4 2.4 0 0 1 1.6-.6z'/%3E%3Crect x='40.5' y='.5' width='22' height='11' rx='3.2' fill='none' stroke='%23000' stroke-opacity='.4'/%3E%3Crect x='42.5' y='2.5' width='18' height='7' rx='1.6'/%3E%3Cpath d='M64 4v4a2 2 0 0 0 0-4z' fill-opacity='.4'/%3E%3C/g%3E%3C/svg%3E") no-repeat right 26px center / 66px 12px; }
.device > * { display:block; width:100%; height:calc(100% - var(--bar)); margin-top:var(--bar); border:0; border-radius:0 0 42px 42px; background:#fff; object-fit:cover; }
.device-note { margin-top:12px; font:400 12px/1.6 var(--mono); color:var(--muted); }

@media (min-width:1180px) {
  body.has-stage main { max-width:1400px; display:grid; grid-template-columns:minmax(0, 640px) minmax(420px, 1fr); column-gap:80px; align-items:start; padding-left:96px; padding-right:48px; }
  body.has-stage main > :not(.stage) { grid-column:1; }
  body.has-stage .crumb, body.has-stage .doc-foot { grid-column:1; }
  .stage { grid-column:2; grid-row:1 / span 99; position:sticky; top:0; height:100vh; }
  .stage figure { position:absolute; inset:0; margin:0; display:flex; flex-direction:column; justify-content:center; align-items:center; padding:7vh 0; opacity:0; transform:translateX(56px); pointer-events:none; transition:opacity 360ms cubic-bezier(.2,.7,.2,1), transform 520ms cubic-bezier(.2,.7,.2,1); }
  .stage figure.is-active { opacity:1; transform:none; pointer-events:auto; }
  .stage figure.is-leaving { opacity:0; transform:translateX(-24px); }
  .stage figure > img, .stage figure > video { max-height:80vh; width:auto; max-width:100%; }
  .stage .media--phone img { max-height:84vh; }
  .stage figcaption { align-self:stretch; text-align:center; }
  .media-anchor { display:block; height:0; }
  /* The opening figure: top edge level with the title, a little wider than the column. */
  .stage figure.is-lead { justify-content:flex-start; padding-top:var(--lead-top, 7vh); left:-40px; right:calc(24px - 48px - max(0px, (100vw - 1400px) / 2)); }
  .stage figure.is-lead > video, .stage .is-lead.media--video video, .stage .is-lead .embed { width:100%; max-width:none; }
}
@media (prefers-reduced-motion: reduce) { .stage figure { transition:none; transform:none; } }

/* Placeholders for pictures that are still to be captured or drawn. */
.placeholder { display:flex; flex-direction:column; justify-content:center; gap:6px; padding:24px; border:1.5px dashed #444; border-radius:12px; color:var(--muted); font-size:14px; text-align:center; }
.placeholder strong { color:#cfcfcf; font-weight:500; }
.placeholder span { font:400 12px/1.6 var(--mono); }
.media--todo[data-shape="wide"] .placeholder { aspect-ratio:16 / 9; }
.media--todo[data-shape="square"] .placeholder { aspect-ratio:1; }
.media--todo[data-shape="phone"] .placeholder { aspect-ratio:390 / 844; width:min(100%, 340px); margin:0 auto; border-radius:44px; }
.stage .media--todo .placeholder { width:min(100%, 560px); }
.stage .media--todo[data-shape="phone"] .placeholder { width:min(100%, 340px); }

/* A drawn browser window around the live PC site; site.js scales a 1280px page into it. */
.browser { width:100%; border-radius:12px; overflow:hidden; background:#0b0b0b; box-shadow:0 0 0 1px #3a3a3a, 0 30px 80px rgba(0,0,0,.5); }
.browser-bar { display:flex; align-items:center; gap:6px; height:32px; padding:0 12px; background:#202020; }
.browser-bar i { width:10px; height:10px; border-radius:50%; background:#444; }
.browser-bar span { flex:1; text-align:center; font:400 11px/1 var(--mono); color:var(--muted); margin-right:46px; }
.browser-view { position:relative; aspect-ratio:1280 / 800; overflow:hidden; }
.browser-view iframe { position:absolute; left:0; top:0; width:1280px; height:800px; border:0; transform-origin:0 0; transform:scale(var(--s, .5)); background:#000; }
.stage .media--browser .browser { width:min(100%, 720px); }

.media--video video { border-radius:12px; background:#000; }
.stage .media--video video { width:100%; max-width:760px; height:auto; }

/* Live browsers need room: in the stage they reach past the column, toward the window's
   right edge (24px short of it) and a little into the gap before the text. */
@media (min-width:1180px) {
  .stage figure.media--browser { left:-40px; right:calc(24px - 48px - max(0px, (100vw - 1400px) / 2)); }
  .stage .media--browser .browser { width:100%; max-width:none; }
}

/* Pages whose pictures are not final yet: hide every figure and the stage, text only. */
body.media-off figure.media, body.media-off .stage { display:none; }

/* A row of screens read side by side (before → after, or the steps of one gesture). */
.media-set { display:flex; justify-content:center; align-items:flex-start; gap:16px; }
.media-set img { flex:1 1 0; min-width:0; width:100%; height:auto; border-radius:12px; }
.stage .media-set { width:100%; }
.stage .media-set img { max-height:72vh; object-fit:contain; }
.media-set--phones img { max-width:260px; border-radius:20px; }

/* A video hosted elsewhere (YouTube), 16:9, loaded on first show like the live sites. */
.embed { position:relative; width:100%; aspect-ratio:16 / 9; border-radius:12px; overflow:hidden; background:#000; }
.embed iframe { position:absolute; inset:0; width:100%; height:100%; border:0; }
.stage .media--embed .embed { width:min(100%, 760px); }

.doc-head h1, .essay h2, .essay h3 { text-wrap:balance; overflow-wrap:anywhere; }
.essay p, .essay li, .essay blockquote { text-wrap:pretty; overflow-wrap:anywhere; }

/* HIG translations stay distinct from the author's commentary. */
.hig-note .essay blockquote {
  margin:28px 0 32px;
  padding:24px 28px;
  background:#242424;
  border:1px solid #323232;
  border-left:3px solid #8f8f8f;
  border-radius:0 6px 6px 0;
  color:#ededed;
  line-height:1.9;
}
@media(max-width:600px){
  .hig-note .essay blockquote{padding:20px;margin:24px 0 28px;}
}

/* Identical artwork and timing, with offscreen pause and a still alternative. */
.notion-motion { position:relative; max-width:100%; }
.notion-motion video, .notion-motion .motion-still { display:block; width:auto; max-width:100%; max-height:min(78vh,760px); height:auto; }
.notion-motion .motion-still { display:none; }
.motion-toggle { position:absolute; right:8px; bottom:8px; padding:5px 9px; border:1px solid #555; border-radius:5px; background:#1a1a1ae6; color:#ddd; font:12px/1.4 var(--sans); }
.motion-toggle:focus-visible { outline:2px solid #fff; outline-offset:3px; }
@media(prefers-reduced-motion:reduce) {
  .notion-motion video, .notion-motion .motion-toggle { display:none; }
  .notion-motion .motion-still { display:block; }
}
