/* ============================================================
   R5DGS — Project Page Design System
   Custom teal/dark palette calibrated to 4D Gaussian Splatting
   visual vocabulary. No gradients, no decorative blobs,
   no centered body text, no emoji in headings.
   ============================================================ */

/* ----- Custom Properties ----- */
:root {
  /* Teal core — Gaussian splatting visual vocabulary */
  --teal-50:  #ecfdf8;
  --teal-100: #ccfbf1;
  --teal-200: #99f6e4;
  --teal-300: #5eead4;
  --teal-400: #2dd4bf;
  --teal-500: #14b8a6;
  --teal-600: #0d9488;
  --teal-700: #0f766e;
  --teal-800: #115e59;
  --teal-900: #134e4a;
  --teal-950: #042f2e;

  /* Neutral scale — cool, technical */
  --gray-50:  #f8fafc;
  --gray-100: #f1f5f9;
  --gray-200: #e2e8f0;
  --gray-300: #cbd5e1;
  --gray-400: #94a3b8;
  --gray-500: #64748b;
  --gray-600: #475569;
  --gray-700: #334155;
  --gray-800: #1e293b;
  --gray-900: #0f172a;
  --gray-950: #020617;

  /* Semantic */
  --accent:   var(--teal-500);
  --accent-dim: var(--teal-600);
  --positive: #22c55e;
  --warning:  #eab308;
  --code-bg:  #1e293b;

  /* Typography */
  --font-display: 'DM Serif Display', 'Times New Roman', serif;
  --font-body:    'DM Sans', 'Inter', system-ui, -apple-system, sans-serif;
  --font-mono:    'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;

  /* Spacing */
  --space-xs:  0.25rem;
  --space-sm:  0.5rem;
  --space-md:  1rem;
  --space-lg:  1.5rem;
  --space-xl:  2rem;
  --space-2xl: 3rem;
  --space-3xl: 4rem;
  --space-4xl: 6rem;

  /* Layout */
  --content-max: 1200px;
  --content-narrow: 800px;
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;

  /* Light-mode defaults */
  --page-bg:       var(--gray-50);
  --surface-bg:    #ffffff;
  --surface-border: var(--gray-200);
  --text-primary:  var(--gray-900);
  --text-secondary: var(--gray-600);
  --text-tertiary:  var(--gray-400);
  --nav-bg:        rgba(255,255,255,0.85);
  --nav-border:    var(--gray-200);
  --hero-bg:       var(--gray-900);
  --hero-text:     #ffffff;
  --hero-muted:    var(--gray-400);
  --card-bg:       #ffffff;
  --card-border:   var(--gray-200);
  --table-stripe:  var(--gray-50);
  --table-border:  var(--gray-200);
  --tag-bg:        var(--teal-50);
  --tag-text:      var(--teal-800);
  --blockquote-border: var(--teal-400);
  --bib-bg:        var(--gray-900);
  --bib-text:      #e2e8f0;
  --footer-bg:     var(--gray-900);
  --footer-text:   var(--gray-400);
  --shadow-sm:     0 1px 2px rgba(0,0,0,0.04);
  --shadow-md:     0 4px 12px rgba(0,0,0,0.06);
  --shadow-lg:     0 8px 24px rgba(0,0,0,0.08);
}

/* ----- Dark Mode ----- */
[data-theme="dark"] {
  --page-bg:       var(--gray-950);
  --surface-bg:    var(--gray-900);
  --surface-border: var(--gray-800);
  --text-primary:  var(--gray-100);
  --text-secondary: var(--gray-400);
  --text-tertiary:  var(--gray-500);
  --nav-bg:        rgba(15,23,42,0.85);
  --nav-border:    var(--gray-800);
  --hero-bg:       #000000;
  --hero-text:     var(--gray-100);
  --hero-muted:    var(--gray-500);
  --card-bg:       var(--gray-900);
  --card-border:   var(--gray-800);
  --table-stripe:  var(--gray-900);
  --table-border:  var(--gray-800);
  --tag-bg:        var(--teal-950);
  --tag-text:      var(--teal-300);
  --blockquote-border: var(--teal-600);
  --bib-bg:        #000000;
  --bib-text:      var(--gray-300);
  --footer-bg:     #000000;
  --footer-text:   var(--gray-500);
  --shadow-sm:     0 1px 2px rgba(0,0,0,0.2);
  --shadow-md:     0 4px 12px rgba(0,0,0,0.3);
  --shadow-lg:     0 8px 24px rgba(0,0,0,0.4);
}

