/* ── Fonts ──────────────────────────────────────────────── */

/* IBM Plex Sans, variable weight 400–600, Latin only. CJK is deliberately not
   webfont-served: the system stacks below are already on every device, so
   Japanese and Chinese prose costs zero requests and renders immediately. */
@font-face {
  font-family: 'IBM Plex Sans';
  font-style: normal;
  font-weight: 400 600;
  font-display: swap;
  src: url('/fonts/IBMPlexSans-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: 'IBM Plex Sans';
  font-style: normal;
  font-weight: 400 600;
  font-display: swap;
  src: url('/fonts/IBMPlexSans-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* Sarasa Mono SC — subset via `npm run font`. Now only serves metadata, code
   and the [source] view, so it is not preloaded. */
@font-face {
  font-family: 'Sarasa Mono SC';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/fonts/Sarasa-Mono-SC-Regular.woff2') format('woff2');
}

/* ── Design tokens ──────────────────────────────────────── */

:root {
  color-scheme: light dark;

  /* Colour is semantic, not literal, so the dark palette below is a pure
     token swap — no component rule mentions a specific colour. */
  --bg: #ffffff;
  --surface: #f4f4f5;
  --surface-2: #eaeaec;
  --fg: #16161a;
  --fg-muted: #6b6b73;
  --fg-subtle: #9c9ca4;
  --rule: #e2e2e6;
  --rule-soft: #f0f0f2;
  --accent: #cc0000;
  --link: #2f6fb5;
  --link-hover: #1d4f8a;
  --shade: rgb(0 0 0 / 4%);

  /* Latin text face first; CJK falls through to the system stack. */
  --font-sans: 'IBM Plex Sans', system-ui, -apple-system, 'Segoe UI', 'Hiragino Sans', 'Hiragino Kaku Gothic ProN', 'Yu Gothic', 'Yu Gothic UI', 'Noto Sans JP', 'Noto Sans CJK JP', sans-serif;
  --font-mono: 'Sarasa Mono SC', 'IBM Plex Mono', ui-monospace, 'SF Mono', Menlo, Consolas, monospace;

  /* Type scale, fluid between the two ends of the viewport range. Every clamp
     keeps a rem term in the middle expression so browser font-size settings and
     page zoom still scale the text — a pure-vw middle term breaks that. */
  --fs-display: clamp(1.75rem, 1.2rem + 2.2vw, 2.75rem);      /* 28 → 44 */
  --fs-title: clamp(1.25rem, 1.05rem + 0.8vw, 1.5rem);        /* 20 → 24 */
  --fs-body: clamp(1rem, 0.96rem + 0.2vw, 1.125rem);          /* 16 → 18 */
  --fs-small: clamp(0.875rem, 0.85rem + 0.1vw, 0.9375rem);    /* 14 → 15 */
  --fs-meta: 0.8125rem;    /* 13 — metadata rows */
  --fs-micro: 0.75rem;     /* 12 — labels, buttons, tags */

  --lh-tight: 1.25;
  --lh-snug: 1.5;
  --lh-body: 1.75;

  /* Spacing (4px base) */
  --sp-1: 0.25rem;
  --sp-2: 0.5rem;
  --sp-3: 0.75rem;
  --sp-4: 1rem;
  --sp-5: 1.25rem;
  --sp-6: 1.5rem;
  --sp-8: 2rem;
  --sp-10: 2.5rem;
  --sp-12: 3rem;
  --sp-16: 4rem;

  /* Widths. --max caps the whole layout so a 3440px display gets margins
     instead of 829px cards that outrun the largest cover variant. */
  --max: 100rem;                    /* 1600 — outer bound for header/main/footer */
  --page: 56.25rem;                 /* 900 — single-column detail pages */
  --rail: 12rem;                    /* 192 — sticky metadata column ≥1240px */
  --measure: min(100%, 42rem);      /* ~68 Latin characters at --fs-body */
  --gutter: clamp(1rem, 3vw, 2.5rem);
  --card-gap: clamp(0.75rem, 1.4vw, 1.75rem);

  /* Side padding that centres content within --max without an extra wrapper
     element, so the header/footer rules still span the full viewport. */
  --edge: max(var(--gutter), (100% - var(--max)) / 2);
}

/* Chinese pages prefer Chinese system faces; the Japanese stack above would
   otherwise render simplified characters in Japanese glyph forms. */
html[lang="zh"] {
  --font-sans: 'IBM Plex Sans', system-ui, -apple-system, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'Noto Sans SC', 'Noto Sans CJK SC', sans-serif;
}

/* CJK characters are full-width (1em each); Latin averages ~0.44em. The same
   pixel measure therefore fits more than twice as many English characters:
   672px gives Japanese 37 per line (right in the 38–42 range books use) but
   English 86, well past the 45–75 that keeps the end-of-line return sweep
   reliable. So English gets its own, narrower measure. */
html[lang="en"] {
  --measure: min(100%, 34rem);   /* 544px → ~69 characters */
}

/* Dark palette. Written twice on purpose: once for "follow the OS" and once
   for an explicit choice, so a manual pick always beats the media query. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121215;
    --surface: #1c1c21;
    --surface-2: #26262c;
    --fg: #e7e7ea;
    --fg-muted: #9a9aa4;
    --fg-subtle: #6e6e78;
    --rule: #2d2d34;
    --rule-soft: #232328;
    --accent: #ff5a4a;
    --link: #78aee6;
    --link-hover: #a3c9f0;
    --shade: rgb(255 255 255 / 6%);
  }
}

:root[data-theme="dark"] {
  --bg: #121215;
  --surface: #1c1c21;
  --surface-2: #26262c;
  --fg: #e7e7ea;
  --fg-muted: #9a9aa4;
  --fg-subtle: #6e6e78;
  --rule: #2d2d34;
  --rule-soft: #232328;
  --accent: #ff5a4a;
  --link: #78aee6;
  --link-hover: #a3c9f0;
  --shade: rgb(255 255 255 / 6%);

  color-scheme: dark;
}

:root[data-theme="light"] {
  color-scheme: light;
}

/* ── Reset & base ───────────────────────────────────────── */

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  background: var(--bg);
  color: var(--fg);
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-sans);
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a {
  color: inherit;
  text-decoration: none;
}

img {
  max-width: 100%;
}

/* Screen-reader only — for H1 and accessibility text that shouldn't be visible */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ── Site header ────────────────────────────────────────── */

.site-header {
  display: flex;
  align-items: baseline;
  gap: var(--sp-4);
  padding-block: var(--sp-5);
  padding-inline: var(--edge);
  border-bottom: 1px solid var(--rule);
}

.site-name {
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--accent);
}

.site-nav {
  margin-left: auto;
  display: flex;
  gap: var(--sp-5);
}

.site-nav a {
  font-size: var(--fs-meta);
  color: var(--fg-muted);
  transition: color 0.15s ease;
}

.site-nav a:hover,
.site-nav a.active {
  color: var(--fg);
}

.site-tools {
  display: flex;
  align-items: baseline;
  gap: var(--sp-3);
}

/* ── Language switcher ──────────────────────────────────── */

/* <details> gives keyboard support and open/close for free, and the options are
   real links, so the switcher works with JavaScript disabled.

   The summary carries a border because it is a control, not a nav link — as
   plain text beside "exhibitions" and "about" nothing said it could be opened. */
.lang-switch {
  position: relative;
  font-size: var(--fs-meta);
}

.lang-switch summary {
  display: flex;
  align-items: center;
  gap: var(--sp-1);
  color: var(--fg-muted);
  cursor: pointer;
  list-style: none;
  padding: 2px var(--sp-2);
  border: 1px solid var(--rule);
  border-radius: 4px;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.lang-switch summary::-webkit-details-marker {
  display: none;
}

.lang-switch summary:hover,
.lang-switch[open] summary {
  color: var(--fg);
  border-color: var(--fg-subtle);
}

/* Drawn with borders rather than a ▾ glyph: that character renders at roughly
   half its point size in most faces, so at 10px in --fg-subtle it was close to
   invisible. Borders give an exact size, and currentcolor makes it track the
   summary's hover state instead of staying the faintest token on the page. */
.lang-switch-caret {
  width: 0;
  height: 0;
  border-left: 0.3125rem solid transparent;
  border-right: 0.3125rem solid transparent;
  border-top: 0.375rem solid currentcolor;
  transition: transform 0.15s ease;
}

.lang-switch[open] .lang-switch-caret {
  transform: rotate(180deg);
}


.lang-switch ul {
  position: absolute;
  top: calc(100% + var(--sp-2));
  right: 0;
  z-index: 20;
  min-width: 7.5rem;
  list-style: none;
  background: var(--bg);
  border: 1px solid var(--rule);
  border-radius: 3px;
  padding: var(--sp-1) 0;
}

.lang-switch li a {
  display: block;
  padding: var(--sp-2) var(--sp-4);
  color: var(--fg-muted);
  white-space: nowrap;
  transition: color 0.15s ease, background-color 0.15s ease;
}

.lang-switch li a:hover {
  color: var(--fg);
  background: var(--surface);
}

.lang-switch li a[aria-current] {
  color: var(--accent);
}

/* ── Theme toggle ───────────────────────────────────────── */

.theme-toggle {
  font-family: inherit;
  font-size: 0.9375rem;
  line-height: 1;
  color: var(--fg-subtle);
  background: none;
  border: none;
  cursor: pointer;
  padding: 2px;
  transition: color 0.15s ease;
}

.theme-toggle:hover {
  color: var(--fg);
}

/* ── Footer ─────────────────────────────────────────────── */

.site-footer {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--sp-4);
  flex-wrap: wrap;
  padding-block: var(--sp-5) var(--sp-6);
  padding-inline: var(--edge);
  margin-top: var(--sp-16);
  border-top: 1px solid var(--rule);
  font-size: var(--fs-micro);
  color: var(--fg-muted);
}

.site-footer a {
  color: var(--fg-muted);
  transition: color 0.15s ease;
}

.site-footer a:hover {
  color: var(--fg);
}

.footer-right {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-4);
}

