/* ==========================================================================
   World-T3 project page
   ========================================================================== */

:root {
  --bg: #ffffff;
  --bg-alt: #f1f4f7;
  --surface: #ffffff;
  --text: #1c2b33;
  --text-muted: #5d6c7b;
  --border: #dee3e9;
  --accent: #0a4fb3;          /* Meta blue */
  --accent-soft: #e7eef8;
  --link: #0a4fb3;
  --code-bg: #f1f4f7;
  --video-bg: #0a1633;        /* navy used in the stitched comparison videos */
  --shadow: 0 1px 2px rgba(28, 43, 51, .06), 0 4px 14px rgba(28, 43, 51, .06);

  --radius: 10px;
  --max: 960px;
  --max-wide: 1200px;
  --max-narrow: 780px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0a1317;
    --bg-alt: #111c23;
    --surface: #16232c;
    --text: #e4e9ed;
    --text-muted: #9aa8b4;
    --border: #263641;
    --accent: #47a1ff;
    --accent-soft: #0f2a45;
    --link: #6fb1ff;
    --code-bg: #16232c;
    --shadow: none;
  }
}
:root[data-theme="dark"] {
  --bg: #0a1317;
  --bg-alt: #111c23;
  --surface: #16232c;
  --text: #e4e9ed;
  --text-muted: #9aa8b4;
  --border: #263641;
  --accent: #47a1ff;
  --accent-soft: #0f2a45;
  --link: #6fb1ff;
  --code-bg: #16232c;
  --shadow: none;
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 64px; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}
img, video { max-width: 100%; display: block; }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
h2, h3, h4 { line-height: 1.25; margin: 0 0 .6em; }
h2 { font-size: 1.85rem; font-weight: 700; letter-spacing: -.01em; }
h3 { font-size: 1.2rem; font-weight: 650; }
h4 { font-size: 1.02rem; font-weight: 650; }
p { margin: 0 0 1em; }
.mono { font-family: var(--mono); }
.muted { color: var(--text-muted); }
.smallcaps { font-variant: small-caps; font-weight: 600; }

.container { max-width: var(--max); margin: 0 auto; padding: 0 16px; }
.container.wide { max-width: var(--max-wide); }
.container.narrow { max-width: var(--max-narrow); }

.section { padding: 64px 0; }
.section.alt { background: var(--bg-alt); }
.section h2 { text-align: center; }
.lead { color: var(--text-muted); text-align: center; max-width: 760px; margin: 0 auto 28px; }
.subhead { margin-top: 48px; text-align: center; font-size: 1.35rem; }

