/* SpaCeFormer Project Page */
:root {
  --primary: #1a73e8;
  --primary-dark: #1557b0;
  --accent: #f9ab00;
  --bg: #ffffff;
  --bg-alt: #f8f9fa;
  --text: #202124;
  --text-secondary: #5f6368;
  --border: #dadce0;
  --code-bg: #f1f3f4;
  --max-width: 1100px;
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", "Fira Code", "Consolas", monospace;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  line-height: 1.7;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}

/* Layout */
.container { max-width: var(--max-width); margin: 0 auto; padding: 0 24px; }
section { padding: 60px 0; }
section:nth-child(even) { background: var(--bg-alt); }

/* Typography */
h1 { font-size: 2.5rem; font-weight: 700; line-height: 1.2; letter-spacing: -0.02em; }
h2 { font-size: 1.75rem; font-weight: 600; margin-bottom: 24px; letter-spacing: -0.01em; }
h3 { font-size: 1.25rem; font-weight: 600; margin-bottom: 12px; }
p { margin-bottom: 16px; }

/* Hero */
.hero {
  text-align: center;
  padding: 80px 0 60px;
  background: linear-gradient(135deg, #f0f4ff 0%, #e8f0fe 50%, #fef7e0 100%);
}

.hero h1 { margin-bottom: 16px; color: var(--text); }

.hero .subtitle {
  font-size: 1.15rem;
  color: var(--text-secondary);
  max-width: 800px;
  margin: 0 auto 24px;
  line-height: 1.6;
}

.venue-badge {
  display: inline-block;
  background: var(--primary);
  color: white;
  padding: 6px 16px;
  border-radius: 20px;
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 24px;
}

.authors {
  font-size: 1.05rem;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.authors a { color: var(--primary); text-decoration: none; }
.authors a:hover { text-decoration: underline; }

.affiliations {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: 32px;
}

/* Links Row */
.links-row {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 24px;
}

.link-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: 8px;
  font-weight: 500;
  font-size: 0.95rem;
  text-decoration: none;
  transition: all 0.2s;
  border: 1.5px solid var(--border);
  background: white;
  color: var(--text);
}

.link-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
  box-shadow: 0 2px 8px rgba(26, 115, 232, 0.15);
}

.link-btn.primary {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.link-btn.primary:hover {
  background: var(--primary-dark);
}

.link-btn svg { width: 18px; height: 18px; }

/* Stats Bar */
.stats-bar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 20px;
  padding: 40px 0;
}

.stat-card {
  text-align: center;
  padding: 24px 16px;
  background: white;
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.stat-number {
  font-size: 2rem;
  font-weight: 700;
  color: var(--primary);
  display: block;
}

.stat-label {
  font-size: 0.85rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 4px;
}

/* Abstract */
.abstract-text {
  font-size: 1.05rem;
  color: var(--text-secondary);
  max-width: 900px;
  margin: 0 auto;
  text-align: justify;
}

/* 3D Viewer */
.viewer-section { background: var(--bg-alt); }

.viewer-container {
  position: relative;
  width: 100%;
  height: 600px;
  background: #1a1a2e;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 4px 24px rgba(0,0,0,0.15);
}

#pointcloud-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.viewer-controls {
  position: absolute;
  top: 16px;
  left: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 10;
}

.viewer-controls select,
.viewer-controls button {
  padding: 8px 14px;
  border-radius: 6px;
  border: none;
  background: rgba(255,255,255,0.92);
  color: var(--text);
  font-size: 0.85rem;
  cursor: pointer;
  backdrop-filter: blur(8px);
  font-family: var(--font);
}

.viewer-controls button:hover { background: rgba(255,255,255,1); }
.viewer-controls button.active { background: var(--primary); color: white; }

.viewer-info {
  position: absolute;
  bottom: 16px;
  left: 16px;
  color: rgba(255,255,255,0.7);
  font-size: 0.8rem;
  z-index: 10;
}

.viewer-legend {
  position: absolute;
  top: 16px;
  right: 16px;
  background: rgba(0,0,0,0.7);
  color: white;
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 0.8rem;
  z-index: 10;
  max-height: 400px;
  overflow-y: auto;
  backdrop-filter: blur(8px);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 0;
  cursor: pointer;
  opacity: 0.9;
}

.legend-item:hover { opacity: 1; }

.legend-swatch {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  flex-shrink: 0;
}

.score-slider-container {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}

.score-slider-container input[type="range"] { width: 120px; }
.score-slider-container label { font-size: 0.8rem; white-space: nowrap; }

.loading-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #1a1a2e;
  color: white;
  font-size: 1.1rem;
  z-index: 20;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(255,255,255,0.2);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-right: 12px;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* Method */
.method-figure {
  width: 100%;
  max-width: 900px;
  margin: 24px auto;
  display: block;
  border-radius: 8px;
}

.method-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin-top: 24px;
}

.method-card {
  padding: 24px;
  background: white;
  border-radius: 12px;
  border: 1px solid var(--border);
}

.method-card h3 { color: var(--primary); }

/* Attention Block Comparison */
.attn-comparison {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  align-items: end;
}

.attn-card {
  background: white;
  border-radius: 8px;
  border: 1.5px solid var(--border);
  overflow: hidden;
  text-align: center;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.attn-card img {
  width: 100%;
  display: block;
  padding: 12px;
}

.attn-label {
  display: block;
  padding: 8px;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-secondary);
  border-top: 1px solid var(--border);
  background: var(--bg-alt);
}

