/* ------------------------------------------------------------------
   Tokens
   The accent is set from the photo playground (hue + chroma in OKLCH,
   lightness fixed per theme so contrast holds for every color).
------------------------------------------------------------------- */
@property --acc-h { syntax: "<number>"; inherits: true; initial-value: 262; }
@property --acc-c { syntax: "<number>"; inherits: true; initial-value: 0.13; }

:root {
  --paper: #f4f5f6;
  --surface: #ffffff;
  --ink: #15171a;
  --ink-2: #474d56;
  --ink-3: #7a818b;
  --rule: #e1e4e8;
  --rule-2: #c9ced5;
  --shade: rgba(21, 23, 26, 0.72);

  --acc-l: 0.5;
  --acc-h: 262;
  --acc-c: 0.13;
  --accent: #2f5fd0;

  --sans: "Archivo", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --step--1: 0.8125rem;  /* 13 */
  --step-0: 1rem;        /* 16 */
  --step-1: 1.1875rem;   /* 19 */
  --step-2: 1.5rem;      /* 24 */
  --step-3: clamp(2rem, 1.4rem + 2.2vw, 2.75rem);

  --gutter: clamp(16px, 4vw, 40px);
  --maxw: 1120px;

  color-scheme: light;
  transition: --acc-h 0.6s ease, --acc-c 0.6s ease;
}

@supports (color: oklch(0.5 0.1 200)) {
  :root { --accent: oklch(var(--acc-l) var(--acc-c) var(--acc-h)); }
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #111315;
    --surface: #181b1f;
    --ink: #eceef1;
    --ink-2: #b0b6be;
    --ink-3: #7f8791;
    --rule: #262a30;
    --rule-2: #353a41;
    --shade: rgba(0, 0, 0, 0.7);
    --acc-l: 0.8;
    --accent: #8fb0ff;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #111315;
  --surface: #181b1f;
  --ink: #eceef1;
  --ink-2: #b0b6be;
  --ink-3: #7f8791;
  --rule: #262a30;
  --rule-2: #353a41;
  --shade: rgba(0, 0, 0, 0.7);
  --acc-l: 0.8;
  --accent: #8fb0ff;
  color-scheme: dark;
}
@supports (color: oklch(0.5 0.1 200)) {
  @media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) { --accent: oklch(var(--acc-l) var(--acc-c) var(--acc-h)); }
  }
  :root[data-theme="dark"] { --accent: oklch(var(--acc-l) var(--acc-c) var(--acc-h)); }
}

/* ------------------------------------------------------------------
   Base
------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 72px; -webkit-text-size-adjust: 100%; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: var(--step-0);
  line-height: 1.6;
  font-variation-settings: "wdth" 100;
  -webkit-font-smoothing: antialiased;
}

img, video, canvas { max-width: 100%; display: block; }
[hidden] { display: none !important; }

a {
  color: inherit;
  text-decoration-line: underline;
  text-decoration-color: color-mix(in srgb, var(--accent) 55%, transparent);
  text-decoration-thickness: 1.5px;
  text-underline-offset: 3px;
  transition: text-decoration-color 0.2s, color 0.2s;
}
a:hover { text-decoration-color: var(--accent); color: var(--accent); }

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

button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }

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

/* ------------------------------------------------------------------
   Header
------------------------------------------------------------------- */
.top {
  position: sticky;
  top: env(safe-area-inset-top, 0px);
  z-index: 10;
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--rule);
}
.top-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-block: 12px;
}
.top-name {
  font-weight: 600;
  font-variation-settings: "wdth" 112;
  letter-spacing: -0.01em;
  text-decoration: none;
  white-space: nowrap;
}
.top-name:hover { color: var(--ink); }
.top-name { transition: opacity 0.25s ease; }
.top.name-off .top-name { opacity: 0; pointer-events: none; }
.top-nav { display: flex; align-items: center; gap: clamp(12px, 3vw, 28px); font-family: var(--mono); font-size: var(--step--1); }
.top-nav a { text-decoration: none; color: var(--ink-2); }
.top-nav a:hover { color: var(--ink); }
.top-nav .cv {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--ink);
  border: 1px solid var(--rule-2);
  border-radius: 999px;
  padding: 5px 13px 5px 10px;
  transition: border-color 0.2s, background 0.2s;
}
.top-nav .cv:hover { border-color: var(--accent); color: var(--ink); background: var(--surface); }
.top-nav .cv svg { width: 14px; height: 14px; }
@media (max-width: 460px) {
  .top-name { font-size: 0.9375rem; }
  .top-nav a:not(.cv) { display: none; }
}

