:root {
  color-scheme: light dark;
  --bg: #ffffff;
  --text: #1d1d1f;
  --soft: #555555;
  --muted: #6b7280;
  --faint: #9aa0a6;
  --line: #e8e8ec;
  --surface: #f1f3f5;
  --surface-hover: #e2e6ea;
  --code-bg: #f6f8fa;
  --vid-bg: #f4f4f6;
  --topo: #0a7d3c;
  --accent: #0a58ca;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  font-family: -apple-system, system-ui, "Helvetica Neue", sans-serif;
  max-width: 900px;
  margin: 0 auto;
  padding: 2rem 1rem 4rem;
  background: var(--bg);
  color: var(--text);
  line-height: 1.65;
}
header {
  text-align: center;
  padding: 1.5rem 0 2.2rem;
  border-bottom: 1px solid var(--line);
  margin-bottom: 2rem;
}
header h1 {
  font-size: clamp(2rem, 4.4vw, 2.9rem);
  font-weight: 800;
  margin: 0 auto .7rem;
  max-width: 18em;
  line-height: 1.18;
  letter-spacing: -0.02em;
}
.authors { color: var(--soft); margin: .2rem 0; }
.venue   { color: var(--muted); font-size: .9rem; margin: .2rem 0; }
.keywords { color: var(--muted); font-size: .85rem; margin: .4rem 0 .8rem; font-style: italic; }
.caption { color: var(--muted); font-size: .9rem; margin-top: .35rem; }
.section-intro { color: var(--muted); font-size: .95rem; margin: .2rem 0 .9rem; }
.muted { color: var(--faint); }
.topo { color: var(--topo); font-weight: 700; }

.links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: .55rem;
  margin: 1rem 0 0;
}
.pill {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .45rem 1rem;
  background: var(--surface);
  color: var(--text);
  font-size: .9rem;
  font-weight: 500;
  text-decoration: none;
  border-radius: 999px;
  transition: background .15s, color .15s;
}
.pill svg { display: block; }
.pill:hover { background: var(--surface-hover); }

section { margin: 2.2rem 0; }
section h2 {
  font-size: 1.2rem;
  border-left: 3px solid var(--topo);
  padding-left: .6rem;
  margin-bottom: .8rem;
}
section > img {
  width: 100%;
  height: auto;
  display: block;
  margin: .5rem 0 1rem;
  border-radius: 4px;
}

/* ---- Hero ---- */
.hero { margin: 0 0 2rem; }
.hero video {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: #000;
}
.hero .caption { text-align: center; }