/* ---------- top nav ---------- */
.topnav {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: saturate(160%) blur(10px);
  -webkit-backdrop-filter: saturate(160%) blur(10px);
  border-bottom: 1px solid var(--border);
}
.topnav-inner {
  max-width: var(--max-wide); margin: 0 auto; padding: 0 16px;
  height: 52px; display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.brand { font-weight: 800; color: var(--text); font-size: 1.05rem; }
.brand:hover { text-decoration: none; }
.topnav-links { display: flex; gap: 20px; overflow-x: auto; scrollbar-width: none; }
.topnav-links::-webkit-scrollbar { display: none; }
.topnav-links a { color: var(--text-muted); font-size: .9rem; font-weight: 500; white-space: nowrap; }
.topnav-links a:hover { color: var(--text); text-decoration: none; }

/* ---------- hero ---------- */
.hero { padding: 64px 0 24px; text-align: center; background: linear-gradient(180deg, var(--bg-alt), var(--bg) 85%); }
.title { margin: 0 0 24px; }
.title-name {
  display: block; font-size: clamp(2.6rem, 7vw, 4rem); font-weight: 800;
  letter-spacing: -.02em; line-height: 1.05; color: var(--accent);
}
.title-sub {
  display: block; margin-top: 12px;
  font-size: clamp(1.25rem, 3vw, 1.8rem); font-weight: 650; letter-spacing: -.01em; line-height: 1.3;
}
.authors { font-size: 1.05rem; margin: 0 auto 8px; max-width: 880px; }
.author { display: inline-block; margin: 0 .45em; white-space: nowrap; }
.author a { color: var(--text); }
.author a:hover { color: var(--link); }
.author sup, .affiliations sup, .notes sup { font-size: .7em; color: var(--text-muted); }
.affiliations { margin: 0 0 4px; }
.affiliations span, .notes span { display: inline-block; margin: 0 .7em; }
.notes { font-size: .88rem; color: var(--text-muted); }

.link-buttons { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-top: 24px; }
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 18px; border-radius: 999px;
  background: var(--text); color: var(--bg);
  font-weight: 600; font-size: .95rem;
  transition: transform .12s ease, opacity .12s ease;
}
.btn:hover { text-decoration: none; transform: translateY(-1px); background: var(--accent); color: #fff; }
.btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.btn small { font-weight: 500; opacity: .75; }
.btn.disabled { opacity: .45; pointer-events: none; }

/* ---------- figures ---------- */
.figure { margin: 0 0 24px; }
.figure img { width: 100%; height: auto; border-radius: 6px; background: #fff; }
.figure figcaption, .caption {
  color: var(--text-muted); font-size: .92rem; line-height: 1.55;
  margin-top: 12px; text-align: center;
}
.caption.left { text-align: left; }
.ours { color: var(--accent); font-weight: 700; }

/* ---------- stats ---------- */
.teaser { padding-top: 24px; }
.stats {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px;
  margin-top: 36px;
}
.stat {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px 16px; text-align: center; box-shadow: var(--shadow);
}
.stat-value { font-size: 2rem; font-weight: 800; color: var(--accent); letter-spacing: -.02em; line-height: 1.1; }
.stat-value .unit { font-size: .55em; font-weight: 700; margin-left: 3px; }
.stat-label { font-size: .88rem; margin-top: 8px; line-height: 1.45; }
.stat-label .muted { font-size: .82rem; }

/* ---------- abstract ---------- */
.abstract { text-align: justify; hyphens: auto; }

/* ---------- tabs ---------- */
.tabs { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-bottom: 18px; }
.tab {
  font: inherit; font-size: .9rem; font-weight: 500;
  padding: 7px 14px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface); color: var(--text-muted);
}
.tab:hover { color: var(--text); }
.tab.active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ---------- videos ---------- */
.video-frame { background: var(--video-bg); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.video { width: 100%; height: auto; aspect-ratio: 2224 / 932; cursor: pointer; }

.sync-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.sync-cell { position: relative; }
.sync-cell video {
  width: 100%; aspect-ratio: 960 / 528; background: #000;
  border-radius: 6px; cursor: pointer;
}
.sync-label { font-size: .9rem; font-weight: 600; margin-bottom: 6px; }

.sync-controls {
  display: flex; align-items: center; gap: 14px; margin-top: 14px;
  padding: 10px 14px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface);
}
.ctrl-btn {
  width: 36px; height: 36px; flex: none; border-radius: 50%; border: 0; cursor: pointer;
  background: var(--accent); color: #fff; display: grid; place-items: center;
}
.ctrl-btn svg { width: 16px; height: 16px; fill: currentColor; }
.ctrl-btn .icon-pause { display: none; }
.ctrl-btn.playing .icon-play { display: none; }
.ctrl-btn.playing .icon-pause { display: block; }
.scrubber { flex: 1; min-width: 0; accent-color: var(--accent); }
.time { font-size: .85rem; color: var(--text-muted); white-space: nowrap; }
.speed {
  font: inherit; font-size: .85rem; padding: 4px 6px; border-radius: 6px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
}

/* ---------- method ---------- */
.stages { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.stage {
  position: relative;
  display: flex; flex-direction: column; align-items: flex-start;
  font: inherit; text-align: left; color: inherit; cursor: pointer;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; box-shadow: var(--shadow);
  transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease;
}
.stage:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); transform: translateY(-1px); }
.stage:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.stage.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent), var(--shadow);
}
/* Pointer from the active card down to the figure panel */
.stage.active::after {
  content: ""; position: absolute; left: 50%; bottom: -17px; transform: translateX(-50%);
  border: 8px solid transparent; border-top-color: var(--accent);
}
.stage-num {
  width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent); font-weight: 700; margin-bottom: 10px;
  transition: background .15s ease, color .15s ease;
}
.stage.active .stage-num { background: var(--accent); color: #fff; }
.stage-title { display: block; font-size: 1.02rem; font-weight: 650; line-height: 1.3; margin-bottom: .5em; }
.stage-desc { display: block; font-size: .93rem; color: var(--text-muted); line-height: 1.6; }

.stage-panels { margin-top: 20px; }
.stage-panel {
  margin: 0; padding: 24px;
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
  animation: panel-in .25s ease;
}
.stage-panel[hidden] { display: none; }
.stage-panel img { width: 100%; height: auto; margin: 0 auto; }
.stage-panel .fig-s1 { max-width: 640px; }
.stage-panel figcaption {
  max-width: 820px; margin: 18px auto 0;
  color: #5b6270; font-size: .92rem; line-height: 1.55; text-align: center;
}
@keyframes panel-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
  .stage, .stage-panel { transition: none; animation: none; }
}

