/* ==========================================================================
   00 tokens: fonts and every design token. Nothing here paints anything.
   Contrast ratios quoted in comments are WCAG 2.x, measured (see
   docs/redesign/prototype-notes.md for the full table).
   ========================================================================== */

/* The bundle is served as css/site.css, so the font sits one level up. */
@font-face {
  font-family: 'Inter';
  src: url('../fonts/inter-latin-wght.woff2') format('woff2');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

/* Arial scaled to Inter's metrics, so the swap moves nothing. */
@font-face {
  font-family: 'Inter Fallback';
  src: local('Arial');
  size-adjust: 107%;
  ascent-override: 90%;
  descent-override: 22.5%;
  line-gap-override: 0%;
}

:root {
  /* text */
  --text: #0f172a;          /* headings, nav, labels: 17.06 on --bg */
  --text-body: #1e293b;     /* long-form prose: 13.98 */
  --text-muted: #475569;    /* secondary copy: 7.24 */
  --text-subtle: #5b6678;   /* meta, captions, small labels: 5.55 */

  /* surfaces */
  --bg: #f8fafc;            /* page */
  --surface: #ffffff;       /* cards, footer */
  --surface-2: #f1f5f9;     /* code, credits, diagram fields */
  --border: #e2e8f0;        /* hairlines (decoration only) */
  --border-strong: #cbd5e1; /* hover borders, table head rule */
  --border-control: #8391a5;/* where a border alone marks a control: 3.20 on white */
  --media-edge: rgba(15, 23, 42, .08); /* hairline around photos and video */

  /* accent: one, used for links, primary buttons, focus, current page */
  --accent: #0369a1;        /* 5.67 on --bg, white on it 5.93 */
  --accent-hover: #075985;
  --accent-tint: #e0f2fe;
  --accent-underline: rgba(3, 105, 161, .4);
  --focus: #0369a1;

  /* kind and status labels */
  --research: #6d28d9;
  --research-tint: #f3effe;
  --project: #0f766e;
  --project-tint: #e6f6f4;
  --status-live: #047857;
  --status-live-tint: #ecfdf5;

  /* diagram ink */
  --ink: #334155;           /* strokes and arrows: 10.35 on white */
  --ink-quiet: #64748b;     /* stroke of a quiet node: 4.76 on white, 4.34 on its own fill */

  /* gradient palette: the home hero, the index band, the 40px title rule */
  --orb-blue: #8fb4ff;
  --orb-violet: #b6a4ff;
  --orb-pink: #ffb0c8;
  --orb-peach: #ffcf99;
  --orb-mint: #93e3c1;
  --orb-opacity: .62;
  --band-opacity: .5;
  --scrim: rgba(248, 250, 252, .4);
  --rule-gradient: linear-gradient(90deg, var(--orb-blue), var(--orb-violet), var(--orb-pink));

  /* type */
  --font-sans: 'Inter', 'Inter Fallback', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  --fs-xs: .8125rem;   /* 13 */
  --fs-sm: .875rem;    /* 14 */
  --fs-ui: .9375rem;   /* 15 */
  --fs-base: 1rem;     /* 16 */
  --fs-md: 1.0625rem;  /* 17, prose */
  --fs-lg: 1.25rem;    /* 20 */
  --fs-xl: 1.5rem;     /* 24 */
  --fs-2xl: clamp(1.75rem, 1.4rem + 1.2vw, 2.25rem);    /* 28-36, section h2 */
  --fs-3xl: clamp(2.25rem, 1.6rem + 2.4vw, 3.5rem);     /* 36-56, page h1 */
  --fs-hero: clamp(2.75rem, 1.6rem + 5vw, 5.5rem);      /* 44-88, the name */
  --fs-lede: clamp(1.25rem, 1.05rem + .8vw, 1.625rem);  /* 20-26, hero sentence */
  --fs-stat: clamp(2rem, 1.6rem + 1.4vw, 2.75rem);      /* 32-44, glance numbers */
  --lh-tight: 1.08;
  --lh-snug: 1.3;
  --lh-body: 1.65;
  --tracking-hero: -.04em;
  --tracking-title: -.03em;
  --tracking-label: .06em;

  /* space, 4px base */
  --s-1: 4px;
  --s-2: 8px;
  --s-3: 12px;
  --s-4: 16px;
  --s-5: 24px;
  --s-6: 32px;
  --s-7: 48px;
  --s-8: 64px;
  --s-9: 96px;
  --s-10: 128px;
  --gutter: clamp(20px, 4vw, 32px);
  --container: 1200px;
  --container-text: 760px;   /* case-study header text */
  --container-resume: 820px;
  --measure: 42.5rem;        /* prose column: 680px, about 75 characters at 17px */
  --section-y: clamp(56px, 8vw, 96px);
  --nav-h: 56px;

  /* radii */
  --radius-xs: 6px;
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 20px;
  --radius-pill: 999px;

  /* shadows */
  --shadow-1: 0 1px 2px rgba(15, 23, 42, .06), 0 1px 1px rgba(15, 23, 42, .04);
  --shadow-2: 0 12px 32px rgba(15, 23, 42, .08), 0 2px 6px rgba(15, 23, 42, .04);
  --shadow-nav: inset 0 1px 0 rgba(255, 255, 255, .6), 0 1px 0 rgba(15, 23, 42, .06), 0 4px 20px rgba(15, 23, 42, .06);

  /* motion */
  --ease-out: cubic-bezier(.16, 1, .3, 1);
  --ease-std: cubic-bezier(.2, .8, .2, 1);
  --dur-fast: 150ms;
  --dur: 200ms;
  --dur-slow: 400ms;
}

@media (min-width: 480px) {
  :root { --nav-h: 64px; }
}

/* ==========================================================================
   10 base: reset, document defaults, focus, and the small shared atoms
   (buttons, quiet links, kind labels, chips, status pill, icons).
   ========================================================================== */

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-padding-top: calc(var(--nav-h) + 16px);
}

@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text-body);
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  line-height: 1.6;
  font-optical-sizing: auto;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

main { flex: 1 0 auto; display: block; }
main:focus { outline: none; }

h1, h2, h3, h4, p, ul, ol, dl, dd, figure, blockquote { margin: 0; }
ul, ol { padding: 0; list-style: none; }

h1, h2, h3, h4 {
  color: var(--text);
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: var(--tracking-title);
  text-wrap: balance;
}

p { text-wrap: pretty; }

img, svg, video { display: block; max-width: 100%; }
img, video { height: auto; }

a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; }
strong, b { font-weight: 600; }
[hidden] { display: none !important; }

::selection { background: var(--accent-tint); color: var(--text); }

/* Focus: one visible ring everywhere. Never removed without a replacement. */
:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  border-radius: var(--radius-xs);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.skip {
  position: fixed;
  top: 8px;
  left: 8px;
  z-index: 200;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  transform: translateY(-200%);
}
.skip:focus { transform: none; }

.num { font-variant-numeric: tabular-nums; }

/* --- icons: 16px inline SVG, drawn with currentColor ---------------------- */
.icon {
  flex: none;
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.icon--fill { fill: currentColor; stroke: none; }

/* --- buttons: always solid, never translucent ------------------------------ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 22px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-size: var(--fs-ui);
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color var(--dur-fast), border-color var(--dur-fast), color var(--dur-fast);
}
.btn--primary { background: var(--accent); color: #fff; }
.btn--primary:hover { background: var(--accent-hover); }
.btn--secondary { background: var(--surface); border-color: var(--border-strong); color: var(--text); }
.btn--secondary:hover { background: var(--surface-2); border-color: var(--border-control); }

/* --- quiet text link with an icon (hero, footer, contact) ------------------ */
.link-quiet {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  margin-inline: -4px;
  padding-inline: 4px;
  color: var(--text);
  font-size: var(--fs-ui);
  font-weight: 600;
}
.link-quiet:hover { text-decoration: underline; text-underline-offset: 4px; text-decoration-thickness: 1.5px; }

/* --- accent text link with an arrow ("Read case study") -------------------- */
.more {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--accent);
  font-size: var(--fs-ui);
  font-weight: 600;
}
.more .icon { transition: transform var(--dur) var(--ease-std); }

/* --- kind label: "RESEARCH · arXiv 2026" ----------------------------------- */
.kind {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 8px;
  font-size: var(--fs-xs);
  line-height: 1.4;
}
.kind__type {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
}
.kind__type::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}
.kind--research .kind__type { color: var(--research); }
.kind--project .kind__type { color: var(--project); }
.kind__detail { color: var(--text-muted); font-weight: 500; }
.kind__detail::before { content: '\00B7'; margin-right: 8px; color: var(--text-subtle); }

/* --- status pill ----------------------------------------------------------- */
.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 10px;
  border-radius: var(--radius-pill);
  background: var(--status-live-tint);
  color: var(--status-live);
  font-size: var(--fs-xs);
  font-weight: 600;
  line-height: 1.5;
  white-space: nowrap;
}
.status::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

/* --- stack chips (plain labels, not links) --------------------------------- */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  padding: 3px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: var(--fs-xs);
  font-weight: 500;
  line-height: 1.5;
  white-space: nowrap;
}

