/* ============================================================
   CogOmniControl — Project Page
   ============================================================ */

:root {
  --bg: #0b0d12;
  --bg-soft: #11141b;
  --bg-alt: #0f1219;
  --surface: #161a23;
  --surface-2: #1c2230;
  --border: rgba(255,255,255,0.08);
  --border-strong: rgba(255,255,255,0.16);

  --text: #e8ecf3;
  --text-soft: #b6bdcc;
  --text-muted: #828a9a;

  --brand: #7c8cff;
  --brand-2: #62e0c8;
  --brand-3: #ff7ab8;

  --tag-control: #ffb86b;
  --tag-ref: #62e0c8;
  --tag-prompt: #b48bff;
  --tag-output: #ff7ab8;
  --tag-ours: #7c8cff;

  --radius-lg: 18px;
  --radius-md: 12px;
  --radius-sm: 8px;

  --container: 1200px;
  --container-narrow: 860px;

  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "PingFang SC", "Microsoft YaHei", sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

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

code { font-family: var(--font-mono); font-size: 0.9em; color: var(--brand-2); }

.container {
  max-width: var(--container);
  margin: 0 auto;
  padding: 0 28px;
  width: 100%;
}
.container.narrow { max-width: var(--container-narrow); }

/* ============================================================
   HERO
   ============================================================ */
.hero {
  position: relative;
  overflow: hidden;
  padding: 88px 0 72px;
  border-bottom: 1px solid var(--border);
}
.hero-bg {
  position: absolute;
  inset: -20% -10% auto -10%;
  height: 120%;
  background:
    radial-gradient(60% 50% at 20% 10%, rgba(124,140,255,0.25), transparent 60%),
    radial-gradient(50% 50% at 85% 25%, rgba(255,122,184,0.18), transparent 60%),
    radial-gradient(45% 45% at 50% 90%, rgba(98,224,200,0.18), transparent 60%);
  filter: blur(40px);
  z-index: 0;
  pointer-events: none;
}
.hero-inner { position: relative; z-index: 1; text-align: center; }

.venue-tag {
  display: inline-block;
  padding: 6px 14px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  font-size: 12px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-soft);
  background: rgba(255,255,255,0.03);
  margin-bottom: 22px;
}

.paper-title {
  font-size: clamp(34px, 5.4vw, 64px);
  font-weight: 800;
  line-height: 1.08;
  letter-spacing: -0.02em;
  margin: 0 0 18px;
}
.subtitle-line {
  font-size: clamp(18px, 2.4vw, 28px);
  font-weight: 600;
  color: var(--text-soft);
  letter-spacing: -0.005em;
  display: inline-block;
  margin-top: 14px;
}

