/* ==========================================================================
   Ram Hirsch personal site
   Visual references: the Swiss International Typographic Style (strict grid,
   large type, asymmetric composition) and Distill-style research articles
   (numbered figures, interactive explanations, captions that carry meaning).
   One stylesheet, no build step. Fonts are self-hosted (assets/fonts).
   ========================================================================== */

@font-face {
  font-family: "Newsreader";
  src: url("../fonts/newsreader-latin-opsz-normal.woff2") format("woff2-variations"),
       url("../fonts/newsreader-latin-opsz-normal.woff2") format("woff2");
  font-weight: 200 800;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Newsreader";
  src: url("../fonts/newsreader-latin-opsz-italic.woff2") format("woff2-variations"),
       url("../fonts/newsreader-latin-opsz-italic.woff2") format("woff2");
  font-weight: 200 800;
  font-style: italic;
  font-display: swap;
}
@font-face {
  font-family: "IBM Plex Mono";
  src: url("../fonts/ibm-plex-mono-latin-400-normal.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "IBM Plex Mono";
  src: url("../fonts/ibm-plex-mono-latin-500-normal.woff2") format("woff2");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

/* ---------- Tokens ---------- */
:root {
  /* light surfaces (contrast ratios measured against --paper) */
  --paper: #f2eee4;
  --paper-tint: #e9e4d7;
  --ink: #121412;        /* 17:1 */
  --ink-2: #4b4f49;      /* 7.4:1 */
  --rule: #cdc6b5;
  --rule-strong: #8f897c;
  --accent: #2f5b36;     /* 7.1:1 */
  --accent-soft: #d5dfc8;
  --sage: #c5d1b6;       /* portrait block */
  --signal: #a8391a;     /* 5.6:1, used for errors and the repair loop */
  --on-accent: #f2eee4;

  /* dark band */
  --field: #13201a;
  --field-ink: #ece7da;    /* 14:1 on field */
  --field-ink-2: #a8b3a5;  /* 7.9:1 on field */
  --field-rule: #2d3d33;
  --field-accent: #b6d49f; /* 10.6:1 on field */
  --field-signal: #f0956d; /* 7.2:1 on field */

  --serif: "Newsreader", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;

  --wrap: 78rem;
  --gutter: clamp(1.25rem, 4vw, 3rem);
  --rail: 12rem;
  --measure: 39rem;
  --header-h: 3.75rem;

  --ease: cubic-bezier(.2, .7, .2, 1);
}

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-padding-top: calc(var(--header-h) + 1rem);
}
@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 1.15rem;
  line-height: 1.6;
  font-optical-sizing: auto;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  font-kerning: normal;
}

img { display: block; max-width: 100%; height: auto; }
h1, h2, h3, h4 { margin: 0; font-weight: 500; line-height: 1.15; }
p, ul, ol, dl, figure { margin: 0; }
ul, ol { padding: 0; list-style: none; }
dd { margin: 0; }

a {
  color: inherit;
  text-decoration-line: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: .22em;
  text-decoration-color: var(--rule-strong);
  transition: text-decoration-color .15s var(--ease), color .15s var(--ease);
}
a:hover { text-decoration-color: currentColor; color: var(--accent); }

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

::selection { background: var(--accent-soft); color: var(--ink); }

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

/* Monospace annotation voice: labels, dates, figure numbers */
.annot {
  font-family: var(--mono);
  font-size: .75rem;
  font-weight: 400;
  letter-spacing: .02em;
  line-height: 1.5;
  color: var(--ink-2);
}

.prose { max-width: var(--measure); }
.prose > * + * { margin-top: 1em; }

.skip-link {
  position: absolute;
  left: 1rem;
  top: -4rem;
  z-index: 100;
  padding: .7rem 1rem;
  background: var(--ink);
  color: var(--paper);
  font-family: var(--mono);
  font-size: .85rem;
}
.skip-link:focus { top: 1rem; color: var(--paper); }