/* --- link chips (publication links) ---------------------------------------- */
.chip-link {
  position: relative;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  padding: 6px 12px;
  border-radius: var(--radius-xs);
  background: var(--accent-tint);
  color: var(--accent);
  font-size: var(--fs-sm);
  font-weight: 600;
  transition: background-color var(--dur-fast), color var(--dur-fast);
}
.chip-link:hover { background: #cce9fb; color: var(--accent-hover); }
@media (pointer: coarse) {
  .chip-link { min-height: 44px; }
}

/* ==========================================================================
   20 layout: the one container, section rhythm, section headings.
   Nav and content share .container, so their edges always line up.
   Breakpoints: 480, 768, 1024.
   ========================================================================== */

.container {
  width: 100%;
  max-width: calc(var(--container) + 2 * var(--gutter));
  margin-inline: auto;
  padding-inline: var(--gutter);
}
.container--text { max-width: calc(var(--container-text) + 2 * var(--gutter)); }
.container--resume { max-width: calc(var(--container-resume) + 2 * var(--gutter)); }

.section { padding-block: var(--section-y); }
.section + .section { padding-top: 0; }
.section--tight { padding-block: calc(var(--section-y) * .75); }

/* h2 with the 40x3 gradient rule under it; optional link on the baseline */
.section__head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 4px 24px;
  margin-bottom: clamp(28px, 4vw, 40px);
}
.section__title {
  font-size: var(--fs-2xl);
}
.section__title::after,
.rule::after {
  content: '';
  display: block;
  width: 40px;
  height: 3px;
  margin-top: 12px;
  border-radius: 2px;
  background: var(--rule-gradient);
}
.section__more { min-height: 44px; }
.section__more:hover .icon,
a.more:hover .icon { transform: translateX(3px); }

/* sub-heading inside a section ("Publications", "Side projects") */
.subhead {
  margin: var(--s-7) 0 var(--s-5);
  font-size: var(--fs-lg);
  font-weight: 600;
  letter-spacing: -.015em;
}

/* intro sentence under a page or section title */
.lede {
  max-width: 60ch;
  color: var(--text-muted);
  font-size: 1.125rem;
  line-height: 1.55;
}

/* ==========================================================================
   30 header and footer: the glass navbar (the only glass on the site),
   its phone menu, its no-JavaScript fallback, and the footer.
   ========================================================================== */

.nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(255, 255, 255, .85);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
  backdrop-filter: blur(20px) saturate(160%);
  border-bottom: 1px solid rgba(15, 23, 42, .08);
  box-shadow: var(--shadow-nav);
  transition: background-color var(--dur), box-shadow var(--dur);
}
/* At the top of the home page the glass is thinner and lets the hero through. */
.surface-hero .nav:not(.is-scrolled) {
  background: rgba(255, 255, 255, .72);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .6);
}

@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .nav,
  .surface-hero .nav:not(.is-scrolled) { background: rgba(248, 250, 252, .97); }
}
@media (prefers-reduced-transparency: reduce) {
  .nav,
  .surface-hero .nav:not(.is-scrolled) {
    background: var(--bg);
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }
}

.nav__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: var(--nav-h);
}

.nav__brand {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  color: var(--text);
  font-size: var(--fs-md);
  font-weight: 600;
  letter-spacing: -.015em;
  white-space: nowrap;
}

.nav__menu { display: flex; align-items: center; gap: 4px; }

.nav__link {
  position: relative;
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 12px;
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: var(--fs-sm);
  font-weight: 500;
  white-space: nowrap;
  transition: background-color var(--dur-fast);
}
.nav__link:hover { background: rgba(15, 23, 42, .06); }
.nav__link[aria-current] { font-weight: 600; }
.nav__link[aria-current]::after {
  content: '';
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 8px;
  height: 2px;
  border-radius: 1px;
  background: var(--accent);
}

.nav__toggle { display: none; }

@media (min-width: 560px) {
  .nav__link { font-size: var(--fs-ui); }
}

/* --- phone: disclosure menu (with JavaScript) ------------------------------ */
@media (max-width: 479.98px) {
  .js .nav__toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 44px;
    margin-right: -12px;
    padding: 0 12px;
    border: 0;
    border-radius: var(--radius-sm);
    background: none;
    color: var(--text);
    font-size: var(--fs-ui);
    font-weight: 500;
    cursor: pointer;
  }
  .js .nav__toggle:hover { background: rgba(15, 23, 42, .06); }
  .nav__toggle .icon line { transition: transform var(--dur) var(--ease-out), opacity var(--dur-fast); transform-origin: 8px 8px; }
  .nav__toggle[aria-expanded='true'] .icon line:nth-child(1) { transform: translateY(4px) rotate(45deg); }
  .nav__toggle[aria-expanded='true'] .icon line:nth-child(2) { opacity: 0; }
  .nav__toggle[aria-expanded='true'] .icon line:nth-child(3) { transform: translateY(-4px) rotate(-45deg); }

  .js .nav__menu {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    display: none;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
    box-shadow: var(--shadow-2);
  }
  .js .nav.is-open .nav__menu {
    display: flex;
    animation: menu-in 160ms var(--ease-out);
  }
  .js .nav__menu li + li { border-top: 1px solid var(--border); }
  .js .nav__link {
    width: 100%;
    min-height: 48px;
    padding: 0 var(--gutter);
    border-radius: 0;
    font-size: var(--fs-md);
  }
  .js .nav__link[aria-current]::after {
    left: 0;
    right: auto;
    top: 10px;
    bottom: 10px;
    width: 3px;
    height: auto;
  }

  /* Without JavaScript: no button, the links sit in a second row. */
  html:not(.js) .nav__inner { flex-wrap: wrap; gap: 0; }
  html:not(.js) .nav__nav { flex: 0 0 100%; }
  html:not(.js) .nav__menu { justify-content: space-between; gap: 0; margin-inline: -6px; }
  html:not(.js) .nav__link { padding: 0 6px; }
  html:not(.js) .nav__link[aria-current]::after { left: 6px; right: 6px; }
}

@keyframes menu-in {
  from { opacity: 0; transform: translateY(-4px); }
}

/* --- footer ---------------------------------------------------------------- */
.footer {
  flex: none;
  border-top: 1px solid var(--border);
  background: var(--surface);
}
.footer__inner {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  padding-block: 24px;
}
.footer__copy { color: var(--text-muted); font-size: var(--fs-sm); }
.footer__links { display: flex; flex-wrap: wrap; gap: 0 20px; }
.footer__links a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  color: var(--text-muted);
  font-size: var(--fs-sm);
  font-weight: 500;
  transition: color var(--dur-fast);
}
.footer__links a:hover { color: var(--text); }

@media (min-width: 480px) {
  .footer__inner {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    padding-block: 20px;
  }
}

/* ==========================================================================
   40 home: the hero (the one place the gradient runs at full strength),
   the Selected work grid, and Contact.
   ========================================================================== */

/* --- hero ------------------------------------------------------------------ */
.hero {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  overflow: clip;
  /* slide under the glass navbar so the gradient shows through it */
  margin-top: calc(-1 * var(--nav-h) - 1px);
  padding-top: calc(var(--nav-h) + 1px);
}

/* The wash: five soft orbs, masked so the hero ends on solid --bg. The hero
   runs the palette richer than the tokens (which also feed the quiet index
   band): the same five hues, more saturated. */
.hero__wash {
  --orb-blue: #6f9eff;
  --orb-violet: #a58cff;
  --orb-pink: #ff8fb6;
  --orb-peach: #ffb866;
  --orb-mint: #6fdcb2;
  --orb-opacity: .9;
  position: absolute;
  inset: 0;
  z-index: -2;
  pointer-events: none;
  -webkit-mask-image: linear-gradient(to bottom, #000 0, #000 62%, transparent 100%);
  mask-image: linear-gradient(to bottom, #000 0, #000 62%, transparent 100%);
}
.orb {
  --c: var(--orb-blue);
  --d: 420px;
  position: absolute;
  width: var(--d);
  aspect-ratio: 1;
  border-radius: 50%;
  translate: -50% -50%;
  opacity: var(--orb-opacity);
  background: radial-gradient(closest-side, var(--c), transparent);
  /* eased falloff, so no orb shows a hot centre or a visible edge */
  background: radial-gradient(closest-side,
    var(--c) 0,
    color-mix(in srgb, var(--c) 86%, transparent) 26%,
    color-mix(in srgb, var(--c) 52%, transparent) 54%,
    color-mix(in srgb, var(--c) 16%, transparent) 80%,
    transparent 100%);
}
/* Phone: the colour gathers along the top, around the portrait. */
.orb--blue   { --c: var(--orb-blue);   left: 6%;   top: 2%; }
.orb--violet { --c: var(--orb-violet); left: 82%;  top: 20%; }
.orb--pink   { --c: var(--orb-pink);   left: 46%;  top: -6%; --d: 340px; }
.orb--peach  { --c: var(--orb-peach);  left: 104%; top: 58%; --d: 360px; }
.orb--mint   { --c: var(--orb-mint);   left: -12%; top: 50%; --d: 280px; }

/* The scrim calms the colour behind the text. All hero text is --text, which
   passes AA on the bare wash; the scrim is for comfort, not rescue. */
.hero__scrim {
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background: linear-gradient(to bottom, transparent 0, transparent 120px, var(--scrim) 200px);
}

.hero__inner {
  display: grid;
  gap: 20px;
  position: relative;
  padding-block: 24px 40px;
}
.hero__portrait {
  order: -1;
  width: 96px;
  padding: 2px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--orb-blue), var(--orb-violet), var(--orb-pink));
}
.hero__portrait img {
  width: 100%;
  aspect-ratio: 1;
  border: 3px solid var(--bg);
  border-radius: 50%;
  background: var(--surface);
  object-fit: cover;
}

.hero__name {
  font-size: var(--fs-hero);
  line-height: 1.05;
  letter-spacing: var(--tracking-hero);
}
.hero__lede {
  max-width: 31ch;
  margin-top: 12px;
  color: var(--text);
  font-size: var(--fs-lede);
  line-height: 1.4;
  letter-spacing: -.012em;
}

