/* Apple-style full-screen slides. Each <section class="slide"> is one screen and
   one scroll-snap point; its content is a 40/60 split of text and media. */

:root {
  --white: #fff;
  --gray: #f5f5f7;
  --black: #000;
  --text: #1d1d1f;
  --text-secondary: #6e6e73;
  --blue: #0071e3;
  --link: #0066cc;
  --link-dark: #2997ff;

  --nav-h: 58px;
  --media-h: calc(100svh - var(--nav-h) - 6vh);

  /* behavior colors from the teaser, fixed order: Bite, Chase, Lead, Peck, Quiver, Tilt */
  --c1: #2a78d6;
  --c2: #eb6834;
  --c3: #1baf7a;
  --c4: #eda100;
  --c5: #e87ba4;
  --c6: #008300;
  --ease: cubic-bezier(0.28, 0.11, 0.32, 1);

  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

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

html {
  scroll-snap-type: y mandatory;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

/* Desktop with mouse/trackpad: page.js drives every slide change itself
   (wheel, keys, links), so native scrolling and snapping are turned off. */
html.is-paged {
  overflow: hidden;
  scroll-snap-type: none;
  scroll-behavior: auto;
}

body {
  margin: 0;
  background: var(--black);
  color: var(--text);
  font-size: 20px;
  line-height: 1.47;
  letter-spacing: -0.022em;
}

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

a {
  color: var(--link);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 3px;
}

/* ---------- Global nav: translucent bar that follows the active slide's theme ---------- */

.globalnav {
  position: fixed;
  inset: 0 0 auto;
  z-index: 10;
  height: var(--nav-h);
  background: rgba(255, 255, 255, 0.72);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
  transition: background-color 0.5s var(--ease), border-color 0.5s var(--ease);
}

.globalnav-inner {
  max-width: 1536px;
  height: 100%;
  margin: 0 auto;
  padding: 0 clamp(19px, 4.8vw, 58px);
  display: flex;
  align-items: center;
  gap: 29px;
}

.globalnav-brand {
  color: var(--text);
  font-size: 23px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.globalnav-brand:hover {
  text-decoration: none;
}

.globalnav-links {
  display: flex;
  gap: clamp(19px, 2.88vw, 38px);
  margin: 0 auto;
  padding: 0;
  list-style: none;
}

.globalnav-links a {
  color: var(--text);
  font-size: 14px;
  letter-spacing: -0.01em;
  opacity: 0.8;
  transition: opacity 0.2s;
}

.globalnav-links a:hover,
.globalnav-links a[aria-current="true"] {
  opacity: 1;
  text-decoration: none;
}

.globalnav-links a[aria-current="true"] {
  font-weight: 600;
}

.globalnav[data-theme="dark"] {
  background: rgba(22, 22, 23, 0.8);
  border-bottom-color: rgba(255, 255, 255, 0.08);
}

.globalnav[data-theme="dark"] .globalnav-brand,
.globalnav[data-theme="dark"] .globalnav-links a {
  color: #f5f5f7;
}

/* ---------- Slides ---------- */

.slide {
  position: relative;
  height: 100vh;
  height: 100svh;
  scroll-snap-align: start;
  scroll-snap-stop: always;
  display: flex;
  align-items: center;
  overflow: hidden;
  padding: calc(var(--nav-h) + 2vh) clamp(20px, 3.5vw, 64px) 2vh;
}

.theme-light { background: var(--white); color: var(--text); }
.theme-gray  { background: var(--gray);  color: var(--text); }
.theme-dark  { background: var(--black); color: #f5f5f7; --text-secondary: #86868b; --link: var(--link-dark); }

.slide-inner {
  width: 100%;
  max-width: 1536px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 4fr 6fr;
  align-items: center;
  gap: clamp(32px, 4vw, 72px);
}

/* let wide children (the results table) scroll instead of stretching the column */
.slide-inner > * {
  min-width: 0;
}

.copy {
  max-width: 40.8rem;
}

.media {
  margin: 0;
  display: flex;
  justify-content: center;
}

.media img {
  width: 100%;
  height: auto;   /* not the height attribute, which only reserves the aspect ratio */
  max-height: var(--media-h);
  object-fit: contain;
}

/* ---------- Type ---------- */

h1,
h2 {
  margin: 0 0 24px;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Inter", "Helvetica Neue", Arial, sans-serif;
  font-weight: 600;
  letter-spacing: -0.015em;
  text-wrap: balance;
}

/* the title slide holds the most text, so it also scales with screen height
   to stay on one screen on short laptops */
h1 {
  font-size: clamp(32px, min(4.2vw, 6.4vh), 68px);
  line-height: 1.08;
}

/* the left column is narrow, so the long teaser headlines run a size smaller */
h2 {
  font-size: clamp(30px, min(3.3vw, 5.2vh), 52px);
  line-height: 1.1;
}

.headline-number {
  margin: 0 0 12px;
  color: var(--blue);
  font-size: clamp(64px, min(7.5vw, 13vh), 120px);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.headline-number small {
  margin-left: 0.04em;
  font-size: 0.42em;
  color: var(--text-secondary);
  font-weight: 600;
}

.stat-label {
  margin: 8px 0 6px;
  color: var(--text-secondary);
  font-size: 17px;
  font-weight: 600;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--text-secondary);
  font-size: clamp(19px, 1.6vw, 25px);
  font-weight: 600;
  letter-spacing: 0.011em;
}

.eyebrow span {
  font-weight: 400;
  opacity: 0.8;
}

.body-text {
  margin: 0 0 24px;
  color: var(--text-secondary);
  font-size: clamp(19px, 1.56vw, 23px);
  line-height: 1.5;
}

.theme-light .body-text strong,
.theme-gray .body-text strong {
  color: var(--text);
}

.authors {
  margin: 0 0 14px;
  font-size: clamp(15px, 2.3vh, 18px);
  line-height: 1.6;
}

.authors sup,
.fineprint sup {
  font-size: 0.65em;
}

.fineprint {
  margin: 0 0 min(29px, 2.6vh);
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.5;
}

/* Cite slide: notice that the BibTeX is the ECCV version until WACV's is out.
   .callout is the same box for a key point on other slides. */
.note,
.callout {
  margin: 0 0 29px;
  padding: 14px 18px;
  border-left: 3px solid var(--link);
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.04);
  color: var(--text-secondary);
  font-size: 17px;
  line-height: 1.45;
}

.credits {
  margin: 48px 0 0;
  color: var(--text-secondary);
  font-size: 14px;
}

.theme-dark .note,
.theme-dark .callout {
  background: rgba(255, 255, 255, 0.06);
}

.callout {
  font-size: clamp(17px, 1.4vw, 20px);
}

.callout strong {
  color: var(--text);
}

/* ---------- Buttons ---------- */

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

/* keep the four title-slide links on one row in the 40% column */
.actions .button {
  min-height: clamp(44px, 6vh, 53px);
  padding: 0 clamp(14px, 1.1vw, 22px);
  font-size: clamp(16px, 1.3vw, 20px);
}

.button {
  display: inline-flex;
  align-items: center;
  min-height: 53px;
  padding: 0 26px;
  border: 1px solid var(--blue);
  border-radius: 980px;
  background: var(--blue);
  color: #fff;
  font: inherit;
  font-size: 20px;
  cursor: pointer;
  transition: background-color 0.2s, color 0.2s;
}

.button:hover {
  background: #0077ed;
  text-decoration: none;
}

.button-secondary {
  background: transparent;
  color: var(--blue);
}

.button-secondary:hover {
  background: var(--blue);
  color: #fff;
}

.button-small {
  min-height: 34px;
  padding: 0 17px;
  font-size: 14px;
}

/* Font Awesome icons (inline <symbol>s in index.html) and the 🤗 emoji */
.button .icon {
  width: 1em;
  height: 1em;
  margin-right: 0.45em;
  fill: currentColor;
}

.button .emoji {
  margin-right: 0.35em;
}

.globalnav-actions {
  display: flex;
  gap: 10px;
  margin-left: auto;
}

.globalnav-links + .globalnav-actions {
  margin-left: 0;
}

.globalnav[data-theme="dark"] .button-secondary {
  border-color: var(--link-dark);
  color: var(--link-dark);
}

.globalnav[data-theme="dark"] .button-secondary:hover {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
}

/* ---------- Full-bleed video slides (title, links) ---------- */

.slide-video {
  align-items: flex-end;
  padding-bottom: 8vh;
  background: #0b0d10;
}

/* the raw dataset clips tiled across the slide, faint, each at its own point in its loop */
.clip-wall {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: repeat(var(--cols, 6), 1fr);
  align-content: center;
  gap: 2px;
  overflow: hidden;
  /* sized by inset, so its ~30 tiles can be laid out and painted in isolation */
  contain: strict;
  opacity: 0;
  transition: opacity 0.4s;
}

.slide.is-active .clip-wall {
  opacity: 0.28;
  transition: opacity 1.4s var(--ease) 0.2s;
}

.clip-wall video {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
}

.slide-video .shade {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.15) 0%, rgba(0, 0, 0, 0.5) 45%, rgba(0, 0, 0, 0.92) 100%);
}

.slide-video .slide-inner {
  position: relative;
  grid-template-columns: 1fr;
}

.slide-video .copy {
  max-width: 1150px;
}

/* the title sits in the middle of the page, over an even (not graded) shade */
#top {
  align-items: center;
}

