/* Pixel showreel frame: the home page video (.video-section > .video-link).
   Same language as pixel-cards.css, on its own properties so the two never clash:
   - .video-link::before  the shadow: the frame's stepped shape, offset down-right,
                           staying on the ground while the frame lifts.
                           Light: solid warm ink. Dark: 50% checker dither.
   - .video-link::after   fill + the 1px stepped outline (4px radius), clipped.
   - .background-video    the video, clipped to the outline's inner edge; on hover
                           it steps in one more pixel, leaving a 1px mat.
   - .play-button         a 24-cell pixel circle (16 cells on phones) on a 4px grid,
                           solid ink with a dithered one-cell shadow; the glyph is
                           the library play-solid icon in ecru.
   - focus                the toggle's corner brackets, 6px outside the frame.
   No scale, no blur, no soft shadow: every move is a whole pixel, in steps. */

@property --pv-lift { syntax: "<length>"; inherits: true; initial-value: 0px; }
@property --pv-base { syntax: "<length>"; inherits: true; initial-value: 0px; }
@property --pv-press { syntax: "<number>"; inherits: true; initial-value: 0; }
@property --pv-line { syntax: "<color>"; inherits: true; initial-value: transparent; }
@property --pv-btn { syntax: "<length>"; inherits: true; initial-value: 0px; }

.video-section .video-link {
  --pv-line-rest: var(--swatch--ecru-50);
  --pv-line-on: var(--swatch--neutral-100);
  --pv-line: var(--pv-line-rest);
  --pv-shadow: color-mix(in srgb, var(--swatch--neutral-100) 78%, var(--swatch--ecru-50));
  --pv-shadow-paint: var(--pv-shadow);
  --pv-fill: var(--color--background-2);
  --pv-brackets: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='30' height='30' shape-rendering='crispEdges' fill='%233d4653'%3E%3Cpath d='M0 0h10v2H2v8H0z M30 0h-10v2h8v8h2z M0 30h10v-2H2v-8H0z M30 30h-10v-2h8v-8h2z'/%3E%3C/svg%3E");
  --pv-lift: 0px;
  --pv-base: 0px;
  --pv-press: 0;
  --pv-btn: 0px;
  position: relative;
  isolation: isolate;
  display: block;
  box-sizing: border-box;
  border: 0 none;
  border-radius: 0;
  border-image: none;
  outline: none !important;
  overflow: visible;
  background: transparent;
  box-shadow: none;
  filter: none;
  transform: none;
  scale: 1;
  translate:
    round(calc(var(--pv-press) * (var(--pv-base) + var(--pv-lift)) - var(--pv-lift)), 1px)
    round(calc(var(--pv-press) * (var(--pv-base) + var(--pv-lift)) - var(--pv-lift)), 1px);
  transition:
    --pv-lift 80ms steps(2, end),
    --pv-base 80ms steps(2, end),
    --pv-line 80ms steps(2, end),
    --pv-btn 80ms steps(2, end),
    --pv-press 120ms linear(0, 0 0%, 1.1667 0%, 1.1667 33.3%, 1 33.3%, 1);
  -webkit-tap-highlight-color: transparent;
}

html.dark-mode .video-section .video-link {
  --pv-line-rest: var(--swatch--neutral-80);
  --pv-line-on: var(--swatch--neutral-10);
  --pv-shadow: var(--swatch--neutral-60);
  --pv-shadow-paint: repeating-conic-gradient(var(--pv-shadow) 0 25%, transparent 0 50%) 0 0 / 2px 2px;
  --pv-brackets: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='30' height='30' shape-rendering='crispEdges' fill='%23bfc8d4'%3E%3Cpath d='M0 0h10v2H2v8H0z M30 0h-10v2h8v8h2z M0 30h10v-2H2v-8H0z M30 30h-10v-2h8v-8h2z'/%3E%3C/svg%3E");
}

