/* ==========================================================================
   Video gallery — three regions
   01  `.vrows`  three endless marquee rows; 1 and 3 drift left, 2 drifts right
   02  `.vpile`  a scattered pile of frames; each fades in and out on its own
                 phase, so the pile is always changing
   03  `.vstack` a stack of cards: one readable front card, three slivers behind,
                 hover a sliver to bring it forward
   Plus the wipe dialog that a frame in the pile opens.
   ========================================================================== */

.vgal {
  padding: clamp(30px, 4vw, 54px) 0 clamp(40px, 5vw, 70px);
  border-top: 1px solid var(--line);
}

[data-theme="dark"] .vgal {
  border-top-color: #1b2438;
}

/* ---------- zone shell ---------- */

.vzone {
  margin-top: clamp(30px, 3.6vw, 46px);
}

.vzone:first-of-type {
  margin-top: 0;
}

/* Two equal columns. Both stages are squares of the same size, so the two
   zones line up along the top and the bottom edge -- the previous 1.1fr/0.9fr
   split left them visibly out of step. */
.vpair {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  /* shared by both zones: the deck reserves three of these for its slivers, and
     the framed plate is narrowed by the same amount so the two read as one pair */
  --peek: clamp(16px, 1.9vw, 24px);
  /* how far inside the front card's right border the nudge zone begins: landing
     on an exact edge is fiddly, so the zone starts inside the card */
  --nudge-inset: clamp(44px, 8%, 84px);
  gap: clamp(18px, 2.4vw, 34px);
  margin-top: clamp(34px, 4vw, 54px);
  padding-top: clamp(26px, 3vw, 40px);
  border-top: 1px solid var(--line);
  align-items: start;
}

[data-theme="dark"] .vpair {
  border-top-color: #182032;
}

.vpair .vzone {
  margin-top: 0;
  min-width: 0;
}

.vzone__bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
  min-width: 0;
}

.vzone__num {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  font-weight: 500;
  letter-spacing: 0.14em;
  color: var(--muted);
  padding: 2px 6px;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
}

.vzone__title {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.05rem, 1.5vw, 1.32rem);
  font-weight: 400;
  letter-spacing: -0.01em;
  color: var(--ink);
}

.vzone__sub {
  font-size: 0.72rem;
  color: var(--muted);
}

.vzone__bar--tall {
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
  margin-bottom: 12px;
}