#top .shade {
  background: rgba(0, 0, 0, 0.2);
}

#top .copy {
  margin: 0 auto;
  text-align: center;
}

#top .actions {
  justify-content: center;
}

#top .eyebrow {
  color: #ffd200;
}

#top .eyebrow span {
  color: rgba(255, 255, 255, 0.75);
  opacity: 1;
}

#top .authors {
  color: rgba(255, 255, 255, 0.92);
}

#top .authors a {
  color: var(--link-dark);
  font-weight: 600;
}

#links .shade {
  background: radial-gradient(ellipse at center, rgba(0, 0, 0, 0.5) 0%, rgba(0, 0, 0, 0.88) 100%);
}

.brand {
  margin: 0 0 16px;
  font-size: clamp(64px, min(8vw, 13vh), 128px);
  font-weight: 700;
  letter-spacing: -0.035em;
  line-height: 1;
}

.brand b {
  color: var(--link-dark);
}

.lede {
  max-width: 820px;
  margin: 0 0 min(40px, 4vh);
  color: rgba(255, 255, 255, 0.88);
  font-size: clamp(20px, min(1.8vw, 3vh), 28px);
  line-height: 1.4;
}

.link-list {
  margin: 0;
  padding: 0;
  list-style: none;
  border-top: 1px solid rgba(255, 255, 255, 0.18);
}

