/* ===================================================================
   Project page styles  (Mage-inspired, dependency-free structure)
   =================================================================== */

:root {
  /* slate palette */
  --fg: #1e293b;            /* ink        */
  --fg-soft: #64748b;       /* muted text */
  --fg-light: #94a3b8;      /* light text */
  --bg: #ffffff;
  --bg-alt: #f8fafc;        /* soft section bg */
  --accent: #0078d4;
  --accent-hover: #005fa3;
  --accent-soft: #e8f4fb;   /* light blue chip / ours row */
  --border: #e2e8f0;
  --border-card: #e5e9f0;
  --radius: 16px;
  --radius-sm: 10px;
  --maxw: 1180px;
  --maxw-narrow: 820px;
  --shadow: 0 10px 30px rgba(15, 23, 42, 0.06);
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06);
  --font: "Google Sans", "Noto Sans", -apple-system, BlinkMacSystemFont,
    "Segoe UI", Roboto, Helvetica, Arial, "PingFang SC", "Microsoft YaHei",
    sans-serif;
  --mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font);
  color: var(--fg);
  background: var(--bg);
  line-height: 1.65;
  font-size: 17px;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); text-decoration: underline; text-underline-offset: 3px; }

.container { width: min(var(--maxw), calc(100% - 48px)); margin: 0 auto; }
.container.narrow { max-width: var(--maxw-narrow); }

/* ---------------- Hero / header ---------------- */
.hero {
  padding: clamp(58px, 7vw, 90px) 0 44px;
  text-align: center;
  background: #fff;
  border-bottom: 1px solid var(--border);
}
.title {
  font-size: clamp(38px, 5vw, 62px);
  font-weight: 800;
  margin: 0 auto 14px;
  max-width: 1000px;
  line-height: 1.1;
  letter-spacing: -0.035em;
  text-wrap: balance;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.25em;
}
.title-logo {
  height: 1.1em;
  width: auto;
}
.subtitle {
  font-size: clamp(1.15rem, 2.4vw, 1.5rem);
  font-weight: 500;
  color: var(--fg-soft);
  margin: 0 auto 28px;
  max-width: 820px;
  line-height: 1.25;
}
.authors {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px 18px;
  font-size: 1.02rem;
  font-weight: 500;
  margin-bottom: 8px;
}
.authors .author a {
  color: var(--fg);
  border-bottom: 1px dotted #cbd5e1;
}
.authors .author a:hover {
  color: var(--accent);
  border-bottom-color: var(--accent);
  text-decoration: none;
}
.authors sup { position: relative; top: -0.25em; font-size: 0.68em; font-weight: 700; }
.affiliations {
  display: flex;
  flex-direction: column;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 4px;
  color: var(--fg-soft);
  font-size: 0.95rem;
  margin-bottom: 28px;
}
.affil-org {
  color: #111827;
  font-weight: 500;
}

/* ---------------- Link bar / buttons ---------------- */
.link-bar {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}
.btn {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--fg);
  color: #fff;
  padding: 9px 20px;
  border: 1px solid var(--fg);
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.95rem;
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s ease, background 0.2s ease, border-color 0.2s ease,
    box-shadow 0.2s ease;
}
.btn:hover {
  background: #0f172a;
  border-color: #0f172a;
  color: #fff;
  transform: translateY(-2px);
  box-shadow: var(--shadow);
  text-decoration: none;
}
.btn-icon { font-size: 1rem; line-height: 1; display: inline-flex; }

/* ---------------- Sections ---------------- */
.section { padding: clamp(56px, 7vw, 90px) 0; }
.section.alt {
  background: var(--bg-alt);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
.section h2 {
  font-size: clamp(31px, 4vw, 44px);
  font-weight: 800;
  text-align: center;
  letter-spacing: -0.028em;
  line-height: 1.12;
  text-wrap: balance;
  margin: 0 0 34px;
}
.subhead {
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 46px 0 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
.section-lead { color: var(--fg-soft); margin: 0 0 22px; }
.abstract-text { font-size: 1.05rem; color: #334155; }

/* ---------------- Metric strip (Mage-style) ---------------- */
.metrics-section { padding: clamp(28px, 4vw, 40px) 0; }
.metric-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  overflow: hidden;
  border: 1px solid var(--border-card);
  border-radius: var(--radius);
  background: var(--bg-alt);
  box-shadow: var(--shadow);
}
.metric { padding: 26px 12px; text-align: center; }
.metric + .metric { border-left: 1px solid var(--border); }
.metric strong {
  display: block;
  color: var(--fg);
  font-size: clamp(26px, 2.8vw, 38px);
  font-weight: 780;
  line-height: 1;
  letter-spacing: -0.03em;
}
.metric span {
  display: block;
  margin-top: 9px;
  color: var(--fg-soft);
  font-size: 0.8rem;
}
.metric-note {
  margin: 14px 0 0;
  color: var(--fg-light);
  font-size: 0.78rem;
  text-align: center;
}

/* ---------------- Highlight cards (kept for optional reuse) -------- */
.highlight-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 20px;
}
.highlight-card {
  background: #fff;
  border: 1px solid var(--border-card);
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
  box-shadow: var(--shadow);
}
.highlight-figure {
  margin-bottom: 14px;
  min-height: 90px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.highlight-figure img { max-width: 100%; border-radius: 8px; }
.highlight-number {
  font-size: 2.4rem;
  font-weight: 800;
  color: var(--accent);
  line-height: 1;
  letter-spacing: -0.03em;
  margin-bottom: 6px;
}
.highlight-card h3 { margin: 0 0 6px; font-size: 1.1rem; }
.highlight-card p { margin: 0; color: var(--fg-soft); font-size: 0.95rem; }

/* ---------------- Charts ---------------- */
.chart-head {
  font-size: 1.1rem;
  font-weight: 700;
  margin: 32px 0 14px;
  color: var(--fg-soft);
}
.chart-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 20px;
}
.chart { margin: 0; text-align: center; }
.chart img {
  max-width: 100%;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-card);
  box-shadow: var(--shadow);
}
.chart figcaption { color: var(--fg-soft); font-size: 0.9rem; margin-top: 10px; }
.wide-figure { margin: 0 0 12px; text-align: center; }
.wide-figure img {
  max-width: 100%;
  border-radius: var(--radius);
  border: 1px solid var(--border-card);
  box-shadow: var(--shadow);
}
.wide-figure figcaption { color: var(--fg-soft); font-size: 0.92rem; margin-top: 12px; }

