/* ---------- Tokens ---------- */

:root {
  --bg: #fbfaf7;
  --surface: #ffffff;
  --ink: #1b1d22;
  --muted: #5b6070;
  --faint: #868b96;
  --line: #e6e2da;
  --accent: #2944a8;
  --accent-ink: #ffffff;
  --accent-soft: #eaedf9;
  --warm: #c0403a;
  /* moving-mesh hero (space-separated RGB so the canvas can add alpha) */
  --mesh-line: rgb(27 29 34 / 0.2);
  --mesh-warm: 192 64 58;
  --mesh-cool: 41 68 168;

  --serif: "Newsreader", Georgia, "Times New Roman", serif;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --maxw: 1040px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1115;
    --surface: #161a21;
    --ink: #e8e9ec;
    --muted: #a3a9b5;
    --faint: #757c88;
    --line: #262b34;
    --accent: #95a8ff;
    --accent-ink: #0f1115;
    --accent-soft: #1b2240;
    --warm: #ff8c7d;
    --mesh-line: rgb(232 233 236 / 0.16);
    --mesh-warm: 255 120 104;
    --mesh-cool: 110 140 255;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #0f1115;
  --surface: #161a21;
  --ink: #e8e9ec;
  --muted: #a3a9b5;
  --faint: #757c88;
  --line: #262b34;
  --accent: #95a8ff;
  --accent-ink: #0f1115;
  --accent-soft: #1b2240;
  --warm: #ff8c7d;
  --mesh-line: rgb(232 233 236 / 0.16);
  --mesh-warm: 255 120 104;
  --mesh-cool: 110 140 255;
  color-scheme: dark;
}

/* ---------- Base ---------- */

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

html { -webkit-text-size-adjust: 100%; scroll-padding-top: 88px; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 17px/1.65 var(--sans);
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  text-decoration-color: color-mix(in srgb, var(--accent) 35%, transparent);
}
a:hover { text-decoration-color: currentColor; }

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

h1, h2, h3 {
  font-family: var(--serif);
  font-weight: 500;
  line-height: 1.2;
  letter-spacing: -0.01em;
  margin: 0;
}

.container { max-width: var(--maxw); margin: 0 auto; padding: 0 24px; }

.eyebrow {
  font-family: var(--mono);
  font-size: 0.75rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 14px;
}

/* ---------- Header ---------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  -webkit-backdrop-filter: saturate(1.4) blur(10px);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 4px 24px;
  min-height: 64px;
}

.brand {
  font-family: var(--serif);
  font-size: 1.3rem;
  font-weight: 500;
  color: var(--ink);
  text-decoration: none;
}

.site-nav { display: flex; align-items: center; gap: 2px; }

.site-nav a {
  position: relative;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.95rem;
  font-weight: 500;
  padding: 6px 10px;
  border-radius: 6px;
}
.site-nav a:hover { color: var(--ink); background: var(--accent-soft); }
.site-nav a[aria-current="page"] { color: var(--ink); }
.site-nav a[aria-current="page"]::after {
  content: "";
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: 1px;
  height: 2px;
  background: var(--accent);
  border-radius: 2px;
}

.theme-toggle,
.mesh-toggle {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  font-size: 0.9rem;
}
.theme-toggle { margin-left: 8px; }
.theme-toggle:hover,
.mesh-toggle:hover { color: var(--accent); border-color: var(--accent); }

.theme-toggle .fa-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .fa-sun { display: inline-block; }
:root[data-theme="dark"] .theme-toggle .fa-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .fa-sun { display: inline-block; }
  :root:not([data-theme="light"]) .theme-toggle .fa-moon { display: none; }
}

/* ---------- Home: hero ---------- */

.hero {
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  gap: 56px;
  align-items: center;
  padding: 72px 0 64px;
}

.hero h1 {
  font-size: clamp(2.6rem, 5vw, 3.6rem);
  letter-spacing: -0.02em;
  margin-bottom: 18px;
}

.lede {
  font-family: var(--serif);
  font-size: 1.35rem;
  line-height: 1.45;
  margin: 0 0 16px;
}

.bio { color: var(--muted); margin: 0; }

.link-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 28px; }

.chip-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  font-size: 0.9rem;
  font-weight: 500;
  text-decoration: none;
}
.chip-link:hover { border-color: var(--accent); color: var(--accent); }
.chip-link.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.chip-link.primary:hover { filter: brightness(1.1); color: var(--accent-ink); }

.mesh-figure { margin: 0; }

.mesh-frame {
  position: relative;
  aspect-ratio: 1 / 1;
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  background: var(--surface);
}
.mesh-frame canvas { display: block; width: 100%; height: 100%; }

.mesh-toggle { position: absolute; right: 10px; bottom: 10px; width: 32px; height: 32px; font-size: 0.75rem; }
.mesh-toggle .fa-play { display: none; }
.mesh-toggle[data-paused="true"] .fa-play { display: inline-block; }
.mesh-toggle[data-paused="true"] .fa-pause { display: none; }

.mesh-figure figcaption {
  margin-top: 10px;
  font-family: var(--mono);
  font-size: 0.72rem;
  line-height: 1.6;
  color: var(--faint);
}
.mesh-figure .warm { color: var(--warm); }
.mesh-figure .cool { color: var(--accent); }