.footer-left .footer-mark {
  color: var(--accent);
}

.footer-left .footer-sep {
  margin: 0 var(--sp-1);
  color: var(--rule);
}

/* ── Main ───────────────────────────────────────────────── */

main {
  flex: 1;
  padding-block: var(--sp-8);
  padding-inline: var(--edge);
}

/* ── Works bar (filter + view switch) ───────────────────── */

.works-bar {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--sp-4);
  flex-wrap: wrap;
  margin-bottom: var(--sp-6);
}

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-1) var(--sp-4);
}

.filter-btn,
.view-switch-btn,
.toggle-btn {
  font-family: var(--font-mono);
  font-size: var(--fs-micro);
  color: var(--fg-muted);
  background: none;
  border: none;
  cursor: pointer;
  padding: 2px 0;
  transition: color 0.15s ease;
}

.filter-btn:hover,
.view-switch-btn:hover,
.toggle-btn:hover {
  color: var(--fg);
}

/* Active state uses the accent — it used to match :hover exactly, which made
   the current filter impossible to spot. */
.filter-btn.active,
.view-switch-btn.active,
.toggle-btn.active {
  color: var(--accent);
}

.view-switch {
  display: flex;
  gap: var(--sp-4);
}

/* Featured-only grid. _data/featured.yaml names what the homepage leads with;
   the rest is one click away. The limit is expressed entirely in this selector
   so the JS only has to set two data attributes: it applies in the grid view,
   with no tag selected, before [show all] has been pressed. Picking a tag is
   itself a request to see all of that tag, and the index view is the full
   archive by definition — both lift the limit without extra code. */