.vzone__head {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.vzone__hint {
  margin: 10px 0 0;
  font-size: 0.64rem;
  color: var(--muted);
}

/* a small tint per zone, so the three read as siblings */
.vzone--flow .vzone__num {
  color: var(--blue);
  border-color: color-mix(in srgb, var(--blue) 40%, transparent);
}

.vzone--pile .vzone__num {
  color: #b86b4b;
  border-color: color-mix(in srgb, #b86b4b 40%, transparent);
}

.vzone--stack .vzone__num {
  color: #6a63a8;
  border-color: color-mix(in srgb, #6a63a8 45%, transparent);
}

.vzone .chip {
  font-size: 0.68rem;
  padding: 4px 10px;
}

.vzone .chips {
  flex-wrap: wrap;
  max-width: 100%;
  min-width: 0;
}

/* ==========================================================================
   01 · endless rows
   ========================================================================== */

.vrows {
  display: flex;
  flex-direction: column;
  gap: 8px;
  /* the rows stop at the same outer edge as the section number and the chips,
     instead of bleeding to the viewport edge */
  margin-inline: 0;
}

.vrow {
  overflow: hidden;
  /* the row's own height; a fade at both ends keeps the loop seam invisible */
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 4%, #000 96%, transparent);
  mask-image: linear-gradient(90deg, transparent, #000 4%, #000 96%, transparent);
}

.vrow__track {
  display: flex;
  gap: 8px;
  width: max-content;
  will-change: transform;
  backface-visibility: hidden;
  animation-timing-function: linear;
  animation-iteration-count: infinite;
  /* set per row by the script */
  animation-direction: normal;
}

.vrow[data-dir="left"] .vrow__track {
  animation-name: vrow-left;
}

.vrow[data-dir="right"] .vrow__track {
  animation-name: vrow-right;
}

/* hovering a row holds that row only */
.vrow:hover .vrow__track,
.vrow.is-hold .vrow__track {
  animation-play-state: paused;
}

.vrow.is-off .vrow__track {
  animation-play-state: paused;
}

@keyframes vrow-left {
  from {
    transform: translate3d(0, 0, 0);
  }
  to {
    transform: translate3d(-50%, 0, 0);
  }
}

@keyframes vrow-right {
  from {
    transform: translate3d(-50%, 0, 0);
  }
  to {
    transform: translate3d(0, 0, 0);
  }
}

/* ---- one clip in a row ---- */

.vmtile {
  position: relative;
  flex: none;
  width: clamp(196px, 18.5vw, 268px);
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 7px;
  overflow: hidden;
  background: #0a0f18;
  cursor: pointer;
  transition: border-color 0.24s ease, box-shadow 0.24s ease;
}

[data-theme="dark"] .vmtile {
  border-color: #1d2637;
}

.vmtile__shot {
  position: relative;
  display: block;
  aspect-ratio: 1664 / 480;
  overflow: hidden;
  border-radius: 6px 6px 0 0;
}

.vmtile__shot img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: filter 0.26s ease;
}

/* the caption is permanent, not hover-only: with rows drifting past, a reader
   cannot hover every frame to find out what it is */
.vmtile__meta {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 4px 6px 5px;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  min-width: 0;
}

.vmtile__t {
  flex: 1;
  min-width: 0;
  font-size: 0.56rem;
  line-height: 1.25;
  color: var(--ink-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

[data-theme="dark"] .vmtile__t {
  color: #b9c6dc;
}

.vmtile__k {
  flex: none;
  display: flex;
  gap: 3px;
}

.vmtile__k i {
  padding: 0 3px;
  border-radius: 2px;
  font-family: var(--font-mono);
  font-size: 0.44rem;
  font-style: normal;
  letter-spacing: 0.03em;
  color: var(--muted);
  background: var(--surface-2);
}

[data-theme="dark"] .vmtile__k i {
  background: rgba(255, 255, 255, 0.07);
}

.vmtile__k i:last-child {
  color: #c07a52;
  background: color-mix(in srgb, #b86b4b 16%, transparent);
}

.vmtile:hover {
  border-color: color-mix(in srgb, #b86b4b 55%, transparent);
  box-shadow: 0 16px 32px -22px rgba(0, 0, 0, 0.85);
}

.vmtile:hover img {
  filter: brightness(1.06) saturate(1.03);
}

/* The clip fades in on top of the poster once its first frame is decoded. The
   poster is never removed: if a tile loses its decoder to the pool, the class
   goes away and the poster is simply there again, with no black flash. */
.vmtile__video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  opacity: 0;
  transition: opacity 0.4s ease;
  pointer-events: none;
}

.vmtile.is-video .vmtile__video {
  opacity: 1;
}

/* a very faint tint on the moving tiles, so a wall of 12 clips does not glare
   against the page's dark surface */
.vmtile.is-video .vmtile__shot::after {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(6, 10, 18, 0.06);
  pointer-events: none;
}

.vmtile__seam {
  position: absolute;
  z-index: 2;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 1px;
  background: rgba(255, 255, 255, 0.2);
  pointer-events: none;
}

.vmtile__tag {
  position: absolute;
  z-index: 3;
  top: 4px;
  padding: 1px 4px;
  border-radius: 3px;
  font-family: var(--font-mono);
  font-size: 0.44rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #eef2f8;
  background: rgba(8, 12, 20, 0.8);
  pointer-events: none;
}

.vmtile__tag--l {
  left: 4px;
}

.vmtile__tag--r {
  right: 4px;
  color: #ffd8bd;
  background: rgba(60, 28, 14, 0.62);
}

.vmtile__play {
  position: absolute;
  z-index: 3;
  inset: 0;
  display: grid;
  place-items: center;
  opacity: 0;
  transition: opacity 0.22s ease;
  pointer-events: none;
}

.vmtile__play i {
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(8, 12, 20, 0.82);
  border: 1px solid rgba(255, 255, 255, 0.26);
}

.vmtile__play svg {
  width: 12px;
  height: 12px;
  color: #fff;
}

.vmtile:hover .vmtile__play {
  opacity: 1;
}

/* ==========================================================================
   02 · a framed pile
   ========================================================================== */

/* The frame IS the container: a padded plate the pile sits inside. As a separate
   absolutely-positioned layer it grew past the column (so 02 looked wider than
   03) and the pile's own background painted over the corners. */
/* Same width as the deck's front card, not the whole column: the plate used to
   fill its column while the deck only filled the left ~87 % of its own, so 02
   looked a full size bigger than 03. */
/* Exactly the footprint of the deck's front card: same width (the deck gives up
   three peeks for its slivers) and the same 1062/986 ratio as the cropped seed
   grid. Matching both means the two zones start and end on the same lines. */
/* Width and height are decoupled here on purpose. The height is pinned to the
   deck's front card (0.9277 = 986/1062) so the two plates still start and end
   on the same lines, while the width grows toward the deck's full 573 px: the
   deck is wider than its own front card because of the three slivers, and
   matching only the card left 02 visibly narrow. */
.vframe {
  position: relative;
  /* 551/465 is the deck's front card height against the wider plate: the ratio
     is fixed, so the height stays pinned to the deck while the width grows. A
     `height: calc(100% * ...)` would not work here -- the percentage resolves
     against an auto-height parent and collapses to nothing. */
  width: calc(100% - var(--peek) * 0.9);
  aspect-ratio: 551 / 465;
  padding: clamp(8px, 0.95vw, 12px);
  border-radius: 16px;
  color: #c98a5f;
  background:
    linear-gradient(
      135deg,
      rgba(200, 138, 95, 0.15),
      rgba(106, 99, 168, 0.11) 52%,
      rgba(200, 138, 95, 0.14)
    );
  box-shadow:
    /* inner hairline, then a soft bevel, then the drop shadow */
    inset 0 0 0 1px rgba(214, 148, 106, 0.5),
    inset 0 0 0 4px rgba(255, 255, 255, 0.025),
    inset 0 1px 0 rgba(255, 255, 255, 0.1),
    0 26px 54px -34px rgba(0, 0, 0, 0.85);
}

[data-theme="dark"] .vframe {
  color: #e0a97f;
  box-shadow:
    inset 0 0 0 1px rgba(224, 169, 127, 0.46),
    inset 0 0 0 4px rgba(255, 255, 255, 0.03),
    inset 0 1px 0 rgba(255, 255, 255, 0.12),
    0 26px 54px -34px rgba(0, 0, 0, 0.9);
}

/* a single diagonal highlight, so the plate reads as a surface rather than a
   flat block of colour */
.vframe::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  background: linear-gradient(
    118deg,
    rgba(255, 255, 255, 0.09) 0%,
    rgba(255, 255, 255, 0) 38%,
    rgba(255, 255, 255, 0) 70%,
    rgba(255, 255, 255, 0.04) 100%
  );
}

.vpile {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 9px;
  overflow: hidden;
  background:
    radial-gradient(120% 90% at 20% 0%, rgba(184, 107, 75, 0.1), transparent 62%),
    radial-gradient(110% 90% at 90% 100%, rgba(106, 99, 168, 0.11), transparent 60%),
    #0a0f18;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.05);
}

/* corners: above the plate, below the frames (which reach z 999 when pinned) */
.vframe__corner {
  position: absolute;
  z-index: 3;
  width: clamp(38px, 4.6vw, 58px);
  height: clamp(38px, 4.6vw, 58px);
  color: inherit;
  pointer-events: none;
}

.vframe__corner--tl { top: 3px; left: 3px; }
.vframe__corner--tr { top: 3px; right: 3px; transform: scaleX(-1); }
.vframe__corner--bl { bottom: 3px; left: 3px; transform: scaleY(-1); }
.vframe__corner--br { bottom: 3px; right: 3px; transform: scale(-1, -1); }

.vpile__item {
  position: absolute;
  left: var(--x);
  top: var(--y);
  width: var(--w);
  max-width: 58%;
  /* The posters are 3.47:1 strips (a 4-step half beside a 2-step half). Shown
     at that ratio in a pile each frame is a sliver, so the display is cropped
     to a friendlier 2.6:1; `cover` trims the outer edges of both halves, and
     the clip itself is never touched. */
  aspect-ratio: 2.6 / 1;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.26);
  border-radius: 4px;
  overflow: hidden;
  background: #070b12;
  cursor: zoom-in;
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.45),
    0 12px 26px -14px rgba(0, 0, 0, 0.92);
  transform: rotate(var(--rot));
  transform-origin: 50% 50%;
  z-index: var(--z);
  animation: vpile-cycle 37s ease-in-out infinite;
  animation-delay: var(--d);
  transition: border-color 0.24s ease, box-shadow 0.24s ease;
}

.vpile__item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
  filter: saturate(0.95);
  transition: filter 0.28s ease;
}

/* ---- badges, matching zone 01's language ---- */

.vpile__tags {
  position: absolute;
  z-index: 3;
  top: 3px;
  left: 3px;
  right: 3px;
  display: flex;
  justify-content: space-between;
  gap: 4px;
  pointer-events: none;
}

.vpile__tag {
  padding: 1px 4px;
  border-radius: 3px;
  font-family: var(--font-mono);
  font-size: 0.42rem;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: #eef2f8;
  background: rgba(8, 12, 20, 0.8);
  white-space: nowrap;
}

.vpile__tag--l {
  color: #dfe6f2;
}

.vpile__tag--r {
  color: #ffd8bd;
  background: rgba(60, 28, 14, 0.66);
}

/* model / backbone strip, always visible: it is what the click is about */
.vpile__meta {
  position: absolute;
  z-index: 3;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 10px 5px 3px;
  font-family: var(--font-mono);
  font-size: 0.42rem;
  letter-spacing: 0.03em;
  color: #b9c6dc;
  background: linear-gradient(to top, rgba(5, 9, 16, 0.9), rgba(5, 9, 16, 0));
  pointer-events: none;
}

.vpile__meta b {
  font-weight: 400;
  color: #e6edf8;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.vpile__meta i {
  flex: none;
  font-style: normal;
  padding: 0 3px;
  border-radius: 2px;
  color: #8fa0ba;
  background: rgba(255, 255, 255, 0.09);
}

.vpile__meta i:last-child {
  color: #e8b08a;
  background: rgba(184, 107, 75, 0.22);
}

/* Opacity only. `visibility` used to be animated alongside it, but visibility
   is not a composited property: all eleven frames forced style and layout work
   on every tick. Keeping the animation to opacity lets the compositor run it,
   and the hit-test flag is a class that a slow timer sets (below). */
@keyframes vpile-cycle {
  0%,
  100% {
    opacity: 0;
  }
  11%,
  66% {
    opacity: 0.96;
  }
  78% {
    opacity: 0;
  }
}

/* invisible frames must not swallow clicks; the class follows the same window
   as the keyframes, on a 250 ms timer instead of every frame */
.vpile__item {
  pointer-events: none;
}

.vpile__item.is-shown,
.vpile__item:hover,
.vpile__item.is-pinned {
  pointer-events: auto;
}

.vpile__item:hover,
.vpile__item:focus-visible,
.vpile__item.is-pinned {
  animation: none;
  opacity: 1;
  visibility: visible;
  transform: rotate(0deg) scale(1.26);
  z-index: 999;
  border-color: color-mix(in srgb, #b86b4b 80%, transparent);
  box-shadow: 0 30px 60px -24px rgba(0, 0, 0, 0.95);
  outline: none;
}

.vpile__item:hover img,
.vpile__item:focus-visible img,
.vpile__item.is-pinned img {
  filter: saturate(1.05) brightness(1.07);
}


/* ---------- foreground motion inside the plate ---------- */

/* A starfield behind the frames and fine rain in front of them. Both are pure
   background gradients on pseudo-elements: no canvas, no extra DOM, and the
   pile keeps its existing stacking (frames 10+, pinned 999, corners 250). */
.vpile::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background-image:
    radial-gradient(1.6px 1.6px at 18% 24%, rgba(255, 255, 255, 0.9) 0 40%, transparent 60%),
    radial-gradient(1.2px 1.2px at 72% 16%, rgba(190, 214, 255, 0.85) 0 40%, transparent 60%),
    radial-gradient(1.9px 1.9px at 44% 62%, rgba(255, 236, 214, 0.8) 0 40%, transparent 60%),
    radial-gradient(1.1px 1.1px at 86% 74%, rgba(255, 255, 255, 0.75) 0 40%, transparent 60%),
    radial-gradient(1.4px 1.4px at 12% 84%, rgba(200, 220, 255, 0.7) 0 40%, transparent 60%),
    radial-gradient(1.3px 1.3px at 58% 38%, rgba(255, 255, 255, 0.6) 0 40%, transparent 60%),
    radial-gradient(1px 1px at 30% 8%, rgba(255, 240, 226, 0.7) 0 40%, transparent 60%),
    radial-gradient(1.2px 1.2px at 92% 40%, rgba(255, 255, 255, 0.55) 0 40%, transparent 60%);
  /* oversized by one tile in each direction so it can drift without exposing an
     edge; the drift is a transform, which the compositor handles without a
     repaint (animating `background-position` repainted the whole plate) */
  inset: -132px;
  background-size: 132px 132px;
  background-repeat: repeat;
  opacity: 0.42;
  animation: vpile-stars 6.5s ease-in-out infinite alternate;
}

@keyframes vpile-stars {
  0% {
    opacity: 0.4;
    transform: translate3d(0, 0, 0);
  }
  50% {
    opacity: 0.85;
  }
  100% {
    opacity: 0.55;
    transform: translate3d(6px, -8px, 0);
  }
}

/* the starfield canvas: the middle distance, between the CSS star dots and the
   photographs. Sized and painted by videos.js. */
.vpile__sky {
  position: absolute;
  inset: 0;
  z-index: 2;
  width: 100%;
  height: 100%;
  display: block;
  pointer-events: none;
}

@media (prefers-reduced-motion: reduce) {
  .vpile::before {
    animation: none;
  }
}

/* ==========================================================================
   03 · stacked cards
   ========================================================================== */

.vstack {
  position: relative;
  /* as tall as the framed plate: two squares would force the deck to be
     centred, and a centred deck does not line up with a top-aligned plate */
  aspect-ratio: 1 / 1;
}

.vstack__card {
  position: absolute;
  /* flush left and flush top: the deck used to be centred in its square, which
     left it 54 px lower than the framed plate next to it */
  left: 0;
  top: 0;
  width: calc(100% - var(--peek) * 3);
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  background: #0a0f18;
  cursor: pointer;
  transform:
    translate(var(--tx, 0px), var(--ty, 0px))
    rotate(var(--rot, 0deg))
    scale(var(--sc, 1));
  transform-origin: 50% 50%;
  z-index: var(--z, 1);
  transition: transform 0.95s cubic-bezier(0.22, 0.9, 0.24, 1),
    box-shadow 0.95s ease, filter 0.95s ease, border-color 0.95s ease;
}

[data-theme="dark"] .vstack__card {
  border-color: #1d2637;
}

.vstack__card img {
  display: block;
  width: 100%;
  height: auto;
  filter: brightness(calc(1 - var(--dim, 0)));
  transition: filter 0.95s ease;
}

.vstack__card.is-front {
  border-color: color-mix(in srgb, #8f7fdd 60%, transparent);
  box-shadow:
    0 0 0 1px rgba(143, 127, 221, 0.28),
    0 0 30px -6px rgba(143, 127, 221, 0.35),
    0 34px 64px -30px rgba(0, 0, 0, 0.95);
  cursor: zoom-in;
}

/* a warm hairline inset on the front card, plus corner ticks: the deck's lead
   card should look framed, since it is the one the section is about */
.vstack__card.is-front::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 2;
  border-radius: inherit;
  pointer-events: none;
  background:
    linear-gradient(135deg, rgba(224, 169, 127, 0.5), transparent 34%) top left /
      38% 38% no-repeat,
    linear-gradient(225deg, rgba(143, 127, 221, 0.5), transparent 34%) top right /
      38% 38% no-repeat,
    linear-gradient(45deg, rgba(143, 127, 221, 0.4), transparent 34%) bottom left /
      38% 38% no-repeat,
    linear-gradient(315deg, rgba(224, 169, 127, 0.45), transparent 34%) bottom right /
      38% 38% no-repeat;
  opacity: 0.85;
}

.vstack__card.is-front::after {
  content: "";
  position: absolute;
  z-index: 2;
  border-radius: inherit;
  pointer-events: none;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.14);
}

.vstack__cap {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 26px 12px 9px;
  font-size: 0.68rem;
  line-height: 1.3;
  color: #f2f6fc;
  text-align: left;
  background: linear-gradient(to top, rgba(5, 9, 16, 0.92), rgba(5, 9, 16, 0));
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}

.vstack__card.is-front .vstack__cap {
  opacity: 1;
}

.vstack__num {
  position: absolute;
  z-index: 2;
  top: 8px;
  left: 8px;
  padding: 1px 6px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 0.54rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: #e6e9f6;
  background: rgba(20, 16, 40, 0.82);
  pointer-events: none;
}

/* ==========================================================================
   wipe dialog — opened from a frame in the pile
   ========================================================================== */

.wdlg {
  width: fit-content;
  max-width: min(1120px, calc(100vw / var(--ui-zoom) - 40px));
  max-width: none;
  max-height: calc(100vh / var(--ui-zoom) - 40px);
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 16px;
  background: #0a0e16;
  color: #eef2f8;
  overflow: hidden;
}

.wdlg::backdrop {
  background: rgba(4, 7, 12, 0.9);
}

.wdlg[open] {
  animation: wdlg-in 0.42s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.wdlg[open]::backdrop {
  animation: wdlg-fade 0.34s ease both;
}

@keyframes wdlg-in {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.955);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes wdlg-fade {
  from { opacity: 0; }
  to { opacity: 1; }
}

.wdlg__inner {
  padding: 13px 15px 15px;
}

.wdlg__head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 10px;
}

.wdlg__meta {
  min-width: 0;
}

.wdlg__title {
  font-size: 0.92rem;
  font-weight: 600;
  color: #f2f6fc;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.wdlg__sub {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 5px;
  font-size: 0.62rem;
  color: #93a1b8;
}

/* the model and method carry a background: they are what the reader needs to
   identify a clip at a glance, and as bare grey text they were easy to miss */
.wdlg__pill {
  padding: 2px 7px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 0.6rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: #dbe6f6;
  background: rgba(255, 255, 255, 0.09);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.09);
}