/* Two role lines, tied together by a short gradient rule on the left. */
.hero__roles {
  position: relative;
  display: grid;
  gap: 2px;
  margin-top: 20px;
  padding-left: 16px;
  color: var(--text);
  font-size: var(--fs-sm);
  font-weight: 500;
  line-height: 1.5;
}
@media (min-width: 360px) {
  .hero__roles { font-size: var(--fs-ui); }
}
.hero__roles::before {
  content: '';
  position: absolute;
  left: 0;
  top: 4px;
  bottom: 4px;
  width: 3px;
  border-radius: 2px;
  background: linear-gradient(180deg, var(--orb-blue), var(--orb-violet), var(--orb-pink));
}
.hero__roles b { font-weight: 600; }

.hero__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  margin-top: 24px;
}
.hero__links {
  display: flex;
  flex-wrap: wrap;
  flex-basis: 100%;
  gap: 0 20px;
}

/* Pause / play for the background drift. Shown by site.js.
   A 44px target around a 34px disc; the disc lines up with the content edge. */
.hero__motion {
  position: absolute;
  right: calc(var(--gutter) - 5px);
  top: 50px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--text-muted);
  cursor: pointer;
  transition: color var(--dur-fast);
}
.hero__motion::before {
  content: '';
  position: absolute;
  inset: 5px;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: rgba(255, 255, 255, .9);
  box-shadow: var(--shadow-1);
  transition: border-color var(--dur-fast);
}
.hero__motion:hover { color: var(--text); }
.hero__motion:hover::before { border-color: var(--border-strong); }
.hero__motion .icon { position: relative; width: 12px; height: 12px; fill: currentColor; stroke: none; }
.hero__motion .icon--play,
.hero__motion[aria-pressed='true'] .icon--pause { display: none; }
.hero__motion[aria-pressed='true'] .icon--play { display: block; }

@media (min-width: 768px) {
  /* Wide screens: the colour runs edge to edge, cool at the top left, warm
     through the middle, violet and pink behind the portrait. */
  .hero__wash {
    background: linear-gradient(100deg, #dfe9ff 0%, #e9e2ff 36%, #ffe4ee 66%, #ffeeda 100%);
    -webkit-mask-image: linear-gradient(to bottom, #000 0, #000 68%, transparent 100%);
    mask-image: linear-gradient(to bottom, #000 0, #000 68%, transparent 100%);
  }
  .orb { --d: clamp(560px, 60vw, 1000px); aspect-ratio: 3 / 2; }
  .orb--blue   { left: 6%;   top: 4%; }
  .orb--mint   { left: 22%;  top: 104%; --d: clamp(460px, 50vw, 840px); }
  .orb--violet { left: 44%;  top: 6%;  --d: clamp(480px, 52vw, 880px); }
  .orb--pink   { left: 74%;  top: 70%; }
  .orb--peach  { left: 100%; top: 10%; --d: clamp(460px, 50vw, 840px); }

  .hero__scrim {
    background: linear-gradient(90deg, var(--scrim) 0, var(--scrim) 40%, rgba(248, 250, 252, 0) 74%);
  }
  .hero__inner {
    grid-template-columns: repeat(8, minmax(0, 1fr));
    align-items: center;
    column-gap: 24px;
    padding-block: 56px 80px;
  }
  .hero__copy { grid-column: 1 / 6; }
  .hero__portrait {
    order: 0;
    grid-column: 6 / 9;
    justify-self: center;
    width: 200px;
    padding: 3px;
  }
  .hero__portrait img { border-width: 4px; }
  .hero__lede { margin-top: 16px; }
  .hero__roles { font-size: var(--fs-base); }
  .hero__actions { margin-top: 32px; }
  .hero__motion { top: auto; bottom: 19px; }
}

@media (min-width: 1024px) {
  .hero__inner {
    grid-template-columns: repeat(12, minmax(0, 1fr));
    column-gap: 32px;
    padding-block: 80px 88px;
  }
  .hero__copy { grid-column: 1 / 8; }
  .hero__portrait { grid-column: 9 / 13; width: 280px; }
  .hero__links {
    flex-basis: auto;
    margin-left: 4px;
    padding-left: 16px;
    border-left: 1px solid var(--border-strong);
  }
}

/* Drift: transform only, opacity never changes, so the measured worst-case
   contrast always holds. Runs only with JavaScript and without a
   reduced-motion preference; otherwise the same picture, still. */
@media (prefers-reduced-motion: no-preference) {
  .js .orb { animation: drift 28s ease-in-out infinite alternate; }
  .js .orb--blue { animation-duration: 24s; }
  .js .orb--pink { animation-duration: 32s; animation-direction: alternate-reverse; }
  .js .orb--peach { animation-duration: 36s; }
  .js .orb--mint { animation-duration: 40s; animation-direction: alternate-reverse; }
  .js .hero.is-paused .orb { animation-play-state: paused; }
}
@media (prefers-reduced-motion: reduce) {
  .hero__motion { display: none !important; }
}
@keyframes drift {
  from { transform: translate(-3%, 2%) scale(1); }
  to { transform: translate(5%, -4%) scale(1.1); }
}

.hero + .section { padding-top: clamp(32px, 5vw, 64px); }

/* --- Selected work: one wide tile, two below ------------------------------- */
.tiles { display: grid; gap: 20px; }
@media (min-width: 768px) {
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px; }
  .tiles > .tile--wide { grid-column: 1 / -1; }
}
@media (min-width: 1024px) {
  .tiles { gap: 32px; }
}

/* --- Contact --------------------------------------------------------------- */
.contact {
  max-width: 760px;
  margin-inline: auto;
  text-align: center;
}
.contact .section__title::after { margin-inline: auto; }
.contact__text {
  margin-top: 20px;
  color: var(--text-muted);
  font-size: 1.125rem;
  line-height: 1.55;
}
.contact__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  margin-top: 28px;
}
.contact__note {
  margin-top: 20px;
  color: var(--text-subtle);
  font-size: var(--fs-sm);
}

/* ==========================================================================
   50 entry: the parts of an entry page. Header, facts, link buttons, hero
   media, at-a-glance numbers, credits note, previous / next.
   The page shell and its two widths are in 52-docs.css; the body copy is
   .prose (80-prose-media.css). No gradient on these pages.
   ========================================================================== */

.entry { padding-bottom: var(--section-y); }

/* --- header ---------------------------------------------------------------- */
.entry-head { padding-top: 12px; }
.back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  margin-left: -2px;
  color: var(--text-muted);
  font-size: var(--fs-sm);
  font-weight: 500;
  transition: color var(--dur-fast);
}
.back:hover { color: var(--text); }
.back .icon { transition: transform var(--dur) var(--ease-std); }
.back:hover .icon { transform: translateX(-3px); }

.entry-head .kind { margin-top: 16px; }
.entry-title {
  margin-top: 12px;
  font-size: clamp(1.875rem, 1.5rem + 1.7vw, 2.5rem);
  line-height: 1.12;
}
.entry-summary {
  margin-top: 16px;
  color: var(--text-muted);
  font-size: clamp(1.125rem, 1.05rem + .3vw, 1.25rem);
  line-height: 1.5;
}

/* --- facts: Role / Period / Context / Status, two by two ---------------------- */
.facts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px 32px;
  margin-top: 28px;
  padding: 18px 0;
  border-block: 1px solid var(--border);
}
.facts dt {
  color: var(--text-subtle);
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
}
.facts dd {
  margin-top: 4px;
  color: var(--text);
  font-size: var(--fs-ui);
  font-weight: 500;
  line-height: 1.4;
  text-wrap: pretty;
}
.facts dd a { text-decoration: underline; text-decoration-color: var(--border-strong); text-underline-offset: 3px; }
.facts dd a:hover { text-decoration-color: currentColor; }

/* --- link buttons ----------------------------------------------------------- */
.entry-links { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 24px; }

/* --- hero media: the full article column -------------------------------------- */
.entry-hero { margin-top: 36px; }
.entry-hero__frame {
  overflow: hidden;
  border: 1px solid var(--media-edge);
  border-radius: var(--radius-lg);
  background: var(--surface-2);
}
.entry-hero__frame img,
.entry-hero__frame video { width: 100%; }
.entry-hero__frame:not(.entry-hero__frame--figure) > :is(picture, img, video),
.entry-hero__frame:not(.entry-hero__frame--figure) > picture > img {
  aspect-ratio: var(--hero-ratio, 16 / 9);
  object-fit: cover;
}
/* a figure, screenshot or svg as the hero: whole, on white, at its own ratio
   (from the img's width and height attributes, so its box is there before
   the file is) */
.entry-hero__frame--figure { padding: clamp(10px, 2.5vw, 24px); background: var(--surface); }
.entry-hero figcaption { margin-top: 12px; }

/* A strip of frames (eight pressure maps in a row). On a phone the strip is
   shown as two rows of frames at twice the size: .strip__row is a window on
   the same image (hero.ejs sets each window from the strip's geometry), so
   every frame, label and scale is there and nothing is squeezed. */
.strip__rows { display: none; }
@media (max-width: 599.98px) {
  .entry-hero__frame--strip > picture,
  .entry-hero__frame--strip > img { display: none; }
  .strip__rows { display: grid; gap: 4px; }
  .strip__row { overflow: hidden; }
  .entry-hero__frame--figure .strip__row img { max-width: none; }
}

/* a strip without that geometry scrolls sideways at a readable height */
.entry-hero__hint { display: none; }
@media (max-width: 767.98px) {
  .entry-hero__frame--pan {
    overflow-x: auto;
    overscroll-behavior-x: contain;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
  }
  .entry-hero__frame--pan img {
    width: auto;
    max-width: none;
    height: clamp(240px, 72vw, 320px);
  }
  .entry-hero__hint {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 10px;
    color: var(--text-muted);
    font-size: var(--fs-xs);
    font-weight: 600;
  }
  .entry-hero__hint + figcaption { margin-top: 6px; }
}

