/* ============================================================
   CSS Variables — Centralized color & sizing tokens
   ============================================================ */
:root {
  /* Brand */
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-darker: #1e40af;
  --primary-light: #dbeafe;
  --primary-50: #eff6ff;

  /* Surfaces */
  --background: #ffffff;
  --surface: #f8fafc;
  --surface-hover: #f1f5f9;

  /* Borders */
  --border: #e2e8f0;
  --border-light: #f1f5f9;

  /* Text */
  --text: #1e293b;
  --text-secondary: #475569;
  --text-muted: #94a3b8;

  /* Shadows */
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.05);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.08), 0 8px 10px -6px rgba(0, 0, 0, 0.05);

  /* Radii */
  --radius-xs: 6px;
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-full: 9999px;

  /* Layout */
  --max-width: 1200px;
  --abstract-width: 900px;
  --nav-height: 64px;

  /* Transitions */
  --transition-fast: 150ms ease;
  --transition: 250ms ease;
  --transition-slow: 400ms ease;
}

/* ============================================================
   Base / Reset — overrides for Bulma compatibility
   ============================================================ */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: var(--nav-height);
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  color: var(--text);
  background: var(--background);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  margin: 0;
  padding: 0;
}

/* Override Bulma's body padding */
body.has-navbar-fixed-top {
  padding-top: 0;
}

/* Default link reset */
a {
  color: inherit;
  text-decoration: none;
}

/* ============================================================
   Typography
   ============================================================ */
.paper-title {
  font-family: 'Inter', sans-serif;
  font-size: 2.25rem;
  font-weight: 700;
  line-height: 1.3;
  color: var(--text);
  text-align: center;
  letter-spacing: -0.02em;
  margin: 0;
}

.section-title {
  font-family: 'Inter', sans-serif;
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text);
  text-align: center;
  letter-spacing: -0.01em;
  margin-bottom: 0.75rem;
}

.section-subtitle {
  font-size: 1rem;
  color: var(--text-secondary);
  text-align: center;
  max-width: 640px;
  margin: 0 auto 2.5rem;
  line-height: 1.6;
}

/* ============================================================
   Navigation
   ============================================================ */
.navbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--nav-height);
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  z-index: 1000;
  transition: box-shadow var(--transition);
}

.navbar.scrolled {
  box-shadow: var(--shadow-sm);
}

.nav-container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 2rem;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Logo */
.nav-logo {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: -0.02em;
  flex-shrink: 0;
}

.nav-logo:hover {
  color: var(--primary-dark);
}

/* Nav links */
.nav-links {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  list-style: none;
  margin: 0;
  padding: 0;
}

.nav-links a {
  display: block;
  padding: 0.5rem 1rem;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  transition: color var(--transition-fast), background var(--transition-fast);
}

.nav-links a:hover,
.nav-links a:focus-visible {
  color: var(--primary);
  background: var(--primary-50);
}

/* Hamburger toggle — hidden on desktop */
.nav-toggle {
  display: none;
  flex-direction: column;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  z-index: 1001;
}

.nav-toggle-bar {
  display: block;
  width: 24px;
  height: 2px;
  background: var(--text);
  border-radius: 2px;
  transition: transform var(--transition), opacity var(--transition);
}

/* Hamburger active state */
.nav-toggle.active .nav-toggle-bar:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}

.nav-toggle.active .nav-toggle-bar:nth-child(2) {
  opacity: 0;
}

.nav-toggle.active .nav-toggle-bar:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

/* ============================================================
   Sections — Shared spacing
   ============================================================ */
.section {
  padding: 5rem 2rem;
}

.section-container {
  max-width: var(--max-width);
  margin: 0 auto;
}

/* ============================================================
   Teaser Section
   ============================================================ */
.teaser-section {
  padding-top: calc(var(--nav-height) + 3rem);
  padding-bottom: 3rem;
}

.teaser-container {
  max-width: var(--max-width);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2.5rem;
}

/* Teaser video */
.teaser-video-wrapper {
  width: 100%;
  max-width: 100%;
  margin: 0;
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  background: #000;
}

.teaser-video-wrapper video {
  display: block;
  width: 100%;
  height: auto;
  border-radius: var(--radius-lg);
}

/* ============================================================
   Abstract Section
   ============================================================ */
.abstract-container {
  max-width: var(--abstract-width);
  margin: 0 auto;
}

