@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

/* Palette follows danielekpo.com: slate neutrals, one quiet accent.
   Orange / blue are reserved for source / destination, matching the video overlays. */
:root {
  --bg: #ffffff;
  --bg-alt: #f8fafc;
  --surface: #ffffff;
  --hover: #f1f5f9;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --text: #0f172a;
  --text-2: #475569;
  --text-3: #64748b;
  --hero-text: #000;
  --accent: #2563eb;
  --source: #ea7a2f;
  --dest: #2f80d8;
  --ok: #15803d;
  --fail: #b91c1c;
  --row-ours: #f1f5f9;
  --code-bg: #f8fafc;
  --max-width: 960px;
  --prose-width: 760px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f172a;
    --bg-alt: #1e293b;
    --surface: #0f172a;
    --hover: #1e293b;
    --border: #334155;
    --border-strong: #475569;
    --text: #f1f5f9;
    --text-2: #cbd5e1;
    --text-3: #94a3b8;
    --hero-text: var(--text);
    --accent: #4facfe;
    --source: #f59a5b;
    --dest: #5aa7f0;
    --ok: #4ade80;
    --fail: #f87171;
    --row-ours: #1e293b;
    --code-bg: #0f172a;
  }
  section.alt .citation-block { background: #0f172a; }
  section.alt tbody tr.ours td { background: #0f172a; }
}

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

html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.7;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

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

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }

figure { margin: 0; }

code { font-family: 'JetBrains Mono', ui-monospace, monospace; font-size: 0.86em; }

.src { color: var(--source); font-weight: 600; }
.dst { color: var(--dest); font-weight: 600; }

/* ── Hero ── */

.hero { text-align: center; padding: 88px 0 56px; }

.hero-title {
  font-size: 2.85rem;
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.02em;
  margin-bottom: 20px;
}

.hero-subtitle {
  display: block;
  font-size: 1.5rem;
  font-weight: 500;
  letter-spacing: -0.01em;
  color: var(--hero-text);
  margin-top: 10px;
}

.hero-authors { font-size: 1.125rem; color: var(--hero-text); max-width: 720px; margin: 0 auto 4px; }
.hero-authors a { color: inherit; }

.hero-affiliation { font-size: 0.95rem; color: var(--text-3); margin-bottom: 2px; }
.hero-venue { font-size: 0.9rem; color: var(--text-3); margin-bottom: 28px; }

.hero-buttons { display: flex; justify-content: center; gap: 4px; flex-wrap: wrap; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 14px;
  border-radius: 6px;
  font-size: 1.02rem;
  font-weight: 600;
  color: var(--text);
  transition: background 0.15s ease;
}

.btn:hover { background: var(--hover); text-decoration: none; }
.btn svg { width: 16px; height: 16px; flex-shrink: 0; }
.btn .ai { font-size: 16px; line-height: 1; }
.btn.disabled { color: var(--text-3); pointer-events: none; }

/* ── Sections ── */

section { padding: 64px 0; }
section.alt { background: var(--bg-alt); }

.section-title {
  font-size: 1.55rem;
  font-weight: 700;
  letter-spacing: -0.015em;
  text-align: center;
  margin-bottom: 22px;
}

.subsection-title {
  font-size: 1.05rem;
  font-weight: 600;
  max-width: var(--prose-width);
  margin: 48px auto 14px;
}

.prose {
  max-width: var(--prose-width);
  margin: 0 auto 24px;
  color: var(--text-2);
}

.prose strong { color: var(--text); font-weight: 600; }
.prose.small { font-size: 0.92rem; }

.abstract-text {
  max-width: var(--prose-width);
  margin: 0 auto;
  color: var(--text-2);
  text-align: justify;
  hyphens: auto;
}

.abstract-text strong { color: var(--text); font-weight: 600; }

.note {
  max-width: var(--prose-width);
  margin: 16px auto 0;
  font-size: 0.82rem;
  color: var(--text-3);
  line-height: 1.55;
  text-align: center;
}

/* ── Figures ── */

