/* ==========================================================================
   Perceptive BFM — paper page (CSS-only, dependency-free)
   Style: clean academic, Nerfies/academicpages-inspired, dark/light auto.
   ========================================================================== */

:root {
  --bg: #ffffff;
  --bg-alt: #f7f8fa;
  --text: #1a1a1a;
  --text-muted: #5a5a5a;
  --accent: #4f46e5;            /* indigo-600 */
  --accent-hover: #3730a3;
  --border: #e3e6eb;
  --code-bg: #0f172a;
  --code-text: #e2e8f0;
  --tldr-bg: #eef2ff;
  --tldr-border: #c7d2fe;
  --max-width: 1100px;
  --narrow-width: 820px;
  --shadow: 0 4px 14px rgba(15, 23, 42, 0.06);
  --shadow-strong: 0 10px 28px rgba(15, 23, 42, 0.10);
  --radius: 10px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --bg-alt: #161922;
    --text: #e6e8eb;
    --text-muted: #a0a4ad;
    --accent: #818cf8;
    --accent-hover: #a5b4fc;
    --border: #2a2f3a;
    --tldr-bg: #1e1f3a;
    --tldr-border: #3b3f7a;
  }
}

* { box-sizing: border-box; }
html {
  scroll-behavior: smooth;
  scroll-padding-top: 64px;
  /* Reserve the scrollbar space consistently so layout doesn't shift between
     platforms (Linux/Windows Chrome show a permanent scrollbar; macOS overlays
     it). This keeps the page centered identically everywhere. */
  scrollbar-gutter: stable;
}