.works[data-works-view="grid"][data-filter="all"][data-show-all="false"]
  .work-card[data-featured="false"] {
  display: none;
}

.works-more {
  display: none;
  margin: var(--sp-8) auto 0;
  font-family: var(--font-mono);
  font-size: var(--fs-micro);
  color: var(--fg-muted);
  background: none;
  border: 1px solid var(--rule);
  border-radius: 4px;
  cursor: pointer;
  padding: var(--sp-2) var(--sp-5);
  transition: color 0.15s ease, border-color 0.15s ease;
}

.works-more:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.works[data-works-view="grid"][data-filter="all"][data-show-all="false"] .works-more {
  display: block;
}

/* ── Homepage: card grid ────────────────────────────────── */

.works[data-works-view="grid"] .work-index {
  display: none;
}

.works[data-works-view="index"] .work-grid {
  display: none;
}

/* The card grid is full-bleed; the timeline list is capped at --page so it stays
   scannable. Match the bar to whichever is showing, or the view switch floats
   off to the right of nothing. */
.works[data-works-view="index"] .works-bar {
  max-width: var(--page);
}

/* auto-fill instead of a fixed column count: cards grow monotonically with the
   viewport. With `repeat(4, 1fr)` every breakpoint halved the card width on the
   way up (520→270 at 600px, 350→239 at 820px), which is the opposite of what a
   wider window should do. --col-min is the only thing the breakpoints touch. */
.work-grid {
  --col-min: 20rem;   /* 320 */

  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(var(--col-min), 100%), 1fr));
  gap: var(--card-gap);
}

.work-card {
  display: block;
  /* Kept transparent purely as layout spacing — hover is signalled by the
     sweep across the mat below, not by an outline. */
  border: 1px solid transparent;
}

/* Hover: one highlight travelling left to right across the mat, looping.
   Implemented as a translated ::after rather than an animated
   background-position, because the direction is then simply the sign of the
   translate — the old shimmer's `200% → -200%` actually reads right-to-left
   once background-size exceeds 100%, which is easy to get backwards.
   z-index 0 keeps it under the image, so the highlight is only seen on the
   mat, and .card-image's overflow: hidden clips it at the edges.
   --shade is black 4% in light and white 6% in dark, so it reads in both. */
