/* ============ design tokens ============ */
:root {
  --bg: #ffffff;
  --bg-alt: #f8fafc;
  --text: #1a1a1a;
  --muted: #6b7280;
  --hairline: #e5e7eb;
  --accent: #4f46e5;
  --gt: #9ca3af;
  --pred: #e11d48;
  --mod-v: #3b82f6;
  --mod-t: #10b981;
  --mod-a: #f59e0b;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16,24,40,.05), 0 8px 24px -12px rgba(16,24,40,.12);
  --font-ui: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-serif: 'Source Serif 4', Georgia, serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, monospace;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-ui);
  font-size: 16.5px;
  line-height: 1.65;
  color: var(--text);
  background: var(--bg);
}
img { max-width: 100%; height: auto; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* the site is designed to read like Chrome's 90% zoom on tablet/desktop */
@media (min-width: 768px) {
  body { zoom: 0.9; }
}

.container { max-width: 980px; margin: 0 auto; padding: 0 18px; }

/* ============ nav ============ */
.nav {
  position: sticky; top: 0; z-index: 50;
  background: rgba(255,255,255,.85);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--hairline);
}
.nav-inner {
  max-width: 980px; margin: 0 auto; padding: 0 18px;
  display: flex; align-items: center; gap: 18px; height: 52px;
}
.nav-brand {
  display: flex; align-items: center; gap: 8px;
  font-weight: 700; color: var(--text); font-size: 15px; flex-shrink: 0;
}
.nav-brand:hover { text-decoration: none; }
.nav-ext { display: flex; align-items: center; gap: 14px; margin-left: auto; }
.nav-ext a {
  display: inline-flex; align-items: center;
  color: var(--muted); font-size: 13.5px; font-weight: 600;
  transition: color .15s;
}
.nav-ext a:hover { color: var(--text); text-decoration: none; }

/* ============ right-side TOC (sits just outside the content column) ============ */
.toc {
  position: fixed; left: calc(50% + 512px); top: 50%; transform: translateY(-50%);
  z-index: 40; display: none; flex-direction: column; gap: 2px;
  border-left: 1px solid var(--hairline); padding-left: 4px;
}
@media (min-width: 1280px) { .toc { display: flex; } }
.toc a {
  display: flex; align-items: center; gap: 9px;
  padding: 5px 10px 5px 12px; border-radius: 8px;
  color: var(--muted); font-size: 13px; font-weight: 500;
  transition: color .15s, background .15s;
}
.toc a:hover { text-decoration: none; color: var(--text); background: var(--bg-alt); }
.toc a i {
  width: 6px; height: 6px; border-radius: 50%;
  background: #d1d5db; flex-shrink: 0;
  transition: background .2s, transform .2s, box-shadow .2s;
}
.toc a.active { color: var(--accent); font-weight: 600; }
.toc a.active i { background: var(--accent); transform: scale(1.35); box-shadow: 0 0 0 4px rgba(79,70,229,.14); }