body {
  margin: 0;
  overflow-x: hidden; /* guard against any full-bleed element causing h-scroll */
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue",
               Arial, "Noto Sans", "PingFang SC", "Hiragino Sans GB",
               "Microsoft YaHei", sans-serif;
  font-size: 16.5px;
  line-height: 1.65;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

.container { max-width: var(--max-width); margin: 0 auto; padding: 0 20px; }
.container.narrow { max-width: var(--narrow-width); }
.muted { color: var(--text-muted); }

/* -------------------------------------------------------------------- nav */
.topnav {
  position: sticky; top: 0; z-index: 50;
  background: rgba(255,255,255,0.85);
  backdrop-filter: saturate(180%) blur(10px);
  -webkit-backdrop-filter: saturate(180%) blur(10px);
  border-bottom: 1px solid var(--border);
}
@media (prefers-color-scheme: dark) {
  .topnav { background: rgba(15,17,21,0.85); }
}
.nav-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 12px 20px;
  display: flex; align-items: center; justify-content: space-between;
  gap: 20px;
}
.nav-brand {
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text);
  text-decoration: none;
  font-size: 1.05em;
}
.nav-links {
  list-style: none; padding: 0; margin: 0;
  display: flex; gap: 18px; flex-wrap: wrap;
}
.nav-links a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.94em;
  transition: color 0.15s ease;
}
.nav-links a:hover { color: var(--accent); }
.nav-links a.active { color: var(--accent); font-weight: 600; }
.nav-demo {
  background: var(--accent);
  color: #fff !important;
  padding: 4px 12px;
  border-radius: 999px;
}
.nav-demo:hover { background: var(--accent-hover); color: #fff !important; }

/* ------------------------------------------------------ cinematic hero */
.hero-cine {
  position: relative;
  min-height: 88vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  overflow: hidden;
  color: #fff;
  padding: 90px 20px 70px;
}
.hero-bg-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 0;
}
.hero-bg-overlay {
  position: absolute;
  inset: 0;
  z-index: 1;
  /* Lighter scrim so the video reads clearly, with a soft dark band behind the
     title text (centered) for legibility. */
  background:
    radial-gradient(70% 55% at 50% 50%, rgba(8,10,18,0.45) 0%, rgba(8,10,18,0.18) 70%, rgba(8,10,18,0.05) 100%),
    linear-gradient(180deg, rgba(8,10,18,0.30) 0%, rgba(8,10,18,0.0) 30%, rgba(8,10,18,0.0) 70%, rgba(8,10,18,0.35) 100%);
}
.hero-cine-inner {
  position: relative;
  z-index: 2;
  max-width: 940px;
  animation: heroFade 0.9s ease both;
}
@keyframes heroFade {
  from { opacity: 0; transform: translateY(18px); }
  to   { opacity: 1; transform: translateY(0); }
}
.hero-cine .venue {
  color: #fff;
  border-color: rgba(255,255,255,0.55);
  background: rgba(255,255,255,0.12);
  backdrop-filter: blur(4px);
}
.hero-cine .paper-title {
  color: #fff;
  text-shadow: 0 2px 24px rgba(0,0,0,0.45);
  font-size: clamp(1.8em, 4vw, 3em);
}
.hero-cine .title-sub { color: rgba(255,255,255,0.82); }
.hero-cine .authors { color: #fff; }
.hero-cine .affiliations { color: rgba(255,255,255,0.72); }
.muted-light { color: rgba(255,255,255,0.78); }
.hero-tagline {
  margin: 22px auto 0;
  max-width: 640px;
  font-size: 1.02em;
}
.btn-glass {
  background: rgba(255,255,255,0.12);
  border-color: rgba(255,255,255,0.30);
  color: #fff;
  backdrop-filter: blur(6px);
  box-shadow: none;
}
.btn-glass:hover {
  background: rgba(255,255,255,0.22);
  border-color: #fff;
  color: #fff;
}

/* scroll cue */
.scroll-cue {
  position: absolute;
  bottom: 22px; left: 50%;
  transform: translateX(-50%);
  z-index: 2;
  width: 26px; height: 42px;
  border: 2px solid rgba(255,255,255,0.6);
  border-radius: 999px;
  display: flex; justify-content: center;
}
.scroll-cue-dot {
  width: 4px; height: 8px;
  margin-top: 7px;
  background: #fff;
  border-radius: 999px;
  animation: scrollDot 1.6s ease-in-out infinite;
}
@keyframes scrollDot {
  0%   { opacity: 0; transform: translateY(0); }
  40%  { opacity: 1; }
  100% { opacity: 0; transform: translateY(14px); }
}

/* ----------------------------------------------------------------- header */
.hero {
  padding: 56px 0 24px;
  text-align: center;
  background: linear-gradient(180deg, var(--bg) 0%, var(--bg-alt) 100%);
}
.venue {
  display: inline-block;
  font-size: 0.85em;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 600;
  margin-bottom: 14px;
  padding: 4px 14px;
  border: 1px solid var(--accent);
  border-radius: 999px;
  background: rgba(79,70,229,0.06);
}
.paper-title {
  font-size: clamp(1.6em, 3.2vw, 2.4em);
  line-height: 1.25;
  margin: 6px 0 20px;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.title-sub {
  display: inline-block;
  font-weight: 500;
  font-size: 0.78em;
  color: var(--text-muted);
  letter-spacing: -0.01em;
}
.authors {
  font-size: 1.05em;
  margin-bottom: 4px;
}
.author { font-weight: 500; }
.affiliations {
  color: var(--text-muted);
  font-size: 0.95em;
  margin-bottom: 24px;
}

.action-buttons {
  display: flex; flex-wrap: wrap; gap: 10px;
  justify-content: center;
  margin-bottom: 36px;
}
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 10px 18px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg);
  color: var(--text);
  text-decoration: none;
  font-size: 0.95em;
  font-weight: 500;
  transition: all 0.15s ease;
  box-shadow: var(--shadow);
}
.btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  transform: translateY(-1px);
  box-shadow: var(--shadow-strong);
}
.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: #fff;
}
.btn-disabled {
  opacity: 0.55;
  cursor: not-allowed;
  pointer-events: none;
}

