.bitbit-case {
  --bb-motion-micro: 180ms;
  --bb-motion-state: 360ms;
  --bb-motion-caption: 460ms;
  --bb-motion-title: 820ms;
  --bb-motion-stagger: 92ms;
  --bb-motion-shift: 14px;
  --bb-motion-drift: 24px;
  --bb-motion-ease: cubic-bezier(.2, .75, .25, 1);
}

html.lenis, html.lenis body { height: auto; }
.lenis.lenis-smooth { scroll-behavior: auto !important; }
.lenis [data-lenis-prevent] { overscroll-behavior: contain; }

.bb-motion-loader {
  position: fixed;
  z-index: 50;
  inset: 0;
  display: grid;
  place-items: center;
  background: #0b0a0e;
  pointer-events: none;
}
.bb-motion-load-panel {
  display: grid;
  gap: 12px;
  justify-items: start;
  width: min(250px, calc(100% - 50px));
}
.bb-motion-load-panel img { width: 190px; height: auto; margin-bottom: 10px; image-rendering: pixelated; }
.bb-motion-load-track { width: 100%; height: 3px; background: #3c3941; }
.bb-motion-load-track i { display: block; height: 100%; background: var(--lime); transform: scaleX(0); transform-origin: left; }
.bb-motion-load-percent {
  color: var(--lime);
  justify-self: end;
  font: 600 14px/1 var(--case-display);
  font-variant-numeric: tabular-nums;
}

.bitbit-case .project-nav .bb-motion-nav {
  position: relative;
  display: flex;
  gap: 12px;
  align-items: center;
  transition: opacity var(--bb-motion-micro) var(--bb-motion-ease);
}
.bb-motion-nav.is-immersive:not(:hover, :focus-within) { opacity: .64; }
.bb-motion-current {
  color: #bbb8c1;
  font: 600 11px/1.25 var(--mono);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.bb-motion-current [data-chapter-number] { color: var(--lime); }
.bb-motion-chapters { display: flex; gap: 2px; }
.bb-motion-chapters a {
  position: relative;
  display: grid;
  place-items: center;
  width: 20px;
  min-height: 36px;
  border-radius: 2px;
}
.bb-motion-chapters a::before {
  width: 5px;
  height: 5px;
  background: #87828e;
  content: "";
  transition: transform var(--bb-motion-micro) var(--bb-motion-ease), background-color var(--bb-motion-micro);
}
.bb-motion-chapters a[aria-current]::before {
  background: var(--lime);
  transform: scale(1.35);
}
.bb-motion-chapters a:is(:hover, :focus-visible)::before { background: var(--lime); }
.bb-motion-chapters a span {
  position: absolute;
  z-index: 1;
  top: calc(100% + 9px);
  right: 0;
  padding: 8px 10px;
  border: 1px solid #ffffff30;
  background: #151319;
  color: #fff;
  white-space: nowrap;
  pointer-events: none;
  clip-path: inset(50%);
}
.bb-motion-chapters a:is(:hover, :focus-visible) span { clip-path: none; }
.bb-motion-chapters a[aria-current]::after {
  position: absolute;
  inset: auto 2px 2px;
  height: 1px;
  background: var(--lime);
  transform: scaleX(var(--bb-chapter-progress, 0));
  transform-origin: left;
  content: "";
}
.bb-motion-toggle { display: none; }

.bb-motion-handoff {
  position: absolute;
  z-index: 3;
  inset: 0 0 auto;
  height: clamp(10px, 7svh, 64px);
  overflow: clip;
  pointer-events: none;
}
.bb-motion-handoff i {
  position: absolute;
  inset: 0;
  background: var(--bb-edge-color);
  pointer-events: none;
}
.bb-motion-handoff[data-look="wipe"] i { transform-origin: left; }
.bb-motion-handoff[data-look="lift"] i { transform-origin: top; }
.bb-motion-handoff[data-look="slices"] i {
  inset: 0 auto 0 0;
  width: 33.4%;
  transform-origin: top;
}
.bb-motion-handoff[data-look="slices"] i:nth-child(2) { left: 33.3%; }
.bb-motion-handoff[data-look="slices"] i:nth-child(3) { left: 66.6%; }
.bb-motion-handoff[data-look="slit"] i {
  inset: 0 0 auto;
  height: 2px;
  transform-origin: right;
}
.bb-motion-handoff[data-look="scan"] i:nth-child(2) {
  height: 2px;
  background: var(--lime);
  transform-origin: left;
}
.bb-motion-handoff[data-look="pixel"] i {
  inset: 0 auto 0 0;
  width: 25.1%;
  transform-origin: top;
}
.bb-motion-handoff[data-look="pixel"] i:nth-child(2) { left: 25%; }
.bb-motion-handoff[data-look="pixel"] i:nth-child(3) { left: 50%; }
.bb-motion-handoff[data-look="pixel"] i:nth-child(4) { left: 75%; }

@media (max-width: 760px) {
  .bitbit-case .project-nav .bb-motion-nav:not([data-ready]) { display: none; }
  .bb-motion-current { display: none; }
  .bitbit-case .project-nav .bb-motion-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 0 5px;
    min-height: 44px;
    border: 0;
    background: none;
    color: #fff;
    font: 600 10px/1.3 var(--mono);
    white-space: nowrap;
  }
  .bb-motion-toggle [data-chapter-number] { color: var(--lime); }
  .bb-motion-chapters {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    width: min(205px, 65vw);
    max-height: 75dvh;
    overflow: auto;
    overscroll-behavior: contain;
    padding: 4px 0;
    border: 1px solid #ffffff25;
    background: #151319;
  }
  .bb-motion-toggle[aria-expanded="true"] + .bb-motion-chapters { display: grid; }
  .bb-motion-chapters a {
    grid-template-columns: 6px 1fr;
    justify-items: start;
    gap: 12px;
    width: 100%;
    min-height: 44px;
    padding: 0 15px;
  }
  .bb-motion-chapters a span { position: static; padding: 0; border: 0; background: none; clip-path: none; }
  .bb-motion-chapters a[aria-current]::after { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .bb-motion-loader, .bb-motion-handoff { display: none; }
  .bb-motion-nav, .bb-motion-chapters a::before { transition-property: none; }
}
