/* ==========================================================================
   CLAP project page
   Design system adapted from the Flex-π project page (flex-pi.github.io):
   dark tokens are the authored base, a complete [data-theme="day"] layer
   overrides them, and the page ships "day" (cream paper, near-black ink).
   Source Serif 4 for body and headings, JetBrains Mono for metadata, a
   claret accent, 4px radii. See footer for attribution.
   ========================================================================== */

/* ---------- base (night) tokens ---------- */
:root {
  /* ground */
  --bg: #0c0c0c;
  --bg-raise: #141414;
  --muted: #191919;
  --fg: #ffffff;
  --fg-muted: rgba(255, 255, 255, .74);
  --fg-dim: rgba(255, 255, 255, .56);
  --fg-faint: rgba(255, 255, 255, .38);
  --border: rgba(255, 255, 255, .20);
  --border-soft: rgba(255, 255, 255, .11);
  --border-faint: rgba(255, 255, 255, .065);
  --surface: rgba(255, 255, 255, .028);
  --surface-2: rgba(255, 255, 255, .06);
  --surface-3: rgba(255, 255, 255, .11);

  /* accents */
  --primary: #d15619;
  --primary-ink: #e8874f;
  --primary-soft: rgba(209, 86, 25, .18);
  --figure-cream: #f6f6ef;
  --figure-black: #0c0c0c;
  --plate-bg: var(--figure-cream);

  /* hero stage is dark in BOTH themes */
  --stage-bg: #050505;

  /* type */
  --ff-body: "Source Serif 4", Georgia, "Times New Roman", serif;
  --ff-display: "Source Serif 4", Georgia, serif;
  --ff-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  /* ONE metadata scale for the whole page. */
  --fs-meta: 11px;
  --ls-meta: .08em;
  --fs-fine: 13px;

  /* measure */
  --col-text: 812px;
  --col-mid: 940px;
  --col-wide: 1140px;
  --col-full: 1340px;
  --pad: clamp(18px, 4vw, 44px);
  --measure: calc(var(--col-text) - 2 * var(--pad));
  --gap-sec: clamp(60px, 7.5vw, 112px);

  --radius: 4px;
  --radius-pill: 999px;
  --ease: cubic-bezier(.22, .61, .36, 1);

  --rail-w: 176px;
  --rail-gap: 44px;
  --rail-shift: 0px;
}

/* ---------- day layer: the shipped theme ---------- */
[data-theme="day"] {
  --bg: #f6f6ef;
  --bg-raise: #ffffff;
  --muted: #ecece2;
  --fg: #0c0c0c;
  --fg-muted: rgba(12, 12, 12, .78);
  --fg-dim: rgba(12, 12, 12, .60);
  --fg-faint: rgba(12, 12, 12, .42);
  --border: rgba(12, 12, 12, .22);
  --border-soft: rgba(12, 12, 12, .13);
  --border-faint: rgba(12, 12, 12, .085);
  --surface: rgba(12, 12, 12, .028);
  --surface-2: rgba(12, 12, 12, .055);
  --surface-3: rgba(12, 12, 12, .10);

  --primary: #d15619;
  --primary-ink: #d15619;
  --primary-soft: rgba(209, 86, 25, .08);
  --plate-bg: #ffffff;
}

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

html {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--ff-body);
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  scroll-padding-top: 76px;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--fg);
  font-size: 19px;
  line-height: 1.62;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1,
h2,
h3,
h4,
h5,
h6 {
  margin: 0;
  font-weight: 600;
  font-family: var(--ff-display);
}

p {
  margin: 0 0 1.05em;
}

p:last-child {
  margin-bottom: 0;
}

a {
  color: inherit;
}

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

[hidden] {
  display: none !important;
}

figure {
  margin: 0;
}

sup {
  font-size: .68em;
  line-height: 0;
}

code,
kbd {
  font-family: var(--ff-mono);
  font-size: .86em;
}

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

::selection {
  background: var(--primary-soft);
}

/* ---------- layout primitives ---------- */
.wrap {
  width: 100%;
  max-width: var(--col-text);
  margin-inline: auto;
  padding-inline: var(--pad);
}

.wrap--mid {
  max-width: var(--col-mid);
}

.wrap--wide {
  max-width: var(--col-wide);
}

.wrap--full {
  max-width: var(--col-full);
}