/* --- at a glance ----------------------------------------------------------------
   A grid of ruled cells at the text measure: number, then what it measures.
   Four numbers sit two by two, so the longest value ("0.10–0.15 m/s") has a
   line to itself at every width. Every value is one line, so the labels of
   a row start on the same line. */
.glance {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 clamp(16px, 5vw, 32px);
  margin-top: 36px;
}
.glance__item {
  padding: 16px 0 22px;
  border-top: 1px solid var(--border);
}
.glance__value {
  display: block;
  color: var(--text);
  font-size: clamp(1.75rem, 1.3rem + 2vw, 2.25rem);
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -.03em;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
/* the longest value sets the size of the whole grid (glance.ejs), so the
   numbers of a page share one size and each still fits its cell on a phone */
.glance--compact .glance__value { font-size: clamp(1.5rem, 1rem + 2.2vw, 2.125rem); }
.glance--tight .glance__value { font-size: clamp(1.25rem, .62rem + 2.9vw, 2rem); }
@media (max-width: 359.98px) {
  .glance--tight { grid-template-columns: minmax(0, 1fr); }
}
.glance__unit { margin-left: .14em; font-size: .52em; font-weight: 600; letter-spacing: -.01em; }
.glance__label {
  display: block;
  max-width: 30ch;
  margin-top: 8px;
  color: var(--text-muted);
  font-size: var(--fs-sm);
  line-height: 1.45;
  text-wrap: pretty;
}
/* three numbers: on a phone the third takes the full second row, so it does
   not sit alone in half of one; from 600px all three share one row */
.glance > :nth-child(3):last-child { grid-column: 1 / -1; }
.glance > :nth-child(3):last-child .glance__label { max-width: none; }
@media (min-width: 600px) {
  .glance:has(> :nth-child(3):last-child) { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .glance > :nth-child(3):last-child { grid-column: auto; }
  .glance > :nth-child(3):last-child .glance__label { max-width: 30ch; }
}

/* --- body column -------------------------------------------------------------- */
.entry-body { margin-top: clamp(40px, 6vw, 64px); }

/* --- credits note -------------------------------------------------------------- */
.credits {
  margin-top: 56px;
  padding: 20px 24px;
  border-radius: var(--radius);
  background: var(--surface-2);
}
.credits__label {
  color: var(--text-subtle);
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: var(--tracking-label);
  line-height: 1.4;
  text-transform: uppercase;
}
.credits__body {
  margin-top: 8px;
  color: var(--text-muted);
  font-size: var(--fs-ui);
  line-height: 1.6;
}
.credits__body li + li,
.credits__body p + p { margin-top: 2px; }
.credits__body a { text-decoration: underline; text-underline-offset: 3px; }

/* --- previous / next -------------------------------------------------------------- */
.pager {
  display: grid;
  gap: 12px;
  margin-top: 48px;
}
.pager__cell {
  display: block;
  padding: 18px 22px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  transition: border-color var(--dur) var(--ease-std), box-shadow var(--dur) var(--ease-std);
}
.pager__label {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-subtle);
  font-size: var(--fs-xs);
  font-weight: 500;
}
.pager__title {
  display: block;
  margin-top: 4px;
  color: var(--text);
  font-size: 1.0625rem;
  font-weight: 600;
  line-height: 1.35;
  letter-spacing: -.01em;
}
.pager__cell--next { order: -1; }
@media (hover: hover) {
  .pager__cell:hover { border-color: var(--border-strong); box-shadow: var(--shadow-1); }
}

@media (min-width: 768px) {
  .entry-head { padding-top: 20px; }
  .facts { margin-top: 32px; padding: 20px 0; }
  .facts dd { font-size: var(--fs-base); }
  .entry-hero { margin-top: 40px; }
  .glance { margin-top: 44px; }

  .pager { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
  .pager__cell--next { order: 0; grid-column: 2; text-align: right; }
  .pager__cell--next .pager__label { justify-content: flex-end; }
}

/* ==========================================================================
   52 docs: an entry page laid out as a page of documentation (post.ejs).

     .docs            the shell, on the site container
       .docs-nav      left, from 1264px: every entry of the site
       .entry         centre: the article
       .docs-toc      right, from 1024px: "On this page"

   The article column has two widths. Text sits at --measure (40rem); the
   hero, "wide" figures and rows use the whole column (--wide, 48rem). Text
   blocks are centred in the column, so all text shares one left edge and
   wide media overhang it by the same amount on both sides.

     below 1024px   one column, at most --wide; "On this page" is a
                    disclosure on the back link's row
     1024-1263px    article + right sidebar
     from 1264px    left sidebar + article + right sidebar (176 / 768 / 176)
   ========================================================================== */

.docs {
  --measure: 40rem;
  --wide: 48rem;
  --side: 176px;
  --stick: calc(var(--nav-h) + 28px);
}
.entry {
  min-width: 0;
  max-width: var(--wide);
  margin-inline: auto;
}
.docs-nav,
.docs-toc { display: none; }

/* text blocks of the article: the measure, centred in the column */
.entry-head,
.entry > .glance,
.entry-body > .credits,
.entry-body > .pager,
.entry-body .prose > * {
  max-width: var(--measure);
  margin-inline: auto;
}
.entry-body .prose { max-width: none; }

/* The caption of media wider than the text (the hero, a wide figure, a
   diagram, a wide row) starts on the text's left edge, not the media's, so
   every line of words on the page shares one edge. */
.entry-hero > figcaption,
.entry-body .prose > .figure--wide > figcaption {
  max-width: var(--measure);
  margin-inline: auto;
  padding-right: max(0px, min(100%, var(--measure)) - 64ch);
}
.entry-body .prose > .figure-row.figure--wide > figcaption {
  --over: max(0px, (100% - var(--measure)) / 2);
  max-width: none;
  margin-inline: 0;
  padding-left: var(--over);
  padding-right: max(0px, 100% - var(--over) - 64ch);
}

/* --- sidebars ---------------------------------------------------------------- */
.docs-nav,
.docs-toc {
  position: sticky;
  top: var(--stick);
  max-height: calc(100vh - var(--stick) - 24px);
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  margin-top: 36px;
  padding-bottom: 8px;
  font-size: var(--fs-sm);
  line-height: 1.4;
}
.docs-nav__label,
.docs-toc__label {
  color: var(--text);
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
}
.docs-nav__label a:hover { color: var(--accent); }
.docs-nav__group + .docs-nav__group { margin-top: 28px; }

/* one hairline down the list; the current item draws the accent bar over it */
.docs-nav ul,
.toc {
  margin-top: 10px;
  border-left: 1px solid var(--border);
}
.docs-nav li a,
.toc a {
  display: block;
  margin-left: -1px;
  padding: 6px 0 6px 14px;
  border-left: 2px solid transparent;
  color: var(--text-muted);
  text-wrap: pretty;
  transition: color var(--dur-fast), border-color var(--dur-fast);
}
.docs-nav li a:hover,
.toc a:hover { color: var(--text); border-left-color: var(--border-strong); }
.docs-nav li a[aria-current],
.toc a.is-active {
  border-left-color: var(--accent);
  color: var(--accent);
}
/* the weight changes only on the static list: a link of "On this page" that
   turned bold while the page scrolls could re-wrap and move the links under it */
.docs-nav li a[aria-current] { color: var(--text); font-weight: 600; }
.toc ol a { padding-left: 28px; font-size: var(--fs-xs); }
.toc a:focus-visible,
.docs-nav a:focus-visible { outline-offset: -3px; }

/* --- "On this page" as a disclosure (below 1024px) --------------------------- */
.entry-top {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.toc-inline summary {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  margin-right: -2px;
  color: var(--text-muted);
  font-size: var(--fs-sm);
  font-weight: 500;
  list-style: none;
  cursor: pointer;
  user-select: none;
}
.toc-inline summary::-webkit-details-marker { display: none; }
.toc-inline summary:hover { color: var(--text); }
.toc-inline summary .icon { transition: transform var(--dur) var(--ease-std); }
.toc-inline[open] summary { color: var(--text); }
.toc-inline[open] summary .icon { transform: rotate(180deg); }
.toc-inline nav {
  position: absolute;
  top: 100%;
  right: 0;
  z-index: 20;
  width: min(100%, 340px);
  max-height: min(70vh, 480px);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 6px 16px 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-2);
  font-size: var(--fs-ui);
  line-height: 1.4;
}
.toc-inline .toc { margin-top: 6px; }
.toc-inline .toc a { padding-block: 9px; }
.toc-inline .toc ol a { font-size: var(--fs-sm); }

/* --- "#" link on every h2 and h3 --------------------------------------------- */
.hlink {
  margin-left: .35em;
  padding: 0 .15em;
  border-radius: var(--radius-xs);
  color: var(--accent);
  font-weight: 500;
  letter-spacing: 0;
  opacity: 0;
  transition: opacity var(--dur-fast);
}
h2:hover > .hlink,
h3:hover > .hlink,
.hlink:focus-visible { opacity: 1; }
/* the heading a link has just jumped to */
.prose :is(h2, h3):target > .hlink { opacity: .55; }

@media (min-width: 1024px) {
  .docs {
    display: grid;
    grid-template-columns: minmax(0, var(--wide)) var(--side);
    justify-content: space-between;
    align-items: start;
    column-gap: 40px;
  }
  .entry { max-width: none; margin: 0; }
  .docs-toc { display: block; }
  .toc-inline { display: none; }
}

@media (min-width: 1264px) {
  .docs { grid-template-columns: var(--side) minmax(0, var(--wide)) var(--side); }
  .docs-nav { display: block; }
}

/* ==========================================================================
   53 masthead: header of an entry that has front-matter `masthead`.
   A transparent cut-out is enlarged into a backdrop layer behind the title
   block on the normal page background. Only the cut-out and the title block
   move, and only with scroll (first viewport height): the cut-out zooms in,
   then out and fades; the CSS scroll timeline where supported, --p set by
   site.js elsewhere. Static under reduced motion.
   ========================================================================== */

.masthead {
  --p: 0;
  position: relative;
  isolation: isolate;
  overflow-x: clip;
  --mh-art: clamp(300px, 80vw, 460px);
  margin-top: 8px;
  padding: 28px 0 calc(var(--mh-art) + var(--mh-gap, 20px));
}
.masthead__text { position: relative; z-index: 2; max-width: 30em; }
.masthead__art {
  position: absolute;
  z-index: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  height: var(--mh-art);
  pointer-events: none;
  transform-origin: 60% 60%;
}
.masthead__img { position: absolute; display: block; min-width: 0; }
.masthead__img img { display: block; width: 100%; height: auto; max-height: 100%; object-fit: contain; background: none !important; }
.masthead__img--front { right: 0; bottom: 0; width: 100%; height: 100%; }
.masthead__img--front img { width: 100%; height: 100%; object-position: 70% 100%; }
.masthead__art--pair .masthead__img--front { width: 72%; height: 100%; right: 0; z-index: 1; }
.masthead__art--pair .masthead__img--back { width: 40%; height: 62%; left: 8%; bottom: 0; z-index: 0; }
.masthead__art--pair .masthead__img img { object-position: 50% 100%; }

@media (min-width: 640px) { .masthead { --mh-gap: 28px; --mh-art: clamp(380px, 60vw, 480px); } .masthead__text { max-width: 36em; } }
@media (min-width: 1024px) { .masthead { --mh-art: 460px; padding-top: 36px; } }

/* scroll 0 to the first viewport height: zoom in (1 to 1.15), then out (0.9), fading as it leaves */
.masthead__art { transform: scale(var(--s, 1)); opacity: var(--o, 1); will-change: transform, opacity; }
.masthead__text { transform: translateY(calc(var(--p) * -28px)); }

@keyframes masthead-art  {
  0%   { transform: scale(1);    opacity: 1; }
  45%  { transform: scale(1.15); opacity: 1; }
  100% { transform: scale(.9);   opacity: .45; }
}
@keyframes masthead-text { to { transform: translateY(-28px); } }
@supports (animation-timeline: scroll()) {
  .masthead__art  { animation: masthead-art linear both; animation-timeline: scroll(root); animation-range: 0 100vh; }
  .masthead__text { animation: masthead-text linear both; animation-timeline: scroll(root); animation-range: 0 100vh; }
}

@media (prefers-reduced-motion: reduce) {
  .masthead__art,
  .masthead__text { animation: none; transform: none; opacity: 1; will-change: auto; }
}
@media print {
  .masthead { padding-bottom: 0; }
  .masthead__art { display: none; }
}

/* ==========================================================================
   55 cards: every listing component.
   .tile          feature tile and project card (modifier --wide)
   .row           research row
   .pubs / .pub   publications
   .side-card     side-project card       .side-line   side-project one-liner
   Whole-component links use one stretched ::after on the title link; any
   second link inside sits above it with position:relative; z-index:1.
   ========================================================================== */

/* --- tile ------------------------------------------------------------------ */
.tile {
  position: relative;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  transition: border-color var(--dur) var(--ease-std), box-shadow var(--dur) var(--ease-std), transform var(--dur) var(--ease-std);
}
.tile__media {
  flex: none;
  aspect-ratio: 3 / 2;
  overflow: hidden;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}
.tile__media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform var(--dur-slow) var(--ease-out);
}
/* a drawn diagram instead of a photo: shown whole, on a quiet field */
.tile__media--diagram { padding: 4%; }
.tile__media--diagram img { object-fit: contain; }
/* a figure (chart, rendered data, screenshot): shown whole on white, never cropped */
.tile__media--figure,
.row__thumb--figure { background: var(--surface); }
.tile__media--figure img,
.row__thumb--figure img { object-fit: contain; }

.tile__body {
  display: flex;
  flex: 1;
  flex-direction: column;
  align-items: flex-start;
  padding: 20px;
}
.tile__title {
  margin-top: 10px;
  font-size: 1.375rem;
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: -.02em;
}
.tile__title a::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
}
.tile__title a:focus-visible { outline: none; }
.tile__title a:focus-visible::after { outline: 3px solid var(--focus); outline-offset: -3px; }
.tile__summary {
  margin-top: 8px;
  color: var(--text-muted);
  font-size: var(--fs-base);
  line-height: 1.5;
}
.tile__facts {
  margin-top: 10px;
  color: var(--text-subtle);
  font-size: var(--fs-sm);
}
.tile .chips { margin-top: 16px; }
.tile__more { margin-top: auto; padding-top: 18px; }

