:root {
  --bg: #f3f2ef; --text: #161616; --muted: #85827b; --home-text: #fff;
  --load: #e4e2dd; --dim-bg: rgba(12,12,12,.9); --lb-text: #d9d7d2;
  --font: -apple-system, BlinkMacSystemFont, "Helvetica Neue", Helvetica, Arial, sans-serif;
  --size: 15px; --gap: 18px; --side: 220px;
}
* { box-sizing: border-box; }
html { scrollbar-gutter: stable; -webkit-text-size-adjust: 100%; }
html.lb-open { overflow: hidden; }
/* no double-tap zoom on phones (pinch zoom still works); touch-action applies through every descendant */
html, body, #lb { touch-action: manipulation; }
body { margin: 0; background: var(--bg); color: var(--text); font: var(--size)/1.5 var(--font); -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: none; }

/* ──── side: name + menu ──── */
/* --side = the left margin (window edge → first column); --menu-l centres the widest line in it;
   --menu-t = its own top, apart from the images' */
.side { position: fixed; top: 0; left: 0; width: var(--side); padding: var(--menu-t, var(--margin, 36px)) 0 0 var(--menu-l, 36px); white-space: nowrap; z-index: 2; }
.name { margin: 0; font-size: var(--name-size, 1.2em); font-weight: var(--name-weight, 500); letter-spacing: .01em; line-height: 1.3; }
.nav { list-style: none; margin: var(--nav-t, 30px) 0 0; padding: 0; }   /* --nav-t = theme.navTop (name → menu) */
.nav a { display: inline-block; padding: 2px 0; }
.nav a[aria-current=page] { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; }
/* --margin = top + bottom (menu top, page top and bottom); --margin-r = the right edge */
main { margin-left: var(--side); padding: var(--margin, 36px) var(--margin-r, var(--margin, 36px)) var(--margin, 36px) 0; }

/* ──── pictures: frame shows the cropped part ──── */
.pic { position: relative; overflow: hidden; background: var(--load); }
.pic img { position: absolute; display: block; max-width: none; height: auto; }
.grey img, img.grey, .grey .vid { filter: grayscale(1); }
/* video player (site.js player): a box placed like the <img>, its two passes stacked for the loop crossfade */
.pic .vid, #lb .lb-frame .vid { position: absolute; display: block; }
.vid video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.vid video::-webkit-media-controls { display: none !important; }