/* Shadow: the frame's own stepped shape, (base + lift) * (1 - press) behind it. */
.video-section .video-link::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -2;
  background: var(--pv-shadow-paint);
  clip-path: polygon(0px 5px, 1px 5px, 1px 3px, 2px 3px, 2px 2px, 3px 2px, 3px 1px, 5px 1px, 5px 0px, calc(100% - 5px) 0px, calc(100% - 5px) 1px, calc(100% - 3px) 1px, calc(100% - 3px) 2px, calc(100% - 2px) 2px, calc(100% - 2px) 3px, calc(100% - 1px) 3px, calc(100% - 1px) 5px, 100% 5px, 100% calc(100% - 5px), calc(100% - 1px) calc(100% - 5px), calc(100% - 1px) calc(100% - 3px), calc(100% - 2px) calc(100% - 3px), calc(100% - 2px) calc(100% - 2px), calc(100% - 3px) calc(100% - 2px), calc(100% - 3px) calc(100% - 1px), calc(100% - 5px) calc(100% - 1px), calc(100% - 5px) 100%, 5px 100%, 5px calc(100% - 1px), 3px calc(100% - 1px), 3px calc(100% - 2px), 2px calc(100% - 2px), 2px calc(100% - 3px), 1px calc(100% - 3px), 1px calc(100% - 5px), 0px calc(100% - 5px));
  translate:
    round(calc((var(--pv-base) + var(--pv-lift)) * (1 - var(--pv-press))), 1px)
    round(calc((var(--pv-base) + var(--pv-lift)) * (1 - var(--pv-press))), 1px);
  pointer-events: none;
}

/* Fill + 1px stepped outline. */
.video-section .video-link::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background-image: linear-gradient(var(--pv-line), var(--pv-line)), linear-gradient(var(--pv-line), var(--pv-line)), linear-gradient(var(--pv-line), var(--pv-line)), linear-gradient(var(--pv-line), var(--pv-line)), linear-gradient(var(--pv-line), var(--pv-line)), linear-gradient(var(--pv-line), var(--pv-line)), linear-gradient(var(--pv-line), var(--pv-line)), linear-gradient(var(--pv-line), var(--pv-line)), linear-gradient(var(--pv-line), var(--pv-line)), linear-gradient(var(--pv-line), var(--pv-line)), linear-gradient(var(--pv-line), var(--pv-line)), linear-gradient(var(--pv-line), var(--pv-line)), linear-gradient(var(--pv-line), var(--pv-line)), linear-gradient(var(--pv-line), var(--pv-line)), linear-gradient(var(--pv-line), var(--pv-line)), linear-gradient(var(--pv-line), var(--pv-line)), linear-gradient(var(--pv-fill), var(--pv-fill));
  background-position: left 5px top 0, left 5px bottom 0, left 0 top 5px, right 0 top 5px, left 3px top 1px, left 2px top 2px, left 1px top 3px, left 3px bottom 1px, left 2px bottom 2px, left 1px bottom 3px, right 3px top 1px, right 2px top 2px, right 1px top 3px, right 3px bottom 1px, right 2px bottom 2px, right 1px bottom 3px, 0 0;
  background-size: calc(100% - 10px) 1px, calc(100% - 10px) 1px, 1px calc(100% - 10px), 1px calc(100% - 10px), 2px 1px, 1px 1px, 1px 2px, 2px 1px, 1px 1px, 1px 2px, 2px 1px, 1px 1px, 1px 2px, 2px 1px, 1px 1px, 1px 2px, 100% 100%;
  background-repeat: no-repeat;
  clip-path: polygon(0px 5px, 1px 5px, 1px 3px, 2px 3px, 2px 2px, 3px 2px, 3px 1px, 5px 1px, 5px 0px, calc(100% - 5px) 0px, calc(100% - 5px) 1px, calc(100% - 3px) 1px, calc(100% - 3px) 2px, calc(100% - 2px) 2px, calc(100% - 2px) 3px, calc(100% - 1px) 3px, calc(100% - 1px) 5px, 100% 5px, 100% calc(100% - 5px), calc(100% - 1px) calc(100% - 5px), calc(100% - 1px) calc(100% - 3px), calc(100% - 2px) calc(100% - 3px), calc(100% - 2px) calc(100% - 2px), calc(100% - 3px) calc(100% - 2px), calc(100% - 3px) calc(100% - 1px), calc(100% - 5px) calc(100% - 1px), calc(100% - 5px) 100%, 5px 100%, 5px calc(100% - 1px), 3px calc(100% - 1px), 3px calc(100% - 2px), 2px calc(100% - 2px), 2px calc(100% - 3px), 1px calc(100% - 3px), 1px calc(100% - 5px), 0px calc(100% - 5px));
  pointer-events: none;
}