.figure { margin: 0 auto; text-align: center; }
/* Paper figures have white backgrounds; keep them on white so they sit cleanly on dark pages. */
.figure img { max-width: 100%; height: auto; border-radius: 6px; display: block; margin: 0 auto; background: #fff; }

.figure-caption {
  margin: 14px auto 0;
  max-width: var(--prose-width);
  font-size: 0.88rem;
  line-height: 1.6;
  color: var(--text-3);
  text-align: left;
}

.figure-caption strong { color: var(--text-2); font-weight: 600; }

/* ── Video ── */

.video-wrap {
  max-width: 880px;
  margin: 0 auto;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: #000;
}

.video-wrap video { display: block; width: 100%; }

.badge { font-size: 0.78rem; font-weight: 500; white-space: nowrap; }
.badge.ok { color: var(--ok); }
.badge.fail { color: var(--fail); }

ol.cmds { padding-left: 1.2em; margin-top: 2px; }
ol.cmds li.novel { color: var(--source); font-weight: 600; }

.legend {
  display: flex;
  justify-content: center;
  gap: 22px;
  flex-wrap: wrap;
  font-size: 0.85rem;
  color: var(--text-3);
  margin: 0 auto 18px;
}

.legend span::before {
  content: '';
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  margin-right: 7px;
}

.legend .l-src::before { background: var(--source); }
.legend .l-dst::before { background: var(--dest); }
.legend .l-other::before { background: #fff; border: 1px solid var(--text-3); }

/* ── Tabs / task picker ── */

.tabs {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px 6px;
  margin: 0 auto 20px;
  max-width: 900px;
}

.tab {
  font: inherit;
  font-size: 0.86rem;
  font-weight: 500;
  padding: 5px 12px;
  border-radius: 6px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-3);
  cursor: pointer;
  transition: color 0.15s ease, background 0.15s ease;
}

.tab:hover { color: var(--text); }
.tab[aria-selected="true"] { color: var(--text); background: var(--hover); border-color: var(--border); }

.panel[hidden] { display: none; }

.controls { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }

.toggle { display: inline-flex; align-items: center; gap: 7px; cursor: pointer; user-select: none; }
.toggle input { accent-color: var(--accent); width: 15px; height: 15px; }

/* ── Tables ── */

.table-wrap { overflow-x: auto; margin: 0 auto 40px; max-width: 900px; }
.table-wrap:last-child { margin-bottom: 0; }

.table-caption { font-size: 0.92rem; font-weight: 600; margin-bottom: 10px; }
.table-caption span { font-weight: 400; color: var(--text-3); }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
  font-variant-numeric: tabular-nums;
  border-top: 1px solid var(--border-strong);
}

thead th {
  font-weight: 600;
  text-align: center;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border-strong);
  white-space: nowrap;
  color: var(--text-2);
}

thead tr.group th { border-bottom: 1px solid var(--border); color: var(--text); }
thead th:first-child { text-align: left; }

tbody td { text-align: center; padding: 7px 10px; border-bottom: 1px solid var(--border); color: var(--text-2); }
tbody td:first-child { text-align: left; white-space: nowrap; color: var(--text); }
tbody tr:last-child td { border-bottom: 1px solid var(--border-strong); }
tbody tr.ours td { background: var(--row-ours); color: var(--text); font-weight: 600; }

.best { font-weight: 700; color: var(--text); }
.second { text-decoration: underline; text-underline-offset: 3px; }

.table-note { font-size: 0.8rem; color: var(--text-3); margin-top: 8px; line-height: 1.5; }

.ablation-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 36px; max-width: 900px; margin: 0 auto; align-items: start; }

/* ── Citation ── */

.citation-block {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 18px 22px;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 0.8rem;
  line-height: 1.7;
  overflow-x: auto;
  max-width: var(--prose-width);
  margin: 0 auto;
  white-space: pre;
  color: var(--text-2);
}

/* ── Footer ── */

footer {
  text-align: center;
  padding: 32px 0;
  font-size: 0.82rem;
  color: var(--text-3);
  border-top: 1px solid var(--border);
}

/* ── Responsive ── */

.ablation-grid > * { min-width: 0; }

