/* ============================================================
   GLITCH INTRUSION // PHASE ONE: FRACTURE

   7 seconds clean
   -> catastrophic intrusion
   -> permanent compromised state
   -> intermittent electrical faults
   ============================================================ */

body {
  --rg-glitch-a: #00e7ff;
  --rg-glitch-b: #ff3df2;
  --rg-glitch-danger: #ff2a2a;
}


/* ============================================================
   INJECTED LAYERS
   ============================================================ */

.rg-fracture-overlay {
  position: fixed;
  inset: 0;
  z-index: 2147483645;

  overflow: hidden;
  pointer-events: none;

  opacity: 0;
}

.rg-fracture-scare {
  --rg-ghost-x: 50vw;
  --rg-ghost-y: 50vh;
  --rg-ghost-scale: .75;
  --rg-ghost-rotate: 0deg;

  position: fixed;
  left: 50%;
  top: 50%;

  width: min(74vw, 680px);
  max-width: none;

  opacity: 0;

  transform:
    translate(-50%, -50%)
    scale(.45);

  transform-origin: center;

  filter:
    contrast(1.4)
    saturate(1.6)
    drop-shadow(-14px 0 0 rgba(0,231,255,.42))
    drop-shadow(14px 0 0 rgba(255,61,242,.38));
}

.rg-fracture-tear {
  position: absolute;
  left: -10vw;

  width: 120vw;
  height: 16vh;

  opacity: 0;

  background:
    repeating-linear-gradient(
      0deg,
      rgba(255,255,255,.18) 0 1px,
      transparent 1px 4px
    ),
    linear-gradient(
      90deg,
      transparent 0 5%,
      rgba(0,231,255,.50) 5% 17%,
      rgba(0,0,0,.94) 17% 62%,
      rgba(255,61,242,.46) 62% 77%,
      transparent 77%
    );

  mix-blend-mode: screen;
}

.rg-fracture-tear-a {
  top: 19%;
}

.rg-fracture-tear-b {
  top: 61%;
}

.rg-fracture-blackout {
  position: absolute;
  inset: 0;

  opacity: 0;
  background: #000;
}


/* ============================================================
   PERSISTENT DAMAGE
   ============================================================ */

.rg-fracture-contamination {
  position: fixed;
  inset: 0;
  z-index: 2147483000;

  display: none;

  pointer-events: none;

  background:
    linear-gradient(
      90deg,
      transparent 0 11%,
      rgba(0,231,255,.075) 11% 11.15%,
      transparent 11.15% 63%,
      rgba(255,61,242,.06) 63% 63.18%,
      transparent 63.18%
    ),
    repeating-linear-gradient(
      0deg,
      transparent 0 47px,
      rgba(255,255,255,.018) 47px 48px,
      transparent 48px 113px
    );

  mix-blend-mode: screen;
}

body.rg-fractured .rg-fracture-contamination {
  display: block;
}

body.rg-fractured .event-nav {
  filter:
    contrast(1.04)
    drop-shadow(-2px 0 rgba(0,231,255,.18))
    drop-shadow(2px 0 rgba(255,61,242,.14));
}

body.rg-fractured .big-top {
  position: relative;
  left: 1px;
}

body.rg-fractured .attraction-grid {
  position: relative;
  right: 1px;
}

body.rg-fractured .jamboree-marquee-art {
  filter:
    contrast(1.04)
    drop-shadow(-2px 0 rgba(0,231,255,.15))
    drop-shadow(2px 0 rgba(255,61,242,.15));
}


/* ============================================================
   PERSISTENT WARNING
   ============================================================ */

.rg-intrusion-warning {
  position: fixed;
  z-index: 2147483646;

  top: clamp(.65rem, 2vw, 1rem);
  right: clamp(.65rem, 2vw, 1rem);

  display: grid;
  gap: .16rem;

  width: min(21rem, calc(100vw - 1.3rem));

  padding: .72rem .84rem;

  border:
    1px solid
    color-mix(
      in srgb,
      var(--rg-glitch-danger) 78%,
      white
    );

  color: #fff;

  background:
    linear-gradient(
      115deg,
      rgba(15,0,0,.97),
      rgba(0,0,0,.93)
    );

  box-shadow:
    0 0 0 2px rgba(0,0,0,.72),
    0 0 26px rgba(255,0,0,.22),
    -3px 0 rgba(0,231,255,.24),
    3px 0 rgba(255,61,242,.19);

  font-family:
    ui-monospace,
    SFMono-Regular,
    Menlo,
    Monaco,
    Consolas,
    monospace;

  text-transform: uppercase;
  letter-spacing: .055em;

  opacity: 0;
  visibility: hidden;

  transform: translateY(-10px);

  transition:
    opacity 120ms linear,
    transform 120ms linear;
}

.rg-intrusion-warning.is-visible {
  opacity: .96;
  visibility: visible;
  transform: translateY(0);
}

.rg-intrusion-warning-head {
  display: flex;
  align-items: center;
  gap: .42rem;

  color: #ff6565;

  font-size: .69rem;
  font-weight: 900;
}

.rg-intrusion-warning-dot {
  width: .52rem;
  height: .52rem;

  border-radius: 50%;

  background: #ff2525;

  box-shadow:
    0 0 6px #ff2525,
    0 0 12px rgba(255,37,37,.7);

  animation:
    rg-warning-dot 1.35s steps(2,end) infinite;
}

.rg-intrusion-warning strong {
  color: #fff;

  font-size: clamp(.96rem, 3vw, 1.18rem);
  line-height: 1.1;
}

.rg-intrusion-warning > span:not(.rg-intrusion-warning-dot) {
  color: #ff6262;

  font-size: .74rem;
  font-weight: 900;
}

.rg-intrusion-warning small {
  color: rgba(255,255,255,.72);

  font-size: .58rem;
  line-height: 1.3;
}


/* ============================================================
   INITIAL FRACTURE
   ============================================================ */

body.rg-fracture-impact {
  overflow-x: hidden;
}

body.rg-fracture-impact .jamboree-shell {
  animation:
    rg-catastrophic-fracture
    1250ms
    steps(2,end);
}

body.rg-fracture-impact .rg-fracture-overlay {
  opacity: 1;
}

body.rg-fracture-impact .rg-fracture-scare {
  animation:
    rg-jump-scare
    1250ms
    steps(2,end);
}

body.rg-fracture-impact .rg-fracture-tear-a {
  animation:
    rg-tear-a
    1250ms
    steps(2,end);
}

body.rg-fracture-impact .rg-fracture-tear-b {
  animation:
    rg-tear-b
    1250ms
    steps(2,end);
}

body.rg-fracture-impact .rg-fracture-blackout {
  animation:
    rg-blackout-hit
    1250ms
    steps(2,end);
}


@keyframes rg-catastrophic-fracture {
  0% {
    transform: translate(0);
    filter: none;
    clip-path: inset(0);
  }

  8% {
    transform:
      translate(-14px, 3px)
      skewX(-2deg);

    filter:
      contrast(1.35)
      saturate(2.4);

    clip-path:
      polygon(
        0 0,
        100% 0,
        100% 31%,
        93% 32%,
        100% 34%,
        100% 100%,
        0 100%
      );
  }

  16% {
    transform:
      translate(18px, -5px)
      skewX(3deg);

    filter:
      contrast(1.8)
      saturate(3)
      drop-shadow(
        -14px 0
        rgba(0,231,255,.55)
      )
      drop-shadow(
        14px 0
        rgba(255,61,242,.48)
      );
  }

  28% {
    transform:
      translate(-8px, 2px)
      scaleX(1.018);

    clip-path:
      polygon(
        0 0,
        100% 0,
        100% 19%,
        0 23%,
        0 57%,
        100% 53%,
        100% 100%,
        0 100%
      );
  }

  43% {
    transform:
      translate(21px, 1px)
      skewX(-4deg);

    filter:
      contrast(2)
      saturate(2.7);
  }

  57% {
    transform:
      translate(-17px, -3px)
      scaleY(.992);

    clip-path:
      polygon(
        0 0,
        100% 0,
        100% 44%,
        8% 47%,
        100% 50%,
        100% 100%,
        0 100%
      );
  }

  70% {
    transform:
      translate(9px, 1px);

    filter:
      contrast(1.6)
      saturate(3.1)
      hue-rotate(8deg);
  }

  82% {
    transform:
      translate(-5px, 0)
      skewX(1deg);

    opacity: .76;
  }

  91% {
    transform:
      translate(3px, 0);

    opacity: 1;

    filter:
      contrast(1.2)
      saturate(1.7);
  }

  100% {
    transform: translate(0);
    opacity: 1;
    filter: none;
    clip-path: inset(0);
  }
}


@keyframes rg-jump-scare {
  0%,
  10% {
    opacity: 0;

    transform:
      translate(-50%, -50%)
      scale(.36);
  }

  14% {
    opacity: .18;

    transform:
      translate(-54%, -48%)
      scale(.65);
  }

  22% {
    opacity: .96;

    transform:
      translate(-49%, -51%)
      scale(1.06)
      rotate(-2deg);
  }

  31% {
    opacity: .22;

    transform:
      translate(-53%, -48%)
      scale(.92);
  }

  39% {
    opacity: 1;

    transform:
      translate(-47%, -52%)
      scale(1.18)
      rotate(2deg);
  }

  49% {
    opacity: .08;
  }

  58% {
    opacity: .82;

    transform:
      translate(-51%, -49%)
      scale(.88);
  }

  68% {
    opacity: .13;
  }

  100% {
    opacity: 0;

    transform:
      translate(-50%, -50%)
      scale(.55);
  }
}


@keyframes rg-tear-a {
  0%,
  8%,
  100% {
    opacity: 0;
    transform: translateX(0);
  }

  14% {
    opacity: .86;
    transform: translateX(-18vw);
  }

  25% {
    opacity: .18;
    transform: translateX(21vw);
  }

  42% {
    opacity: .76;
    transform: translateX(-8vw);
  }

  63% {
    opacity: .15;
    transform: translateX(17vw);
  }

  79% {
    opacity: .48;
    transform: translateX(-4vw);
  }
}