/* The video: flush with the outline's inner edge. No blur, no brightness hover. */
.video-section .video-link .background-video,
.video-section .video-link .background-video:hover,
.video-section .video-link .background-video:active {
  border: 0 none;
  border-radius: 0;
  filter: none;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  transition: none;
  clip-path: polygon(1px 5px, 2px 5px, 2px 3px, 3px 3px, 3px 2px, 5px 2px, 5px 1px, calc(100% - 5px) 1px, calc(100% - 5px) 2px, calc(100% - 3px) 2px, calc(100% - 3px) 3px, calc(100% - 2px) 3px, calc(100% - 2px) 5px, calc(100% - 1px) 5px, calc(100% - 1px) calc(100% - 5px), calc(100% - 2px) calc(100% - 5px), calc(100% - 2px) calc(100% - 3px), calc(100% - 3px) calc(100% - 3px), calc(100% - 3px) calc(100% - 2px), calc(100% - 5px) calc(100% - 2px), calc(100% - 5px) calc(100% - 1px), 5px calc(100% - 1px), 5px calc(100% - 2px), 3px calc(100% - 2px), 3px calc(100% - 3px), 2px calc(100% - 3px), 2px calc(100% - 5px), 1px calc(100% - 5px));
}
.video-section .video-link .video-depixel-overlay {
  border-radius: 0;
}