section[id],
.part[id],
h4[id],
h5[id] {
  scroll-margin-top: 80px;
}

.sec {
  margin-block: var(--gap-sec);
}

.eyebrow {
  font-family: var(--ff-mono);
  font-size: var(--fs-meta);
  letter-spacing: var(--ls-meta);
  text-transform: uppercase;
  color: var(--fg-faint);
  margin-bottom: 16px;
}

.sec__title {
  font-size: clamp(26px, 2.9vw, 34px);
  line-height: 1.18;
  letter-spacing: -.012em;
  margin-bottom: .5em;
  padding-bottom: 14px;
  position: relative;
  text-wrap: balance;
}

.sec__title:has(.sec__no) {
  display: flex;
  align-items: baseline;
}

.sec__title::after {
  content: '';
  position: absolute;
  left: 0;
  bottom: 0;
  width: 72px;
  height: 3px;
  border-radius: 2px;
  background: var(--primary);
}

.sec__no {
  display: inline-block;
  flex: none;
  margin-right: .6em;
  font-family: var(--ff-mono);
  font-size: .58em;
  font-weight: 500;
  letter-spacing: .08em;
  color: var(--primary-ink);
  transform: translateY(-.22em);
}

.sec__sub {
  font-size: clamp(17px, 1.8vw, 20px);
  color: var(--fg-muted);
  line-height: 1.58;
  max-width: var(--measure);
}

.sec__sub a,
.sub__lede a {
  color: var(--primary-ink);
  text-decoration: none;
  border-bottom: 1px solid var(--border);
}

.sec__sub a:hover,
.sub__lede a:hover {
  border-bottom-color: var(--primary);
}

.sub__title {
  font-size: clamp(19px, 1.9vw, 23px);
  line-height: 1.28;
  margin: 0 0 .45em;
  letter-spacing: -.008em;
}

.subsub__title {
  font-size: 16px;
  font-weight: 600;
  line-height: 1.3;
  margin: 0 0 .5em;
  letter-spacing: -.004em;
  color: var(--fg-muted);
}

.sub__lede {
  font-size: 18px;
  line-height: 1.62;
  color: var(--fg-muted);
  margin: 0;
}

.rule {
  height: 1px;
  background: var(--border-soft);
  border: 0;
  margin: 0;
}

/* ==========================================================================
   part dividers
   ========================================================================== */
.part {
  margin-block: calc(var(--gap-sec) * 1.1) var(--gap-sec);
}

.part__in {
  border-top: 1px solid var(--border);
  padding-top: 20px;
  display: flex;
  align-items: baseline;
  gap: 14px clamp(20px, 4vw, 46px);
  flex-wrap: wrap;
}

.part__head {
  display: contents;
}

.part__t {
  font-size: clamp(22px, 2.4vw, 29px);
  letter-spacing: -.014em;
  line-height: 1.16;
}

.part__d {
  flex: 1 1 300px;
  font-size: 15.5px;
  line-height: 1.55;
  color: var(--fg-dim);
  margin: 0;
}

/* ==========================================================================
   outline rail
   ========================================================================== */
.rail {
  display: none;
}

@media (min-width: 1024px) {
  :root {
    --rail-shift: calc(var(--rail-w) + var(--rail-gap));
  }

  main> :not(.stage):not(.hero),
  .foot {
    padding-left: var(--rail-shift);
  }

  main>hr.rule {
    padding-left: 0;
    margin-left: var(--rail-shift);
  }

  .nav .nav__links {
    display: none;
  }

  .rail {
    display: block;
    position: fixed;
    z-index: 50;
    top: 108px;
    width: var(--rail-w);
    left: max(20px, calc((100vw - var(--rail-shift) - var(--col-wide)) / 2));
    max-height: calc(100vh - 150px);
    overflow-y: auto;
    padding-left: 15px;
    border-left: 1px solid var(--border);
    scrollbar-width: none;
  }

  .rail::-webkit-scrollbar {
    display: none;
  }

  .rail[data-over-hero="true"],
  .rail[data-near-footer="true"] {
    opacity: 0;
    pointer-events: none;
  }
}

.rail {
  transition: opacity .3s var(--ease);
}

.rail__links {
  display: grid;
  gap: 0;
}

.rail__links a {
  display: block;
  position: relative;
  text-decoration: none;
  padding: 9px 0;
  font-size: 14.5px;
  line-height: 1.28;
  color: var(--fg-dim);
  transition: color .16s var(--ease);
}