/* ---- Video figures & grids ---- */
.grid { display: grid; gap: .8rem; margin: .9rem 0 .3rem; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

figure.vid { margin: 0; }
figure.vid video {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 5px;
  border: 1px solid var(--line);
  background: var(--vid-bg);
}
figure.vid figcaption {
  color: var(--muted);
  font-size: .82rem;
  margin-top: .35rem;
  line-height: 1.4;
}
figure.vid.wide video { border-radius: 6px; }
figure.vid.wide figcaption { text-align: center; }

.steps .step-no {
  display: inline-block;
  color: var(--topo);
  font-weight: 700;
  margin-right: .3rem;
}

/* comparison rows */
.cmp-title {
  font-size: .95rem;
  font-weight: 600;
  color: var(--soft);
  margin: 1.2rem 0 .1rem;
}
figure.vid .tag {
  display: block;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .03em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: .3rem;
}
.cmp figure.vid .tag { line-height: 1.25; }
/* Keep videos row-aligned when labels of different lengths wrap (mobile
   staircase fix): let each figure span a tag-row + video-row via subgrid,
   so tags share one row height and videos share another across columns. */
@supports (grid-template-rows: subgrid) {
  .cmp.grid { grid-auto-rows: min-content; }
  .cmp figure.vid {
    grid-row: span 2;
    display: grid;
    grid-template-rows: subgrid;
    row-gap: 0; /* tag->video spacing comes from tag margin, not the grid gap */
  }
}
/* Fallback for browsers without subgrid: reserve a 2-line tag height. */
@supports not (grid-template-rows: subgrid) {
  .cmp figure.vid .tag { min-height: 2.5em; }
}
/* 2x2 finger-opposition grid: gentler hover zoom (half width) */
@media (hover: hover) {
  .cmp-2x2 figure.vid.zoomable:hover video { transform: scale(1.6); }
}
figure.vid .tag.best { color: var(--topo); }
figure.vid .tag.ref  { color: var(--accent); }

/* hover-to-zoom for small comparison clips */
@media (hover: hover) {
  figure.vid.zoomable { cursor: zoom-in; }
  figure.vid.zoomable video {
    transition: transform .2s ease, box-shadow .2s ease;
  }
  figure.vid.zoomable:hover { position: relative; z-index: 30; }
  figure.vid.zoomable:hover video {
    transform: scale(2.1);
    box-shadow: 0 10px 30px rgba(0, 0, 0, .32);
    border-color: rgba(0, 0, 0, .15);
  }
  /* half-width clips (2x2 cube grid) need a gentler zoom */
  .cubes figure.vid.zoomable:hover video { transform: scale(1.7); }
}

/* ---- Stats strip ---- */
.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 1.1rem 0;
}
.stat { text-align: center; padding: 0 .6rem; }
.stat + .stat { border-left: 1px solid var(--line); }
.stat-num {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.1;
}
.stat-num .unit { font-size: .95rem; font-weight: 600; margin-left: .12rem; color: #555; }
.stat-label { font-size: .8rem; color: var(--muted); margin-top: .25rem; }

/* expandable */
.more { margin-top: 1rem; }
.more summary {
  cursor: pointer;
  font-size: .9rem;
  font-weight: 600;
  color: var(--soft);
  padding: .3rem 0;
}
.top-gap { margin-top: 1rem; }

/* ---- Zoom loupe (figures) ---- */
.zoom { position: relative; cursor: crosshair; border-radius: 4px; margin: .5rem 0 1rem; }
.zoom img { display: block; width: 100%; height: auto; margin: 0; border-radius: 4px; }
.loupe {
  position: absolute;
  width: 220px; height: 220px;
  border: 2px solid #fff;
  border-radius: 6px;
  box-shadow: 0 4px 14px rgba(0,0,0,.25);
  background-color: #fff;
  background-repeat: no-repeat;
  pointer-events: none;
  opacity: 0;
  transition: opacity .12s;
  z-index: 5;
}
.zoom-hint {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  background: #f1f3f5;
  color: #555;
  font-size: .7rem;
  font-weight: 600;
  letter-spacing: .05em;
  padding: .25rem .55rem;
  border-radius: 999px;
  margin-left: .6rem;
  vertical-align: middle;
}
.zoom-hint::before { content: "\1F50D"; }

/* ---- BibTeX ---- */
pre {
  background: var(--code-bg);
  padding: 1rem;
  border-radius: 4px;
  overflow-x: auto;
  font-size: .85rem;
  margin: 0;
}
.code-block { position: relative; }
.copy-btn {
  position: absolute;
  top: .55rem; right: .55rem;
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  padding: .3rem .65rem;
  background: #fff;
  color: #555;
  border: 1px solid #d6d9dc;
  border-radius: 4px;
  font-size: .75rem;
  font-family: inherit;
  cursor: pointer;
  transition: background .12s, color .12s, border-color .12s;
}
.copy-btn:hover { background: #f1f3f5; color: #000; }
.copy-btn.copied { background: #2ea043; color: #fff; border-color: #2ea043; }

footer {
  text-align: center;
  font-size: .8rem;
  color: #999;
  margin-top: 3rem;
  border-top: 1px solid var(--line);
  padding-top: 1rem;
}

/* ---- Responsive ---- */
@media (max-width: 760px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 480px) {
  .grid-2, .grid-4 { grid-template-columns: 1fr 1fr; }
  .loupe { display: none; }
}

/* ---- Dark mode (auto, follows system/browser) ---- */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --text: #e7e8ea;
    --soft: #b6b9c0;
    --muted: #9aa0ab;
    --faint: #7b8089;
    --line: #2a2e36;
    --surface: #1b1f27;
    --surface-hover: #262b35;
    --code-bg: #161a21;
    --vid-bg: #161a21;
    --topo: #3ecf7e;
    --accent: #6ea8ff;
  }
  .copy-btn { background: var(--surface); color: var(--soft); border-color: var(--line); }
  .copy-btn:hover { background: var(--surface-hover); color: var(--text); }
  .zoom-hint { background: var(--surface); color: var(--soft); }
  .loupe { border-color: var(--line); background-color: var(--vid-bg); box-shadow: 0 4px 14px rgba(0,0,0,.6); }
}