/* ----- Reset & Base ----- */
*, *::before, *::after { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  margin: 0;
  padding: 0;
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.6;
  color: var(--text-primary);
  background: var(--page-bg);
  transition: background 0.2s ease, color 0.2s ease;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

a {
  color: var(--teal-500);
  text-decoration: none;
  transition: color 0.15s ease;
}
a:hover { color: var(--teal-400); }

/* ----- Typography ----- */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  font-weight: 400;
  line-height: 1.25;
  margin: 0 0 var(--space-sm);
  color: var(--text-primary);
}

h1 { font-size: 2.5rem; }
h2 { font-size: 1.75rem; }
h3 { font-size: 1.25rem; }

h2 {
  letter-spacing: -0.01em;
  margin-bottom: var(--space-lg);
}

p { margin: 0 0 var(--space-md); }

/* Body text is NEVER centered — anti-pattern guard. */
p, li, figcaption, .text-body { text-align: left; }

code, pre {
  font-family: var(--font-mono);
  font-size: 0.85em;
}

small, .text-small { font-size: 0.85rem; }
.text-secondary { color: var(--text-secondary); }
.text-mono { font-family: var(--font-mono); }

/* ----- Container ----- */
.container {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 0 var(--space-xl);
}

/* ----- Nav ----- */
nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--nav-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--nav-border);
  transition: background 0.2s ease, border-color 0.2s ease;
}

nav .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
}

.nav-brand {
  font-family: var(--font-display);
  font-size: 1.1rem;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: var(--space-lg);
  list-style: none;
  margin: 0;
  padding: 0;
}

.nav-links a {
  font-size: 0.85rem;
  color: var(--text-secondary);
  transition: color 0.15s ease;
}
.nav-links a:hover { color: var(--text-primary); }

/* Theme toggle */
.theme-toggle {
  background: none;
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-sm);
  padding: var(--space-xs) var(--space-sm);
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 0.9rem;
  line-height: 1;
  transition: color 0.15s ease, border-color 0.15s ease;
}
.theme-toggle:hover {
  color: var(--text-primary);
  border-color: var(--text-tertiary);
}

/* ----- Hero ----- */
.hero {
  background: var(--hero-bg);
  color: var(--hero-text);
  padding: var(--space-4xl) 0 var(--space-3xl);
  transition: background 0.2s ease;
}

.hero .container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-3xl);
  align-items: start;
}

.hero-content { min-width: 0; }

.venue-badge {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 0.3rem 0.7rem;
  border: 1px solid var(--teal-600);
  border-radius: var(--radius-sm);
  color: var(--teal-400);
  margin-bottom: var(--space-lg);
}

.hero h1 {
  font-size: 2.75rem;
  line-height: 1.15;
  margin-bottom: var(--space-md);
  color: #ffffff;
}

.hero-authors {
  font-size: 0.95rem;
  color: var(--hero-muted);
  margin-bottom: var(--space-lg);
  line-height: 1.6;
}

.hero-authors .affiliation {
  display: block;
  font-size: 0.8rem;
  color: var(--gray-500);
  margin-top: var(--space-xs);
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
  margin-top: var(--space-lg);
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  padding: 0.55rem 1.1rem;
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 500;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s ease;
  text-decoration: none;
  line-height: 1.3;
}