.rail__links a[data-level="2"] {
  padding: 5px 0 5px 12px;
  font-size: 13px;
  color: var(--fg-faint);
}

.rail__links a[data-level="3"] {
  padding: 4px 0 4px 24px;
  font-size: 12px;
  color: var(--fg-faint);
}

.rail__links a::before {
  content: "";
  position: absolute;
  left: -15px;
  top: 50%;
  width: 2px;
  height: 0;
  transform: translateY(-50%);
  background: var(--fg-dim);
  transition: height .16s var(--ease);
}

.rail__links a:hover,
.rail__links a:focus-visible {
  color: var(--fg);
}

.rail__links a:hover::before,
.rail__links a:focus-visible::before {
  height: 18px;
}

.rail__links a[aria-current="true"] {
  color: var(--fg);
}

.rail__links a[aria-current="true"]::before {
  height: 20px;
  background: var(--primary);
}

.rail__links a[data-in="true"] {
  color: var(--fg-muted);
}

/* ==========================================================================
   nav
   ========================================================================== */
.nav {
  position: sticky;
  top: 0;
  z-index: 60;
  background: color-mix(in srgb, var(--bg) 84%, transparent);
  backdrop-filter: blur(14px) saturate(140%);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  border-bottom: 1px solid var(--border-faint);
}

.nav__in {
  max-width: var(--col-full);
  margin-inline: auto;
  padding: 10px var(--pad);
  display: flex;
  align-items: center;
  gap: 14px;
}

.nav__brand {
  color: var(--primary-ink);
  font-size: 17px;
  font-weight: 600;
  text-decoration: none;
  letter-spacing: -.01em;
  white-space: nowrap;
}

.nav__links {
  display: flex;
  gap: 2px;
  margin-left: auto;
  align-items: center;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
  scroll-snap-type: x proximity;
  -webkit-overflow-scrolling: touch;
  mask-image: linear-gradient(to right, #000 0, #000 calc(100% - 18px), transparent 100%);
  -webkit-mask-image: linear-gradient(to right, #000 0, #000 calc(100% - 18px), transparent 100%);
}

.nav__links::-webkit-scrollbar {
  display: none;
}

@media (min-width: 1120px) {
  .nav__links {
    overflow-x: visible;
    mask-image: none;
    -webkit-mask-image: none;
  }
}

.nav__links a {
  font-size: 14.5px;
  text-decoration: none;
  color: var(--fg-dim);
  padding: 6px 9px;
  border-radius: var(--radius);
  transition: color .18s var(--ease), background .18s var(--ease);
  white-space: nowrap;
}

.nav__links a:hover {
  color: var(--fg);
  background: var(--surface-2);
}

.nav__links a[aria-current="true"] {
  color: var(--fg);
  background: var(--surface-2);
}

@media (max-width: 900px) {
  .nav__links .nav-hide {
    display: none;
  }
}

.nav__title,
.nav__actions {
  display: none;
}

@media (min-width: 1024px) {
  .nav__title {
    display: block;
    flex: 1 1 auto;
    min-width: 0;
    font-size: 14.5px;
    color: var(--fg-dim);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding-left: 14px;
    border-left: 1px solid var(--border-soft);
    opacity: 0;
    transition: opacity .3s var(--ease);
  }

  .nav[data-over-hero="false"] .nav__title {
    opacity: 1;
  }

  .nav__actions {
    display: flex;
    align-items: center;
    gap: 2px;
    margin-left: auto;
  }
}

.navbtn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  white-space: nowrap;
  padding: 6px 10px;
  border-radius: var(--radius);
  text-decoration: none;
  font-size: 14.5px;
  color: var(--fg-dim);
  transition: color .18s var(--ease), background .18s var(--ease);
}

.navbtn:hover {
  color: var(--fg);
  background: var(--surface-2);
}

.navbtn--off {
  color: var(--fg-faint);
  cursor: not-allowed;
}

.navbtn--off:hover {
  color: var(--fg-faint);
  background: none;
}

.navbtn em {
  font-style: normal;
  font-family: var(--ff-mono);
  font-size: 10px;
  letter-spacing: var(--ls-meta);
  text-transform: uppercase;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-pill);
  padding: 1px 5px;
  color: var(--fg-faint);
}

