/* ============================================================
   CAIP project page — styles
   Clean, academic, single-accent. No framework.
   ============================================================ */

:root {
  --bg: #ffffff;
  --bg-alt: #f7f8fa;
  --ink: #16181d;
  --ink-soft: #4a4f59;
  --ink-faint: #8a909c;
  --line: #e6e8ec;
  --line-strong: #d4d7dd;
  --accent: #2f5fd0;
  --accent-soft: #eaf0fd;
  --accent-ink: #1f47a8;
  --ours: #fff6e9;
  --ours-line: #f0c98a;
  --radius: 12px;
  --radius-sm: 8px;
  --maxw: 1080px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 6px 24px rgba(16, 24, 40, .06);
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; scroll-padding-top: 72px; }

body {
  margin: 0;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.6;
  font-size: 17px;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

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

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

/* ----------------------------- NAV ----------------------------- */
.nav {
  position: sticky; top: 0; z-index: 50;
  background: rgba(255, 255, 255, .82);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
}
.nav-inner {
  max-width: var(--maxw); margin: 0 auto; padding: 0 24px;
  height: 56px; display: flex; align-items: center; justify-content: space-between;
}
.nav-brand {
  font-weight: 700; letter-spacing: .04em; color: var(--ink);
  font-size: 1.05rem;
}
.nav-brand:hover { text-decoration: none; }
.nav-links { display: flex; gap: 22px; }
.nav-links a {
  color: var(--ink-soft); font-size: .9rem; font-weight: 500;
}
.nav-links a:hover { color: var(--accent); text-decoration: none; }
@media (max-width: 760px) {
  .nav-links { display: none; }
}

/* ----------------------------- HERO ----------------------------- */
.hero {
  padding: 64px 0 8px;
  text-align: center;
  background:
    radial-gradient(1200px 380px at 50% -120px, var(--accent-soft), transparent 70%);
}
.eyebrow {
  text-transform: uppercase; letter-spacing: .14em; font-size: .72rem;
  font-weight: 600; color: var(--accent-ink); margin: 0 0 12px;
}
.title {
  font-family: "Newsreader", Georgia, serif;
  font-weight: 500;
  font-size: clamp(2rem, 4.6vw, 3.1rem);
  line-height: 1.12; letter-spacing: -.01em;
  margin: 0 auto 26px; max-width: none;
}
/* Keep the first line ("…Pre-training") intact so the title is 2 lines, not 3.
   Release the constraint on narrow screens so it wraps instead of overflowing. */
.title-l1 { white-space: nowrap; }
@media (max-width: 640px) { .title-l1 { white-space: normal; } }

.authors {
  display: flex; flex-wrap: wrap; justify-content: center;
  gap: 2px 14px; max-width: 860px; margin: 0 auto 14px;
}
.author { color: var(--ink); font-size: .96rem; white-space: nowrap; }
.author a { color: var(--ink); }
.author a:hover { color: var(--accent); }
.author sup { color: var(--ink-faint); font-size: .68em; }
.author-break { flex-basis: 100%; height: 0; }

.affiliations, .contrib-note {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 20px;
  color: var(--ink-soft); font-size: .9rem;
}
.affiliations { margin: 6px auto 6px; }
.affiliations sup, .contrib-note sup { color: var(--ink-faint); }
.contrib-note { margin: 2px auto 30px; color: var(--ink-faint); font-size: .84rem; }

/* CTA buttons */
.cta-row { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; margin-bottom: 44px; }
.btn {
  display: inline-flex; align-items: center; gap: 9px;
  padding: 10px 18px; border-radius: 999px;
  border: 1px solid var(--line-strong); background: #fff; color: var(--ink);
  font-size: .92rem; font-weight: 600; cursor: pointer;
  transition: transform .12s ease, box-shadow .12s ease, border-color .12s ease;
}
.btn:hover { text-decoration: none; transform: translateY(-1px); box-shadow: var(--shadow); border-color: var(--line-strong); }
.btn svg { width: 17px; height: 17px; }
.btn-primary { background: var(--ink); color: #fff; border-color: var(--ink); }
.btn-primary:hover { background: #000; }
.btn .soon { font-weight: 500; opacity: .6; font-size: .85em; }
.btn .hf-emoji { font-size: 17px; line-height: 1; }
.btn[aria-disabled="true"] { cursor: default; pointer-events: none; }

/* Hero video */
.hero-video { margin: 0 0 28px; }
.hero-video video,
.hero-video .media-placeholder { width: 100%; border-radius: var(--radius); }
.hero-video video { display: block; box-shadow: var(--shadow); background: #000; }
.video-caption {
  display: flex; align-items: center; justify-content: center; gap: 14px;
  margin-top: 12px; color: var(--ink-faint); font-size: .88rem;
}
.narration-toggle {
  display: inline-flex; align-items: center; gap: 7px;
  background: #fff; border: 1px solid var(--line-strong); color: var(--ink-soft);
  border-radius: 999px; padding: 5px 12px; font-size: .82rem; font-weight: 600; cursor: pointer;
}
.narration-toggle:hover { border-color: var(--accent); color: var(--accent); }
.narration-toggle .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }
.narration-toggle[hidden] { display: none; }

/* TL;DR */
.tldr {
  max-width: 760px; margin: 0 auto; text-align: left;
  background: var(--bg-alt); border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm); padding: 18px 22px;
  font-size: .98rem; color: var(--ink-soft);
}
.tldr strong { color: var(--ink); }
.tldr em { font-style: italic; }

/* ----------------------------- SECTIONS ----------------------------- */
.section { padding: 64px 0; border-top: 1px solid var(--line); }
.section-alt { background: var(--bg-alt); }
.section-eyebrow {
  text-transform: uppercase; letter-spacing: .14em; font-size: .72rem;
  font-weight: 600; color: var(--accent-ink); margin: 0 0 8px;
}
.section-title {
  font-family: "Newsreader", Georgia, serif; font-weight: 500;
  font-size: clamp(1.6rem, 3vw, 2.1rem); line-height: 1.15;
  margin: 0 0 22px; letter-spacing: -.01em;
}
.subhead {
  font-size: 1.05rem; font-weight: 700; margin: 36px 0 14px; color: var(--ink);
}

.prose { max-width: 760px; color: var(--ink-soft); }
.prose p { margin: 0 0 16px; }
.prose strong { color: var(--ink); }
.prose code, .tldr code {
  font-family: var(--mono); font-size: .85em; background: #eef0f3;
  padding: 1px 6px; border-radius: 5px; color: var(--ink);
}

/* ----------------------------- FIGURES ----------------------------- */
.figure { margin: 28px 0 0; }
.figure img, .figure video { width: 100%; border-radius: var(--radius); display: block; box-shadow: var(--shadow); background: #000; }
.figure figcaption, figure.demo-item figcaption {
  font-size: .86rem; color: var(--ink-faint); margin-top: 10px; line-height: 1.5;
}
.figure figcaption strong { color: var(--ink-soft); }
.figure-narrow { max-width: 560px; }
.figure-square { max-width: 680px; margin-left: auto; margin-right: auto; }

/* Media placeholders (intentional, dashed) */
.media-placeholder {
  position: relative; width: 100%;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px; text-align: center;
  background:
    repeating-linear-gradient(45deg, #fafbfc, #fafbfc 14px, #f3f5f8 14px, #f3f5f8 28px);
  border: 1.5px dashed var(--line-strong);
  border-radius: var(--radius); color: var(--ink-faint);
}
.ph-label { font-weight: 600; font-size: .95rem; color: var(--ink-soft); }
.ph-path { font-family: var(--mono); font-size: .76rem; color: var(--ink-faint); padding: 0 12px; }

/* Aspect ratio boxes */
.ratio-16x9 { aspect-ratio: 16 / 9; }
.ratio-21x9 { aspect-ratio: 21 / 9; }
.ratio-4x3  { aspect-ratio: 4 / 3; }
.ratio-1x1  { aspect-ratio: 1 / 1; }

/* ----------------------------- STAT STRIP ----------------------------- */
.stat-strip {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-top: 36px;
}
.stat {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px 16px; text-align: center;
}
.stat-num { font-size: 1.7rem; font-weight: 700; letter-spacing: -.02em; color: var(--ink); }
.stat-lbl { font-size: .82rem; color: var(--ink-faint); margin-top: 4px; }
.stat-accent { background: var(--accent); border-color: var(--accent); }
.stat-accent .stat-num, .stat-accent .stat-lbl { color: #fff; }
.stat-accent .stat-lbl { opacity: .9; }
@media (max-width: 700px) { .stat-strip { grid-template-columns: repeat(2, 1fr); } }

/* ----------------------------- CARDS ----------------------------- */
.cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-top: 30px; }
.card {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 22px;
}
.section-alt .card { background: #fff; }
.card h3 { margin: 0 0 8px; font-size: 1.02rem; }
.card p { margin: 0; font-size: .92rem; color: var(--ink-soft); }
@media (max-width: 820px) { .cards { grid-template-columns: 1fr; } }

/* ----------------------------- TABS ----------------------------- */
.tabs {
  display: inline-flex; gap: 4px; padding: 4px; margin-bottom: 26px;
  background: var(--bg-alt); border: 1px solid var(--line); border-radius: 999px;
}
.section .tabs { background: #f0f2f5; }
.tab {
  border: 0; background: transparent; cursor: pointer;
  padding: 8px 18px; border-radius: 999px; font-size: .9rem; font-weight: 600;
  color: var(--ink-soft); font-family: inherit;
  transition: background .15s ease, color .15s ease;
}
.tab:hover { color: var(--ink); }
.tab.is-active { background: #fff; color: var(--accent); box-shadow: var(--shadow); }

.tab-panel { display: none; }
.tab-panel.is-active { display: block; animation: fade .25s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ----------------------------- TABLES ----------------------------- */
.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--line); margin-top: 4px; }
.results-table { width: 100%; border-collapse: collapse; font-size: .9rem; background: #fff; }
.results-table th, .results-table td {
  padding: 11px 12px; text-align: center; white-space: nowrap;
  border-bottom: 1px solid var(--line);
}
.results-table thead th {
  font-weight: 600; color: var(--ink-soft); font-size: .82rem;
  background: var(--bg-alt); position: sticky; top: 0;
}
.results-table .th-method { text-align: left; font-weight: 600; color: var(--ink); }
.results-table tbody .th-method { color: var(--ink-soft); }
.results-table .th-avg { background: #f1f3f6; font-weight: 600; }
.results-table tbody tr:last-child td { border-bottom: 0; }
.results-table tbody tr:hover { background: #fbfcfd; }
.results-table u { text-decoration-color: var(--ink-faint); text-underline-offset: 2px; }

.row-ours { background: var(--ours) !important; }
.row-ours:hover { background: var(--ours) !important; }
.row-ours td { border-top: 1.5px solid var(--ours-line); font-weight: 600; }
.row-ours .th-method { color: var(--accent-ink); }
.row-ours .th-avg { background: #fcefd8; }
.row-ours b { color: var(--accent-ink); }

.results-table.compact th, .results-table.compact td { padding: 8px 9px; font-size: .82rem; }
.table-note { font-size: .8rem; color: var(--ink-faint); margin-top: 10px; }

/* ----------------------------- DEMO GRIDS ----------------------------- */
.demo-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-top: 8px; }
.compare-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-top: 8px; }
.demo-item { margin: 0; }
.demo-item video, .demo-item .media-placeholder { width: 100%; border-radius: var(--radius); }
.demo-item video { display: block; box-shadow: var(--shadow); background: #000; }
.demo-item figcaption { text-align: center; font-weight: 600; color: var(--ink-soft); }
@media (max-width: 820px) {
  .demo-grid, .compare-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 520px) {
  .demo-grid, .compare-grid { grid-template-columns: 1fr; }
}

/* Encoder comparison matrix (Analysis): row labels + 3 encoder columns */
.cmp-matrix {
  display: grid;
  grid-template-columns: max-content repeat(3, 1fr);
  gap: 8px 12px; margin: 8px 0 4px; align-items: center;
}
.cmp-corner { }
.cmp-head { text-align: center; font-size: .85rem; font-weight: 700; color: var(--ink-soft); padding-bottom: 2px; }
.cmp-head.cmp-ours { color: var(--accent-ink); }
.cmp-rowlabel {
  font-size: .72rem; font-weight: 600; color: var(--ink-faint);
  text-transform: uppercase; letter-spacing: .06em; text-align: right;
  padding-right: 2px; white-space: nowrap;
}
.cmp-vid {
  width: 100%; display: block; border-radius: var(--radius-sm);
  box-shadow: var(--shadow); background: #000; aspect-ratio: 16 / 9; object-fit: cover;
}
.heatmap-ph {
  width: 100%; aspect-ratio: 16 / 9; border-radius: var(--radius-sm);
  background: #0d0f14; display: flex; align-items: center; justify-content: center;
  border: 1px solid #20242e;
}
.heatmap-ph span {
  color: #6b7280; font-size: .74rem; font-weight: 500; letter-spacing: .04em;
  text-transform: uppercase; text-align: center; padding: 0 8px;
}
@media (max-width: 640px) {
  /* stack: drop the row-label column, show encoder blocks in one column */
  .cmp-matrix { grid-template-columns: 1fr; }
  .cmp-corner, .cmp-rowlabel { display: none; }
  .cmp-head { text-align: left; margin-top: 8px; }
}

.robustness-media { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-top: 18px; }
.ablation-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-top: 8px; }
@media (max-width: 760px) {
  .robustness-media, .ablation-grid { grid-template-columns: 1fr; }
}

/* ----------------------------- BIBTEX ----------------------------- */
.bibtex-card { position: relative; background: #11131a; border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.bibtex-card pre { margin: 0; padding: 22px 22px; overflow-x: auto; }
.bibtex-card code { font-family: var(--mono); font-size: .86rem; color: #d6dbe6; line-height: 1.7; }
.copy-btn {
  position: absolute; top: 12px; right: 12px;
  background: rgba(255, 255, 255, .1); color: #fff; border: 1px solid rgba(255, 255, 255, .2);
  border-radius: var(--radius-sm); padding: 6px 12px; font-size: .8rem; font-weight: 600; cursor: pointer;
  font-family: inherit;
}
.copy-btn:hover { background: rgba(255, 255, 255, .2); }
.copy-btn.copied { background: var(--accent); border-color: var(--accent); }

/* ----------------------------- FOOTER ----------------------------- */
.footer { border-top: 1px solid var(--line); padding: 36px 0; text-align: center; color: var(--ink-soft); }
.footer p { margin: 4px 0; font-size: .9rem; }
.footer-fine { color: var(--ink-faint); font-size: .8rem; }