/* Buttons and chips */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  min-height: 2.75rem;               /* 44px touch target */
  padding: .55rem 1.2rem;
  font-family: var(--mono);
  font-size: .8rem;
  letter-spacing: .02em;
  color: var(--ink);
  background: transparent;
  border: 1px solid var(--ink);
  border-radius: 999px;
  text-decoration: none;
  cursor: pointer;
  transition: background-color .18s var(--ease), color .18s var(--ease), border-color .18s var(--ease);
}
.btn:hover { background: var(--ink); color: var(--paper); }
.btn--solid { background: var(--ink); color: var(--paper); }
.btn--solid:hover { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn--small { min-height: 2.5rem; padding: .4rem 1rem; font-size: .75rem; }

.chip {
  appearance: none;
  min-height: 2.5rem;
  padding: .4rem .95rem;
  font-family: var(--mono);
  font-size: .75rem;
  color: var(--ink-2);
  background: transparent;
  border: 1px solid var(--rule-strong);
  border-radius: 999px;
  cursor: pointer;
  transition: all .18s var(--ease);
}
.chip:hover { color: var(--ink); border-color: var(--ink); }
.chip[aria-pressed="true"] { color: var(--paper); background: var(--ink); border-color: var(--ink); }
.chip[data-rm-mode="invalid"][aria-pressed="true"] { background: var(--signal); border-color: var(--signal); color: var(--field); }

/* ---------- Header ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--paper) 90%, transparent);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--rule);
}
.site-header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  min-height: var(--header-h);
}
.site-header__name {
  display: inline-flex;
  align-items: center;
  gap: .65rem;
  font-family: var(--mono);
  font-size: .82rem;
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
}
.monogram {
  display: inline-grid;
  place-items: center;
  width: 1.9rem;
  height: 1.9rem;
  border-radius: 50%;
  background: var(--ink);
  color: var(--paper);
  font-family: var(--serif);
  font-size: .8rem;
  font-weight: 500;
  letter-spacing: .02em;
}
.site-nav ul { display: flex; gap: clamp(.25rem, 1.2vw, 1rem); }
.site-nav a {
  display: inline-flex;
  align-items: center;
  min-height: 2.75rem;
  padding-inline: .45rem;
  font-family: var(--mono);
  font-size: .78rem;
  text-decoration: none;
  color: var(--ink-2);
  position: relative;
}
.site-nav a::after {
  content: "";
  position: absolute;
  left: .45rem;
  right: .45rem;
  bottom: .55rem;
  height: 1px;
  background: currentColor;
  transform: scaleX(0);
  transform-origin: left;
  transition: transform .25s var(--ease);
}
.site-nav a:hover,
.site-nav a[aria-current="true"] { color: var(--ink); }
.site-nav a:hover::after,
.site-nav a[aria-current="true"]::after { transform: scaleX(1); }

@media (max-width: 52rem) {
  .site-header__inner { flex-wrap: wrap; gap: 0; padding-top: .45rem; }
  .site-nav {
    width: calc(100% + 2 * var(--gutter));
    margin-inline: calc(-1 * var(--gutter));
    padding-inline: calc(var(--gutter) - .45rem);
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-mask-image: linear-gradient(to right, #000 85%, transparent);
            mask-image: linear-gradient(to right, #000 85%, transparent);
  }
  .site-nav::-webkit-scrollbar { display: none; }
  .site-nav a { white-space: nowrap; }
}

/* ---------- Hero ---------- */
.hero { padding-block: clamp(1.75rem, 4vw, 3rem) clamp(3rem, 6vw, 5rem); overflow: hidden; }
.hero__grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  column-gap: clamp(1rem, 2vw, 1.5rem);
}
.hero__meta {
  grid-column: 1 / -1;
  grid-row: 1;
  display: flex;
  flex-wrap: wrap;
  gap: .25rem 0;
  padding-bottom: .9rem;
  border-bottom: 1.5px solid var(--ink);
  font-family: var(--mono);
  font-size: .75rem;
  color: var(--ink-2);
}
.hero__meta span + span::before { content: "/"; margin-inline: .8rem; color: var(--rule-strong); }

/* Cut-out portrait standing in a colour field that it slightly breaks out of */
.hero__portrait {
  grid-column: 8 / -1;
  grid-row: 2 / span 2;
  align-self: start;
  margin-top: clamp(2rem, 4vw, 3.5rem);
  position: relative;
}
.portrait { position: relative; isolation: isolate; }
.portrait::before {
  content: "";
  position: absolute;
  inset: 17% 0 0 0;
  z-index: -1;
  background: var(--sage);
}
.portrait::after {
  /* ruler ticks along the field's left edge */
  content: "";
  position: absolute;
  left: -.9rem;
  top: 17%;
  bottom: 0;
  width: .5rem;
  background: repeating-linear-gradient(to bottom, var(--ink) 0 1px, transparent 1px 1.25rem);
  opacity: .55;
}
.portrait img { width: 100%; }
.hero__caption {
  display: flex;
  justify-content: space-between;
  margin-top: .7rem;
  padding-top: .5rem;
  border-top: 1px solid var(--ink);
}

.hero__name {
  grid-column: 1 / span 9;
  grid-row: 2;
  align-self: end;
  position: relative;
  z-index: 2;
  margin-top: clamp(2rem, 5vw, 4rem);
  font-size: clamp(4.25rem, 13.2vw, 12.5rem);
  font-weight: 300;
  line-height: .84;
  letter-spacing: -.045em;
}
.hero__first,
.hero__last { display: block; }
.hero__last { font-style: italic; font-weight: 300; padding-left: .55em; }