@media (hover: hover) {
  .tile:hover { border-color: var(--border-strong); box-shadow: var(--shadow-2); transform: translateY(-2px); }
  .tile:hover .tile__media img { transform: scale(1.03); }
  .tile:hover .tile__media--diagram img,
  .tile:hover .tile__media--figure img { transform: none; }
  .tile:hover .more .icon,
  .row:hover .more .icon { transform: translateX(3px); }
}

@media (min-width: 768px) {
  .tile__media { aspect-ratio: 4 / 3; }
  .tile__title { font-size: var(--fs-lg); }
  .tile--wide .tile__media { aspect-ratio: 16 / 9; }
  .tile--wide .tile__body { padding: 28px; }
  .tile--wide .tile__title { font-size: 1.75rem; letter-spacing: -.025em; }
  .tile--wide .tile__summary { font-size: var(--fs-md); max-width: 62ch; }
}

@media (min-width: 1024px) {
  .tile__media { aspect-ratio: 16 / 10; }
  .tile__body { padding: 24px 28px 28px; }
  .tile__title { font-size: var(--fs-xl); }
  .tile__summary { font-size: var(--fs-md); }

  .tile--wide { display: grid; grid-template-columns: 7fr 5fr; }
  .tile--wide .tile__media { position: relative; aspect-ratio: auto; min-height: 440px; border-bottom: 0; border-right: 1px solid var(--border); }
  .tile--wide .tile__media img { position: absolute; inset: 0; }
  .tile--wide .tile__body { justify-content: center; padding: clamp(32px, 4vw, 48px); }
  .tile--wide .tile__title { font-size: clamp(1.625rem, .7rem + 1.45vw, 2rem); line-height: 1.15; }
  .tile--wide .tile__more { margin-top: 0; padding-top: 24px; }
}

/* grid of project cards */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(340px, 100%), 1fr));
  gap: 20px;
}
@media (min-width: 768px) {
  .card-grid { gap: 24px; }
}
@media (min-width: 1024px) {
  .card-grid { gap: 32px; }
}

/* --- research row ----------------------------------------------------------
   Phone: thumbnail and title side by side, then the meta line, the summary
   and a footer line (Read more left, outside links right), each the full
   width. The body wrapper is unboxed with display:contents so its children
   join the row grid.
   From 768px: thumbnail | body, and from 1024px: thumbnail | body | arrow. */
.rows { border-bottom: 1px solid var(--border); }
.row {
  position: relative;
  isolation: isolate;
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr);
  column-gap: 14px;
  align-items: start;
  padding: 22px 0;
  border-top: 1px solid var(--border);
}
/* hover field, drawn outside the flow so the hairlines never move */
.row::before {
  content: '';
  position: absolute;
  inset: 1px -16px 0;
  z-index: -1;
  border-radius: var(--radius);
  background: var(--surface);
  opacity: 0;
  transition: opacity var(--dur) var(--ease-std);
}
.row__thumb {
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border: 1px solid var(--media-edge);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}
.row__thumb img { width: 100%; height: 100%; object-fit: cover; }
.row__thumb--diagram { padding: 7%; }
.row__thumb--diagram img { object-fit: contain; }

.row__meta {
  color: var(--text-subtle);
  font-size: var(--fs-xs);
  line-height: 1.5;
  font-variant-numeric: tabular-nums;
}
.row__meta .status { margin-left: 6px; }
.row__title {
  font-size: 1.125rem;
  font-weight: 600;
  line-height: 1.28;
  letter-spacing: -.015em;
}
.row__title a::after { content: ''; position: absolute; inset: 0; }
.row__title a:focus-visible { outline: none; }
.row__title a:focus-visible::after { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: var(--radius-sm); }
.row__summary {
  max-width: 70ch;
  color: var(--text-muted);
  font-size: var(--fs-ui);
  line-height: 1.55;
}
.row__links { display: flex; flex-wrap: wrap; gap: 0 16px; }
.row__link {
  position: relative;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 44px;
  color: var(--accent);
  font-size: var(--fs-sm);
  font-weight: 600;
}
.row__link:hover { color: var(--accent-hover); text-decoration: underline; text-underline-offset: 3px; }

/* a row with no thumbnail */
.row--text { grid-template-columns: minmax(0, 1fr); }

@media (hover: hover) {
  .row:has(.row__title a):hover::before { opacity: 1; }
}

