/* PASSAGE project page — design system.
 * Self-hosted fonts (78KB total, latin subsets, font-display swap),
 * indigo-on-paper palette, card shadows, eyebrow section labels. */

/* ── Fonts ───────────────────────────────────────────────────────── */

@font-face {
  font-family: 'Sora';
  src: url('assets/fonts/sora-latin-700-normal.woff2') format('woff2');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Sora';
  src: url('assets/fonts/sora-latin-600-normal.woff2') format('woff2');
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Inter';
  src: url('assets/fonts/inter-latin-400-normal.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Inter';
  src: url('assets/fonts/inter-latin-600-normal.woff2') format('woff2');
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}

/* ── Tokens ──────────────────────────────────────────────────────── */

:root {
  --paper: #fbfbfd;
  --card: #ffffff;
  --ink: #1c2130;
  --ink-soft: #4b5262;
  --ink-faint: #8b91a1;
  --line: #e7e9f0;
  --accent: #4c5bf5;
  --accent-deep: #3a46d6;
  --accent-soft: #eef0fe;
  --brand-grad: linear-gradient(115deg, #4f5cf0 10%, #22b8ee 90%);
  --shadow-sm: 0 1px 2px rgba(28, 33, 48, 0.05);
  --shadow-md: 0 1px 2px rgba(28, 33, 48, 0.04),
               0 18px 44px -16px rgba(28, 33, 48, 0.22);
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI',
               Roboto, 'Helvetica Neue', Arial, sans-serif;
  --font-display: 'Sora', 'Inter', -apple-system, BlinkMacSystemFont,
                  'Segoe UI', Roboto, sans-serif;
  --radius: 14px;
}

/* ── Base ────────────────────────────────────────────────────────── */

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  /* Soft indigo aura behind the header, fading into the paper. */
  background:
    radial-gradient(1100px 420px at 50% -140px, #e9ecfd 0%, rgba(233, 236, 253, 0) 70%),
    var(--paper);
  color: var(--ink);
  font: 400 16.5px/1.75 var(--font-body);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

::selection { background: #dde1fd; color: var(--ink); }

.page {
  /* Wide but still a comfortable reading measure: ~880px of text column
   * plus side padding; on very wide panels (>1600px, e.g. 2560x1440)
   * allow up to 1100px so media rails use the space. */
  max-width: 1000px;
  margin: 0 auto;
  padding: 56px 22px 72px;
}
@media (min-width: 1600px) {
  .page { max-width: 1100px; }
}

/* ── Header: title / subtitle / authors / links ─────────────────── */

.header { text-align: center; margin-bottom: 10px; }

.title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(26px, 5.4vw, 36px);
  line-height: 1.28;
  letter-spacing: -0.015em;
  margin: 0 0 10px;
  color: var(--ink);
}

/* The acronym carries the brand gradient. */
.title__brand {
  background: var(--brand-grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.subtitle {
  font-size: 17px;
  font-weight: 400;
  color: var(--ink-soft);
  text-align: center;
  margin: 0 0 26px;
}

.authors { font-size: 16.5px; font-weight: 600; margin: 0 0 8px; }
.author { display: inline-block; white-space: nowrap; }
.authors a { color: var(--ink); text-decoration: none; }
.authors a:hover { color: var(--accent); }
.authors sup { color: var(--accent); font-weight: 600; }

.affiliations { font-size: 14px; color: var(--ink-faint); margin: 0 0 26px; }

/* ── Link pills ──────────────────────────────────────────────────── */

.links { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }

.links .btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 18px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  color: var(--ink);
  font: 600 14px/1 var(--font-body);
  text-decoration: none;
  box-shadow: var(--shadow-sm);
  transition: background-color 0.15s, border-color 0.15s, color 0.15s,
              transform 0.15s, box-shadow 0.15s;
}
.links .btn svg { width: 15px; height: 15px; flex: none; }
.links .btn:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  transform: translateY(-1px);
  box-shadow: 0 8px 20px -6px rgba(76, 91, 245, 0.45);
}
.links .btn[aria-disabled="true"],
.links .btn[aria-disabled="true"]:hover {
  background: var(--card);
  border-color: var(--line);
  color: var(--ink-faint);
  transform: none;
  box-shadow: var(--shadow-sm);
  cursor: default;
}

/* ── Sections ────────────────────────────────────────────────────── */

.section { margin-top: 52px; scroll-margin-top: 24px; }

/* Eyebrow label: small caps accent word between two fading hairlines. */
.section h2 {
  display: flex;
  align-items: center;
  gap: 16px;
  font: 600 12.5px/1 var(--font-display);
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 12px;
}
.section h2::before,
.section h2::after {
  content: '';
  flex: 1;
  height: 1px;
}
.section h2::before { background: linear-gradient(to right, transparent, var(--line)); }
.section h2::after  { background: linear-gradient(to left,  transparent, var(--line)); }

.body-text { margin: 14px 0 6px; text-align: justify; color: var(--ink-soft); }

/* Keep the dense paper summary compact without shrinking body copy elsewhere. */
.section--abstract .body-text {
  margin-top: 8px;
  font-size: 14px;
  line-height: 1.56;
}

/* Group subhead inside a section (e.g. Simulation / Real Robot): a short
 * gradient tick keeps it visually below the eyebrow h2, not competing. */
.subhead {
  display: flex;
  align-items: center;
  gap: 9px;
  font: 600 15px/1.4 var(--font-display);
  color: var(--ink);
  margin: 30px 0 0;
}
.subhead::before {
  content: '';
  width: 18px;
  height: 2px;
  border-radius: 2px;
  background: var(--brand-grad);
}

/* ── Media facade ────────────────────────────────────────────────── */

.facade {
  position: relative;
  margin: 20px 0 8px;
  aspect-ratio: 16 / 10;
  border-radius: var(--radius);
  background: var(--card);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-md);
  overflow: hidden;
  cursor: pointer;
}

.facade--wide { aspect-ratio: 16 / 9; }
.facade--cinema { aspect-ratio: 400 / 177; }

/* Fullscreen: author aspect-ratio/max-height would otherwise keep the
   facade at inline size inside the top layer. Stretch to the screen and
   let the video letterbox inside. */
.facade:fullscreen {
  margin: 0;
  aspect-ratio: auto;
  width: 100vw;
  height: 100vh;
  max-height: none;
  border: none;
  border-radius: 0;
}
.facade:fullscreen > video {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.facade:fullscreen > img {
  object-fit: contain;
}

.facade img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  /* Fade posters in as they decode; web.js adds .is-loaded (also on error,
   * so a missing poster never leaves a permanently dim frame). Guarded by
   * the .js flag set inline in <head>: without scripts, posters just show. */
  opacity: 0;
  transition: opacity .45s ease;
}
.js .facade img.is-loaded { opacity: 1; }

/* Videos start hidden and cross-fade from the poster on the first decoded
   frame — no black flash while the stream buffers. */
.facade > video { opacity: 0; transition: opacity .3s ease; }
.facade > video.is-ready { opacity: 1; }

/* Warm-up element: fetches headers/ahead chunk for a video before its
   click. Invisible and inert — the facade still shows its poster. */
.facade__warm {
  position: absolute;
  inset: 0;
  width: 1px; height: 1px;
  opacity: 0;
  pointer-events: none;
}

/* Loading progress: a thin accent bar along the bottom edge that fills
   with buffered/duration while the first frames stream in (the poster
   stays visible meanwhile), then dissolves once playback starts. Only
   video facades that have been clicked get --load-progress set. */
.facade[data-facade="video"][data-loaded]::after {
  content: '';
  position: absolute;
  left: 0; bottom: 0;
  height: 3px;
  width: var(--load-progress, 0%);
  max-width: 100%;
  background: var(--accent, #5b8cff);
  border-radius: 0 2px 2px 0;
  transition: width .25s ease, opacity .5s ease;
  z-index: 6;
  pointer-events: none;
}
.facade.is-buffered::after { opacity: 0; }

@media (prefers-reduced-motion: reduce) {
  .facade img, .facade > video { transition: none; }
}

.facade__play {
  position: absolute;
  inset: 0;
  margin: auto;
  width: 74px;
  height: 74px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.92);
  color: var(--accent);
  font-size: 24px;
  line-height: 1;
  padding-left: 6px;          /* optical centering of ▶ */
  cursor: pointer;
  box-shadow: 0 10px 30px -6px rgba(28, 33, 48, 0.4);
  transition: background-color 0.15s, color 0.15s, transform 0.15s;
}
.facade__play:hover {
  background: var(--accent);
  color: #fff;
  transform: scale(1.06);
}

.facade__tag {
  position: absolute;
  left: 12px;
  bottom: 12px;
  padding: 4px 12px;
  border-radius: 999px;
  background: rgba(18, 22, 36, 0.6);
  backdrop-filter: blur(4px);
  color: #fff;
  font: 600 12px/1.5 var(--font-body);
}

/* Fullscreen toggle for video players. */
.facade__fs {
  position: absolute;
  right: 12px;
  bottom: 12px;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 10px;
  background: rgba(18, 22, 36, 0.6);
  backdrop-filter: blur(4px);
  color: #fff;
  cursor: pointer;
  transition: background-color 0.15s;
}
.facade__fs svg { width: 17px; height: 17px; }
.facade__fs:hover { background: var(--accent); }
.facade.is-missing .facade__fs { display: none; }

/* Native fullscreen: fill the screen. */
.facade:fullscreen {
  aspect-ratio: auto;
  border-radius: 0;
  border: none;
}

/* Missing-material state: dashed slot + hint, never a broken layout.
 * The hint text comes from the facade's own data-fallback attribute. */
.facade.is-missing { box-shadow: none; border-style: dashed; }
.facade.is-missing img,
.facade.is-missing .facade__play,
.facade.is-missing .facade__fs,
.facade.is-missing .facade__tag { display: none; }
.facade.is-missing::before {
  content: attr(data-fallback, 'Material pending');
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-faint);
  font-size: 14.5px;
  text-align: center;
  padding: 0 24px;
}

/* After click: the real video fills the same slot. */
.facade > video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  background: #0d1017;
}
/* Horizontal swipes scrub; vertical pans still scroll the page. */
.facade > video { object-fit: contain; cursor: pointer; touch-action: pan-y; }