.hero__text {
  grid-column: 1 / span 7;
  grid-row: 3;
  margin-top: clamp(1.75rem, 3.5vw, 2.75rem);
  max-width: 40rem;
}
.hero__lead {
  font-size: clamp(1.5rem, 2.6vw, 2.2rem);
  line-height: 1.22;
  letter-spacing: -.012em;
}
.hero__sub {
  margin-top: 1.1rem;
  font-size: clamp(1.1rem, 1.45vw, 1.25rem);
  font-style: italic;
  color: var(--ink-2);
  max-width: 34rem;
}
.hero__links { display: flex; flex-wrap: wrap; gap: .75rem; margin-top: 2rem; }

.now-strip {
  grid-column: 1 / -1;
  grid-row: 4;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-top: clamp(3rem, 6vw, 4.5rem);
  border-top: 1.5px solid var(--ink);
}
.now-strip > div { padding: 1rem 1.5rem 0 0; }
.now-strip > div + div { padding-left: 1.5rem; border-left: 1px solid var(--rule); }
.now-strip dt { font-family: var(--mono); font-size: .72rem; color: var(--accent); margin-bottom: .3rem; }
.now-strip dd { font-size: 1.05rem; line-height: 1.4; }

@media (max-width: 60rem) {
  .hero__grid { grid-template-columns: 1fr; }
  .hero__meta,
  .hero__portrait,
  .hero__name,
  .hero__text,
  .now-strip { grid-column: 1; grid-row: auto; }
  .hero__portrait { width: min(78%, 24rem); justify-self: end; margin-top: 2rem; }
  .hero__caption { display: none; }
  .hero__name { margin-top: -.62em; font-size: clamp(3.75rem, 19vw, 8rem); }
  .now-strip { grid-template-columns: 1fr; }
  .now-strip > div,
  .now-strip > div + div { padding: .85rem 0; border-left: 0; }
  .now-strip > div + div { border-top: 1px solid var(--rule); }
}

/* ---------- Sections ---------- */
.section { padding-block: clamp(4rem, 9vw, 7.5rem); }
.section__grid {
  display: grid;
  grid-template-columns: var(--rail) minmax(0, 1fr);
  column-gap: clamp(1.5rem, 4vw, 3.5rem);
}
.section__grid > .section__body { grid-column: 2; }
.section__grid > .wide { grid-column: 1 / -1; }

.section__rail {
  grid-column: 1;
  align-self: start;
  position: sticky;
  top: calc(var(--header-h) + 1.5rem);
  padding-top: .9rem;
  border-top: 1.5px solid var(--ink);
}
.section__num {
  display: block;
  font-family: var(--mono);
  font-size: .75rem;
  color: var(--accent);
  margin-bottom: .35rem;
}
.section__title { font-size: 1.55rem; font-weight: 400; letter-spacing: -.01em; }
.section__intro { max-width: var(--measure); color: var(--ink-2); margin-bottom: 2.5rem; }

.section--tint { background: var(--paper-tint); }
.section--tint .timeline__axis { background: var(--paper-tint); }

/* Dark band: remap tokens so every component adapts automatically */
.section--dark,
.site-footer {
  --paper: var(--field);
  --ink: var(--field-ink);
  --ink-2: var(--field-ink-2);
  --rule: var(--field-rule);
  --rule-strong: #57685c;
  --accent: var(--field-accent);
  --accent-soft: #2f4a37;
  --signal: var(--field-signal);
  --on-accent: var(--field);
  background: var(--field);
  color: var(--field-ink);
}

@media (max-width: 52rem) {
  .section__grid { grid-template-columns: 1fr; row-gap: 2rem; }
  .section__grid > .section__body,
  .section__grid > .wide { grid-column: 1; }
  .section__rail { position: static; display: flex; align-items: baseline; gap: .9rem; }
  .section__num { margin: 0; }
}

.subhead { font-size: 1.55rem; font-weight: 400; margin-bottom: 1.5rem; }
.figcaption { margin-top: 1.1rem; font-size: .98rem; line-height: 1.55; color: var(--ink-2); max-width: 52rem; }
.figcaption .annot { margin-right: .6rem; color: var(--ink); }

/* ---------- About ---------- */
.about {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 17rem);
  gap: clamp(2rem, 5vw, 4.5rem);
  align-items: start;
}
.lede { font-size: clamp(1.3rem, 2vw, 1.55rem); line-height: 1.4; letter-spacing: -.005em; }
.glance { border-top: 1.5px solid var(--ink); }
.glance > div { padding-block: .7rem; border-bottom: 1px solid var(--rule); }
.glance dt { font-family: var(--mono); font-size: .72rem; color: var(--ink-2); }
.glance dd { font-size: 1.02rem; line-height: 1.4; margin-top: .15rem; }

@media (max-width: 64rem) {
  .about { grid-template-columns: 1fr; }
  .glance { max-width: var(--measure); }
}