/* Play button: pixel circle. ::before = dithered shadow, ::after = ink fill. */
.video-section .video-link .play-button {
  --pv-size: 96px;
  --pv-cell: 4px;
  --pv-circle: polygon(62.5% 0%, 62.5% 4.16667%, 75% 4.16667%, 75% 8.33333%, 79.1667% 8.33333%, 79.1667% 12.5%, 83.3333% 12.5%, 83.3333% 16.6667%, 87.5% 16.6667%, 87.5% 20.8333%, 91.6667% 20.8333%, 91.6667% 25%, 95.8333% 25%, 95.8333% 29.1667%, 95.8333% 33.3333%, 95.8333% 37.5%, 100% 37.5%, 100% 41.6667%, 100% 45.8333%, 100% 50%, 100% 54.1667%, 100% 58.3333%, 100% 62.5%, 95.8333% 62.5%, 95.8333% 66.6667%, 95.8333% 70.8333%, 95.8333% 75%, 91.6667% 75%, 91.6667% 79.1667%, 87.5% 79.1667%, 87.5% 83.3333%, 83.3333% 83.3333%, 83.3333% 87.5%, 79.1667% 87.5%, 79.1667% 91.6667%, 75% 91.6667%, 75% 95.8333%, 62.5% 95.8333%, 62.5% 100%, 37.5% 100%, 37.5% 95.8333%, 25% 95.8333%, 25% 91.6667%, 20.8333% 91.6667%, 20.8333% 87.5%, 16.6667% 87.5%, 16.6667% 83.3333%, 12.5% 83.3333%, 12.5% 79.1667%, 8.33333% 79.1667%, 8.33333% 75%, 4.16667% 75%, 4.16667% 70.8333%, 4.16667% 66.6667%, 4.16667% 62.5%, 0% 62.5%, 0% 58.3333%, 0% 54.1667%, 0% 50%, 0% 45.8333%, 0% 41.6667%, 0% 37.5%, 4.16667% 37.5%, 4.16667% 33.3333%, 4.16667% 29.1667%, 4.16667% 25%, 8.33333% 25%, 8.33333% 20.8333%, 12.5% 20.8333%, 12.5% 16.6667%, 16.6667% 16.6667%, 16.6667% 12.5%, 20.8333% 12.5%, 20.8333% 8.33333%, 25% 8.33333%, 25% 4.16667%, 37.5% 4.16667%, 37.5% 0%);
  --pv-ink: var(--swatch--neutral-100);
  --pv-glyph: var(--swatch--ecru-10);
  --pv-btn-shadow: repeating-conic-gradient(var(--swatch--neutral-100) 0 25%, transparent 0 50%) 0 0 / 2px 2px;
  isolation: isolate;
  display: flex;
  align-items: center;
  justify-content: center;
  width: var(--pv-size);
  height: var(--pv-size);
  border-radius: 0;
  background: transparent;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  mix-blend-mode: normal;
  box-shadow: none;
  filter: none;
  transform: none;
  scale: 1;
  /* No translate of its own: the button rides the frame's lift and press
     exactly (same transform, same frames), so the two read as one object. */
  translate: none;
  transition: none;
  overflow: visible;
}
.video-section .video-link .play-button::before,
.video-section .video-link .play-button::after {
  content: "";
  position: absolute;
  inset: 0;
  clip-path: var(--pv-circle);
  pointer-events: none;
}
.video-section .video-link .play-button::before {
  z-index: -2;
  background: var(--pv-btn-shadow);
  /* one cell down-right at rest, plus the lift; flat when pressed */
  translate:
    round(calc((var(--pv-cell) + var(--pv-btn)) * (1 - var(--pv-press))), 1px)
    round(calc((var(--pv-cell) + var(--pv-btn)) * (1 - var(--pv-press))), 1px);
}
.video-section .video-link .play-button::after {
  z-index: -1;
  background: var(--pv-ink);
}
.video-section .video-link .play-button:hover,
.video-section .video-link .play-button:active {
  background: transparent;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  transform: none;
}
/* The glyph: 48px on a 2px grid, sits 2px right of centre (the triangle's optical centre). */
.video-section .video-link .play-button svg.play-icon {
  position: static;
  inset: auto;
  display: block;
  width: calc(var(--pv-size) / 2);
  height: calc(var(--pv-size) / 2);
  padding: 0;
  margin: 0 0 0 calc(var(--pv-cell) / 2);
  color: var(--pv-glyph);
  shape-rendering: crispEdges;
  translate: 0 0;
  transition: translate 80ms steps(2, end), color 80ms steps(2, end);
}

/* Hover (mouse only): the frame lifts in 4 frames like the cards, the outline
   inks in, the video steps in to a 1px mat, the play button rises one more
   pixel off its shadow and the glyph nudges right by one icon pixel. */
@media (hover: hover) and (pointer: fine) {
  .video-section .video-link:hover {
    --pv-lift: 2px;
    --pv-base: 4px;
    --pv-line: var(--pv-line-on);
    --pv-btn: 2px;
    border-color: transparent;
    transform: none;
    transition:
      --pv-lift 160ms linear(0, 0 0%, -0.5 0%, -0.5 25%, 0.5 25%, 0.5 50%, 1.5 50%, 1.5 75%, 1 75%, 1),
      --pv-base 80ms steps(2, end),
      --pv-line 80ms steps(2, end) 40ms,
      --pv-btn 80ms steps(2, end) 40ms,
      --pv-press 120ms linear(0, 0 0%, 1.1667 0%, 1.1667 33.3%, 1 33.3%, 1);
  }
  .video-section .video-link:hover .background-video {
    clip-path: polygon(2px 5px, 3px 5px, 3px 3px, 5px 3px, 5px 2px, calc(100% - 5px) 2px, calc(100% - 5px) 3px, calc(100% - 3px) 3px, calc(100% - 3px) 5px, calc(100% - 2px) 5px, calc(100% - 2px) calc(100% - 5px), calc(100% - 3px) calc(100% - 5px), calc(100% - 3px) calc(100% - 3px), calc(100% - 5px) calc(100% - 3px), calc(100% - 5px) calc(100% - 2px), 5px calc(100% - 2px), 5px calc(100% - 3px), 3px calc(100% - 3px), 3px calc(100% - 5px), 2px calc(100% - 5px));
  }
  .video-section .video-link:hover .play-button svg.play-icon {
    translate: calc(var(--pv-cell) / 2) 0;
    transition: translate 80ms steps(2, end) 160ms, color 80ms steps(2, end);
  }
}