@media (max-width: 460px) {
  .nav__brand {
    font-size: 15px;
  }

  .nav__in {
    gap: 8px;
  }
}

.themebtn {
  margin-left: 6px;
  flex: none;
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  cursor: pointer;
  padding: 0;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--fg-muted);
  transition: background .18s var(--ease), color .18s var(--ease);
}

.themebtn:hover {
  background: var(--surface-2);
  color: var(--fg);
}

.themebtn svg {
  width: 15px;
  height: 15px;
}

.themebtn .i-sun {
  display: block;
}

.themebtn .i-moon {
  display: none;
}

[data-theme="day"] .themebtn .i-sun {
  display: none;
}

[data-theme="day"] .themebtn .i-moon {
  display: block;
}

/* ==========================================================================
   cinematic hero stage (dark in both themes)
   ========================================================================== */
.stage {
  position: relative;
  width: 100%;
  height: min(86vh, 820px);
  min-height: 380px;
  background: var(--stage-bg);
  overflow: hidden;
}

.stage__video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.stage__scrim {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(to bottom, rgba(5, 5, 5, .42) 0%, rgba(5, 5, 5, 0) 26%, rgba(5, 5, 5, 0) 62%, rgba(5, 5, 5, .78) 100%);
}

.stage__cue {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 26px;
  z-index: 3;
  display: grid;
  justify-items: center;
  gap: 10px;
  font-family: var(--ff-mono);
  font-size: 10.5px;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, .66);
}

.stage__tick {
  width: 1px;
  height: 26px;
  background: rgba(255, 255, 255, .55);
  transform-origin: top;
  animation: cue 2.6s var(--ease) infinite;
}

@keyframes cue {

  0%,
  100% {
    transform: scaleY(.25);
    opacity: .35;
  }

  50% {
    transform: scaleY(1);
    opacity: 1;
  }
}

.stage__expand {
  position: absolute;
  right: var(--pad);
  bottom: 22px;
  z-index: 4;
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, .24);
  border-radius: var(--radius);
  background: rgba(12, 12, 12, .55);
  backdrop-filter: blur(6px);
  color: #fff;
  cursor: pointer;
  padding: 0;
}

.stage__expand:hover {
  background: rgba(12, 12, 12, .85);
}

.stage__expand svg {
  width: 15px;
  height: 15px;
}

/* ==========================================================================
   title block
   ========================================================================== */
.hero {
  padding-top: clamp(38px, 6vw, 72px);
  text-align: center;
}

.hero .links {
  justify-content: center;
}

.hero .affils {
  justify-content: center;
}

.hero__title {
  font-size: clamp(28px, 3.4vw, 48px);
  font-optical-sizing: none;
  font-variation-settings: "opsz" 36;
  font-weight: 700;
  line-height: 1.16;
  letter-spacing: -.008em;
  text-wrap: balance;
  margin-bottom: .34em;
}

.hero__title .mark {
  color: var(--primary-ink);
  font-style: normal;
}

.hero__tagline {
  font-size: clamp(18px, 2.3vw, 23px);
  line-height: 1.45;
  color: var(--fg-muted);
  max-width: 52ch;
  margin-inline: auto;
  text-wrap: balance;
  margin-bottom: 1.5em;
}

.authors {
  margin-bottom: 10px;
  font-size: 17px;
  line-height: 1.8;
}

.authors .sep {
  color: var(--fg-faint);
}

.authors a {
  color: inherit;
  text-decoration: none;
  transition: color .18s var(--ease);
}

.authors a:hover {
  color: var(--primary-ink);
}

.affils {
  font-size: 14.5px;
  color: var(--fg-muted);
  line-height: 1.7;
  display: flex;
  flex-wrap: wrap;
  gap: 2px 18px;
  margin-bottom: 6px;
}

.affils span {
  white-space: nowrap;
}

.affils sup,
.authors sup {
  color: var(--primary-ink);
  font-weight: 600;
  padding-right: 1px;
}

.eqc {
  font-size: 13.5px;
  color: var(--fg-faint);
  margin-bottom: 26px;
}

/* link buttons */
.links {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  margin-bottom: clamp(26px, 4vw, 40px);
}

