/* ============================================================
   Macro Dataset – Shared Stylesheet
   ============================================================ */

/* ---------- CSS Variables ---------- */
:root {
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --secondary: #6366f1;
  --accent: #f59e0b;
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-2: #f1f5f9;
  --border: #e2e8f0;
  --text: #1e293b;
  --text-muted: #64748b;
  --text-light: #94a3b8;
  --radius: 12px;
  --radius-sm: 6px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 4px 16px rgba(0,0,0,.06);
  --shadow-lg: 0 8px 32px rgba(0,0,0,.12);
  --transition: 0.2s ease;

  /* Task colours */
  --customization: #7c3aed;
  --illustration: #059669;
  --spatial: #d97706;
  --temporal: #dc2626;
}

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

html { scroll-behavior: smooth; font-size: 16px; }

body {
  font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}

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

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

/* ---------- Layout ---------- */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
}

section { padding: 64px 0; }
section:nth-child(even) { background: var(--surface); }

.section-title {
  font-size: 2rem;
  font-weight: 700;
  text-align: center;
  margin-bottom: 40px;
  color: var(--text);
}

.section-title span {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ---------- Navbar / Tab Bar ---------- */
.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(255,255,255,.95);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 0;
}

.navbar-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
  gap: 8px;
  height: 56px;
}

.navbar-brand {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--primary);
  margin-right: auto;
  white-space: nowrap;
}

.nav-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 16px;
  border-radius: 20px;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-muted);
  transition: all var(--transition);
  cursor: pointer;
  border: none;
  background: none;
}

.nav-tab:hover,
.nav-tab.active {
  background: var(--primary);
  color: #fff;
  text-decoration: none;
}