.abstract-text {
  font-size: 1.05rem;
  line-height: 1.8;
  color: var(--text-secondary);
  text-align: justify;
}

/* ============================================================
   Results Section — Video grid
   ============================================================ */
.results-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.5rem;
}

.result-card {
  margin: 0;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition), box-shadow var(--transition);
}

.result-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.result-card video {
  display: block;
  width: 100%;
  height: auto;
  border-radius: var(--radius) var(--radius) 0 0;
  background: #000;
}

.result-card figcaption {
  padding: 0.75rem 1rem;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text);
  text-align: center;
  background: var(--surface);
}

/* ============================================================
   Comparison Section — Split-view sliders
   ============================================================ */
.comparison-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.5rem;
}

.comparison-card {
  margin: 0;
}

/* The comparison container */
.comparison-container {
  position: relative;
  width: 100%;
  overflow: hidden;
  border-radius: var(--radius);
  cursor: col-resize;
  user-select: none;
  -webkit-user-select: none;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.comparison-container img {
  display: block;
  width: 100%;
  height: auto;
  pointer-events: none;
}

/* Overlay: shows Ours (left side), clipped */
.comp-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 50%;
  height: 100%;
  overflow: hidden;
  pointer-events: none;
}

.comp-overlay img {
  position: absolute;
  top: 0;
  left: 0;
  display: block;
  height: auto;
  max-width: none;
  /* width is set dynamically by JS to match the container width */
}

/* The draggable handle */
.comp-handle {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 3px;
  background: var(--primary);
  pointer-events: auto;
  cursor: col-resize;
  transform: translateX(-50%);
  transition: background var(--transition-fast);
}

.comp-handle:hover,
.comp-handle.active {
  background: var(--primary-dark);
}

/* Handle knob */
.comp-handle::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  background: var(--primary);
  box-shadow: var(--shadow-md);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition-fast), transform var(--transition-fast);
}

.comp-handle:hover::after,
.comp-handle.active::after {
  background: var(--primary-dark);
  transform: translate(-50%, -50%) scale(1.1);
}

/* Arrows on handle */
.comp-handle::before {
  content: '\f060 \f061'; /* fa-arrow-left fa-arrow-right */
  font-family: 'Font Awesome 6 Free';
  font-weight: 900;
  font-size: 0.65rem;
  color: #fff;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 2;
  pointer-events: none;
  white-space: nowrap;
  letter-spacing: 2px;
  opacity: 0.9;
}

/* Comparison card title */
.comparison-card figcaption {
  margin-top: 0.75rem;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  text-align: center;
}

/* ============================================================
   Table Section
   ============================================================ */
.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  background: var(--background);
}

.results-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  white-space: nowrap;
}

.results-table thead {
  border-bottom: 2px solid var(--border);
}

.results-table th {
  padding: 0.75rem 1rem;
  font-weight: 600;
  color: var(--text);
  text-align: center;
  background: var(--surface);
  font-size: 0.8rem;
}

.results-table th:first-child {
  text-align: left;
  min-width: 140px;
}

.dataset-header {
  font-size: 0.85rem;
  letter-spacing: 0.02em;
  border-bottom: 1px solid var(--border);
}

.results-table td {
  padding: 0.65rem 1rem;
  text-align: center;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-light);
}

.results-table td:first-child {
  text-align: left;
  font-weight: 500;
  color: var(--text);
}

.results-table tbody tr:hover {
  background: var(--primary-50);
}

/* Highlight best row */
.results-table .highlight-row {
  background: var(--primary-50);
}

.results-table .highlight-row td:first-child {
  color: var(--primary-dark);
  font-weight: 700;
}

/* "(Ours)" tag */
.ours-tag {
  color: #d91a1a;
  font-weight: 600;
  font-size: 0.8rem;
}

/* ============================================================
   BibTeX Section
   ============================================================ */
.bibtex-wrapper {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.bibtex-wrapper pre {
  margin: 0;
  padding: 1.5rem;
  padding-bottom: 3.5rem;
  overflow-x: auto;
  font-size: 0.85rem;
  line-height: 1.7;
  max-height: 300px;
  overflow-y: auto;
}

.bibtex-wrapper code {
  font-family: 'SF Mono', 'Fira Code', 'Fira Mono', 'Roboto Mono', monospace;
  color: var(--text-secondary);
  white-space: pre;
}

/* Copy button */
.copy-btn {
  position: absolute;
  bottom: 0.75rem;
  right: 0.75rem;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 1rem;
  font-size: 0.85rem;
  font-weight: 500;
  font-family: 'Inter', sans-serif;
  color: #fff;
  background: var(--primary);
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition-fast), transform var(--transition-fast);
}