/* ------------------------------------------------------------------
   Hero: photo playground on the left, bio on the right.
   The photo's size follows the window height so the tabs, photo,
   caption and controls all fit on the first screen.
------------------------------------------------------------------- */
.hero {
  --vh: 100vh;
  --img-h: clamp(260px, calc(var(--vh) - 392px), 470px);
  --img-w: calc(var(--img-h) * 720 / 869);
  --col-w: max(300px, var(--img-w));
  display: grid;
  grid-template-columns: var(--col-w) minmax(0, 1fr);
  column-gap: clamp(32px, 5vw, 72px);
  padding-block: 22px clamp(40px, 5vw, 64px);
  align-items: start;
}
@supports (height: 100svh) { .hero { --vh: 100svh; } }
.play-col { min-width: 0; }


.nowrap { white-space: nowrap; }
.bio h1 {
  margin: 0;
  font-size: var(--step-3);
  line-height: 1.02;
  font-weight: 650;
  font-variation-settings: "wdth" 118;
  letter-spacing: -0.025em;
  text-wrap: balance;
}
.role {
  margin: 10px 0 18px;
  font-family: var(--mono);
  font-size: var(--step--1);
  color: var(--ink-3);
}
.bio p { max-width: 62ch; margin: 0 0 13px; color: var(--ink-2); }
.bio .lead {
  color: var(--ink);
  font-size: var(--step-1);
  line-height: 1.45;
  font-weight: 500;
  max-width: 44ch;
  text-wrap: pretty;
}
.contact {
  list-style: none;
  margin: 16px 0 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 20px;
  font-family: var(--mono);
  font-size: var(--step--1);
}
/* Phones: name and one line first, then the photo, then the rest of the bio. */
@media (max-width: 719px) {
  .hero {
    --img-w: min(100%, calc(46 * var(--vh) / 100 * 720 / 869));
    display: flex;
    flex-direction: column;
    padding-top: 20px;
  }
  .bio { display: contents; }
  .bio h1 { order: 1; }
  .bio .role { order: 2; }
  .bio .lead { order: 3; margin-bottom: 20px; }
  .play-col { order: 4; margin-bottom: 32px; }
  .bio p:not(.lead):not(.role) { order: 5; }
  .contact { order: 6; }
}

/* --- Tabs ---------------------------------------------------------- */
.modes {
  display: flex;
  gap: 16px;
  margin-bottom: 10px;
  font-family: var(--mono);
  font-size: 12.5px;
  border-bottom: 1px solid var(--rule);
}
.modes button {
  padding: 2px 0 8px;
  color: var(--ink-3);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  white-space: nowrap;
  transition: color 0.2s, border-color 0.3s;
}
.modes button:hover { color: var(--ink); }
.modes button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent); }

