/* ==========================================================================
   FONTS
   IBM Plex Sans for text, IBM Plex Mono for labels and figures. Served from
   /fonts so visitors never contact Google. Latin and Latin Extended only;
   other scripts fall back to the system font.
   ========================================================================== */
/* IBM Plex Mono, 400, latin-ext */
@font-face {
  font-family: 'IBM Plex Mono';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url(fonts/ibm-plex-mono-400-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-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
/* IBM Plex Mono, 400, latin */
@font-face {
  font-family: 'IBM Plex Mono';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url(fonts/ibm-plex-mono-400-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;
}
/* IBM Plex Mono, 500, latin-ext */
@font-face {
  font-family: 'IBM Plex Mono';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url(fonts/ibm-plex-mono-500-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-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
/* IBM Plex Mono, 500, latin */
@font-face {
  font-family: 'IBM Plex Mono';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url(fonts/ibm-plex-mono-500-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;
}
/* IBM Plex Sans, italic, latin-ext */
@font-face {
  font-family: 'IBM Plex Sans';
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  src: url(fonts/ibm-plex-sans-italic-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-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
/* IBM Plex Sans, italic, latin */
@font-face {
  font-family: 'IBM Plex Sans';
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  src: url(fonts/ibm-plex-sans-italic-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;
}
/* IBM Plex Sans, latin-ext */
@font-face {
  font-family: 'IBM Plex Sans';
  font-style: normal;
  font-weight: 400 600;
  font-display: swap;
  src: url(fonts/ibm-plex-sans-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-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
/* IBM Plex Sans, latin */
@font-face {
  font-family: 'IBM Plex Sans';
  font-style: normal;
  font-weight: 400 600;
  font-display: swap;
  src: url(fonts/ibm-plex-sans-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;
}

/* ==========================================================================
   CUSTOMISE HERE
   Colours, fonts and widths live in these variables. Change them and the
   whole site follows. Light theme first, dark theme further down.
   Keep the colours in sync with manim/style.py so clips match the page.
   One accent (blue). Amber is used only inside figures, for trigger events.
   ========================================================================== */
:root {
  --paper: #F5F4F0;   /* page background (also the clip background) */
  --ink:   #1C2024;   /* text */
  --muted: #5B636B;   /* secondary text */
  --line:  #D9DAD5;   /* hairlines, grid */
  --blue:  #1F4FD8;   /* the accent: links, buttons, curves */
  --amber: #B86E00;   /* figures only: event-trigger instants */

  --font-display: "IBM Plex Sans", system-ui, sans-serif;
  --font-text:    "IBM Plex Sans", system-ui, sans-serif;
  --font-mono:    "IBM Plex Mono", ui-monospace, monospace;

  --page:   72rem;                          /* max page width */
  --gutter: clamp(1.25rem, 4vw, 3rem);      /* side padding */
  color-scheme: light;
}

/* Dark theme. Same values twice: once when the visitor picked it with the
   button, once when their system prefers dark and they have not picked. */
:root[data-theme="dark"] {
  --paper: #121416;
  --ink:   #E7E8E5;
  --muted: #9AA1A8;
  --line:  #2A2F34;
  --blue:  #7AA2FF;
  --amber: #FFB224;
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --paper: #121416;
    --ink:   #E7E8E5;
    --muted: #9AA1A8;
    --line:  #2A2F34;
    --blue:  #7AA2FF;
    --amber: #FFB224;
    color-scheme: dark;
  }
}

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

html {
  scroll-behavior: smooth;
  scroll-padding-top: 5rem;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-text);
  font-size: 1.0625rem;
  line-height: 1.65;
  text-rendering: optimizeLegibility;
}

.wrap {
  max-width: var(--page);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

a {
  color: inherit;
  text-decoration: underline;
  text-decoration-color: var(--blue);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
  transition: color 0.2s ease;
}
a:hover { color: var(--blue); }

:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 3px;
  border-radius: 2px;
}

h1, h2, h3 { font-family: var(--font-display); font-weight: 600; letter-spacing: -0.01em; }

/* Small labels and metrics are set in the text face; mono is kept for
   numbers and code (metric figures, dates, counters, tables, BibTeX). */
.label, .metric { font-size: 0.85rem; }
.eyebrow { margin: 0; font-family: var(--font-mono); font-size: 0.8rem; color: var(--muted); letter-spacing: 0.08em; }
.metric { color: var(--ink); }
.metric b { font-family: var(--font-mono); font-weight: 500; color: var(--blue); }

.skip {
  position: absolute;
  left: -999px;
  top: 0.5rem;
  background: var(--ink);
  color: var(--paper);
  padding: 0.5rem 1rem;
  z-index: 50;
}
.skip:focus { left: 0.5rem; }

/* ---------- Top bar ---------- */
.bar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--paper);
  border-bottom: 1px solid transparent;
}
@supports (color: color-mix(in srgb, red 50%, blue)) {
  .bar {
    background: color-mix(in srgb, var(--paper) 88%, transparent);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
  }
}
.bar-in {
  display: flex;
  align-items: center;
  gap: 2rem;
  padding-block: 0.85rem;
}
.bar-name {
  font-weight: 600;
  font-size: 1rem;
  text-decoration: none;
  margin-right: auto;
}
.bar nav {
  display: flex;
  gap: 1.5rem;
  font-size: 0.92rem;
}
.bar nav a { text-decoration: none; color: var(--muted); white-space: nowrap; }
.bar nav a:hover,
.bar nav a[aria-current="true"] { color: var(--ink); }
.bar nav a[aria-current="true"] {
  text-decoration: underline;
  text-decoration-color: var(--blue);
  text-decoration-thickness: 2px;
  text-underline-offset: 0.45em;
}

#theme-toggle {
  display: grid;
  place-items: center;
  width: 2.25rem;
  height: 2.25rem;
  background: none;
  border: 0;
  border-radius: 50%;
  color: var(--ink);
  cursor: pointer;
}
#theme-toggle:hover { color: var(--blue); }

/* ---------- Language ----------
   Each text exists twice, with lang="en" and lang="fr"; only the page's
   language is shown. Without JavaScript the page stays in English. */
:root:not([data-lang="fr"]) [lang="fr"],
:root[data-lang="fr"] [lang="en"] { display: none !important; }

#lang-toggle {
  margin-right: -1.25rem;          /* sit next to the theme button */
  padding: 0.3rem 0.5rem;
  background: none;
  border: 0;
  font-family: inherit;
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--ink);
  cursor: pointer;
}
#lang-toggle:hover { color: var(--blue); }

.progress { height: 2px; background: transparent; }
.progress span {
  display: block;
  height: 100%;
  background: var(--blue);
  transform: scaleX(0);
  transform-origin: left;
}

/* ---------- Buttons and link rows ---------- */
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem 1.5rem; margin: 2rem 0 0; }
.btn {
  display: inline-block;
  padding: 0.6rem 1.1rem;
  border: 1px solid var(--blue);
  border-radius: 3px;
  background: var(--blue);
  color: var(--paper);
  font-weight: 500;
  font-size: 0.95rem;
  text-decoration: none;
}
.btn:hover { color: var(--paper); filter: brightness(1.08); }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn.ghost:hover { color: var(--blue); border-color: var(--blue); filter: none; }

.links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1.5rem;
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 0.92rem;
}
.links a { display: inline-flex; align-items: center; gap: 0.4em; text-decoration: none; color: var(--muted); }
.links a:hover { color: var(--blue); }
.ico { width: 1em; height: 1em; flex: none; fill: currentColor; }

.more { font-weight: 500; text-decoration: none; }
.more::after { content: " →"; }
.more:hover { text-decoration: underline; text-decoration-color: var(--blue); }

/* ---------- Hero ---------- */
.hero { padding-top: clamp(3rem, 8vw, 6.5rem); }
.hero h1 {
  display: flex;
  align-items: center;
  gap: clamp(0.9rem, 2vw, 1.4rem);
  margin: 0;
  font-size: clamp(2.4rem, 6vw, 4.4rem);
  line-height: 1.04;
  letter-spacing: -0.025em;
}
.lede {
  max-width: 36rem;
  margin: 1.4rem 0 0;
  font-size: clamp(1.1rem, 2vw, 1.3rem);
  line-height: 1.5;
  color: var(--ink);
}
.portrait {
  flex: none;
  width: clamp(3.25rem, 6vw, 4.5rem);
  height: clamp(3.25rem, 6vw, 4.5rem);
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--line);
  background: var(--line);
}
.hero .links { margin-top: 1.25rem; }

/* Figures: the hero canvas, clips, diagrams. */
.trace { position: relative; margin: 3rem 0 0; }
.trace canvas {
  display: block;
  width: 100%;
  height: clamp(230px, 30vw, 340px);
}
.trace figcaption, .clip figcaption, .diagram figcaption, .poster figcaption {
  margin-top: 0.6rem;
  font-size: 0.85rem;
  line-height: 1.5;
  color: var(--muted);
}
figcaption .fig { color: var(--ink); font-weight: 600; margin-right: 0.4rem; }
.pause {
  position: absolute;
  right: 0;
  top: 0;
  padding: 0.25rem 0.55rem;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: var(--paper);
  color: var(--muted);
  font-family: inherit;
  font-size: 0.8rem;
  cursor: pointer;
}
.pause:hover { color: var(--blue); border-color: var(--blue); }

/* ---------- Sections ----------
   Titles sit in the left margin on wide screens and stay in view. */
.section {
  display: grid;
  grid-template-columns: minmax(8rem, 12rem) minmax(0, 1fr);
  column-gap: clamp(2rem, 5vw, 4.5rem);
  padding-top: clamp(4.5rem, 9vw, 7rem);
}
.section > h2 {
  position: sticky;
  top: 5rem;
  align-self: start;
  margin: 0.15rem 0 0;
  font-size: 1.05rem;
  line-height: 1.3;
}
.body { max-width: 46rem; }
.body.wide { max-width: none; }
.body > :first-child { margin-top: 0; }
.body p { margin: 0 0 1.1rem; }
.body h3 { margin: 2.5rem 0 0.75rem; font-size: 1.3rem; line-height: 1.25; }

/* ---------- Featured work ---------- */
.work { margin: 0; padding: 0; list-style: none; }
.work > li {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
  gap: clamp(1.25rem, 3.5vw, 2.75rem);
  align-items: start;
  padding: 2.25rem 0;
  border-top: 1px solid var(--line);
}
.work > li:first-child { padding-top: 0; border-top: 0; }
.work h3 { margin: 0.5rem 0 0.6rem; font-size: clamp(1.3rem, 2.4vw, 1.6rem); line-height: 1.2; }
.work p { margin: 0 0 0.9rem; }
.work .metric { margin: 0 0 1rem; padding-left: 0.75rem; border-left: 2px solid var(--blue); }
.work .row-links { display: flex; flex-wrap: wrap; gap: 0.4rem 1.25rem; font-size: 0.95rem; }

.poster { margin: 0; }
.poster a { display: block; }
.poster img, .poster video {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--paper);
}

/* Featured work as a side-scrolling carousel: one project in front, the
   neighbours peeking in at the sides. Native scroll-snap (swipe, trackpad,
   keyboard); arrows and dimming added by script.js. */
.carousel-nav { display: flex; align-items: center; justify-content: flex-end; gap: 0.5rem; margin: 0 0 1.25rem; }
.carousel-count { margin-right: auto; font-family: var(--font-mono); font-size: 0.8rem; color: var(--muted); }
.carousel-nav button {
  width: 2.25rem;
  height: 2.25rem;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: var(--paper);
  color: var(--ink);
  font-size: 1rem;
  cursor: pointer;
}
.carousel-nav button:hover:not(:disabled) { color: var(--blue); border-color: var(--blue); }
.carousel-nav button:disabled { opacity: 0.35; cursor: default; }
.carousel .work {
  position: relative;
  display: flex;
  gap: clamp(1rem, 2.5vw, 1.75rem);
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  overscroll-behavior-x: contain;
  scroll-behavior: smooth;
  scrollbar-width: none;
}
.carousel .work::-webkit-scrollbar { display: none; }
.carousel .work > li {
  flex: 0 0 82%;
  scroll-snap-align: center;
  padding: 0;
  border-top: 0;
  transition: opacity 0.3s ease;
}
.js .carousel .work > li:not(.is-current) { opacity: 0.35; cursor: pointer; }
.js .carousel .work > li:not(.is-current):hover { opacity: 0.6; }
/* Hint that there is more: the projects peeking in at the sides glow slowly
   and keep doing so, wherever the carousel stands. */
.carousel .work { padding-block: 1.25rem; margin-block: -1.25rem; }
.js .carousel .work > li.is-prev,
.js .carousel .work > li.is-next { animation: peek-fade 5s ease-in-out infinite; }
.js .carousel .work > li.is-prev .poster video,
.js .carousel .work > li.is-next .poster video { animation: peek-glow 5s ease-in-out infinite; }
.js .carousel .work > li.is-prev:hover,
.js .carousel .work > li.is-next:hover { animation: none; }
@keyframes peek-fade { 50% { opacity: 0.7; } }
@keyframes peek-glow { 50% { box-shadow: 0 0 22px -4px var(--blue); border-color: var(--blue); } }
/* On wide screens the left neighbour shows its text, not its clip, so the
   glow also comes from the edge each neighbour turns to the one in front. */
.carousel .work > li { position: relative; }
.js .carousel .work > li.is-prev::after,
.js .carousel .work > li.is-next::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  width: 5rem;
  pointer-events: none;
  opacity: 0;
  animation: peek-edge 5s ease-in-out infinite;
}
.js .carousel .work > li.is-prev::after,
.js .carousel .work > li.is-next::after { background: radial-gradient(closest-side, var(--blue), transparent); }
.js .carousel .work > li.is-prev::after { right: 0; }
.js .carousel .work > li.is-next::after { left: 0; }
@keyframes peek-edge { 50% { opacity: 0.35; } }
.carousel.moving .work > li,
.carousel.moving .work > li .poster video,
.carousel.moving .work > li::after { animation-play-state: paused; }
/* The neighbours fade into the page at the outer edges instead of being cut. */
.js .carousel .work {
  --fade-l: 0rem;
  --fade-r: 0rem;
  -webkit-mask-image: linear-gradient(to right, transparent, #000 var(--fade-l), #000 calc(100% - var(--fade-r)), transparent);
  mask-image: linear-gradient(to right, transparent, #000 var(--fade-l), #000 calc(100% - var(--fade-r)), transparent);
}
.js .carousel.has-prev .work { --fade-l: 1.75rem; }
.js .carousel.has-next .work { --fade-r: 1.75rem; }
@media (prefers-reduced-motion: reduce) {
  .js .carousel .work > li,
  .js .carousel .work > li .poster video { animation: none !important; }
  .js .carousel .work > li::after { display: none; }
}

/* ---------- Areas and approach ---------- */
.areas {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1.75rem clamp(1.25rem, 3vw, 2.25rem);
  margin: 0 0 1rem;
  padding: 0;
  list-style: none;
}
.areas li { padding-top: 0.9rem; border-top: 2px solid var(--ink); }
.areas h3 { margin: 0 0 0.5rem; font-size: 1.1rem; }
.areas p { margin: 0; font-size: 0.97rem; color: var(--ink); }


/* ---------- Publications, talks ---------- */
.pubs { margin: 0; padding: 0; list-style: none; }
.pubs li { margin-bottom: 1.75rem; }
.pubs li:last-child { margin-bottom: 0; }
.pubs p { margin: 0; }
.pub-title { font-weight: 600; line-height: 1.4; }
.pub-meta { color: var(--muted); font-size: 0.95rem; line-height: 1.5; margin-top: 0.2rem !important; }
.pub-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem 1.25rem;
  margin-top: 0.4rem !important;
  font-size: 0.92rem;
}

.timeline { margin: 0; padding: 0; list-style: none; }
.timeline li {
  display: grid;
  grid-template-columns: 6.5rem minmax(0, 1fr);
  column-gap: 1rem;
  padding: 0.55rem 0;
  border-top: 1px solid var(--line);
  font-size: 0.95rem;
  line-height: 1.5;
}
.timeline time { font-family: var(--font-mono); font-size: 0.8rem; color: var(--muted); padding-top: 0.15rem; }

.bib { margin-top: 0.5rem; }
.bib summary {
  display: inline-block;
  cursor: pointer;
  font-size: 0.92rem;
  text-decoration: underline;
  text-decoration-color: var(--blue);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
}
.bib summary:hover { color: var(--blue); }
.bib summary::marker, .bib summary::-webkit-details-marker { content: ""; display: none; }
.bib pre {
  margin: 0.6rem 0 0;
  padding: 1rem;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  line-height: 1.5;
}

/* ---------- About ---------- */
.toolbox { margin: 1.5rem 0 0; }
.toolbox > div { display: grid; grid-template-columns: 11rem minmax(0, 1fr); column-gap: 1rem; padding: 0.6rem 0; border-top: 1px solid var(--line); }
.toolbox dt { font-weight: 600; font-size: 0.95rem; }
.toolbox dd { margin: 0; font-size: 0.95rem; }

.contact-mail { font-size: clamp(1.2rem, 2.6vw, 1.6rem); font-weight: 500; }

/* ---------- Project pages ---------- */
.back { display: inline-block; margin-bottom: 1.5rem; font-size: 0.9rem; color: var(--muted); text-decoration: none; }
.back:hover { color: var(--blue); }
.back::before { content: "← "; }
.project-head .kind { margin: 0; color: var(--muted); }
.project-head h1 { max-width: 22ch; margin: 0.8rem 0 0; font-size: clamp(2rem, 5vw, 3.3rem); line-height: 1.08; }
.facts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
  gap: 1rem 2rem;
  margin: 2rem 0 0;
  padding: 1rem 0 0;
  border-top: 1px solid var(--line);
}
.facts div { margin: 0; }
.facts dt { font-size: 0.85rem; color: var(--muted); }
.facts dd { margin: 0.2rem 0 0; font-size: 0.95rem; }
.results { width: 100%; border-collapse: collapse; margin: 0.5rem 0 1.5rem; font-size: 0.9rem; }
.results th, .results td { padding: 0.45rem 0.6rem; border-bottom: 1px solid var(--line); text-align: left; }
.results th { font-weight: 600; }
.results td { font-family: var(--font-mono); font-size: 0.82rem; }
.table-scroll { overflow-x: auto; }
.note { font-size: 0.92rem; color: var(--muted); }