@keyframes rg-tear-b {
  0%,
  17%,
  100% {
    opacity: 0;
    transform: translateX(0);
  }

  23% {
    opacity: .68;
    transform: translateX(14vw);
  }

  34% {
    opacity: .14;
    transform: translateX(-22vw);
  }

  54% {
    opacity: .82;
    transform: translateX(7vw);
  }

  72% {
    opacity: .12;
    transform: translateX(-11vw);
  }

  87% {
    opacity: .42;
    transform: translateX(5vw);
  }
}


@keyframes rg-blackout-hit {
  0%,
  12%,
  100% {
    opacity: 0;
  }

  13%,
  15% {
    opacity: .94;
  }

  31% {
    opacity: .16;
  }

  32%,
  35% {
    opacity: .88;
  }

  51% {
    opacity: 0;
  }

  69% {
    opacity: .47;
  }

  72% {
    opacity: 0;
  }
}


/* ============================================================
   INTERMITTENT DAMAGE
   ============================================================ */

body.rg-fault-shake .jamboree-shell {
  animation:
    rg-fault-shake
    460ms
    steps(2,end);
}

body.rg-fault-shear .jamboree-shell {
  animation:
    rg-fault-shear
    640ms
    steps(3,end);
}

body.rg-fault-flicker .jamboree-shell {
  animation:
    rg-fault-flicker
    360ms
    steps(2,end);
}

body.rg-fault-ghost .rg-fracture-overlay {
  opacity: 1;
}

body.rg-fault-ghost .rg-fracture-scare {
  animation:
    rg-ghost-manifestation
    680ms
    steps(2,end);
}


@keyframes rg-fault-shake {
  0%,
  100% {
    transform: translate(0);
  }

  18% {
    transform:
      translate(-5px, 1px)
      rotate(-.08deg);
  }

  37% {
    transform:
      translate(6px, -1px)
      rotate(.06deg);
  }

  61% {
    transform:
      translate(-3px, 0);
  }

  79% {
    transform:
      translate(2px, 1px);
  }
}


@keyframes rg-fault-shear {
  0%,
  100% {
    transform: translate(0);
    clip-path: inset(0);
    filter: none;
  }

  19% {
    transform:
      translateX(-8px)
      skewX(-1deg);

    clip-path:
      inset(7% 0 14% 0);

    filter:
      drop-shadow(
        -7px 0
        rgba(0,231,255,.36)
      );
  }

  42% {
    transform:
      translateX(10px)
      skewX(1.4deg);

    clip-path:
      inset(21% 0 3% 0);

    filter:
      drop-shadow(
        8px 0
        rgba(255,61,242,.34)
      );
  }

  68% {
    transform: translateX(-4px);

    clip-path:
      inset(2% 0 19% 0);
  }
}


@keyframes rg-fault-flicker {
  0%,
  100% {
    opacity: 1;
    filter: none;
  }

  17% {
    opacity: .34;

    filter:
      brightness(.42)
      contrast(2);
  }

  26% {
    opacity: 1;

    filter:
      brightness(1.6)
      saturate(2);
  }

  52% {
    opacity: .12;
  }

  63% {
    opacity: .91;

    filter:
      contrast(1.9);
  }

  79% {
    opacity: .48;
  }
}


@keyframes rg-ghost-manifestation {
  0% {
    opacity: 0;

    left: var(--rg-ghost-x);
    top: var(--rg-ghost-y);

    transform:
      translate(-50%, -50%)
      scale(
        calc(
          var(--rg-ghost-scale)
          * .72
        )
      )
      rotate(var(--rg-ghost-rotate));
  }

  18% {
    opacity: .18;
  }

  31% {
    opacity: .58;
  }

  47% {
    opacity: .08;
  }

  64% {
    opacity: .43;
  }

  76% {
    opacity: .11;
  }

  100% {
    opacity: 0;

    left: var(--rg-ghost-x);
    top: var(--rg-ghost-y);

    transform:
      translate(-50%, -50%)
      scale(var(--rg-ghost-scale))
      rotate(var(--rg-ghost-rotate));
  }
}


/* ============================================================
   WARNING LIGHT
   ============================================================ */

@keyframes rg-warning-dot {
  0%,
  46% {
    opacity: 1;
  }

  47%,
  100% {
    opacity: .28;
  }
}


/* ============================================================
   MOBILE
   ============================================================ */

@media (max-width: 640px) {
  .rg-intrusion-warning {
    top: auto;
    right: .55rem;
    bottom: .55rem;
    left: .55rem;

    width: auto;

    padding: .62rem .72rem;
  }

  .rg-fracture-scare {
    width: min(105vw, 580px);
  }
}


/* ============================================================
   REDUCED MOTION
   ============================================================ */

@media (prefers-reduced-motion: reduce) {
  body.rg-fracture-impact .jamboree-shell,
  body.rg-fracture-impact .rg-fracture-scare,
  body.rg-fracture-impact .rg-fracture-tear-a,
  body.rg-fracture-impact .rg-fracture-tear-b,
  body.rg-fracture-impact .rg-fracture-blackout,
  body.rg-fault-shake .jamboree-shell,
  body.rg-fault-shear .jamboree-shell,
  body.rg-fault-flicker .jamboree-shell,
  body.rg-fault-ghost .rg-fracture-scare,
  .rg-intrusion-warning-dot {
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
  }
}


/* ============================================================
   PHASE ONE // BROKEN-STATE OVERRIDE
   The page should look damaged, not merely filtered.
   ============================================================ */

body.rg-fractured {
  overflow-x: hidden;
}


/* whole surviving document is subtly off-axis */
body.rg-fractured .jamboree-shell {
  position: relative;
  transform:
    translateX(-3px)
    skewX(-0.12deg);
}


/* navigation no longer sits correctly */
body.rg-fractured .event-nav {
  transform:
    translate(7px, -2px)
    skewX(-0.7deg);

  clip-path:
    polygon(
      0 0,
      100% 0,
      100% 71%,
      96% 72%,
      100% 76%,
      100% 100%,
      0 100%,
      0 31%,
      3% 29%,
      0 26%
    );

  filter:
    contrast(1.12)
    saturate(1.22)
    drop-shadow(-5px 0 rgba(0,231,255,.28))
    drop-shadow(4px 0 rgba(255,61,242,.25));
}


/* marquee/header got knocked sideways */
body.rg-fractured .big-top {
  left: auto;
  transform:
    translate(-9px, 5px)
    rotate(-0.28deg);
}

body.rg-fractured .marquee-sign {
  transform:
    translateX(5px)
    skewX(.45deg);
}

body.rg-fractured .jamboree-marquee-art {
  transform:
    translateX(-4px)
    scaleX(1.008);

  filter:
    contrast(1.12)
    saturate(1.18)
    drop-shadow(-5px 0 rgba(0,231,255,.26))
    drop-shadow(6px 1px rgba(255,61,242,.24));
}


/* attraction grid is visibly no longer square */
body.rg-fractured .attraction-grid {
  right: auto;

  transform:
    translate(6px, -3px)
    skewX(.18deg);
}


/*
  Individual cards no longer agree on where the grid is.
  Deliberately asymmetric.
*/
body.rg-fractured .attraction-grid > :nth-child(1) {
  transform:
    translate(-13px, 4px)
    rotate(-0.34deg);
}

body.rg-fractured .attraction-grid > :nth-child(2) {
  transform:
    translate(8px, -6px)
    rotate(.42deg);
}

body.rg-fractured .attraction-grid > :nth-child(3) {
  transform:
    translate(-5px, 8px)
    rotate(-.22deg);
}

body.rg-fractured .attraction-grid > :nth-child(4) {
  transform:
    translate(12px, 2px)
    rotate(.31deg);
}

body.rg-fractured .attraction-grid > :nth-child(5) {
  transform:
    translate(-9px, -5px)
    rotate(-.38deg);
}

body.rg-fractured .attraction-grid > :nth-child(6) {
  transform:
    translate(5px, 7px)
    rotate(.19deg);
}


/* make a few cards look physically torn */
body.rg-fractured .attraction-grid > :nth-child(2),
body.rg-fractured .attraction-grid > :nth-child(5) {
  clip-path:
    polygon(
      0 0,
      100% 0,
      100% 39%,
      96% 41%,
      100% 44%,
      100% 100%,
      0 100%
    );
}

body.rg-fractured .attraction-grid > :nth-child(3) {
  clip-path:
    polygon(
      0 0,
      100% 0,
      100% 100%,
      0 100%,
      0 63%,
      4% 61%,
      0 58%
    );
}


/* radio survives, but not in quite the same place */
body.rg-fractured .midway-radio {
  transform:
    translate(-7px, 5px)
    rotate(-.12deg);
}


/* persistent hard tear bands across the viewport */
body.rg-fractured .rg-fracture-contamination {
  display: block;

  background:
    linear-gradient(
      180deg,
      transparent 0 17%,

      rgba(0,0,0,.72) 17% 17.7%,
      rgba(0,231,255,.19) 17.7% 18.05%,
      transparent 18.05% 43%,

      rgba(255,61,242,.13) 43% 43.25%,
      rgba(0,0,0,.58) 43.25% 44.1%,
      transparent 44.1% 68%,

      rgba(0,231,255,.12) 68% 68.2%,
      rgba(0,0,0,.66) 68.2% 69.05%,
      rgba(255,61,242,.12) 69.05% 69.3%,
      transparent 69.3%
    ),

    linear-gradient(
      90deg,
      transparent 0 8%,
      rgba(0,231,255,.09) 8% 8.18%,
      transparent 8.18% 57%,
      rgba(255,61,242,.085) 57% 57.22%,
      transparent 57.22%
    ),

    repeating-linear-gradient(
      0deg,
      transparent 0 34px,
      rgba(255,255,255,.022) 34px 35px,
      transparent 35px 91px
    );
}