@media (max-width: 767.98px) {
  .row__body { display: contents; }
  .row__thumb { grid-area: 1 / 1; }
  .row__title { grid-area: 1 / 2; align-self: center; }
  .row--text .row__title { grid-column: 1; }
  .row__meta { grid-area: 2 / 1 / auto / -1; margin-top: 14px; }
  .row__summary { grid-area: 3 / 1 / auto / -1; margin-top: 4px; }
  /* footer line: both sit on grid row 4 */
  .row__links { grid-area: 4 / 1 / auto / -1; justify-self: end; margin-top: 2px; }
  .row__more { grid-area: 4 / 1 / auto / -1; justify-self: start; align-self: center; margin-top: 12px; }
  .row:has(.row__links) .row__more { margin-top: 2px; }
  .row:not(:has(.row__more)) .row__links { justify-self: start; }
}
@media (min-width: 360px) and (max-width: 767.98px) {
  .row { grid-template-columns: 104px minmax(0, 1fr); column-gap: 16px; }
}

@media (min-width: 768px) {
  .row { grid-template-columns: 160px minmax(0, 1fr); column-gap: 24px; padding: 28px 0; }
  .row__thumb { grid-row: 1 / span 2; border-radius: var(--radius); }
  .row__meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 10px;
    font-size: var(--fs-sm);
    line-height: 1.45;
  }
  .row__meta .status { margin-left: 0; }
  .row__title { margin-top: 4px; font-size: 1.25rem; line-height: 1.3; }
  .row__summary { margin-top: 6px; font-size: var(--fs-base); }
  .row__links { margin-top: 2px; }
  .row__more { grid-column: 2; margin-top: 6px; }
  .row__body:has(.row__links) + .row__more { margin-top: 0; }
  .row--text .row__more { grid-column: 1; }
}
@media (min-width: 1024px) {
  .row { grid-template-columns: 200px minmax(0, 1fr) auto; column-gap: 32px; align-items: center; }
  .row__thumb { grid-row: auto; }
  .row__title { font-size: 1.375rem; }
  .row__more,
  .row__body:has(.row__links) + .row__more { grid-column: auto; margin-top: 0; white-space: nowrap; }
  .row--text { grid-template-columns: minmax(0, 1fr) auto; }
  .row--text .row__more { grid-column: auto; }

  /* research index: larger rows carrying the full summary */
  .rows--large .row { grid-template-columns: 280px minmax(0, 1fr) auto; column-gap: 40px; padding: 36px 0; }
  .rows--large .row__title { font-size: var(--fs-xl); letter-spacing: -.02em; }
  .rows--large .row__summary { font-size: var(--fs-md); }
}

/* --- publications ---------------------------------------------------------- */
.pubs-card {
  margin-top: var(--s-7);
  padding: 8px 24px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
}
.section__head + .pubs-card { margin-top: 0; }
.pubs-card__title {
  padding-top: 16px;
  font-size: var(--fs-lg);
  font-weight: 600;
  letter-spacing: -.015em;
}
.pub { padding: 20px 0; }
.pub + .pub { border-top: 1px solid var(--border); }
.pub__title {
  max-width: 62ch;
  color: var(--text);
  font-size: var(--fs-md);
  font-weight: 600;
  line-height: 1.4;
  letter-spacing: -.01em;
}
.pub__authors { margin-top: 4px; color: var(--text-muted); font-size: var(--fs-ui); }
.pub__authors strong { color: var(--text); }
.pub__venue { color: var(--text-subtle); font-size: var(--fs-ui); font-variant-numeric: tabular-nums; }
.pub__links { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }

@media (min-width: 768px) {
  .pubs-card { padding: 12px 32px; }
  .pub {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 0 32px;
    align-items: start;
    padding: 24px 0;
  }
  .pub__body { grid-column: 1; }
  /* the chip is taller than a title line: pull it up so the two share a centre */
  .pub__links { grid-column: 2; grid-row: 1; margin-top: -6px; }
}
@media (min-width: 768px) and (pointer: coarse) {
  .pub__links { margin-top: -10px; }
}

/* --- side projects --------------------------------------------------------- */
.side-grid { display: grid; gap: 16px; }
@media (min-width: 768px) {
  .side-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px; }
}
.side-card {
  position: relative;
  display: flex;
  flex-direction: column;
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  transition: border-color var(--dur) var(--ease-std), box-shadow var(--dur) var(--ease-std);
}
.side-card__name {
  color: var(--text);
  font-family: var(--font-mono);
  font-size: var(--fs-base);
  font-weight: 600;
  letter-spacing: -.01em;
  line-height: 1.4;
}
.side-card__summary {
  margin-top: 8px;
  color: var(--text-muted);
  font-size: var(--fs-ui);
  line-height: 1.55;
}
.side-card__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: auto;
  padding-top: 8px;
  color: var(--text-subtle);
  font-size: var(--fs-xs);
}
.repo {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 44px;
  color: var(--accent);
  font-size: var(--fs-ui);
  font-weight: 600;
  white-space: nowrap;
}
.repo:hover { color: var(--accent-hover); }
.side-card .repo::after { content: ''; position: absolute; inset: 0; }
.side-card .repo { position: static; }
@media (hover: hover) {
  .side-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow-1); }
}

.side-list { margin-top: 24px; border-bottom: 1px solid var(--border); }
.side-line {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0 16px;
  align-items: center;
  padding: 6px 0 14px;
  border-top: 1px solid var(--border);
}
.side-line__name {
  color: var(--text);
  font-family: var(--font-mono);
  font-size: var(--fs-ui);
  font-weight: 600;
  letter-spacing: -.01em;
}
.side-line .repo { grid-column: 2; grid-row: 1; }
.side-line__summary {
  grid-column: 1 / -1;
  color: var(--text-muted);
  font-size: var(--fs-ui);
  line-height: 1.55;
}
@media (min-width: 768px) {
  .side-line { grid-template-columns: 220px minmax(0, 1fr) auto; gap: 24px; padding: 6px 0; }
  .side-line__summary { grid-column: auto; }
  .side-line .repo { grid-column: auto; grid-row: auto; }
}

/* ==========================================================================
   60 section: index pages (/research/, /projects/), About and 404 share
   one page header with a static band of the hero palette behind the title.
   The band is pure CSS on ::before, so templates add no markup for it.
   Inside the band only --text and --text-muted are allowed (measured).
   ========================================================================== */

.page-head {
  position: relative;
  isolation: isolate;
  /* slide under the navbar, like the home hero */
  margin-top: calc(-1 * var(--nav-h) - 1px);
  padding-top: calc(var(--nav-h) + 1px + clamp(36px, 7vw, 72px));
  padding-bottom: clamp(28px, 5vw, 48px);
}
.page-head::before {
  content: '';
  position: absolute;
  inset: 0 0 auto;
  z-index: -1;
  height: 200px;
  opacity: var(--band-opacity);
  background:
    radial-gradient(52% 130% at 86% 0%, var(--orb-violet), transparent 72%),
    radial-gradient(60% 150% at 6% -20%, var(--orb-blue), transparent 72%),
    radial-gradient(34% 110% at 52% -30%, var(--orb-pink), transparent 72%),
    radial-gradient(30% 120% at 104% 70%, var(--orb-mint), transparent 72%),
    radial-gradient(30% 100% at 30% 60%, var(--orb-peach), transparent 72%);
  -webkit-mask-image: linear-gradient(to bottom, #000 0, #000 40%, transparent 100%);
  mask-image: linear-gradient(to bottom, #000 0, #000 40%, transparent 100%);
  pointer-events: none;
}
@media (min-width: 768px) {
  .page-head::before { height: 280px; }
}

.page-head__title {
  font-size: var(--fs-3xl);
  line-height: 1.08;
}
.page-head .lede { margin-top: 14px; }

/* index pages sit closer to their header than home sections do */
.page-head + .section { padding-top: clamp(8px, 2vw, 24px); }

/* 404: the same band, with the block centred under it */
.notfound {
  max-width: 560px;
  margin-inline: auto;
  padding-block: clamp(16px, 6vw, 72px) var(--s-8);
}
.notfound__code { color: var(--text-muted); font-size: var(--fs-sm); font-weight: 600; }
.notfound .page-head__title { margin-top: 6px; }
.notfound .entry-links { margin-top: 28px; }

/* ==========================================================================
   70 about and resume.
   ========================================================================== */

/* --- About: portrait column plus prose ------------------------------------- */
.about { display: grid; gap: 28px; }
.about__portrait {
  width: 160px;
  overflow: hidden;
  border: 1px solid var(--media-edge);
  border-radius: var(--radius-lg);
  background: var(--surface);
}
.about__portrait img { width: 100%; aspect-ratio: 1; object-fit: cover; }
.about__body { min-width: 0; max-width: var(--measure); }

.about__h {
  margin: 48px 0 16px;
  font-size: var(--fs-xl);
  letter-spacing: -.02em;
}

/* Now: a short dated list */
.now {
  margin-top: 40px;
  padding: 22px 24px 24px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}
.now__label {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 2px 10px;
  color: var(--text-subtle);
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
}
.now__label b { color: var(--text); font-weight: 700; }
.now__list { margin-top: 12px; }
.now__list li {
  position: relative;
  padding-left: 18px;
  color: var(--text-body);
  font-size: var(--fs-base);
  line-height: 1.55;
}
.now__list li + li { margin-top: 10px; }
.now__list li::before {
  content: '';
  position: absolute;
  left: 0;
  top: .62em;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--status-live);
}
.now__list b { color: var(--text); font-weight: 600; }

/* Earlier: organisation on the left, one line on the right */
.timeline { border-bottom: 1px solid var(--border); }
.timeline__row {
  display: grid;
  gap: 2px 16px;
  padding: 12px 0;
  border-top: 1px solid var(--border);
}
.timeline__org {
  color: var(--text);
  font-size: var(--fs-ui);
  font-weight: 600;
  line-height: 1.5;
}
.timeline__what { color: var(--text-muted); font-size: var(--fs-base); line-height: 1.5; }
.timeline__when { color: var(--text-subtle); font-size: var(--fs-sm); font-variant-numeric: tabular-nums; white-space: nowrap; }

@media (min-width: 600px) {
  .timeline__row { grid-template-columns: 248px minmax(0, 1fr); }
}
@media (min-width: 1024px) {
  .about { grid-template-columns: 280px minmax(0, 1fr); gap: 64px; align-items: start; }
  .about__portrait { position: sticky; top: calc(var(--nav-h) + 32px); width: 280px; }
}

/* --- Resume: the PDF, shown as one image per page --------------------------- */
/* Markup: .resume > .resume-head (title, date, button) + ol.resume-pages > li >
   a.resume-page > img. The owner updates the resume by replacing the PDF; the
   build renders its pages to images, so nothing here depends on the content. */
.resume { padding-block: clamp(32px, 6vw, 64px) var(--section-y); }

.resume-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px 24px;
}
.resume-head__title { font-size: clamp(2rem, 1.6rem + 1.6vw, 2.5rem); line-height: 1.1; }
.resume-head__updated,
.resume-head__hint { color: var(--text-muted); font-size: var(--fs-sm); line-height: 1.5; }
.resume-head__updated { margin-top: 8px; }
/* shown where there is no hover to reveal that the page is a link */
.resume-head__hint { display: none; }
@media (hover: none) {
  .resume-head__hint { display: block; }
}