.hero-figure {
  margin: 24px auto 0;
  max-width: 100%;
}
.hero-figure img {
  width: 100%; height: auto;
  border-radius: var(--radius);
  box-shadow: var(--shadow-strong);
  border: 1px solid var(--border);
}
.hero-figure figcaption {
  margin-top: 14px;
  font-size: 0.95em;
  color: var(--text-muted);
  max-width: var(--narrow-width);
  margin-left: auto; margin-right: auto;
  text-align: left;
}

/* -------------------------------------------------------------------- TLDR */
.tldr-section { padding: 32px 0 0; }
.tldr {
  background: var(--tldr-bg);
  border: 1px solid var(--tldr-border);
  border-radius: var(--radius);
  padding: 22px 26px;
  position: relative;
}
.tldr-label {
  position: absolute;
  top: -12px; left: 22px;
  background: var(--accent);
  color: #fff;
  padding: 3px 12px;
  border-radius: 999px;
  font-size: 0.78em;
  font-weight: 700;
  letter-spacing: 0.06em;
}
.tldr p { margin: 0; }

/* ----------------------------------------------------------------- sections */
.section { padding: 56px 0; border-bottom: 1px solid var(--border); }
.section.gray { background: var(--bg-alt); }
.section h2 {
  font-size: 1.85em;
  margin: 0 0 22px;
  letter-spacing: -0.02em;
  font-weight: 700;
}
.subsection-title {
  margin-top: 36px;
  font-size: 1.25em;
  font-weight: 600;
  letter-spacing: -0.01em;
}

/* -------------------------------------------------------------- video block */
.video-wrapper {
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}
.video-placeholder {
  background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
  color: #cbd5e1;
  aspect-ratio: 16 / 9;
  display: flex; align-items: center; justify-content: center;
}
.video-placeholder-inner {
  text-align: center; padding: 30px;
  max-width: 600px;
}
.play-icon {
  font-size: 3em;
  background: rgba(255,255,255,0.1);
  width: 80px; height: 80px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 18px;
}
.code-snippet {
  background: rgba(0,0,0,0.4);
  color: #e2e8f0;
  padding: 12px;
  border-radius: 6px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.78em;
  text-align: left;
  white-space: pre-wrap;
  margin: 14px 0 0;
}

/* --------------------------------------------------------------- method grid */
.method-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 18px;
  margin-bottom: 36px;
}
.method-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  background: var(--bg);
  position: relative;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.method-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-strong);
}
.method-num {
  position: absolute;
  top: -14px; left: 22px;
  width: 32px; height: 32px;
  background: var(--accent);
  color: #fff;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
  font-size: 0.95em;
}
.method-card h3 {
  margin: 8px 0 10px;
  font-size: 1.05em;
  font-weight: 600;
}
.method-card p {
  margin: 0;
  font-size: 0.94em;
  color: var(--text-muted);
}

/* ----------------------------------------------------------------- figures */
.figure-block {
  margin: 28px 0;
  text-align: center;
}
.figure-block img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.figure-block figcaption {
  margin: 12px auto 0;
  max-width: 720px;
  font-size: 0.93em;
  color: var(--text-muted);
  text-align: left;
}
.figure-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 22px;
}
.figure-grid .figure-block { margin: 0; }