/* displaced copies of the damaged horizontal bands */
body.rg-fractured .rg-fracture-contamination::before,
body.rg-fractured .rg-fracture-contamination::after {
  content: "";

  position: absolute;
  left: -4vw;

  width: 108vw;

  pointer-events: none;
}

body.rg-fractured .rg-fracture-contamination::before {
  top: 31%;

  height: 9px;

  background:
    linear-gradient(
      90deg,
      transparent 0 5%,
      rgba(0,231,255,.30) 5% 19%,
      rgba(0,0,0,.88) 19% 61%,
      rgba(255,61,242,.24) 61% 74%,
      transparent 74%
    );

  transform:
    translateX(17px)
    skewX(-19deg);

  opacity: .62;
}

body.rg-fractured .rg-fracture-contamination::after {
  top: 74%;

  height: 6px;

  background:
    linear-gradient(
      90deg,
      rgba(0,0,0,.85),
      rgba(255,61,242,.28) 31%,
      transparent 31% 56%,
      rgba(0,231,255,.25) 56% 78%,
      rgba(0,0,0,.82)
    );

  transform:
    translateX(-21px)
    skewX(24deg);

  opacity: .52;
}


/* some text now carries permanent channel damage */
body.rg-fractured .hero-copy,
body.rg-fractured .ticket-strip {
  text-shadow:
    -2px 0 rgba(0,231,255,.28),
    2px 0 rgba(255,61,242,.22);
}


/* mobile: still damaged, but don't throw content off-screen */
@media (max-width: 640px) {
  body.rg-fractured .big-top {
    transform:
      translate(-4px, 3px)
      rotate(-.18deg);
  }

  body.rg-fractured .attraction-grid {
    transform:
      translate(2px, -2px);
  }

  body.rg-fractured .attraction-grid > :nth-child(odd) {
    transform:
      translate(-5px, 3px)
      rotate(-.18deg);
  }

  body.rg-fractured .attraction-grid > :nth-child(even) {
    transform:
      translate(5px, -3px)
      rotate(.18deg);
  }
}


/* ============================================================
   PHASE ONE // LOCALIZED DAMAGE ENGINE
   ============================================================ */

.rg-fault-stage {
  position: fixed;
  inset: 0;

  z-index: 2147483643;

  overflow: hidden;

  pointer-events: none;
}

.rg-fault-artifact {
  pointer-events: none !important;
  user-select: none !important;
}


/* real DOM fragment kicked sideways */
.rg-fault-slice {
  z-index: 4;

  opacity: .84;

  transform:
    translate(
      var(--rg-slice-x),
      var(--rg-slice-y)
    );

  filter:
    contrast(1.35)
    saturate(1.8)
    drop-shadow(
      -5px 0
      rgba(0,231,255,.48)
    )
    drop-shadow(
      5px 0
      rgba(255,61,242,.42)
    );

  animation:
    rg-local-slice
    520ms
    steps(2,end);
}


/* duplicate DOM afterimage */
.rg-fault-duplicate {
  z-index: 3;

  opacity: .26;

  transform:
    translate(
      var(--rg-duplicate-x),
      var(--rg-duplicate-y)
    );

  mix-blend-mode: screen;

  filter:
    contrast(1.4)
    saturate(1.7)
    hue-rotate(8deg);

  animation:
    rg-local-duplicate
    680ms
    steps(3,end);
}


/* one card gets temporarily torn out of the surviving layout */
body.rg-fractured
.attraction-grid > *.rg-card-fault {
  position: relative;

  z-index: 50;

  animation:
    rg-card-dislocation
    760ms
    steps(3,end) !important;
}


/* partial flashes of the triage image */
.rg-triage-fragment {
  position: fixed;

  left: var(--rg-triage-x);
  top: var(--rg-triage-y);

  width: var(--rg-triage-w);
  height: auto;

  z-index: 5;

  opacity: 0;

  transform:
    rotate(var(--rg-triage-r));

  filter:
    contrast(1.8)
    saturate(1.55)
    drop-shadow(
      -8px 0
      rgba(0,231,255,.42)
    )
    drop-shadow(
      8px 0
      rgba(255,61,242,.38)
    );

  animation:
    rg-triage-fragment-hit
    640ms
    steps(2,end);
}


/* short horizontal failure where the page effectively ceases to exist */
.rg-dead-zone {
  position: fixed;

  top: var(--rg-dead-top);
  left: -5vw;

  width: 110vw;
  height: var(--rg-dead-height);

  z-index: 6;

  opacity: 0;

  background:
    linear-gradient(
      90deg,
      #000 0 18%,
      rgba(0,231,255,.22) 18% 18.5%,
      #000 18.5% 66%,
      rgba(255,61,242,.2) 66% 66.5%,
      #000 66.5%
    );

  transform:
    translateX(var(--rg-dead-shift));

  box-shadow:
    0 -2px rgba(0,231,255,.16),
    0 2px rgba(255,61,242,.15);

  animation:
    rg-dead-zone-hit
    380ms
    steps(2,end);
}


/* rare combined malfunction */
body.rg-fault-major .jamboree-shell {
  animation:
    rg-major-failure
    960ms
    steps(3,end);
}

body.rg-fault-major .rg-fracture-contamination {
  filter:
    contrast(1.8)
    saturate(2.3);
}


/* ------------------------------------------------------------
   Local damage animations
   ------------------------------------------------------------ */

@keyframes rg-local-slice {
  0% {
    opacity: 0;
  }

  14% {
    opacity: .92;
  }

  31% {
    transform:
      translate(
        calc(var(--rg-slice-x) * -0.4),
        var(--rg-slice-y)
      );

    opacity: .44;
  }

  48% {
    transform:
      translate(
        var(--rg-slice-x),
        calc(var(--rg-slice-y) * -1)
      );

    opacity: .88;
  }

  72% {
    transform:
      translate(
        calc(var(--rg-slice-x) * .25),
        0
      );

    opacity: .23;
  }

  100% {
    opacity: 0;
  }
}


@keyframes rg-local-duplicate {
  0% {
    opacity: 0;
  }

  19% {
    opacity: .36;
  }

  37% {
    opacity: .11;

    transform:
      translate(
        calc(var(--rg-duplicate-x) * -1),
        var(--rg-duplicate-y)
      );
  }

  58% {
    opacity: .29;
  }

  100% {
    opacity: 0;

    transform:
      translate(0);
  }
}


@keyframes rg-card-dislocation {
  0% {
    transform:
      translate(0)
      rotate(0);
  }

  17% {
    transform:
      translate(
        var(--rg-card-fault-x),
        var(--rg-card-fault-y)
      )
      rotate(var(--rg-card-fault-r));
  }

  32% {
    transform:
      translate(
        calc(var(--rg-card-fault-x) * -.35),
        calc(var(--rg-card-fault-y) * .55)
      )
      rotate(
        calc(var(--rg-card-fault-r) * -.6)
      );

    filter:
      contrast(1.7)
      saturate(2);
  }

  49% {
    transform:
      translate(
        calc(var(--rg-card-fault-x) * .72),
        calc(var(--rg-card-fault-y) * -.4)
      )
      rotate(var(--rg-card-fault-r));
  }

  66% {
    transform:
      translate(
        calc(var(--rg-card-fault-x) * -.18),
        0
      );
  }

  100% {
    transform: none;
    filter: none;
  }
}


@keyframes rg-triage-fragment-hit {
  0%,
  10% {
    opacity: 0;
  }

  18% {
    opacity: .72;
  }

  29% {
    opacity: .11;

    transform:
      translateX(-12px)
      rotate(var(--rg-triage-r));
  }

  42% {
    opacity: .88;

    transform:
      translateX(9px)
      rotate(var(--rg-triage-r));
  }

  57% {
    opacity: .17;
  }

  71% {
    opacity: .53;
  }

  100% {
    opacity: 0;
  }
}


@keyframes rg-dead-zone-hit {
  0% {
    opacity: 0;
  }

  9% {
    opacity: .96;
  }

  29% {
    opacity: .41;

    transform:
      translateX(
        calc(var(--rg-dead-shift) * -1)
      );
  }

  47% {
    opacity: .94;
  }

  68% {
    opacity: .23;
  }

  100% {
    opacity: 0;
  }
}


@keyframes rg-major-failure {
  0%,
  100% {
    transform: inherit;
    filter: none;
  }

  11% {
    transform:
      translate(-14px, 2px)
      skewX(-1.3deg);

    filter:
      contrast(1.7)
      saturate(2.2);
  }

  23% {
    transform:
      translate(18px, -3px)
      skewX(2deg);

    filter:
      contrast(2)
      saturate(2.8)
      hue-rotate(7deg);
  }

  39% {
    transform:
      translate(-6px, 1px);

    opacity: .68;
  }

  53% {
    transform:
      translate(11px, 0)
      skewX(-.9deg);

    opacity: 1;
  }

  71% {
    transform:
      translate(-3px, -1px);

    filter:
      contrast(1.5)
      saturate(2);
  }

  86% {
    transform:
      translate(2px, 0);
  }
}


/* localized artifacts disappear entirely for reduced-motion users */
@media (prefers-reduced-motion: reduce) {
  .rg-fault-stage {
    display: none !important;
  }

  body.rg-fractured
  .attraction-grid > *.rg-card-fault,
  body.rg-fault-major .jamboree-shell {
    animation-duration: 1ms !important;
  }
}


/* ============================================================
   PHASE ONE // DANGER ZONE ESCALATION
   ============================================================ */

/*
  During a major failure the surviving page itself nearly loses
  synchronization with the viewport.
*/
body.rg-fault-major {
  background: #000;
}

