/* ==========================================================================
   M. Onurcan Kaya: personal site (v2)
   One stylesheet, no framework. Tokens → base → layout → components.
   ========================================================================== */

@font-face {
  font-family: "Inter";
  src: url("../fonts/inter.woff2") format("woff2");
  font-weight: 400 700;
  font-style: normal;
  font-display: optional;
}
@font-face {
  font-family: "Newsreader";
  src: url("../fonts/newsreader-roman.woff2") format("woff2");
  font-weight: 400 600;
  font-style: normal;
  font-display: optional; /* preloaded: used if it arrives before first paint, never a late swap (no layout shift) */
}
@font-face {
  font-family: "Newsreader";
  src: url("../fonts/newsreader-italic.woff2") format("woff2");
  font-weight: 400;
  font-style: italic;
  font-display: optional;
}

/* ---------- Tokens ---------- */
:root {
  color-scheme: light;
  --bg: #fbfaf7;
  --panel: #f2f0ea;
  --paper: #ffffff;
  --thumb: #ffffff;
  --ink: #18181b;
  --ink-2: #46464e;
  --ink-3: #6b6b74;
  --rule: #e5e2da;
  --rule-strong: #d3cfc5;
  --accent: #3346d3;
  --accent-hover: #2433ad;
  --on-accent: #ffffff;
  --accent-soft: rgba(51, 70, 211, 0.08);
  --accent-2: #c2560f;
  --marker: #f4a73b;
  --chart: #3346d3;
  --good: #15803d;
  --good-soft: #eaf6ee;
  --bad: #c2410c;
  --nav-bg: rgba(251, 250, 247, 0.85);
  --paper-shadow: 0 1px 2px rgba(20, 20, 30, 0.06), 0 0 0 1px rgba(20, 20, 30, 0.04);

  --serif: "Newsreader", "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", "JetBrains Mono", Menlo, Consolas, monospace;

  --w: 1040px;
  --gutter: clamp(18px, 4.5vw, 32px);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #111114; --panel: #18181d; --paper: #202026; --thumb: #f4f4f2;
    --ink: #ececf0; --ink-2: #babac3; --ink-3: #8f8f9a; --rule: #28282f; --rule-strong: #3a3a43;
    --accent: #9eabff; --accent-hover: #c3caff; --on-accent: #111114; --accent-soft: rgba(158, 171, 255, 0.12); --accent-2: #f29a55; --marker: #e89a2c;
    --chart: #6f7ff0; --good: #4ade80; --good-soft: rgba(74, 222, 128, 0.1); --bad: #fb923c;
    --nav-bg: rgba(17, 17, 20, 0.82); --paper-shadow: 0 0 0 1px #2c2c34;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #111114; --panel: #18181d; --paper: #202026; --thumb: #f4f4f2;
  --ink: #ececf0; --ink-2: #babac3; --ink-3: #8f8f9a; --rule: #28282f; --rule-strong: #3a3a43;
  --accent: #9eabff; --accent-hover: #c3caff; --on-accent: #111114; --accent-soft: rgba(158, 171, 255, 0.12); --accent-2: #f29a55; --marker: #e89a2c;
  --chart: #6f7ff0; --good: #4ade80; --good-soft: rgba(74, 222, 128, 0.1); --bad: #fb923c;
  --nav-bg: rgba(17, 17, 20, 0.82); --paper-shadow: 0 0 0 1px #2c2c34;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: 16px; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 400 1rem/1.65 var(--sans);
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
  overflow-x: clip;
}
img, video, canvas, svg { display: block; max-width: 100%; }
p, h1, h2, h3, dl, dd, figure { margin: 0; }
button { font: inherit; color: inherit; }
fieldset { margin: 0; padding: 0; border: 0; min-width: 0; }
a {
  color: var(--accent);
  text-decoration-line: underline; text-decoration-thickness: 1px; text-underline-offset: 0.2em;
  text-decoration-color: color-mix(in srgb, currentColor 35%, transparent);
  transition: color 0.15s, text-decoration-color 0.15s;
}
a:hover { color: var(--accent-hover); text-decoration-color: currentColor; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }
code { font-family: var(--mono); font-size: 0.86em; }