@keyframes card-sweep {
  from { transform: translateX(-100%); }
  to { transform: translateX(100%); }
}

.work-card:hover .card-image::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  background: linear-gradient(90deg, transparent 0%, var(--shade) 50%, transparent 100%);
  /* ease-out, not ease-in-out: the highlight starts outside the left edge, and
     an ease-in would spend the first moments barely moving — the sweep has
     to register immediately on hover. */
  animation: card-sweep 0.8s ease-out infinite;
}

/* The mat. Covers are no longer cropped to fill the card — each one keeps its
   own aspect ratio and sits inset on a shared ground, the way a set of prints
   of different sizes is matted to hang together. That is what buys tolerance:
   a weak image is an object being shown rather than the card's own surface, so
   a 640×360 screenshot and a 2:3 portrait can sit side by side without one of
   them reading as a mistake. The 4:3 box stays, so the grid rows still align.
   Consequence: `role: "cover"` (the build-time smart crop) is not used by the
   homepage any more — see index.njk. */
.card-image {
  width: 100%;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  background: var(--surface);
  position: relative;
  padding: var(--sp-4);
}

/* Skeleton shimmer lives only on the wrapper. The image used to carry a second
   copy, which was only ever visible underneath this one. */
/* `:not(.has-image)` rather than a separate override: an override rule has the
   same specificity as this one, so it only wins if it comes later in the file —
   a trap this exact rule fell into once. src/main.js adds `.has-image` on load.
   It matters more than it used to: under `object-fit: cover` the image hid this
   shimmer completely, but the mat leaves it visible around every cover, so it
   would animate forever. */
.card-image:not(.no-image):not(.has-image)::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, var(--surface) 0%, var(--surface-2) 50%, var(--surface) 100%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.4s ease-in-out infinite;
  z-index: 0;
}

.card-image picture {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  position: relative;
  z-index: 1;
}

.card-image img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  display: block;
  opacity: 0;
  transition: opacity 0.4s ease;
  position: relative;
  z-index: 1;
}

.card-image img.loaded {
  opacity: 1;
}

.work-card:hover .card-image img.loaded {
  opacity: 0.9;
}

@keyframes skeleton-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.card-body {
  padding: var(--sp-3) 2px var(--sp-4);
}

.card-title {
  font-size: var(--fs-small);
  font-weight: 500;
  line-height: var(--lh-snug);
  color: var(--fg);
  margin-bottom: var(--sp-2);
}

.card-meta {
  font-family: var(--font-mono);
  font-size: var(--fs-micro);
  line-height: 1.4;
  color: var(--fg-subtle);
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
}

.card-tag {
  color: var(--fg-subtle);
}

.filtered-out {
  display: none;
}

/* ── Homepage: timeline index ───────────────────────────── */

/* The whole 2012→2026 span in one screen. Same items, same filter, no covers. */
.work-index {
  list-style: none;
  border-top: 1px solid var(--rule);
  max-width: var(--page);
}

.work-index-row {
  border-bottom: 1px solid var(--rule-soft);
}

.work-index-row a {
  display: grid;
  grid-template-columns: 4rem 1fr auto;
  gap: var(--sp-4);
  align-items: baseline;
  padding: var(--sp-3) var(--sp-1);
  transition: background-color 0.15s ease;
}

.work-index-row a:hover {
  background: var(--shade);
}

.wi-year {
  font-family: var(--font-mono);
  font-size: var(--fs-meta);
  color: var(--fg-muted);
  font-variant-numeric: tabular-nums;
}

.wi-title {
  font-size: var(--fs-small);
  line-height: var(--lh-snug);
}

.work-index-row a:hover .wi-title {
  color: var(--accent);
}

.wi-tags {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  font-family: var(--font-mono);
  font-size: var(--fs-micro);
  color: var(--fg-subtle);
  justify-content: flex-end;
}

/* ── Detail pages: shared shell ─────────────────────────── */

/* Narrow and mid widths: a single centred column, unchanged. The wide-screen
   two-column form (metadata rail + body) lives at the bottom of this file with
   the other responsive rules. */
.work-page,
.lab-page,
.talk-page,
.exhibitions-page {
  max-width: var(--page);
  margin: 0 auto;
}

.about-page {
  max-width: var(--measure);
  margin: 0 auto;
}

.page-back {
  grid-area: back;
  display: inline-block;
  margin-bottom: var(--sp-8);
  font-family: var(--font-mono);
  font-size: var(--fs-micro);
  color: var(--fg-muted);
  transition: color 0.15s ease;
}

.page-back:hover {
  color: var(--accent);
}