body.rg-fault-major .jamboree-shell {
  animation:
    rg-danger-zone-collapse
    1550ms
    steps(2,end) !important;
}


/*
  Persistent compromised state now has a damaged perimeter.
  Not animated constantly: it should read as system damage.
*/
body.rg-fractured::before {
  content: "";

  position: fixed;
  inset: 0;

  z-index: 2147483001;

  pointer-events: none;

  border:
    clamp(2px, .25vw, 5px)
    solid
    rgba(255,25,25,.20);

  box-shadow:
    inset 0 0 58px rgba(255,0,0,.12),
    inset 0 0 160px rgba(0,0,0,.40);

  clip-path:
    polygon(
      0 0,
      100% 0,
      100% 18%,
      99.3% 21%,
      100% 24%,
      100% 100%,
      72% 100%,
      69% 99.2%,
      64% 100%,
      0 100%,
      0 77%,
      .7% 73%,
      0 69%
    );
}


/*
  Local artifacts now look like actual chunks of the page escaping
  their coordinate space.
*/
.rg-fault-slice {
  opacity: .96;

  filter:
    contrast(1.85)
    saturate(2.8)
    brightness(1.08)
    drop-shadow(
      -12px 0
      rgba(0,231,255,.70)
    )
    drop-shadow(
      13px 0
      rgba(255,61,242,.68)
    );
}

.rg-fault-duplicate {
  opacity: .48;

  mix-blend-mode: difference;

  filter:
    contrast(2.1)
    saturate(2.6)
    hue-rotate(24deg);
}


/* dead zones become actual missing signal */
.rg-dead-zone {
  background:
    repeating-linear-gradient(
      0deg,
      rgba(255,255,255,.06) 0 1px,
      transparent 1px 4px
    ),
    linear-gradient(
      90deg,
      #000 0 9%,
      rgba(0,231,255,.44) 9% 10%,
      #000 10% 28%,
      rgba(255,255,255,.08) 28% 29%,
      #000 29% 61%,
      rgba(255,61,242,.42) 61% 62%,
      #000 62% 83%,
      rgba(0,231,255,.35) 83% 84%,
      #000 84%
    );

  box-shadow:
    0 -4px rgba(0,231,255,.26),
    0 4px rgba(255,61,242,.25),
    0 0 30px rgba(0,0,0,.96);
}


/* triage fragments should be unmistakable when they appear */
.rg-triage-fragment {
  filter:
    contrast(2.2)
    saturate(2)
    brightness(1.12)
    drop-shadow(
      -15px 0
      rgba(0,231,255,.64)
    )
    drop-shadow(
      16px 0
      rgba(255,61,242,.61)
    );
}


/*
  Catastrophic short-lived collapse.
  Several frames intentionally approach blackout.
*/
@keyframes rg-danger-zone-collapse {
  0%,
  100% {
    transform:
      translateX(-3px)
      skewX(-.12deg);

    opacity: 1;
    filter: none;
    clip-path: inset(0);
  }

  6% {
    transform:
      translate(-34px, 6px)
      skewX(-4deg)
      scaleX(1.025);

    filter:
      contrast(2.4)
      saturate(3.2)
      brightness(.48);

    clip-path:
      inset(4% 0 17% 0);
  }

  12% {
    transform:
      translate(41px, -8px)
      skewX(6deg)
      scaleX(.98);

    opacity: .18;

    filter:
      brightness(.12)
      contrast(3);
  }

  18% {
    transform:
      translate(-22px, 3px);

    opacity: 1;

    filter:
      contrast(2.8)
      saturate(4)
      hue-rotate(35deg);

    clip-path:
      polygon(
        0 0,
        100% 0,
        100% 23%,
        0 28%,
        0 44%,
        100% 38%,
        100% 72%,
        0 77%,
        0 100%,
        100% 100%
      );
  }

  27% {
    transform:
      translate(55px, 0)
      skewX(-7deg);

    opacity: .08;

    filter:
      brightness(.08);
  }

  35% {
    transform:
      translate(-47px, -4px)
      scaleX(1.04);

    opacity: .93;

    filter:
      contrast(3)
      saturate(2.8)
      invert(.16);
  }

  44% {
    transform:
      translate(28px, 5px)
      skewX(4deg);

    opacity: .32;

    filter:
      brightness(.34)
      hue-rotate(110deg);

    clip-path:
      inset(26% 0 7% 0);
  }

  53% {
    transform:
      translate(-16px, -3px);

    opacity: 1;

    filter:
      contrast(2.5)
      saturate(3.4);

    clip-path:
      polygon(
        0 0,
        100% 0,
        100% 49%,
        7% 55%,
        100% 59%,
        100% 100%,
        0 100%
      );
  }

  63% {
    transform:
      translate(39px, 2px)
      skewX(-3deg);

    opacity: .12;

    filter:
      brightness(.1);
  }

  72% {
    transform:
      translate(-24px, 4px);

    opacity: .88;

    filter:
      contrast(2.7)
      saturate(3)
      hue-rotate(-35deg);
  }

  83% {
    transform:
      translate(11px, -2px)
      skewX(1.5deg);

    opacity: .44;

    filter:
      brightness(.52)
      contrast(2);
  }

  91% {
    transform:
      translate(-6px, 1px);

    opacity: 1;

    filter:
      contrast(1.7)
      saturate(1.9);
  }
}


/* warning becomes unstable during major failure */
body.rg-fault-major .rg-intrusion-warning {
  animation:
    rg-danger-warning
    1550ms
    steps(2,end);
}

@keyframes rg-danger-warning {
  0%,
  100% {
    transform: translateY(0);
    opacity: .96;
  }

  14% {
    transform:
      translate(-18px, 5px)
      skewX(-4deg);

    opacity: .32;
  }

  27% {
    transform:
      translate(13px, -4px)
      skewX(6deg);

    opacity: 1;
  }

  43% {
    opacity: .18;
  }

  57% {
    transform:
      translate(-8px, 3px);

    opacity: 1;
  }

  72% {
    transform:
      translate(17px, -2px)
      skewX(-3deg);
  }

  84% {
    opacity: .28;
  }
}


@media (prefers-reduced-motion: reduce) {
  body.rg-fault-major .jamboree-shell,
  body.rg-fault-major .rg-intrusion-warning {
    animation-duration: 1ms !important;
  }
}


/* ============================================================
   PHASE TWO // RESISTOR ARRIVAL PRE-PAINT

   Applied by the tiny <head> bootstrap on /resistor/ only when
   a fresh Jamboree takeover handoff exists.

   Prevents the fully assembled Resistor page from flashing
   before the reconstruction sequence begins.
   ============================================================ */

html.rg-takeover-arrival-pending {
  background: #000;
}

html.rg-takeover-arrival-pending body.resistor-page {
  background: #000;
  overflow: hidden;
}

html.rg-takeover-arrival-pending
body.resistor-page
.jamboree-shell {
  visibility: hidden;
  opacity: 0;
}


/* ============================================================
   PHASE TWO // RESISTOR RECONSTRUCTION
   ============================================================ */

.rg-takeover-arrival-stage {
  position: fixed;
  inset: 0;
  z-index: 2147483647;

  overflow: hidden;
  pointer-events: none;

  background:
    repeating-linear-gradient(
      0deg,
      rgba(255,255,255,.025) 0 1px,
      transparent 1px 4px
    ),
    #000;
}

.rg-takeover-arrival-stage::before,
.rg-takeover-arrival-stage::after {
  content: "";

  position: absolute;
  inset: 0;

  pointer-events: none;
}

.rg-takeover-arrival-stage::before {
  z-index: 100;

  opacity: .42;

  background:
    linear-gradient(
      90deg,
      transparent 0 9%,
      rgba(0,231,255,.20) 9% 9.3%,
      transparent 9.3% 58%,
      rgba(255,61,242,.18) 58% 58.35%,
      transparent 58.35%
    ),
    repeating-linear-gradient(
      0deg,
      transparent 0 41px,
      rgba(255,255,255,.035) 41px 42px,
      transparent 42px 88px
    );

  mix-blend-mode: screen;

  animation:
    rg-arrival-static
    220ms
    steps(2,end)
    infinite;
}

.rg-takeover-arrival-stage::after {
  z-index: 101;

  opacity: 0;

  background: #000;

  animation:
    rg-arrival-blackout
    1450ms
    steps(2,end);
}


/*
  Each slice is a full clone of the Resistor page.
  clip-path exposes only one horizontal band.
*/
.rg-takeover-arrival-slice {
  position: fixed !important;
  inset: 0 auto auto 0 !important;

  width: 100vw !important;
  min-width: 100vw !important;

  margin: 0 !important;

  visibility: visible !important;
  opacity: 0;

  pointer-events: none !important;
  user-select: none !important;

  transform-origin: center;

  filter:
    contrast(1.7)
    saturate(2.2)
    drop-shadow(-10px 0 rgba(0,231,255,.55))
    drop-shadow(10px 0 rgba(255,61,242,.48));
}


/*
  Starting displacement is supplied per-slice by JS.
*/
.rg-takeover-arrival-stage.is-assembling
.rg-takeover-arrival-slice {
  animation:
    rg-resistor-reassemble
    1450ms
    cubic-bezier(.16,.72,.17,1)
    var(--rg-arrival-delay, 0ms)
    both;
}


/* real page appears only at the end of reconstruction */
body.rg-resistor-arriving .jamboree-shell {
  visibility: hidden;
  opacity: 0;
}

body.rg-resistor-arrival-complete .jamboree-shell {
  visibility: visible;
  opacity: 1;

  animation:
    rg-resistor-lock
    420ms
    steps(2,end);
}