.wdlg__pill--model {
  color: #cfe0ff;
  background: rgba(92, 155, 232, 0.2);
  box-shadow: inset 0 0 0 1px rgba(92, 155, 232, 0.34);
}

.wdlg__pill--method {
  color: #ffd8bd;
  background: rgba(184, 107, 75, 0.24);
  box-shadow: inset 0 0 0 1px rgba(224, 169, 127, 0.32);
}

.wdlg__vs {
  color: #8e9bb1;
}

.wdlg__head .lightbox__close {
  margin-left: auto;
  flex: none;
}

.wdlg__cap {
  margin: 10px 2px 0;
  font-size: 0.68rem;
  line-height: 1.5;
  color: #9aa6bb;
}

.wipe {
  position: relative;
  width: min(820px, 86vw);
  aspect-ratio: var(--wipe-ar, 832 / 480);
  margin-inline: auto;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  overflow: hidden;
  background: #05080d;
  cursor: ew-resize;
  touch-action: none;
  outline: none;
  -webkit-user-select: none;
  user-select: none;
}

.wipe:focus-visible {
  border-color: color-mix(in srgb, var(--blue) 65%, transparent);
}

.wipe__layer {
  position: absolute;
  inset: 0;
  overflow: hidden;
}

/* one file, two halves: each layer shows its own half blown up to full width */
/* One raster per layer, at the layer's own width.

   The earlier version gave each video `width: 200%` and shifted it by -100 %,
   so every layer rasterised and composited at twice the stage width for content
   that is then clipped away. `object-fit: cover` with an edge `object-position`
   shows exactly the same half of the frame while compositing only the visible
   pixels. `cover` cannot crop here in practice: the stage ratio comes from the
   clip's own metadata, so the scale is already exact. */