/* ── Loop player overlays ────────────────────────────────────────── */

/* Paused: a soft play button invites the next tap. */
.player__center {
  position: absolute;
  inset: 0;
  margin: auto;
  width: 64px;
  height: 64px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.92);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  padding-left: 4px;          /* optical centering of ▶ */
  cursor: pointer;
  box-shadow: 0 10px 30px -6px rgba(28, 33, 48, 0.4);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s;
  z-index: 3;
}
.facade.is-paused .player__center { opacity: 1; pointer-events: auto; }
.player__center svg { width: 26px; height: 26px; }

/* Tap feedback: the current play/pause icon flashes dead center. */
.player__flash {
  position: absolute;
  inset: 0;
  margin: auto;
  width: 76px;
  height: 76px;
  border-radius: 50%;
  background: rgba(13, 16, 23, 0.55);
  backdrop-filter: blur(4px);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.35s;
  pointer-events: none;
  z-index: 3;
}
.player__flash.show { opacity: 1; transition: opacity 0.05s; }
.player__flash svg { width: 30px; height: 30px; }

/* Play / pause icon swap, driven by the facade's paused state. */
.facade.is-paused .i-pause { display: none; }
.facade:not(.is-paused) .i-play { display: none; }

/* Time bubble, shown while a horizontal swipe or seek-bar drag scrubs. */
.player__scrub {
  position: absolute;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%);
  padding: 6px 15px;
  border-radius: 999px;
  background: rgba(13, 16, 23, 0.72);
  backdrop-filter: blur(4px);
  color: #fff;
  font: 600 13px/1 var(--font-body);
  font-variant-numeric: tabular-nums;
  opacity: 0;
  transition: opacity 0.2s;
  pointer-events: none;
  z-index: 3;
  white-space: nowrap;
}
.player__scrub.show { opacity: 1; }