.link-list li {
  border-bottom: 1px solid rgba(255, 255, 255, 0.18);
}

.link-list a {
  display: flex;
  align-items: baseline;
  gap: 24px;
  padding: min(14px, 1.5vh) 0;
  color: #f5f5f7;
  font-size: clamp(16px, min(1.4vw, 2.4vh), 21px);
  overflow-wrap: anywhere;
}

.link-list a span {
  flex: none;
  width: 110px;
  color: #86868b;
}

.link-list a:hover {
  color: var(--link-dark);
  text-decoration: none;
}

/* ---------- Clips ---------- */

.clip {
  position: relative;
  overflow: hidden;
  border-radius: 18px;
  background: #000;
}

.clip video,
.tile video {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
}

.clip-label {
  position: absolute;
  left: 12px;
  bottom: 12px;
  padding: 4px 12px;
  border-radius: 980px;
  background: rgba(0, 0, 0, 0.55);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
}

/* ---------- Problem ---------- */

.points {
  margin: 0 0 min(28px, 2.5vh);
  padding: 0;
  list-style: none;
}

.points li {
  margin-bottom: min(14px, 1.3vh);
  padding-left: 18px;
  border-left: 2px solid #d2d2d7;
  color: var(--text-secondary);
  font-size: clamp(16px, min(1.4vw, 2.3vh), 21px);
  line-height: 1.4;
}

.points strong {
  color: var(--text);
}

.stats {
  display: grid;
  grid-template-columns: auto auto 1fr;
  gap: 28px;
  margin: 0;
  padding-top: min(22px, 2vh);
  border-top: 1px solid #d2d2d7;
}