.wipe__layer video {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.wipe__layer--a video {
  object-position: left center;
}

.wipe__layer--b video {
  object-position: right center;
}

.wipe__layer--b {
  clip-path: inset(0 0 0 50%);
}

.wipe__tag {
  position: absolute;
  top: 8px;
  z-index: 4;
  padding: 2px 7px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 0.56rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #eef2f8;
  background: rgba(8, 12, 20, 0.82);
  pointer-events: none;
}

.wipe__tag--l { left: 8px; }

.wipe__tag--r {
  right: 8px;
  color: #ffd8bd;
  background: rgba(62, 28, 14, 0.66);
}

.wipe__handle {
  position: absolute;
  z-index: 5;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 2px;
  margin-left: -1px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 0 14px rgba(0, 0, 0, 0.55);
  pointer-events: none;
}

.wipe__handle i {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 32px;
  height: 32px;
  margin: -16px 0 0 -16px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(12, 17, 27, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.55);
  color: #fff;
}

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

.wipe__flip {
  position: absolute;
  z-index: 6;
  right: 8px;
  bottom: 8px;
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 6px;
  background: rgba(8, 12, 20, 0.66);
  color: #e6edf8;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.2s ease, background 0.2s ease;
}

.wipe__flip svg { width: 12px; height: 12px; }

.wipe:hover .wipe__flip,
.wipe:focus-within .wipe__flip {
  opacity: 1;
}

.wipe__flip:hover {
  background: rgba(26, 36, 54, 0.9);
}

/* film strip inside the dialog */

.wstrip {
  display: flex;
  gap: 5px;
  margin-top: 10px;
  overflow-x: auto;
  padding-bottom: 3px;
  scrollbar-width: thin;
}

.wstrip::-webkit-scrollbar { height: 4px; }
.wstrip::-webkit-scrollbar-thumb {
  background: #33405a;
  border-radius: 999px;
}

.wthumb {
  flex: none;
  width: 62px;
  aspect-ratio: 832 / 480;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 5px;
  overflow: hidden;
  background: #0a0f18;
  cursor: pointer;
  opacity: 0.58;
  transition: opacity 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

.wthumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: left center;
  display: block;
}

.wthumb:hover {
  opacity: 1;
  transform: translateY(-1px);
}

.wthumb.is-active {
  opacity: 1;
  border-color: color-mix(in srgb, #b86b4b 75%, transparent);
}

/* ==========================================================================
   responsive
   ========================================================================== */

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

@media (max-width: 760px) {
  .vzone .chips {
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    margin-left: auto;
  }

  .vzone .chips::-webkit-scrollbar { display: none; }
  .vzone .chip { flex: none; }

  .vmtile {
    width: 180px;
  }

  .vpile {
    height: 300px;
  }

  .vstack {
    height: 268px;
    --peek: 24px;
  }

  .wthumb { width: 54px; }

  .wdlg {
    width: calc(100vw / var(--ui-zoom));
    max-height: calc(100vh / var(--ui-zoom));
    border-radius: 0;
    border: 0;
  }
}

/* ---------- reduced motion: everything static ---------- */

@media (prefers-reduced-motion: reduce) {
  .vrow__track {
    animation: none;
    transform: none;
  }

  .vrow {
    overflow-x: auto;
  }

  .vpile__item {
    animation: none;
    opacity: 0.94;
    visibility: visible;
    transform: rotate(var(--rot));
  }

  .vstack__card,
  .vmtile,
  .vmtile img,
  .vpile__item img {
    transition: none;
  }

  .wdlg[open],
  .wdlg[open]::backdrop {
    animation: none;
  }
}


/* The induction band: the whole exposed edge of the deck, from the front card's
   right border to the rightmost card's right border. It is invisible -- it is
   there to give the pointer a landing area, and it must sit above the cards so
   that a drift near an edge is noticed at all. */
.vstack__edge {
  position: absolute;
  top: 0;
  bottom: 0;
  right: 0;
  /* Begins exactly at the front card's right border: the exposed edge is the
     region that answers, which is what the reader expects. */
  left: calc(100% - var(--peek) * 3);
  z-index: 40;
  cursor: e-resize;
  border-radius: 0 12px 12px 0;
  background: linear-gradient(
    to right,
    rgba(224, 169, 127, 0) 0%,
    rgba(224, 169, 127, 0) 60%,
    rgba(224, 169, 127, 0.1) 100%
  );
  opacity: 0;
  transition: opacity 0.24s ease;
}

/* a faint warm wash when the pointer is in the band, so the reader can see the
   region that responds */
.vstack__edge:hover {
  opacity: 1;
}


/* ==========================================================================
   03 · foreground motion for the card deck
   A slow aurora behind the stack and a few drifting motes in front of it. Both
   are decorative, both stop under reduced motion.
   ========================================================================== */

.vstack::before {
  content: "";
  position: absolute;
  inset: 6% -4% -4% -4%;
  border-radius: 40% 46% 42% 48%;
  background:
    radial-gradient(52% 52% at 30% 26%, rgba(143, 127, 221, 0.22), transparent 68%),
    radial-gradient(48% 48% at 74% 68%, rgba(226, 160, 124, 0.18), transparent 66%),
    radial-gradient(40% 40% at 52% 92%, rgba(88, 143, 220, 0.14), transparent 70%);
  /* no `filter: blur()` here: a blurred element that also animates its
     transform is re-rasterised every frame, which dominated the paint budget.
     The gradients below are already soft, so the blur was buying very little. */
  animation: vstack-aurora 18s ease-in-out infinite alternate;
  pointer-events: none;
  z-index: 0;
}

@keyframes vstack-aurora {
  0% {
    transform: translate3d(-2%, 1%, 0) scale(1);
    opacity: 0.75;
  }
  50% {
    transform: translate3d(2%, -2%, 0) scale(1.06);
    opacity: 1;
  }
  100% {
    transform: translate3d(-1%, -1%, 0) scale(1.02);
    opacity: 0.85;
  }
}

/* motes: a handful of soft points that rise past the deck */
.vstack::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(circle at 18% 82%, rgba(226, 190, 160, 0.55) 0 1.4px, transparent 1.6px),
    radial-gradient(circle at 34% 68%, rgba(190, 180, 245, 0.5) 0 1.1px, transparent 1.4px),
    radial-gradient(circle at 62% 88%, rgba(226, 190, 160, 0.45) 0 1px, transparent 1.3px),
    radial-gradient(circle at 78% 60%, rgba(190, 180, 245, 0.4) 0 1.3px, transparent 1.6px),
    radial-gradient(circle at 88% 78%, rgba(226, 190, 160, 0.35) 0 0.9px, transparent 1.2px),
    radial-gradient(circle at 48% 74%, rgba(190, 180, 245, 0.35) 0 1px, transparent 1.3px);
  background-size: 100% 100%;
  animation: vstack-motes 22s linear infinite;
  pointer-events: none;
  z-index: 6;
  opacity: 0.85;
}

@keyframes vstack-motes {
  0% {
    transform: translate3d(0, 12px, 0);
    opacity: 0.35;
  }
  25% {
    opacity: 0.85;
  }
  60% {
    opacity: 0.7;
  }
  100% {
    transform: translate3d(-10px, -34px, 0);
    opacity: 0;
  }
}

/* a slow sheen across the front card */
.vstack__card.is-front::after {
  content: "";
  position: absolute;
  background: linear-gradient(
    104deg,
    transparent 34%,
    rgba(255, 255, 255, 0.12) 47%,
    rgba(255, 255, 255, 0.02) 55%,
    transparent 66%
  );
  /* a band three times the card's width, slid by transform: the highlight still
     crosses the card, but nothing is repainted */
  width: 300%;
  left: -100%;
  right: auto;
  inset-block: 0;
  background: linear-gradient(
    104deg,
    transparent 38%,
    rgba(255, 255, 255, 0.12) 47%,
    rgba(255, 255, 255, 0.02) 55%,
    transparent 62%
  );
  animation: vstack-sheen 7.5s ease-in-out infinite;
  pointer-events: none;
  z-index: 3;
  will-change: transform;
}

@keyframes vstack-sheen {
  0% {
    transform: translate3d(60%, 0, 0);
  }
  55%,
  100% {
    transform: translate3d(-60%, 0, 0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .vstack::before,
  .vstack::after,
  .vstack__card.is-front::after {
    animation: none;
  }
}

/* ---------- narrow screens: stack the pair, keep both stages square -------- */

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

  .vpile,
  .vstack {
    max-width: 520px;
    margin-inline: auto;
  }
}


/* ---------- arrows over the front card ---------- */

/* Exactly the front card's box, and transparent to the pointer, so the card
   underneath keeps receiving clicks. Only the buttons are interactive. */
.vstack__nav {
  position: absolute;
  left: 0;
  top: 0;
  width: calc(100% - var(--peek) * 3);
  aspect-ratio: 1062 / 986;
  z-index: 60;
  pointer-events: none;
  visibility: hidden;
  opacity: 0;
  transition: opacity 0.28s ease, visibility 0s linear 0.28s;
}

.vstack.is-hover .vstack__nav,
.vstack:hover .vstack__nav,
.vstack:focus-within .vstack__nav {
  opacity: 1;
  visibility: visible;
  transition: opacity 0.28s ease, visibility 0s;
}

.vstack__arrow {
  position: absolute;
  top: 50%;
  width: 38px;
  height: 38px;
  margin-top: -19px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.55);
  border-radius: 50%;
  /* a solid fill, deliberately: `backdrop-filter` is what made the wipe stutter
     (it forces the whole page to re-blur each frame) and in a software-composited
     browser it can fail to paint the element at all. */
  background: #0d1220;
  color: #fff;
  cursor: pointer;
  pointer-events: auto;
  box-shadow:
    0 0 0 1px rgba(224, 169, 127, 0.5),
    0 8px 20px -8px rgba(0, 0, 0, 0.95),
    inset 0 1px 0 rgba(255, 255, 255, 0.14);
  transition: background 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

.vstack__arrow svg {
  width: 16px;
  height: 16px;
}

.vstack__arrow--prev {
  left: 10px;
}

.vstack__arrow--next {
  /* sits inboard of the band's left edge, so the two never fight for the click */
  right: calc(var(--nudge-inset) * 0.5);
}

.vstack__arrow--next svg {
  margin-left: 2px;
}

.vstack__arrow--prev svg {
  margin-right: 2px;
}

.vstack__arrow:hover {
  background: rgba(46, 34, 66, 0.9);
  border-color: rgba(224, 169, 127, 0.7);
  transform: scale(1.08);
}

.vstack__arrow:focus-visible {
  outline: 2px solid rgba(224, 169, 127, 0.9);
  outline-offset: 2px;
}

@media (max-width: 760px) {
  .vstack__arrow {
    width: 30px;
    height: 30px;
    margin-top: -15px;
  }

  .vstack__arrow svg {
    width: 13px;
    height: 13px;
  }

  .vstack__arrow--prev {
    left: 6px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .vstack__nav,
  .vstack__arrow {
    transition: none;
  }
}