.btn-primary {
  background: var(--teal-500);
  color: #ffffff;
  border-color: var(--teal-500);
}
.btn-primary:hover {
  background: var(--teal-400);
  border-color: var(--teal-400);
  color: #ffffff;
}

.btn-outline {
  background: transparent;
  color: var(--gray-300);
  border-color: var(--gray-700);
}
.btn-outline:hover {
  color: #ffffff;
  border-color: var(--gray-500);
}

.hero-teaser {
  position: relative;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--gray-800);
  aspect-ratio: 4 / 3;
}

.hero-teaser img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.hero-teaser figcaption {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: var(--space-md);
  font-size: 0.78rem;
  color: var(--gray-300);
  background: linear-gradient(transparent, rgba(0,0,0,0.75));
}

/* ----- Section common ----- */
.section {
  padding: var(--space-4xl) 0;
}

.section-header {
  margin-bottom: var(--space-2xl);
}

.section-header h2 {
  margin-bottom: var(--space-sm);
}

/* ----- Abstract ----- */
.abstract-grid {
  display: grid;
  grid-template-columns: 3fr 2fr;
  gap: var(--space-2xl);
  align-items: start;
}

.abstract-text {
  font-size: 1rem;
  line-height: 1.7;
}

.abstract-text blockquote {
  margin: 0 0 var(--space-lg);
  padding: 0 0 0 var(--space-lg);
  border-left: 3px solid var(--blockquote-border);
  color: var(--text-secondary);
}

.stats-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  padding: var(--space-xl);
  box-shadow: var(--shadow-sm);
}

.stats-card h3 {
  font-family: var(--font-body);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-tertiary);
  margin-bottom: var(--space-lg);
}

.stat-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: var(--space-sm) 0;
  border-bottom: 1px solid var(--table-border);
}

.stat-row:last-child { border-bottom: none; }

.stat-label {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.stat-value {
  font-family: var(--font-mono);
  font-size: 1.1rem;
  font-weight: 500;
  color: var(--accent);
}

/* ----- Method ----- */
.pipeline-figure {
  margin-bottom: var(--space-2xl);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
}

.pipeline-figure img {
  width: 100%;
}

.pipeline-figure figcaption {
  padding: var(--space-sm) var(--space-md);
  font-size: 0.8rem;
  color: var(--text-secondary);
  border-top: 1px solid var(--card-border);
}

.contrib-grid {
  display: grid;
  grid-template-columns: 1.3fr 1fr 1fr;
  gap: var(--space-lg);
}

.contrib-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  padding: var(--space-xl);
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.2s ease;
}

.contrib-card:hover {
  box-shadow: var(--shadow-md);
}

.contrib-card:first-child {
  grid-row: span 1;
}

.contrib-number {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: var(--space-sm);
}

.contrib-card h3 {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 1rem;
  margin-bottom: var(--space-sm);
}

.contrib-card p {
  font-size: 0.88rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

.contrib-tag {
  display: inline-block;
  margin-top: var(--space-sm);
  font-size: 0.72rem;
  font-weight: 500;
  padding: 0.2rem 0.5rem;
  background: var(--tag-bg);
  color: var(--tag-text);
  border-radius: var(--radius-sm);
}

/* ----- Results ----- */
.video-placeholder {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  aspect-ratio: 16 / 9;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin-bottom: var(--space-2xl);
  color: var(--text-tertiary);
  font-size: 0.85rem;
  gap: var(--space-md);
}

.video-placeholder .play-icon {
  width: 48px;
  height: 48px;
  border: 2px solid var(--text-tertiary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  transition: border-color 0.15s ease, color 0.15s ease;
}

.video-placeholder:hover .play-icon {
  border-color: var(--accent);
  color: var(--accent);
}

.comparison-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-md);
  margin-bottom: var(--space-2xl);
}

.comparison-panel {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.comparison-panel img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-bottom: 1px solid var(--card-border);
}