/* ---------------- Placeholders ---------------- */
.chart-ph {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 150px;
  background: repeating-linear-gradient(45deg, #f1f5f9, #f1f5f9 10px, #e9eef4 10px, #e9eef4 20px);
  border: 1px dashed #cbd5e1;
  border-radius: var(--radius-sm);
}
.chart-ph.tall { min-height: 240px; }
.placeholder-tag {
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--fg-soft);
  background: rgba(255, 255, 255, 0.8);
  padding: 3px 8px;
  border-radius: 6px;
}

/* ---------------- Case gallery ---------------- */
.gallery { display: flex; flex-direction: column; gap: 28px; }

.case-card {
  background: #fff;
  border: 1px solid var(--border-card);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}
.case-meta { margin-bottom: 14px; }
.case-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}
.case-tag {
  display: inline-block;
  background: var(--bg-alt);
  color: var(--fg-soft);
  border: 1px solid var(--border);
  font-size: 0.76rem;
  font-weight: 700;
  padding: 3px 11px;
  border-radius: 999px;
}
.case-tag.primary {
  background: var(--accent-soft);
  color: var(--accent-hover);
  border-color: transparent;
}
.case-instruction {
  font-size: 1.05rem;
  font-weight: 600;
}
.case-instruction .instr-label { color: var(--fg-soft); font-weight: 600; }
.instr-list {
  margin: 6px 0 0;
  padding-left: 22px;
  font-size: 1.02rem;
  font-weight: 600;
}
.instr-list li { margin-bottom: 3px; }
.instr-list li::marker { color: var(--accent); font-weight: 700; }
.case-note { color: var(--fg-soft); font-size: 0.92rem; margin-top: 4px; }

/* 4-up grid variant — compact cards in a 4-column grid (Part 1 overview) */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}
.gallery-grid .case-card {
  display: flex;
  flex-direction: column;
  padding: 12px;
}
/* push the video to the bottom so cards in the same row line up */
.gallery-grid .case-card > .video-slider,
.gallery-grid .case-card > .media-row { margin-top: auto; }
.gallery-grid .case-meta { margin-bottom: 8px; }
.gallery-grid .case-tags { gap: 4px; margin-bottom: 6px; }
.gallery-grid .case-tag { font-size: 0.66rem; padding: 2px 7px; }
.gallery-grid .case-instruction { font-size: 0.82rem; }
.gallery-grid .instr-list { margin: 4px 0 0; padding-left: 16px; font-size: 0.8rem; }
.gallery-grid .case-note { font-size: 0.76rem; }

/* side-by-side media grid; columns auto-fit to number of items */
.media-row {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(var(--cols, 2), 1fr);
}
.media-col { text-align: center; }
.media-col .media-label {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--fg-soft);
  margin-bottom: 6px;
}
.media-col.highlight-col .media-label { color: var(--accent); }
.media-col video,
.media-col img {
  width: 100%;
  border-radius: var(--radius-sm);
  background: #000;
  display: block;
}
.media-col.highlight-col video,
.media-col.highlight-col img {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
}