.attn-card.highlight-card {
  border-color: var(--primary);
  box-shadow: 0 2px 12px rgba(26, 115, 232, 0.15);
}

.attn-card.highlight-card .attn-label {
  background: var(--primary);
  color: white;
}

@media (max-width: 768px) {
  .attn-comparison { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 480px) {
  .attn-comparison { grid-template-columns: 1fr 1fr; }
}

/* Results Table */
.results-table-wrapper { overflow-x: auto; }

.results-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  background: white;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.results-table th {
  background: var(--primary);
  color: white;
  padding: 12px 16px;
  text-align: left;
  font-weight: 600;
  white-space: nowrap;
}

.results-table td {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
}

.results-table tr:last-child td { border-bottom: none; }
.results-table tr:hover { background: #f0f4ff; }

.results-table .highlight {
  background: #e8f5e9;
  font-weight: 600;
}

.results-table .ours {
  background: #fff3e0;
  font-weight: 600;
}

/* Qualitative Results */
.qual-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 16px;
}

.qual-item {
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.qual-item img {
  width: 100%;
  display: block;
}

.qual-item .caption {
  padding: 8px 12px;
  font-size: 0.85rem;
  color: var(--text-secondary);
  background: white;
}

/* Dataset Examples */
.dataset-scene { margin-bottom: 24px; }

.instance-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 16px;
}

.instance-card {
  background: white;
  border-radius: 8px;
  overflow: hidden;
  border: 1.5px solid var(--border);
  cursor: pointer;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.instance-card:hover {
  border-color: var(--primary);
  box-shadow: 0 2px 12px rgba(26, 115, 232, 0.15);
}

.instance-card img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: contain;
  background: #0a0a1a;
  display: block;
}

.instance-captions {
  padding: 10px 14px 0;
  font-size: 0.8rem;
  color: var(--text-secondary);
  line-height: 1.55;
  position: relative;
  max-height: 90px;
  overflow: hidden;
  transition: max-height 0.4s ease, padding-bottom 0.4s ease;
}

/* Fade-out gradient at bottom */
.instance-captions::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 40px;
  background: linear-gradient(transparent, white);
  pointer-events: none;
  transition: opacity 0.3s;
}


.instance-captions strong {
  display: block;
  color: var(--text);
  margin-bottom: 6px;
  font-size: 0.9rem;
}

.instance-captions ol {
  margin: 0;
  padding-left: 18px;
}

.instance-captions li {
  margin-bottom: 4px;
  font-style: italic;
}

.instance-captions li:last-child { margin-bottom: 0; }

/* Image Modal */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 24px;
  cursor: pointer;
}

.modal-overlay.active { display: flex; }

.modal-content {
  display: flex;
  gap: 24px;
  max-width: 1100px;
  max-height: 90vh;
  width: 100%;
  cursor: default;
}

.modal-image {
  flex: 0 0 auto;
  max-width: 55%;
  max-height: 85vh;
  object-fit: contain;
  border-radius: 8px;
  background: #0a0a1a;
}

.modal-captions {
  flex: 1;
  color: var(--text);
  font-size: 0.9rem;
  line-height: 1.7;
  overflow-y: auto;
  background: white;
  border-radius: 8px;
  padding: 20px 24px;
}

.modal-captions strong {
  display: block;
  font-size: 1.2rem;
  color: var(--text);
  margin-bottom: 12px;
}

.modal-captions ol {
  padding-left: 20px;
  margin: 0;
}

.modal-captions li {
  margin-bottom: 10px;
  font-style: italic;
  color: var(--text-secondary);
}

.modal-close {
  position: fixed;
  top: 16px;
  right: 20px;
  color: white;
  font-size: 2rem;
  cursor: pointer;
  z-index: 1001;
  background: none;
  border: none;
  line-height: 1;
  opacity: 0.7;
  transition: opacity 0.2s;
}

.modal-close:hover { opacity: 1; }

@media (max-width: 768px) {
  .modal-content {
    flex-direction: column;
    align-items: center;
  }
  .modal-image {
    max-width: 100%;
    max-height: 50vh;
  }
}

/* BibTeX */
.bibtex-section { background: var(--bg-alt); }

.bibtex-block {
  position: relative;
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 20px;
  font-family: var(--mono);
  font-size: 0.85rem;
  line-height: 1.6;
  overflow-x: auto;
  white-space: pre;
}

.copy-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 6px 12px;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: white;
  color: var(--text);
  cursor: pointer;
  font-size: 0.8rem;
  font-family: var(--font);
}

.copy-btn:hover { background: var(--primary); color: white; border-color: var(--primary); }

/* Footer */
footer {
  text-align: center;
  padding: 40px 0;
  color: var(--text-secondary);
  font-size: 0.85rem;
  border-top: 1px solid var(--border);
}

/* Responsive */
@media (max-width: 768px) {
  h1 { font-size: 1.75rem; }
  h2 { font-size: 1.35rem; }
  .method-grid { grid-template-columns: 1fr; }
  .viewer-container { height: 400px; }
  .stats-bar { grid-template-columns: repeat(2, 1fr); }
  section { padding: 40px 0; }
  .hero { padding: 48px 0 40px; }
}

@media (max-width: 480px) {
  .stats-bar { grid-template-columns: 1fr; }
  .viewer-container { height: 320px; }
}