@keyframes rg-resistor-reassemble {
  0% {
    opacity: 0;

    transform:
      translate(
        var(--rg-arrival-x),
        var(--rg-arrival-y)
      )
      rotate(var(--rg-arrival-r))
      scaleX(1.06);

    filter:
      brightness(.15)
      contrast(3)
      saturate(3);
  }

  12% {
    opacity: .92;
  }

  28% {
    transform:
      translate(
        calc(var(--rg-arrival-x) * -.52),
        calc(var(--rg-arrival-y) * .42)
      )
      rotate(
        calc(var(--rg-arrival-r) * -.55)
      )
      scaleX(.97);

    filter:
      brightness(1.5)
      contrast(2.5)
      saturate(3.3)
      hue-rotate(22deg);
  }

  43% {
    opacity: .22;

    transform:
      translate(
        calc(var(--rg-arrival-x) * .30),
        calc(var(--rg-arrival-y) * -.22)
      )
      rotate(
        calc(var(--rg-arrival-r) * .24)
      );
  }

  56% {
    opacity: 1;

    transform:
      translate(
        calc(var(--rg-arrival-x) * -.14),
        calc(var(--rg-arrival-y) * .10)
      );

    filter:
      contrast(2)
      saturate(2.6);
  }

  72% {
    transform:
      translate(
        calc(var(--rg-arrival-x) * .055),
        0
      )
      skewX(.35deg);

    filter:
      contrast(1.55)
      saturate(1.9);
  }

  86% {
    transform:
      translate(-2px, 0);

    opacity: .88;
  }

  100% {
    opacity: 1;
    transform: none;
    filter: none;
  }
}


@keyframes rg-resistor-lock {
  0% {
    transform: translateX(7px);
    opacity: .55;

    filter:
      contrast(2)
      saturate(2.5)
      drop-shadow(-7px 0 rgba(0,231,255,.45))
      drop-shadow(7px 0 rgba(255,61,242,.40));
  }

  34% {
    transform: translateX(-4px);
    opacity: 1;
  }

  67% {
    transform: translateX(2px);

    filter:
      contrast(1.35)
      saturate(1.5);
  }

  100% {
    transform: none;
    opacity: 1;
    filter: none;
  }
}


@keyframes rg-arrival-static {
  0% {
    transform: translate(0);
  }

  33% {
    transform: translate(-7px, 2px);
  }

  66% {
    transform: translate(9px, -1px);
  }

  100% {
    transform: translate(-2px, 1px);
  }
}


@keyframes rg-arrival-blackout {
  0%,
  9% {
    opacity: .92;
  }

  10%,
  18% {
    opacity: .12;
  }

  19%,
  23% {
    opacity: .72;
  }

  24%,
  54% {
    opacity: .04;
  }

  55%,
  58% {
    opacity: .43;
  }

  59%,
  100% {
    opacity: 0;
  }
}


@media (prefers-reduced-motion: reduce) {
  .rg-takeover-arrival-stage::before,
  .rg-takeover-arrival-stage::after,
  .rg-takeover-arrival-slice,
  body.rg-resistor-arrival-complete .jamboree-shell {
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
  }
}


/* ============================================================
   PHASE TWO // VIEWPORT SLICE GEOMETRY OVERRIDE
   Slice wrapper = moving fragment.
   Inner clone = correctly aligned Resistor document.
   ============================================================ */

.rg-takeover-arrival-slice {
  position: fixed !important;

  left: 0 !important;
  right: auto !important;

  width: 100vw !important;
  min-width: 100vw !important;

  overflow: hidden !important;

  margin: 0 !important;
  padding: 0 !important;

  visibility: visible !important;
}

.rg-takeover-arrival-clone {
  position: absolute !important;

  left: 0 !important;

  width: 100vw !important;
  min-width: 100vw !important;

  margin: 0 !important;

  pointer-events: none !important;
  user-select: none !important;

  visibility: visible !important;
  opacity: 1 !important;
}

.rg-takeover-arrival-clone
audio,
.rg-takeover-arrival-clone
video,
.rg-takeover-arrival-clone
iframe,
.rg-takeover-arrival-clone
script {
  display: none !important;
}


/* ============================================================
   PHASE TWO // SHATTERED RESISTOR REBUILD
   Supersedes the earlier horizontal-slice prototype.
   ============================================================ */

.rg-takeover-grid-stage {
  position: fixed;
  inset: 0;

  z-index: 2147483647;

  overflow: hidden;
  pointer-events: none;

  background: #000;
}


/* real randomized CRT noise canvas */
.rg-takeover-noise {
  position: absolute;
  inset: 0;

  width: 100%;
  height: 100%;

  z-index: 80;

  opacity: .72;

  image-rendering: pixelated;

  mix-blend-mode: screen;

  filter:
    contrast(2.4)
    brightness(.86)
    saturate(.25);

  animation:
    rg-noise-violence
    170ms
    steps(2,end)
    infinite;
}


/* scanline/channel contamination above the real noise */
.rg-takeover-grid-stage::before {
  content: "";

  position: absolute;
  inset: 0;

  z-index: 90;

  pointer-events: none;

  background:
    repeating-linear-gradient(
      0deg,
      transparent 0 2px,
      rgba(0,0,0,.42) 2px 4px
    ),
    linear-gradient(
      90deg,
      rgba(0,231,255,.13),
      transparent 19% 73%,
      rgba(255,61,242,.14)
    );

  mix-blend-mode: screen;

  animation:
    rg-channel-roll
    260ms
    steps(2,end)
    infinite;
}


/* ------------------------------------------------------------
   24 actual page fragments
   ------------------------------------------------------------ */

.rg-takeover-tile {
  position: fixed;

  z-index: 20;

  overflow: hidden;

  opacity: 0;

  pointer-events: none;
  user-select: none;

  transform-origin: center;

  transform:
    translate(
      var(--rg-tile-x),
      var(--rg-tile-y)
    )
    rotate(var(--rg-tile-r))
    scale(var(--rg-tile-scale));

  filter:
    brightness(.18)
    contrast(3)
    saturate(3.2)
    drop-shadow(
      -13px 0
      rgba(0,231,255,.70)
    )
    drop-shadow(
      14px 0
      rgba(255,61,242,.66)
    );
}


.rg-takeover-tile-clone {
  position: absolute !important;

  width: 100vw !important;
  min-width: 100vw !important;

  margin: 0 !important;

  pointer-events: none !important;
  user-select: none !important;

  visibility: visible !important;
  opacity: 1 !important;
}


.rg-takeover-grid-stage.is-rebuilding
.rg-takeover-tile {
  animation:
    rg-tile-rebuild
    1580ms
    cubic-bezier(.14,.76,.18,1)
    var(--rg-tile-delay)
    both;
}


/* ------------------------------------------------------------
   TRIAGE intrusion during reconstruction
   ------------------------------------------------------------ */

.rg-takeover-triage-hit {
  position: absolute;

  left: 50%;
  top: 50%;

  z-index: 70;

  width: min(78vw, 760px);
  max-width: none;

  opacity: 0;

  transform:
    translate(-50%, -50%)
    scale(.55)
    rotate(-2deg);

  filter:
    contrast(2.4)
    saturate(1.8)
    drop-shadow(
      -20px 0
      rgba(0,231,255,.75)
    )
    drop-shadow(
      21px 0
      rgba(255,61,242,.70)
    );

  animation:
    rg-takeover-triage
    1550ms
    steps(2,end)
    180ms
    both;
}


/* ------------------------------------------------------------
   Final violent lock frame
   ------------------------------------------------------------ */

.rg-takeover-lock-flash {
  position: absolute;
  inset: 0;

  z-index: 110;

  opacity: 0;

  background:
    repeating-linear-gradient(
      0deg,
      #fff 0 1px,
      #000 1px 5px
    );

  mix-blend-mode: screen;
}


.rg-takeover-grid-stage.is-finalizing
.rg-takeover-lock-flash {
  animation:
    rg-takeover-lock-flash
    260ms
    steps(2,end);
}


/* ============================================================
   SHATTER REBUILD ANIMATIONS
   ============================================================ */

@keyframes rg-tile-rebuild {
  0% {
    opacity: 0;

    transform:
      translate(
        var(--rg-tile-x),
        var(--rg-tile-y)
      )
      rotate(var(--rg-tile-r))
      scale(var(--rg-tile-scale));
  }

  8% {
    opacity: .95;
  }

  18% {
    transform:
      translate(
        calc(var(--rg-tile-x) * -.42),
        calc(var(--rg-tile-y) * .58)
      )
      rotate(
        calc(var(--rg-tile-r) * -.7)
      )
      scale(1.08);

    filter:
      brightness(1.7)
      contrast(3.2)
      saturate(4);
  }

  27% {
    opacity: .18;

    transform:
      translate(
        calc(var(--rg-tile-x) * .31),
        calc(var(--rg-tile-y) * -.28)
      )
      rotate(
        calc(var(--rg-tile-r) * .42)
      );
  }

  39% {
    opacity: 1;

    transform:
      translate(
        calc(var(--rg-tile-x) * -.17),
        calc(var(--rg-tile-y) * .15)
      )
      rotate(
        calc(var(--rg-tile-r) * -.2)
      )
      scale(.97);

    filter:
      brightness(.72)
      contrast(2.3)
      saturate(2.8)
      hue-rotate(18deg);
  }

  51% {
    transform:
      translate(
        calc(var(--rg-tile-x) * .085),
        calc(var(--rg-tile-y) * -.07)
      )
      rotate(
        calc(var(--rg-tile-r) * .09)
      )
      scale(1.025);

    filter:
      contrast(2)
      saturate(2.4);
  }

  63% {
    opacity: .46;

    transform:
      translate(
        calc(var(--rg-tile-x) * -.035),
        4px
      )
      skewX(-.55deg);
  }

  72% {
    opacity: 1;

    transform:
      translate(
        calc(var(--rg-tile-x) * .018),
        -2px
      );

    filter:
      contrast(1.55)
      saturate(1.8);
  }

  83% {
    transform:
      translate(-5px, 1px);

    filter:
      contrast(2.2)
      saturate(2.3)
      drop-shadow(
        -6px 0
        rgba(0,231,255,.5)
      )
      drop-shadow(
        6px 0
        rgba(255,61,242,.46)
      );
  }

  90% {
    transform:
      translate(4px, -1px);
  }

  96% {
    transform:
      translate(-1px, 0);
  }

  100% {
    opacity: 1;
    transform: none;
    filter: none;
  }
}