.hero__cta {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin: -14px 0 clamp(26px, 4vw, 40px);
  padding: 10px 18px;
  border: 1px solid color-mix(in srgb, var(--primary) 34%, var(--border-soft));
  background: color-mix(in srgb, var(--primary) 9%, var(--bg-raise));
  border-radius: var(--radius-pill);
  color: var(--fg);
  text-decoration: none;
  font-size: 14.5px;
  transition: background .18s var(--ease), border-color .18s var(--ease), transform .18s var(--ease);
}

.hero__cta:hover {
  background: color-mix(in srgb, var(--primary) 15%, var(--bg-raise));
  border-color: color-mix(in srgb, var(--primary) 48%, var(--border-soft));
  transform: translateY(-1px);
}

.hero__cta svg {
  flex: none;
}

.hero__cta svg:first-child {
  width: 16px;
  height: 16px;
  color: var(--primary-ink);
}

.hero__cta-arrow {
  width: 14px;
  height: 14px;
  transition: transform .18s var(--ease);
}

.hero__cta:hover .hero__cta-arrow {
  transform: translateX(2px);
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--fg);
  text-decoration: none;
  font-size: 15px;
  white-space: nowrap;
  transition: background .18s var(--ease), border-color .18s var(--ease), transform .18s var(--ease);
}

.btn:hover {
  background: var(--surface-3);
  border-color: var(--fg-dim);
  transform: translateY(-1px);
}

.btn svg {
  width: 14px;
  height: 14px;
  flex: none;
}

.btn--ghost {
  color: var(--fg-faint);
  border-style: dashed;
  cursor: not-allowed;
}

.btn--ghost:hover {
  transform: none;
  background: var(--surface);
  border-color: var(--border);
}

.btn--ghost .soon,
.soon {
  font-family: var(--ff-mono);
  font-size: 10px;
  letter-spacing: var(--ls-meta);
  text-transform: uppercase;
  padding: 2px 6px;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-pill);
  color: var(--fg-faint);
}

.soon {
  margin-left: 8px;
  vertical-align: 2px;
}

/* editorial marker for content that still needs filling in (TODO) */
.tag-todo {
  display: inline-block;
  vertical-align: 3px;
  margin-left: 10px;
  font-family: var(--ff-mono);
  font-size: var(--fs-meta);
  letter-spacing: var(--ls-meta);
  text-transform: uppercase;
  line-height: 1.6;
  padding: 1px 7px;
  color: #c03030;
  border: 1px solid rgba(192, 48, 48, .45);
  background: rgba(192, 48, 48, .08);
  border-radius: var(--radius);
}

/* ==========================================================================
   prose
   ========================================================================== */
.prose {
  font-size: 19px;
  line-height: 1.62;
  color: var(--fg-muted);
}

.prose strong {
  color: var(--fg);
  font-weight: 600;
}

.prose a {
  color: var(--primary-ink);
  text-decoration: none;
  border-bottom: 1px solid var(--border);
}

.prose a:hover {
  border-bottom-color: var(--primary);
}

.lede {
  font-size: clamp(19px, 2.1vw, 22px);
  line-height: 1.58;
  color: var(--fg);
}

.abstract__problem,
.abstract__method,
.abstract__payoff {
  position: relative;
  margin-bottom: clamp(22px, 2.8vw, 30px);
  padding: clamp(14px, 2vw, 18px) clamp(16px, 2.5vw, 22px);
  border-radius: var(--radius);
}