.page-header {
  grid-area: title;
  margin-bottom: var(--sp-6);
}

.page-rail {
  grid-area: rail;
  margin-bottom: var(--sp-8);
}

.page-body {
  grid-area: body;
  min-width: 0;   /* let the gallery shrink inside the grid track */
}

.page-title {
  font-size: var(--fs-display);
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: var(--lh-tight);
  color: var(--fg);
  margin-bottom: var(--sp-4);
  max-width: var(--measure);
}

.page-meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2) var(--sp-4);
  align-items: baseline;
  font-family: var(--font-mono);
  font-size: var(--fs-meta);
  color: var(--fg-muted);
}

.page-tags {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2) var(--sp-3);
}

.page-tag {
  color: var(--accent);
}

.page-meta-materials {
  color: var(--fg-subtle);
}

/* ── Work video ─────────────────────────────────────────── */

.work-video {
  margin-bottom: var(--sp-10);
}

.video-embed {
  position: relative;
  width: 100%;
  padding-top: 56.25%;
}

.video-embed iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: none;
}

/* ── Talk pages ─────────────────────────────────────────── */

/* Event / role / location join year and tags in the rail. The event name is
   the anchor of the three, so it keeps full contrast; the rest recede. */
.page-meta-event {
  color: var(--fg);
}

.page-meta-event a {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px solid var(--rule);
}

.page-meta-event a:hover {
  color: var(--link-hover);
  border-bottom-color: currentcolor;
}

.page-meta-role,
.page-meta-location {
  color: var(--fg-subtle);
}

/* ── Prose ──────────────────────────────────────────────── */

/* Text is capped at --measure while galleries and standalone images stay full
   width — the editorial answer to "images are the subject, words are readable". */
.work-text {
  border-top: 1px solid var(--rule);
  padding-top: var(--sp-8);
}

/* The gallery is usually the first thing in the body; its own top margin would
   double up with the padding above. */
.work-text > :first-child {
  margin-top: 0;
}

.work-text p,
.about-text p,
.work-text ul,
.about-text ul,
.work-text ol,
.about-text ol,
.work-text blockquote,
.about-text blockquote,
.work-text h2,
.about-text h2,
.work-text h3,
.about-text h3 {
  max-width: var(--measure);
}

.work-text p,
.about-text p {
  margin-bottom: var(--sp-5);
}

.work-text h2,
.about-text h2 {
  font-size: var(--fs-title);
  font-weight: 600;
  line-height: var(--lh-tight);
  letter-spacing: -0.01em;
  margin: var(--sp-10) 0 var(--sp-4);
}

.work-text h3,
.about-text h3 {
  font-size: var(--fs-body);
  font-weight: 600;
  margin: var(--sp-8) 0 var(--sp-3);
}

.work-text a,
.about-text a {
  color: var(--link);
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-thickness: 1px;
}

.work-text a:hover,
.about-text a:hover {
  color: var(--link-hover);
}

.work-text ul,
.about-text ul,
.work-text ol,
.about-text ol {
  padding-left: 1.5em;
  margin-bottom: var(--sp-5);
}

.work-text li,
.about-text li {
  margin-bottom: var(--sp-2);
}

.work-text li::marker,
.about-text li::marker {
  color: var(--fg-subtle);
}

.work-text strong,
.about-text strong {
  font-weight: 600;
}

.work-text em,
.about-text em {
  font-style: italic;
}

.work-text hr,
.about-text hr {
  border: none;
  border-top: 1px solid var(--rule);
  margin: var(--sp-8) 0;
  max-width: var(--measure);
}

.work-text blockquote,
.about-text blockquote {
  border-left: 2px solid var(--rule);
  padding-left: var(--sp-4);
  margin-bottom: var(--sp-5);
  color: var(--fg-muted);
}

.work-text code,
.about-text code {
  font-family: var(--font-mono);
  font-size: 0.875em;
  background: var(--surface);
  padding: 0.1em 0.35em;
  border-radius: 3px;
}

/* A standalone image in the prose — markdown wraps those in a <p>, which is what
   scopes this rule away from galleries. Unscoped as `.work-text img` it also hit
   every gallery thumbnail: the 24px top margin survived inside the multi-column
   BFC and pushed the first masonry item down, while collapsing through each
   <picture> turned the intended 4px gutter into 24px. */
.work-text p img {
  height: auto;
  display: block;
  margin: var(--sp-6) 0;
}

/* ── Gallery ────────────────────────────────────────────── */

/* Masonry via multi-column: every photograph keeps its own aspect ratio. The
   old grid forced aspect-ratio: 1 on all of them, and only 3 of the 100 gallery
   images are actually square — 38 are wider than 16:10 and 11 are portrait.
   Trade-off: columns fill top-to-bottom, so reading order runs down a column
   before moving right. That's the normal contact-sheet convention, and the
   alternative (true left-to-right masonry) needs JS or unshipped CSS. */