/* ------------------------------------------------------------------- paper card */
.paper-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  overflow: hidden;
  transition: box-shadow 0.2s ease;
}
.paper-card:hover { box-shadow: var(--shadow-strong); }
.paper-link {
  display: flex;
  gap: 18px;
  padding: 20px;
  text-decoration: none;
  color: inherit;
  align-items: center;
}
.paper-thumb {
  width: 76px; height: 96px;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 2.2em;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.paper-meta { flex: 1; min-width: 0; }
.paper-card-title { font-weight: 600; font-size: 1.05em; line-height: 1.4; }
.paper-card-sub  { color: var(--text-muted); font-size: 0.93em; margin: 4px 0 10px; }
.paper-card-links { display: flex; gap: 8px; flex-wrap: wrap; }
.badge {
  display: inline-block;
  padding: 3px 10px;
  background: var(--accent);
  color: #fff;
  border-radius: 999px;
  font-size: 0.78em;
  font-weight: 600;
}
.badge-muted {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}

/* -------------------------------------------------------------------- code */
.code-block { position: relative; }
.code-block pre {
  background: var(--code-bg);
  color: var(--code-text);
  padding: 22px 24px;
  border-radius: var(--radius);
  overflow-x: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.88em;
  line-height: 1.55;
}
.copy-btn {
  position: absolute;
  top: 12px; right: 12px;
  background: rgba(255,255,255,0.10);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 6px;
  padding: 4px 12px;
  font-size: 0.82em;
  cursor: pointer;
  transition: background 0.15s ease;
}
.copy-btn:hover { background: rgba(255,255,255,0.25); }
.copy-btn.copied {
  background: #10b981;
  border-color: #10b981;
}

code {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  padding: 1px 6px;
  border-radius: 4px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.92em;
}

a { color: var(--accent); }
a:hover { color: var(--accent-hover); }

/* ------------------------------------------------------ section lead text */
.section-lead {
  max-width: var(--narrow-width);
  color: var(--text-muted);
  font-size: 1.0em;
  margin: -6px 0 24px;
}

/* ------------------------------------------------------ teaser figure */
/* Full-bleed: span (nearly) the full viewport width. Uses margins, NOT
   transform, so the .reveal animation class can't override the centering. */
/* The teaser is a direct child of its section (outside .container), so it can be
   a simple centered block wider than the 1100px text column. No vw units → no
   scrollbar-driven misalignment between macOS and Linux/Windows. */
.hero-teaser {
  margin: 0 auto;
  width: 100%;
  max-width: 1700px;
  padding: 0 20px;
}
.hero-teaser img {
  width: 100%;
  box-shadow: var(--shadow-strong);
}
.hero-teaser figcaption { max-width: 1100px; margin-inline: auto; }
/* pull the teaser section up so the big figure sits right under the hero */
#teaser { padding-top: 30px; }

/* ------------------------------------------------------ TL;DR three cards */
.tldr-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-top: 30px;
}
.tldr-card {
  background: var(--tldr-bg);
  border: 1px solid var(--tldr-border);
  border-radius: var(--radius);
  padding: 20px 22px;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.tldr-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-strong); }
.tldr-card-icon { font-size: 1.7em; line-height: 1; margin-bottom: 8px; }
.tldr-card h3 { margin: 0 0 8px; font-size: 1.05em; font-weight: 600; }
.tldr-card p { margin: 0; font-size: 0.92em; color: var(--text-muted); }

/* ------------------------------------------------------ demo launch card */
.demo-launch {
  display: block;
  text-decoration: none;
  color: inherit;
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-strong);
  aspect-ratio: 16 / 9;
  max-height: 560px;
  cursor: pointer;
  background: #0b0e16;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.demo-launch:hover {
  transform: translateY(-3px);
  box-shadow: 0 16px 40px rgba(15,23,42,0.18);
}
.demo-launch:hover .demo-play {
  transform: scale(1.08);
  background: var(--accent);
}
.demo-launch-poster {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  filter: brightness(0.55) saturate(1.05);
}
.demo-launch-overlay {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 10px;
  color: #fff;
  text-align: center;
  padding: 20px;
  background: radial-gradient(80% 80% at 50% 45%, rgba(10,12,22,0.25), rgba(10,12,22,0.55));
}
.demo-launch-overlay p { margin: 0; }
.demo-play {
  width: 84px; height: 84px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.7);
  background: rgba(79,70,229,0.85);
  color: #fff;
  font-size: 2em;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: transform 0.18s ease, background 0.18s ease;
  box-shadow: 0 8px 28px rgba(0,0,0,0.4);
}
.demo-play:hover { transform: scale(1.08); background: var(--accent); }
.demo-launch iframe {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  border: 0;
}