@keyframes rg-noise-violence {
  0% {
    transform:
      translate(0)
      scale(1.01);

    opacity: .76;
  }

  25% {
    transform:
      translate(-12px, 3px)
      scaleX(1.04);

    opacity: .48;
  }

  50% {
    transform:
      translate(9px, -2px);

    opacity: .84;
  }

  75% {
    transform:
      translate(-4px, 4px)
      scaleY(1.03);

    opacity: .37;
  }

  100% {
    transform:
      translate(3px, -1px);

    opacity: .71;
  }
}


@keyframes rg-channel-roll {
  0% {
    transform: translateY(-5%);
  }

  33% {
    transform: translateY(2%);
  }

  66% {
    transform: translateY(-1%);
  }

  100% {
    transform: translateY(4%);
  }
}


@keyframes rg-takeover-triage {
  0%,
  8% {
    opacity: 0;
  }

  12% {
    opacity: .88;

    transform:
      translate(-54%, -48%)
      scale(.82)
      rotate(-4deg);
  }

  17% {
    opacity: .09;
  }

  24% {
    opacity: 1;

    transform:
      translate(-47%, -52%)
      scale(1.13)
      rotate(3deg);
  }

  31% {
    opacity: .05;
  }

  43% {
    opacity: .61;

    transform:
      translate(-51%, -49%)
      scale(.94);
  }

  49% {
    opacity: 0;
  }

  67% {
    opacity: .28;

    transform:
      translate(-49%, -51%)
      scale(1.22);
  }

  72%,
  100% {
    opacity: 0;
  }
}


@keyframes rg-takeover-lock-flash {
  0% {
    opacity: 0;
  }

  14% {
    opacity: .92;
  }

  31% {
    opacity: .08;

    transform:
      translateX(-18px);
  }

  46% {
    opacity: .72;

    transform:
      translateX(15px);
  }

  62% {
    opacity: .12;
  }

  78% {
    opacity: .48;
  }

  100% {
    opacity: 0;
    transform: none;
  }
}


@media (prefers-reduced-motion: reduce) {
  .rg-takeover-grid-stage {
    display: none !important;
  }
}


/* ============================================================
   PHASE TWO // TRUE CLIPPED VIEWPORT FRAGMENTS

   Every fragment is the full Resistor viewport, but clip-path
   exposes only one irregular section of it.

   Result:
     actual page pieces
     -> explosion
     -> wrong-slot shuffle
     -> second wrong-slot shuffle
     -> convergence
     -> lock
   ============================================================ */

.rg-takeover-fragment {
  position: fixed;

  inset: 0;

  width: 100vw;
  height: 100vh;

  z-index: 25;

  overflow: visible;

  opacity: 0;

  pointer-events: none;
  user-select: none;

  transform-origin: center;

  will-change:
    transform,
    opacity,
    filter;

  transform:
    translate(
      var(--rg-frag-scatter-x),
      var(--rg-frag-scatter-y)
    )
    rotate(var(--rg-frag-r))
    scale(1.08);

  filter:
    brightness(.15)
    contrast(3.2)
    saturate(3.4)
    drop-shadow(
      -14px 0
      rgba(0,231,255,.72)
    )
    drop-shadow(
      15px 0
      rgba(255,61,242,.67)
    );
}


.rg-takeover-fragment-clone {
  position: absolute !important;

  inset: 0 auto auto 0 !important;

  width: 100vw !important;
  min-width: 100vw !important;

  margin: 0 !important;

  visibility: visible !important;
  opacity: 1 !important;

  pointer-events: none !important;
  user-select: none !important;
}


.rg-takeover-grid-stage.is-rebuilding
.rg-takeover-fragment {
  animation:
    rg-fragment-coalesce
    2260ms
    cubic-bezier(.15,.76,.18,1)
    var(--rg-frag-delay)
    both;
}


@keyframes rg-fragment-coalesce {
  /*
    Nothing exists.
  */
  0% {
    opacity: 0;

    transform:
      translate(
        var(--rg-frag-scatter-x),
        var(--rg-frag-scatter-y)
      )
      rotate(var(--rg-frag-r))
      scale(1.08);
  }


  /*
    Pieces violently appear.
  */
  7% {
    opacity: .96;

    filter:
      brightness(1.45)
      contrast(3.4)
      saturate(3.8);
  }


  /*
    FIRST WRONG CONFIGURATION.
    Every fragment is sitting where a different fragment belongs.
  */
  20% {
    opacity: 1;

    transform:
      translate(
        var(--rg-frag-shuffle1-x),
        var(--rg-frag-shuffle1-y)
      )
      rotate(
        calc(
          var(--rg-frag-r) * -.72
        )
      )
      scale(.97);

    filter:
      contrast(2.5)
      saturate(3)
      hue-rotate(23deg);
  }


  /*
    Signal drops while the pieces are still wrong.
  */
  27% {
    opacity: .16;

    transform:
      translate(
        calc(
          var(--rg-frag-shuffle1-x) * .88
        ),
        calc(
          var(--rg-frag-shuffle1-y) * 1.07
        )
      )
      rotate(
        calc(
          var(--rg-frag-r) * .42
        )
      );
  }


  /*
    SECOND WRONG CONFIGURATION.
    The page visibly reshuffles itself.
  */
  39% {
    opacity: 1;

    transform:
      translate(
        var(--rg-frag-shuffle2-x),
        var(--rg-frag-shuffle2-y)
      )
      rotate(
        calc(
          var(--rg-frag-r) * .55
        )
      )
      scale(1.035);

    filter:
      brightness(.72)
      contrast(2.8)
      saturate(3.1);
  }


  /*
    Another corruption hit.
  */
  47% {
    opacity: .31;

    transform:
      translate(
        calc(
          var(--rg-frag-shuffle2-x) * -.38
        ),
        calc(
          var(--rg-frag-shuffle2-y) * .41
        )
      )
      rotate(
        calc(
          var(--rg-frag-r) * -.28
        )
      );

    filter:
      brightness(.28)
      contrast(3);
  }


  /*
    System has roughly figured out where the piece belongs.
  */
  59% {
    opacity: 1;

    transform:
      translate(
        var(--rg-frag-near-x),
        var(--rg-frag-near-y)
      )
      rotate(
        calc(
          var(--rg-frag-r) * .12
        )
      )
      scale(.992);

    filter:
      contrast(2.1)
      saturate(2.5);
  }


  /*
    Overshoot.
  */
  70% {
    transform:
      translate(
        calc(
          var(--rg-frag-near-x) * -.48
        ),
        calc(
          var(--rg-frag-near-y) * -.62
        )
      )
      rotate(
        calc(
          var(--rg-frag-r) * -.05
        )
      )
      scale(1.014);

    filter:
      contrast(1.7)
      saturate(2);
  }


  /*
    Almost synchronized.
  */
  80% {
    opacity: .88;

    transform:
      translate(
        calc(
          var(--rg-frag-near-x) * .18
        ),
        calc(
          var(--rg-frag-near-y) * .16
        )
      );

    filter:
      contrast(1.45)
      saturate(1.7)
      drop-shadow(
        -5px 0
        rgba(0,231,255,.43)
      )
      drop-shadow(
        5px 0
        rgba(255,61,242,.39)
      );
  }


  /*
    One last disagreement with reality.
  */
  89% {
    opacity: 1;

    transform:
      translate(-5px, 1px)
      skewX(-.35deg);
  }


  94% {
    transform:
      translate(4px, -1px)
      skewX(.2deg);
  }


  /*
    Exact original coordinates.
  */
  100% {
    opacity: 1;
    transform: none;
    filter: none;
  }
}


/*
  Kill the obsolete prototype pieces if any somehow survive.
*/
.rg-takeover-grid-stage
.rg-takeover-tile,
.rg-takeover-grid-stage
.rg-takeover-arrival-slice {
  display: none !important;
}


@media (prefers-reduced-motion: reduce) {
  .rg-takeover-fragment {
    animation-duration: 1ms !important;
  }
}


/* ============================================================
   PHASE TWO // JAMBOREE CATASTROPHIC DEPARTURE

   Coherent damaged Jamboree
   -> wrong fragment arrangements
   -> total disassembly
   -> blackout
   -> /resistor/
   ============================================================ */

body.rg-takeover-departing {
  overflow: hidden !important;
  background: #000 !important;
}


/*
  Once the fragment overlay has painted, the real page can
  disappear underneath it without the visitor seeing the swap.
*/
body.rg-takeover-departing
> .jamboree-shell {
  visibility: hidden;
}


.rg-takeover-departure-stage {
  position: fixed;
  inset: 0;

  z-index: 2147483647;

  overflow: hidden;
  pointer-events: none;

  background: #000;
}


/* ------------------------------------------------------------
   Real randomized static
   ------------------------------------------------------------ */

.rg-takeover-departure-noise {
  position: absolute;
  inset: 0;

  width: 100%;
  height: 100%;

  z-index: 55;

  opacity: .18;

  image-rendering: pixelated;

  mix-blend-mode: screen;

  filter:
    contrast(2.8)
    brightness(.72)
    saturate(.22);
}


.rg-takeover-departure-stage.is-destroying
.rg-takeover-departure-noise {
  animation:
    rg-depart-noise
    160ms
    steps(2,end)
    infinite;
}