/* ---------- Hero / Paper Header ---------- */
.hero {
  background: linear-gradient(160deg, #eff6ff 0%, #f0fdf4 50%, #fefce8 100%);
  padding: 80px 0 60px;
  text-align: center;
}

.paper-title {
  font-size: clamp(1.8rem, 4vw, 3rem);
  font-weight: 800;
  line-height: 1.2;
  margin-bottom: 24px;
  color: var(--text);
}

.paper-title em {
  font-style: normal;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

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

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

/* ---------- Link Buttons ---------- */
.link-buttons {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  margin-top: 24px;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  border: 2px solid transparent;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); text-decoration: none; color:#fff; }

.btn-outline {
  background: transparent;
  color: var(--primary);
  border-color: var(--primary);
}
.btn-outline:hover { background: var(--primary); color: #fff; text-decoration: none; }

.btn-dark {
  background: #1e293b;
  color: #fff;
  border-color: #1e293b;
}
.btn-dark:hover { background: #334155; text-decoration: none; color:#fff; }

.btn-amber {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.btn-amber:hover { background: #d97706; text-decoration: none; color:#fff; }

/* ---------- Abstract ---------- */
.abstract-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px;
  box-shadow: var(--shadow);
  max-width: 900px;
  margin: 0 auto;
}

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

/* ---------- Manual Carousel (slide-based) ---------- */
.carousel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.carousel-header h3 {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text);
}

.manual-carousel {
  position: relative;
  border-radius: var(--radius);
  background: var(--surface-2);
  overflow: visible;
  padding: 0 48px;
  margin: 0 -48px;
}

.mc-viewport {
  overflow: hidden;
  border-radius: var(--radius);
}

.mc-track {
  display: flex;
  transition: transform 0.45s cubic-bezier(0.4, 0, 0.2, 1);
}

.mc-slide {
  flex: 0 0 100%;
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

.mc-slide img {
  width: 100%;
  height: auto;
  max-height: 560px;
  object-fit: contain;
  background: #f8fafc;
  cursor: zoom-in;
  display: block;
}

.mc-caption {
  padding: 14px 20px;
  font-size: 0.88rem;
  color: var(--text-muted);
  line-height: 1.5;
  background: var(--surface);
}

.mc-prev,
.mc-next {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  cursor: pointer;
  font-size: 1.4rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
  transition: all var(--transition);
  z-index: 10;
  padding: 0;
}

.mc-prev { left: 4px; }
.mc-next { right: 4px; }

.mc-prev:hover,
.mc-next:hover {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.mc-dots {
  display: flex;
  justify-content: center;
  gap: 8px;
  padding: 12px 0 4px;
}

.mc-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--border);
  border: none;
  cursor: pointer;
  transition: all var(--transition);
  padding: 0;
}

.mc-dot.active {
  background: var(--primary);
  width: 24px;
  border-radius: 4px;
}

/* Autoplay pause button */
.mc-autoplay-btn {
  padding: 6px 16px;
  border-radius: 20px;
  border: 1.5px solid var(--primary);
  background: var(--primary);
  color: #fff;
  font-size: 0.83rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}

.mc-autoplay-btn:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
}

.mc-autoplay-btn.paused {
  background: var(--surface);
  color: var(--primary);
  border-color: var(--primary);
}

.mc-autoplay-btn.paused:hover {
  background: var(--primary);
  color: #fff;
}

/* ---------- Statistics – full width ---------- */
.stats-block {
  display: flex;
  flex-direction: column;
  gap: 28px;
  align-items: center;
}

.stats-img-full {
  width: 100%;
  max-width: 960px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  cursor: zoom-in;
}

.stats-desc-full {
  width: 100%;
  max-width: 960px;
  font-size: 0.95rem;
  line-height: 1.8;
  color: var(--text);
}

.stats-desc-full h3 {
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 16px;
}

/* ---------- Task Tags ---------- */
.tag {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #fff;
}

.tag-customization { background: var(--customization); }
.tag-illustration   { background: var(--illustration); }
.tag-spatial        { background: var(--spatial); }
.tag-temporal       { background: var(--temporal); }

/* ---------- Pipeline Slider (manual, wide) ---------- */
.pipeline-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.pipeline-tab {
  padding: 8px 20px;
  border-radius: 20px;
  border: 2px solid var(--border);
  background: var(--surface);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  color: var(--text-muted);
}

.pipeline-tab:hover { border-color: var(--primary); color: var(--primary); }
.pipeline-tab.active { background: var(--primary); color: #fff; border-color: var(--primary); }

.pipeline-panel {
  display: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  box-shadow: var(--shadow);
  /* allow horizontal expansion */
  width: 100%;
}

/* Horizontal layout: illustration / spatial */
.pipeline-panel.active { display: flex; gap: 32px; align-items: flex-start; flex-wrap: wrap; }

.pipeline-panel img {
  flex: 0 0 auto;
  height: 320px;
  width: auto;
  max-width: 100%;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  object-fit: contain;
  cursor: zoom-in;
}

/* Vertical layout: customization / temporal */
.pipeline-panel.pipeline-vertical.active {
  flex-direction: column;
  align-items: stretch;
}

.pipeline-panel.pipeline-vertical img {
  width: 100%;
  height: 320px;   /* same fixed height as horizontal panels */
  object-fit: contain;
  flex: 0 0 auto;
}

.pipeline-desc {
  flex: 1 1 300px;
  font-size: 0.95rem;
  line-height: 1.8;
  color: var(--text);
}

.pipeline-desc strong {
  display: block;
  font-size: 1.1rem;
  margin-bottom: 12px;
  color: var(--text);
}

/* ---------- Main Table Image ---------- */
.maintab-wrap {
  text-align: center;
}

.maintab-img {
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  cursor: zoom-in;
}

/* ---------- Ablation Accordion – centered content ---------- */
.accordion {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}

.accordion-header {
  width: 100%;
  background: var(--surface);
  padding: 18px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  color: var(--text);
  transition: background var(--transition);
}

.accordion-header:hover { background: var(--surface-2); }

.accordion-arrow {
  width: 20px;
  height: 20px;
  transition: transform 0.3s ease;
  color: var(--text-muted);
}

.accordion.open .accordion-arrow { transform: rotate(180deg); }

.accordion-body {
  display: none;
  padding: 32px 24px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

.accordion.open .accordion-body { display: flex; }

.accordion-body img {
  width: 100%;
  max-width: 720px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  cursor: zoom-in;
}

.accordion-body p {
  width: 100%;
  max-width: 720px;
  font-size: 0.95rem;
  line-height: 1.8;
  color: var(--text);
  text-align: center;
}

/* ---------- BibTeX ---------- */
.bibtex-box {
  background: #1e293b;
  color: #e2e8f0;
  border-radius: var(--radius);
  padding: 32px;
  position: relative;
  font-family: 'JetBrains Mono', 'Fira Code', 'Courier New', monospace;
  font-size: 0.85rem;
  line-height: 1.8;
  overflow-x: auto;
  white-space: pre;
}

.bibtex-copy {
  position: absolute;
  top: 12px;
  right: 12px;
  padding: 6px 14px;
  background: rgba(255,255,255,.1);
  border: 1px solid rgba(255,255,255,.2);
  border-radius: var(--radius-sm);
  color: #e2e8f0;
  font-size: 0.8rem;
  cursor: pointer;
  transition: background var(--transition);
}

.bibtex-copy:hover { background: rgba(255,255,255,.2); }

/* ---------- Gallery Pages ---------- */
.gallery-header {
  padding: 48px 0 32px;
  text-align: center;
  background: linear-gradient(160deg, #eff6ff 0%, #f0fdf4 100%);
  border-bottom: 1px solid var(--border);
}

.gallery-title {
  font-size: 2rem;
  font-weight: 800;
  margin-bottom: 8px;
}

.gallery-subtitle {
  font-size: 1rem;
  color: var(--text-muted);
  margin-bottom: 24px;
}

/* Filter bar */
.filter-bar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 16px 0;
  position: sticky;
  top: 56px;
  z-index: 90;
}

.filter-bar-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.filter-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
}

.filter-group {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.filter-chip {
  padding: 5px 14px;
  border-radius: 20px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  color: var(--text-muted);
  user-select: none;
}

.filter-chip:hover { border-color: var(--primary); color: var(--primary); }
.filter-chip.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.filter-chip.active-customization { background: var(--customization); border-color: var(--customization); color:#fff; }
.filter-chip.active-illustration  { background: var(--illustration);  border-color: var(--illustration);  color:#fff; }
.filter-chip.active-spatial       { background: var(--spatial);       border-color: var(--spatial);       color:#fff; }
.filter-chip.active-temporal      { background: var(--temporal);      border-color: var(--temporal);      color:#fff; }

/* Model checkbox bar (case gallery) */
.model-toggles {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.model-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 20px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  color: var(--text-muted);
  user-select: none;
}

.model-toggle.checked {
  background: #1e293b;
  color: #fff;
  border-color: #1e293b;
}

.model-toggle input[type=checkbox] { display: none; }

/* Sample card */
.sample-grid {
  display: flex;
  flex-direction: column;
  gap: 32px;
  padding: 32px 0;
}

.sample-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.sample-card-header {
  padding: 12px 20px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}

.sample-card-header .sample-id {
  font-size: 0.8rem;
  color: var(--text-light);
  font-family: monospace;
}

.sample-card-body { padding: 20px; }

/* Image rows – gallery images fixed 256px height */
.img-row {
  display: flex;
  gap: 8px;
  flex-wrap: nowrap;
  overflow-x: auto;
  padding-bottom: 8px;
  scrollbar-width: thin;
}

.img-row-scroll {
  display: flex;
  gap: 8px;
  flex-wrap: nowrap;
  overflow-x: auto;
  padding-bottom: 8px;
}

.img-cell {
  flex: 0 0 auto;
  text-align: center;
}

.img-cell img {
  height: 200px;
  width: auto;
  object-fit: contain;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
  cursor: zoom-in;
  transition: box-shadow var(--transition);
}

.img-cell img:hover {
  box-shadow: 0 4px 16px rgba(37,99,235,.2);
}

.img-cell .img-label {
  font-size: 0.73rem;
  color: var(--text-muted);
  margin-top: 4px;
  text-align: center;
}

.prompt-text {
  font-size: 0.9rem;
  color: var(--text);
  line-height: 1.6;
  margin: 12px 0;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  border-left: 3px solid var(--primary);
}

.section-divider {
  border: none;
  border-top: 1px dashed var(--border);
  margin: 16px 0;
}

/* Case gallery: flat output grid (no group row separator) */
.output-flat-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 8px;
}

.output-flat-cell {
  flex: 0 0 auto;
  text-align: center;
}

.output-flat-cell img {
  height: 200px;
  width: auto;
  object-fit: contain;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
  cursor: zoom-in;
  transition: box-shadow var(--transition);
}

.output-flat-cell img:hover {
  box-shadow: 0 4px 16px rgba(37,99,235,.2);
}

.output-flat-cell .model-badge {
  font-size: 0.73rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-top: 4px;
  text-align: center;
  padding: 2px 8px;
  background: var(--surface-2);
  border-radius: 4px;
  display: inline-block;
  white-space: nowrap;
}

/* Highlight ours */
.output-flat-cell.ours img {
  border: 2px solid var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.output-flat-cell.ours .model-badge {
  background: var(--primary);
  color: #fff;
}

/* GT cell */
.output-flat-cell.gt img {
  border: 2px solid #059669;
}
.output-flat-cell.gt .model-badge {
  background: #059669;
  color: #fff;
}

/* ---------- Lightbox ---------- */
.lightbox {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.88);
  z-index: 9999;
  align-items: center;
  justify-content: center;
  padding: 24px;
  cursor: zoom-out;
}

.lightbox.open {
  display: flex;
}

.lightbox img {
  max-width: 95vw;
  max-height: 90vh;
  object-fit: contain;
  border-radius: var(--radius);
  box-shadow: 0 24px 80px rgba(0,0,0,.5);
  cursor: default;
}

.lightbox-close {
  position: fixed;
  top: 20px;
  right: 24px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255,255,255,.15);
  border: 1px solid rgba(255,255,255,.3);
  color: #fff;
  font-size: 1.1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition);
  z-index: 10000;
}

.lightbox-close:hover { background: rgba(255,255,255,.3); }

/* ---------- Footer ---------- */
footer {
  background: #1e293b;
  color: #94a3b8;
  text-align: center;
  padding: 32px 24px;
  font-size: 0.85rem;
  line-height: 1.8;
}

footer a { color: #93c5fd; }

/* ---------- Loading / empty states ---------- */
.loading-spinner {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 200px;
  color: var(--text-muted);
  gap: 10px;
  font-size: 0.9rem;
}

.spinner {
  width: 24px;
  height: 24px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
  font-size: 0.95rem;
}

/* ---------- Back-to-top ---------- */
.back-to-top {
  position: fixed;
  bottom: 28px;
  right: 28px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-lg);
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition);
  border: none;
  font-size: 1.1rem;
}

.back-to-top.visible { opacity: 1; pointer-events: auto; }

/* ---------- Responsive ---------- */
@media (max-width: 768px) {
  .paper-title { font-size: 1.6rem; }
  .abstract-box { padding: 24px; }
  .pipeline-panel.active { flex-direction: column; }
  .pipeline-panel img { height: auto; width: 100%; max-height: 320px; object-fit: contain; }
  .accordion-body { flex-direction: column; }
  .navbar-brand { font-size: 0.95rem; }
  .manual-carousel { margin: 0; padding: 0 40px; }
  .mc-prev { left: 0; }
  .mc-next { right: 0; }
}