.copy-btn:hover {
  background: var(--primary-dark);
  transform: translateY(-1px);
}

.copy-btn:active {
  transform: translateY(0);
}

.copy-btn.copied {
  background: #16a34a;
}

/* ============================================================
   Footer
   ============================================================ */
.footer {
  text-align: center;
  padding: 2rem;
  border-top: 1px solid var(--border);
}

.footer-text {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin: 0;
}

/* ============================================================
   Back to Top button
   ============================================================ */
.back-to-top {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  width: 44px;
  height: 44px;
  border-radius: var(--radius-full);
  background: var(--primary);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  box-shadow: var(--shadow-md);
  opacity: 0;
  visibility: hidden;
  transform: translateY(12px);
  transition: opacity var(--transition), visibility var(--transition), transform var(--transition),
              background var(--transition-fast);
  z-index: 999;
}

.back-to-top.visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.back-to-top:hover {
  background: var(--primary-dark);
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.back-to-top:active {
  transform: translateY(0);
}

/* ============================================================
   Scroll-triggered fade-in animation
   ============================================================ */
.fade-in {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 0.6s ease-out, transform 0.6s ease-out;
}

.fade-in.visible {
  opacity: 1;
  transform: translateY(0);
}

/* Stagger children */
.fade-in-stagger > * {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.5s ease-out, transform 0.5s ease-out;
}

.fade-in-stagger > *.visible {
  opacity: 1;
  transform: translateY(0);
}

/* ============================================================
   Image hover zoom
   ============================================================ */
.hover-zoom {
  transition: transform var(--transition);
}

.hover-zoom:hover {
  transform: scale(1.03);
}

/* ============================================================
   Responsive — Tablet
   ============================================================ */
@media (max-width: 1024px) {
  .paper-title {
    font-size: 1.75rem;
  }

  .section {
    padding: 3.5rem 1.5rem;
  }

  .teaser-section {
    padding-top: calc(var(--nav-height) + 2rem);
  }

  .results-grid,
  .comparison-grid {
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
  }
}

/* ============================================================
   Responsive — Mobile
   ============================================================ */
@media (max-width: 768px) {
  :root {
    --nav-height: 56px;
  }

  .paper-title {
    font-size: 1.35rem;
  }

  .section-title {
    font-size: 1.35rem;
  }

  .section {
    padding: 2.5rem 1rem;
  }

  .teaser-section {
    padding-top: calc(var(--nav-height) + 1.5rem);
  }

  .abstract-text {
    font-size: 0.95rem;
    line-height: 1.7;
    text-align: left;
  }

  /* Nav — mobile */
  .nav-toggle {
    display: flex;
  }

  .nav-links {
    position: fixed;
    top: var(--nav-height);
    left: 0;
    right: 0;
    background: rgba(255, 255, 255, 0.97);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    flex-direction: column;
    align-items: stretch;
    padding: 0.5rem 1rem;
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-md);
    transform: translateY(-110%);
    opacity: 0;
    transition: transform var(--transition), opacity var(--transition);
    pointer-events: none;
  }

  .nav-links.active {
    transform: translateY(0);
    opacity: 1;
    pointer-events: auto;
  }

  .nav-links a {
    padding: 0.75rem 1rem;
    font-size: 1rem;
    border-radius: var(--radius-sm);
  }

  /* Single-column grids */
  .results-grid,
  .comparison-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  /* Table */
  .results-table {
    font-size: 0.75rem;
  }

  .results-table th,
  .results-table td {
    padding: 0.5rem 0.65rem;
  }

  /* Back to top */
  .back-to-top {
    bottom: 1.25rem;
    right: 1.25rem;
    width: 40px;
    height: 40px;
  }

  /* Handle knob — slightly smaller on mobile */
  .comp-handle::after {
    width: 30px;
    height: 30px;
  }

  .comp-handle::before {
    font-size: 0.55rem;
  }
}

/* ============================================================
   Responsive — Small mobile
   ============================================================ */
@media (max-width: 480px) {
  .paper-title {
    font-size: 1.15rem;
  }

  .section-title {
    font-size: 1.2rem;
  }

  .teaser-container {
    gap: 1.5rem;
  }

  .copy-btn span {
    display: none;
  }
}