/* ---------- Research ---------- */
.status {
  display: inline-flex;
  align-items: center;
  gap: .6rem;
  font-family: var(--mono);
  font-size: .75rem;
  color: var(--ink-2);
  padding: .4rem .8rem;
  border: 1px solid var(--rule-strong);
  border-radius: 999px;
  margin-bottom: 2rem;
}
.status__dot { flex: none; width: .5rem; height: .5rem; border-radius: 50%; background: var(--accent); }
@media (prefers-reduced-motion: no-preference) {
  .status__dot { animation: pulse 2.4s var(--ease) infinite; }
}
@keyframes pulse { 50% { opacity: .35; } }

.display-q {
  font-size: clamp(1.9rem, 3.9vw, 3.2rem);
  font-weight: 300;
  line-height: 1.12;
  letter-spacing: -.02em;
  max-width: 48rem;
  margin-bottom: 2.25rem;
}
.display-q em { font-style: italic; color: var(--accent); }

/* Fig. 1: reward machine toy */
.rm {
  margin-top: clamp(3.5rem, 7vw, 5.5rem);
  padding-top: 1.25rem;
  border-top: 1.5px solid var(--ink);
}
.rm__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 2rem;
}
.rm__kicker { color: var(--ink); }
.rm__modes { display: flex; flex-wrap: wrap; gap: .5rem; }
.rm__stage {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
  gap: clamp(2rem, 5vw, 4rem);
  align-items: center;
}
.rm__grid,
.rm__machine { width: 100%; height: auto; overflow: visible; }

