/* styles.css — the one stylesheet.
 *
 * Tokens first, three-state theme (system / light / dark), then layout, then
 * components in the order the generator emits them. No framework, no reset
 * beyond what is needed. Every class here is emitted by tools/lib/*.mjs and
 * tests/dist.test.mjs checks the two sets match — a class with no rule and a
 * rule with no element are both failures.
 */

/* ---------------------------------------------------------------- tokens */
:root {
  color-scheme: light;
  --bg: #FFFFFF;
  --ink: #161616;
  --ink-2: #66665F;
  --line: #E8E8E3;
  --lift: #F4F4F1;
  --focus: #2F6BE0;
  /* Helvetica Neue, decided 2026-09-04 after seeing Manrope live: the system face, no webfont.
     Macs and iPhones ship it in six weights; elsewhere Helvetica, then Arial (400 and 700 only —
     the 500s below fall back to 400 there and the hierarchy still holds through size and colour). */
  --font: 'Helvetica Neue', Helvetica, Arial, sans-serif;
  --side: 200px;
  --gutter: 40px;
  --content: 1600px;                             /* the column: images use it, text stops at --measure */
  --measure: 60ch;
  /* the scale: one bold voice (h1, h2), medium for names and labels, regular for everything read */
  --t-label: 12px;                               /* uppercase labels: nav sections, cover section */
  --t-small: 14px;                               /* meta: subtitle, captions, cover years, footer */
  --t-nav: 15px;
  --t-meta: 15px;                                /* the years under a project title */
  --t-body: 17px;
  --t-brand: 18px;
  --t-lead: clamp(19px, 1.1vw + 12px, 22px);
  --t-h2: 22px;
  --t-h1: clamp(32px, 2.6vw + 14px, 46px);
  --w-medium: 500;
  --w-bold: 700;
  --track-caps: 0.09em;                          /* small capitals need air */
  --track-tight: -0.02em;                        /* big Helvetica needs less */
  --gap-block: 40px;
  --gap-section: 96px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #101012; --ink: #ECECE8; --ink-2: #9C9C96; --line: #262629; --lift: #18181B; --focus: #7FB0FF;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #101012; --ink: #ECECE8; --ink-2: #9C9C96; --line: #262629; --lift: #18181B; --focus: #7FB0FF;
}
/* phones: 24 px gutters give reading text a 327 px line on a 375 px screen instead of 295 px.
   The image sizes hints in tools/lib/images.mjs assume the same 48 px below 600 px. */
@media (max-width: 599.98px) { :root { --gutter: 24px; } }
/* wide screens: more air around the pictures (the old site used the whole window; 2026-09-04) */
@media (min-width: 1400px) { :root { --gutter: 56px; } }