/* --- Photo --------------------------------------------------------- */
.photo { margin: 0; }
.stage {
  position: relative;
  width: var(--img-w);
  max-width: 100%;
  aspect-ratio: 720 / 869;
  overflow: hidden;
  border-radius: 3px;
  background: var(--rule);
  user-select: none;
  -webkit-user-select: none;
}
.layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
#fx-canvas, #nc-canvas { opacity: 0; }
#fx-canvas { object-fit: fill; } /* renders are 624 x 768, a slight squeeze of the photo; fill undoes it */
.hero[data-mode="nc"] #nc-canvas.ready { opacity: 1; }
.hero:not([data-mode="nc"]) #fx-canvas.ready { opacity: 1; }
.stage.own #frame-a { visibility: hidden; }
.stage.own #nc-canvas, .stage.own #original { object-fit: contain; }
#original { opacity: 0; transition: opacity 0.12s; pointer-events: none; }
.stage.own #original { background: var(--rule); }
.stage.comparing #original { opacity: 1; }

.hold, .standin {
  position: absolute;
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1;
  color: #fff;
  background: rgba(15, 16, 18, 0.62);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border-radius: 999px;
  padding: 6px 10px;
}
.hold { right: 8px; bottom: 8px; touch-action: none; }
.hold:hover { background: rgba(15, 16, 18, 0.8); }
.standin { left: 8px; top: 8px; background: rgba(15, 16, 18, 0.5); }

figcaption {
  margin-top: 8px;
  min-height: calc(3 * 1.45em);
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--ink-2);
  text-wrap: pretty;
}
figcaption b { font-weight: 600; color: var(--ink); }
figcaption a { font-family: var(--mono); font-size: 11.5px; white-space: nowrap; }

/* --- Controls ------------------------------------------------------ */
.panels { display: grid; margin-top: 12px; container-type: inline-size; }
.panel { grid-area: 1 / 1; min-width: 0; }
.panel.is-off { visibility: hidden; }

/* NamedCurves: color names | curve + channel, actions underneath */
.nc-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas: "left curve" "actions actions";
  column-gap: 14px;
}
.nc-left { grid-area: left; min-width: 0; }
.curve-row { grid-area: curve; display: flex; align-items: flex-start; gap: 6px; }
.nc-actions { grid-area: actions; }

.cats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
@container (min-width: 360px) { .cats { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.cat {
  position: relative;
  height: 24px;
  border-radius: 4px;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.14);
  transition: transform 0.15s;
}
.cat:hover { transform: translateY(-1px); }
.cat[aria-checked="true"]::after {
  content: "";
  position: absolute;
  inset: -3px;
  border-radius: 6px;
  border: 1.5px solid var(--ink);
}
.cat .edited {
  position: absolute;
  right: 3px;
  top: 3px;
  width: 6px; height: 6px; border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.5);
  visibility: hidden;
}
.cat.is-edited .edited { visibility: visible; }
.cat-name {
  margin: 10px 0 0;
  font-family: var(--mono);
  font-size: 11.5px;
  line-height: 1.45;
  color: var(--ink);
}
.cat-name span { color: var(--ink-3); }

#curve {
  flex: none;
  width: 148px;
  height: 148px;
  touch-action: none;
  cursor: ns-resize;
  border-radius: 3px;
}
@container (min-width: 380px) { #curve { width: 168px; height: 168px; } }
.chan {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--rule-2);
  border-radius: 4px;
  overflow: hidden;
  font-family: var(--mono);
  font-size: 11px;
}
.chan button { padding: 4px 0; width: 34px; color: var(--ink-2); }
.chan button + button { border-top: 1px solid var(--rule-2); }
.chan button[aria-checked="true"] { background: var(--ink); color: var(--paper); }