/* scanline / channel-tear layer */
.rg-takeover-departure-stage::before {
  content: "";

  position: absolute;
  inset: 0;

  z-index: 56;

  pointer-events: none;

  opacity: .42;

  background:
    repeating-linear-gradient(
      0deg,
      transparent 0 2px,
      rgba(0,0,0,.48) 2px 4px
    ),
    linear-gradient(
      90deg,
      rgba(0,231,255,.18),
      transparent 18% 72%,
      rgba(255,61,242,.18)
    );

  mix-blend-mode: screen;

  animation:
    rg-depart-channel
    220ms
    steps(2,end)
    infinite;
}


/* ------------------------------------------------------------
   Actual clipped pieces of the existing Jamboree viewport
   ------------------------------------------------------------ */

.rg-takeover-departure-fragment {
  position: fixed;

  inset: 0;

  width: 100vw;
  height: 100vh;

  z-index: 25;

  overflow: visible;

  pointer-events: none;
  user-select: none;

  transform-origin: center;

  will-change:
    transform,
    opacity,
    filter;

  opacity: 1;
  transform: none;
}


.rg-takeover-departure-clone {
  position: absolute !important;

  left: 0 !important;

  width: 100vw !important;
  min-width: 100vw !important;

  margin: 0 !important;

  visibility: visible !important;
  opacity: 1 !important;

  pointer-events: none !important;
  user-select: none !important;
}


.rg-takeover-departure-stage.is-destroying
.rg-takeover-departure-fragment {
  animation:
    rg-jamboree-disintegrate
    2050ms
    cubic-bezier(.3,.02,.65,.98)
    var(--rg-depart-delay)
    both;
}


/* ------------------------------------------------------------
   TRIAGE takeover hit
   ------------------------------------------------------------ */

.rg-takeover-departure-triage {
  position: absolute;

  left: 50%;
  top: 50%;

  z-index: 75;

  width: min(88vw, 820px);
  max-width: none;

  opacity: 0;

  transform:
    translate(-50%, -50%)
    scale(.58);

  filter:
    contrast(2.5)
    saturate(1.9)
    drop-shadow(
      -22px 0
      rgba(0,231,255,.78)
    )
    drop-shadow(
      23px 0
      rgba(255,61,242,.72)
    );
}


.rg-takeover-departure-stage.is-destroying
.rg-takeover-departure-triage {
  animation:
    rg-depart-triage
    1850ms
    steps(2,end)
    260ms
    both;
}


/* ------------------------------------------------------------
   Final blackout
   ------------------------------------------------------------ */

.rg-takeover-departure-blackout {
  position: absolute;
  inset: 0;

  z-index: 120;

  opacity: 0;

  background: #000;
}


.rg-takeover-departure-stage.is-blackout
.rg-takeover-departure-blackout {
  animation:
    rg-depart-blackout
    340ms
    steps(2,end)
    forwards;
}


/* ============================================================
   DEPARTURE ANIMATIONS
   ============================================================ */

@keyframes rg-jamboree-disintegrate {
  /*
    Starts exactly where the real page was.
  */
  0% {
    opacity: 1;
    transform: none;
    filter: none;
  }


  /*
    First sign that coordinates are failing.
  */
  8% {
    transform:
      translate(-5px, 2px)
      skewX(-.3deg);

    filter:
      contrast(1.5)
      saturate(1.8)
      drop-shadow(
        -5px 0
        rgba(0,231,255,.38)
      )
      drop-shadow(
        5px 0
        rgba(255,61,242,.34)
      );
  }


  /*
    FIRST WRONG PAGE.
  */
  22% {
    transform:
      translate(
        var(--rg-depart-shuffle1-x),
        var(--rg-depart-shuffle1-y)
      )
      rotate(
        calc(
          var(--rg-depart-r) * .34
        )
      )
      scale(1.012);

    filter:
      brightness(1.35)
      contrast(2.6)
      saturate(3.2);
  }


  31% {
    opacity: .24;

    transform:
      translate(
        calc(
          var(--rg-depart-shuffle1-x) * .84
        ),
        calc(
          var(--rg-depart-shuffle1-y) * 1.08
        )
      );

    filter:
      brightness(.22)
      contrast(3);
  }


  /*
    SECOND WRONG PAGE.
  */
  43% {
    opacity: 1;

    transform:
      translate(
        var(--rg-depart-shuffle2-x),
        var(--rg-depart-shuffle2-y)
      )
      rotate(
        calc(
          var(--rg-depart-r) * -.58
        )
      )
      scale(.98);

    filter:
      contrast(3)
      saturate(3.6)
      hue-rotate(28deg);
  }


  /*
    Geometry has stopped pretending.
  */
  55% {
    opacity: .72;

    transform:
      translate(
        calc(
          var(--rg-depart-scatter-x) * .28
        ),
        calc(
          var(--rg-depart-scatter-y) * .28
        )
      )
      rotate(
        calc(
          var(--rg-depart-r) * .6
        )
      )
      scale(1.04);

    filter:
      brightness(.62)
      contrast(2.7)
      saturate(3);
  }


  67% {
    opacity: .93;

    transform:
      translate(
        calc(
          var(--rg-depart-scatter-x) * .68
        ),
        calc(
          var(--rg-depart-scatter-y) * .68
        )
      )
      rotate(var(--rg-depart-r))
      scale(.94);

    filter:
      contrast(2.4)
      saturate(2.8)
      drop-shadow(
        -14px 0
        rgba(0,231,255,.66)
      )
      drop-shadow(
        15px 0
        rgba(255,61,242,.61)
      );
  }


  /*
    Most of the page has left the viewport.
  */
  80% {
    opacity: .34;

    transform:
      translate(
        var(--rg-depart-scatter-x),
        var(--rg-depart-scatter-y)
      )
      rotate(
        calc(
          var(--rg-depart-r) * 1.35
        )
      )
      scale(.82);

    filter:
      brightness(.24)
      contrast(3);
  }


  91% {
    opacity: .10;

    transform:
      translate(
        calc(
          var(--rg-depart-scatter-x) * 1.18
        ),
        calc(
          var(--rg-depart-scatter-y) * 1.18
        )
      )
      rotate(
        calc(
          var(--rg-depart-r) * 1.7
        )
      )
      scale(.72);
  }


  100% {
    opacity: 0;

    transform:
      translate(
        calc(
          var(--rg-depart-scatter-x) * 1.32
        ),
        calc(
          var(--rg-depart-scatter-y) * 1.32
        )
      )
      rotate(
        calc(
          var(--rg-depart-r) * 2
        )
      )
      scale(.62);

    filter:
      brightness(0)
      contrast(3);
  }
}


@keyframes rg-depart-triage {
  0%,
  7% {
    opacity: 0;
  }

  11% {
    opacity: .87;

    transform:
      translate(-55%, -48%)
      scale(.78)
      rotate(-4deg);
  }

  17% {
    opacity: .06;
  }

  24% {
    opacity: 1;

    transform:
      translate(-47%, -52%)
      scale(1.15)
      rotate(3deg);
  }

  31% {
    opacity: .08;
  }

  39% {
    opacity: .71;

    transform:
      translate(-52%, -49%)
      scale(.94);
  }

  46% {
    opacity: 0;
  }

  61% {
    opacity: .42;

    transform:
      translate(-48%, -51%)
      scale(1.28)
      rotate(-2deg);
  }

  68%,
  100% {
    opacity: 0;
  }
}


@keyframes rg-depart-noise {
  0% {
    opacity: .22;
    transform: translate(0);
  }

  24% {
    opacity: .78;

    transform:
      translate(-13px, 3px)
      scaleX(1.05);
  }

  49% {
    opacity: .34;

    transform:
      translate(11px, -2px);
  }

  73% {
    opacity: .91;

    transform:
      translate(-5px, 4px)
      scaleY(1.04);
  }

  100% {
    opacity: .48;

    transform:
      translate(4px, -1px);
  }
}


@keyframes rg-depart-channel {
  0% {
    transform: translateY(-4%);
  }

  33% {
    transform: translateY(3%);
  }

  66% {
    transform: translateY(-1%);
  }

  100% {
    transform: translateY(5%);
  }
}


@keyframes rg-depart-blackout {
  0% {
    opacity: 0;
  }

  18% {
    opacity: .93;
  }

  34% {
    opacity: .35;
  }

  48% {
    opacity: 1;
  }

  63% {
    opacity: .72;
  }

  100% {
    opacity: 1;
  }
}


@media (prefers-reduced-motion: reduce) {
  .rg-takeover-departure-fragment,
  .rg-takeover-departure-triage,
  .rg-takeover-departure-noise,
  .rg-takeover-departure-blackout {
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
  }
}


/* ============================================================
   PRESSURE RESISTOR // LIVE FRAGMENT INFECTION ENGINE

   Supersedes the earlier decorative ambient-glitch experiments.
   The infection now manipulates clipped pieces of the real page.
   ============================================================ */


/*
  Disable the obsolete overlay implementation.
*/
body.rg-resistor-compromised
.rg-resistor-ambient {
  display: none !important;
}


/*
  Kill the old whole-shell "signal" animation.
  Structural corruption now comes from real page fragments.
*/
body.rg-resistor-compromised
> .jamboree-shell {
  animation: none !important;
}


/* ============================================================
   PERMANENT MISREGISTERED SCARS
   ============================================================ */

.rg-resistor-scar-stage {
  position: fixed;
  inset: 0;

  z-index: 2147480000;

  overflow: hidden;

  pointer-events: none;
  user-select: none;
}


.rg-resistor-scar {
  position: fixed;
  inset: 0;

  width: 100vw;
  height: 100vh;

  overflow: hidden;

  pointer-events: none;

  transform:
    translateX(
      var(--rg-scar-x)
    );

  filter:
    contrast(1.18)
    saturate(1.22)
    drop-shadow(
      -2px 0
      rgba(0,231,255,.48)
    )
    drop-shadow(
      2px 0
      rgba(255,61,242,.42)
    );

  opacity: .72;

  animation:
    rg-resistor-scar-twitch
    5.7s
    steps(1,end)
    infinite;
}