/* ---------------------------------------------------------------- base */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } *, *::before, *::after { transition: none !important; } }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 var(--t-body) / 1.55 var(--font);
  -webkit-font-smoothing: antialiased;
  font-kerning: normal;
}
img, video { display: block; max-width: 100%; height: auto; }
a { color: inherit; text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 0.18em; text-decoration-color: var(--ink-2); }
a:hover { text-decoration-color: currentColor; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; border-radius: 2px; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
h1, h2 { font-weight: var(--w-bold); margin: 0; text-wrap: balance; }
p { margin: 0; text-wrap: pretty; }

/* ---------------------------------------------------------------- layout: sidebar + column */
.skip { position: absolute; left: 12px; top: -100px; padding: 8px 12px; background: var(--ink); color: var(--bg); border-radius: 4px; z-index: 10; }
.skip:focus { top: 12px; }

body { display: flex; flex-direction: column; min-height: 100vh; }
.side { padding: 24px var(--gutter) 0; }
.main-col { flex: 1; padding: 24px var(--gutter) var(--gutter); max-width: calc(var(--content) + 2 * var(--gutter)); width: 100%; }

@media (min-width: 900px) {
  body { flex-direction: row; align-items: flex-start; }
  .side { position: sticky; top: 0; flex: 0 0 calc(var(--side) + var(--gutter)); max-height: 100vh; overflow-y: auto; padding: var(--gutter) 0 var(--gutter) var(--gutter); }
  .main-col { padding: var(--gutter); }
}

/* ---------------------------------------------------------------- header + controls */
.site { display: grid; grid-template-columns: 1fr auto auto; grid-template-areas: "brand theme menu" "sub theme menu"; column-gap: 8px; align-items: center; }
.brand { grid-area: brand; font-size: var(--t-brand); font-weight: var(--w-medium); line-height: 1.2; letter-spacing: -0.01em; }
.brand a { text-decoration: none; }
.subtitle { grid-area: sub; color: var(--ink-2); font-size: var(--t-small); }
.theme, .menu { width: 40px; height: 40px; display: inline-grid; place-items: center; border-radius: 999px; color: var(--ink-2); }
.theme { grid-area: theme; }
.menu { grid-area: menu; }
.theme:hover, .menu:hover { color: var(--ink); background: var(--lift); }
.theme svg, .menu svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.theme .sun { display: none; }
:root[data-theme="dark"] .theme .moon { display: none; }
:root[data-theme="dark"] .theme .sun { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme .moon { display: none; }
  :root:not([data-theme="light"]) .theme .sun { display: block; }
}
@media (min-width: 900px) {
  .site { grid-template-columns: 1fr auto; grid-template-areas: "brand theme" "sub theme"; }
  .menu { display: none; }
}

/* ---------------------------------------------------------------- nav */
nav { font-size: var(--t-nav); line-height: 1.5; margin-top: 28px; }
nav ul { list-style: none; margin: 0; padding: 0; }
nav > ul { display: grid; gap: 22px; }
nav a { text-decoration: none; }
nav a:hover, nav a[aria-current="page"] { text-decoration: underline; text-underline-offset: 0.2em; }
nav > ul > li > a, .page-link a { font-size: var(--t-label); font-weight: var(--w-medium); letter-spacing: var(--track-caps); text-transform: uppercase; color: var(--ink-2); }
nav > ul > li > a[aria-current="page"], .page-link a[aria-current="page"], nav > ul > li > a:hover, .page-link a:hover { color: var(--ink); }
nav ul ul { margin-top: 6px; display: grid; gap: 3px; }
nav ul ul a { color: var(--ink); }
nav ul ul a[aria-current="page"] { font-weight: var(--w-medium); }
.demo a { color: var(--ink-2); }
@media (max-width: 899.98px) {
  nav { display: none; padding-bottom: 8px; border-bottom: 1px solid var(--line); }
  .side[data-open] nav { display: block; }
}
@media (min-width: 900px) { nav > ul { gap: 28px; } }

/* ---------------------------------------------------------------- start page: the statement */
.intro { display: grid; gap: 16px; margin: 6px 0 56px; }
.statement { font-size: var(--t-h1); line-height: 1.08; font-weight: var(--w-bold); letter-spacing: var(--track-tight); max-width: 20ch; text-wrap: balance; }
.statement-sub { font-size: var(--t-lead); line-height: 1.4; max-width: var(--measure); }   /* three lines at most: no hyphenation, pretty wrap */
.statement-link { font-size: var(--t-nav); font-weight: var(--w-medium); margin-top: 2px; }

/* ---------------------------------------------------------------- index pages: cover tiles */
/* one column on phones, two from 640, three once the column is about 1000 px wide (1340) —
   the tiles then grow with the window up to the 1600 px column: 313 px at 1340, 507 px at 1968 */
.covers { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: 1fr; gap: 40px 28px; }
@media (min-width: 640px) { .covers { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1340px) { .covers { grid-template-columns: repeat(3, 1fr); gap: 48px 40px; } }
h1 + .covers { margin-top: 32px; }
.cover a { display: block; text-decoration: none; }
.cover figure { margin: 0; }
.cover-pic { position: relative; }                 /* the hover image's containing block */
.cover-img { width: 100%; aspect-ratio: 1.28; object-fit: cover; border-radius: 3px; background: var(--lift); }
.cover-img.hover { position: absolute; inset: 0; opacity: 0; transition: opacity 0.25s ease; pointer-events: none; }
.cover a:hover .cover-img.hover, .cover a:focus-visible .cover-img.hover { opacity: 1; }
.cover figcaption { margin-top: 12px; display: grid; gap: 2px; }
.cover .title { font-size: var(--t-body); font-weight: var(--w-medium); line-height: 1.3; }
.cover .year, .cover .years, .cover .lead { font-size: var(--t-small); line-height: 1.4; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.cover .lead { color: var(--ink); }
.cover .section { font-size: var(--t-label); font-weight: var(--w-medium); letter-spacing: var(--track-caps); text-transform: uppercase; color: var(--ink-2); margin-top: 3px; }

/* ---------------------------------------------------------------- project + page */
.project > header, .page > header { margin-bottom: var(--gap-block); }
h1 { font-size: var(--t-h1); line-height: 1.05; letter-spacing: var(--track-tight); }
.lead { font-size: var(--t-lead); line-height: 1.35; margin-top: 12px; max-width: var(--measure); letter-spacing: -0.005em; }
.years { font-size: var(--t-meta); color: var(--ink-2); margin-top: 8px; font-variant-numeric: tabular-nums; }

.text { max-width: var(--measure); margin-block: var(--gap-block); }
.text[data-space="section"] { margin-top: var(--gap-section); }
.text[data-width="medium"] { max-width: 72ch; }
.text h2 { font-size: var(--t-h2); line-height: 1.2; letter-spacing: -0.01em; margin: 0 0 0.5em; }
.text p + h2 { margin-top: 1.4em; }
.text p { margin: 0 0 1em; -webkit-hyphens: auto; hyphens: auto; hyphenate-limit-chars: 10 4 4; }
.text p:last-child { margin-bottom: 0; }
.text a { word-break: break-word; }

figure { margin: 0; }
.image, .video { margin-block: var(--gap-block); }
.image img, .video video { width: 100%; }
.image img, .video video, .tile img { border-radius: 3px; background: var(--lift); }
figcaption { font-size: var(--t-small); line-height: 1.45; color: var(--ink-2); margin-top: 10px; max-width: var(--measure); }
.zoom { display: block; text-decoration: none; }

/* the gallery: rows of N as composed (data-columns), each row justified — a tile's flex-grow is its
   aspect ratio on a zero basis, so widths are proportional to ratio and every height in the row is
   equal, with no cropping. A short last row carries a filler with the missing ratio. */
.gallery { display: grid; gap: 8px; margin-block: var(--gap-block); }
.gallery-row { display: flex; gap: 8px; }
/* --ar is "w / h" — a ratio expression: valid for aspect-ratio and inside calc(), NOT as a bare
   number. flex-grow needs the number, so it is calc(var(--ar)); "flex: var(--ar) 1 0%" is an
   invalid declaration that Chrome drops without a word (2026-09-04). */
.tile { flex: calc(var(--ar)) 1 0%; min-width: 0; }
.tile img { width: 100%; height: auto; }
.tile figcaption { display: none; }
.gallery-fill { flex: calc(var(--ar)) 1 0%; }
@media (max-width: 599.98px) {
  .gallery-row { flex-wrap: wrap; }
  .tile { flex: 0 0 calc(50% - 4px); }
  .gallery-fill { display: none; }
}

/* two or more images side by side, widths in proportion to their shapes (Adobe's "tree") */
.row { display: flex; gap: 8px; margin-block: var(--gap-block); }
.row .image { flex: calc(var(--ar)) 1 0%; margin: 0; min-width: 0; }
@media (max-width: 599.98px) { .row { flex-direction: column; } }

.portrait { float: right; width: min(38%, 260px); margin: 6px 0 20px 32px; }
.portrait img { border-radius: 4px; }
@media (max-width: 599.98px) { .portrait { float: none; width: 55%; margin: 0 0 24px; } }

/* ---------------------------------------------------------------- lightbox
   A native <dialog>. Always dark: this is where the picture is looked at, so it is a
   deliberate single-theme surface with every colour painted explicitly. */
.lightbox { border: 0; padding: 0; margin: 0; width: 100vw; height: 100vh; max-width: none; max-height: none; background: transparent; color: #F2F2EE; }
.lightbox::backdrop { background: rgba(8, 8, 10, 0.94); }
.lightbox[open] { display: block; }
html:has(.lightbox[open]) { overflow: hidden; }
.lightbox-figure { margin: 0; width: 100vw; height: 100vh; display: grid; place-items: center; }
.lightbox-img { max-width: 100vw; max-height: calc(100vh - 64px); width: auto; height: auto; object-fit: contain; background: #18181B; }
.lightbox-caption { position: absolute; left: 20px; right: 140px; bottom: 18px; margin: 0; font-size: var(--t-small); line-height: 1.45; color: #CFCFCA; max-width: none; text-wrap: balance; }
.lightbox-caption:empty { display: none; }
.lightbox-counter { position: absolute; right: 20px; bottom: 18px; margin: 0; font-size: 13px; color: #9A9A95; font-variant-numeric: tabular-nums; }
.lightbox-close, .lightbox-prev, .lightbox-next { position: absolute; width: 48px; height: 48px; border-radius: 999px; display: grid; place-items: center; color: #F2F2EE; background: rgba(255, 255, 255, 0.08); }
.lightbox-close:hover, .lightbox-prev:hover, .lightbox-next:hover { background: rgba(255, 255, 255, 0.18); }
.lightbox-close:focus-visible, .lightbox-prev:focus-visible, .lightbox-next:focus-visible { outline: 2px solid #7FB0FF; outline-offset: 3px; }
.lightbox-close { top: 16px; right: 16px; }
.lightbox-prev { left: 16px; top: 50%; transform: translateY(-50%); }
.lightbox-next { right: 16px; top: 50%; transform: translateY(-50%); }
.lightbox svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
@media (max-width: 599.98px) {
  .lightbox-close, .lightbox-prev, .lightbox-next { width: 40px; height: 40px; }
  .lightbox-prev { left: 8px; } .lightbox-next { right: 8px; }
  .lightbox-caption { right: 90px; left: 12px; bottom: 12px; }
  .lightbox-counter { right: 12px; bottom: 12px; }
}

/* ---------------------------------------------------------------- footer */
footer.site { margin-top: var(--gap-section); padding-top: 20px; border-top: 1px solid var(--line); font-size: var(--t-small); color: var(--ink-2); clear: both; }
footer.site a { text-decoration: none; }
footer.site a:hover { text-decoration: underline; }