/* ------------------------------------------------------ stat callouts */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin: 8px 0 30px;
}
.stat-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  background: var(--bg);
  box-shadow: var(--shadow);
}
.stat-num {
  font-size: 2em;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--accent);
  line-height: 1.1;
}
.stat-vs { font-size: 0.5em; font-weight: 600; color: var(--text-muted); }
.stat-label { margin-top: 8px; font-size: 0.9em; color: var(--text-muted); }

/* ------------------------------------------------------ limitations row */
.limitation-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 28px;
  align-items: center;
}
.limitation-row p:first-child { margin-top: 0; }
@media (max-width: 720px) {
  .limitation-row { grid-template-columns: 1fr; }
}

/* ----------------------------------------------------------- video gallery */
.video-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 18px;
  margin: 18px 0 8px;
}
.video-grid.grid-2 {
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
}
.video-card {
  margin: 0;
  border-radius: var(--radius);
  overflow: hidden;
  background: #0b0e16;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  cursor: pointer;
  position: relative;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.video-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-strong);
  border-color: var(--accent);
}
.video-card video {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  background: #0b0e16;
}
.video-card::after {
  content: "⤢";
  position: absolute;
  top: 10px; right: 10px;
  width: 30px; height: 30px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(10,12,22,0.65);
  color: #fff;
  border-radius: 8px;
  font-size: 0.95em;
  opacity: 0;
  transition: opacity 0.2s ease;
  backdrop-filter: blur(4px);
}
.video-card:hover::after { opacity: 1; }
.video-card figcaption {
  padding: 11px 14px;
  font-size: 0.9em;
  color: var(--text-muted);
  text-align: left;
  line-height: 1.45;
}

/* ----------------------------------------------------------------- lightbox */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(6,8,14,0.92);
  backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.lightbox.open { display: flex; animation: lbFade 0.2s ease; }
@keyframes lbFade { from { opacity: 0; } to { opacity: 1; } }
.lightbox-stage {
  max-width: 1100px;
  width: 100%;
  text-align: center;
}
.lightbox-stage video {
  width: 100%;
  max-height: 80vh;
  border-radius: var(--radius);
  box-shadow: 0 20px 60px rgba(0,0,0,0.6);
  background: #000;
}
.lightbox-caption {
  color: #cbd5e1;
  margin-top: 14px;
  font-size: 0.95em;
}
.lightbox-close {
  position: absolute;
  top: 18px; right: 24px;
  width: 44px; height: 44px;
  border-radius: 50%;
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.25);
  color: #fff;
  font-size: 1.6em;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s ease;
}
.lightbox-close:hover { background: rgba(255,255,255,0.28); }

/* -------------------------------------------------------- scroll reveal */
.reveal {
  opacity: 0;
  transform: translateY(22px);
  transition: opacity 0.6s ease, transform 0.6s ease;
  will-change: opacity, transform;
}
.reveal.visible {
  opacity: 1;
  transform: none;
}
@media (prefers-reduced-motion: reduce) {
  .reveal { opacity: 1; transform: none; transition: none; }
  .scroll-cue-dot, .hero-cine-inner { animation: none; }
}

/* ----------------------------------------------------------------- footer */
.site-footer {
  padding: 30px 0;
  text-align: center;
  font-size: 0.9em;
  color: var(--text-muted);
}
.site-footer p { margin: 4px 0; }

/* ----------------------------------------------------------------- mobile */
@media (max-width: 640px) {
  .hero { padding: 36px 0 16px; }
  .hero-cine { min-height: 78vh; padding: 80px 16px 60px; }
  .nav-links { gap: 12px; font-size: 0.88em; }
  .nav-brand { font-size: 0.95em; }
  .paper-link { flex-direction: column; align-items: flex-start; }
  .paper-thumb { width: 56px; height: 72px; font-size: 1.6em; }
  .video-grid, .video-grid.grid-2 { grid-template-columns: 1fr; }
  .lightbox-close { top: 10px; right: 12px; }
}