.rm-cellline { fill: none; stroke: var(--rule); stroke-width: 1; }
.rm-frame { fill: none; stroke: var(--ink-2); stroke-width: 1.5; }
.rm-walls rect { fill: url(#rm-hatch); stroke: var(--ink-2); stroke-width: 1; }
.rm-hatchline { stroke: var(--ink-2); stroke-width: 1.2; }
.rm-door { fill: transparent; stroke: var(--ink); stroke-width: 1.5; stroke-dasharray: 4 4; transition: fill .3s var(--ease); }
.rm-door.is-done { fill: color-mix(in srgb, var(--accent) 30%, transparent); stroke: var(--accent); stroke-dasharray: none; }
.rm-path { fill: none; stroke: var(--accent); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.rm.is-invalid .rm-path { stroke: var(--signal); }
.rm-agent { fill: var(--ink); stroke: var(--paper); stroke-width: 3; }
.rm-marker circle,
.rm-marker rect { fill: var(--paper); stroke: var(--ink); stroke-width: 1.5; transition: fill .3s var(--ease); }
.rm-marker text { font-family: var(--mono); font-size: 11px; text-anchor: middle; fill: var(--ink); }
.rm-marker.is-done circle,
.rm-marker.is-done rect { fill: var(--accent); stroke: var(--accent); }
.rm-marker.is-done text { fill: var(--paper); }
.rm-label { font-family: var(--mono); font-size: 10px; fill: var(--ink-2); }
.rm-block path { stroke: var(--signal); stroke-width: 3; stroke-linecap: round; }
.rm-block { opacity: 0; transition: opacity .2s var(--ease); }
.rm-block.is-shown { opacity: 1; }

.rm-edge { fill: none; stroke: var(--ink-2); stroke-width: 1.5; transition: stroke .3s var(--ease); }
.rm-arrowhead { fill: var(--ink-2); }
.rm-edge.is-done { stroke: var(--accent); stroke-width: 2.5; }
.rm-edge.is-bad { stroke: var(--signal); stroke-width: 2.5; stroke-dasharray: 5 4; }
.rm-edge-labels text { font-family: var(--mono); font-size: 12px; fill: var(--ink-2); }
.rm-edge-labels text.is-bad { fill: var(--signal); }
.rm-state circle { fill: var(--paper); stroke: var(--ink-2); stroke-width: 1.5; transition: fill .3s var(--ease), stroke .3s var(--ease); }
.rm-state text { font-family: var(--mono); font-size: 13px; text-anchor: middle; fill: var(--ink); }
.rm-state.is-visited circle { stroke: var(--accent); }
.rm-state.is-active circle:first-child { fill: var(--accent); stroke: var(--accent); }
.rm-state.is-active .rm-inner { fill: none; stroke: var(--paper); }
.rm-state.is-active text { fill: var(--paper); }
.rm-state.is-stuck circle:first-child { fill: var(--signal); stroke: var(--signal); }
.rm-state.is-stuck text { fill: var(--paper); }
.rm-readout { font-family: var(--mono); font-size: 12px; fill: var(--ink-2); }

.rm__controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem 1.5rem;
  margin-top: 2rem;
  padding-top: 1rem;
  border-top: 1px solid var(--rule);
}
.rm__scrub { display: inline-flex; align-items: center; gap: .75rem; }
.rm__scrub input { width: min(16rem, 50vw); accent-color: var(--accent); min-height: 2.5rem; }
.rm__verdict { color: var(--ink); min-height: 1.5em; }
.rm.is-invalid .rm__verdict { color: var(--signal); }

@media (max-width: 52rem) {
  .rm__stage { grid-template-columns: 1fr; }
}

/* Fig. 2: workflow */
.workflow {
  margin-top: clamp(4rem, 8vw, 6rem);
  padding-top: 1.25rem;
  border-top: 1.5px solid var(--ink);
}
.workflow__kicker { color: var(--ink); margin-bottom: 1rem; }
.workflow__diagram { position: relative; }

.wf-step {
  appearance: none;
  background: none;
  border: 0;
  color: inherit;
  font: inherit;
  text-align: inherit;
  cursor: pointer;
  width: 100%;
  border-radius: 4px;
}
.wf-step__num { font-family: var(--mono); font-size: .72rem; color: var(--ink-2); }
.wf-step__title { font-size: 1.02rem; line-height: 1.25; transition: color .15s var(--ease); }
.wf-step:hover .wf-step__title { color: var(--accent); }
.wf-step[aria-selected="true"] .wf-step__title { font-weight: 600; }
.wf-step[aria-selected="true"] .wf-step__num { color: var(--accent); }

.wf-step::before {
  content: "";
  display: block;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 1.5px solid var(--ink);
  background: var(--paper);
  transition: background-color .2s var(--ease), transform .2s var(--ease);
}
.is-loop .wf-step::before { border-color: var(--signal); }
.wf-step[aria-selected="true"]::before { background: var(--accent); border-color: var(--accent); transform: scale(1.2); }
.is-loop .wf-step[aria-selected="true"]::before { background: var(--signal); border-color: var(--signal); }

.workflow__lines path { fill: none; vector-effect: non-scaling-stroke; }
.wf-base { stroke: var(--ink); stroke-width: 1.5; }
.wf-loop { stroke: var(--signal); stroke-width: 1.5; stroke-dasharray: 5 5; }

.workflow__loop-label,
.workflow__accept-label { position: absolute; color: var(--signal); white-space: nowrap; }
.workflow__accept-label { color: var(--accent); }
.workflow__note { margin-top: 1.25rem; color: var(--signal); }

@media (min-width: 48rem) {
  .workflow__steps {
    position: relative;
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    padding-top: 4.5rem;
  }
  .wf-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: .6rem;
    padding: 0 .4rem .9rem;
  }
  .wf-step::before { margin-top: -8px; }
  .workflow__lines { position: absolute; left: 0; top: 0; width: 100%; height: 4.5rem; overflow: visible; }
  .workflow__loop-label {
    top: .4rem;
    left: 41.667%;
    transform: translateX(-50%);
    background: var(--paper);
    padding-inline: .5rem;
  }
  .workflow__accept-label { top: calc(4.5rem - 1.6rem); left: 66.667%; transform: translateX(-50%); }
}

@media (max-width: 47.99rem) {
  .workflow__lines,
  .workflow__loop-label,
  .workflow__accept-label { display: none; }
  .workflow__steps {
    position: relative;
    display: grid;
    grid-auto-rows: 3.5rem;
    padding-right: 2.5rem;
  }
  .workflow__steps::before {
    content: "";
    position: absolute;
    left: 8px;
    top: 1.75rem;
    bottom: 1.75rem;
    border-left: 1.5px solid var(--ink);
  }
  .workflow__steps::after {
    content: "";
    position: absolute;
    right: .6rem;
    top: calc(3.5rem + 1rem);
    height: calc(3.5rem * 2 + 1.5rem);
    width: 1rem;
    border: 1.5px dashed var(--signal);
    border-left: 0;
  }
  .wf-step {
    display: grid;
    grid-template-columns: 16px 2rem minmax(0, 1fr);
    align-items: center;
    column-gap: .75rem;
    height: 100%;
  }
}

.workflow__panels { margin-top: 2.25rem; }
.wf-panel {
  display: grid;
  grid-template-columns: minmax(0, 9rem) minmax(0, var(--measure));
  column-gap: 2.5rem;
  row-gap: .6rem;
  padding-block: 1.5rem;
  border-top: 1px solid var(--rule);
}
.wf-panel > * { grid-column: 2; }
.wf-panel__num {
  grid-column: 1;
  grid-row: 1 / span 3;
  font-size: clamp(3.5rem, 7vw, 5.5rem);
  font-weight: 200;
  line-height: .9;
  letter-spacing: -.04em;
  color: var(--accent);
}
.wf-panel__title { font-size: 1.45rem; font-weight: 400; }
.wf-panel__why { color: var(--ink-2); font-size: 1.04rem; }
.wf-panel__why .annot { display: block; color: var(--accent); margin-bottom: .1rem; }

.js .wf-panel[hidden] { display: none; }
.js .wf-panel { border-top: 0; padding-top: .5rem; }
@media (prefers-reduced-motion: no-preference) {
  .js .wf-panel:not([hidden]) { animation: panel-in .3s var(--ease); }
  .js .workflow.is-looping .wf-loop { animation: march 1s linear infinite; }
}
@keyframes panel-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes march { to { stroke-dashoffset: -10; } }

@media (max-width: 40rem) {
  .wf-panel { grid-template-columns: 1fr; }
  .wf-panel > *,
  .wf-panel__num { grid-column: 1; grid-row: auto; }
}

/* Technical layer */
.tech {
  margin-top: clamp(3rem, 6vw, 4.5rem);
  border-top: 1.5px solid var(--ink);
  border-bottom: 1px solid var(--rule);
}
.tech summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: .4rem 1rem;
  min-height: 3.5rem;
  padding-block: 1.1rem;
}
.tech summary::-webkit-details-marker { display: none; }
.tech summary::before {
  content: "+";
  font-family: var(--mono);
  width: 1rem;
  color: var(--accent);
}
.tech[open] summary::before { content: "\2212"; }
.tech__label { font-size: 1.35rem; font-weight: 400; }
.tech summary:hover .tech__label { color: var(--accent); }
.tech__body { padding: 0 0 2rem 2rem; max-width: 52rem; }
.tech__list > div {
  display: grid;
  grid-template-columns: 7rem minmax(0, 1fr);
  gap: 1rem;
  padding-block: .7rem;
  border-top: 1px solid var(--rule);
}
.tech__list dt { font-family: var(--mono); font-size: .75rem; color: var(--ink-2); padding-top: .3rem; }
.tech__note { margin-top: 1.25rem; font-size: 1rem; color: var(--ink-2); }