.stats dt {
  font-size: clamp(30px, min(2.9vw, 5vh), 46px);
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.stats dd {
  margin: 4px 0 0;
  color: var(--text-secondary);
  font-size: 15px;
  line-height: 1.35;
}

.media-stack {
  display: grid;
  grid-template-rows: minmax(0, 1fr) minmax(0, 1.2fr);
  gap: 2.5vh;
  height: var(--media-h);
}

.media-stack .clip video {
  height: 100%;
  aspect-ratio: auto;
}

.media-stack .timeline {
  width: 100%;
  height: 100%;
}

/* ---------- SVG figures ---------- */

.media svg text {
  fill: var(--text-secondary);
  font-family: inherit;
  letter-spacing: 0;
}

.media svg .cap {
  fill: var(--text);
  font-size: 19px;
  font-weight: 600;
}

.media svg .sub,
.media svg .legend-row text {
  font-size: 16px;
}

.media svg .tick {
  fill: #86868b;
  font-size: 15px;
  font-variant-numeric: tabular-nums;
}

.media svg .axis {
  font-size: 16px;
  font-weight: 600;
}

.media svg .grid {
  stroke: #e8e8ed;
  stroke-width: 1;
}

.media svg .base {
  stroke: #86868b;
  stroke-width: 1.2;
}

/* ---------- Dataset ---------- */

.segmented {
  display: inline-flex;
  padding: 4px;
  border-radius: 980px;
  background: #1d1d1f;
}

.segmented button {
  min-height: 41px;
  padding: 0 19px;
  border: 0;
  border-radius: 980px;
  background: transparent;
  color: #a1a1a6;
  font: inherit;
  font-size: 17px;
  cursor: pointer;
  transition: background-color 0.25s var(--ease), color 0.25s var(--ease);
}

.segmented button[aria-pressed="true"] {
  background: #424245;
  color: #f5f5f7;
}

.behavior-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 22px 18px;
}

.tile video {
  border-radius: 14px;
  background: #1d1d1f;
  transition: opacity 0.25s var(--ease);
}

.tile video.is-swapping {
  opacity: 0;
}

.tile p {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 10px 2px 0;
  color: #86868b;
  font-size: 15px;
}

.tile b {
  color: #f5f5f7;
  font-size: 18px;
  font-weight: 600;
}

.tile i {
  flex: none;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--c);
}

.tile span {
  margin-left: auto;
  font-variant-numeric: tabular-nums;
}

/* ---------- Tracking ---------- */

.pipeline {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px 14px;
  align-items: end;
}

.pipeline > p {
  margin: 0;
  font-size: clamp(15px, 1.3vw, 19px);
}

.pipeline .sync-row {
  display: contents;
}

.pipeline .clip {
  border-radius: 14px;
}

/* ---------- Model ---------- */

.cards {
  margin: min(16px, 1.5vh) 0 0;
}

.cards div {
  padding: min(18px, 1.8vh) 0;
  border-top: 1px solid #d2d2d7;
}

.cards dt {
  font-size: clamp(19px, 1.6vw, 24px);
  font-weight: 600;
}

.cards dd {
  margin: 4px 0 0;
  color: var(--text-secondary);
  font-size: clamp(17px, 1.35vw, 20px);
  line-height: 1.45;
}

/* ---------- Charts ---------- */

.chart {
  flex-direction: column;
  max-height: var(--media-h);
}

.chart > svg {
  width: 100%;
  min-height: 0;
  max-height: calc(var(--media-h) - 90px);
}