/* ── Seek bar ────────────────────────────────────────────────────── */

/* Draggable progress bar along the bottom edge of a loaded video facade.
 * Thin hairline by default, thickens on hover; the fill follows playback,
 * the lighter underlay follows the buffered range. Hidden until the video
 * is ready; on touch devices it appears whenever the clip is paused. */
.player__bar {
  position: absolute;
  left: 12px;
  right: 54px;               /* clears the fullscreen button */
  bottom: 5px;
  height: 18px;
  display: flex;
  align-items: center;
  cursor: pointer;
  z-index: 4;
  opacity: 0;
  transition: opacity 0.25s;
  touch-action: none;        /* the drag owns the pointer */
  outline: none;
}
.facade[data-loaded][data-facade="video"]:hover .player__bar,
.facade[data-loaded][data-facade="video"]:focus-within .player__bar,
.facade.is-paused .player__bar { opacity: 1; }
.player__bar:focus-visible .bar__track { box-shadow: 0 0 0 2px rgba(76, 91, 245, 0.55); }

.bar__track {
  position: relative;
  width: 100%;
  height: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.32);
  overflow: hidden;
  transition: height 0.15s;
}
.player__bar:hover .bar__track { height: 6px; }
.bar__buf, .bar__fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0;
  border-radius: inherit;
}
.bar__buf { background: rgba(255, 255, 255, 0.45); }
.bar__fill { background: #fff; }
.player__bar:hover .bar__fill { background: var(--accent); }

.bar__thumb {
  position: absolute;
  width: 13px;
  height: 13px;
  margin-left: -6.5px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
  transform: scale(0);
  transition: transform 0.15s;
  pointer-events: none;
  left: var(--fill, 0%);
}
.player__bar:hover .bar__thumb,
.player__bar:focus-visible .bar__thumb { transform: scale(1); }

/* The tag pill rides a little higher once the player bar exists. */
.facade[data-loaded][data-facade="video"] .facade__tag { bottom: 26px; }

/* ── Figures ─────────────────────────────────────────────────────── */

.figure { margin: 22px 0 8px; text-align: center; }
.figure img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
}
.figure figcaption {
  font-size: 13.5px;
  color: var(--ink-faint);
  margin-top: 10px;
  text-align: center;
}