@media (max-width: 40rem) {
  .tech__body { padding-left: 0; }
  .tech__list > div { grid-template-columns: 1fr; gap: .2rem; }
}

/* ---------- Lab ---------- */
.lab__intro {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 18rem);
  gap: clamp(2rem, 5vw, 4.5rem);
  align-items: start;
}
.lab__kicker { color: var(--accent); margin-bottom: .5rem; }
.lab__name {
  font-size: clamp(2.75rem, 6vw, 4.75rem);
  font-weight: 300;
  line-height: .95;
  letter-spacing: -.035em;
}
.lab__name a { text-decoration: none; }
.lab__name a::after { content: "\2197"; font-size: .4em; vertical-align: .9em; margin-left: .15em; color: var(--accent); }
.lab__expansion { font-style: italic; font-size: 1.2rem; color: var(--ink-2); margin: .6rem 0 1.5rem; }

.advisor { border-top: 3px solid var(--accent); padding-top: .9rem; }
.advisor__name { font-size: 1.6rem; line-height: 1.2; margin: .3rem 0 .4rem; }
.advisor__name a { text-decoration-color: var(--accent); }
.advisor__role { font-size: 1rem; line-height: 1.5; color: var(--ink-2); }
.advisor__links { display: flex; flex-wrap: wrap; gap: .25rem 1.25rem; margin-top: .9rem; }
.advisor__links a {
  display: inline-flex;
  align-items: center;
  min-height: 2.5rem;
  font-family: var(--mono);
  font-size: .78rem;
}
.advisor__links a::after { content: "\2197"; margin-left: .3rem; color: var(--accent); }

.themes {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(1.25rem, 3vw, 2.25rem);
  margin-top: clamp(3rem, 6vw, 4rem);
}
.theme { border-top: 1px solid var(--ink); padding-top: 1rem; }
.theme--home { border-top: 3px solid var(--accent); padding-top: calc(1rem - 2px); }
.theme__num { font-size: 2.75rem; font-style: italic; font-weight: 300; line-height: 1; color: var(--accent); margin-bottom: .75rem; }
.theme__title { font-size: 1.2rem; font-weight: 500; line-height: 1.25; margin-bottom: .55rem; }
.theme p:not(.theme__num):not(.theme__mine) { font-size: 1rem; line-height: 1.55; color: var(--ink-2); }
.theme__mine { margin-top: .8rem; color: var(--accent); }
.lab__note { margin-top: 2.5rem; max-width: var(--measure); font-size: 1rem; color: var(--ink-2); }

@media (max-width: 64rem) {
  .lab__intro { grid-template-columns: 1fr; }
  .advisor { max-width: 26rem; }
}
@media (max-width: 52rem) {
  .themes { grid-template-columns: 1fr; }
}

/* ---------- Timeline ---------- */
.timeline-fig { margin-top: .5rem; }
.timeline { --years: calc(var(--a1) - var(--a0)); position: relative; }
.timeline__axis,
.tl-row {
  display: grid;
  grid-template-columns: var(--rail) minmax(0, 1fr) minmax(16rem, .9fr);
  column-gap: clamp(1.5rem, 4vw, 3.5rem);
}
.timeline__axis {
  position: sticky;
  top: var(--header-h);
  z-index: 2;
  background: var(--paper);
  border-bottom: 1.5px solid var(--ink);
  padding-top: .5rem;
}
.timeline__ticks { grid-column: 3; position: relative; height: 1.6rem; }
.timeline__ticks span {
  position: absolute;
  bottom: .3rem;
  left: calc((var(--y) - var(--a0)) / var(--years) * 100%);
  font-family: var(--mono);
  font-size: .68rem;
  color: var(--ink-2);
  padding-left: 4px;
  border-left: 1px solid var(--rule-strong);
  line-height: 1;
}