.gallery {
  columns: 3;
  column-gap: var(--sp-1);
  margin: var(--sp-8) 0;
}

/* Masonry items. Both selectors are needed: most images are wrapped in a
   <picture>, but GIFs and SVGs are served as-is and land here as a bare <img>.
   Margins are stated explicitly rather than left to inherit — a stray vertical
   margin here is invisible in the first column and offsets every other one. */
.gallery > picture,
.gallery > img {
  display: block;
  width: 100%;
  margin: 0 0 var(--sp-1);
  break-inside: avoid;
}

/* width/height on the <img> come from the image manifest, so the browser
   reserves the right box before bytes arrive — no reflow as the gallery loads. */
.gallery img {
  width: 100%;
  height: auto;
  display: block;
  cursor: zoom-in;
  background: linear-gradient(90deg, var(--surface) 0%, var(--surface-2) 50%, var(--surface) 100%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.4s ease-in-out 200ms infinite;
}

.gallery img.loaded {
  animation: none;
  background: none;
}

.gallery img:hover {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

/* ── Lightbox ───────────────────────────────────────────── */

.lightbox {
  border: 1px solid #333333;
  background: #0a0a0a;
  padding: 36px 16px 16px;
  margin: auto;
  overflow: hidden;
}

.lightbox:modal {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  width: 92vw;
  max-width: 92vw;
  max-height: 94vh;
}

.lightbox::backdrop {
  background: rgb(0 0 0 / 85%);
}

.lightbox-img {
  width: 100%;
  max-height: calc(92vh - 80px);
  object-fit: contain;
  display: block;
  cursor: zoom-in;
  transform-origin: center center;
  transition: none;
  user-select: none;
  -webkit-user-drag: none;
  will-change: transform;
}

.lightbox-img.zoomed {
  cursor: grab;
}

.lightbox.is-loading .lightbox-img {
  visibility: hidden;
}

.lightbox.is-loading::after {
  content: "";
  position: absolute;
  inset: 50% auto auto 50%;
  width: 20px;
  height: 20px;
  margin: -10px 0 0 -10px;
  border: 1px solid #444444;
  border-top-color: #cccccc;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  pointer-events: none;
  z-index: 1;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.lightbox-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  align-self: stretch;
  position: relative;
  z-index: 2;
  background: rgb(10 10 10 / 70%);
  padding: 6px 0;
  border-radius: 2px;
}

.lightbox-counter {
  font-family: var(--font-mono);
  font-size: var(--fs-micro);
  color: #888888;
  font-variant-numeric: tabular-nums;
  min-width: 60px;
  text-align: center;
}

.lightbox-prev,
.lightbox-next,
.lightbox-close {
  font-family: var(--font-mono);
  font-size: var(--fs-micro);
  color: #999999;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 8px;
}

.lightbox-prev:hover,
.lightbox-next:hover,
.lightbox-close:hover {
  color: #ffffff;
}

.lightbox-close {
  position: absolute;
  top: 8px;
  right: 12px;
  z-index: 2;
  background: rgb(10 10 10 / 70%);
  border-radius: 2px;
}

/* ── View toggle (rendered / source) ────────────────────── */

/* Lives inside .page-rail, which owns the spacing below it. */
.view-toggle {
  display: flex;
  gap: var(--sp-4);
  margin-top: var(--sp-4);
}

.work-source {
  font-family: var(--font-mono);
  font-size: var(--fs-meta);
  line-height: 1.7;
  color: var(--fg);
  white-space: pre-wrap;
  word-break: break-word;
  border-top: 1px solid var(--rule);
  padding-top: var(--sp-8);
}

/* ── Exhibitions ────────────────────────────────────────── */

.ex-header,
.ex-row {
  display: grid;
  grid-template-columns: 3.5rem 1fr 4rem 1fr;
  gap: 0 var(--sp-4);
  padding: var(--sp-2) 0;
}

.ex-header {
  font-family: var(--font-mono);
  font-size: var(--fs-micro);
  color: var(--fg-subtle);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--rule);
  margin-bottom: 2px;
}

.ex-row {
  border-bottom: 1px solid var(--rule-soft);
}

.ex-row:last-child {
  border-bottom: none;
}

.ex-year {
  font-family: var(--font-mono);
  font-size: var(--fs-meta);
  color: var(--fg-muted);
  font-variant-numeric: tabular-nums;
}

.ex-title {
  font-size: var(--fs-small);
  line-height: var(--lh-snug);
}

.ex-type {
  font-family: var(--font-mono);
  font-size: var(--fs-micro);
  color: var(--fg-subtle);
}

.ex-type.solo {
  color: var(--accent);
}

.ex-venue {
  font-size: var(--fs-meta);
  color: var(--fg-muted);
  line-height: var(--lh-snug);
}

/* ── About: CV block ────────────────────────────────────── */

/* Sits below the prose: the writing is the page, this is reference. */
.about-meta {
  margin-top: var(--sp-16);
  padding-top: var(--sp-8);
  border-top: 1px solid var(--rule);
}

.meta-section {
  margin-bottom: var(--sp-8);
}

.meta-section:last-child {
  margin-bottom: 0;
}

.meta-header {
  font-family: var(--font-mono);
  font-size: var(--fs-micro);
  color: var(--accent);
  letter-spacing: 0.08em;
  margin-bottom: var(--sp-3);
}

.meta-row {
  display: grid;
  grid-template-columns: 6rem 1fr;
  gap: var(--sp-3);
  font-size: var(--fs-meta);
  line-height: var(--lh-snug);
  padding: var(--sp-1) 0;
}

.meta-when {
  font-family: var(--font-mono);
  color: var(--fg-muted);
  font-variant-numeric: tabular-nums;
}

.meta-note {
  font-size: var(--fs-meta);
  color: var(--fg-muted);
  line-height: var(--lh-snug);
  margin-top: var(--sp-2);
  padding-left: calc(6rem + var(--sp-3));
}

.meta-row a {
  color: var(--fg);
  border-bottom: 1px dotted var(--fg-subtle);
}

.meta-row a:hover {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* ── Lab detail: actions + embed ────────────────────────── */

/* Capped at the prose measure: this is a small control block, and stretching it
   across the full body column left the link text stranded on the far left. */
.lab-actions,
.talk-links {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  max-width: var(--measure);
  margin-bottom: var(--sp-8);
  padding: var(--sp-4) var(--sp-5);
  border: 1px solid var(--rule);
  border-radius: 4px;
}

.lab-launch,
.lab-github,
.talk-link {
  display: grid;
  grid-template-columns: 1.25rem 4.5rem 1fr;
  gap: var(--sp-3);
  align-items: baseline;
  font-size: var(--fs-meta);
  padding: var(--sp-1) 0;
  transition: color 0.15s ease;
}

.lab-launch:hover,
.lab-github:hover,
.talk-link:hover {
  color: var(--accent);
}

.lab-launch-arrow,
.talk-link-arrow {
  color: var(--accent);
}

.lab-launch-text,
.talk-link-kind {
  font-family: var(--font-mono);
  font-size: var(--fs-micro);
  color: var(--fg-muted);
}

.lab-launch:hover .lab-launch-text,
.lab-github:hover .lab-launch-text,
.talk-link:hover .talk-link-kind {
  color: var(--accent);
}

.lab-launch-url,
.talk-link-title {
  font-family: var(--font-mono);
  font-size: var(--fs-micro);
  overflow-wrap: anywhere;
}

.lab-embed-wrapper,
.talk-embed-wrapper {
  margin-bottom: var(--sp-8);
  position: relative;
}

.lab-embed,
.talk-embed {
  width: 100%;
  aspect-ratio: 3 / 2;
  max-height: 85vh;
  border: 1px solid var(--rule);
  border-radius: 4px;
  display: block;
  background: var(--surface);
}

/* A deck is 16:9; the 3:2 above suits lab tools with panels and toolbars. */
.talk-embed {
  aspect-ratio: 16 / 9;
}

/* Separate rules on purpose — never a selector list: an unknown pseudo-class
   invalidates the entire list, so pairing these dropped the sizing in Firefox.
   That is also why .talk-embed gets its own copy below instead of joining. */
.lab-embed:fullscreen {
  width: 100vw;
  height: 100vh;
  max-height: 100vh;
  aspect-ratio: auto;
  border: none;
  border-radius: 0;
}

.talk-embed:fullscreen {
  width: 100vw;
  height: 100vh;
  max-height: 100vh;
  aspect-ratio: auto;
  border: none;
  border-radius: 0;
}

.lab-embed:-webkit-full-screen {
  width: 100vw;
  height: 100vh;
  max-height: 100vh;
  aspect-ratio: auto;
  border: none;
  border-radius: 0;
}

.talk-embed:-webkit-full-screen {
  width: 100vw;
  height: 100vh;
  max-height: 100vh;
  aspect-ratio: auto;
  border: none;
  border-radius: 0;
}

.lab-embed-fs,
.talk-embed-fs {
  position: absolute;
  top: var(--sp-2);
  right: var(--sp-2);
  z-index: 2;
  font-family: var(--font-mono);
  font-size: var(--fs-micro);
  color: var(--fg-muted);
  background: var(--bg);
  border: 1px solid var(--rule);
  border-radius: 3px;
  padding: var(--sp-1) var(--sp-2);
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.lab-embed-fs:hover,
.talk-embed-fs:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.lab-embed-hint,
.talk-embed-hint {
  font-size: var(--fs-micro);
  color: var(--fg-subtle);
  margin-top: var(--sp-2);
  text-align: right;
}

.lab-embed-hint a,
.talk-embed-hint a {
  color: var(--fg-muted);
  border-bottom: 1px dotted var(--fg-subtle);
}

.lab-embed-hint a:hover,
.talk-embed-hint a:hover {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* ── 404 ────────────────────────────────────────────────── */

/* One document serves every language here, so all three are shown at once. */
.page-404 {
  text-align: center;
  padding: var(--sp-16) var(--sp-5);
}

.page-404 h1 {
  font-size: var(--fs-title);
  font-weight: 600;
  line-height: var(--lh-tight);
}

.page-404 [lang] {
  margin-bottom: var(--sp-10);
}

.page-404 p {
  margin-top: var(--sp-3);
  font-size: var(--fs-meta);
  color: var(--fg-muted);
}

.page-404 a:hover {
  color: var(--accent);
}

/* ── Responsive ─────────────────────────────────────────── */

/* Layout breakpoints, deliberately only three: 1100 / 760 / 480. Everything
   that used to need 560, 640 and 900 is handled by clamp() and the auto-fill
   grid. Two component breakpoints go the other way (min-width) because they add
   structure rather than reflow it: 1240 for the metadata rail and 1600 for the
   gallery's fourth column. */

/* Wide screens: metadata moves into a sticky left rail. A centred prose column
   leaves ~1020px unused at 1920px wide, which read as "a phone layout centred
   on a big screen". Widening the prose is the wrong fix — English already runs
   86 characters per line at 672px — so the width goes to metadata and images
   instead. Below this width everything collapses to a single column, and the
   DOM order already matches, so nothing needs reordering. */
@media (min-width: 1240px) {
  .work-page,
  .lab-page,
  .talk-page {
    display: grid;
    grid-template-columns: var(--rail) minmax(0, 1fr);
    grid-template-areas:
      "back  title"
      "rail  body";
    column-gap: var(--sp-8);
    max-width: none;   /* bounded by --max on main */
  }

  .page-rail {
    position: sticky;
    top: var(--sp-8);
    align-self: start;
    margin-bottom: 0;
  }

  /* Stack the metadata down the rail instead of across a row. */
  .page-meta {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--sp-3);
  }
}

/* The gallery grows with the main column, so images get bigger rather than more
   numerous. A fourth column only once three would make each image oversized. */
@media (min-width: 1600px) {
  .gallery {
    columns: 4;
  }
}

@media (max-width: 1100px) {
  .work-grid {
    --col-min: 17rem;   /* 272 — keeps 3 up on a laptop */
  }
}

@media (max-width: 760px) {
  .site-header {
    flex-wrap: wrap;
    padding-block: var(--sp-4);
  }

  .work-grid {
    --col-min: 15rem;   /* 240 — 2 up on a tablet / large phone */
  }

  /* Was 3-up until 480px, so tablet thumbnails were only ~165px wide. */
  .gallery {
    columns: 2;
  }

  .ex-header {
    display: none;
  }

  .ex-row {
    grid-template-columns: 3.5rem 1fr;
    grid-template-rows: auto auto;
    gap: 2px var(--sp-3);
    padding: var(--sp-3) 0;
  }

  .ex-year { grid-area: 1 / 1; }
  .ex-title { grid-area: 1 / 2; }
  .ex-type { grid-area: 2 / 1; }
  .ex-venue { grid-area: 2 / 2; }
}

@media (max-width: 480px) {
  /* One column on phones: this is a portfolio, the image should be as big as
     the screen allows rather than two 200px thumbnails. */
  .work-grid {
    --col-min: 100%;
  }

  .gallery {
    columns: 1;
  }

  .work-index-row a {
    grid-template-columns: 3.5rem 1fr;
    row-gap: var(--sp-1);
  }

  .wi-tags {
    grid-area: 2 / 2;
    justify-content: flex-start;
  }

  .meta-row {
    grid-template-columns: 4.5rem 1fr;
    gap: var(--sp-2);
  }

  .meta-note {
    padding-left: calc(4.5rem + var(--sp-2));
  }
}

/* Two cursors used to blink forever and every unloaded card shimmered — on the
   homepage that was ~20 concurrent infinite animations. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