/* ──── home ──── */
.page-home .side { color: var(--home-text); }
.hero { position: fixed; inset: 0; width: 100%; height: 100vh; height: 100dvh; object-fit: cover; display: block; }
.hero-ph { background: linear-gradient(160deg, #50555a, #232629); }

/* ──── work ──── */
.grid { display: flex; gap: var(--gap); align-items: flex-start; }
.col { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.item { margin: 0; }
.item .pic { cursor: pointer; }
/* Caption text (capital tops to baseline, line-box padding trimmed) sits dead centre
   between its image and the next one: the same gap above and below (--vgap-below adds
   to the gap under it only). Unset = the original 7px margin + trimmed padding (.43em). */
.item figcaption { --cap-gap: var(--vgap, calc(7px + .43em)); font-size: .87em; color: var(--muted); margin: var(--cap-gap) 0 calc(var(--cap-gap) + var(--vgap-below, 0px)); text-box: trim-both cap alphabetic; white-space: pre-line; text-align: var(--cap-align, left); }
.item figcaption:empty { display: none; }
.item:has(> figcaption:empty) { margin-bottom: calc(var(--vgap, var(--gap)) + var(--vgap-below, 0px)); }

/* ──── about / contact ──── */
.text { max-width: 34em; white-space: pre-line; font-size: 1.05em; line-height: var(--line, normal); }
.text.wide { width: var(--text-w); max-width: calc(100% + var(--margin-r, 36px) - 24px); }
.seg { width: fit-content; max-width: 100%; }
.rule { height: 1px; background: currentColor; margin: var(--rule-gap, 1.1em) 0; max-width: 100%; }
.about-img { width: min(100%, 520px); max-width: 100%; margin-bottom: var(--about-gap, 28px); }
.text a { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; }


/* ──── lightbox ──── */
#lb { position: fixed; inset: 0; z-index: 10; display: flex; align-items: center; justify-content: center; background: var(--dim-bg); }
#lb[hidden] { display: none; }
/* Lightbox caption hangs below the image (in the margin), so the image stays centred. */
#lb .lb-box { position: relative; }
#lb .lb-cap { position: absolute; top: 100%; left: 0; right: 0; padding-top: 12px; font-size: .87em; color: var(--lb-cap); white-space: pre-line; text-align: var(--cap-align, left); }
#lb .lb-cap[hidden] { display: none; }
/* Captions off on the page: hidden in the grid, the gap where they were = the plain image gap. */
.no-caps .item figcaption { display: none; }
.no-caps .item { margin-bottom: calc(var(--vgap, var(--gap)) + var(--vgap-below, 0px)); }
#lb .lb-frame { position: relative; overflow: hidden; box-shadow: var(--lb-shadow); }
#lb .lb-frame img { position: absolute; display: block; max-width: none; height: auto; }

.edit-enter { position: fixed; right: 12px; bottom: 12px; z-index: 30; display: flex; gap: 6px; }
.edit-enter button { font: 12px system-ui, sans-serif; padding: 4px 10px; border: 1px solid rgba(128,128,128,.4); background: rgba(255,255,255,.7); color: #333; border-radius: 4px; cursor: pointer; }

/* ──── phone layout: html.narrow (window ≤ 700 px, or edit mode's Mobile preview); site.js sets it ────
   --m-edge = screen edge → images and image → image (one value); the rest are theme.mobile */
.narrow .side { position: static; width: auto; padding: var(--m-top) var(--m-edge) 0; white-space: normal; }
.narrow .page-home .side { position: fixed; }
.narrow .nav { display: flex; flex-wrap: wrap; gap: var(--m-nav-row) var(--m-nav-gap); margin-top: var(--m-edge); }
.narrow main { margin-left: 0; padding: calc(var(--m-edge) + 4px) var(--m-edge) var(--m-edge); }   /* +4 = the menu underline (3px offset + 1px line): the gap starts under it */
.narrow main:has(> .grid) { padding-bottom: 0; }   /* the last image's own gap is the bottom margin */
.narrow .grid { gap: var(--m-edge); --vgap: var(--m-edge); --vgap-below: 0px; }
.narrow .text.wide { max-width: 100%; }
/* name + menu text trimmed to its letters (capital tops → baseline), so name → menu → first image
   measure the same as image → image (--m-edge) */
.narrow .name, .narrow .nav a { text-box: trim-both cap alphabetic; }
.narrow .nav a { display: block; padding: 0; }   /* block: no line box (and its strut) around it */
.narrow .item .pic { cursor: default; }   /* no lightbox on phones */
/* the current page's underline drawn as a box (not text-decoration, whose drop the browser picks), so
   it sits exactly 3px under the baseline, 1px thick — and main's +4px puts the images one gap under it */
.narrow .nav a[aria-current=page] { position: relative; text-decoration: none; }
.narrow .nav a[aria-current=page]::after { content: ''; position: absolute; left: 0; right: 0; top: calc(100% + 3px); height: 1px; background: currentColor; }
/* Menu beside the name (theme.mobile.beside): both trimmed to their baselines, bottoms aligned, the menu
   raised 4px (the underline's 3px drop + 1px line) so the underline's bottom = the name's baseline.
   That line is then the header's bottom, so main drops its +4. */
.narrow.m-beside .side { display: flex; align-items: flex-end; gap: var(--m-beside-gap); }
.narrow.m-beside .name { flex: none; }
.narrow.m-beside .side > nav { flex: 1 1 auto; min-width: 0; }
.narrow.m-beside .nav { margin: 0 0 4px; }
.narrow.m-beside main { padding-top: var(--m-edge); }
/* …or (theme.mobile.besideText) the menu words' bottoms on the name's baseline, the underline hanging
   4px below it; the gap (--m-edge) runs from that baseline, not the underline */
.narrow.m-beside.m-beside-text .nav { margin-bottom: 0; }
/* Menu to the right (theme.mobile.right): its last item ends on the images' right edge (--m-edge in) */
.narrow.m-right .nav { justify-content: flex-end; }
.narrow.m-right .page-home .side { right: 0; }