/* the button takes its own full-width row on a phone, then sits right of the title */
.resume-head__actions { display: flex; flex: 1 0 100%; }
.resume-head__actions .btn { flex: 1 0 auto; }
@media (min-width: 480px) {
  .resume-head__actions { flex: 0 0 auto; }
}

/* N pages stacked with a small gap; each is a sheet of paper on the calm surface */
.resume-pages {
  display: grid;
  gap: 16px;
  margin-top: clamp(20px, 4vw, 32px);
}
.resume-page {
  position: relative;
  display: block;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  background: #fff;
  box-shadow: var(--shadow-2);
  cursor: zoom-in;
  transition: border-color var(--dur-fast), box-shadow var(--dur);
}
.resume-page:hover {
  border-color: var(--border-strong);
  box-shadow: 0 16px 40px rgba(15, 23, 42, .12), 0 2px 6px rgba(15, 23, 42, .05);
}
/* width and height attributes on the img reserve the sheet before it loads */
.resume-page img { width: 100%; }

/* ==========================================================================
   80 prose and media: rendered Markdown (.prose), the displayed equation,
   the media vocabulary of the figure / figures / videos / aside / diagram
   tags (themes/zerun/scripts/tags.js), tables, code, and the diagram
   classes (.dg-*).
   .prose expects flat children (h2, p, ul, figure, .table-wrap ...).
   Vertical rhythm uses margin-top only.

   Widths on an entry page (52-docs.css): text and plain figures at
   --measure, .figure--small at half of it, .figure--wide and wide rows at
   the full article column. On any other page .prose is one column.
   ========================================================================== */

.prose {
  max-width: var(--measure);
  margin-inline: auto;
  color: var(--text-body);
  font-size: var(--fs-md);
  line-height: 1.7;
}
.prose > * + * { margin-top: 1.2em; }

.prose h2 {
  font-size: clamp(1.5rem, 1.3rem + .8vw, 1.75rem);
  line-height: 1.2;
  letter-spacing: -.022em;
}
.prose > * + h2 { margin-top: 64px; }
.prose > h2 + * { margin-top: 16px; }
.prose h3 {
  font-size: var(--fs-lg);
  font-weight: 650;
  line-height: 1.3;
  letter-spacing: -.015em;
}
.prose > * + h3 { margin-top: 40px; }
.prose > h3 + * { margin-top: 10px; }
.prose > h2 + h3 { margin-top: 24px; }

/* a subscript or superscript in running text (p<sub>i</sub>, I²C) does not
   push its line apart from its neighbours */
.prose sub,
.prose sup,
figcaption sub,
figcaption sup { font-size: .75em; line-height: 0; }

/* a key term, bold where it is defined */
.prose strong { color: var(--text); font-weight: 650; }

/* Links in running text are always underlined: colour alone is 2.47:1
   against body text and cannot mark a link (WCAG 1.4.1). */
.prose a:not([class]) {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-decoration-color: var(--accent-underline);
  text-underline-offset: 3px;
}
.prose a:not([class]):hover { text-decoration-thickness: 2px; text-decoration-color: var(--accent); }

.prose ul,
.prose ol { padding-left: 1.5em; }
.prose ul { list-style: disc; }
.prose ol { list-style: decimal; }
.prose li { padding-left: .2em; }
.prose li + li { margin-top: .5em; }
.prose li > ul,
.prose li > ol { margin-top: .5em; }
.prose ul > li::marker { color: var(--border-control); }
.prose ol > li::marker { color: var(--text-muted); font-weight: 600; font-variant-numeric: tabular-nums; }

.prose hr,
hr.rule-line {
  height: 0;
  margin: 48px 0;
  border: 0;
  border-top: 1px solid var(--border);
}
.prose > hr + h2 { margin-top: 0; }

/* --- displayed equation -------------------------------------------------------
   <div class="equation">P = k<sub>1</sub>Στ² + …</div>: centred, a size up,
   variables in <i>. A long one scrolls sideways inside its own box. */
.equation {
  overflow-x: auto;
  overflow-y: hidden;
  padding: 6px 2px;
  color: var(--text);
  font-family: 'STIX Two Text', 'Cambria Math', Cambria, 'Times New Roman', serif;
  font-size: 1.25rem;
  line-height: 2rem; /* fixed, so a fitted equation keeps the height of its box */
  text-align: center;
  white-space: nowrap;
  scrollbar-width: thin;
}
/* An equation a little wider than a phone screen is set smaller until it
   fits (site.js sets --eq-fit, never below .78); a longer one scrolls
   sideways, or is broken into lines with <br> in the post. */
.equation[style*='--eq-fit'] { font-size: calc(1.25rem * var(--eq-fit)); }

/* --- sideways scroll hint ------------------------------------------------------
   A table or an equation wider than its column scrolls inside its own box.
   A soft shadow marks the edge that hides more; it is painted under two
   page-coloured covers that travel with the content, so it shows only on
   the side that can still be scrolled. */
.table-wrap,
.equation {
  background:
    linear-gradient(to right, var(--bg) 40%, rgba(248, 250, 252, 0)) left center / 36px 100% no-repeat local,
    linear-gradient(to left, var(--bg) 40%, rgba(248, 250, 252, 0)) right center / 36px 100% no-repeat local,
    radial-gradient(farthest-side at 0 50%, rgba(15, 23, 42, .16), rgba(15, 23, 42, 0)) left center / 12px 100% no-repeat scroll,
    radial-gradient(farthest-side at 100% 50%, rgba(15, 23, 42, .16), rgba(15, 23, 42, 0)) right center / 12px 100% no-repeat scroll;
}
.equation:focus-visible { outline-offset: 4px; }
.prose > * + .equation,
.prose > .equation + * { margin-top: 1.5em; }
.equation sub,
.equation sup { font-size: .7em; line-height: 0; }
/* on an entry page a long equation may use the whole article column */
.entry-body .prose > .equation { max-width: none; }

/* --- figures ----------------------------------------------------------------
   figure.figure            one image or clip
   .figure--small           half the measure, centred
   .figure--wide            the full article column
   .figure--plot            a chart, screenshot or svg: whole, on white, padded */
.prose > :is(.figure, .figure-row, .media-aside, .table-wrap) { margin-top: 36px; }
.prose > :is(.figure, .figure-row, .media-aside, .table-wrap) + * { margin-top: 36px; }
/* media right under the heading it belongs to */
.prose > :is(h2, h3) + :is(.figure, .figure-row, .media-aside) { margin-top: 20px; }

.figure img,
.figure video,
.figure-row img,
.figure-row video {
  width: 100%;
  border: 1px solid var(--media-edge);
  border-radius: var(--radius);
  background: var(--surface);
}
figcaption,
.caption {
  max-width: 64ch;
  margin-top: 10px;
  color: var(--text-subtle);
  font-size: var(--fs-sm);
  line-height: 1.5;
  text-wrap: pretty;
}
figcaption b { color: var(--text-muted); font-weight: 600; }

.prose > .figure--small { width: min(100%, var(--measure) / 2); margin-inline: auto; }
@media (max-width: 599.98px) {
  /* on a phone a small landscape figure needs the width; an upright one does not */
  .prose > .figure--small { width: 100%; }
  .prose > .figure--small.figure--tall { width: min(100%, 16.5rem); }
}

/* outside an entry page: a figure wider than the text column */
.figure--wide {
  width: min(960px, 100vw - 2 * var(--gutter));
  margin-inline: calc(50% - min(480px, 50vw - var(--gutter)));
}
/* on an entry page: the article column */
.entry-body .prose > .figure--wide {
  width: auto;
  max-width: none;
  margin-inline: 0;
}

/* charts and plots: shown whole on white, never cropped */
.figure--plot img { padding: clamp(8px, 2vw, 20px); }
.figure--small.figure--plot img,
.media-aside .figure--plot img { padding: clamp(6px, 1.2vw, 12px); }

/* a chart or plot links to its full-size file, for pinch zoom on phones. The
   disc in the top right corner (the emptiest corner of a plot) says so:
   always shown where there is no hover, and on hover or keyboard focus
   elsewhere. */