.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 32px; margin-top: 16px; }
.two-col p { font-size: .96rem; }
.eq {
  overflow-x: auto; overflow-y: hidden; padding: 6px 12px; margin: 0 0 1em;
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  font-size: .92rem;
}


/* ---------- Stage 2 walkthrough ---------- */
.anim-panel { padding: 22px 22px 14px; }
.anim-svg { display: block; width: 100%; height: auto; }

.anim-caption { display: flex; align-items: baseline; gap: 14px; margin: 14px 4px 6px; color: #26323f; }
.anim-text { margin: 0; font-size: .95rem; line-height: 1.55; }
.anim-text strong { font-weight: 650; }
.anim-text span { color: #5d6c7b; }
.anim-pill {
  flex: none; font: 600 .7rem var(--mono); letter-spacing: .08em; text-transform: uppercase;
  padding: 3px 9px; border-radius: 999px; color: #4f7394; background: #e6eef6;
}
.anim-pill[data-kind="green"] { color: #3f6e50; background: #e8f1ea; }
.anim-pill[data-kind="orange"] { color: #a2602c; background: #fbeadc; }
.anim-eq { min-height: 3.1rem; display: grid; place-items: center; overflow-x: auto; color: #26323f; font-size: 1.05rem; padding: 2px 4px; }

.anim-scrub {
  --p: 0%;
  display: block; width: 100%; height: 18px; margin: 2px 0 10px; padding: 0; background: none; cursor: pointer;
  -webkit-appearance: none; appearance: none;
}
.anim-scrub:focus-visible { outline: 2px solid #0a4fb3; outline-offset: 4px; border-radius: 6px; }
/* track: filled part in the accent colour, thin gaps at the phase boundaries */
.anim-scrub::-webkit-slider-runnable-track {
  height: 5px; border-radius: 3px;
  background:
    linear-gradient(#fff, #fff) 25% 0 / 3px 100% no-repeat,
    linear-gradient(#fff, #fff) 50% 0 / 3px 100% no-repeat,
    linear-gradient(#fff, #fff) 75% 0 / 3px 100% no-repeat,
    linear-gradient(90deg, #0a4fb3 var(--p), #e3e8ee var(--p));
}
.anim-scrub::-moz-range-track {
  height: 5px; border-radius: 3px;
  background:
    linear-gradient(#fff, #fff) 25% 0 / 3px 100% no-repeat,
    linear-gradient(#fff, #fff) 50% 0 / 3px 100% no-repeat,
    linear-gradient(#fff, #fff) 75% 0 / 3px 100% no-repeat,
    linear-gradient(90deg, #0a4fb3 var(--p), #e3e8ee var(--p));
}
.anim-scrub::-webkit-slider-thumb {
  -webkit-appearance: none; width: 16px; height: 16px; margin-top: -5.5px; border-radius: 50%;
  background: #fff; border: 3px solid #0a4fb3; box-shadow: 0 1px 3px rgba(28, 43, 51, .25);
}
.anim-scrub::-moz-range-thumb {
  width: 11px; height: 11px; border-radius: 50%; background: #fff; border: 3px solid #0a4fb3; box-shadow: 0 1px 3px rgba(28, 43, 51, .25);
}
.anim-ctl { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 10px; }
.anim-steps, .anim-btns { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.anim-ctl button, .anim-ctl select {
  font: 500 .82rem var(--font); color: #26323f; background: #fff; cursor: pointer;
  padding: 6px 12px; border: 1px solid #dee3e9; border-radius: 8px;
}
.anim-ctl button:hover, .anim-ctl select:hover { border-color: #b7c2ce; }
.anim-steps button[aria-pressed="true"] { color: #fff; background: #0a4fb3; border-color: #0a4fb3; }
.anim-legend { display: flex; flex-wrap: wrap; gap: 6px 18px; margin: 14px 4px 0; font-size: .78rem; color: #5d6c7b; }
.anim-legend i { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 6px; }
.anim-legend .k-blue { background: #4f7394; } .anim-legend .k-green { background: #5b8a6a; } .anim-legend .k-orange { background: #c07a45; }
.anim-legend .muted { color: #8793a1; }


@media (max-width: 640px) {
  .anim-panel { padding: 14px 12px 10px; }
  .anim-caption { flex-direction: column; gap: 8px; }
}

/* ---------- results ---------- */
.results-row { display: grid; grid-template-columns: minmax(300px, 430px) 1fr; gap: 24px; align-items: stretch; margin-bottom: 8px; }
.card {
  display: flex; flex-direction: column; margin: 0;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 20px 24px 18px;
}
.card-title {
  margin: 0 0 16px; font: 500 .72rem var(--mono); letter-spacing: .09em; text-transform: uppercase; color: var(--text-muted);
}
.plot-card img { margin: auto 0; width: 100%; height: auto; background: #fff; border-radius: 6px; }
.plot-card figcaption { margin-top: 14px; text-align: left; font-size: .92rem; line-height: 1.55; color: var(--text-muted); }
.table-card .table-wrap { overflow-x: auto; margin: auto 0; }
.table-card .caption { margin-top: 14px; }
table.results { width: 100%; border-collapse: collapse; font-size: .92rem; font-variant-numeric: tabular-nums; }
table.results th, table.results td { padding: 9px 12px; text-align: center; white-space: nowrap; }
table.results th { font-weight: 600; border-bottom: 1px solid var(--border); }
table.results thead tr:first-child th { border-bottom: 1px solid var(--border); }
table.results td:first-child, table.results th:first-child { text-align: left; }
table.results tbody tr { border-bottom: 1px solid var(--border); }
table.results tr.sep { border-top: 2px solid var(--text-muted); }
table.results tr.ours-row { background: var(--accent-soft); }
table.results tr.ours-row td:first-child { font-weight: 650; color: var(--accent); }
.best { font-weight: 700; }
.second { text-decoration: underline; text-underline-offset: 3px; }

/* ---------- bibtex ---------- */
.bibtex { position: relative; }
.bibtex pre {
  margin: 0; padding: 20px; overflow-x: auto;
  background: var(--code-bg); border: 1px solid var(--border); border-radius: var(--radius);
  font-family: var(--mono); font-size: .84rem; line-height: 1.6;
}
.copy-btn {
  position: absolute; top: 10px; right: 10px;
  font: inherit; font-size: .8rem; font-weight: 600; cursor: pointer;
  padding: 4px 10px; border-radius: 6px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text);
}

/* ---------- footer ---------- */
.footer { padding: 32px 0 48px; text-align: center; font-size: .85rem; color: var(--text-muted); border-top: 1px solid var(--border); }

/* ---------- responsive ---------- */
@media (max-width: 860px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .stages, .two-col { grid-template-columns: 1fr; }
  .stages { gap: 10px; }
  .stage { padding: 16px 18px; }
  .stage.active::after { display: none; }
  .stage-panel { padding: 14px; }
  .results-row { grid-template-columns: 1fr; }
  .plot-card img { max-width: 360px; margin: 0 auto; }
}
@media (max-width: 640px) {
  body { font-size: 16px; }
  .section { padding: 44px 0; }
  .topnav-links { gap: 14px; }
  .brand { display: none; }
  .br-desktop { display: none; }
  .sync-grid { grid-template-columns: 1fr; }
  .abstract { text-align: left; }
}

/* Let grid children shrink below their content width (wide tables / equations scroll instead). */
.results-row > *, .two-col > *, .stages > *, .stats > * { min-width: 0; }

/* ---------- full-screen view of the walkthroughs (narrow screens only) ---------- */
.anim-top, .anim-close { display: none; }
.anim-expand, .anim-close {
  align-items: center; gap: 6px; cursor: pointer;
  font: 500 .82rem var(--font); color: #26323f; background: #fff;
  padding: 6px 12px; border: 1px solid #dee3e9; border-radius: 8px;
}
.anim-expand { display: inline-flex; }
@media (max-width: 700px) {
  .anim-top { display: flex; justify-content: flex-end; margin-bottom: 8px; }
}
html.anim-lock, html.anim-lock body { overflow: hidden; }
.anim.is-full {
  position: fixed; inset: 0; z-index: 300; display: flex; flex-direction: column; overflow: hidden;
  background: #fff; padding: max(10px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
}
.anim.is-full .anim-top, .anim.is-full .anim-desc, .anim.is-full .anim-eq, .anim.is-full .anim-legend { display: none; }
.anim.is-full .anim-stage { position: relative; flex: 1; min-height: 0; }
.anim.is-full .anim-svg { position: absolute; }
.anim.is-full .anim-caption { flex-direction: row; align-items: center; margin: 8px 0 4px; }
.anim.is-full .anim-text { flex: 1; min-width: 0; font-size: .85rem; line-height: 1.35; }
.anim.is-full .anim-close { display: inline-flex; flex: none; }
.anim.is-full .anim-ctl { gap: 6px; }
.anim.is-full .anim-ctl button, .anim.is-full .anim-ctl select { padding: 5px 9px; font-size: .78rem; }
