/* home.html: the new site by Dan's wireframes (28.10). Light, one cover at a time, project pages as an overlay.
   Loads after style.css (font, lightbox), style-layout.css (Terms media grid) and style-shuttle.css. */

:root {
  --ink: #111111;
  --muted: #737373;          /* labels: 4.7:1 on white */
  --pill-dark: #222222;
  --pill-light: #ececec;
  --pill-light-hover: #e0e0e0;
  --accent: #f5be3c;         /* the "i" */
  --r: 8px;                  /* radius, as style-layout's tiles */
  --edge: 24px;              /* distance of header / bars from the window edge */
  --pill-h: 36px;
  --ease-out: cubic-bezier(.22, 1, .36, 1);
  --ease-in-out: cubic-bezier(.65, 0, .35, 1);
  --ease-icon: cubic-bezier(.2, 0, 0, 1);
  --t-move: 650ms;           /* card flight, deck steps, panel */
  --focus: 0 0 0 2px #fff, 0 0 0 4px var(--ink);
}
@media (max-width: 640px) { :root { --edge: 16px; } }

html { scrollbar-gutter: stable; scroll-padding-block: 80px 96px; }   /* focused links never land under the header or the bar */
html.is-home, html.panel-open { overflow: hidden; overscroll-behavior: none; }
html.is-deeplink .home { visibility: hidden; }
body { background: #fafafa; color: var(--ink); }

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

/* ---------- pills ---------- */
.pill {
  display: inline-flex; align-items: center;
  height: var(--pill-h); padding: 0 12px;
  border-radius: var(--r);
  font-size: var(--fs-body); line-height: 1; white-space: nowrap;
  text-box: trim-both cap alphabetic;   /* optical centring where supported */
}
.pill-dark { background: var(--pill-dark); color: #fff; }
.pill-light { background: var(--pill-light); color: var(--ink); }

/* ---------- header: name + i ---------- */
.top {
  position: fixed; z-index: 60;
  top: calc(var(--edge) + env(safe-area-inset-top, 0px)); left: calc(var(--edge) + env(safe-area-inset-left, 0px));
  display: flex; gap: 4px;
}
.top-name { color: #fff; transition: background-color .15s ease; -webkit-tap-highlight-color: transparent; }
@media (hover: hover) { .top-name:hover { color: #fff; background: #3a3a3a; } }
.top-name:focus-visible { outline: none; box-shadow: var(--focus); }

.info-btn {
  position: relative; display: grid; place-items: center;
  width: var(--pill-h); height: var(--pill-h); padding: 0;
  border: 0; border-radius: var(--r);
  background: var(--accent); color: var(--ink);
  font: inherit; font-size: var(--fs-body); font-feature-settings: var(--font-features);
  cursor: pointer;
  /* home.js moves it (transform) and sets --b, 0 at rest by the name … 1 at the open panel's edge.
     Colour and icon follow --b frame by frame, so they change with the travel; no transitions of their own. */
  --b: 0;
  --from: var(--accent);
  --to: #fff;
  background: color-mix(in oklab, var(--from), var(--to) calc(var(--b) * 100%));
  transition: scale .15s ease-out, box-shadow .3s ease;
  -webkit-tap-highlight-color: transparent;
}
.info-btn.is-inside { --to: var(--pill-light); }   /* phone: the panel is full width, so the button sits on white */
.info-btn > * { grid-area: 1 / 1; }
/* i ⇄ ×: scale .25→1, opacity, blur 4px→0; the i leaves over the first 60% of the way, the × arrives over the last 60% */
.info-i { --q: clamp(0, var(--b) / .6, 1); opacity: calc(1 - var(--q)); scale: calc(1 - .75 * var(--q)); filter: blur(calc(4px * var(--q))); }
.info-x { --q: clamp(0, (var(--b) - .4) / .6, 1); opacity: var(--q); scale: calc(.25 + .75 * var(--q)); filter: blur(calc(4px - 4px * var(--q))); }
@media (hover: hover) {
  .info-btn:hover { --from: #f0b21f; --to: #f4f4f4; }
  .info-btn.is-inside:hover { --to: var(--pill-light-hover); }
}
.info-btn:focus-visible { outline: none; box-shadow: var(--focus); }
.info-btn:active { scale: .96; }

/* ---------- info panel ---------- */
.scrim {
  position: fixed; inset: 0; z-index: 40;
  background: rgba(17, 17, 17, .5);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  opacity: 0; visibility: hidden;   /* home.js sets both from the drawer's progress */
}

.info {
  position: fixed; z-index: 50; top: 0; bottom: 0; left: 0;
  width: clamp(360px, 33.333vw, 560px);
  overflow-y: auto; overscroll-behavior: contain;
  background: #fff;
  padding: calc(var(--edge) + var(--pill-h) + 56px) 48px 48px calc(var(--edge) + 12px); /* text starts on the name's first letter */
  transform: translateX(-100%);
  visibility: hidden;   /* home.js drives transform and visibility, in step with the button */
}
.info:focus { outline: none; }
/* white band under the name pill: the long panel scrolls under it and fades out instead of colliding with it.
   Sits in the panel's top padding (pad = band + 40px), so the start position of the text doesn't move. */
.info::before {
  content: ""; display: block; position: sticky; z-index: 1;
  top: calc(-1 * (var(--edge) + var(--pill-h) + 56px));   /* sticky counts from the padding edge, so pull it back to the panel's top */
  height: calc(var(--edge) + var(--pill-h) + 16px);
  margin: calc(-1 * (var(--edge) + var(--pill-h) + 56px)) -48px 40px calc(-1 * (var(--edge) + 12px));
  background: linear-gradient(#fff 75%, rgb(255 255 255 / 0));
  pointer-events: none;
}
.info-text { max-width: 34em; color: var(--ink); }
.info-text p { text-wrap: wrap; }   /* greedy, fills the measure: typography.css */
.info-text p + p { margin-top: .8em; }
@media (max-width: 640px) {
  .info { width: 100%; padding-right: var(--edge); }
  .info::before { margin-right: calc(-1 * var(--edge)); }
}
/* links in the panel: underline, ↗ when it leaves the site */
.info a.ext { color: var(--ink); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: .2em; transition: color .15s ease; }
.info a.ext span[aria-hidden] { display: inline-block; margin-left: .15em; text-decoration: none; }
@media (hover: hover) { .info a.ext:hover { color: var(--muted); } }
.info a.ext:focus-visible { outline: none; box-shadow: var(--focus); border-radius: 2px; }

/* CV, as in Dan's reference: heading in ink, label in grey on the left, role in body grey, place under it in light grey */
.cv { max-width: 34em; margin-top: 56px; }
.cv h3 { font: inherit; color: var(--ink); margin: 0 0 16px; }
.cv dl { margin: 0; display: grid; grid-template-columns: 8.5em minmax(0, 1fr); column-gap: 16px; row-gap: 16px; }
.cv dt { min-width: 0; color: var(--muted); font-variant-numeric: tabular-nums; }   /* wraps: "Claude Code, Codex" is wider than the 8.5em column and ran into the role (01.11); names stay glued by typeset.py */
.cv dd { margin: 0; min-width: 0; color: var(--text-2); text-wrap: balance; overflow-wrap: anywhere; }   /* short two-line roles: even halves, no lone & at a line end */
.cv dd > span { display: block; color: var(--muted); }
/* phone: the panel is full width and a fixed label column leaves the role ~200px, so the label goes on top */
@media (max-width: 640px) {
  .cv { margin-top: 48px; }
  .cv dl { grid-template-columns: minmax(0, 1fr); row-gap: 0; }
  .cv dd + dt { margin-top: 20px; }
}

/* ---------- home ---------- */
.app { position: relative; }
.home { position: fixed; inset: 0; z-index: 10; touch-action: none; transition: opacity .4s ease; }
.view { position: absolute; inset: 0; }
.view[hidden] { display: none; }
.view-works { transition: opacity .35s ease, visibility 0s linear 0s; }
.home[data-view="other"] .view-works { opacity: 0; visibility: hidden; transition: opacity .35s ease, visibility 0s linear .35s; }
.home[data-view="other"] { touch-action: auto; }   /* the deck's swipe needs none; the Other wall scrolls and pinch-zooms */
.deck { position: absolute; inset: 0; transition: transform var(--t-move) var(--ease-out); }
.deck.no-anim, .deck.no-anim .cover, .cover.no-anim { transition: none !important; }

.cover {
  /* 3:2, ~960 wide, shrinks with the window so header, peek and toggle always fit */
  --w: min(960px, 100vw - 32px, (100svh - 248px) * 1.5);
  --h: calc(var(--w) / 1.5);
  --peek-s: .74;
  --peek-gap: 40px;
  position: absolute; left: 50%; top: 50%;
  width: var(--w); height: var(--h);
  margin: calc(var(--h) / -2) 0 0 calc(var(--w) / -2);
  display: block; overflow: hidden;
  border-radius: var(--r);
  background: #101114;
  color: var(--ink);
  transform-origin: 50% 50%;
  transition: transform var(--t-move) var(--ease-out), opacity var(--t-move) var(--ease-out), filter var(--t-move) var(--ease-out);
  -webkit-tap-highlight-color: transparent;
  outline: none;
}
.cover:hover { color: var(--ink); }
.cover:focus-visible { box-shadow: var(--focus); }
.cover-media, .cover-media > video, .cover-media > img { position: absolute; inset: 0; width: 100%; height: 100%; }
.cover-media > video, .cover-media > img { object-fit: cover; display: block; }
img.fit-contain, .tile > img.fit-contain { object-fit: contain; }
.cover-ttp, .tile-ttp { background: #282828; }   /* the image's own ground, so contain letterboxes invisibly */

.cover .pill { position: absolute; bottom: 8px; transition: opacity .3s ease, background-color .2s ease; }
.cover-name { left: 8px; }
.cover-year { right: 8px; }
@media (hover: hover) { .cover[data-pos="current"]:hover .pill { background: #fff; } }

.cover[data-pos="current"] { transform: none; }
.cover[data-pos="next"] {
  transform: translateY(calc(var(--h) / 2 + var(--peek-gap) + var(--h) * var(--peek-s) / 2)) scale(var(--peek-s));
  filter: blur(14px); opacity: .55; cursor: pointer;
}
.cover[data-pos="after"] {
  transform: translateY(calc(var(--h) + 50svh)) scale(.6);
  filter: blur(14px); opacity: 0; pointer-events: none;
}
.cover[data-pos="before"] {
  transform: translateY(calc(-50svh - var(--h) / 2 - 24px)) scale(.94);
  opacity: 0; pointer-events: none;
  transition: transform var(--t-move) var(--ease-out), opacity .4s ease, filter var(--t-move) var(--ease-out);
}
.cover:not([data-pos="current"]) .pill { opacity: 0; }
/* phone: the cover sits a little above centre, so the peek and the toggle share the lower part */
@media (max-width: 640px) { .cover { top: 44%; --peek-gap: 32px; } }
/* short landscape windows: give the cover more of the height */
@media (max-height: 520px) { .cover { --w: min(960px, 100vw - 32px, (100svh - 150px) * 1.5); --peek-gap: 20px; } }

/* previous / next: for keyboard and screen readers, visible while one of them has focus */
.deck-nav { position: absolute; z-index: 2; right: var(--edge); top: 50%; translate: 0 -50%; display: flex; flex-direction: column; gap: 4px; }
.deck-nav:not(:focus-within) { clip-path: inset(50%); width: 1px; height: 1px; overflow: hidden; }
.deck-btn {
  height: var(--pill-h); padding: 0 12px; border: 0; border-radius: var(--r);
  background: var(--pill-light); color: var(--ink);
  font: inherit; font-size: var(--fs-body); font-feature-settings: var(--font-features); white-space: nowrap; cursor: pointer;
}
.deck-btn:focus-visible { outline: none; box-shadow: var(--focus); }

/* works / other */
.seg {
  position: fixed; z-index: 15; left: 50%;
  bottom: calc(var(--edge) + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  display: grid; grid-template-columns: 1fr 1fr;
  padding: 4px; border-radius: calc(var(--r) + 4px);   /* concentric: inner 8 + padding 4 */
  background: var(--pill-dark);
  transition: opacity .35s ease, transform .5s var(--ease-out);
}
.seg button {
  position: relative; z-index: 1;
  height: 32px; padding: 0 14px;
  border: 0; border-radius: var(--r); background: none;
  color: #fff; font: inherit; font-size: var(--fs-body); font-feature-settings: var(--font-features);
  cursor: pointer; transition: color .15s ease, scale .15s ease-out;
  -webkit-tap-highlight-color: transparent;
}
.seg button:active { scale: .96; }
.seg button[aria-selected="true"] { color: var(--ink); cursor: default; }
.seg button:focus-visible { outline: 2px solid #fff; outline-offset: -2px; }
.seg button[aria-selected="true"]:focus-visible { outline-color: var(--ink); }
.seg-thumb {
  position: absolute; top: 4px; bottom: 4px; left: 4px; width: calc(50% - 4px);
  border-radius: var(--r); background: #fff;
  transition: transform .15s ease-out;   /* a tab switch answers at once */
}
.seg[data-view="other"] .seg-thumb { transform: translateX(100%); }

/* ---------- project overlay ---------- */
.project { position: relative; z-index: 20; }
.project[hidden], .case[hidden] { display: none; }
.case { padding: clamp(104px, 18vh, 176px) 0 calc(var(--edge) * 2 + var(--pill-h) + 48px); }

.pj-head { width: min(720px, 100% - 32px); margin: 0 auto; }
.pj-title {
  margin: 0; color: var(--ink);
  font-size: clamp(1.75rem, 1.2rem + 1.4vw, 2.25rem); font-weight: 400;
  line-height: 1.1; letter-spacing: -0.01em;
  text-wrap: balance;
}
.pj-title:focus { outline: none; }
.pj-intro { margin-top: 32px; max-width: 68ch; color: var(--ink); text-wrap: wrap; }   /* ~68 characters a line; greedy: typography.css */
.pj-facts { margin: 32px 0 0; display: grid; row-gap: 6px; }
.pj-facts > div { display: grid; grid-template-columns: 6.5em minmax(0, 1fr); column-gap: 16px; }
.pj-facts dt { color: var(--muted); }
.pj-facts dd { margin: 0; color: var(--ink); }
.pj-facts a {
  text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px;
  text-decoration-color: #b3b3b3; overflow-wrap: anywhere;
  transition: text-decoration-color .15s ease;
}
@media (hover: hover) { .pj-facts a:hover { text-decoration-color: currentColor; } }
.pj-facts a:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; border-radius: 2px; }
/* ↗ on a link that opens a new tab; inline-block keeps the underline off it */
.ext-arrow { display: inline-block; margin-left: .15em; text-decoration: none; }

.case .col { margin-top: 72px; }
@media (max-width: 640px) {
  .case .col { margin-top: 48px; }
  .pj-facts > div { grid-template-columns: 5.5em minmax(0, 1fr); column-gap: 12px; }
}

/* TTP keeps every image whole (16:9, 4:5, story): natural tiles, and one equal-height row of mixed ratios */
.row-fit { display: flex; gap: var(--t-gap); }
.row-fit > .tile { flex: var(--r) 1 0; min-width: 0; }

/* the slot the cover media lands in */
.tile[data-slot] > video, .tile[data-slot] > img { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.tile[data-slot] > video, .tile[data-slot] > img:not(.fit-contain) { object-fit: cover; }
.slot-wait [data-slot] { visibility: hidden; }

/* open / close: text and the rest of the case fade in around the arriving cover */
.pj-head > * { opacity: 0; transform: translateY(12px); filter: blur(4px); transition: opacity .15s ease-out, transform .15s ease-out, filter .15s ease-out; }
.col > :not([data-slot]) { opacity: 0; transition: opacity .15s ease-out; }
.is-leaving .pj-head > * { transform: translateY(-12px); }   /* enter from below, exit upward */
.is-open .pj-head > * { opacity: 1; transform: none; filter: none; transition: opacity .3s ease-out, transform .3s ease-out, filter .3s ease-out; }
.is-open .pj-head > :nth-child(1) { transition-delay: .15s; }
.is-open .pj-head > :nth-child(2) { transition-delay: .25s; }
.is-open .pj-head > :nth-child(3) { transition-delay: .35s; }
.is-open .col > :not([data-slot]) { opacity: 1; transition: opacity .4s ease-out .4s; }

/* the home steps back while a project is up */
.home-dim .seg { opacity: 0; transform: translateX(-50%) translateY(8px); pointer-events: none; }
.home-dim .cover:not(.is-flying) { opacity: 0; }
.home-dim .cover.is-flying .cover-year { opacity: 0; }
.cover.is-flying .cover-name { opacity: 0; transition: none; }
.home.is-away { visibility: hidden; }

/* ---------- bottom bar: ×, project pill, section pill (variant E of _bar-variants, 29.10) ----------
   One dark capsule (.bar-cap) holds all three, hairlines between them, a chevron on each pill that
   opens a list and the section's number beside its label. The capsule arrives with × and the section
   pill once the cover has landed; until then the project pill flies on its own. The project pill opens the index (a large cover that follows the
   pointer or focus), the section pill opens the map (a line filled as far as you have read).
   Motion: every toggle is a CSS transition, so a reopen mid-exit retargets instead of jumping.
   Menus grow out of their pill (transform-origin on the pill), enter in 260 ms, leave in 150 ms.
   Only transform and opacity move; widths change at once and are FLIP-ed by home.js. */
:root {
  --ease-snap: cubic-bezier(.23, 1, .32, 1);   /* strong ease-out: answers at once, settles long */
  --pill-dark-hover: #383838;
  --on-dark-muted: #a6a6a6;                    /* years on #222: 6.9:1 */
  --cap-at: .47s;                              /* .72 of the 650 ms flight: the pill has all but landed (CAP_AT in home.js) */
  --menu-gap: 8px;
  /* the bar floats over photos and video: a hairline plus a soft drop keeps each pill's edge on any frame */
  --float: 0 0 0 1px rgba(0, 0, 0, .06), 0 2px 6px rgba(0, 0, 0, .10), 0 8px 24px rgba(0, 0, 0, .10);
  --lift: 0 0 0 1px rgba(0, 0, 0, .06), 0 4px 12px rgba(0, 0, 0, .10), 0 20px 48px rgba(0, 0, 0, .18);
  --lift-dark: inset 0 0 0 1px rgba(255, 255, 255, .10), var(--lift);
}

.bar {
  position: fixed; z-index: 25; left: 50%;
  bottom: calc(var(--edge) + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  display: flex; align-items: center;
  max-width: calc(100vw - 32px);
}
/* the capsule: its own layer under the three, so a change of width is FLIP-ed like a pill's fill */
.bar-cap {
  position: absolute; inset: 0; z-index: -1;
  border-radius: var(--r);
  background: var(--pill-dark);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .12), var(--float);   /* the rim keeps its edge on dark frames (TTP's ground is #282828) */
  transform-origin: 0 50%;
  opacity: 0; transition: opacity .15s var(--ease-snap);
}
.bar-close {
  position: relative;
  display: grid; place-items: center; flex: none;
  width: var(--pill-h); height: var(--pill-h); padding: 0;
  border: 3px solid transparent; border-radius: var(--r);   /* the hover fill sits inset, as the pills' */
  background: none; background-clip: padding-box; color: var(--on-dark-muted);
  cursor: pointer;
  opacity: 0; transform: scale(.8);
  transition: opacity .15s var(--ease-snap), transform .15s var(--ease-snap), scale .15s var(--ease-snap), background-color .15s ease-out, border-color .15s ease-out;
  -webkit-tap-highlight-color: transparent;
}
@media (hover: hover) { .bar-close:hover { background: var(--pill-dark-hover); color: #fff; } }
.bar-close:active { scale: .96; }
.bar-close:focus-visible { outline: none; box-shadow: var(--focus); }

/* a pill is a button with its fill on its own layer, so the fill can be stretched with a transform */
.bar-pill {
  position: relative; isolation: isolate; flex: none;
  display: inline-flex; align-items: center; gap: 6px;
  height: var(--pill-h); padding: 0 12px;   /* = .cover-name; the chevron's extra width is FLIP-ed on the flight */
  border: 0; border-radius: var(--r); background: none;
  font: inherit; font-size: var(--fs-body); font-feature-settings: var(--font-features);
  line-height: 1; white-space: nowrap; text-box: trim-both cap alphabetic;
  cursor: pointer;
  transition: scale .15s var(--ease-snap);
  -webkit-tap-highlight-color: transparent;
}
.bar-pill[hidden] { display: none; }
.bar-pill:active { scale: .96; }
.bar-pill:focus-visible { outline: none; }
.bar-pill:focus-visible .bar-bg { box-shadow: var(--focus); }
.bar-bg {
  position: absolute; inset: 0; z-index: -1;
  border-radius: var(--r);
  box-shadow: var(--float);
  transform-origin: 0 50%;
  transition: background-color .15s ease-out;
}
/* the hit area grows to 44 px tall on touch without growing the pill */
.bar-close::after, .bar-pill::after { content: ""; position: absolute; inset: -4px 0; }
/* a hairline on the left of each pill, inside the capsule only */
.bar-pill::before {
  content: ""; position: absolute; left: 0; top: 10px; bottom: 10px; width: 1px;
  background: rgba(255, 255, 255, .16); pointer-events: none;
  opacity: 0; transition: opacity .15s var(--ease-snap);
}
.bar-chev { flex: none; width: 12px; height: 12px; color: var(--on-dark-muted); transition: color .15s ease-out, rotate .26s var(--ease-snap); }

.bar-name { max-width: 50vw; color: #fff; opacity: 0; }
.bar-name .bar-bg { background: var(--pill-dark); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .12), var(--float); }   /* the rim keeps its edge on dark frames (TTP's ground is #282828) */
.bar-label { display: block; flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; padding-block: 2px; }
.is-project .bar-name { opacity: 1; }

.bar-sec { flex: 0 1 auto; min-width: 72px; padding: 0; color: #fff; opacity: 0; transform: scale(.8);
  transition: opacity .15s var(--ease-snap), transform .15s var(--ease-snap), scale .15s var(--ease-snap); }
.bar-sec .bar-bg { background: transparent; box-shadow: none; }
.sec-labels { position: absolute; inset: 0 30px 0 12px; }   /* right: 6 gap + 12 chevron + 12 */
.bar-sec .bar-chev { position: absolute; right: 12px; top: calc(50% - 6px); }
/* landed inside the capsule (slot-wait ends with the flight): the capsule has the colour, the rim and the drop;
   a pill's fill shows only on hover or while its menu is open, inset 3 px so the capsule's rim stays whole */
:where(.is-open:not(.slot-wait)) .bar-pill .bar-bg { padding: 3px; background-clip: content-box; background-color: transparent; box-shadow: none; }
.sec-text {
  position: absolute; left: 0; top: 0; height: 100%;
  display: flex; align-items: center;
  white-space: nowrap; pointer-events: none;
}
.sec-text > span { display: block; min-width: 0; overflow: hidden; text-overflow: ellipsis; padding-block: 2px; }
.sec-text > .sec-num { flex: none; margin-left: 8px; color: var(--on-dark-muted); font-variant-numeric: tabular-nums; }
.sec-measure { position: absolute; font-variant-numeric: tabular-nums; visibility: hidden; white-space: nowrap; font-size: var(--fs-body); font-feature-settings: var(--font-features); pointer-events: none; }

@media (hover: hover) {
  .bar-name:hover .bar-bg { background: var(--pill-dark-hover); }
  .bar-sec:hover .bar-bg { background: var(--pill-dark-hover); }
  .bar-pill:hover .bar-chev { color: #fff; }
}
/* a pill whose menu is open stays pressed-in in colour: the static cue next to the motion */
.bar-name[aria-expanded="true"] .bar-bg { background: var(--pill-dark-hover); }
.bar-sec[aria-expanded="true"] .bar-bg { background: var(--pill-dark-hover); }
.bar-pill[aria-expanded="true"] .bar-chev { color: #fff; rotate: 180deg; }   /* open: it points down, the way the menu goes back */

/* the controls arrive once the cover has landed; on the way home they leave at once */
.is-open .bar-close, .is-open .bar-sec {
  opacity: 1; transform: none;
  transition: opacity .3s var(--ease-snap) var(--cap-at), transform .3s var(--ease-snap) var(--cap-at), scale .15s var(--ease-snap), background-color .15s ease-out, color .15s ease-out;
}
/* the capsule grows out of the landed project pill (home.js), so it is fully there from its first frame */
.is-open .bar-cap { opacity: 1; transition: opacity 0s var(--cap-at); }
.is-open .bar-pill::before { opacity: 1; transition: opacity .3s var(--ease-snap) var(--cap-at); }
.is-leaving .bar-sec, .is-leaving .bar-pill::before { opacity: 0; transition: opacity .12s ease-out; }
.is-leaving .bar-cap { opacity: 0; transition: opacity .15s ease-out; }

/* ---------- menus ----------
   One set of rules for both: one module, the same width for both, centred over the bar (Dan, 29.10),
   in its pill's colour, growing out of its pill; 8 px padding, 56 px rows with an 8 px radius,
   12 px text inset, pictures inset concentrically. One highlighted row at a time: the one under the
   pointer or focus, resting on where you are. Where you are also has its own mark: a tick, a ringed dot. */
:root { --row-h: 56px; --menu-pad: 8px; --menu-w: 780px; }   /* 780: a 3:2 cover of ~474 beside the list (variant C of _index-variants, 29.10) */
.menu {
  position: absolute; z-index: 1;
  left: var(--mx, 0px); bottom: calc(100% + var(--menu-gap));
  width: min(var(--menu-w), calc(100vw - 32px));
  max-height: calc(100dvh - var(--pill-h) - var(--edge) * 2 - var(--menu-gap) - 72px - env(safe-area-inset-bottom, 0px));
  overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin;
  padding: var(--menu-pad);
  border: 1px solid transparent;   /* invisible, but forced-colors mode draws it */
  border-radius: calc(var(--r) + var(--menu-pad) + 1px);   /* concentric: 8 row + 8 padding + 1 border */
  /* grows out of its pill: the origin sits at the pill's centre, below the menu */
  transform-origin: var(--ox, 50%) calc(100% + var(--menu-gap) + var(--pill-h) / 2);
  opacity: 0; visibility: hidden;
  transform: translateY(6px) scale(.96);
  transition: opacity .15s var(--ease-snap), transform .15s var(--ease-snap), visibility 0s linear .15s;
}
.menu.is-open {
  opacity: 1; visibility: visible; transform: none;
  transition: opacity .18s var(--ease-snap), transform .26s var(--ease-snap), visibility 0s;
}
.menu:focus { outline: none; }   /* focusable only so a click on its padding keeps focus inside */
.menu ul, .menu ol { margin: 0; padding: 0; list-style: none; }
.menu a { color: inherit; text-decoration: none; }

/* rows: a short rise, 30 ms apart, only on the way in; on the way out the menu fades as one */
.menu li { opacity: 0; transform: translateY(6px); transition: opacity 0s .15s, transform 0s .15s; }
.menu.is-open li {
  opacity: 1; transform: none;
  transition: opacity .2s var(--ease-snap) calc(40ms + var(--i, 0) * 30ms), transform .26s var(--ease-snap) calc(40ms + var(--i, 0) * 30ms);
}
.menu.is-quiet li, .menu.is-quiet.is-open li { transition: none; }   /* opened from the keyboard: no stagger */

.menu .row {   /* scoped: .row is also the layout row (style-layout.css) */
  position: relative;
  display: grid; align-items: center; column-gap: 12px;
  min-height: var(--row-h); padding: 4px 12px;
  border-radius: var(--r);
  background: transparent;
  line-height: 1.3;
  transition: background-color .12s ease-out;
  -webkit-tap-highlight-color: transparent;
}
.menu .row:focus-visible { outline: none; }
.row-title { min-width: 0; text-wrap: pretty; }
.row-year { font-variant-numeric: tabular-nums; white-space: nowrap; }
.row-tick { width: 16px; height: 16px; }
.menu .row:not([aria-current]) .row-tick { visibility: hidden; }

/* index: dark, the cover on the left follows the pointer or focus. On a phone it sits above the list
   at 3:2; wider, it keeps 3:2 beside the list, and the list is exactly as tall as the cover and
   scrolls on its own, its lower edge fading while more rows wait below (.has-more, home.js). */
.menu-index { background: var(--pill-dark); color: #fff; box-shadow: var(--lift-dark); }
.index-grid { display: grid; grid-template-columns: minmax(0, 1fr) max-content; gap: var(--menu-pad); }
.index-cover {   /* fills what the list leaves: as tall as the list, the rest of the module wide */
  position: relative; display: block; align-self: stretch; overflow: hidden;
  border-radius: var(--r); background: #101114; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.index-list { display: grid; grid-auto-rows: minmax(var(--row-h), 1fr); }
.index-list > li { display: grid; }
.index-cover img {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block;
  outline: 1px solid rgba(255, 255, 255, .1); outline-offset: -1px;
  opacity: 0; transform: scale(1.04);
  transition: opacity .15s ease-out, transform .3s var(--ease-snap);
}
.index-cover img.is-contain { object-fit: contain; background: #282828; }
.index-cover img.is-on { z-index: 1; opacity: 1; transform: none; transition: opacity .22s var(--ease-snap), transform .45s var(--ease-snap); }
.index-cover.is-instant img { transition: none; }   /* arrow keys: the cover swaps at once */
.index-list { touch-action: none; }   /* touch: press previews, sliding along the list scrubs the covers */
@media (min-width: 641px) and (min-height: 561px) {
  .menu-index { --cover-w: min(474px, (min(var(--menu-w), 100vw - 32px) - 2px - var(--menu-pad) * 3) * .6); }
  .index-grid { grid-template-columns: var(--cover-w) minmax(0, 1fr); }
  .index-cover { align-self: start; width: var(--cover-w); aspect-ratio: 3 / 2; }
  .index-list { height: calc(var(--cover-w) / 1.5); overflow-y: auto; overscroll-behavior: contain; scrollbar-width: none;
    grid-auto-rows: minmax(calc(100% / 5.5), 1fr); }   /* up to 5 fill the height; with more, the 6th shows half */
  .index-list::-webkit-scrollbar { display: none; }
  .index-list.has-more { mask-image: linear-gradient(#000 calc(100% - 64px), rgba(0, 0, 0, .25)); }   /* the next row still shows through */
}
.menu-index .row { grid-template-columns: minmax(0, 1fr) auto 16px; }
.menu-index .row-year { color: var(--on-dark-muted); }
/* the highlighted row is the one the cover shows (hover, focus or a finger), never two at once */
.menu-index .row.is-preview { background: var(--pill-dark-hover); }
.menu-index .row:focus-visible { box-shadow: inset 0 0 0 2px #fff; }

/* map: dark as the capsule (29.10, was grey); a spine with a dot per section, the line filled as far as you have read.
   Text only (29.10, evening; thumbnails dropped): number, chapter, and its conclusion in muted, all three columns
   shared by every row (subgrid), so the conclusions start on one line. On a phone the conclusion goes under the name. */
.menu-map { background: var(--pill-dark); color: #fff; box-shadow: var(--lift-dark); --dot-y: calc(var(--row-h) / 2); }
.map-list { display: grid; grid-template-columns: auto max-content minmax(0, 1fr); }
.map-list > li { grid-column: 1 / -1; display: grid; grid-template-columns: subgrid; }
.menu-map .row { grid-column: 1 / -1; grid-template-columns: subgrid; padding-inline: 40px 12px; }   /* 40 = 12 + spine 16 + 12 */
.menu-map .row.is-preview { background: var(--pill-dark-hover); }
.menu-map .row:focus-visible { box-shadow: inset 0 0 0 2px #fff; }
.row-num { color: var(--on-dark-muted); font-variant-numeric: tabular-nums; }
.row-sub { min-width: 0; margin-left: 12px; color: var(--on-dark-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }   /* 24 from the longest name */
@media (max-width: 640px) {
  .menu-map { --dot-y: 22px; }   /* the middle of the name's line: 12 px padding + half of 19.5 */
  .map-list, .map-list > li { display: block; }
  .menu-map .row { grid-template-columns: auto minmax(0, 1fr); align-items: start; row-gap: 2px; min-height: 44px; padding-block: 12px; }
  .row-sub {
    grid-column: 2; margin-left: 0; white-space: normal; font-size: var(--fs-small); line-height: 1.35;
    display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2;
  }
}

/* the spine spans the whole row, so rows of any height join up: dot at --dot-y, the line on to the next dot */
.spine { position: absolute; top: 0; bottom: 0; left: 12px; width: 16px; }
.spine::before, .spine-fill {   /* track and fill run from the bottom of this dot to the top of the next */
  content: ""; position: absolute; left: 7px; width: 2px; top: calc(var(--dot-y) + 5px); height: calc(100% - 18px); border-radius: 1px;
}
.spine::before { background: #4d4d4d; }   /* the track, quiet on #222 */
.spine-fill {
  display: block; background: #fff;
  transform-origin: 50% 0; transform: scaleY(0);
  transition: transform 0s .15s;   /* reset after the menu has gone */
}
li:last-child .spine::before, li:last-child .spine-fill { display: none; }
/* opening draws the line down to where you are, a dot at a time */
.menu-map.is-open .spine-fill {
  transform: scaleY(var(--fill, 0));
  transition: transform .32s var(--ease-snap) calc(80ms + var(--i, 0) * 45ms);
}
/* once drawn, it follows the scroll directly */
.menu-map.is-open.is-drawn .spine-fill { transition: transform .2s ease-out; }
.dot {
  position: absolute; z-index: 1; left: 3px; top: var(--dot-y); margin-top: -5px;
  width: 10px; height: 10px; border-radius: 50%;
  box-shadow: inset 0 0 0 2px #8c8c8c;   /* unread: on #222, 4.9:1 */
}
.dot::after {
  content: ""; position: absolute; inset: 0; border-radius: 50%;
  background: #fff;
  transform: scale(0); transition: transform 0s .15s;
}
.is-read .dot::after { transform: scale(1); }
.is-here .dot { box-shadow: inset 0 0 0 3px #fff; }   /* where you are: a ring, and the line ends here */
.menu-map.is-open .dot::after { transition: transform .2s var(--ease-snap) calc(80ms + var(--i, 0) * 45ms); }
.menu-map.is-open.is-drawn .dot::after { transition: transform .15s ease-out; }

/* phone: the project pill drops its chevron, so the name fits beside the chapter and its number */
@media (max-width: 640px) { .bar-name .bar-chev { display: none; } }

/* phone: the cover goes above the list at 3:2 */
@media (max-width: 640px) {
  .index-grid { grid-template-columns: minmax(0, 1fr); }
  .index-cover { align-self: start; aspect-ratio: 3 / 2; }
}
/* short windows: the list matters more than the picture */
@media (max-height: 560px) { .index-grid { grid-template-columns: minmax(0, 1fr); } .index-cover { display: none; } }

/* a project switch: the old case fades out, the new one runs its entrance again, a little quicker */
.case.is-prep .pj-head > *, .case.is-prep .col > * { opacity: 0 !important; transition: none !important; }
.case.is-swap .pj-head > :nth-child(1) { transition-delay: .04s; }
.case.is-swap .pj-head > :nth-child(2) { transition-delay: .1s; }
.case.is-swap .pj-head > :nth-child(3) { transition-delay: .16s; }
.case.is-swap .col > [data-slot] { transition: opacity .3s var(--ease-snap) .12s; }
.case.is-swap .col > :not([data-slot]) { transition: opacity .35s ease-out .2s; }
.case h2[tabindex="-1"]:focus { outline: none; }   /* a heading reached from the map */

/* Windows high contrast drops box-shadow rings: draw a system-colour outline instead */
@media (forced-colors: active) {
  :focus-visible { outline: 2px solid CanvasText !important; outline-offset: 2px; }
  .menu .row[aria-current] { outline: 2px solid Highlight; outline-offset: -2px; }
  .spine-fill, .dot::after { background: CanvasText; }
  .bar-bg { border: 1px solid ButtonText; }
  .bar-cap { border: 1px solid ButtonText; }
}

/* lightbox above everything of ours */
.lb { z-index: 100; }

/* ---------- reduced motion: crossfades, nothing travels ---------- */
@media (prefers-reduced-motion: reduce) {
  .deck, .cover, .seg-thumb { transition-property: opacity, visibility, background-color, color !important; transition-duration: .2s !important; }
  .info-btn { transition: none; }   /* home.js cross-fades it */
  .info-x, .info-i { scale: 1; filter: none; }
  .cover[data-pos="next"] { transition: none !important; }
  .info { transform: none; }
  .pj-head > *, .is-open .pj-head > *, .is-leaving .pj-head > * { transform: none; filter: none; transition-delay: 0s !important; }
  .is-open .col > :not([data-slot]) { transition-delay: 0s; }
  /* bar and menus: nothing scales, rises or draws; menus and covers cross-fade */
  .menu, .menu.is-open, .menu li, .menu.is-open li, .index-cover img, .index-cover img.is-on { transform: none; }
  .menu li, .menu.is-open li { opacity: 1; transition: none; }
  .bar-sec, .bar-close { transform: none !important; }
  .bar-pill:active, .bar-close:active { scale: 1; }
  .spine-fill, .menu-map.is-open .spine-fill, .dot::after, .menu-map.is-open .dot::after { transition: none !important; }
  .case.is-swap .pj-head > * { transition-delay: 0s !important; }
}

/* ---------- page tone + image edge (28.10) ---------- */
/* the page sits 2% under white, and every picture gets a hairline inner edge,
   so white artwork does not melt into the page */
html { background: #fafafa; }
.tile img, .tile video, .cover img, .cover video {
  outline: 1px solid rgba(0, 0, 0, .06); outline-offset: -1px;
}

/* ---------- a case under a password (31.10, the Real-estate CRM; home.js "a case under a password") ----------
   The card carries a quiet tag in its top-left corner, the light pill a size down, grey type. It goes with the other pills:
   gone off the current card, faded during the flight. The case shows its head and cover; under them, until the chapters
   come in, the password form, centred under the cover (below). */
.cover .cover-tag {
  top: 8px; left: 8px; bottom: auto;
  height: 28px; padding: 0 10px;
  font-size: var(--fs-small);
  color: #555;   /* 6.4:1 on #ececec */
}
.home-dim .cover.is-flying .cover-tag { opacity: 0; }

/* The form (31.10). Centred in the column: the line, then the field, then the message, whose line is kept so an error
   moves nothing. data-look="a" on the form is the hook for the capsule rules below. Motion is home.js ("the form's
   motion"): CSS here holds only the states and the quick colour changes, 150 ms on --ease-snap like the bar.
   The capsule: one dark capsule like the bottom bar: Password | field | Open, hairlines between, Open a light pill
   inset 3 px. It opens from its middle, shakes on a wrong password, folds into Open (a check) on the right one. */
.case .col > .case-lock {
  justify-self: center; width: min(560px, 100%); min-width: 0; margin-block: var(--text-pause);
  display: flex; flex-direction: column; align-items: center;
  text-align: center;
}
.case-lock[hidden] { display: none; }
.case .col > .case-lock.is-waiting { opacity: 0; }   /* shown, not yet seen: home.js brings it in once it is in view */
/* the line over the field: edit its words in home.html, or delete the <p> (and aria-labelledby on the form) to drop it */
.case-lock-t { max-width: 52ch; margin: 0 0 24px; color: var(--ink); text-wrap: balance; }
.case-lock-t a {
  color: var(--ink);
  text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px;
  text-decoration-color: #b3b3b3; overflow-wrap: anywhere;
  transition: text-decoration-color .15s ease;
}
@media (hover: hover) { .case-lock-t a:hover { text-decoration-color: currentColor; } }
.case-lock-t a:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; border-radius: 2px; }

.case-lock-field { position: relative; isolation: isolate; width: min(440px, 100%); text-align: start; }
.case-lock-label { flex: none; white-space: nowrap; transition: color .15s var(--ease-snap); }
.case-lock-input {
  flex: 1 1 0; width: 0; min-width: 0; margin: 0; padding: 0 12px;   /* width 0: its 20-character default never widens the column */
  border: 0; border-radius: 0; outline: none; background: none; box-shadow: none;
  font: inherit; font-size: var(--fs-body); font-feature-settings: var(--font-features);
  -webkit-appearance: none; appearance: none;
}
@media (pointer: coarse) { .case-lock-input { font-size: 16px; } }   /* iOS zooms into a field set under 16px */
.case-lock-btn {
  position: relative; flex: none;
  display: grid; place-items: center;
  margin: 0; padding: 0 14px;
  border: 0; border-radius: var(--r);
  font: inherit; font-size: var(--fs-body); font-feature-settings: var(--font-features);
  line-height: 1; white-space: nowrap;
  cursor: pointer; -webkit-tap-highlight-color: transparent;
  transition: background-color .15s var(--ease-snap), color .15s var(--ease-snap), scale .15s var(--ease-snap);
}
.case-lock-btn:active { scale: .96; }
.case-lock-btn > * { grid-area: 1 / 1; }   /* "Open" and the check share one cell, so the swap moves nothing */
.case-lock-go { text-box: trim-both cap alphabetic; }
.case-lock-ok { width: 14px; height: 14px; opacity: 0; scale: .25; filter: blur(4px); }
.case-lock.is-in .case-lock-go { opacity: 0; scale: .25; filter: blur(4px); }
.case-lock.is-in .case-lock-ok { opacity: 1; scale: 1; filter: none; }
.case-lock-go, .case-lock-ok { transition: opacity .2s var(--ease-snap), scale .2s var(--ease-snap), filter .2s var(--ease-snap); }
.case-lock[aria-busy="true"] .case-lock-btn { cursor: progress; }
.case-lock[aria-busy="true"] .case-lock-go { opacity: .5; }
.case-lock-msg {
  min-height: 1.5em; margin: 8px 0 0;
  color: #b3261e;   /* 6.4:1 on the page */
  font-size: var(--fs-small); line-height: 1.5; text-wrap: balance;
}

[data-look="a"] .case-lock-field {
  display: flex; align-items: center; height: var(--pill-h);
  border-radius: var(--r); background: var(--pill-dark); color: #fff;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .12), var(--float);
  transition: box-shadow .15s var(--ease-snap);
}
[data-look="a"] .case-lock-label { align-self: stretch; display: flex; align-items: center; padding: 0 12px; color: var(--on-dark-muted); }
[data-look="a"] .case-lock-input { align-self: stretch; color: #fff; caret-color: #fff; }
[data-look="a"] .case-lock-label { position: relative; }
[data-look="a"] .case-lock-label::after {   /* the bar's hairline */
  content: ""; position: absolute; right: 0; top: 10px; bottom: 10px; width: 1px;
  background: rgba(255, 255, 255, .16); pointer-events: none;
}
[data-look="a"] .case-lock-btn { align-self: stretch; padding: 0 14px; margin-left: 4px; border: 3px solid transparent; border-radius: var(--r); background: var(--pill-light); background-clip: padding-box; color: var(--ink); }
@media (hover: hover) { [data-look="a"] .case-lock-btn:hover { background-color: #fff; } }
[data-look="a"] .case-lock-btn:focus-visible { outline: 2px solid #fff; outline-offset: -1px; }
[data-look="a"] .case-lock-field:has(.case-lock-input:focus) { box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .12), var(--float), var(--focus); }
[data-look="a"] .case-lock-field:has(.case-lock-input:focus) .case-lock-label { color: #fff; }
[data-look="a"] .case-lock-field:has([aria-invalid="true"]) { box-shadow: inset 0 0 0 1px #ff6b5e, var(--float); }   /* 5.6:1 on #222 */
[data-look="a"] .case-lock-field:has([aria-invalid="true"]:focus) { box-shadow: inset 0 0 0 1px #ff6b5e, var(--float), var(--focus); }
[data-look="a"].is-in .case-lock-field, [data-look="a"].is-in .case-lock-field:has(.case-lock-input:focus) { box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .12), var(--float); }   /* done: no ring on the way out */
[data-look="a"] .case-lock-input:-webkit-autofill { -webkit-box-shadow: inset 0 0 0 40px var(--pill-dark); -webkit-text-fill-color: #fff; }

@media (prefers-reduced-motion: reduce) {
  .case-lock-go, .case-lock-ok, .case-lock.is-in .case-lock-go, .case-lock.is-in .case-lock-ok { scale: 1; filter: none; }
  .case-lock-btn:active { scale: 1; }
}

/* A real control when autoplay is refused, a clip stalls, or reduced motion is on. */
.tile > .video-retry {
  position: absolute; z-index: 2; left: 50%; top: 50%; transform: translate(-50%, -50%);
  min-height: 44px; padding: 10px 18px; border: 1px solid rgba(255,255,255,.25);
  border-radius: 999px; background: #222; color: #fff;
  font: inherit; font-size: 14px; line-height: 1.4; cursor: pointer;
  box-shadow: 0 2px 12px rgba(0,0,0,.15);
}
.tile > .video-retry[hidden] { display: none; }
.tile > .video-retry:focus-visible { outline: 3px solid #f8c335; outline-offset: 3px; }
