/* ImagiNav project page. Same palette, type and margin-rail grid as j1dan.github.io:
   mono-caps section names sit in an 11.5rem rail, content runs in the column beside it,
   and the teaser spans the full frame. */
:root {
  --bg: #fff8e7;
  --surface: #fffcf4;
  --plate: #ffffff;
  --ink: #17161a;
  --ink-2: #47463f;
  --muted: #6e6a5e;
  --rule: #ebe1c8;
  --accent: #2c47d0;
  --accent-soft: #e7ebfc;
  --highlight: #f97316;
  /* Path colors from the top-down maps */
  --ref: #2f9e44;
  --exe: #e03131;

  --f-display: "Newsreader", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --f-body: "Instrument Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --f-mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  --f-terminal: "Ubuntu Mono", ui-monospace, "DejaVu Sans Mono", Menlo, monospace;

  --rail: 11.5rem;
  --gap: 2.5rem;
  --measure: 45rem;
  --frame: 64rem;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1014;
    --surface: #161920;
    --plate: #f1f2f4;
    --ink: #e9ebf0;
    --ink-2: #b6bcc8;
    --muted: #8a919e;
    --rule: #272b34;
    --accent: #97a7ff;
    --accent-soft: #1d2447;
    --highlight: #ff8c42;
    --ref: #69db7c;
    --exe: #ff6b6b;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0e1014;
  --surface: #161920;
  --plate: #f1f2f4;
  --ink: #e9ebf0;
  --ink-2: #b6bcc8;
  --muted: #8a919e;
  --rule: #272b34;
  --accent: #97a7ff;
  --accent-soft: #1d2447;
  --highlight: #ff8c42;
  --ref: #69db7c;
  --exe: #ff6b6b;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scrollbar-gutter: stable; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } * { transition: none !important; } }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 1rem/1.6 var(--f-body);
  -webkit-font-smoothing: antialiased;
}
img, video { max-width: 100%; }
a { color: inherit; text-decoration-color: color-mix(in srgb, var(--accent) 45%, transparent); text-decoration-thickness: 1px; text-underline-offset: 0.2em; }
a:hover { color: var(--accent); text-decoration-color: currentColor; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 2px; }
sup { font-size: 0.68em; line-height: 0; }

.frame { max-width: var(--frame); margin-inline: auto; padding-inline: clamp(1rem, 4vw, 2.5rem); padding-block: 0 2rem; }

/* Top bar */
.top { position: relative; z-index: 2; display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding-block: 1.1rem; border-bottom: 1px solid var(--rule); }
/* Alien monster from the homepage's top bar (OpenMoji, CC BY-SA 4.0; credited in the bottom bar). Decorative:
   on hover it steps side to side like a Space Invaders sprite and two more invaders join the row. */
.top-mark { position: relative; display: inline-flex; align-items: center; height: 2rem; cursor: default; user-select: none; -webkit-tap-highlight-color: transparent; }
.invader { display: block; width: auto; height: 1.45rem; overflow: visible; }
.invader.clone {
  position: absolute;
  top: 50%;
  left: 0;
  margin-top: -0.725rem;
  opacity: 0;
  scale: 0.4;
  pointer-events: none;
  transition: translate 0.45s cubic-bezier(0.2, 0.9, 0.3, 1.25), scale 0.45s cubic-bezier(0.2, 0.9, 0.3, 1.25), opacity 0.2s ease;
}
.invader.c1 { filter: hue-rotate(235deg); }
.invader.c2 { filter: hue-rotate(115deg); transition-delay: 0.08s; }
.top-mark.on .clone { pointer-events: auto; }
.top-mark.on .c1 { opacity: 1; scale: 1; translate: 2.2rem 0; }
.top-mark.on .c2 { opacity: 1; scale: 1; translate: 4.4rem 0; }
.top-mark.on .invader { animation: invader-step 0.8s steps(1) infinite; }
.top-mark.on .invader.c1 { animation-delay: -0.4s; }
@keyframes invader-step { 0% { transform: translate(-2px, 0) rotate(-6deg); } 50% { transform: translate(2px, -2px) rotate(6deg); } }
@media (prefers-reduced-motion: reduce) { .top-mark .invader { animation: none !important; } }
.top nav { display: flex; align-items: center; flex-wrap: wrap; justify-content: flex-end; gap: 0.4rem clamp(0.9rem, 2.5vw, 1.75rem); font-size: 0.9rem; }
.top nav a { color: var(--ink-2); text-decoration: none; }
.top nav a:hover { color: var(--accent); }
.theme-btn { position: relative; width: 2rem; height: 2rem; padding: 0; overflow: hidden; border: 1px solid var(--rule); border-radius: 50%; background: var(--surface); color: var(--ink-2); cursor: pointer; }
.theme-btn:hover { color: var(--accent); border-color: var(--accent); }
.theme-btn svg { position: absolute; inset: 0; width: 1rem; height: 1rem; margin: auto; transition: transform 0.6s cubic-bezier(0.65, 0, 0.35, 1), opacity 0.35s ease; }
.theme-btn .sun { opacity: 0; transform: translateY(110%) rotate(-90deg) scale(0.5); }
.theme-btn[data-mode="dark"] .sun { opacity: 1; transform: none; }
.theme-btn[data-mode="dark"] .moon { opacity: 0; transform: translateY(-110%) rotate(90deg) scale(0.5); }