.figure__zoom { position: relative; display: block; border-radius: var(--radius); cursor: zoom-in; }
.figure__zoom::after {
  content: '';
  position: absolute;
  top: 6px;
  right: 6px;
  width: 28px;
  height: 28px;
  border: 1px solid var(--border-strong);
  border-radius: 50%;
  background: rgba(255, 255, 255, .94) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%23334155' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M9.5 2.5h4v4M13.5 2.5 9 7M6.5 13.5h-4v-4M2.5 13.5 7 9'/%3E%3C/svg%3E") center / 12px no-repeat;
  box-shadow: var(--shadow-1);
  pointer-events: none;
}
@media (hover: hover) and (min-width: 768px) {
  .figure__zoom::after { opacity: 0; transition: opacity var(--dur-fast); }
  .figure__zoom:hover::after,
  .figure__zoom:focus-visible::after { opacity: 1; }
}

/* --- rows -------------------------------------------------------------------
   div.figure-row.figure-row--N > figure.figure[style="--ar: w / h"] xN + figcaption
   Two or three cells share the row's width in proportion to --ar, so cells
   of different shapes come out the same height, uncropped. Four cells
   (.figure-row--grid) make two such lines of two; --share is the cell's
   part of its line. One caption for the row.
   On a phone a row of landscape cells stacks; a row upright enough to keep
   its height (.figure-row--tall) and the 2 x 2 grid stay side by side. */
.figure-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 12px;
}
.figure-row > .figure { flex: 1 1 100%; min-width: 0; margin: 0; }
/* the caption takes a full line of its own; padding keeps its measure */
.figure-row > figcaption { flex: 0 0 100%; max-width: none; margin-top: -2px; padding-right: max(0px, 100% - 64ch); }
.figure-row--tall > .figure { flex: calc(var(--ar, 1)) 1 0; }
.figure-row--grid > .figure { flex: 0 0 calc((100% - 12px) * var(--share, .5)); }
@media (min-width: 600px) {
  .figure-row { gap: 14px 16px; }
  .figure-row > .figure { flex: calc(var(--ar, 1)) 1 0; }
  .figure-row--grid > .figure { flex: 0 0 calc((100% - 16px) * var(--share, .5)); }
}

/* --- aside: a picture or clip beside the paragraphs that explain it ----------
   div.media-aside.media-aside--left|right
     > figure.figure.media-aside__media + div.media-aside__text
   Stacked, media first, below 768px; an upright picture (.media-aside--tall)
   is then held to a hand's width. From 768px the media column sits on the
   outer edge of the article column and the text keeps the measure's edge. */
.media-aside { display: grid; gap: 20px; }
.media-aside__media { min-width: 0; }
.media-aside__text > * + * { margin-top: 1.2em; }
.media-aside--tall .media-aside__media { width: min(100%, 300px); margin-inline: auto; }
@media (min-width: 768px) {
  .media-aside {
    --aside-media: min(42.5%, 17rem);
    grid-template-columns: minmax(0, 1fr) var(--aside-media);
    align-items: start;
    gap: 0 32px;
  }
  .media-aside--left { grid-template-columns: var(--aside-media) minmax(0, 1fr); }
  .media-aside__media { grid-row: 1; grid-column: 2; }
  .media-aside--left .media-aside__media { grid-column: 1; }
  .media-aside__text { grid-row: 1; grid-column: 1; }
  .media-aside--left .media-aside__text { grid-column: 2; }
  .media-aside--tall .media-aside__media { width: auto; margin-inline: 0; }
  /* the cap height of the first line meets the top edge of the picture */
  .media-aside__media { margin-top: .35em; }

  .entry-body .prose > .media-aside {
    --over: max(0px, (100% - var(--measure)) / 2);
    max-width: none;
    margin-left: var(--over);
    margin-right: 0;
  }
  .entry-body .prose > .media-aside--left { margin-left: 0; margin-right: var(--over); }
}

/* drawn diagram, in the body or as the page hero */
.figure--diagram .figure__frame,
.entry-hero__frame--diagram {
  padding: clamp(14px, 3vw, 32px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
}

/* --- portrait photo as the page hero -------------------------------------------
   A photo is only ever cropped, never extended, filled or retouched. A portrait
   photo in the hero keeps a tall crop on phones and a 3:2 crop from 768px;
   object-position on the img (set per entry) chooses what stays in frame. */
.entry-hero__frame--portrait { --hero-ratio: 4 / 5; }
@media (min-width: 768px) {
  .entry-hero__frame--portrait { --hero-ratio: 3 / 2; }
}

/* --- video ------------------------------------------------------------------
   Width and height attributes give the box its shape before the poster loads. */
video { background: #0f172a; }
.figure video,
.figure-row video { display: block; height: auto; }

/* --- tables ----------------------------------------------------------------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table-wrap:focus-visible { outline-offset: 4px; }
.prose table,
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-ui);
  line-height: 1.45;
}
.prose caption,
.table caption {
  padding-bottom: 10px;
  color: var(--text-subtle);
  font-size: var(--fs-sm);
  text-align: left;
}
.prose th,
.table th {
  padding: 10px 12px;
  border-bottom: 2px solid var(--border-strong);
  color: var(--text);
  font-weight: 600;
  text-align: left;
  vertical-align: bottom;
}
.prose td,
.table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  color: var(--text-body);
  vertical-align: top;
}
.prose th:first-child,
.prose td:first-child { padding-left: 0; }
.prose th:last-child,
.prose td:last-child { padding-right: 0; }
.prose th.num,
.prose td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.prose tr.is-key td { color: var(--text); font-weight: 600; }
/* a table of five or more columns keeps each heading on one line and scrolls
   inside its wrapper on a phone, instead of breaking headings word by word */
.prose table:has(th:nth-child(5)) th { white-space: nowrap; }

/* --- code -------------------------------------------------------------------- */
.prose code {
  padding: .1em .35em;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface-2);
  font-family: var(--font-mono);
  font-size: .9em;
}
.prose pre,
.prose figure.highlight {
  overflow-x: auto;
  padding: 16px 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  line-height: 1.6;
}
.prose pre code { padding: 0; border: 0; background: none; font-size: inherit; }
.prose .keyword { color: #6d28d9; }
.prose .string { color: #0f766e; }
.prose .number { color: #b45309; }
.prose .comment { color: var(--text-subtle); font-style: italic; }

/* --- diagram vocabulary -------------------------------------------------------
   Diagrams carry their colours as presentation attributes so they also
   rasterise; these rules restate them from the tokens for inline use.
   A diagram may hold two drawings: .dg-wide (landscape) and .dg-tall
   (portrait, nested <svg>). Below 1024px the tall one is shown and the root
   takes the tall drawing's aspect ratio from --dg-tall. */
.dg { width: 100%; height: auto; font-family: var(--font-sans); }
.dg text { font-family: inherit; }
.dg-node { fill: var(--surface); stroke: var(--ink); }
.dg-node--accent { fill: var(--accent-tint); stroke: var(--accent); }
.dg-node--quiet { fill: var(--surface-2); stroke: var(--ink-quiet); }
.dg-group { fill: var(--surface-2); }
.dg-group--accent { fill: #f0f9ff; stroke: var(--accent); }
.dg-edge { stroke: var(--ink); }
.dg-arrowhead { fill: var(--ink); }
.dg-label { fill: var(--text); }
.dg-note { fill: var(--text-muted); }
.dg-tag { fill: var(--accent); }
.dg-tall { display: none; }

@media (max-width: 1023.98px) {
  .dg--dual { aspect-ratio: var(--dg-tall, 9 / 16); max-width: 420px; margin-inline: auto; }
  .dg--dual .dg-wide { display: none; }
  .dg--dual .dg-tall { display: block; }
}

/* ==========================================================================
   90 print and the global reduced-motion guard. Last in the bundle.
   A printed /resume/ is the resume's page images, one per sheet at full
   sheet width; every other page prints legibly with all content visible.
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
}

@media print {
  @page { size: letter; margin: .5in .6in; }
  /* no sheet margin on /resume/: the page image carries the PDF's own margins */
  @page resume { size: letter; margin: 0; }
  .resume { page: resume; }

  html { font-size: 10pt; }
  body {
    display: block;
    min-height: 0;
    background: #fff;
    color: #000;
    line-height: 1.35;
  }
  *,
  *::before,
  *::after {
    box-shadow: none !important;
    animation: none !important;
    transition: none !important;
  }

  .nav,
  .skip,
  .footer,
  .hero__wash,
  .hero__scrim,
  .hero__motion,
  .page-head::before,
  .pager,
  .back,
  .no-print,
  .entry-hero__hint,
  .docs-nav,
  .docs-toc,
  .toc-inline,
  .hlink,
  .figure__zoom::after,
  video { display: none !important; }

  .hero,
  .page-head { margin-top: 0; padding-top: 0; }
  .container { max-width: none; padding-inline: 0; }
  .section { padding-block: 18pt; }

  a { color: inherit; text-decoration: none; }
  img { max-width: 100% !important; }
  figure,
  .figure,
  .figure-row,
  .tile,
  .row,
  .pub,
  .side-card,
  .glance__item,
  tr { break-inside: avoid; }
  h1, h2, h3 { break-after: avoid; }
  p, li { orphans: 3; widows: 3; }

  .tile,
  .pubs-card,
  .side-card,
  .now,
  .credits { border-color: #bbb; background: none; }
  .docs { display: block; }
  .entry { max-width: none; }
  .figure--wide { width: auto; margin-inline: 0; }

  /* --- the resume: each PDF page image fills one sheet ----------------------- */
  .resume { padding: 0; }
  .resume-head { display: none !important; }
  .resume-pages { display: block; margin: 0; }
  .resume-pages li { break-inside: avoid; }
  .resume-pages li + li { break-before: page; }
  .resume-page { overflow: visible; border: 0; border-radius: 0; background: none; }
  /* full sheet width; on a sheet of another shape the page shrinks to fit its height */
  .resume-page img { width: 100%; max-height: 100vh; object-fit: contain; }
}