/* floating TOC button + sheet (mobile / tablet) */
.toc-fab {
  position: fixed; right: 16px; bottom: max(18px, env(safe-area-inset-bottom));
  z-index: 60; width: 48px; height: 48px; border-radius: 50%;
  border: 1px solid var(--hairline); background: rgba(255,255,255,.92);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  color: #374151; display: grid; place-items: center; cursor: pointer;
  box-shadow: 0 4px 18px -4px rgba(16,24,40,.25);
  transition: transform .15s;
}
.toc-fab:active { transform: scale(.94); }
@media (min-width: 1280px) { .toc-fab { display: none; } }
.toc-sheet { position: fixed; inset: 0; z-index: 70; }
.toc-sheet-backdrop { position: absolute; inset: 0; background: rgba(17,24,39,.4); backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px); }
.toc-sheet-panel {
  position: absolute; right: 12px; bottom: max(76px, calc(env(safe-area-inset-bottom) + 58px));
  min-width: 190px; background: #fff; border-radius: 16px;
  box-shadow: 0 12px 40px -8px rgba(16,24,40,.35);
  padding: 12px 8px 8px; display: flex; flex-direction: column;
  animation: sheet-in .18s ease-out;
}
@keyframes sheet-in { from { opacity: 0; transform: translateY(10px) scale(.97); } }
.toc-sheet-panel p {
  margin: 0 0 6px; padding: 0 12px; font-size: 11px; font-weight: 700;
  letter-spacing: .1em; text-transform: uppercase; color: var(--muted);
}
.toc-sheet-panel a {
  padding: 10px 12px; border-radius: 10px; color: var(--text);
  font-size: 15px; font-weight: 500;
}
.toc-sheet-panel a:hover { background: var(--bg-alt); text-decoration: none; }
.toc-sheet-panel a.active { color: var(--accent); background: #eef2ff; font-weight: 600; }

/* ============ hero ============ */
.hero {
  padding: 54px 0 38px;
  text-align: center;
  background:
    radial-gradient(900px 380px at 15% -10%, rgba(59,130,246,.07), transparent 60%),
    radial-gradient(900px 380px at 85% -10%, rgba(16,185,129,.07), transparent 60%),
    radial-gradient(700px 320px at 50% 0%, rgba(245,158,11,.05), transparent 60%);
}
.hero-venue {
  margin: 0 0 12px;
  color: #dc2626;
  font-size: 19px; font-weight: 700; letter-spacing: .16em;
}
.hero-title {
  font-family: var(--font-serif);
  font-size: clamp(28px, 5.6vw, 46px);
  line-height: 1.18; margin: 0 auto 18px; max-width: 21em; font-weight: 700;
}
.grad {
  background: linear-gradient(90deg,
    var(--mod-v), var(--mod-t) 25%, var(--mod-a) 50%, var(--mod-t) 75%, var(--mod-v) 100%);
  background-size: 200% 100%;
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: transparent;
}
@media (prefers-reduced-motion: no-preference) {
  .grad { animation: grad-slide 7s linear infinite; }
}
@keyframes grad-slide {
  from { background-position: 0% 0; }
  to   { background-position: -200% 0; }
}
.hero-authors { font-size: 16px; margin: 0 0 4px; }
.hero-authors a {
  color: var(--text); font-weight: 500;
  text-decoration: underline;
  text-decoration-color: #c3c9d4;
  text-decoration-thickness: 1.5px;
  text-underline-offset: 3.5px;
  transition: color .15s, text-decoration-color .15s;
}
.hero-authors a:hover { color: var(--accent); text-decoration-color: var(--accent); }
.hero-affil { color: var(--text); margin: 8px 0 3px; font-size: 18px; font-weight: 400; }
.hero-affil-note { color: var(--muted); margin: 0 0 24px; font-size: 13.5px; }
.stat b.stat-vta { font-size: 17px; letter-spacing: 0; line-height: 31px; }
.stat-vta em { font-style: normal; font-weight: 700; }
.m-v { color: var(--mod-v); } .m-t { color: var(--mod-t); } .m-a { color: var(--mod-a); }
.hero-buttons { display: flex; flex-wrap: wrap; gap: 9px; justify-content: center; margin-bottom: 30px; }
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 16px; border-radius: 999px;
  background: #1a1a1a; color: #fff; font-size: 14px; font-weight: 500;
  transition: transform .12s, box-shadow .12s;
}
.btn:hover { text-decoration: none; transform: translateY(-1px); box-shadow: 0 6px 16px -6px rgba(0,0,0,.4); }
.hero-stats {
  display: flex; flex-wrap: wrap; justify-content: center;
  gap: 10px 34px; padding-top: 22px; border-top: 1px solid var(--hairline);
  max-width: 760px; margin: 0 auto;
}
.stat b { display: block; font-size: 21px; letter-spacing: -.01em; }
.stat span { font-size: 12.5px; color: var(--muted); }

/* ============ sections ============ */
.section { padding: 58px 0; }
.section-alt { background: var(--bg-alt); border-top: 1px solid var(--hairline); border-bottom: 1px solid var(--hairline); }
.section h2 {
  font-family: var(--font-serif);
  font-size: clamp(23px, 3.6vw, 31px);
  line-height: 1.25; margin: 0 0 18px; font-weight: 700;
  scroll-margin-top: 70px;
}
.kicker {
  display: block; font-family: var(--font-ui);
  font-size: 12.5px; font-weight: 700; letter-spacing: .12em;
  text-transform: uppercase; color: var(--accent); margin-bottom: 8px;
}
.sub-heading { font-family: var(--font-serif); font-size: 21px; margin: 40px 0 10px; scroll-margin-top: 70px; }
.lead { font-size: 17px; }
.footnote { font-size: 13.5px; color: var(--muted); }
section { scroll-margin-top: 56px; }

figure { margin: 26px 0; }
figure img {
  width: 100%; border: 1px solid var(--hairline); border-radius: var(--radius);
  background: #fff; padding: 10px;
}
figcaption { font-size: 13.5px; color: var(--muted); margin-top: 9px; line-height: 1.5; }
.fig-pair { display: grid; grid-template-columns: 1fr; gap: 4px 20px; }
@media (min-width: 768px) { .fig-pair { grid-template-columns: 1fr 1fr; } }