/* ---------- Clips ---------- */
.clip { margin: 1.5rem 0 2rem; }
.clip video {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
  background: var(--paper);     /* same colour as the clip, no flash while loading */
  border: 1px solid var(--line);
  border-radius: 4px;
  cursor: pointer;
}

/* Show only the clip or poster that matches the active theme. */
.only-dark { display: none !important; }
:root[data-theme="dark"] .only-dark { display: block !important; }
:root[data-theme="dark"] .only-light { display: none !important; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) .only-dark { display: block !important; }
  :root:not([data-theme]) .only-light { display: none !important; }
}

/* ---------- Diagram (inline SVG, follows the theme) ---------- */
.diagram { margin: 1.5rem 0 2rem; }
.diagram-scroll { overflow-x: auto; }
.diagram svg { display: block; width: 100%; min-width: 34rem; height: auto; }
.diagram text { fill: var(--ink); font-family: var(--font-display); font-size: 12px; }
.diagram .d-math { font-family: var(--font-text); font-size: 13px; }
.diagram .d-it { font-style: italic; }
.diagram .d-big { font-size: 17px; }
.diagram .d-small { font-size: 10.5px; }
.diagram .d-sub, .diagram .d-sup { font-size: 70%; }
.diagram .d-script { font-size: 9px; }
.diagram .d-hat { font-size: 12px; }
.diagram .d-wire { fill: none; stroke: var(--muted); stroke-width: 1.3; }
.diagram .d-dashed { stroke-dasharray: 4 3; }
.diagram .d-head { fill: var(--muted); }
.diagram .d-frame { fill: none; stroke: var(--muted); stroke-width: 1.3; stroke-dasharray: 7 5; }
.diagram .d-box { fill: var(--paper); stroke: var(--ink); stroke-width: 1.3; }
/* Plain fills first, for browsers without color-mix() (Firefox < 113, Safari < 16.2). */
.diagram .d-layer { fill: var(--paper); stroke: var(--blue); stroke-width: 1.3; }
.diagram .d-etm { fill: var(--paper); stroke: var(--amber); stroke-width: 1.3; }
@supports (color: color-mix(in srgb, red 50%, blue)) {
  .diagram .d-layer { fill: color-mix(in srgb, var(--blue) 22%, var(--paper)); }
  .diagram .d-etm { fill: color-mix(in srgb, var(--amber) 25%, var(--paper)); }
}