@media (max-width: 860px) {
  .ablation-grid { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  .hero { padding: 56px 0 40px; }
  .hero-title { font-size: 2.2rem; }
  .hero-subtitle { font-size: 1.2rem; }
  section { padding: 44px 0; }
  .section-title { font-size: 1.35rem; }
  .abstract-text { text-align: left; }
}

@media (max-width: 560px) {
  .container { padding: 0 16px; }
  .hero-title { font-size: 1.9rem; }
  table { font-size: 0.8rem; }
  thead th, tbody td { padding: 6px; }
}

/* ── Gallery: main viewer + caption + thumbnail strip ── */

.gallery { max-width: 920px; margin: 0 auto; }
.gallery.is-single .g-stage { max-width: 720px; margin: 0 auto; }
.gallery.is-single.is-wide .g-stage { max-width: 860px; }
.gallery.is-pair .g-stage { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

.g-view {
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface);
  min-width: 0;
}

.g-view video { display: block; width: 100%; background: #000; }
.gallery:not(.is-wide) .g-view video { aspect-ratio: 4 / 3; object-fit: contain; }

.g-label { padding: 8px 12px 10px; font-size: 0.84rem; color: var(--text-3); line-height: 1.5; }
.g-label .title { display: flex; justify-content: space-between; gap: 8px; font-weight: 600; color: var(--text); }

.g-caption {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  max-width: 720px;
  margin: 12px auto 0;
  font-size: 0.88rem;
  line-height: 1.55;
  color: var(--text-2);
}

.gallery.is-wide .g-caption { max-width: 860px; }
.gallery.is-pair .g-caption { max-width: none; }
.g-title { font-weight: 600; color: var(--text); }
.g-body .quote { font-style: italic; }
.g-count { font-size: 0.8rem; color: var(--text-3); white-space: nowrap; font-variant-numeric: tabular-nums; padding-top: 1px; }

.g-nav { display: flex; align-items: center; gap: 6px; margin-top: 18px; }

.g-arrow {
  flex: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-2);
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
  display: grid;
  place-items: center;
  padding-bottom: 2px;
  transition: color 0.15s ease, border-color 0.15s ease, opacity 0.15s ease;
}

.g-arrow:hover:not(:disabled) { color: var(--text); border-color: var(--border-strong); }
.g-arrow:disabled { opacity: 0.3; cursor: default; }

.g-strip {
  flex: 1;
  display: flex;
  gap: 10px;
  overflow-x: auto;
  scroll-snap-type: x proximity;
  scrollbar-width: none;
  padding: 2px;
}

.g-strip::-webkit-scrollbar { display: none; }

.g-thumb {
  flex: 0 0 150px;
  scroll-snap-align: center;
  font: inherit;
  text-align: left;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  background: var(--surface);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  transition: border-color 0.15s ease;
}

.g-thumb img { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; opacity: 0.6; transition: opacity 0.15s ease; }
.g-thumb .t-title { padding: 6px 9px 0; font-size: 0.76rem; font-weight: 600; color: var(--text-2); line-height: 1.35; }
.g-thumb .t-meta { padding: 1px 9px 7px; font-size: 0.7rem; color: var(--text-3); }
.g-thumb:hover img, .g-thumb[aria-selected="true"] img { opacity: 1; }
.g-thumb:hover { border-color: var(--border-strong); }
.g-thumb[aria-selected="true"] { border-color: var(--accent); }
.g-thumb[aria-selected="true"] .t-title { color: var(--text); }
.g-thumb:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

section.alt .g-view, section.alt .g-thumb { background: var(--bg); }

.gallery-options { max-width: 720px; margin: 0 auto 10px; display: flex; justify-content: flex-end; font-size: 0.86rem; color: var(--text-3); }

@media (max-width: 640px) {
  .gallery.is-pair .g-stage { grid-template-columns: 1fr; }
  .g-thumb { flex-basis: 124px; }
}

/* Center the thumbnails when they all fit; still scrolls normally when they overflow. */
.g-thumb:first-child { margin-left: auto; }
.g-thumb:last-child { margin-right: auto; }

/* Keep the strip (and its arrows) exactly as wide as the viewer above it. */
.gallery.is-single .g-nav { max-width: 720px; margin-left: auto; margin-right: auto; }
.gallery.is-single.is-wide .g-nav { max-width: 860px; }
.g-strip { position: relative; } /* thumbnail offsets are measured against the strip */

/* ── Results plots: one row, equal frames ── */
.plot-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 24px;
  max-width: 960px;
  margin: 44px auto 0;
  align-items: start;
}
.plot img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: contain;
  background: #fff;
  border-radius: 6px;
  padding: 8px;
  border: 1px solid var(--border);
}
.plot figcaption { margin-top: 10px; font-size: 0.82rem; line-height: 1.55; color: var(--text-3); }
.plot figcaption strong { color: var(--text-2); font-weight: 600; }
@media (max-width: 860px) {
  .plot-row { grid-template-columns: 1fr; max-width: 520px; }
}
.plot a { display: block; cursor: zoom-in; }