.grad-text {
  background: linear-gradient(92deg, #a8b3ff 0%, #62e0c8 50%, #ff95c8 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.authors {
  margin: 14px 0 6px;
  font-size: 17px;
  color: var(--text);
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px 18px;
}
.author {
  font-weight: 500;
  color: var(--text);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: color .15s ease, border-color .15s ease;
}
.author:hover {
  color: var(--brand);
  border-bottom-color: var(--brand);
  text-decoration: none;
}
.author sup { color: var(--brand); font-weight: 600; margin-left: 1px; }

/* authors without a homepage: render as plain text */
.author[data-nohome] {
  pointer-events: none;
  cursor: default;
  border-bottom: none;
}
.author[data-nohome]:hover { color: var(--text); border-bottom-color: transparent; }

.affiliations {
  font-size: 14px;
  color: var(--text-soft);
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px 10px;
}
.affiliations sup { color: var(--brand); font-weight: 600; margin-right: 2px; }
.aff-sep { color: var(--text-muted); }

.author-notes {
  margin-top: 6px;
  font-size: 12.5px;
  color: var(--text-muted);
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px 14px;
}
.author-notes sup { color: var(--brand); margin-right: 2px; }

.cta-row {
  margin-top: 30px;
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 18px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  font-weight: 600;
  font-size: 14px;
  letter-spacing: 0.01em;
  color: var(--text);
  background: rgba(255,255,255,0.04);
  transition: transform .15s ease, background .2s ease, border-color .2s ease;
}
.btn:hover { text-decoration: none; transform: translateY(-1px); background: rgba(255,255,255,0.08); border-color: rgba(255,255,255,0.28); }
.btn-primary {
  background: linear-gradient(120deg, #7c8cff, #ff7ab8);
  border-color: transparent;
  color: #fff;
}
.btn-primary:hover { background: linear-gradient(120deg, #8c9bff, #ff8dc2); }

/* ============================================================
   TEASER
   ============================================================ */
.teaser-section { padding: 50px 0 8px; }
.teaser, .pipeline-figure {
  margin: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.pipeline-figure { margin: 0; }

/* generic figure slot — fits image / svg / pdf */
.figure-slot {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 7;
  background:
    linear-gradient(120deg, rgba(124,140,255,0.10), rgba(98,224,200,0.06) 60%, rgba(255,122,184,0.10)),
    repeating-linear-gradient(45deg, rgba(255,255,255,0.02) 0 14px, rgba(255,255,255,0) 14px 28px);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
/* when slot holds a real asset, drop the decorative bg */
.figure-slot.has-asset {
  background: #ffffff;
  aspect-ratio: auto; /* let asset define height */
}
.figure-slot > img,
.figure-slot > svg,
.figure-slot > object,
.figure-slot > embed {
  display: block;
  width: 100%;
  height: auto;
  max-height: 78vh;
  background: #fff;
}
.figure-slot > object,
.figure-slot > embed {
  height: 70vh;          /* PDFs need an explicit height */
  min-height: 420px;
}

.figure-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--text-muted);
  text-align: center;
  padding: 32px 16px;
}

.teaser figcaption, .pipeline-figure figcaption {
  padding: 16px 22px;
  font-size: 14px;
  color: var(--text-soft);
  background: var(--surface-2);
  border-top: 1px solid var(--border);
}

/* ============================================================
   GENERIC SECTIONS
   ============================================================ */
.section {
  padding: 80px 0;
  border-bottom: 1px solid var(--border);
}
.section-alt { background: var(--bg-alt); }
.section-title {
  font-size: clamp(26px, 3vw, 36px);
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 0 0 22px;
  text-align: center;
}
.section-title::after {
  content: "";
  display: block;
  width: 56px;
  height: 3px;
  margin: 14px auto 0;
  background: linear-gradient(90deg, var(--brand), var(--brand-3));
  border-radius: 999px;
}
.section-lead {
  text-align: center;
  max-width: 820px;
  margin: 0 auto 40px;
  color: var(--text-soft);
  font-size: 17px;
}

.abstract {
  font-size: 17px;
  line-height: 1.85;
  color: var(--text-soft);
  text-align: justify;
}
.abstract b { color: var(--text); font-weight: 600; }

/* ============================================================
   METHOD GRID
   ============================================================ */
.method-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  margin-bottom: 42px;
}
.method-card {
  position: relative;
  padding: 26px 24px 22px;
  background: linear-gradient(180deg, var(--surface) 0%, var(--surface-2) 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  transition: border-color .2s ease, transform .2s ease;
}
.method-card:hover { border-color: var(--border-strong); transform: translateY(-2px); }
.method-num {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.2em;
  color: var(--brand);
  margin-bottom: 10px;
}
.method-card h3 {
  margin: 0 0 10px;
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -0.005em;
  line-height: 1.35;
}
.method-card h3 .muted {
  display: inline-block;
  margin-top: 2px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.method-card p {
  margin: 0;
  color: var(--text-soft);
  font-size: 15px;
  line-height: 1.7;
}

/* ============================================================
   EXAMPLES
   ============================================================ */
.example {
  margin: 0 auto 56px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.example:last-child { margin-bottom: 0; }

.example-header {
  display: flex;
  align-items: baseline;
  gap: 14px;
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}
.example-id {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  color: var(--brand);
  letter-spacing: 0.16em;
  text-transform: uppercase;
}
.example-title {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
}

.example-body { padding: 22px; }

/* --- Inputs row : adapts based on data-attributes --- */
.inputs-row {
  display: grid;
  gap: 16px;
  margin-bottom: 18px;
  align-items: start;   /* don't stretch — let each card keep its natural height */
}

/* prompt card height follows its sibling video cards (set via JS).
   Without JS it falls back to a sensible cap. */
.inputs-row .prompt-card {
  min-width: 0;
  min-height: 0;
  align-self: stretch;
  display: flex;
  flex-direction: column;
}
.inputs-row .prompt-card .prompt-box {
  flex: 1 1 auto;
  min-height: 0;
  max-height: 100%;
}

/* default: 3 columns (control + ref + prompt) */
.example[data-has-control="true"][data-has-ref="true"]  .inputs-row {
  grid-template-columns: 1fr 1fr 1.4fr;
}
/* control + prompt */
.example[data-has-control="true"][data-has-ref="false"] .inputs-row {
  grid-template-columns: 1fr 1.2fr;
}
/* ref + prompt */
.example[data-has-control="false"][data-has-ref="true"] .inputs-row {
  grid-template-columns: 1fr 1.2fr;
}
/* prompt only */
.example[data-has-control="false"][data-has-ref="false"] .inputs-row {
  grid-template-columns: 1fr;
}

.output-row { display: grid; grid-template-columns: 1fr; }

/* --- Media card --- */
.media-card {
  display: flex;
  flex-direction: column;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  min-width: 0;
}
.media-card-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  background: rgba(255,255,255,0.02);
}

.kind-tag {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border: 1px solid transparent;
}
.tag-control { color: var(--tag-control); border-color: rgba(255,184,107,0.4); background: rgba(255,184,107,0.08); }
.tag-ref     { color: var(--tag-ref);     border-color: rgba(98,224,200,0.4);  background: rgba(98,224,200,0.08); }
.tag-prompt  { color: var(--tag-prompt);  border-color: rgba(180,139,255,0.4); background: rgba(180,139,255,0.08); }
.tag-output  { color: var(--tag-output);  border-color: rgba(255,122,184,0.4); background: rgba(255,122,184,0.10); }
.tag-ours    { color: var(--tag-ours);    border-color: rgba(124,140,255,0.4); background: rgba(124,140,255,0.10); }

/* --- Media frame --- */
.media-frame {
  position: relative;
  background:
    linear-gradient(135deg, rgba(124,140,255,0.06), rgba(98,224,200,0.04)),
    repeating-linear-gradient(45deg, rgba(255,255,255,0.02) 0 12px, rgba(255,255,255,0) 12px 24px);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  width: 100%;
}
/* Default: let media decide the height (preserve native aspect ratio).
   Only the dedicated output frame keeps a fixed 16:9 box. */
.media-frame.ratio-16x9 {
  aspect-ratio: 16 / 9;
  min-height: 280px;
}
.media {
  width: 100%;
  height: auto;          /* preserve aspect ratio of source */
  max-height: 520px;     /* avoid super-tall portrait videos blowing up the row */
  object-fit: contain;   /* never crop the source */
  display: block;
  background: #000;
}
/* output stays as cover-fit 16:9 */
.output-card .media {
  height: 100%;
  object-fit: cover;
}
.media-fallback {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
  padding: 12px;
}
/* hide fallback whenever video/img is actually loaded (handled in JS) */
video.media:not([data-broken="true"]) ~ .media-fallback { display: none; }

/* --- Prompt card --- */
.prompt-card .prompt-box {
  flex: 1;
  padding: 14px 16px;
  background: rgba(180,139,255,0.04);
  font-size: 14px;
  line-height: 1.7;
  color: var(--text-soft);
  white-space: pre-wrap;
  overflow-y: auto;
}
.prompt-card .prompt-box p { margin: 0; }
.prompt-card-wide { max-width: 100%; }

/* Featured examples — slightly larger but compact prompt,
   matching the height of side-by-side control/ref videos */
.example.featured .prompt-card .prompt-box {
  font-size: 14.5px;
  line-height: 1.7;
  color: var(--text-soft);
  padding: 14px 18px;
}

/* --- Output card --- */
.output-card {
  border-color: rgba(124,140,255,0.35);
  box-shadow: 0 0 0 1px rgba(124,140,255,0.08), 0 8px 24px rgba(0,0,0,0.25);
}
.output-card .media-card-head {
  background: linear-gradient(90deg, rgba(124,140,255,0.10), rgba(255,122,184,0.10));
}
.output-card .media-frame { aspect-ratio: 16 / 9; min-height: 280px; }

/* ============================================================
   COMPACT EXAMPLES (More Results — 2 columns)
   ============================================================ */
.subgroup-title {
  margin: 56px 0 22px;
  text-align: center;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.005em;
  color: var(--text);
}
.subgroup-title::before,
.subgroup-title::after {
  content: "";
  display: inline-block;
  vertical-align: middle;
  width: 36px;
  height: 1px;
  background: var(--border-strong);
  margin: 0 14px;
}

.examples-grid-2col {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 22px;
}
.examples-grid-2col .example { margin: 0; }

/* Compact card tweaks */
.example.compact .example-header { padding: 12px 18px; }
.example.compact .example-id { font-size: 11px; }
.example.compact .example-body { padding: 16px; }

.example.compact .inputs-row {
  grid-template-columns: 1fr 1fr !important;  /* control + ref side by side */
  gap: 12px;
  margin-bottom: 12px;
}
/* if compact has only one of control/ref */
.example.compact[data-has-control="true"][data-has-ref="false"] .inputs-row,
.example.compact[data-has-control="false"][data-has-ref="true"]  .inputs-row {
  grid-template-columns: 1fr !important;
}

.example.compact .media-frame { min-height: 0; aspect-ratio: 16 / 9; }
.example.compact .media-card-head { padding: 8px 10px; }
.example.compact .kind-tag { font-size: 10px; padding: 2px 8px; }

/* compact prompt as a single horizontal strip between inputs and output */
.example.compact .prompt-row { margin-bottom: 12px; }
.example.compact .compact-prompt {
  background: rgba(180,139,255,0.05);
  border: 1px solid rgba(180,139,255,0.18);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  display: flex;
  gap: 10px;
  align-items: flex-start;
  font-size: 13.5px;
  line-height: 1.6;
  color: var(--text-soft);
  max-height: 110px;
  overflow-y: auto;
}
.example.compact .compact-prompt .kind-tag { flex-shrink: 0; align-self: center; }
.example.compact .compact-prompt p { margin: 0; }

.example.compact .output-card .media-frame { min-height: 0; }

/* ============================================================
   BIBTEX
   ============================================================ */
.bibtex {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 18px 20px;
  font-family: var(--font-mono);
  font-size: 13.5px;
  line-height: 1.7;
  color: var(--text-soft);
  overflow-x: auto;
  white-space: pre;
}
.bibtex code { color: var(--text-soft); }

/* ============================================================
   FOOTER
   ============================================================ */
.footer {
  padding: 28px 0;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
  background: var(--bg-soft);
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 960px) {
  .method-grid { grid-template-columns: 1fr; }
  .example[data-has-control="true"][data-has-ref="true"] .inputs-row,
  .example[data-has-control="true"][data-has-ref="false"] .inputs-row,
  .example[data-has-control="false"][data-has-ref="true"]  .inputs-row {
    grid-template-columns: 1fr;
  }
  .output-card .media-frame { min-height: 220px; }
  .examples-grid-2col { grid-template-columns: 1fr; }
}

@media (max-width: 600px) {
  .hero { padding: 64px 0 52px; }
  .section { padding: 60px 0; }
  .container { padding: 0 18px; }
  .example-body { padding: 14px; }
}