.abstract__problem {
  border: 1px solid color-mix(in srgb, #e0a526 26%, var(--border-soft));
  background: color-mix(in srgb, #e0a526 10%, var(--bg-raise));
}

.abstract__method {
  border: 1px solid color-mix(in srgb, var(--primary) 26%, var(--border-soft));
  background: color-mix(in srgb, var(--primary) 9%, var(--bg-raise));
}

.abstract__payoff {
  border: 1px solid color-mix(in srgb, var(--primary) 34%, var(--border-soft));
  background: color-mix(in srgb, var(--primary) 13%, var(--bg-raise));
}

.abstract__problem em,
.abstract__method em,
.abstract__payoff em {
  color: inherit;
  font-weight: inherit;
}

.introvid .player video {
  width: 100%;
  height: auto;
  display: block;
}

.figcap {
  margin-top: 13px;
  font-size: 14.5px;
  line-height: 1.55;
  color: var(--fg-dim);
  max-width: var(--measure);
  margin-inline: auto;
  text-align: center;
  text-wrap: pretty;
}

.figcap b,
.figcap strong {
  color: var(--fg-muted);
  font-weight: 600;
}

.figcap--left {
  margin-inline: 0;
  text-align: start;
  max-width: 86ch;
}

/* prominent placeholder disclosure */
.placeholder-notice {
  margin: 0;
  padding: 13px 16px;
  border-radius: var(--radius);
  border: 1px dashed var(--border);
  background: var(--surface);
  font-size: 14px;
  line-height: 1.55;
  color: var(--fg-dim);
}

.placeholder-notice b {
  color: var(--fg-muted);
}

/* ==========================================================================
   static figure plate (charts/comparison images; light card so figures
   authored on a white background stay legible in night mode too)
   ========================================================================== */
.plate {
  background: var(--plate-bg);
  border: 1px solid var(--border-faint);
  border-radius: var(--radius);
  padding: 18px;
}

.plate img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: calc(var(--radius) - 2px);
}

.plate .placeholder-notice {
  background: none;
  border-color: rgba(12, 12, 12, .18);
  color: rgba(12, 12, 12, .56);
}

.plate .placeholder-notice b {
  color: rgba(12, 12, 12, .78);
}

.legend {
  list-style: none;
  margin: 14px 0 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 22px;
}

.legend li {
  display: flex;
  align-items: baseline;
  gap: 7px;
  font-size: 14px;
  line-height: 1.5;
  color: var(--fg-dim);
  max-width: 46ch;
}

.legend__dot {
  flex: none;
  width: 9px;
  height: 9px;
  margin-bottom: 1px;
  border-radius: 50%;
}

.legend b {
  color: var(--fg);
  font-weight: 600;
}

/* ==========================================================================
   video player + lightbox
   ========================================================================== */
.player {
  position: relative;
  background: var(--muted);
  overflow: hidden;
  border-radius: var(--radius);
  border: 1px solid var(--border-faint);
  line-height: 0;
}

.player:has(.player__expand) {
  cursor: pointer;
}

.player video {
  width: 100%;
  height: auto;
  display: block;
  background: var(--muted);
}

.player__expand {
  position: absolute;
  right: 8px;
  bottom: 8px;
  z-index: 2;
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, .24);
  border-radius: var(--radius);
  background: rgba(12, 12, 12, .6);
  backdrop-filter: blur(6px);
  color: #fff;
  cursor: pointer;
  padding: 0;
  opacity: 0;
  transition: opacity .2s var(--ease), background .2s var(--ease);
}

.player:hover .player__expand,
.player__expand:focus-visible {
  opacity: 1;
}

.player__expand:hover {
  background: rgba(12, 12, 12, .9);
}

.player__expand svg {
  width: 14px;
  height: 14px;
}

.player__badge {
  position: absolute;
  left: 8px;
  top: 8px;
  z-index: 2;
  font-size: 12.5px;
  padding: 2px 8px;
  border-radius: var(--radius);
  background: rgba(12, 12, 12, .66);
  backdrop-filter: blur(6px);
  color: rgba(255, 255, 255, .84);
  border: 1px solid rgba(255, 255, 255, .15);
  line-height: 1.5;
}

.player__badge--bl {
  top: auto;
  bottom: 8px;
}

.vgrid {
  display: grid;
  gap: clamp(14px, 2vw, 22px);
}

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

.vgrid--3 {
  grid-template-columns: repeat(3, 1fr);
}

@media (max-width: 900px) {
  .vgrid--3 {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 620px) {

  .vgrid--2,
  .vgrid--3 {
    grid-template-columns: 1fr;
  }
}

.vgrid .player video {
  aspect-ratio: 16 / 9;
  object-fit: cover;
  height: auto;
}

/* ==========================================================================
   comparison carousel: model x camera-view grid with a sample toggle
   ========================================================================== */
.compare {
  border: 1px solid var(--border-faint);
  border-radius: var(--radius);
  background: var(--surface);
  padding: clamp(14px, 2.4vw, 22px);
}

.compare--center .compare__grid {
  grid-template-columns:
    34px calc(var(--compare-col-w, 1fr) + var(--compare-mid-gap, 0px)) var(--compare-col-w, 1fr);
  width: fit-content;
  max-width: 100%;
  margin-inline: auto;
}

/* the ground-truth column's track is widened by --compare-mid-gap above;
   pin its content to the track's left edge (flush with the row labels) so
   the extra width shows up as blank space before the next column instead
   of stretching/centering the header and video out of alignment */
.compare__colhead.compare__colhead--gt,
.compare__cell.compare__cell--gt {
  width: var(--compare-col-w, 100%);
  justify-self: start;
}

.compare__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px 20px;
  margin-bottom: 12px;
}