/* Press (mouse and touch): frame and button drop onto their shadows, held. */
.video-section .video-link:active {
  --pv-press: 1;
  --pv-base: 4px;
  --pv-line: var(--pv-line-on);
  transform: none;
  transition: --pv-lift 0s, --pv-base 0s, --pv-line 0s, --pv-btn 0s, --pv-press 0s;
}

/* Keyboard focus: the toggle's corner brackets, 6px outside the frame,
   and the button lifts as on hover. */
.video-section .video-link:focus-visible {
  --pv-line: var(--pv-line-on);
  --pv-btn: 2px;
  border-image: var(--pv-brackets) 10 / 10px / 6px;
}

/* Phones: smaller frame on the same grid, 64px button (16 cells of 4px), 24px glyph. */
@media (max-width: 767px) {
  .video-section .video-link .play-button {
    --pv-size: 64px;
    --pv-circle: polygon(68.75% 0%, 68.75% 6.25%, 81.25% 6.25%, 81.25% 12.5%, 87.5% 12.5%, 87.5% 18.75%, 93.75% 18.75%, 93.75% 25%, 93.75% 31.25%, 100% 31.25%, 100% 37.5%, 100% 43.75%, 100% 50%, 100% 56.25%, 100% 62.5%, 100% 68.75%, 93.75% 68.75%, 93.75% 75%, 93.75% 81.25%, 87.5% 81.25%, 87.5% 87.5%, 81.25% 87.5%, 81.25% 93.75%, 68.75% 93.75%, 68.75% 100%, 31.25% 100%, 31.25% 93.75%, 18.75% 93.75%, 18.75% 87.5%, 12.5% 87.5%, 12.5% 81.25%, 6.25% 81.25%, 6.25% 75%, 6.25% 68.75%, 0% 68.75%, 0% 62.5%, 0% 56.25%, 0% 50%, 0% 43.75%, 0% 37.5%, 0% 31.25%, 6.25% 31.25%, 6.25% 25%, 6.25% 18.75%, 12.5% 18.75%, 12.5% 12.5%, 18.75% 12.5%, 18.75% 6.25%, 31.25% 6.25%, 31.25% 0%);
    margin: auto;
  }
  .video-section .video-link .play-button svg.play-icon {
    width: 24px;
    height: 24px;
    margin-left: 2px;
  }
  .video-section .video-link:hover .play-button svg.play-icon {
    translate: 1px 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .video-section .video-link,
  .video-section .video-link:hover,
  .video-section .video-link:active,
  .video-section .video-link .play-button svg.play-icon {
    transition: none !important;
  }
}

/* ===== Translucent play button with a pixel mosaic behind it ==============
   js/pixel-video.js draws the patch of video behind the button into a tiny
   canvas (one canvas pixel per 4px cell) and scales it up without smoothing,
   so the circle reads as frosted-in-pixels instead of blurred. The ink sits
   on top at 62%, enough for the ecru triangle to stay clearly legible over
   the pale showreel. Without the script (or before the first frame) the fill
   falls back to a 2px dither of 78% / 46% ink over the plain video. */
.video-section .video-link .play-button {
  --pv-ink-a: 62%;
}
.video-section .video-link .play-button::after {
  background: repeating-conic-gradient(
      color-mix(in srgb, var(--pv-ink) 78%, transparent) 0 25%,
      color-mix(in srgb, var(--pv-ink) 46%, transparent) 0 50%
    ) 0 0 / 4px 4px;
}
/* With the mosaic, js/pixel-video.js paints the ink into the canvas (already cut
   to the circle), so the pseudo-element ink is off and nothing depends on clip-path. */
.video-section .video-link .play-button.pv-has-mosaic::after {
  background: transparent;
}
.video-section .video-link .play-button .pv-mosaic {
  position: absolute;
  inset: 0;
  z-index: -1; /* above the shadow (::before, -2), below the ink (::after, -1, later in order) */
  display: block;
  width: 100%;
  height: 100%;
  clip-path: var(--pv-circle);
  image-rendering: -webkit-optimize-contrast;
  image-rendering: crisp-edges;
  image-rendering: pixelated;
  opacity: 0;
  pointer-events: none;
}
.video-section .video-link .play-button.pv-has-mosaic .pv-mosaic {
  opacity: 1;
}
/* The glyph needs to sit above the canvas. */
.video-section .video-link .play-button svg.play-icon {
  position: relative;
  z-index: 0;
}

/* ===== Play button hover (frame hover, button hover and keyboard focus) =====
   - lift: none of its own. The button is carried by the frame's lift and press
     (sinks 1px, rises 1, 3, settles at 2), so it never drifts against the video.
     Once the frame has settled (160ms) its dithered shadow steps 4 > 6px and the
     glyph nudges one icon pixel right, both in 2 steps of 40ms.
   - ink: 62% > 70% > 78% in 2 steps, so the button firms up under the cursor.
   - mosaic: the cells sharpen 8px > 6px > 4px (8px > 4px on phones), stepped
     by js/pixel-video.js on the same 40ms beat.
   - press: the frame drops onto its shadow, carrying the button; the button's
     shadow goes flat with it. */
@property --pv-ink-a { syntax: "<percentage>"; inherits: true; initial-value: 62%; }

.video-section .video-link .play-button {
  transition: --pv-ink-a 80ms steps(2, end);
}
@media (hover: hover) and (pointer: fine) {
  .video-section .video-link:hover {
    transition:
      --pv-lift 160ms linear(0, 0 0%, -0.5 0%, -0.5 25%, 0.5 25%, 0.5 50%, 1.5 50%, 1.5 75%, 1 75%, 1),
      --pv-base 80ms steps(2, end),
      --pv-line 80ms steps(2, end) 40ms,
      --pv-btn 80ms steps(2, end) 160ms,
      --pv-press 120ms linear(0, 0 0%, 1.1667 0%, 1.1667 33.3%, 1 33.3%, 1);
  }
  .video-section .video-link:hover .play-button {
    --pv-ink-a: 78%;
  }
}
.video-section .video-link:focus-visible {
  transition:
    --pv-line 80ms steps(2, end),
    --pv-btn 80ms steps(2, end) 160ms;
}
.video-section .video-link:focus-visible .play-button {
  --pv-ink-a: 78%;
}
.video-section .video-link:focus-visible .play-button svg.play-icon {
  translate: calc(var(--pv-cell) / 2) 0;
  transition: translate 80ms steps(2, end) 160ms, color 80ms steps(2, end);
}
@media (max-width: 767px) {
  .video-section .video-link:focus-visible .play-button svg.play-icon { translate: 1px 0; }
}
/* Press: ink at its firmest, button flat on its shadow (from the rules above). */
.video-section .video-link:active .play-button {
  --pv-ink-a: 84%;
  transition: --pv-ink-a 0s;
}

@media (prefers-reduced-motion: reduce) {
  .video-section .video-link .play-button,
  .video-section .video-link:focus-visible,
  .video-section .video-link:active .play-button {
    transition: none !important;
  }
}

/* ===== Button's own hover: the triangle turns light blue ==================
   Only when the pointer is on the button itself (frame hover keeps ecru), and
   on keyboard focus. Ecru > mid > primary-20 (#b8dcfc) in 2 steps of 40ms:
   about 7:1 on the 62-78% ink in both themes, also over the blue frames.
   Reduced motion: instant (the svg transition is off above). */
@media (hover: hover) and (pointer: fine) {
  .video-section .video-link .play-button:hover {
    --pv-glyph: var(--swatch--primary-20);
  }
}
.video-section .video-link:focus-visible .play-button {
  --pv-glyph: var(--swatch--primary-20);
}
