/* ==========================================================================
   NEUROCLAW — signature slide transition  ·  "SCANLINE REWRITE"
   ---------------------------------------------------------------------------
   ONE dominant idea (Tenet 1), not five. On every slide change a single CRT
   scanline sweeps once down the stage — as if the screen were redrawing the
   next frame line by line — leaving a near-black "recompiling" band behind it
   with a faint cyan→red fringe at the moving edge. The incoming slide then
   does a one-frame boot-flicker as it powers on under the sweep. It reads as
   the deck *recompiling* the next slide — which is the whole thesis
   ("compiled by machine"). Consistent across every slide.

   Why a custom layer, not reveal's built-ins:
   reveal only ships slide/fade/convex/concave/zoom — none nerdy enough, and
   hacking their internals is fragile. So reveal runs transition:'none' and we
   drive the signature here: ONE GPU-only overlay (transform + opacity, no
   layout, no filter, no animated blur/shadow) triggered by a tiny
   slidechanged hook. ~520ms, off the main thread once armed → smooth on stage.

   Accessibility: prefers-reduced-motion disables the whole apparatus and the
   deck falls back to an instant cut — no motion, no flash.
   ========================================================================== */

/* The sweep curtain. It is 200% tall and parked shifted up by half, so its
   opaque lower half + the bright scanline edge enter from the top and exit
   the bottom in a single downward pass. Inert + invisible until armed. */
.nc-sweep {
  position: fixed;
  inset: 0;
  top: -100%;
  height: 200%;
  z-index: 30;                 /* above .reveal slides, below cold-open fullscreen video */
  pointer-events: none;
  opacity: 0;
  background:
    /* the curtain: opaque near-black upper half, then a readable cyan→red
       leading scanline band at the 50% line, transparent below it. The band
       is a touch wide so the moving "write head" reads from across a room. */
    linear-gradient(
      to bottom,
      rgba(8, 7, 7, 0.97)      0%,
      rgba(10, 10, 10, 0.97)   48.8%,
      rgba(43, 212, 196, 0.0)  48.8%,
      rgba(43, 212, 196, 0.45) 49.4%,    /* cyan echo, leading */
      rgba(232, 103, 95, 0.98) 49.9%,    /* hot red write-line */
      rgba(255, 210, 205, 0.9) 50.0%,    /* white-hot core */
      rgba(214, 52, 43, 0.55)  50.2%,
      rgba(214, 52, 43, 0.0)   50.9%,
      transparent              100%
    ),
    /* static CRT scanline texture riding the whole curtain (cheap, no anim) */
    repeating-linear-gradient(
      to bottom,
      rgba(255, 255, 255, 0.04) 0,
      rgba(255, 255, 255, 0.04) 1px,
      transparent 1px,
      transparent 3px
    );
}

/* ARMED — a single pass. Animate transform (GPU) so the scanline edge travels
   from top to bottom of the stage exactly once, then a short fade-out. */
.nc-sweep--run {
  opacity: 1;
  will-change: transform, opacity;
  /* a CRT refresh travels at near-constant speed, so an even ease (not a
     snap) reads as a deliberate line-by-line rewrite, not a flash. 560ms is
     long enough to register from across a room, short enough to stay crisp. */
  animation:
    nc-sweep-pass 560ms cubic-bezier(0.45, 0.05, 0.55, 0.95) forwards,
    nc-sweep-fade 140ms linear 470ms forwards;
}
@keyframes nc-sweep-pass {
  0%   { transform: translate3d(0, 0,   0); }   /* edge at stage top */
  100% { transform: translate3d(0, 50%, 0); }   /* edge past stage bottom */
}
@keyframes nc-sweep-fade {
  0%   { opacity: 1; }
  100% { opacity: 0; }
}

/* The incoming slide powers on under the sweep: a one-frame boot-flicker +
   micro-settle. This is what sells "the next slide is being redrawn" rather
   than "a bar moved". Transform + opacity only — never touches layout. */
.reveal .slides section.nc-boot-in {
  animation: nc-boot-in 520ms cubic-bezier(0.16, 1, 0.3, 1) both;
}
@keyframes nc-boot-in {
  0%   { opacity: 0;    transform: translate3d(0, 0, 0) scale(1.006); }
  8%   { opacity: 0.12; }                         /* dark for the first ~40ms */
  11%  { opacity: 0.92; }                         /* flick on (CRT power-up) */
  15%  { opacity: 0.55; }                         /* a single dip */
  100% { opacity: 1;    transform: translate3d(0, 0, 0) scale(1); }
}

/* A11y: no motion, no flash. Kill the apparatus; reveal does an instant cut. */
@media (prefers-reduced-motion: reduce) {
  .nc-sweep { display: none !important; }
  .reveal .slides section.nc-boot-in {
    animation: none !important;
    opacity: 1 !important;
    transform: none !important;
  }
}