.figure-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 16px;
}

.method-results__title { margin-top: 34px; }
.figure--table { margin-top: 16px; }
.results-figure-grid {
  display: grid;
  grid-template-columns: 4fr 3fr;
  gap: 16px;
  align-items: start;
  margin-top: 16px;
}
.results-figure-grid .figure { margin: 0; }

.figure.is-missing img { display: none; }
.figure.is-missing::before {
  content: 'Figure placeholder — add the image under assets/images/';
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 16 / 10;
  border-radius: var(--radius);
  border: 1px dashed #ccd0da;
  color: var(--ink-faint);
  font-size: 13.5px;
  padding: 0 16px;
}

/* ── Video grid ──────────────────────────────────────────────────── */

.video-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px 16px;
}
.video-grid .facade { margin: 0; }

/* ── Media groups and horizontal rails ─────────────────────────── */

.media-group { margin-top: 30px; }
.media-group + .media-group { margin-top: 38px; }

.media-group__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}
.media-group__head .subhead { margin: 0; }

.carousel-nav {
  display: flex;
  gap: 7px;
  transition: opacity 0.18s;
}
.carousel-nav.is-static { opacity: 0; pointer-events: none; }
.carousel-nav button {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--card);
  color: var(--ink-soft);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background-color 0.15s,
              transform 0.15s;
}
.carousel-nav button:hover:not(:disabled) {
  color: #fff;
  border-color: var(--accent);
  background: var(--accent);
  transform: translateY(-1px);
}
.carousel-nav button:disabled { opacity: 0.28; cursor: default; }
.carousel-nav svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.media-rail {
  display: flex;
  flex-wrap: nowrap;
  gap: 14px;
  margin: 0;
  padding: 4px 0 13px;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scroll-snap-type: x mandatory;
  scroll-padding-inline: 0;
  scrollbar-width: thin;
  scrollbar-color: #c5cae9 var(--accent-soft);
}
.media-rail::-webkit-scrollbar { height: 6px; }
.media-rail::-webkit-scrollbar-track {
  background: var(--accent-soft);
  border-radius: 999px;
}
.media-rail::-webkit-scrollbar-thumb {
  background: #c5cae9;
  border-radius: 999px;
}
.media-rail::-webkit-scrollbar-thumb:hover { background: #aeb6e6; }
.media-rail:focus-visible {
  outline: 2px solid rgba(76, 91, 245, 0.38);
  outline-offset: 5px;
  border-radius: 4px;
}

.clip-card {
  flex: 0 0 45%;
  min-width: 0;
  scroll-snap-align: start;
}
.clip-card--wide { width: 100%; }
.media-rail--pair .clip-card { flex-basis: calc((100% - 14px) / 2); }
.clip-card .facade {
  margin: 0;
  border-radius: 12px;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.18s, box-shadow 0.18s, transform 0.18s;
}
.clip-card:hover .facade {
  border-color: #d9dcef;
  box-shadow: 0 12px 30px -20px rgba(28, 33, 48, 0.5);
  transform: translateY(-1px);
}
.clip-card .facade__play,
.clip-card .player__center {
  width: 52px;
  height: 52px;
  font-size: 18px;
}
.clip-card .player__center svg { width: 22px; height: 22px; }
.clip-card .player__flash { width: 58px; height: 58px; }
.clip-card .facade__fs {
  right: 9px;
  bottom: 9px;
  width: 32px;
  height: 32px;
}
/* Horizontal gestures move the rail instead of scrubbing an individual clip. */
.media-rail .facade > video { touch-action: pan-x pan-y; }

.clip-card__meta {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 3px 1px;
  font-size: 13.5px;
  line-height: 1.4;
}
.clip-card__title { color: var(--ink-soft); font-weight: 600; }
.clip-card__duration {
  flex: none;
  color: var(--ink-faint);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

/* ── BibTeX: compact, horizontally scrollable code strip ────────── */

.bibtex {
  position: relative;
  max-width: 860px;
  margin: 0 auto;
}

.bibtex pre {
  margin: 10px 0 0;
  padding: 13px 16px 17px;
  background: #202534;
  border: 1px solid #2a3040;
  border-radius: 12px;
  box-shadow: var(--shadow-sm);
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior-x: contain;
  white-space: pre;
  scrollbar-width: thin;
  scrollbar-color: #69738c #2a3040;
  font: 400 11.5px/1.55 ui-monospace, SFMono-Regular, Menlo, Consolas,
        'Liberation Mono', monospace;
  color: #d2d8e7;
}
.bibtex pre:focus-visible {
  outline: 2px solid rgba(76, 91, 245, 0.42);
  outline-offset: 4px;
}
.bibtex pre::-webkit-scrollbar { height: 6px; }
.bibtex pre::-webkit-scrollbar-track {
  background: #2a3040;
  border-radius: 999px;
}
.bibtex pre::-webkit-scrollbar-thumb {
  background: #69738c;
  border-radius: 999px;
}

.bibtex__copy {
  position: absolute;
  top: 18px;
  right: 10px;
  padding: 4px 11px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  color: #cfd6ea;
  font: 600 11px/1.45 var(--font-body);
  cursor: pointer;
  transition: background-color 0.15s, color 0.15s;
}
.bibtex__copy:hover { background: #fff; color: var(--ink); }

/* ── Mobile ──────────────────────────────────────────────────────── */

@media (max-width: 640px) {
  .title { font-size: 24px; }
  .subtitle { font-size: 15.5px; }
  .figure-grid, .video-grid { grid-template-columns: 1fr; }
  .results-figure-grid { grid-template-columns: 1fr; gap: 18px; }
  .facade__play { width: 62px; height: 62px; font-size: 20px; }
  .clip-card,
  .media-rail--pair .clip-card { flex-basis: 86%; }
  .media-rail { gap: 12px; }
  .clip-card .facade__play,
  .clip-card .player__center { width: 50px; height: 50px; }
}

/* ── Reduced motion ──────────────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .facade__play:hover,
  .links .btn:hover { transform: none; }
}