.comparison-panel .panel-label {
  padding: var(--space-sm) var(--space-md);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
}

/* Metrics table */
.metrics-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.metrics-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
  line-height: 1.5;
}

.metrics-table thead th {
  font-family: var(--font-body);
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  text-align: left;
  padding: 0.6rem 0.8rem;
  border-bottom: 2px solid var(--table-border);
  color: var(--text-tertiary);
  white-space: nowrap;
}

.metrics-table tbody td {
  padding: 0.55rem 0.8rem;
  border-bottom: 1px solid var(--table-border);
  white-space: nowrap;
}

.metrics-table tbody tr:nth-child(even) {
  background: var(--table-stripe);
}

.metrics-table tbody tr:hover {
  background: var(--teal-50);
}

[data-theme="dark"] .metrics-table tbody tr:hover {
  background: var(--teal-950);
}

.metrics-table .method-name {
  font-weight: 600;
}

.metrics-table .best {
  color: var(--positive);
  font-weight: 600;
}

.metrics-table .dim {
  color: var(--text-tertiary);
}

/* ----- BibTeX ----- */
.bib-block {
  position: relative;
  background: var(--bib-bg);
  border-radius: var(--radius-md);
  padding: var(--space-lg);
  overflow-x: auto;
}

.bib-block pre {
  margin: 0;
  font-size: 0.78rem;
  line-height: 1.55;
  color: var(--bib-text);
  white-space: pre;
}

.bib-copy-btn {
  position: absolute;
  top: var(--space-sm);
  right: var(--space-sm);
  background: var(--gray-800);
  border: 1px solid var(--gray-700);
  border-radius: var(--radius-sm);
  padding: 0.3rem 0.6rem;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--gray-400);
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.bib-copy-btn:hover {
  color: #ffffff;
  border-color: var(--gray-500);
}

.bib-copy-btn.copied {
  color: var(--positive);
  border-color: var(--positive);
}

/* ----- Related Work Cards ----- */
.related-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-lg);
}

.related-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  padding: var(--space-lg);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.related-card .venue-tag {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-tertiary);
}

.related-card h3 {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.9rem;
  margin: 0;
  color: var(--text-primary);
}

.related-card p {
  font-size: 0.8rem;
  color: var(--text-secondary);
  line-height: 1.5;
  margin: 0;
  flex: 1;
}

.related-card .related-link {
  font-size: 0.78rem;
  font-weight: 500;
}

/* ----- Footer ----- */
footer {
  background: var(--footer-bg);
  color: var(--footer-text);
  padding: var(--space-2xl) 0;
  font-size: 0.82rem;
  border-top: 1px solid var(--gray-800);
}

footer .container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-md);
}

footer a { color: var(--gray-400); }
footer a:hover { color: var(--gray-200); }

/* ----- Responsive ----- */
@media (max-width: 900px) {
  .hero .container {
    grid-template-columns: 1fr;
    gap: var(--space-xl);
  }
  .hero h1 { font-size: 2rem; }
  .abstract-grid {
    grid-template-columns: 1fr;
  }
  .contrib-grid {
    grid-template-columns: 1fr;
  }
  .related-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 640px) {
  .container { padding: 0 var(--space-md); }
  h1 { font-size: 1.6rem; }
  h2 { font-size: 1.35rem; }
  .hero { padding: var(--space-2xl) 0; }
  .section { padding: var(--space-2xl) 0; }
  .nav-links { gap: var(--space-md); }
  .nav-links a { font-size: 0.78rem; }
  .comparison-strip { grid-template-columns: 1fr; }
  .related-grid { grid-template-columns: 1fr; }
  .hero-actions { flex-direction: column; }
  .btn { justify-content: center; }
  .hero-authors { font-size: 0.85rem; }
  .hero-teaser { order: 1; }
}

@media (max-width: 480px) {
  .nav-links { display: none; }
  .hero h1 { font-size: 1.35rem; }
}