.tl-row {
  padding-block: 1.2rem;
  border-bottom: 1px solid var(--rule);
  transition: opacity .2s var(--ease);
}
.tl-row__dates { font-family: var(--mono); font-size: .8rem; color: var(--ink); padding-top: .3rem; }
.tl-row__tag {
  font-family: var(--mono);
  font-size: .68rem;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--ink-2);
  margin-bottom: .25rem;
}
.tl-row.is-ongoing .tl-row__tag { color: var(--accent); }
.tl-row__title { font-size: 1.2rem; font-weight: 500; line-height: 1.3; }
.tl-row__org { font-size: 1rem; color: var(--ink-2); }
.tl-row__content p:last-child { margin-top: .25rem; font-size: 1.02rem; line-height: 1.5; }
.tl-row__content p.tl-row__tag:last-child { margin-top: 0; }

.tl-row__track {
  position: relative;
  margin-block: -1.2rem;
  background-image: repeating-linear-gradient(
    to right,
    var(--rule) 0 1px,
    transparent 1px calc(100% / var(--years))
  );
}
.tl-row__track::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: calc((var(--now) - var(--a0)) / var(--years) * 100%);
  border-left: 1.5px dashed var(--accent);
}
.tl-bar {
  --end: var(--e, var(--now));
  position: absolute;
  top: 1.95rem;
  height: 10px;
  left: calc((var(--s) - var(--a0)) / var(--years) * 100%);
  width: calc((var(--end) - var(--s)) / var(--years) * 100%);
  background: var(--ink-2);
  border-radius: 1px;
  transform-origin: left center;
  transition: transform .2s var(--ease);
}
.tl-row.is-ongoing .tl-bar {
  background: linear-gradient(to right, var(--accent) calc(100% - 14px), color-mix(in srgb, var(--accent) 30%, transparent));
}

/* Entrance: bars grow once when the timeline scrolls into view */
@media (prefers-reduced-motion: no-preference) {
  .js .timeline:not(.is-in) .tl-bar { transform: scaleX(0); }
  .js .timeline .tl-bar { transition: transform .7s var(--ease); }
  .js .timeline .tl-row:nth-child(2) .tl-bar { transition-delay: .05s; }
  .js .timeline .tl-row:nth-child(3) .tl-bar { transition-delay: .1s; }
  .js .timeline .tl-row:nth-child(4) .tl-bar { transition-delay: .15s; }
  .js .timeline .tl-row:nth-child(5) .tl-bar { transition-delay: .2s; }
  .js .timeline .tl-row:nth-child(6) .tl-bar { transition-delay: .25s; }
  .js .timeline .tl-row:nth-child(7) .tl-bar { transition-delay: .3s; }
}

@media (hover: hover) {
  .timeline__rows:hover .tl-row { opacity: .45; }
  .timeline__rows:hover .tl-row:hover { opacity: 1; }
}

@media (max-width: 64rem) {
  .timeline__axis,
  .tl-row { grid-template-columns: 7.5rem minmax(0, 1fr); }
  .timeline__ticks { grid-column: 2; }
  .tl-row__track { grid-column: 2; height: 1.75rem; margin: .8rem 0 -1.2rem; }
  .tl-bar { top: .5rem; }
}
@media (max-width: 40rem) {
  .timeline__axis,
  .tl-row { grid-template-columns: 1fr; }
  .timeline__ticks,
  .tl-row__track { grid-column: 1; }
  .timeline__ticks span[data-odd] { display: none; }
  .tl-row__dates { padding-top: 0; margin-bottom: .2rem; }
}

/* ---------- Education ---------- */
.education { margin-top: clamp(4rem, 8vw, 6rem); }
.degrees {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  border-top: 1.5px solid var(--ink);
}
.degree { padding: 1.4rem 2.5rem 0 0; }
.degree + .degree { padding-left: 2.5rem; border-left: 1px solid var(--rule); }
.degree__years { margin-bottom: .6rem; }
.degree__title { font-size: clamp(1.3rem, 2vw, 1.6rem); font-weight: 400; line-height: 1.2; }
.degree__field { font-style: italic; margin-top: .25rem; }
.degree__school { color: var(--ink-2); font-size: 1rem; }
.degree__facts { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 2.5rem; margin-top: 1.4rem; }
.degree__facts dt { font-family: var(--mono); font-size: .7rem; color: var(--ink-2); }
.degree__facts dd { font-size: 1.05rem; }
.degree__facts dd.degree__gpa {
  font-size: clamp(3rem, 5vw, 4rem);
  font-weight: 200;
  line-height: 1;
  letter-spacing: -.03em;
  font-variant-numeric: lining-nums tabular-nums;
}