.nc-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 14px;
  margin-top: 10px;
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--ink-2);
}
.toggle { display: inline-flex; align-items: center; gap: 5px; cursor: pointer; }
.toggle input { accent-color: var(--ink); margin: 0; }
.textbtn { color: var(--ink-2); text-decoration: underline; text-decoration-color: var(--rule-2); text-underline-offset: 3px; cursor: pointer; }
.textbtn:hover { color: var(--ink); text-decoration-color: var(--accent); }
.upload { position: relative; }
.upload input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.upload:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Sliders (SyncLight, UniSlider) */
.slider-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: baseline;
  gap: 2px 12px;
  margin-top: 14px;
  max-width: 360px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink-3);
}
.slider-row output {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  text-align: right;
}
.slider-row input { grid-column: 1 / -1; }
.dot { width: 10px; height: 10px; border-radius: 50%; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.2); }

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 26px;
  background: transparent;
  margin: 0;
  cursor: pointer;
  --track: var(--rule-2);
  --track-h: 2px;
}
input[type="range"]::-webkit-slider-runnable-track { height: var(--track-h); border-radius: 999px; background: var(--track); }
input[type="range"]::-moz-range-track { height: var(--track-h); border-radius: 999px; background: var(--track); }
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px; height: 18px;
  margin-top: calc(var(--track-h) / 2 - 9px);
  border-radius: 50%;
  background: var(--surface);
  border: 1.5px solid var(--ink);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.18);
}
input[type="range"]::-moz-range-thumb {
  width: 15px; height: 15px;
  border-radius: 50%;
  background: var(--surface);
  border: 1.5px solid var(--ink);
}
/* One tick per frame, inset by half the thumb so ticks sit under the thumb's stops */
input.track-ticks {
  --track:
    repeating-linear-gradient(90deg, var(--ink-3) 0 1px, transparent 1px 12.5%) 8.5px 0 / calc(100% - 17px) 100% no-repeat,
    linear-gradient(var(--ink-3), var(--ink-3)) calc(100% - 8.5px) 0 / 1px 100% no-repeat,
    var(--rule-2);
  --track-h: 6px;
}
input.track-hue, input.track-int { --track-h: 8px; }
input.track-hue { --track: linear-gradient(90deg, #ff6c69, #ff984d, #ffe27f, #a5ffa5, #5cfffc, #5bbbff, #f885ff); } /* replaced by blocks in site.js */
input.track-int { --track: linear-gradient(90deg, #1b1c1e, #ff984d); }
input.track-hue::-webkit-slider-runnable-track, input.track-int::-webkit-slider-runnable-track { box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.12); }

.slider-row:first-child { margin-top: 0; }
.prompt-box + .slider-row { margin-top: 10px; }
.prompt-box {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin: 10px 0 0;
  padding: 8px 10px;
  min-height: calc(2 * 1.45em + 16px);
  background: var(--surface);
  border: 1px solid var(--rule-2);
  border-radius: 4px;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.45;
  color: var(--ink);
}
.prompt-label { flex: none; color: var(--ink-3); }
#us-prompt-text.typing::after {
  content: "";
  display: inline-block;
  width: 7px;
  height: 1.05em;
  margin-left: 1px;
  vertical-align: -2px;
  background: var(--accent);
  animation: caret 0.8s steps(1) infinite;
}
@keyframes caret { 50% { opacity: 0; } }

/* UniSlider prompts */
.prompts { display: flex; flex-wrap: wrap; gap: 8px; }
.prompt {
  font-family: var(--mono);
  font-size: 12px;
  padding: 6px 11px;
  border: 1px solid var(--rule-2);
  border-radius: 999px;
  color: var(--ink-2);
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.prompt:hover { color: var(--ink); border-color: var(--ink-3); }
.prompt[aria-checked="true"] { color: var(--ink); border-color: var(--accent); background: var(--surface); }

/* ------------------------------------------------------------------
   Sections
------------------------------------------------------------------- */
.block { padding-block: clamp(28px, 4vw, 44px); border-top: 1px solid var(--rule); }
.block-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 12px 24px; }
.block h2 {
  margin: 0 0 20px;
  font-size: var(--step-2);
  line-height: 1.2;
  font-weight: 600;
  font-variation-settings: "wdth" 112;
  letter-spacing: -0.015em;
}

/* News */
.news { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; max-width: 900px; }
.news li {
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr);
  gap: 20px;
  align-items: baseline;
}
.news time {
  font-family: var(--mono);
  font-size: var(--step--1);
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.news .text { color: var(--ink-2); max-width: 70ch; }
.news .text strong { color: var(--ink); font-weight: 600; }
.news li.is-extra { display: none; }
.news.open li.is-extra { display: grid; }
@media (max-width: 520px) {
  .news li { grid-template-columns: minmax(0, 1fr); gap: 0; }
}
.more {
  margin-top: 18px;
  font-family: var(--mono);
  font-size: var(--step--1);
  color: var(--ink-2);
  text-decoration: underline;
  text-decoration-color: var(--rule-2);
  text-underline-offset: 3px;
}
.more:hover { color: var(--ink); text-decoration-color: var(--accent); }

/* Publications */
.filter {
  display: inline-flex;
  gap: 16px;
  font-family: var(--mono);
  font-size: var(--step--1);
  margin-bottom: 20px;
}
.filter button { color: var(--ink-3); padding-bottom: 2px; border-bottom: 1.5px solid transparent; }
.filter button:hover { color: var(--ink); }
.filter button[aria-checked="true"] { color: var(--ink); border-bottom-color: var(--accent); }
.filter .n { color: var(--ink-3); }

.year {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 8px 0 18px;
  font-family: var(--mono);
  font-size: var(--step--1);
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}
.year::after { content: ""; flex: 1; height: 1px; background: var(--rule); }
.year-group + .year-group .year { margin-top: 28px; }
.year-group[hidden] { display: none; }

.pub {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: clamp(16px, 3vw, 32px);
  align-items: start;
  padding-block: 14px;
}
.pub[hidden] { display: none; }
.thumb {
  position: relative;
  border-radius: 3px;
  overflow: hidden;
  background: var(--surface);
  box-shadow: 0 0 0 1px var(--rule);
}
.thumb img, .thumb video { width: 100%; height: auto; }
.thumb-empty {
  aspect-ratio: 2 / 1;
  display: grid;
  place-items: center;
  font-family: var(--mono);
  font-size: var(--step--1);
  color: var(--ink-3);
  background:
    repeating-linear-gradient(135deg, transparent 0 7px, var(--rule) 7px 8px),
    var(--surface);
}
.thumb-empty span { background: var(--surface); padding: 3px 8px; border-radius: 2px; }
.thumb .play-dot {
  position: absolute;
  right: 7px;
  bottom: 7px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(15, 16, 18, 0.55);
  display: grid;
  place-items: center;
  transition: opacity 0.2s;
}
.thumb .play-dot::before {
  content: "";
  margin-left: 2px;
  border-left: 7px solid #fff;
  border-top: 4.5px solid transparent;
  border-bottom: 4.5px solid transparent;
}
.thumb.playing .play-dot { opacity: 0; }

.pub h3 {
  margin: 0 0 4px;
  font-size: 1.0625rem;
  line-height: 1.35;
  font-weight: 600;
  text-wrap: balance;
}
.pub h3 a { text-decoration: none; }
.pub h3 a:hover { color: var(--ink); text-decoration: underline; text-decoration-color: var(--accent); }
.pub .authors { margin: 0 0 6px; font-size: 0.9375rem; line-height: 1.5; color: var(--ink-2); }
.pub .authors .me { color: var(--ink); font-weight: 600; }
.pub .venue {
  margin: 0 0 8px;
  font-family: var(--mono);
  font-size: var(--step--1);
  color: var(--ink);
}
.pub .venue .short { color: var(--ink-3); }
.pub .links {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
  margin: 0;
  padding: 0;
  list-style: none;
  font-family: var(--mono);
  font-size: var(--step--1);
}
.pub .links a { color: var(--ink-2); }
.pub .links a:hover { color: var(--accent); }

@media (max-width: 640px) {
  .pub { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .thumb { max-width: 420px; }
}

/* ------------------------------------------------------------------
   Footer
------------------------------------------------------------------- */
.foot { border-top: 1px solid var(--rule); }
.foot-inner {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px 24px;
  padding-block: 24px 40px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink-3);
}
.foot p { margin: 0; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
}