.wrap { width: 100%; max-width: calc(var(--w) + 2 * var(--gutter)); margin-inline: auto; padding-inline: var(--gutter); }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.i { width: 1.05em; height: 1.05em; flex: none; display: inline-block; vertical-align: -0.16em; }
.muted { color: var(--ink-3); }
.no-js .js-only { display: none !important; }
.skip {
  position: absolute; left: 12px; top: -64px; z-index: 100; padding: 10px 16px; border-radius: 10px;
  background: var(--ink); color: var(--bg); font-weight: 600; text-decoration: none;
}
.skip:focus { top: 12px; color: var(--bg); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px; height: 42px; padding: 0 18px; cursor: pointer;
  border: 1px solid var(--rule-strong); border-radius: 999px; background: transparent;
  color: var(--ink); font: 500 0.94rem/1 var(--sans); text-decoration: none;
  transition: background 0.15s, border-color 0.15s, color 0.15s, transform 0.15s;
}
.btn:hover { color: var(--ink); border-color: var(--ink-3); transform: translateY(-1px); }
.btn:active { transform: none; }
.btn-primary { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.btn-primary:hover { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn-small { height: 34px; padding: 0 14px; font-size: 0.86rem; gap: 6px; }
.icon-link {
  width: 42px; height: 42px; display: inline-grid; place-items: center; border-radius: 999px;
  color: var(--ink-2); transition: background 0.15s, color 0.15s;
}
.icon-link:hover { background: var(--panel); color: var(--ink); }
.icon-link .i { width: 20px; height: 20px; }
.icon-btn {
  width: 32px; height: 32px; display: inline-grid; place-items: center; flex: none; cursor: pointer;
  border: 1px solid var(--rule); border-radius: 999px; background: transparent; color: var(--ink-2);
  transition: color 0.15s, border-color 0.15s;
}
.icon-btn:hover { color: var(--accent); border-color: var(--accent); }
.icon-btn .i { width: 15px; height: 15px; }

/* ---------- Hero: text on the left; photo with the contact buttons under it on the right ---------- */
.hero {
  display: grid; grid-template-columns: minmax(0, 1fr) 232px; column-gap: clamp(28px, 5vw, 64px);
  align-items: start; padding-block: clamp(20px, 3vw, 40px) clamp(28px, 3.5vw, 44px);
}
.hero-side { display: grid; gap: 12px; align-self: start; margin-top: 28px; } /* a little lower than the name */
.hero-photo { width: 100%; height: auto; aspect-ratio: 1; object-fit: cover; border-radius: 22px; }
h1 { font-family: var(--serif); font-weight: 500; font-size: clamp(2.3rem, 1.8rem + 2.6vw, 4rem); line-height: 1.02; letter-spacing: -0.028em; }
.zh {
  font-family: "Songti SC", "Noto Serif CJK SC", "Noto Serif SC", "Source Han Serif SC", STSong, SimSun, serif;
  font-size: 0.5em; font-weight: 400; letter-spacing: 0.04em; color: var(--ink-3); white-space: nowrap;
}
.lede {
  margin-top: 12px; max-width: 36em;
  font-family: var(--serif); font-size: clamp(1.22rem, 1.1rem + 0.6vw, 1.48rem); line-height: 1.4; letter-spacing: -0.005em;
}
.lede em { color: var(--accent); }
.hero-meta { margin-top: 10px; max-width: 40em; font-size: 0.96rem; color: var(--ink-3); }
.hero-meta a { color: var(--ink-2); }
.hero-meta a:hover { color: var(--accent); }
.badges { list-style: none; margin: 14px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.badge { display: inline-flex; align-items: center; gap: 8px; padding: 6px 13px 6px 11px; border-radius: 999px; font-size: 0.88rem; font-weight: 600; line-height: 1.35; }
.badge-good { background: var(--good-soft); color: var(--good); }
.badge-accent { background: var(--accent-soft); color: var(--accent); }
/* A soft ring pulses behind each badge icon ("available now"); the two alternate. Off with reduced motion. */
.badge-icon { position: relative; display: inline-grid; place-items: center; width: 16px; height: 16px; flex: none; }
.badge-icon .i { position: relative; width: 16px; height: 16px; }
.badge-icon::before {
  content: ""; position: absolute; inset: -3px; border-radius: 50%; background: currentColor; opacity: 0;
  animation: badge-pulse 2.4s ease-out infinite;
}
.badge-accent .badge-icon::before { animation-delay: 1.2s; }
@keyframes badge-pulse { 0% { transform: scale(0.55); opacity: 0.32; } 75%, 100% { transform: scale(1.4); opacity: 0; } }
.actions { display: grid; gap: 8px; }
.actions .btn-primary { justify-content: center; }
.actions-row { display: flex; align-items: center; gap: 2px; }
.actions-row .btn { padding: 0 14px; margin-right: 4px; }
.actions-row .icon-link { width: 38px; height: 38px; }

/* ---------- Sections ---------- */
.section { padding-block: clamp(32px, 4.5vw, 52px); border-top: 1px solid var(--rule); }
h2 { font-family: var(--serif); font-weight: 500; font-size: clamp(1.85rem, 1.55rem + 1.3vw, 2.4rem); line-height: 1.1; letter-spacing: -0.022em; }
.section-lede { margin-top: 10px; max-width: 64ch; color: var(--ink-2); font-size: 1rem; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; flex-wrap: wrap; gap: 8px 16px; }
.quiet-link { display: inline-flex; align-items: center; gap: 4px; color: var(--ink-2); font-size: 0.94rem; font-weight: 500; text-decoration: none; }

/* ---------- Research intro: heading + text left, timeline right ---------- */
.intro { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); gap: 20px clamp(24px, 4vw, 52px); align-items: start; }
/* grey = before deployment, amber = deployment, blue = test time (my work) */
.tl-fig { display: grid; grid-template-columns: minmax(0, 0.85fr) 104px minmax(0, 1.25fr); grid-template-rows: auto 1fr auto; gap: 10px 14px; margin: 0; }
.tlf-title { grid-row: 1; align-self: end; text-align: center; font: 700 0.86rem/1.25 var(--sans); color: var(--ink-2); }
.tlf-t-before { grid-column: 1; }
.tlf-t-after { grid-column: 3; color: var(--accent); }
/* bottom padding = one box + the arrow, so post-training sits level with the gap between the two routes */
.tlf-flow { grid-row: 2; grid-column: 1; align-self: center; display: grid; padding-bottom: calc(2.52rem + 14px); text-align: center; font-size: 0.84rem; line-height: 1.5; color: var(--ink); }
.tlf-flow span:not(.tlf-arr) { position: relative; padding: 7px 6px; border-radius: 8px; background: var(--panel); }
.tlf-arr { justify-self: center; line-height: 1.5; color: var(--ink-3); transform: rotate(90deg); }
/* the arrow from post-training runs on across the deployment line, into test time */
.tlf-flow span:last-child::after { content: ""; position: absolute; z-index: 1; left: 100%; top: 50%; width: 124px; height: 2px; margin-top: -1px; background: var(--ink-3); }
.tlf-flow span:last-child::before { content: ""; position: absolute; z-index: 1; left: calc(100% + 124px); top: 50%; margin-top: -5px; border-style: solid; border-width: 5px 0 5px 8px; border-color: transparent transparent transparent var(--ink-3); }
.tlf-routes { grid-row: 2; grid-column: 3; align-self: center; display: grid; gap: 10px; }
.tlf-route { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 9px; padding: 8px 10px; border-radius: 10px; background: var(--accent-soft); font-size: 0.8rem; line-height: 1.35; color: var(--ink-3); text-decoration: none; transition: box-shadow 0.15s; }
.tlf-route:hover { color: var(--ink-3); box-shadow: inset 0 0 0 1.5px var(--accent); }
.tlf-route b { display: block; font-size: 0.88rem; font-weight: 650; color: var(--ink); }
.tlf-n { display: grid; place-items: center; width: 20px; height: 20px; margin-top: 1px; border-radius: 50%; background: var(--accent); color: var(--on-accent); font: 700 0.72rem/1 var(--sans); }
.tlf-cap { grid-row: 3; text-align: center; text-wrap: balance; font-size: 0.8rem; line-height: 1.35; color: var(--ink-3); }
.tlf-cap b { color: var(--ink); }
.tlf-cap-before { grid-column: 1; }
.tlf-cap-after { grid-column: 3; }
.tlf-marker { grid-row: 1 / 4; grid-column: 2; position: relative; display: grid; justify-items: center; align-content: start; }
.tlf-marker::before { content: ""; position: absolute; top: 0; bottom: 0; left: 50%; width: 4px; margin-left: -2px; border-radius: 2px; background: var(--marker); }
.tlf-marker span { position: relative; display: grid; padding: 6px 7px; border-radius: 7px; background: var(--marker); color: #241600; font: 700 0.76rem/1.25 var(--sans); text-align: center; }
.tlf-marker small { font-size: 0.68rem; font-weight: 500; text-wrap: balance; }
@media (max-width: 859px) { .intro { grid-template-columns: minmax(0, 1fr); } .tl-fig { max-width: 560px; } }
@media (max-width: 520px) { /* phones: the timeline runs top to bottom */
  .tl-fig { grid-template-columns: minmax(0, 1fr); grid-template-rows: none; gap: 8px; }
  .tl-fig > * { grid-column: 1; }
  .tlf-t-before { grid-row: 1; } .tlf-flow { grid-row: 2; } .tlf-cap-before { grid-row: 3; } .tlf-marker { grid-row: 4; }
  .tlf-t-after { grid-row: 5; } .tlf-routes { grid-row: 6; } .tlf-cap-after { grid-row: 7; }
  .tlf-flow { grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: 8px; padding-bottom: 0; }
  .tlf-arr { transform: none; }
  .tlf-flow span:last-child::before, .tlf-flow span:last-child::after { display: none; }
  .tlf-marker { padding-block: 6px; }
  .tlf-marker::before { top: 50%; bottom: auto; left: 0; right: 0; width: auto; height: 4px; margin: -2px 0 0; }
}

/* ---------- Research routes ---------- */
.route {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 420px);
  gap: clamp(20px, 3.5vw, 48px); align-items: center; margin-top: clamp(28px, 4vw, 44px);
}
.route:nth-of-type(even) { grid-template-columns: minmax(0, 420px) minmax(0, 1fr); } /* alternate sides for rhythm */
/* a section that opens with a route: its heading sits in the text column, centered against the figure */
.section > .route:first-child { margin-top: 0; }
.route-text > h2 { margin-bottom: clamp(14px, 2vw, 20px); }
.route:nth-of-type(even) .route-text { order: 2; }
.route-text { max-width: 48ch; }
.kicker { font: 650 0.72rem/1 var(--sans); letter-spacing: 0.12em; text-transform: uppercase; color: var(--accent); }
.route h3 { margin-top: 6px; font-family: var(--serif); font-weight: 500; font-size: clamp(1.5rem, 1.3rem + 0.8vw, 1.85rem); line-height: 1.12; letter-spacing: -0.015em; }
.route-text > p:not(.kicker) { margin-top: 8px; color: var(--ink-2); }

/* ---------- Figures (shared) ---------- */
.fig { container-type: inline-size; }
.fig-body { background: var(--panel); border-radius: 18px; padding: clamp(12px, 3.6cqi, 18px); }
.fig figcaption { margin-top: 8px; padding-inline: 4px; font-size: 0.84rem; line-height: 1.5; color: var(--ink-3); }
.fig figcaption b { color: var(--ink); font-weight: 600; }
.fig-no { font: 600 0.72rem/1 var(--mono); letter-spacing: 0.02em; margin-right: 4px; }
.q-tag { flex: none; font: 600 0.64rem/1 var(--mono); letter-spacing: 0.03em; text-transform: uppercase; color: var(--ink-3); border: 1px solid var(--rule-strong); border-radius: 5px; padding: 3px 5px; }
.demo-q { display: flex; align-items: baseline; gap: 8px; min-height: 1.5em; margin-bottom: 10px; font-size: 0.95rem; color: var(--ink); }
.verdict { display: inline-flex; align-items: center; gap: 6px; color: var(--ink-3); font-weight: 600; }
.verdict b { color: var(--ink); font-weight: 650; }
.verdict .i { width: 16px; height: 16px; }
.verdict.is-right .i { color: var(--good); }
.verdict.is-wrong .i { color: var(--bad); }
.demo .btn-small { margin-top: 14px; }
.stage { position: relative; aspect-ratio: 3 / 2; overflow: hidden; border-radius: 12px; background: var(--paper); }
.stage img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.stage-tag { position: absolute; left: 8px; top: 8px; z-index: 2; padding: 3px 9px; border-radius: 999px; font: 600 0.72rem/1.3 var(--sans); color: #fff; background: rgba(0, 0, 0, 0.6); transition: background 0.15s; }

/* Numbered steps (Figs. 1 and 2): they light up one at a time */
.steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; }
.step { display: grid; grid-template-columns: 22px minmax(0, 1fr); gap: 10px; }
.step .step-body > :not(.step-t) { transition: opacity 0.4s ease; }
.step.is-dim .step-body > :not(.step-t) { opacity: 0.25; }
.step.is-dim .step-t { color: var(--ink-3); }
.step.is-dim .tta-hint, .step.is-dim .demo-out { visibility: hidden; } /* nothing to read until the step runs */
.step-n { width: 22px; height: 22px; display: grid; place-items: center; border-radius: 50%; background: var(--accent); color: var(--on-accent); font: 700 0.72rem/1 var(--sans); transition: background 0.3s; }
.step.is-dim .step-n { background: var(--ink-3); }
.step-t { margin: 2px 0 8px; font-size: 0.88rem; font-weight: 600; line-height: 1.35; color: var(--ink); }
.case { display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: 12px; align-items: center; }
.case-img { width: 96px; height: 72px; object-fit: cover; object-position: 50% 55%; border-radius: 8px; }
.case-q { margin-bottom: 4px; font-size: 0.92rem; color: var(--ink); }

/* Fig. 1: practice problems (SIMIT) */
.practice { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.practice-item { display: grid; grid-template-columns: 56px minmax(0, 1fr); gap: 10px; align-items: center; }
.practice-item img { width: 56px; height: 56px; object-fit: cover; border-radius: 8px; filter: blur(6px) grayscale(1); opacity: 0.3; transition: filter 0.6s ease, opacity 0.6s ease; }
.practice-item.has-img img { filter: none; opacity: 1; }
.practice-item p { font-size: 0.85rem; line-height: 1.4; color: var(--ink-2); opacity: 0; transition: opacity 0.4s ease; }
.practice-item.has-q p { opacity: 1; }
.practice-q { display: block; }
.practice-a { font-weight: 650; color: var(--accent); }
.practice-a::before { content: "Answer: "; font-weight: 500; color: var(--ink-3); }

/* Fig. 2: look again (TTAug) */
.tta-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(4, 1fr); gap: 3px; width: min(100%, 300px); aspect-ratio: 10 / 7; }
.tta-tile {
  background-size: 400% 400%; background-color: var(--rule-strong); border-radius: 3px; cursor: pointer;
  opacity: 0.25; transform: scale(0.88); transition: opacity 0.3s, transform 0.35s cubic-bezier(0.2, 0.9, 0.3, 1.2), box-shadow 0.15s;
  transition-delay: var(--d, 0ms);
}
.tta.is-near .tta-tile { background-image: url("../img/ttaug-views.webp"); }
.tta.is-many .tta-tile { opacity: 1; transform: none; }
.tta-tile.is-hot { box-shadow: 0 0 0 2px var(--accent); position: relative; z-index: 1; }
.tta-hint { margin-top: 6px; min-height: 2.7em; font-size: 0.8rem; line-height: 1.35; color: var(--ink-3); }
.tta-qtag { font-weight: 600; color: var(--ink-2); }
.tta-qtext.is-aug { font-family: var(--mono); font-size: 0.78rem; color: var(--accent); }

/* Fig. 3: two kinds of edits (POEM, WildLight) */
.tabs { display: flex; width: fit-content; max-width: 100%; gap: 2px; padding: 3px; margin-bottom: 12px; border: 1px solid var(--rule); border-radius: 999px; background: var(--bg); }
.tab { padding: 6px 12px; border: 0; border-radius: 999px; background: transparent; cursor: pointer; font-size: 0.84rem; font-weight: 500; color: var(--ink-2); transition: background 0.15s, color 0.15s; }
.tab:hover { color: var(--ink); }
.tab[aria-selected="true"] { background: var(--ink); color: var(--bg); }
/* Both tab panels share one grid cell, so the figure keeps the taller panel's height on either tab;
   the POEM photo grows to fill the space */
.fig-body.edit { display: grid; grid-template-rows: auto 1fr; }
.edit .tabs { grid-row: 1; grid-column: 1; justify-self: start; }
.edit-panel { grid-row: 2; grid-column: 1; display: flex; flex-direction: column; min-width: 0; }
.edit-panel[hidden] { display: flex; visibility: hidden; }
.edit-stage { flex: 1 1 auto; aspect-ratio: auto; min-height: 220px; }
button.stage { display: block; width: 100%; padding: 0; border: 0; font: inherit; color: inherit; text-align: left; }
.edit-stage { cursor: pointer; }
.edit-stage:hover .stage-tag, .edit-stage:focus-visible .stage-tag { background: var(--accent); }
.edit-stage img { transition: opacity 0.5s ease; }
.edit-after { opacity: 0; }
.edit-stage.is-after .edit-after { opacity: 1; }
.sun-range { -webkit-appearance: none; appearance: none; display: block; width: 100%; height: 30px; margin: 10px 0 2px; background: transparent; cursor: pointer; }
.sun-range::-webkit-slider-runnable-track { height: 6px; border-radius: 999px; background: linear-gradient(90deg, #8ec5ff, #ffd36b 55%, #ff8a3d); }
.sun-range::-moz-range-track { height: 6px; border-radius: 999px; background: linear-gradient(90deg, #8ec5ff, #ffd36b 55%, #ff8a3d); }
.sun-range::-webkit-slider-thumb { -webkit-appearance: none; width: 24px; height: 24px; margin-top: -9px; border-radius: 50%; background: #f5b301; border: 3px solid #fff3c4; box-shadow: 0 0 0 5px rgba(245, 179, 1, 0.28), 0 1px 3px rgba(0, 0, 0, 0.3); cursor: grab; }
.sun-range::-moz-range-thumb { width: 18px; height: 18px; border-radius: 50%; background: #f5b301; border: 3px solid #fff3c4; box-shadow: 0 0 0 5px rgba(245, 179, 1, 0.28); cursor: grab; }
.sun-range:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; border-radius: 999px; }
.relight-target { display: grid; grid-template-columns: minmax(0, 46%) minmax(0, 1fr); gap: 12px; align-items: center; margin-bottom: 10px; }
.relight-env { position: relative; aspect-ratio: 295 / 144; overflow: hidden; border-radius: 8px; background: var(--paper); }
.relight-env img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.relight-target p { display: grid; gap: 6px; justify-items: start; font-size: 0.86rem; line-height: 1.35; color: var(--ink-2); }
.relight-ticks { display: flex; justify-content: space-between; font: 500 0.7rem/1 var(--mono); color: var(--ink-3); font-variant-numeric: tabular-nums; }
.relight-ticks .is-on { color: var(--ink); font-weight: 650; }

/* Fig. 4: classical phase retrieval (HIO), measurement + three runs */
.pr-tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.pr-tile canvas { display: block; width: 100%; height: auto; aspect-ratio: 1; border-radius: 8px; background: #000; box-shadow: 0 0 0 2px transparent; transition: box-shadow 0.3s; }
.pr-tile.is-best canvas { box-shadow: 0 0 0 2px var(--good); }
.pr-cap { margin-top: 5px; text-align: center; font-size: 0.74rem; font-weight: 600; line-height: 1.3; color: var(--ink-2); }
.pr-cap span { display: block; font-size: 0.68rem; font-weight: 500; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.pr-tile.is-best .pr-fit { color: var(--good); }
.pr-tile.is-best .pr-fit::after { content: " · best fit"; }
.pr-controls { display: flex; align-items: center; gap: 10px; margin-top: 12px; }
.pr-controls .btn-small { margin-top: 0; flex: none; }
.pr-step { white-space: nowrap; font: 500 0.76rem/1 var(--mono); color: var(--ink-3); font-variant-numeric: tabular-nums; }
.pr-step b { color: var(--ink); font-weight: 600; display: inline-block; min-width: 3ch; }
.pr-range { flex: 1; min-width: 0; accent-color: var(--chart); }
@container (max-width: 360px) { .pr-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* ---------- Publications ---------- */
.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 20px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 13px; cursor: pointer;
  border: 1px solid var(--rule-strong); border-radius: 999px; background: transparent;
  color: var(--ink-2); font: 500 0.86rem/1 var(--sans); transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.chip:hover { border-color: var(--ink-3); color: var(--ink); }
.chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.chip-n { font: 500 0.72rem/1 var(--mono); opacity: 0.7; }
.pubs { list-style: none; margin: 24px 0 0; padding: 0; }
.pub[hidden] { display: none; }
.pub { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: clamp(18px, 3.5vw, 32px); padding-block: 0 24px; }
/* a rule only between papers that are shown, so the top one never has one, whatever the filter */
.pub:not([hidden]) ~ .pub { padding-top: 24px; border-top: 1px solid var(--rule); }
.pub.is-flash { animation: flash 1.8s ease; }
@keyframes flash { 0%, 30% { background: var(--accent-soft); box-shadow: 0 0 0 14px var(--accent-soft); } 100% { background: transparent; box-shadow: 0 0 0 14px transparent; } }
.pub-media { display: block; position: relative; aspect-ratio: 3 / 2; align-self: start; overflow: hidden; border-radius: 10px; background: var(--thumb); box-shadow: var(--paper-shadow); }
.pub-media > img, .pub-media > video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; padding: 6px; }
.pub-media > video { padding: 0; }
/* Card hover (or keyboard focus): the figure zooms in slightly inside its frame, an accent ring appears,
   and the title turns accent. Multi-frame thumbnails also cycle (frames load on first hover). */
.pub-media { transition: box-shadow 0.3s ease; }
.pub-media > img, .pub-media > video { transition: transform 0.6s cubic-bezier(0.2, 0.7, 0.2, 1), opacity 0.35s ease; }
.pub:focus-within .pub-media { box-shadow: 0 0 0 1.5px var(--accent); }
.pub:focus-within .pub-media > img, .pub:focus-within .pub-media > video { transform: scale(1.04); }
@media (hover: hover) {
  .pub:hover .pub-media { box-shadow: 0 0 0 1.5px var(--accent); }
  .pub:hover .pub-media > img, .pub:hover .pub-media > video { transform: scale(1.04); }
  .pub:hover .pub-title a { color: var(--accent); }
}
.pub-media.is-ready > img { opacity: 0; }
.pub-media.is-ready > img.is-active { opacity: 1; }
.pub-venue { display: flex; flex-wrap: wrap; gap: 6px; }
.venue { padding: 5px 8px; border: 1px solid var(--rule-strong); border-radius: 6px; font: 600 0.74rem/1 var(--sans); letter-spacing: 0.01em; color: var(--ink-2); }
.venue-main { color: var(--accent); background: var(--accent-soft); border-color: transparent; }
.pub-title { margin-top: 10px; font-family: var(--serif); font-weight: 500; font-size: 1.28rem; line-height: 1.25; letter-spacing: -0.006em; text-wrap: balance; }
.pub-title a { color: var(--ink); text-decoration: none; }
.pub-title a:hover { color: var(--accent); text-decoration: underline; text-decoration-thickness: 1px; }
.pub-authors { margin-top: 6px; font-size: 0.92rem; color: var(--ink-3); }
.pub-authors a { color: inherit; text-decoration: none; }
.pub-authors a:hover { color: var(--ink); text-decoration: underline; }
.me { color: var(--ink); font-weight: 600; }
.pub-tldr { margin-top: 8px; max-width: 68ch; font-size: 0.95rem; color: var(--ink-2); }
.pub-links { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.pill {
  display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 11px;
  border: 1px solid var(--rule-strong); border-radius: 999px; font-size: 0.82rem; font-weight: 550; color: var(--ink-2); text-decoration: none;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.pill .i { width: 14px; height: 14px; }
.pill:hover { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }

/* ---------- Background (timeline) ---------- */
.timeline { list-style: none; margin: 18px 0 0; padding: 0; display: grid; gap: 16px; }
.tl { display: grid; grid-template-columns: 7.5em minmax(0, 1fr); gap: 16px; }
.tl-when { padding-top: 2px; font: 500 0.82rem/1.6 var(--mono); color: var(--ink-3); font-variant-numeric: tabular-nums; }
.tl-what { font-weight: 600; color: var(--ink); }
.tl-what span { font-weight: 400; color: var(--ink-3); }
.tl-what span a { color: inherit; }
.tl-detail { margin-top: 2px; max-width: 72ch; font-size: 0.94rem; color: var(--ink-2); }

/* ---------- Responsive ---------- */
@media (max-width: 859px) {
  .hero {
    grid-template-columns: 76px minmax(0, 1fr); column-gap: 14px; align-items: center;
    grid-template-areas: "photo name" "lede lede" "meta meta" "badges badges" "actions actions";
  }
  .hero-main, .hero-side { display: contents; }
  .hero-photo { grid-area: photo; width: 76px; border-radius: 18px; }
  .hero h1 { grid-area: name; font-size: clamp(1.9rem, 1.3rem + 3vw, 2.6rem); }
  .lede { grid-area: lede; margin-top: 14px; }
  .hero-meta { grid-area: meta; }
  .badges { grid-area: badges; }
  .actions { grid-area: actions; margin-top: 14px; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
  .route { grid-template-columns: minmax(0, 1fr); }
  .route:nth-of-type(even) { grid-template-columns: minmax(0, 1fr); }
  .route:nth-of-type(even) .route-text { order: 0; }
  .route-text { max-width: 64ch; padding-top: 0; }
  .fig { max-width: 480px; }
}
@media (max-width: 480px) {
  .actions { gap: 6px; }
  .actions-row .icon-link { width: 36px; height: 36px; }
}
@media (max-width: 640px) {
  .tl { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .pub { grid-template-columns: 104px minmax(0, 1fr); gap: 16px; }
  .pub-media { aspect-ratio: 1; }
  .pub-media > img { padding: 3px; }
  .pub-title { font-size: 1.1rem; }
  .pub-tldr { font-size: 0.92rem; }
}

/* ---------- Motion & print ---------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; transition-delay: 0ms !important; }
}
@media print {
  .skip, .js-only, .actions { display: none !important; }
  body { background: #fff; color: #000; }
  .section { border: 0; padding-block: 24px; }
  .pub { break-inside: avoid; }
}
