/* TSD project page. Light academic layout (Nerfies family).
   Colour carries meaning:
     blue   = temporal mean (what the teacher keeps)
     orange = deviations / motion, and our method
     red    = collapse / the DMD baseline */
:root {
  --text: #363636;
  --text-2: #4a4a4a;
  --muted: #6b6b6b;
  --line: #e3e3e3;
  --band: #f5f5f5;
  --link: #3273dc;
  --dark: #363636;
  --mean: #2a78b8;
  --dev: #a95206;
  --dev-mark: #e8830c;
  --dev-soft: #fff4e6;
  --bad: #c9354d;
  --bad-mark: #d6455d;
  --sans: 'Noto Sans', -apple-system, 'Segoe UI', Roboto, sans-serif;
  --display: 'Google Sans', 'Noto Sans', -apple-system, sans-serif;
  --math: Castoro, 'Times New Roman', serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 64px; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
body { margin: 0; background: #fff; color: var(--text); font-family: var(--sans); font-size: 16px; line-height: 1.6; -webkit-font-smoothing: antialiased; }
img, video, svg { display: block; max-width: 100%; }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
p { margin: 0 0 1em; }
sub, sup { line-height: 0; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--link); outline-offset: 2px; border-radius: 4px; }

.container { width: min(100% - 48px, 960px); margin-inline: auto; }
.container.wide { width: min(100% - 48px, 1240px); }
.center { text-align: center; justify-content: center; }

/* ---------- nav ---------- */
.navbar { position: sticky; top: 0; z-index: 30; background: rgba(255,255,255,.94); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.nav-inner { width: min(100% - 48px, 1240px); margin-inline: auto; display: flex; align-items: center; height: 52px; gap: 24px; }
.brand { font-family: var(--display); font-weight: 700; font-size: 20px; color: var(--text); letter-spacing: .02em; margin-right: auto; }
.brand:hover { text-decoration: none; }
.nav-wrap { position: relative; padding: 4px; border-radius: 999px; background: #f1f3f6; box-shadow: inset 0 0 0 1px rgba(20,30,50,.05); }
.nav-pill { position: absolute; left: 0; top: 4px; bottom: 4px; width: 0; border-radius: 999px; background: #fff; box-shadow: 0 1px 2px rgba(20,30,50,.10), 0 3px 10px rgba(20,30,50,.10); opacity: 0; transition: transform .38s cubic-bezier(.3,1.25,.4,1), width .38s cubic-bezier(.3,1.25,.4,1), opacity .2s; }
.nav-links { position: relative; display: flex; list-style: none; margin: 0; padding: 0; }
.nav-links a { display: flex; align-items: center; gap: 7px; height: 32px; padding: 0 13px; border-radius: 999px; color: #5a616b; font-family: var(--display); font-size: 14.5px; font-weight: 500; white-space: nowrap; transition: color .2s; }
.nav-links a:hover, .nav-links a.active { color: #14181f; text-decoration: none; }
.nav-links a:focus-visible { outline: 2px solid var(--link); outline-offset: 1px; }
.ni { width: 18px; height: 18px; flex: none; overflow: visible; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.ni * { transition: stroke .2s, fill .2s, transform .3s cubic-bezier(.3,1.4,.5,1); transform-box: fill-box; transform-origin: center; }
.ni .f { fill: currentColor; stroke: none; }
a:is(:hover, .active) > .ni .r { stroke: var(--bad-mark); }
a:is(:hover, .active) > .ni .b:not(.f) { stroke: var(--mean); }
a:is(:hover, .active) > .ni .o:not(.f) { stroke: var(--dev-mark); }
a:is(:hover, .active) > .ni .b.f { fill: var(--mean); }
a:is(:hover, .active) > .ni .o.f { fill: var(--dev-mark); }
@media (prefers-reduced-motion: no-preference) {
  a:hover > .ni-wave .r, a:hover > .ni-split :is(.b, .o) { stroke-dasharray: 1; animation: ni-draw .75s ease-out; }
  a:hover > .ni-slide .kn { animation: ni-slide .8s ease-in-out; }
  a:hover > .ni-grid .t1 { transform: scale(.94); }
  a:hover > .ni-grid :is(.t2, .t3) { animation: ni-pop .4s cubic-bezier(.3,1.4,.5,1) backwards; }
  a:hover > .ni-grid .t3 { animation-delay: .09s; }
  a:hover > .ni-brace .l { transform: translateX(-1.4px); }
  a:hover > .ni-brace .rr { transform: translateX(1.4px); }
}
@media (prefers-reduced-motion: reduce) { .nav-pill, .ni *, .nav-links .tx { transition: none; } }
@keyframes ni-draw { from { stroke-dashoffset: 1; } to { stroke-dashoffset: 0; } }
@keyframes ni-slide { 30% { transform: translateX(-4px); } 70% { transform: translateX(4px); } }
@keyframes ni-pop { from { transform: scale(.2); opacity: 0; } }

/* ---------- masthead ---------- */
.masthead { position: relative; text-align: center; padding: 64px 0 40px; overflow: hidden; }
.masthead .intro { position: relative; }
.pub-title { font-family: var(--display); font-weight: 500; font-size: clamp(30px, 4.2vw, 44px); line-height: 1.2; color: #363636; margin: 0 0 14px; letter-spacing: -.005em; }
.pub-title .sc { font-weight: 700; letter-spacing: .03em; }
.venue { font-family: var(--display); font-size: 22px; color: #4a4a4a; margin: 0 0 16px; }
.authors { font-family: var(--display); font-size: 19px; margin: 0 0 2px; }
.authors a { color: var(--link); }
.author, .affil { display: inline-block; white-space: nowrap; margin: 0 5px; }
.affil { margin: 0 10px; }
.authors sup, .affils sup { font-size: .65em; line-height: 0; margin-left: 1px; }
.affils sup { margin-right: 2px; }
.affils { font-family: var(--display); font-size: 17px; color: var(--text-2); margin: 0 0 20px; }
.pub-links { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.pill { display: inline-flex; align-items: center; gap: 8px; height: 40px; padding: 0 20px; border-radius: 999px; background: var(--dark); color: #fff; font-family: var(--display); font-size: 16px; }
.pill svg { width: 16px; height: 16px; }
.pill:hover { background: #222; text-decoration: none; color: #fff; }
.pill[aria-disabled="true"] { cursor: default; background: transparent; color: var(--text-2); box-shadow: inset 0 0 0 1px #cfcfcf; }
.pill[aria-disabled="true"]:hover { background: transparent; color: var(--text-2); }
.pill[aria-disabled="true"]::after { content: "soon"; font-size: 11px; letter-spacing: .04em; text-transform: uppercase; opacity: .7; }

/* ---------- teaser ---------- */
.teaser { padding: 12px 0 8px; }
.teaser-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.teaser-grid figure { margin: 0; position: relative; aspect-ratio: 832 / 480; background: #111; border-radius: 4px; overflow: hidden; }
.teaser-grid video { width: 100%; height: 100%; object-fit: cover; }
.teaser-grid .p { position: absolute; inset: auto 0 0 0; padding: 18px 10px 8px; font-size: 12.5px; line-height: 1.35; color: #fff; background: linear-gradient(transparent, rgba(0,0,0,.72)); opacity: 0; transition: opacity .2s; }
.teaser-grid figure:hover .p, .teaser-grid figure:focus-within .p { opacity: 1; }
.teaser-cap { max-width: 860px; margin: 14px auto 0; text-align: center; font-size: 15.5px; color: var(--text-2); }

/* ---------- sections ---------- */
.section { padding: 48px 0; }
.section.band { background: var(--band); }
.title { font-family: var(--display); font-weight: 500; font-size: 30px; line-height: 1.2; color: #363636; text-align: center; margin: 0 0 24px; }
.title.left { text-align: left; }
.subtitle { font-family: var(--display); font-weight: 500; font-size: 22px; color: #363636; margin: 44px 0 12px; }
.content { text-align: justify; }
.content.narrow { max-width: 900px; margin-inline: auto; text-align: center; }
.content ul { padding-left: 1.3em; margin: 0 0 1em; }
.content li { margin-bottom: .45em; }
.note-sm { font-size: 13.5px; color: var(--muted); line-height: 1.5; margin-top: 10px; }
.note-sm.top { margin-top: -4px; }
.k-mean { color: var(--mean); font-weight: 600; }
.k-dev { color: var(--dev); font-weight: 600; }
.m, .math { font-family: var(--math); font-style: italic; }

.tldr { max-width: 960px; background: #f6f8fb; border-left: 4px solid var(--link); border-radius: 0 8px 8px 0; padding: 16px 22px; margin: 28px auto 40px; font-size: 16.5px; }
.tldr p { margin: 0; }

/* ---------- players ---------- */
.player { margin: 0; min-width: 0; }
.player .lbl { display: flex; align-items: baseline; gap: 8px; font-family: var(--display); font-size: 16px; font-weight: 500; margin-bottom: 6px; color: #363636; }
.player .lbl .it { color: var(--muted); font-weight: 400; font-size: 14px; }
.player.ours .lbl .name { color: var(--dev); font-weight: 700; }
.player.fail .lbl .name { color: var(--bad); }
.player .media { position: relative; aspect-ratio: 832 / 480; background: #111; border-radius: 6px; overflow: hidden; }
.player.ours .media { box-shadow: 0 0 0 2px var(--dev-mark); }
.player video { width: 100%; height: 100%; object-fit: cover; }
.player .note { font-size: 14px; line-height: 1.45; color: var(--text-2); margin: 7px 0 0; }
.tag { font-family: var(--display); font-size: 12px; font-weight: 500; line-height: 1; padding: 3px 7px; border-radius: 4px; }
.tag.ours { background: var(--dev-soft); color: var(--dev); }
.tag.fail { background: #fdecef; color: var(--bad); }

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

/* transport */
.transport { display: flex; align-items: center; gap: 12px; margin-top: 12px; }
.transport button { flex: none; width: 34px; height: 34px; border-radius: 50%; border: 1px solid #cfcfcf; background: #fff; display: grid; place-items: center; cursor: pointer; }
.transport button:hover { border-color: #888; }
.transport svg { width: 12px; height: 12px; fill: var(--dark); }
.transport input[type=range] { flex: 1; height: 24px; accent-color: var(--dark); cursor: pointer; }
.transport .t { flex: none; width: 46px; text-align: right; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }

/* chips & toggles */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 18px 0 18px; }
.chip, .seg button { border: 1px solid #dbdbdb; background: #fff; color: var(--text); border-radius: 999px; padding: 5px 15px; font-family: var(--display); font-size: 14.5px; cursor: pointer; }
.chip:hover, .seg button:hover:not(:disabled) { border-color: #9a9a9a; }
.chip[aria-pressed="true"], .seg button[aria-pressed="true"] { background: var(--dark); border-color: var(--dark); color: #fff; }
.seg { display: inline-flex; gap: 6px; flex: none; }
.seg button:disabled { opacity: .4; cursor: not-allowed; }

/* ---------- collapse ---------- */

.type { background: #fff; border-radius: 10px; padding: 22px 24px 20px; margin-top: 18px; border: 1px solid var(--line); }
.type-head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 4px; }
.type-head .idx { font-family: var(--display); font-size: 15px; color: var(--muted); }
.type h4 { font-family: var(--display); font-weight: 500; font-size: 20px; margin: 0; color: var(--bad); }
.type .desc { color: var(--text-2); margin: 0 0 16px; }
.type .prompt { font-size: 13.5px; color: var(--muted); font-style: italic; margin: 10px 0 0; }

/* ---------- method ---------- */
.equation { margin-top: 8px; }
.eq-row { display: grid; grid-template-columns: 1fr auto 1fr auto 1fr; align-items: start; gap: 10px; }
.eq-cell { margin: 0; min-width: 0; }
.eq-cell .media { aspect-ratio: 832 / 480; background: #111; border-radius: 6px; overflow: hidden; }
.eq-cell video, .eq-cell img { width: 100%; height: 100%; object-fit: cover; }
.eq-cell figcaption { text-align: center; font-size: 14.5px; color: var(--text-2); margin-top: 8px; }
.eq-cell .math { font-size: 18px; margin-right: 4px; }
.op { font-family: var(--math); font-size: 34px; color: #555; align-self: center; margin-top: -30px; }
.equation .chips { margin: 14px 0 4px; }
#eq-src { margin: 4px 0 0; }


.diagram { margin: 18px 0 0; }
.diagram-frame { border: 1px solid var(--line); border-radius: 8px; padding: 8px; background: #fff; }
.diagram svg { width: 100%; height: auto; }
.diagram figcaption { font-size: 14px; color: var(--muted); margin-top: 10px; text-align: center; }
.diagram .swipe { display: none; font-size: 12.5px; color: var(--muted); text-align: right; margin: 0 2px 6px; }
@media (min-width: 761px) {
  .diagram { margin-inline: calc((100% - min(100vw - 48px, 1240px)) / 2); }
  .diagram figcaption { max-width: 960px; margin-inline: auto; }
}
.nw { white-space: nowrap; }

.terms { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin: 26px 0 22px; }
.term { border-top: 3px solid; padding-top: 10px; }
.term.t-mean { border-color: var(--mean); }
.term.t-dev { border-color: var(--dev-mark); }
.term h4 { font-family: var(--display); font-weight: 500; font-size: 17px; margin: 0 0 4px; }
.term.t-mean h4 { color: var(--mean); }
.term.t-dev h4 { color: var(--dev); }
.term .math-line { font-family: var(--math); font-style: italic; font-size: 16px; margin: 0 0 6px; white-space: nowrap; overflow-x: auto; }
.term p { font-size: 14.5px; line-height: 1.5; color: var(--text-2); margin: 0; }

/* ---------- comparisons ---------- */
.scene-tabs { list-style: none; margin: 8px 0 22px; padding: 6px 6px 8px; display: flex; gap: 10px; overflow-x: auto; justify-content: safe center; }
.scene-tabs li { flex: 0 1 116px; min-width: 76px; }
.scene-tabs button { display: block; width: 100%; padding: 0; border: 0; background: none; cursor: pointer; text-align: center; }
.scene-tabs img { width: 100%; aspect-ratio: 832 / 480; object-fit: cover; border-radius: 6px; opacity: .62; transition: opacity .15s; outline: 2px solid transparent; outline-offset: 2px; }
.scene-tabs button:hover img { opacity: 1; }
.scene-tabs button[aria-current="true"] img { opacity: 1; outline-color: var(--dark); }
.scene-tabs .nm { display: block; font-family: var(--display); font-size: 14px; margin-top: 6px; color: var(--text-2); }
.scene-tabs button[aria-current="true"] .nm { color: #111; font-weight: 700; }
.stage { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 18px 20px 16px; }
.stage .prompt { margin: 0; font-style: italic; color: var(--text-2); }
.headline { margin: 12px 0 0; text-align: center; font-size: 15.5px; }



/* ---------- bibtex ---------- */
.bib-wrap { position: relative; }
pre { background: var(--band); border-radius: 6px; padding: 18px 22px; overflow-x: auto; font-size: 14px; line-height: 1.55; margin: 0; }
pre code { font-family: ui-monospace, Menlo, Consolas, monospace; color: #363636; }
.copy { position: absolute; top: 10px; right: 10px; border: 1px solid #d0d0d0; background: #fff; border-radius: 6px; padding: 3px 12px; font-size: 13px; cursor: pointer; }

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


/* ---------- responsive ---------- */
@media (max-width: 1000px) {
  .terms { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 760px) {
  .nav-inner { width: min(100% - 28px, 1240px); gap: 8px; }
  .nav-links a { font-size: 13px; padding: 0 11px; gap: 0; height: 34px; }
  .nav-links .tx { max-width: 0; opacity: 0; overflow: hidden; transition: max-width .3s ease, opacity .2s, margin .3s; }
  .nav-links a.active .tx { max-width: 120px; opacity: 1; margin-left: 6px; }
  .scene-tabs { justify-content: safe center; }
  .container, .container.wide { width: min(100% - 28px, 960px); }
  .masthead { padding-top: 36px; }
  .pub-title br { display: none; }
  .venue { font-size: 18px; }
  .teaser-grid { grid-template-columns: 1fr 1fr; }
  .section { padding: 36px 0; }
  .title { font-size: 25px; }
  .subtitle { font-size: 19px; margin-top: 34px; }
  .content { text-align: left; }
  .type { padding: 16px 14px; }
  .duo { gap: 10px; }
  .player .note { font-size: 13px; }
  .player .lbl { flex-wrap: wrap; gap: 2px 6px; font-size: 14.5px; }
  .player .lbl .it { font-size: 12.5px; }
  .tag.fail { display: none; }
  .eq-row { grid-template-columns: 1fr; }
  .op { margin: -6px 0; text-align: center; font-size: 26px; }
  .diagram-frame { overflow-x: auto; overscroll-behavior-x: contain; -webkit-mask-image: linear-gradient(90deg,#000 80%,transparent); mask-image: linear-gradient(90deg,#000 80%,transparent); }
  .diagram-frame.end { -webkit-mask-image: none; mask-image: none; }
  .diagram-frame svg { width: 960px; max-width: none; }
  .diagram .swipe { display: block; }
  .terms { grid-template-columns: 1fr; }
  .stage { padding: 12px; }
}

/* =================== motion =================== */
/* masthead signal lines: kept out from behind the title by a soft mask */
.waves { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none;
  -webkit-mask-image: radial-gradient(ellipse 46% 58% at 50% 46%, transparent 0 42%, #000 92%);
          mask-image: radial-gradient(ellipse 46% 58% at 50% 46%, transparent 0 42%, #000 92%); }

/* one orchestrated load: title block rises, then the teaser wall wipes in left to right */
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes wipe { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0 0 0 0); } }
.intro > * { animation: rise .8s cubic-bezier(.2,.7,.2,1) both; }
.intro > :nth-child(2) { animation-delay: .08s; }
.intro > :nth-child(3) { animation-delay: .16s; }
.intro > :nth-child(4) { animation-delay: .22s; }
.intro > :nth-child(5) { animation-delay: .28s; }
.teaser-grid figure { animation: wipe .9s cubic-bezier(.65,0,.25,1) backwards; animation-delay: calc(.45s + var(--i, 0) * 70ms); }
.teaser-grid video { transition: transform .5s cubic-bezier(.2,.7,.2,1); }
.teaser-grid figure:hover video, .teaser-grid figure:focus-within video { transform: scale(1.045); }

/* nav progress + current section */
.progress { position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; background: linear-gradient(90deg, var(--mean), var(--dev-mark)); transform-origin: 0 50%; transform: scaleX(0); }

/* buttons */
.pill { transition: transform .2s, background-color .2s, box-shadow .2s; }
.pill:not([aria-disabled="true"]):hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(0,0,0,.18); }

/* DMD 1K -> 3K: training arrow between the two clips */
.duo.pair { grid-template-columns: 1fr 64px 1fr; gap: 10px; }
.train-arrow { align-self: center; display: grid; justify-items: center; gap: 6px; margin-top: 10px; color: var(--muted); }
.train-arrow .chev { display: flex; gap: 2px; }
.train-arrow .chev i { width: 10px; height: 10px; border-right: 2.5px solid var(--bad-mark); border-top: 2.5px solid var(--bad-mark); transform: rotate(45deg); opacity: .2; animation: chev 1.4s infinite; }
.train-arrow .chev i:nth-child(2) { animation-delay: .2s; }
.train-arrow .chev i:nth-child(3) { animation-delay: .4s; }
@keyframes chev { 0%, 100% { opacity: .2; } 30% { opacity: 1; } }
.train-arrow .txt { font-family: var(--display); font-size: 12px; line-height: 1.25; text-align: center; }

/* decomposition: mean and deviations peel off the video */
.eq-row { position: relative; }
.eq-cell { transition: transform 1s cubic-bezier(.65,0,.25,1), opacity .6s ease; }
.eq-cell:nth-of-type(3) { transition-delay: .12s; }
.eq-row .eq-cell:first-child { position: relative; z-index: 2; }
.eq-row.pre .eq-cell:not(:first-child) { transform: translate(var(--dx, 0), var(--dy, 0)); opacity: 0; }
.eq-cell figcaption { transition: opacity .35s ease .95s; }
.eq-row.pre .eq-cell:not(:first-child) figcaption { opacity: 0; transition: none; }
.op { transition: opacity .5s ease .75s, transform .6s cubic-bezier(.3,1.6,.5,1) .75s; }
.eq-row.pre .op { opacity: 0; transform: scale(.3); }
.eq-cell .media { transition: opacity .22s; }
.eq-row.swap .media { opacity: .12; }

/* diagram: sweeps in along the time axis, then signal dots flow */
.diagram.arm:not(.in) svg { clip-path: inset(0 100% 0 0); }
.diagram.in svg { clip-path: inset(0 0 0 0); transition: clip-path 1.8s cubic-bezier(.65,0,.25,1); }
.diagram .flow { opacity: 0; transition: opacity .6s ease 1.6s; }
.diagram.in .flow { opacity: 1; }
.diagram.still .flow { display: none; }

/* comparisons: the four players arrive one after another */
.scene-tabs img { transition: opacity .15s, transform .25s cubic-bezier(.2,.7,.2,1); }
.scene-tabs button:hover img { transform: translateY(-2px); }

@media (max-width: 760px) {
  .duo.pair { grid-template-columns: 1fr 22px 1fr; gap: 6px; }
  .train-arrow .txt { display: none; }
  .train-arrow .chev { gap: 0; }
  .train-arrow .chev i { width: 6px; height: 6px; border-width: 2px; margin-left: -2px; }
  .train-arrow .chev i:first-child { margin-left: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .intro > *, .teaser-grid figure, .train-arrow .chev i { animation: none; }
  .train-arrow .chev i { opacity: .8; }
  .diagram svg, .diagram.in svg { clip-path: none; transition: none; }
  .eq-cell, .op, .eq-cell .media, .teaser-grid video { transition: none; }
}

@media (max-width: 760px) {
  .waves { -webkit-mask-image: linear-gradient(#000 0, transparent 9%, transparent 66%, #000 80%);
                   mask-image: linear-gradient(#000 0, transparent 9%, transparent 66%, #000 80%); }
}
/* hold the load animation until the title font is in (see the inline script in index.html) */
.fp .intro > *, .fp .teaser-grid figure { animation-play-state: paused; }
@media print {
  .diagram svg { clip-path: none !important; transition: none !important; }
  .diagram .flow, .waves, .navbar { display: none; }
  .eq-row.pre .eq-cell, .eq-row.pre .op { transform: none !important; opacity: 1 !important; transition: none !important; }
}
.prompt-line { font-style: italic; margin-top: 8px; }

/* =================== comparisons: before/after video slider =================== */
.stage .prompt { text-align: center; margin: 0 0 12px; }
.stage-ctrl { display: flex; align-items: center; justify-content: space-between; gap: 12px; max-width: 1000px; margin: 0 auto 12px; }
.ba { --pos: 50%; position: relative; max-width: 1000px; margin: 0 auto; aspect-ratio: 832 / 480; border-radius: 8px; overflow: hidden; background: #111; cursor: ew-resize; touch-action: pan-y; user-select: none; -webkit-user-select: none; }
.ba-after, .ba-before { position: absolute; inset: 0; }
.ba-before { clip-path: inset(0 calc(100% - var(--pos)) 0 0); }
.ba video { width: 100%; height: 100%; object-fit: cover; pointer-events: none; }
.ba-lbl { position: absolute; bottom: 14px; padding: 5px 10px; border-radius: 4px; background: rgba(0,0,0,.62); color: #fff; font-family: var(--display); font-size: 14px; line-height: 1.2; white-space: nowrap; }
.ba-lbl.l { left: 14px; }
.ba-lbl.r { right: 14px; }
.ba-lbl .o { margin-left: 6px; padding: 1px 6px; border-radius: 3px; background: var(--dev-mark); color: #fff; font-size: 11.5px; }
.ba-line { position: absolute; top: 0; bottom: 0; left: var(--pos); width: 2px; margin-left: -1px; background: #fff; box-shadow: 0 0 6px rgba(0,0,0,.35); pointer-events: none; }
.ba-handle { pointer-events: auto; position: absolute; top: 50%; left: 50%; width: 44px; height: 44px; margin: -22px 0 0 -22px; border-radius: 50%; border: 2px solid #fff; background: rgba(0,0,0,.28); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); cursor: ew-resize; padding: 0; transition: transform .15s; }
.ba.drag .ba-handle, .ba-handle:hover { transform: scale(1.08); }
.ba-handle i { position: absolute; top: 50%; margin-top: -5px; border: 5px solid transparent; }
.ba-handle i:first-child { left: 1px; border-right-color: #fff; }
.ba-handle i:last-child { right: 1px; border-left-color: #fff; }
.ba-handle:focus-visible { outline: 3px solid var(--link); outline-offset: 2px; }
.ba-caps { display: flex; justify-content: space-between; gap: 24px; max-width: 1000px; margin: 8px auto 0; font-size: 14px; color: var(--text-2); }
.ba-caps p { margin: 0; flex: 1; }
.ba-caps p:last-child { text-align: right; }
.ba-caps b { font-family: var(--display); font-weight: 500; margin-right: 4px; }
.stage .transport { max-width: 1000px; margin-inline: auto; }
.ba.enter video { animation: fadein .45s ease both; }
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }
@media (max-width: 760px) {
  .stage-ctrl { flex-wrap: wrap; justify-content: center; }
  .stage-ctrl #iter-seg { order: 3; }
  .ba-lbl { bottom: 8px; font-size: 12px; padding: 3px 7px; }
  .ba-lbl.l { left: 8px; } .ba-lbl.r { right: 8px; }
  .ba-lbl .o { display: none; }
  .ba-handle { width: 36px; height: 36px; margin: -18px 0 0 -18px; }
  .ba-caps { font-size: 12.5px; gap: 12px; }
}
@media (prefers-reduced-motion: reduce) { .ba.enter video { animation: none; } .ba-handle { transition: none; } }

/* =================== title ripple =================== */
.pub-title .w { display: inline-block; white-space: nowrap; }
.pub-title .ch { display: inline-block; }
.pub-title.ripple .ch { animation: ripple .8s cubic-bezier(.3,.7,.3,1) both; animation-delay: calc(1.75s + var(--i) * 14ms); }
.pub-title .nw { white-space: nowrap; }
.pub-title.again .ch { animation: ripple 1s cubic-bezier(.3,.7,.3,1) both; animation-delay: calc(var(--i) * 18ms); }
@keyframes ripple {
  0% { transform: none; color: inherit; }
  28% { transform: translateY(-8px); color: var(--dev-mark); }
  58% { transform: translateY(2px); color: var(--mean); }
  100% { transform: none; color: inherit; }
}
.fp .pub-title .ch { animation-play-state: paused; }

/* =================== teaser tilt =================== */
.teaser-grid { perspective: none; }
.teaser-grid figure { --rx: 0deg; --ry: 0deg; transform: perspective(900px) rotateX(var(--rx)) rotateY(var(--ry)); transition: transform .35s cubic-bezier(.2,.7,.2,1), box-shadow .35s; will-change: transform; backface-visibility: hidden; }
.teaser-grid figure.tilt { z-index: 2; transition: transform .08s linear, box-shadow .35s; box-shadow: 0 22px 40px -18px rgba(0,0,0,.45); }
.teaser-grid figure::after { content: ""; position: absolute; inset: 0; pointer-events: none; opacity: 0; transition: opacity .3s;
  background: radial-gradient(circle at var(--gx, 50%) var(--gy, 50%), rgba(255,255,255,.45), rgba(255,255,255,.12) 30%, transparent 60%); }
.teaser-grid figure.tilt::after { opacity: 1; }

/* =================== frame stack =================== */
.stack-scene { --sw: min(520px, 64vw); position: relative; margin: 6px 0 26px; overflow-x: clip; }
.stack-scene.pinned { height: calc(130vh + 470px); }
.stack-sticky { display: grid; justify-items: center; align-content: center; gap: 64px; padding: 24px 0; }
.stack-scene.pinned .stack-sticky { position: sticky; top: max(64px, calc(50vh - 210px)); }
.stack-scene.pinned .stack-stage { width: min(var(--sw), calc((100vh - 52px) * .75)); }
.stack-scene:not(.pinned) .stack-sticky { padding-top: calc(var(--sw) * .36); }
.stack-stage { perspective: 1500px; width: var(--sw); aspect-ratio: 832 / 480; }
.stack { position: relative; width: 100%; height: 100%; transform-style: preserve-3d; will-change: transform; }
.stack .card { position: absolute; inset: 0; border-radius: 6px; overflow: hidden; background: #111; outline: 2px solid rgba(255,255,255,.9); outline-offset: -2px; will-change: transform, opacity; }
.stack .card img { width: 100%; height: 100%; object-fit: cover; display: block; }
.stack .card .t { position: absolute; left: 8px; top: 8px; font-family: var(--display); font-size: 12px; color: #fff; background: rgba(0,0,0,.5); padding: 2px 6px; border-radius: 3px; transition: opacity .3s; }
.stack.merged .card { outline-color: transparent; }
.stack.merged .card .t { opacity: 0; }
.stack-cap { position: relative; width: min(640px, 90vw); height: 3.2em; text-align: center; font-size: 17px; }
.stack-cap p { position: absolute; inset: 0; margin: 0; opacity: 0; transform: translateY(8px); transition: opacity .15s, transform .15s; }
.stack-cap p.on { opacity: 1; transform: none; transition: opacity .3s .15s, transform .3s .15s; }
.stack-replay { display: none; margin-top: -6px; border: 1px solid #cfcfcf; background: #fff; border-radius: 999px; padding: 3px 14px; font-family: var(--display); font-size: 13.5px; color: var(--text-2); cursor: pointer; }
.stack-scene:not(.pinned):not(.static) .stack-replay { display: inline-block; }
.stack-scene:not(.pinned):not(.static) { cursor: pointer; }
.stack-scene.static .stack-cap { height: auto; }
.stack-scene.static .stack-cap p { position: static; display: inline; opacity: 1; transform: none; }
.stack-scene.static .stack-cap p + p::before { content: " "; }

/* =================== diagram <-> cards =================== */
#diagram .tg { transition: opacity .2s; }
#diagram .tg rect { pointer-events: all; }
#diagram.linking .tg:not(.hot) { opacity: .35; }
#diagram.linking .tg[data-term="ts"]:not(.hot) { opacity: .55; }
#diagram .tg.hot rect { filter: drop-shadow(0 0 10px rgba(232,131,12,.75)); }
#diagram .tg[data-term="ia"].hot rect { filter: drop-shadow(0 0 10px rgba(42,120,184,.75)); }
.term:focus-visible { outline: 2px solid var(--link); outline-offset: 4px; }
.term { transition: opacity .2s, transform .2s; }
.terms.linking .term:not(.hot) { opacity: .4; }
.terms .term.hot { transform: translateY(-3px); }

@media (prefers-reduced-motion: reduce) {
  .teaser-grid figure, .term { transition: none; }
}
@media print {
  .stack-scene { display: none; }
  .diagram-frame { overflow: visible; -webkit-mask-image: none; mask-image: none; }
  .diagram-frame svg { width: 100%; max-width: 100%; }
  .diagram .swipe { display: none; }
  .diagram { break-inside: avoid; }
  .eq-row.pre figcaption { opacity: 1 !important; transition: none !important; }
}
@media (max-width: 899px) { .stack-scene { --sw: min(520px, 76vw); } .stack-sticky { padding-bottom: 8px; gap: 44px; } }

/* =================== gallery (one row; the active tile opens) =================== */
.gallery { --h: clamp(220px, 27vw, 360px); display: flex; gap: 10px; margin-top: 8px; height: var(--h); }
/* The active tile is exactly one uncropped frame wide; the rest share what is left (flex keeps the sum exact
   mid-transition). The video inside never changes size: it is only uncovered. */
.gallery .g-tile { --open: calc(var(--h) * 832 / 480); flex: 1 1 auto; min-width: 0; aspect-ratio: auto; height: 100%; width: calc((100% - var(--open) - 30px) / 3); transition: width .35s cubic-bezier(.3,.7,.2,1); }
.gallery .g-tile.on { width: var(--open); }
.gallery .g-tile video { position: absolute; left: 50%; top: 0; width: var(--open); max-width: none; height: 100%; margin-left: calc(var(--open) / -2); pointer-events: none; }
.gallery .g-tile .p { width: var(--open); }
.gallery .g-tile:not(.on) .p, .gallery .g-tile:not(.on) .zoom { opacity: 0; }
.g-tile { position: relative; margin: 0; border-radius: 10px; overflow: hidden; background: #111; aspect-ratio: 832 / 480; cursor: zoom-in; }
.g-tile:focus-visible { outline-offset: -3px; }
.g-tile video { width: 100%; height: 100%; object-fit: cover; transition: transform .6s cubic-bezier(.2,.7,.2,1); }
.g-tile:hover video, .g-tile:focus-visible video { transform: scale(1.04); }
.g-tile .p { position: absolute; inset: auto 0 0 0; padding: 28px 14px 12px; font-size: 13.5px; line-height: 1.4; color: #fff; background: linear-gradient(transparent, rgba(0,0,0,.75)); opacity: 0; transform: translateY(6px); transition: opacity .25s, transform .25s; }
.g-tile:hover .p, .g-tile:focus-visible .p { opacity: 1; transform: none; }
.g-tile .zoom { position: absolute; right: 10px; top: 10px; width: 30px; height: 30px; border-radius: 50%; background: rgba(0,0,0,.45); opacity: 0; transition: opacity .25s; }
.g-tile .zoom::before, .g-tile .zoom::after { content: ""; position: absolute; left: 50%; top: 50%; background: #fff; }
.g-tile .zoom::before { width: 12px; height: 2px; margin: -1px 0 0 -6px; }
.g-tile .zoom::after { width: 2px; height: 12px; margin: -6px 0 0 -1px; }
.g-tile:hover .zoom, .g-tile:focus-visible .zoom { opacity: 1; }
.teaser-grid figure { cursor: zoom-in; }
@media (max-width: 760px) {
  .gallery { display: flex; gap: 8px; height: auto; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; }
  .gallery::-webkit-scrollbar { display: none; }
  .gallery .g-tile { flex: 0 0 80vw; width: 80vw; height: auto; aspect-ratio: 832 / 480; scroll-snap-align: center; }
  .gallery .g-tile.on { width: 80vw; }
  .gallery .g-tile video { position: static; width: 100%; margin: 0; }
  .g-tile .p { display: none; }
}

/* =================== lightbox =================== */
.lb { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; }
.lb[hidden] { display: none; }
.lb-bg { position: absolute; inset: 0; background: rgba(12,14,18,.9); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); opacity: 0; transition: opacity .35s; }
.lb.on .lb-bg { opacity: 1; }
.lb-fig { position: relative; margin: 0; width: min(92vw, calc((100vh - 140px) * 832 / 480), 1280px); }
.lb-media { aspect-ratio: 832 / 480; border-radius: 8px; overflow: hidden; background: #000; transform-origin: 0 0; box-shadow: 0 30px 80px -20px rgba(0,0,0,.7); }
.lb-media video { width: 100%; height: 100%; object-fit: cover; display: block; }
.lb-fig figcaption { margin-top: 14px; color: #e8e8e8; font-size: 15px; line-height: 1.5; opacity: 0; transition: opacity .3s .2s; display: flex; gap: 10px; align-items: baseline; }
.lb.on .lb-fig figcaption { opacity: 1; }
.lb-tag { flex: none; font-family: var(--display); font-size: 12px; padding: 2px 7px; border-radius: 4px; background: var(--dev-mark); color: #fff; }
.lb-close, .lb-prev, .lb-next { position: absolute; border: 0; background: rgba(255,255,255,.12); color: #fff; width: 46px; height: 46px; border-radius: 50%; font-size: 28px; line-height: 1; cursor: pointer; opacity: 0; transition: opacity .3s, background-color .2s; }
.lb.on .lb-close, .lb.on .lb-prev, .lb.on .lb-next { opacity: 1; }
.lb-close:hover, .lb-prev:hover, .lb-next:hover { background: rgba(255,255,255,.25); }
.lb-close { top: 18px; right: 18px; }
.lb-prev { left: 18px; top: 50%; margin-top: -23px; }
.lb-next { right: 18px; top: 50%; margin-top: -23px; }
.lb button:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
html.lb-open { overflow: hidden; }
@media (max-width: 760px) { .lb-prev, .lb-next { top: auto; bottom: 18px; margin: 0; } .lb-fig figcaption { font-size: 13px; } }
@media (prefers-reduced-motion: reduce) {
  .g-tile video, .gallery .g-tile { transition: none; }
  .lb-bg, .lb-fig figcaption, .lb button { transition: none; }
}
@media print { .lb { display: none; } }

/* =================== teaser as a bento wall =================== */
.teaser-grid { grid-template-columns: repeat(6, 1fr); gap: 8px; }
.teaser-grid figure { grid-column: span var(--span, 2); border-radius: 8px; }
.teaser-grid figure.feature { grid-row: span 2; aspect-ratio: auto; }
.teaser-grid .p .txt, .g-tile .p .txt { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; overflow: hidden; }
#eq-chips[hidden] { display: none; }
@media (max-width: 760px) {
  .teaser-grid { grid-template-columns: 1fr 1fr; gap: 6px; }
  .teaser-grid figure { grid-column: span 1; }
  .teaser-grid figure.feature { grid-column: span 2; grid-row: auto; aspect-ratio: 832 / 480; }
}

.lb-prompt { max-height: 4.5em; overflow-y: auto; }
@media (max-height: 820px) { .lb-fig { width: min(88vw, calc((100vh - 190px) * 832 / 480), 1280px); } }
@media (max-height: 500px) { .lb-fig { width: min(80vw, calc((100vh - 90px) * 832 / 480)); } .lb-prompt { max-height: 3em; } .lb-fig figcaption { margin-top: 8px; font-size: 12.5px; } }
@media (max-width: 760px) { .teaser-grid .p { display: none; } }

@media (max-width: 370px) {
  .nav-inner { width: calc(100% - 20px); gap: 6px; }
  .nav-links a { padding: 0 5px; font-size: 12.5px; }
  .brand { font-size: 18px; }
  .nav-links a.active .tx { margin-left: 5px; }
}