.cards { display: grid; grid-template-columns: 1fr; gap: 14px; margin-top: 26px; }
@media (min-width: 768px) { .cards { grid-template-columns: repeat(3, 1fr); } }
.mini-card {
  background: #fff; border: 1px solid var(--hairline); border-radius: var(--radius);
  padding: 18px 18px 14px; box-shadow: var(--shadow);
}
.mini-card h4 { margin: 0 0 7px; font-size: 15.5px; }
.mini-card p { margin: 0; font-size: 14px; color: #4b5563; line-height: 1.55; }

.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin: 24px 0; }
@media (min-width: 768px) { .stat-grid { grid-template-columns: repeat(4, 1fr); } }
.stat-card {
  background: #fff; border: 1px solid var(--hairline); border-radius: var(--radius);
  padding: 16px; text-align: center; box-shadow: var(--shadow);
}
.stat-card b { display: block; font-size: 24px; letter-spacing: -.02em; }
.stat-card span { font-size: 12.5px; color: var(--muted); }

/* tables */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 22px 0 6px; border: 1px solid var(--hairline); border-radius: var(--radius); }
table { border-collapse: collapse; width: 100%; font-size: 14px; min-width: 540px; background: #fff; }
th, td { padding: 9px 14px; text-align: center; white-space: nowrap; }
th:first-child, td:first-child { text-align: left; }
thead th { background: #f3f4f6; font-weight: 600; font-size: 13px; border-bottom: 1px solid var(--hairline); }
tbody tr + tr td { border-top: 1px solid #f1f3f5; }
.row-ours td { background: #fff1f2; }

/* dots */
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin: 0 3px 1px 1px; }
.dot-v { background: var(--mod-v); } .dot-t { background: var(--mod-t); } .dot-a { background: var(--mod-a); }

/* ============ demo player ============ */
.card {
  background: #fff; border: 1px solid var(--hairline);
  border-radius: var(--radius); box-shadow: var(--shadow);
  overflow: hidden;
}
.player { margin: 26px 0 30px; }
.player-video-wrap { position: relative; background: #000; }
.player-video-wrap video { display: block; width: 100%; max-height: 64vh; aspect-ratio: 16/9; cursor: pointer; }
.player-badge {
  position: absolute; top: 12px; right: 12px;
  background: var(--pred); color: #fff;
  padding: 4px 12px; border-radius: 999px;
  font-size: 12.5px; font-weight: 600;
  box-shadow: 0 2px 10px rgba(225,29,72,.45);
  animation: pulse 1.6s ease-in-out infinite;
}
@keyframes pulse { 50% { opacity: .82; } }
.unmute-btn {
  position: absolute; left: 12px; bottom: 12px;
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 14px; border: 0; border-radius: 999px;
  background: rgba(17,24,39,.78); color: #fff;
  font-family: var(--font-ui); font-size: 13px; font-weight: 600;
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  cursor: pointer; transition: background .15s, transform .12s;
}
.unmute-btn:hover { background: rgba(17,24,39,.92); transform: translateY(-1px); }
.player-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 14px; padding: 14px 16px 4px;
}
.player-title-group h3 { margin: 0; font-size: 16px; line-height: 1.35; }
.player-title-group p { margin: 3px 0 0; font-size: 13px; color: var(--muted); }
.player-title-group .chip {
  display: inline-block; padding: 1px 8px; margin-right: 5px;
  border-radius: 999px; background: #eef2ff; color: var(--accent);
  font-size: 11.5px; font-weight: 600;
}
.toggle { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; flex-shrink: 0; padding-top: 2px; }
.toggle input { position: absolute; opacity: 0; pointer-events: none; }
.toggle-track {
  width: 40px; height: 23px; border-radius: 999px; background: #d1d5db;
  position: relative; transition: background .18s; flex-shrink: 0;
}
.toggle-thumb {
  position: absolute; top: 2.5px; left: 2.5px; width: 18px; height: 18px;
  border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.3);
  transition: transform .18s;
}
.toggle input:checked + .toggle-track { background: var(--pred); }
.toggle input:checked + .toggle-track .toggle-thumb { transform: translateX(17px); }
.toggle-label { font-size: 13px; font-weight: 600; color: #374151; white-space: nowrap; }

.charts { padding: 8px 16px 0; }
#chartCanvas { display: block; width: 100%; touch-action: none; cursor: crosshair; }
.legend {
  display: flex; flex-wrap: wrap; gap: 6px 16px; align-items: center;
  padding: 8px 16px 14px; font-size: 12.5px; color: #4b5563;
}
.legend .swatch { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; }
.legend span { display: inline-flex; align-items: center; }
.legend-sep { width: 1px; height: 14px; background: var(--hairline); }

/* gallery */
.gallery-hint { font-size: 14px; color: var(--muted); margin-bottom: 12px; }
.gallery {
  display: grid; gap: 14px;
  grid-template-columns: repeat(2, 1fr);
}
@media (min-width: 640px) { .gallery { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 900px) { .gallery { grid-template-columns: repeat(4, 1fr); } }
.tile {
  background: #fff; border: 1px solid var(--hairline); border-radius: 12px;
  overflow: hidden; cursor: pointer; padding: 0; text-align: left;
  font-family: inherit; font-size: inherit;
  transition: transform .14s, box-shadow .14s, border-color .14s;
}
.tile:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.tile.active { border-color: var(--pred); box-shadow: 0 0 0 2px rgba(225,29,72,.25); }
.tile-thumb { position: relative; aspect-ratio: 16/9; background: #eceef1; }
.tile-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tile-thumb .dur {
  position: absolute; right: 6px; bottom: 6px;
  background: rgba(0,0,0,.72); color: #fff;
  font-size: 11px; font-weight: 600; padding: 1px 6px; border-radius: 5px;
}
.tile-thumb .play-ic {
  position: absolute; inset: 0; display: grid; place-items: center;
  opacity: 0; transition: opacity .15s; background: rgba(0,0,0,.18);
}
.tile:hover .play-ic, .tile.active .play-ic { opacity: 1; }
.play-ic span {
  width: 40px; height: 40px; border-radius: 50%;
  background: rgba(255,255,255,.92); display: grid; place-items: center;
  font-size: 15px; color: #111; padding-left: 3px;
}
.tile-body { padding: 8px 10px 10px; }
.tile-title {
  font-size: 12.5px; font-weight: 600; line-height: 1.35;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; min-height: 2.7em;
}
.tile-metrics { margin-top: 5px; font-size: 11px; color: var(--muted); }
.tile-metrics b { color: var(--pred); font-weight: 600; }

/* ============ poster viewer ============ */
.poster-viewer {
  border: 1px solid var(--hairline); border-radius: var(--radius);
  overflow: hidden; background: #f1f3f5;
  height: min(74vh, 560px); position: relative;
  touch-action: none; cursor: grab;
}
.poster-viewer:active { cursor: grabbing; }
.poster-viewer img {
  position: absolute; top: 0; left: 0;
  transform-origin: 0 0; will-change: transform;
  max-width: none; user-select: none; -webkit-user-drag: none;
}

/* ============ bibtex ============ */
#bibtex { padding-bottom: 150px; }
.bibtex-box { position: relative; }
.bibtex-box pre {
  background: #0f172a; color: #e2e8f0;
  border-radius: var(--radius); padding: 20px;
  overflow-x: auto; font-family: var(--font-mono); font-size: 13px; line-height: 1.6;
  margin: 0;
}
.copy-btn {
  position: absolute; top: 10px; right: 10px;
  background: rgba(255,255,255,.12); color: #e2e8f0;
  border: 1px solid rgba(255,255,255,.2); border-radius: 8px;
  font-size: 12px; font-weight: 600; padding: 5px 12px; cursor: pointer;
  font-family: var(--font-ui);
  transition: background .15s;
}
.copy-btn:hover { background: rgba(255,255,255,.22); }

/* ============ footer ============ */
.footer {
  border-top: 1px solid var(--hairline);
  padding: 30px 0 max(30px, env(safe-area-inset-bottom));
  text-align: center; color: var(--muted); font-size: 14px;
}
.footer p { margin: 4px 0; }

/* ============ reveal-on-scroll ============ */
@media (prefers-reduced-motion: no-preference) {
  .reveal { opacity: 0; transform: translateY(14px); transition: opacity .55s ease, transform .55s ease; }
  .reveal.in { opacity: 1; transform: none; }
}

@media (max-width: 480px) {
  body { font-size: 16px; }
  .section { padding: 44px 0; }
  .player-head { flex-direction: column; }
  .hero-stats { gap: 10px 22px; }
  figure img { padding: 6px; }
  .hero-venue { font-size: 16px; }
  .hero-affil { font-size: 16.5px; }
}