/* Theme switching, as on the homepage: a soft circle from the toggle, or dusk/dawn sweeps */
::view-transition-old(root), ::view-transition-new(root) { animation: none; mix-blend-mode: normal; }
@property --reveal { syntax: "<length>"; inherits: false; initial-value: 0px; }
html[data-theme-anim="reveal"]::view-transition-new(root) {
  -webkit-mask-image: radial-gradient(circle at var(--reveal-x) var(--reveal-y), #000 calc(var(--reveal) - 220px), transparent var(--reveal));
  mask-image: radial-gradient(circle at var(--reveal-x) var(--reveal-y), #000 calc(var(--reveal) - 220px), transparent var(--reveal));
}
html[data-theme-anim="dusk"]::view-transition-new(root) {
  -webkit-mask: linear-gradient(to bottom, #000 40%, transparent 60%) 0 100% / 100% 250% no-repeat;
  mask: linear-gradient(to bottom, #000 40%, transparent 60%) 0 100% / 100% 250% no-repeat;
  animation: theme-dusk 1.6s cubic-bezier(0.45, 0, 0.2, 1) both;
}
html[data-theme-anim="dawn"]::view-transition-new(root) {
  -webkit-mask: linear-gradient(to top, #000 40%, transparent 60%) 0 0 / 100% 250% no-repeat;
  mask: linear-gradient(to top, #000 40%, transparent 60%) 0 0 / 100% 250% no-repeat;
  animation: theme-dawn 1.6s cubic-bezier(0.45, 0, 0.2, 1) both;
}
@keyframes theme-dusk { to { -webkit-mask-position: 0 0; mask-position: 0 0; } }
@keyframes theme-dawn { to { -webkit-mask-position: 0 100%; mask-position: 0 100%; } }
html.theme-fade, html.theme-fade *:not(svg) { transition: background-color 0.6s ease, color 0.6s ease, border-color 0.6s ease, text-decoration-color 0.6s ease !important; }

/* Rail + column grid shared by the hero and every section */
.hero, .section {
  display: grid;
  grid-template-columns: var(--rail) minmax(0, 1fr);
  column-gap: var(--gap);
}
.section { padding-block: clamp(2.5rem, 6vw, 4rem); border-top: 1px solid var(--rule); }
.rail {
  position: sticky;
  top: 1.5rem;
  align-self: start;
  margin: 0;
  padding-top: 0.35rem;
  font: 500 0.72rem/1.4 var(--f-mono);
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--muted);
}
.body { min-width: 0; }
.prose { max-width: var(--measure); font-size: 1.06rem; color: var(--ink-2); }
.prose p { margin: 0 0 1em; }
.prose p:last-child { margin-bottom: 0; }
.prose a { color: var(--ink); }
.lead { max-width: var(--measure); margin: 0 0 1rem; font: 450 clamp(1.4rem, 2.6vw, 1.7rem)/1.25 var(--f-display); letter-spacing: -0.01em; color: var(--ink); text-wrap: balance; }
.lead.later { margin-top: 3.5rem; }
.note { margin: 0.6rem 0 0; font: 500 0.72rem/1.4 var(--f-mono); letter-spacing: 0.04em; color: var(--muted); }

/* Hero */
.hero { padding-block: clamp(2.5rem, 6vw, 3.75rem) 2rem; }
.hero .rail { position: static; padding-top: 0.9rem; }
.tag { display: inline-block; padding: 0.22rem 0.45rem; border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent); border-radius: 3px; background: var(--accent-soft); color: var(--accent); font: 500 0.7rem/1 var(--f-mono); letter-spacing: 0.06em; text-transform: uppercase; }
.hero-text { max-width: 48rem; }
.title { margin: 0; font: 450 clamp(2.6rem, 6vw, 3.6rem)/1 var(--f-display); font-optical-sizing: auto; letter-spacing: -0.02em; }
/* The paper title in the Times small caps of the ICLR template. */
.subtitle { margin: 0.7rem 0 0; font: 400 clamp(1.15rem, 2.2vw, 1.35rem)/1.35 "Times New Roman", Times, "Nimbus Roman", "Nimbus Roman No9 L", "TeX Gyre Termes", "Liberation Serif", Tinos, serif; font-variant-caps: small-caps; color: var(--ink-2); text-wrap: balance; }
.authors, .affils, .links { display: flex; flex-wrap: wrap; margin: 0; padding: 0; list-style: none; }
.authors { gap: 0.15rem 1.1rem; margin-top: 1.4rem; font-size: 0.98rem; }
.authors a { text-decoration: underline; text-decoration-color: var(--rule); }
.authors a:hover { text-decoration-color: currentColor; }
.authors sup, .affils sup { margin-left: 0.1em; color: var(--muted); font-family: var(--f-mono); }
.affils { gap: 0.1rem 1.2rem; margin-top: 0.45rem; font-size: 0.88rem; color: var(--muted); }
.affils sup { margin: 0 0.25em 0 0; }
.links { gap: 0.5rem 1.4rem; align-items: center; margin-top: 1.3rem; }
.links a { padding: 0.2rem 0; color: var(--ink-2); font: 500 0.82rem/1.2 var(--f-mono); letter-spacing: 0.02em; text-decoration: none; }
.links a::after { content: " \2197"; color: var(--muted); }
.links a:hover { color: var(--accent); }
.links a.primary { display: inline-block; padding: 0.3rem 0.6rem; border: 1.5px solid var(--highlight); border-radius: 3px; color: var(--ink); transition: background-color 0.2s ease; }
.links a.primary::after { color: var(--highlight); }
.links a.primary:hover { background: color-mix(in srgb, var(--highlight) 14%, transparent); }

/* Panels (TL;DR, instruction, BibTeX): a blue bar on the left, as on the homepage */
.panel { position: relative; margin-top: 1.4rem; padding: 1rem 1.1rem 1rem calc(1.1rem + 3px); background: var(--surface); border: 1px solid var(--rule); border-left-width: 0; border-radius: 0 6px 6px 0; color: var(--ink-2); }
.panel::before { content: ""; position: absolute; top: -1px; bottom: -1px; left: 0; width: 3px; background: var(--accent); }
.panel p { margin: 0; }
.tldr p { font: 400 1.02rem/1.55 var(--f-terminal); color: var(--ink); }
.tldr-label { margin-right: 0.4em; color: var(--accent); font-weight: 700; }
.panel pre { margin: 0; overflow-x: auto; font: 400 0.88rem/1.5 var(--f-terminal); color: var(--ink); white-space: pre; }
.panel .copy { position: absolute; top: 0.55rem; right: 0.6rem; padding: 0.25rem 0.55rem; border: 1px solid var(--rule); border-radius: 4px; background: var(--bg); color: var(--ink-2); font: 500 0.7rem/1 var(--f-mono); cursor: pointer; }
.panel .copy:hover { color: var(--accent); border-color: var(--accent); }
.bib { margin-top: 0; }

/* Media plates: figures and videos sit on a white card with a hairline border */
.plate { display: block; width: 100%; margin: 0; padding: 0; overflow: hidden; background: var(--plate); border: 1px solid var(--rule); border-radius: 6px; }
.plate.dark { background: #000; }
.plate video, .plate img { display: block; width: 100%; height: auto; }
button.plate { font: inherit; cursor: zoom-in; transition: border-color 0.2s ease; }
button.plate img { padding: clamp(0.5rem, 2vw, 1.1rem); }
button.plate:hover { border-color: var(--accent); }
/* Two source videos carry thin black lines along their top and bottom edges; trim them */
.crop-teaser { clip-path: inset(0.2% 0); }
.crop-diverse { clip-path: inset(0.85% 0); }
figure { margin: 0; }
figcaption { margin-top: 0.7rem; max-width: var(--measure); font-size: 0.9rem; line-height: 1.55; color: var(--muted); }
.figure { margin-top: 1.8rem; }
/* The teaser sits in the text column, so the figure and the text share both edges */
.teaser { padding-left: calc(var(--rail) + var(--gap)); padding-bottom: clamp(2.5rem, 6vw, 3.5rem); }
.teaser figcaption { font: italic 400 1.02rem/1.45 var(--f-display); color: var(--ink-2); }
.flow { font: 500 0.75rem/1.5 var(--f-mono); letter-spacing: 0.03em; color: var(--ink-2); }
.flow span { color: var(--muted); padding-inline: 0.2em; }

/* Method steps: a real sequence, so they are numbered */
.steps { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.4rem 2rem; max-width: 48rem; margin: 1.6rem 0 0; padding: 0; list-style: none; counter-reset: step; }
.steps li { counter-increment: step; padding-top: 0.75rem; border-top: 1px solid var(--rule); }
.steps h3 { display: flex; align-items: baseline; gap: 0.6rem; margin: 0; font: 600 1rem/1.35 var(--f-body); }
.steps h3::before { content: counter(step, decimal-leading-zero); font: 500 0.72rem/1 var(--f-mono); color: var(--accent); }
.steps p { margin: 0.35rem 0 0; font-size: 0.95rem; color: var(--ink-2); }
.steps q { font-family: var(--f-display); font-style: italic; quotes: "\201C" "\201D"; }
.math { font-family: var(--f-display); font-style: italic; white-space: nowrap; }

/* "What the pipeline does not need" */
.needs { display: flex; flex-wrap: wrap; gap: 0.5rem 0.6rem; margin: 1.3rem 0 0; padding: 0; list-style: none; }
.needs li { display: inline-flex; align-items: center; gap: 0.45rem; padding: 0.3rem 0.6rem; border: 1px solid var(--rule); border-radius: 3px; background: var(--surface); font: 500 0.76rem/1.2 var(--f-mono); color: var(--ink-2); }
.needs li::before { content: "\00d7"; font-size: 1rem; line-height: 0.8; color: var(--highlight); }

/* Key figures above the tables */
.figures { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem 1.6rem; max-width: 48rem; margin: 1.8rem 0 0; }
.figures div { padding-top: 0.7rem; border-top: 1px solid var(--rule); }
.figures dt { font: 450 1.9rem/1.1 var(--f-display); letter-spacing: -0.01em; color: var(--ink); font-variant-numeric: lining-nums tabular-nums; }
.figures dt small { font-size: 0.55em; color: var(--muted); }
.figures dd { margin: 0.3rem 0 0; font-size: 0.86rem; line-height: 1.45; color: var(--muted); }

/* Results tables */
.table-title { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.2rem 0.7rem; margin: 2.8rem 0 0.8rem; font: 600 1rem/1.35 var(--f-body); }
.table-title span { font: italic 400 0.95rem/1.35 var(--f-display); color: var(--muted); }
.table-wrap { overflow-x: auto; border-top: 1.5px solid var(--ink); border-bottom: 1.5px solid var(--ink); }
table.results { width: 100%; min-width: 40rem; border-collapse: collapse; font-size: 0.88rem; font-variant-numeric: tabular-nums; }
.results th, .results td { padding: 0.5rem 0.55rem; text-align: left; font-weight: 400; white-space: nowrap; }
.results thead th { white-space: normal; padding-block: 0.7rem 0.55rem; border-bottom: 1px solid var(--rule); font: 500 0.68rem/1.3 var(--f-mono); letter-spacing: 0.05em; text-transform: uppercase; color: var(--ink-2); vertical-align: bottom; }
.results tbody tr + tr > * { border-top: 1px solid color-mix(in srgb, var(--rule) 70%, transparent); }
.results th[scope="row"] { font-weight: 500; color: var(--ink); }
.results .group th { padding-block: 0.9rem 0.3rem; font: italic 400 0.92rem/1.3 var(--f-display); color: var(--muted); }
.results .n { text-align: right; }
.results .c { text-align: center; }
.results .no { color: var(--muted); }
.results .b { font-weight: 650; color: var(--ink); }
.results tr.ours > * { background: var(--accent-soft); }
.results tr.ours th { box-shadow: inset 3px 0 0 var(--accent); }
.results tr.ours + tr.ours > * { border-top-color: color-mix(in srgb, var(--accent) 15%, transparent); }
.data { display: inline-flex; align-items: center; gap: 0.55rem; }
.data-v { min-width: 4.2rem; }
.data-bar { position: relative; display: block; width: 5rem; height: 4px; border-radius: 2px; background: color-mix(in srgb, var(--rule) 70%, transparent); }
.data-bar::after { content: ""; position: absolute; inset: 0 auto 0 0; width: max(var(--w), 2px); border-radius: 2px; background: var(--muted); }
tr.ours .data-bar::after { background: var(--accent); }
.table-note { max-width: var(--measure); margin: 0.6rem 0 0; font-size: 0.82rem; line-height: 1.5; color: var(--muted); }

/* Imagination vs execution: three synchronized clips per scene */
.explorer { margin-top: 1.6rem; }
.scenes { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.scenes button { padding: 0.35rem 0.7rem; border: 1px solid var(--rule); border-radius: 3px; background: var(--surface); color: var(--ink-2); font: 500 0.76rem/1.2 var(--f-mono); cursor: pointer; transition: color 0.2s ease, border-color 0.2s ease, background-color 0.2s ease; }
.scenes button:hover { color: var(--accent); border-color: var(--accent); }
.scenes button[aria-selected="true"] { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 45%, transparent); color: var(--accent); }
.instruction { margin-top: 0.9rem; }
.instruction-label { display: block; margin-bottom: 0.2rem; font: 500 0.66rem/1.3 var(--f-mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.instruction p { font: 400 1.05rem/1.5 var(--f-terminal); color: var(--ink); }
.clips { display: grid; grid-template-columns: 480fr 480fr 256fr; gap: 0.6rem; margin-top: 0.9rem; }
.clip video { display: block; width: 100%; height: auto; border-radius: 5px; background: var(--surface); }
.clip figcaption { margin-top: 0.4rem; font: 500 0.68rem/1.3 var(--f-mono); letter-spacing: 0.07em; text-transform: uppercase; color: var(--ink-2); }
.clip.imagined figcaption { color: var(--accent); }
.player { display: flex; flex-wrap: wrap; align-items: center; gap: 0.6rem 0.9rem; margin-top: 0.8rem; }
.play { display: grid; place-items: center; width: 2rem; height: 2rem; padding: 0; border: 1px solid var(--rule); border-radius: 50%; background: var(--surface); color: var(--ink-2); cursor: pointer; }
.play:hover { color: var(--accent); border-color: var(--accent); }
.play svg { width: 0.7rem; height: 0.7rem; }
.play .i-play, .play.paused .i-pause { display: none; }
.play.paused .i-play { display: block; }
#clip-scrub { flex: 1 1 10rem; min-width: 0; accent-color: var(--accent); cursor: pointer; }
.legend { display: flex; gap: 1rem; margin: 0; font: 500 0.7rem/1.3 var(--f-mono); color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 0.4rem; }
.legend span::before { content: ""; width: 1.1rem; height: 3px; border-radius: 2px; }
.legend .ref::before { background: var(--ref); }
.legend .exe::before { background: var(--exe); }

/* Footer */
.bottom { display: grid; justify-items: center; gap: 0.35rem; padding-block: 1.6rem 0; border-top: 1px solid var(--rule); }
.bottom .credits { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.2rem 1.2rem; }
.bottom p { margin: 0; font: 500 0.72rem/1.4 var(--f-mono); letter-spacing: 0.04em; color: var(--muted); text-align: center; }

/* Lightbox: the figure grows out of the clicked plate */
html.lightbox-open { overflow: hidden; }
.lightbox { width: 100vw; max-width: none; height: 100vh; max-height: none; margin: 0; padding: 0; border: 0; overflow: hidden; background: rgb(8 10 14 / 0.84); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); color: #e9ebf0; cursor: zoom-out; }
.lightbox[open] { display: grid; place-items: center; }
.lightbox::backdrop { background: transparent; }
.lightbox figure { display: grid; justify-items: center; gap: 0.9rem; margin: 0; padding: 3.5rem 1rem 1.5rem; }
.lightbox img { display: block; width: auto; max-width: none; height: auto; padding: 1rem; border-radius: 6px; background: #fff; transform-origin: 0 0; }
.lightbox figcaption { max-width: 60ch; margin: 0; font: 500 0.88rem/1.4 var(--f-body); color: #c9ced8; text-align: center; text-wrap: balance; }
.lightbox-close { position: fixed; top: calc(1rem + env(safe-area-inset-top, 0px)); right: 1rem; width: 2.5rem; height: 2.5rem; padding: 0; border: 1px solid rgb(255 255 255 / 0.25); border-radius: 50%; background: rgb(255 255 255 / 0.08); color: #fff; font: 400 1.5rem/1 var(--f-body); cursor: pointer; }
.lightbox-close:hover { background: rgb(255 255 255 / 0.18); }

@media (max-width: 760px) {
  .hero, .section { grid-template-columns: minmax(0, 1fr); }
  .rail { position: static; margin-bottom: 1.2rem; padding-top: 0; }
  .hero .rail { margin-bottom: 1rem; padding-top: 0; }
  .teaser { padding-left: 0; }
  .steps { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 560px) {
  .top nav a[href="#data"], .top nav a[href="#examples"] { display: none; }
  .figures { grid-template-columns: minmax(0, 1fr); }
  .clips { grid-template-columns: 480fr 256fr; }
  .clip.imagined { grid-column: 1 / -1; }
}