/* ---------- Sections ---------- */

.section { padding: 48px 0; border-top: 1px solid var(--line); }

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px 16px;
  margin-bottom: 20px;
}
.section-head h2 { font-size: 1.75rem; }
.section-head a { font-size: 0.9rem; font-weight: 500; text-decoration: none; }
.section-head a:hover { text-decoration: underline; }

.cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }

.card {
  display: flex;
  flex-direction: column;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: inherit;
  text-decoration: none;
  transition: border-color 0.2s, transform 0.2s;
}
.card:hover { border-color: var(--accent); transform: translateY(-2px); }
.card .num { font-family: var(--mono); font-size: 0.75rem; color: var(--accent); }
.card h3 { font-size: 1.2rem; margin: 10px 0 8px; }
.card p { margin: 0; color: var(--muted); font-size: 0.93rem; line-height: 1.55; }

.news, .timeline, .pub-list { list-style: none; margin: 0; padding: 0; }

.news li,
.timeline li {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 16px;
  padding: 12px 0;
  border-bottom: 1px dashed var(--line);
}
.news li:last-child, .timeline li:last-child { border-bottom: 0; }

.news time,
.timeline .when {
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--faint);
  padding-top: 3px;
}

.timeline .what strong { display: block; font-weight: 600; }
.timeline .what span { display: block; color: var(--muted); font-size: 0.93rem; }

/* ---------- Publications ---------- */

.pub {
  display: grid;
  grid-template-columns: 64px 1fr;
  gap: 16px;
  padding: 16px 0;
  border-bottom: 1px solid var(--line);
}
.pub:last-child { border-bottom: 0; }

.pub-year { font-family: var(--mono); font-size: 0.8rem; color: var(--faint); padding-top: 4px; }

.pub p { margin: 0; }

.pub .pub-title {
  font-family: var(--serif);
  font-size: 1.15rem;
  font-weight: 500;
  line-height: 1.35;
  margin-bottom: 4px;
}
.pub-title a { color: var(--ink); text-decoration: none; }
.pub-title a:hover { color: var(--accent); }

.pub-authors, .pub-venue { color: var(--muted); font-size: 0.93rem; }
.pub-authors strong { color: var(--ink); font-weight: 600; }

.pub .pub-links { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }

.tag {
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 3px 8px;
  border: 1px solid var(--line);
  border-radius: 5px;
  color: var(--muted);
  text-decoration: none;
}
.tag:hover { border-color: var(--accent); color: var(--accent); }

/* ---------- Inner pages ---------- */

.page-head { padding: 64px 0 40px; }
.page-head h1 { font-size: clamp(2.2rem, 4.5vw, 3rem); letter-spacing: -0.02em; max-width: 20ch; }
.page-head p:not(.eyebrow) { color: var(--muted); max-width: 62ch; font-size: 1.05rem; margin: 16px 0 0; }

.pub-group { padding: 36px 0; border-top: 1px solid var(--line); }
.pub-group h2 { font-size: 1.5rem; margin-bottom: 8px; }
.count { font-family: var(--mono); font-size: 0.8rem; color: var(--faint); vertical-align: middle; margin-left: 6px; }

.project {
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  gap: 56px;
  align-items: center;
  padding: 56px 0;
  border-top: 1px solid var(--line);
}
.project:nth-child(even) .project-media { order: 2; }

.project-media { margin: 0; }
.project-media video {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 460px;
  margin: 0 auto;
  border-radius: 12px;
  background: var(--surface);
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.06), 0 8px 24px rgb(0 0 0 / 0.08);
}

.project-text h2 { font-size: 1.8rem; margin: 0 0 12px; }
.project-text p { color: var(--muted); margin: 0 0 18px; }
.project-link { font-size: 0.95rem; font-weight: 500; text-decoration: none; }
.project-link:hover { text-decoration: underline; }

/* ---------- Footer ---------- */

.site-footer { border-top: 1px solid var(--line); margin-top: 48px; padding: 28px 0 36px; }

.footer-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px 24px;
}

.social { display: flex; gap: 4px; margin-left: -10px; }
.social a {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  color: var(--muted);
  font-size: 1.1rem;
  text-decoration: none;
}
.social a:hover { color: var(--accent); background: var(--accent-soft); }

.site-footer p { margin: 0; font-size: 0.85rem; color: var(--faint); }

/* ---------- Responsive ---------- */

@media (max-width: 820px) {
  .hero { grid-template-columns: 1fr; gap: 36px; padding: 48px 0; }
  .mesh-frame { aspect-ratio: 4 / 3; }
  .cards { grid-template-columns: 1fr; }
  .project { grid-template-columns: 1fr; gap: 24px; padding: 40px 0; }
  .project:nth-child(even) .project-media { order: 0; }
}

@media (max-width: 600px) {
  body { font-size: 16px; }
  .container { padding: 0 16px; }
  .header-inner { padding-top: 10px; padding-bottom: 6px; }
  .site-nav { width: 100%; margin-left: -10px; }
  .theme-toggle { margin-left: auto; }
  .news li, .timeline li, .pub { grid-template-columns: 1fr; gap: 2px; }
  .page-head { padding: 40px 0 28px; }
}

@media (prefers-reduced-motion: reduce) {
  .card { transition: none; }
  .card:hover { transform: none; }
}