.compare__head .sub__title {
  margin: 0;
}

.compare__toggle {
  display: inline-flex;
  flex: none;
  padding: 3px;
  gap: 2px;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-pill);
  background: var(--bg-raise);
}

.compare__toggle-btn {
  border: 0;
  background: none;
  cursor: pointer;
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  font-family: var(--ff-body);
  font-size: 13.5px;
  color: var(--fg-dim);
  transition: background .18s var(--ease), color .18s var(--ease);
}

.compare__toggle-btn:hover {
  color: var(--fg);
}

.compare__toggle-btn.is-active {
  background: var(--primary);
  color: #fff;
}

.compare__lang {
  display: inline-block;
  margin: 0 0 16px;
  padding: 7px 14px;
  border-radius: var(--radius);
  background: var(--muted);
  border: 1px solid var(--border-faint);
  font-family: var(--ff-mono);
  font-size: 13px;
  font-style: italic;
  color: var(--fg-muted);
}

.compare__scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.compare__grid {
  display: grid;
  grid-template-columns: 34px repeat(var(--compare-cols, 6), minmax(0, var(--compare-col-w, 1fr)));
  column-gap: var(--compare-gap, 18px);
  row-gap: 8px;
}

@media (max-width: 900px) {
  .compare__grid {
    column-gap: 10px;
  }
}

@media (max-width: 620px) {
  .compare__grid {
    grid-template-columns: 20px repeat(var(--compare-cols, 6), minmax(0, 1fr));
    column-gap: 5px;
  }

  .compare__colhead {
    font-size: 10px;
    padding: 4px 2px;
  }
}

.compare__colhead,
.compare__rowhead {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  border-radius: var(--radius);
  background: var(--muted);
  font-family: var(--ff-mono);
  font-size: 11px;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--fg-muted);
}

.compare__colhead {
  padding: 5px 6px;
  font-size: 13px;
  font-weight: 600;
}

.compare__rowhead {
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  letter-spacing: .1em;
  color: var(--fg-dim);
}

.compare__cell {
  position: relative;
  width: 100%;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--muted);
  border: 1px solid var(--border-faint);
  line-height: 0;
}

.compare__cell video {
  width: 100%;
  height: auto;
  display: block;
  background: var(--muted);
}

.vcard__cap {
  margin-top: 11px;
  font-size: 14px;
  line-height: 1.5;
  color: var(--fg-muted);
}

.vcard__cap b {
  display: block;
  color: var(--fg);
  font-weight: 600;
  font-size: 15px;
  margin-bottom: 2px;
}

.lb {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: none;
  background: rgba(6, 6, 6, .94);
  backdrop-filter: blur(10px);
  padding: clamp(14px, 3vw, 40px);
}

.lb[data-open="true"] {
  display: grid;
  place-items: center;
}

.lb__stage {
  max-width: 1200px;
  width: 100%;
}

.lb__stage video {
  width: 100%;
  max-height: 78vh;
  border-radius: var(--radius);
  background: #000;
}

.lb__bar {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  margin-top: 14px;
  font-family: var(--ff-mono);
  font-size: 12px;
}

.lb__cap {
  flex: 1 1 260px;
  font-family: var(--ff-body);
  font-size: 15px;
  color: rgba(255, 255, 255, .76);
}

.lb__badge {
  font-size: 12.5px;
  padding: 2px 8px;
  border-radius: var(--radius);
  white-space: nowrap;
  background: rgba(12, 12, 12, .66);
  color: rgba(255, 255, 255, .84);
  border: 1px solid rgba(255, 255, 255, .15);
  line-height: 1.5;
}

.lb__speeds {
  display: flex;
  gap: 4px;
}

.lb__speeds button {
  font-family: var(--ff-mono);
  font-size: var(--fs-meta);
  padding: 5px 9px;
  background: rgba(255, 255, 255, .08);
  color: rgba(255, 255, 255, .78);
  border: 1px solid rgba(255, 255, 255, .16);
  border-radius: var(--radius);
  cursor: pointer;
}

.lb__speeds button[aria-pressed="true"] {
  background: #b8455f;
  border-color: #b8455f;
  color: #fff;
}