/* ---------------- Comparison slider (before/after) ---------------- */
.video-slider {
  position: relative;
  width: 100%;
  overflow: hidden;
  border-radius: var(--radius-sm);
  background: #000;
  cursor: crosshair;
  line-height: 0;               /* kill inline-video whitespace */
  transform: translateZ(0);     /* own compositing layer */
}
/* `before` sits in normal flow and defines the container height */
.video-slider .video-before {
  display: block;
  width: 100%;
  height: auto;
}
/* `after` overlays and is revealed via clip-path */
.video-slider .video-after {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  clip-path: inset(0 0 0 50%);
  transition: clip-path 0.12s ease-out;
  will-change: clip-path;
}
.slider-handle {
  position: absolute;
  top: 0;
  left: 50%;
  width: 2px;
  height: 100%;
  margin-left: -1px;
  background: var(--accent);
  box-shadow: 0 0 8px rgba(0, 120, 212, 0.6);
  z-index: 10;
  transition: left 0.12s ease-out;
  will-change: left;
  pointer-events: none;
}
.slider-handle::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 14px;
  height: 14px;
  background: #fff;
  border: 2px solid var(--accent);
  border-radius: 50%;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}
/* while dragging/hovering, react instantly (no lag from transition) */
.video-slider.is-active .video-after { transition: none; }
.video-slider.is-active .slider-handle { transition: none; }
/* corner labels */
.slider-label {
  position: absolute;
  bottom: 8px;
  z-index: 11;
  font-size: 0.78rem;
  font-weight: 600;
  color: #fff;
  background: rgba(15, 23, 42, 0.6);
  padding: 2px 8px;
  border-radius: 6px;
  line-height: 1.4;
  pointer-events: none;
}
.slider-label.before { left: 8px; }
.slider-label.after { right: 8px; }

/* ─── Zoom button on slider ─── */
.slider-zoom-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 12;
  width: 30px;
  height: 30px;
  border: none;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.15s ease, background 0.15s ease;
}
.video-slider:hover .slider-zoom-btn { opacity: 1; }
.slider-zoom-btn:hover { background: rgba(0, 0, 0, 0.8); }

/* ─── Modal: enlarged slider view ─── */
.video-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0, 0, 0, 0.95);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.modal-slider-wrap {
  position: relative;
  width: min(90vw, 1280px);
  max-height: 90vh;
}
.modal-slider-wrap .video-slider {
  border-radius: 8px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
}
.modal-close-btn {
  position: fixed;
  top: 20px;
  right: 24px;
  z-index: 1001;
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease;
}
.modal-close-btn:hover { background: rgba(255, 255, 255, 0.3); }

/* checklist (bench cases) */
.checklist { margin: 14px 0 0; padding-left: 20px; }
.checklist li { font-size: 0.94rem; color: #475569; }

/* responsive: stack media on narrow screens */
@media (max-width: 1024px) {
  .gallery-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 640px) {
  .gallery-grid { grid-template-columns: 1fr; }
  .media-row { grid-template-columns: 1fr !important; }
  .title { font-size: 2rem; }
}

/* ---------------- Metrics table ---------------- */
.metrics-table { overflow-x: auto; }
table.metrics {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
  background: #fff;
  border: 1px solid var(--border-card);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}
table.metrics th,
table.metrics td {
  padding: 11px 16px;
  border-bottom: 1px solid var(--border);
}
table.metrics td { text-align: center; }
table.metrics th { text-align: center; }
table.metrics th {
  background: var(--bg-alt);
  color: var(--fg-soft);
  font-weight: 650;
  font-size: 0.82rem;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
table.metrics thead tr:first-child th:first-child,
table.metrics td:first-child { text-align: left; }
table.metrics tbody tr:last-child td { border-bottom: 0; }
table.metrics td.method-name { text-align: left; font-weight: 400; }
table.metrics tr.is-ours { background: var(--accent-soft); }
table.metrics tr.is-ours td { color: var(--accent-hover); }
table.metrics td.best { font-weight: 990; }
table.metrics tr.is-baseline td { border-bottom: 2px solid var(--fg); }
table.metrics th.group-start,
table.metrics td.group-start { border-left: 2px solid var(--border-card); }
table.metrics.metrics-grouped thead tr:first-child th:first-child { border-right: 2px solid var(--border-card); }

/* ---------------- BibTeX ---------------- */
.bibtex {
  background: #0f172a;
  color: #e6e9ee;
  padding: 22px;
  border-radius: var(--radius);
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 0.88rem;
  line-height: 1.55;
  box-shadow: var(--shadow);
}

/* ---------------- Footer ---------------- */
.footer {
  padding: 30px 0;
  text-align: center;
  color: var(--fg-light);
  font-size: 0.9rem;
  border-top: 1px solid var(--border);
}
.footer a { color: var(--fg-soft); }

/* ---------------- Loading / error states ---------------- */
.gallery-status {
  color: var(--fg-soft);
  font-size: 0.92rem;
  padding: 16px;
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  text-align: center;
}

/* ---------------- Responsive: metric strip ---------------- */
@media (max-width: 680px) {
  .metric-strip { grid-template-columns: repeat(2, 1fr); }
  .metric:nth-child(odd) { border-left: 0; }
  .metric:nth-child(even) { border-left: 1px solid var(--border); }
  .metric:nth-child(n + 3) { border-top: 1px solid var(--border); }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}