.legend {
  display: grid;
  grid-template-columns: repeat(3, auto);
  justify-content: start;
  gap: 8px 28px;
  margin-top: 12px;
  color: var(--text-secondary);
  font-size: 15px;
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.legend svg {
  flex: none;
  width: 36px;
  height: 12px;
}

.legend b {
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.legend .ours {
  color: var(--text);
  font-weight: 600;
}

.legend .ours b {
  color: var(--blue);
}

.media svg .line {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.media svg .s-mil   { stroke: #b9c0c9; stroke-width: 2; stroke-dasharray: 2 5; }
.media svg .s-milpp { stroke: #b9c0c9; stroke-width: 2; stroke-dasharray: 8 5; }
.media svg .s-asm   { stroke: #7b8694; stroke-width: 2; stroke-dasharray: 8 4 2 4; }
.media svg .s-hrpro { stroke: #7b8694; stroke-width: 2; stroke-dasharray: 8 5; }
.media svg .s-af    { stroke: var(--text); stroke-width: 2.4; }
.media svg .s-ours  { stroke: var(--blue); stroke-width: 4; }

.media svg .dot {
  fill: var(--blue);
  stroke: var(--gray);
  stroke-width: 2;
}

.media svg .dlabel {
  fill: var(--text);
  font-size: 17px;
  font-weight: 600;
}

.media svg .dlabel.ours {
  fill: var(--blue);
}

.media svg .bar-val {
  fill: var(--text);
  font-size: 20px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.media svg .bar-name {
  fill: var(--text);
  font-size: 19px;
  font-weight: 600;
}

/* ---------- BibTeX ---------- */

pre {
  width: 100%;
  margin: 0;
  padding: 34px;
  overflow-x: auto;
  border-radius: 22px;
  background: #1d1d1f;
  color: #f5f5f7;
  font: 16px/1.6 "SF Mono", ui-monospace, Menlo, Consolas, monospace;
  letter-spacing: 0;
  white-space: pre-wrap;
  word-break: break-word;
}

/* ---------- Slide-in transitions (driven by .is-active from page.js) ---------- */

.js .reveal {
  opacity: 0;
  transform: translate3d(0, 28px, 0);
  transition: opacity 0.5s var(--ease), transform 0.5s var(--ease);
}

.js .media.reveal {
  transform: scale(0.94);
}

/* --i staggers the text column (set by page.js); --d (seconds) times
   elements inside a figure, as in the teaser */
.js .slide.is-active .reveal {
  opacity: 1;
  transform: none;
  transition-duration: 1s;
  transition-delay: calc(var(--i, 0) * 90ms + 120ms + var(--d, 0s));
}

.js .slide.is-active .media.reveal {
  transition-duration: 1.3s;
  transition-delay: 80ms;
}

/* Figure animations: fade in, draw a line, grow a bar up or across. They
   reset quickly when the slide is left so they replay on return. */
.js .pop {
  opacity: 0;
  transition: opacity 0.2s;
}

.js .draw {
  stroke-dasharray: var(--len, 2000);
  stroke-dashoffset: var(--len, 2000);
  transition: stroke-dashoffset 0.2s;
}

.js .grow,
.js .growx {
  transform-box: fill-box;
  transition: transform 0.2s;
}

.js .grow {
  transform: scaleY(0);
  transform-origin: bottom;
}

.js .growx {
  transform: scaleX(0);
  transform-origin: left;
}

.js .slide.is-active .pop {
  opacity: 1;
  transition: opacity 0.45s ease var(--d, 0s);
}

.js .slide.is-active .draw {
  stroke-dashoffset: 0;
  transition: stroke-dashoffset var(--dur, 1.4s) cubic-bezier(0.4, 0, 0.2, 1) var(--d, 0s);
}

.js .slide.is-active .grow,
.js .slide.is-active .growx {
  transform: none;
  transition: transform 0.8s cubic-bezier(0.22, 1, 0.36, 1) var(--d, 0s);
}

/* ---------- Narrow or short screens: stack and stop snapping ---------- */

@media (max-width: 900px), (max-height: 600px) {
  html {
    scroll-snap-type: none;
  }

  .slide {
    height: auto;
    min-height: 100svh;
    padding-top: calc(var(--nav-h) + 58px);
    padding-bottom: 77px;
    --media-h: none;
  }

  .media-stack {
    height: auto;
    grid-template-rows: auto auto;
  }

  .media-stack .clip video {
    aspect-ratio: 16 / 9;
  }

  .media-stack .timeline {
    height: auto;
  }
}

@media (max-width: 1180px) {
  .globalnav-links {
    display: none;
  }

  .globalnav-links + .globalnav-actions {
    margin-left: auto;
  }
}

@media (max-width: 520px) {
  .globalnav-brand {
    display: none;
  }

  .globalnav-actions {
    gap: 7px;
    margin: 0 auto;
  }

  .globalnav-actions .button-small {
    padding: 0 12px;
  }
}

@media (max-width: 900px) {
  .slide-inner {
    grid-template-columns: 1fr;
    gap: 48px;
  }

  .copy {
    max-width: none;
  }

  .behavior-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  /* Tracking turns sideways like the Dataset grid: Lead and Chase become the
     two columns, and each stage's title sits above its row of clips */
  .pipeline {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px 14px;
  }

  .pipeline > p { grid-column: 1 / -1; }
  .pipeline > p:nth-of-type(2) { grid-row: 3; margin-top: 10px; }
  .pipeline > p:nth-of-type(3) { grid-row: 5; margin-top: 10px; }
  .pipeline .sync-row:first-of-type .clip { grid-column: 1; }
  .pipeline .sync-row:last-of-type .clip { grid-column: 2; }
  .pipeline .clip:nth-child(1) { grid-row: 2; }
  .pipeline .clip:nth-child(2) { grid-row: 4; }
  .pipeline .clip:nth-child(3) { grid-row: 6; }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  .js .reveal,
  .js .media.reveal,
  .js .pop,
  .js .grow,
  .js .growx {
    opacity: 1;
    transform: none;
    transition: none;
  }

  .js .draw {
    stroke-dashoffset: 0;
    transition: none;
  }
}