.lb__close {
  background: rgba(255, 255, 255, .08);
  color: #fff;
  cursor: pointer;
  border: 1px solid rgba(255, 255, 255, .16);
  border-radius: var(--radius);
  font-size: 14px;
  padding: 5px 12px;
}

.lb__close:hover {
  background: rgba(255, 255, 255, .18);
}

/* ==========================================================================
   stage cards (two-stage curriculum)
   ========================================================================== */
.stagecards {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(2, 1fr);
}

@media (max-width: 680px) {
  .stagecards {
    grid-template-columns: 1fr;
  }
}

.stagecard {
  border: 1px solid var(--border-faint);
  border-radius: var(--radius);
  padding: 18px 20px;
  background: var(--surface);
  transition: border-color .18s var(--ease), background .18s var(--ease), transform .18s var(--ease);
}

.stagecard:hover {
  border-color: color-mix(in srgb, var(--primary) 34%, var(--border-soft));
  background: color-mix(in srgb, var(--primary) 6%, var(--surface));
  transform: translateY(-2px);
}

.stagecard__tag {
  display: inline-block;
  margin-bottom: 8px;
  font-family: var(--ff-mono);
  font-size: var(--fs-meta);
  letter-spacing: var(--ls-meta);
  text-transform: uppercase;
  color: var(--primary-ink);
}

.stagecard__title {
  font-size: 17px;
  font-weight: 600;
  margin-bottom: 6px;
}

.stagecard__body {
  font-size: 14.5px;
  color: var(--fg-muted);
  line-height: 1.55;
  margin: 0;
}

/* ==========================================================================
   tables
   ========================================================================== */
.tablewrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 14.5px;
  font-variant-numeric: tabular-nums;
  min-width: 520px;
}

table.data th,
table.data td {
  padding: 9px 12px;
  text-align: right;
  border-bottom: 1px solid var(--border-faint);
}

table.data th:first-child,
table.data td:first-child {
  text-align: left;
}

table.data thead th {
  font-family: var(--ff-mono);
  font-size: var(--fs-meta);
  letter-spacing: var(--ls-meta);
  text-transform: uppercase;
  color: var(--fg-faint);
  font-weight: 400;
  border-bottom-color: var(--border-soft);
  white-space: nowrap;
}

table.data tbody tr:hover {
  background: var(--surface);
}

/* descriptive (not numeric) tables read left-to-right in every column */
table.data.data--text th,
table.data.data--text td {
  text-align: left;
}

/* ==========================================================================
   bibtex
   ========================================================================== */
.bib {
  position: relative;
}

.bib pre {
  margin: 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--muted);
  border: 1px solid var(--border-faint);
  border-radius: var(--radius);
  padding: 20px;
  font-family: var(--ff-mono);
  font-size: 12.5px;
  line-height: 1.7;
  color: var(--fg-muted);
  tab-size: 2;
}

.bib__copy {
  position: absolute;
  right: 10px;
  top: 10px;
  font-size: 14px;
  padding: 5px 12px;
  border-radius: var(--radius);
  cursor: pointer;
  background: var(--surface-2);
  color: var(--fg-muted);
  border: 1px solid var(--border-soft);
}

.bib__copy:hover {
  background: var(--surface-3);
  color: var(--fg);
}

/* ==========================================================================
   footer
   ========================================================================== */
.foot {
  border-top: 1px solid var(--border-faint);
  margin-top: var(--gap-sec);
  padding-block: 34px 46px;
  font-size: 13.5px;
  color: var(--fg-dim);
  line-height: 1.6;
}

.foot a {
  color: var(--fg-muted);
}

.foot p {
  margin-bottom: .7em;
}

/* ==========================================================================
   reveal + motion
   ========================================================================== */
.reveal {
  opacity: 0;
  transform: translateY(14px);
  transition: opacity .6s var(--ease), transform .6s var(--ease);
}

.reveal.in {
  opacity: 1;
  transform: none;
}

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

  .reveal {
    opacity: 1;
    transform: none;
    transition: none;
  }

  .stage__tick {
    animation: none;
  }

  *,
  *::before,
  *::after {
    animation-duration: .001ms !important;
    transition-duration: .001ms !important;
  }
}

@media print {

  .nav,
  .rail,
  .stage__expand,
  .player__expand,
  .lb,
  .themebtn {
    display: none !important;
  }
}