/* ---------- Footer ---------- */
.foot {
  margin-top: clamp(4.5rem, 9vw, 7rem);
  padding-block: 1.5rem 3rem;
  border-top: 1px solid var(--line);
  font-size: 0.85rem;
  color: var(--muted);
}
.foot p { margin: 0; }

/* ---------- Scroll animation ----------
   One small fade-and-rise, only when JavaScript is on. */
.js .reveal {
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.5s ease, transform 0.5s ease;
  transition-delay: calc(var(--i, 0) * 60ms);
}
.js .reveal.in { opacity: 1; transform: none; }

/* ---------- Smaller screens ---------- */
@media (max-width: 56rem) {
  .section { display: block; }
  .section > h2 { position: static; margin-bottom: 1.5rem; font-size: 1.2rem; }
  .work > li { grid-template-columns: minmax(0, 1fr); }
  .carousel .work > li { flex-basis: 86%; }
  .js .carousel.has-prev .work { --fade-l: 0.6rem; }
  .js .carousel.has-next .work { --fade-r: 0.6rem; }
  .areas { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 40rem) {
  .bar-name { display: none; }
  .bar-in { gap: 0.5rem; }
  #lang-toggle { margin-right: 0; padding-inline: 0.2rem; }
  #theme-toggle { width: 2rem; }
  .bar nav { gap: 0.75rem; font-size: 0.82rem; overflow-x: auto; margin-right: auto; }
  .bar nav .nav-wide { display: none; }   /* no room on phones */
  .toolbox > div { grid-template-columns: minmax(0, 1fr); }
  .timeline li { grid-template-columns: minmax(0, 1fr); }
  body { font-size: 1rem; }
}

/* ---------- Respect reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .js .reveal { opacity: 1; transform: none; transition: none; }
}

/* Project pages read as one document: closer sections. */
article .section { padding-top: clamp(2.75rem, 5vw, 4rem); }