.rg-resistor-scar:nth-child(2) {
  animation-delay: -1.8s;
}


.rg-resistor-scar:nth-child(3) {
  animation-delay: -3.1s;
}


.rg-resistor-scar:nth-child(4) {
  animation-delay: -4.2s;
}


/* ============================================================
   SHARED LIVE CLONES
   ============================================================ */

.rg-resistor-infection-clone {
  position: absolute !important;

  margin: 0 !important;

  min-width: 0 !important;

  visibility: visible !important;
  opacity: 1 !important;

  pointer-events: none !important;
  user-select: none !important;
}


/* ============================================================
   ACTIVE INFECTION STAGE
   ============================================================ */

.rg-resistor-live-stage {
  position: fixed;
  inset: 0;

  z-index: 2147482400;

  overflow: hidden;

  pointer-events: none;
  user-select: none;
}


.rg-resistor-live-fragment {
  position: fixed;
  inset: 0;

  width: 100vw;
  height: 100vh;

  opacity: 0;

  overflow: visible;

  pointer-events: none;

  transform-origin: center;

  will-change:
    transform,
    opacity,
    filter;
}


/* ============================================================
   MINOR INFECTION
   ============================================================ */

.rg-resistor-live-stage.is-minor.is-active
.rg-resistor-live-fragment {
  animation:
    rg-resistor-minor-fragment
    820ms
    cubic-bezier(.2,.75,.22,1)
    var(--rg-live-delay)
    both;
}


@keyframes rg-resistor-minor-fragment {
  0% {
    opacity: 0;
    transform: none;
    filter: none;
  }

  7% {
    opacity: 1;
  }

  18% {
    transform:
      translate(
        var(--rg-live-x1),
        var(--rg-live-y1)
      )
      rotate(
        var(--rg-live-r)
      );

    filter:
      contrast(1.8)
      saturate(2.2)
      drop-shadow(
        -6px 0
        rgba(0,231,255,.66)
      )
      drop-shadow(
        7px 0
        rgba(255,61,242,.62)
      );
  }

  29% {
    opacity: .24;

    transform:
      translate(
        var(--rg-live-x2),
        var(--rg-live-y2)
      )
      rotate(
        calc(
          var(--rg-live-r) * -.6
        )
      );
  }

  39% {
    opacity: 1;

    transform:
      translate(
        calc(
          var(--rg-live-x1) * .62
        ),
        calc(
          var(--rg-live-y1) * -.35
        )
      )
      rotate(
        calc(
          var(--rg-live-r) * .4
        )
      );

    filter:
      contrast(2.2)
      saturate(2.7);
  }

  53% {
    transform:
      translate(
        var(--rg-live-x3),
        var(--rg-live-y3)
      );

    filter:
      contrast(1.5)
      saturate(1.7);
  }

  66% {
    transform:
      translate(-5px, 2px);
  }

  77% {
    transform:
      translate(4px, -1px);
  }

  88% {
    transform:
      translate(-1px, 0);
  }

  100% {
    opacity: 0;
    transform: none;
    filter: none;
  }
}


/* ============================================================
   MAJOR INFECTION
   ============================================================ */

.rg-resistor-live-stage.is-major {
  background:
    rgba(0,0,0,.08);
}


.rg-resistor-live-stage.is-major.is-active
.rg-resistor-live-fragment {
  animation:
    rg-resistor-major-fragment
    1580ms
    cubic-bezier(.15,.72,.18,1)
    var(--rg-live-delay)
    both;
}


.rg-resistor-live-stage.is-major.is-active
.rg-resistor-live-fragment.is-lagging {
  animation-duration: 1900ms;
}


@keyframes rg-resistor-major-fragment {
  0% {
    opacity: 0;
    transform: none;
    filter: none;
  }

  5% {
    opacity: 1;
  }

  /*
    First loss of geometry.
  */
  16% {
    transform:
      translate(
        var(--rg-live-x1),
        var(--rg-live-y1)
      )
      rotate(
        var(--rg-live-r)
      )
      scale(1.025);

    filter:
      brightness(1.2)
      contrast(2.4)
      saturate(3)
      drop-shadow(
        -12px 0
        rgba(0,231,255,.76)
      )
      drop-shadow(
        13px 0
        rgba(255,61,242,.69)
      );
  }

  /*
    Fragment relocates somewhere else entirely.
  */
  27% {
    opacity: .22;

    transform:
      translate(
        var(--rg-live-x2),
        var(--rg-live-y2)
      )
      rotate(
        calc(
          var(--rg-live-r) * -.7
        )
      )
      scale(.96);
  }

  36% {
    opacity: 1;

    transform:
      translate(
        calc(
          var(--rg-live-x1) * -.68
        ),
        calc(
          var(--rg-live-y1) * .55
        )
      )
      rotate(
        calc(
          var(--rg-live-r) * .8
        )
      );

    filter:
      contrast(3)
      saturate(3.5)
      hue-rotate(18deg);
  }

  /*
    The system starts trying to recover.
  */
  51% {
    transform:
      translate(
        calc(
          var(--rg-live-x2) * .42
        ),
        calc(
          var(--rg-live-y2) * .38
        )
      )
      rotate(
        calc(
          var(--rg-live-r) * -.25
        )
      )
      scale(1.012);

    filter:
      contrast(2)
      saturate(2.4);
  }

  63% {
    opacity: .48;

    transform:
      translate(
        var(--rg-live-x3),
        var(--rg-live-y3)
      )
      skewX(-.5deg);
  }

  /*
    Almost home. Not quite.
  */
  73% {
    opacity: 1;

    transform:
      translate(-9px, 3px);

    filter:
      contrast(1.8)
      saturate(2)
      drop-shadow(
        -5px 0
        rgba(0,231,255,.50)
      )
      drop-shadow(
        6px 0
        rgba(255,61,242,.46)
      );
  }

  82% {
    transform:
      translate(7px, -2px);
  }

  90% {
    transform:
      translate(-3px, 1px);
  }

  96% {
    transform:
      translate(1px, 0);
  }

  100% {
    opacity: 0;
    transform: none;
    filter: none;
  }
}


/* ============================================================
   MAJOR EVENT SIGNAL NOISE
   ============================================================ */

.rg-resistor-live-noise {
  position: absolute;
  inset: 0;

  z-index: 45;

  width: 100%;
  height: 100%;

  opacity: 0;

  image-rendering: pixelated;

  mix-blend-mode: screen;

  pointer-events: none;
}


.rg-resistor-live-stage.is-active
.rg-resistor-live-noise {
  animation:
    rg-resistor-live-noise
    1450ms
    steps(2,end)
    both;
}


@keyframes rg-resistor-live-noise {
  0% {
    opacity: 0;
  }

  8% {
    opacity: .15;
  }

  14% {
    opacity: .48;
    transform: translateX(-9px);
  }

  19% {
    opacity: .08;
  }

  34% {
    opacity: .31;
    transform: translateX(7px);
  }

  39% {
    opacity: .04;
  }

  58% {
    opacity: .42;
    transform: translate(-5px, 2px);
  }

  64% {
    opacity: .09;
  }

  78% {
    opacity: .24;
  }

  86%,
  100% {
    opacity: 0;
    transform: none;
  }
}


/* ============================================================
   TRIAGE LEAKAGE
   ============================================================ */

.rg-resistor-live-triage {
  position: absolute;

  left: 50%;
  top: 50%;

  z-index: 60;

  width: min(
    62vw,
    620px
  );

  opacity: 0;

  pointer-events: none;

  transform:
    translate(-50%, -50%)
    scale(.78);

  filter:
    contrast(2.5)
    saturate(1.8)
    drop-shadow(
      -14px 0
      rgba(0,231,255,.72)
    )
    drop-shadow(
      15px 0
      rgba(255,61,242,.66)
    );
}


.rg-resistor-live-stage.is-active
.rg-resistor-live-triage {
  animation:
    rg-resistor-live-triage
    1250ms
    steps(2,end)
    160ms
    both;
}


@keyframes rg-resistor-live-triage {
  0%,
  8% {
    opacity: 0;
  }

  12% {
    opacity: .34;

    transform:
      translate(-54%, -48%)
      scale(.86)
      rotate(-2deg);
  }

  18% {
    opacity: .04;
  }

  25% {
    opacity: .48;

    transform:
      translate(-47%, -52%)
      scale(1.04)
      rotate(2deg);
  }

  31% {
    opacity: 0;
  }

  47% {
    opacity: .19;

    transform:
      translate(-51%, -49%)
      scale(.93);
  }

  53%,
  100% {
    opacity: 0;
  }
}


/* ============================================================
   PERMANENT SCAR MICRO-MOTION
   ============================================================ */

@keyframes rg-resistor-scar-twitch {
  0%,
  21% {
    transform:
      translateX(
        var(--rg-scar-x)
      );
  }

  22% {
    transform:
      translateX(
        calc(
          var(--rg-scar-x) * -1
        )
      );
  }

  23% {
    transform:
      translateX(
        calc(
          var(--rg-scar-x) + 2px
        )
      );
  }

  24%,
  57% {
    transform:
      translateX(
        var(--rg-scar-x)
      );
  }

  58% {
    transform:
      translate(
        calc(
          var(--rg-scar-x) - 3px
        ),
        1px
      );
  }

  59% {
    transform:
      translate(
        calc(
          var(--rg-scar-x) + 2px
        ),
        -1px
      );
  }

  60%,
  84% {
    transform:
      translateX(
        var(--rg-scar-x)
      );
  }

  85% {
    transform:
      translateX(
        calc(
          var(--rg-scar-x) + 4px
        )
      );
  }

  86%,
  100% {
    transform:
      translateX(
        var(--rg-scar-x)
      );
  }
}


@media (prefers-reduced-motion: reduce) {
  .rg-resistor-scar-stage,
  .rg-resistor-live-stage {
    display: none !important;
  }
}