@media (max-width: 44rem) {
  .degrees { grid-template-columns: 1fr; }
  .degree,
  .degree + .degree { padding: 1.4rem 0; border-left: 0; }
  .degree + .degree { border-top: 1px solid var(--rule); }
}

/* ---------- Project ---------- */
.project {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 21rem);
  gap: clamp(2rem, 5vw, 4.5rem);
  align-items: start;
}
.project__title {
  font-size: clamp(1.9rem, 3.6vw, 2.9rem);
  font-weight: 300;
  letter-spacing: -.02em;
  line-height: 1.05;
  margin: .5rem 0 1.25rem;
}
.pipeline { border-top: 1.5px solid var(--ink); padding-top: 1.25rem; }
.pipeline__flow { border-left: 1.5px solid var(--ink); margin-left: .4rem; }
.pipeline__node { position: relative; font-family: var(--mono); font-size: .8rem; padding: .6rem 0 .6rem 1.3rem; }
.pipeline__node::before {
  content: "";
  position: absolute;
  left: -6px;
  top: 50%;
  width: 10px;
  height: 10px;
  margin-top: -5px;
  background: var(--paper);
  border: 1.5px solid var(--ink);
  border-radius: 50%;
}
.pipeline__node--end::before { background: var(--accent); border-color: var(--accent); }
.pipeline__node--split { display: flex; flex-wrap: wrap; gap: .4rem; }
.pipeline__node--split span { border: 1px solid var(--rule-strong); border-radius: 999px; padding: .15rem .6rem; }

@media (max-width: 56rem) {
  .project { grid-template-columns: 1fr; }
  .pipeline { max-width: 24rem; }
}

/* ---------- Skills ---------- */
.skills { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); border-top: 1.5px solid var(--ink); }
.skills__group { padding: 1rem 1.5rem 0 0; }
.skills__group + .skills__group { padding-left: 1.5rem; border-left: 1px solid var(--rule); }
.skills__head { font-family: var(--mono); font-size: .75rem; font-weight: 400; color: var(--accent); margin-bottom: .7rem; }
.skills__group li { font-size: 1.15rem; line-height: 1.75; }
.skills__note { margin-top: 1.5rem; }

@media (max-width: 44rem) {
  .skills { grid-template-columns: 1fr; }
  .skills__group,
  .skills__group + .skills__group { padding: 1rem 0; border-left: 0; }
  .skills__group + .skills__group { border-top: 1px solid var(--rule); }
}

/* ---------- Contact ---------- */
.contact { padding-bottom: clamp(3rem, 6vw, 5rem); }
.contact__list { border-top: 1.5px solid var(--ink); }
.contact__list li {
  display: grid;
  grid-template-columns: 6rem minmax(0, 1fr);
  align-items: baseline;
  gap: .5rem 1.5rem;
  padding-block: 1.4rem;
  border-bottom: 1px solid var(--rule);
}
.contact__big {
  font-size: clamp(1.7rem, 5.2vw, 4.25rem);
  font-weight: 300;
  line-height: 1.05;
  letter-spacing: -.025em;
  text-decoration-thickness: 1px;
  text-underline-offset: .15em;
  overflow-wrap: anywhere;
}
.contact__big--secondary { font-size: clamp(1.35rem, 3vw, 2.25rem); }
.contact__tools { grid-column: 2; display: flex; align-items: center; gap: 1rem; }
.copy-status { color: var(--accent); }

@media (max-width: 40rem) {
  .contact__list li { grid-template-columns: 1fr; }
  .contact__tools { grid-column: 1; }
}

/* ---------- Footer ---------- */
.site-footer__inner {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: .5rem 2rem;
  padding-block: 1.75rem 2.5rem;
  /* rule spans the content width only, not the wrap padding */
  background: linear-gradient(var(--rule), var(--rule)) center top / calc(100% - 2 * var(--gutter)) 1px no-repeat;
  font-size: .95rem;
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
}

/* ---------- Print ---------- */
@media print {
  .site-header, .skip-link, .copy-btn, .workflow__diagram, .workflow__note, .rm { display: none !important; }
  .js .wf-panel[hidden] { display: grid !important; }
  .section--dark, .site-footer { background: #fff; color: #000; --ink: #000; --ink-2: #333; --paper: #fff; }
  body { background: #fff; }
  .section__rail { position: static; }
}

/* Small screens: keep figure labels legible once the SVGs scale down */
@media (max-width: 40rem) {
  .rm-state text { font-size: 17px; }
  .rm-edge-labels text,
  .rm-readout { font-size: 15px; }
  .rm-label,
  .rm-marker text { font-size: 13px; }
}
