/* Заставка «Выдра»: череп + глитч (~0.5 с) перед оверлеем маркета */

.vydra-glitch-splash {
  position: fixed;
  inset: 0;
  z-index: 2147483647;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: center;
  overflow: hidden;
  pointer-events: none;
  background:
    radial-gradient(ellipse 80% 60% at 50% 45%, rgba(80, 40, 120, 0.35), transparent 70%), #120818;
  opacity: 0;
  visibility: hidden;
}

.vydra-glitch-splash:not([hidden]) {
  visibility: visible;
}

.vydra-glitch-splash.is-active {
  pointer-events: auto;
  animation: vydraSplashFadeIn 0.12s ease-out forwards;
}

.vydra-glitch-splash.is-active .vydra-glitch-splash__skull {
  animation: vydraSkullGlitch 0.5s steps(1, end) forwards;
}

.vydra-glitch-splash.is-active .vydra-glitch-splash__skull-wrap {
  animation: vydraSkullIdleGlitch 0.055s steps(2, end) infinite;
}

.vydra-glitch-splash.is-active .vydra-glitch-splash__scanlines {
  animation:
    vydraScanFlicker 0.5s linear forwards,
    vydraScanIdle 0.09s steps(2, end) infinite;
}

.vydra-glitch-splash.is-active .vydra-glitch-splash__rgb--r {
  animation:
    vydraRgbR 0.5s steps(1, end) forwards,
    vydraRgbIdleR 0.065s steps(2, end) infinite;
}

.vydra-glitch-splash.is-active .vydra-glitch-splash__rgb--g {
  animation:
    vydraRgbG 0.5s steps(1, end) forwards,
    vydraRgbIdleG 0.075s steps(2, end) infinite;
}

.vydra-glitch-splash.is-active .vydra-glitch-splash__rgb--b {
  animation:
    vydraRgbB 0.5s steps(1, end) forwards,
    vydraRgbIdleB 0.06s steps(2, end) infinite;
}

.vydra-glitch-splash__skull-wrap {
  position: relative;
  z-index: 3;
  width: 100%;
  max-width: 100vw;
  margin-inline: auto;
  transform-origin: center center;
}

.vydra-glitch-splash__skull {
  display: block;
  width: 100%;
  height: auto;
  max-height: min(92vh, 100dvh);
  object-fit: contain;
  object-position: center;
  filter: drop-shadow(0 0 28px rgba(255, 80, 200, 0.45));
  transform-origin: center center;
}

.vydra-glitch-splash__scanlines {
  position: absolute;
  inset: 0;
  z-index: 4;
  pointer-events: none;
  opacity: 0.32;
  background: repeating-linear-gradient(
    0deg,
    rgba(0, 0, 0, 0) 0,
    rgba(0, 0, 0, 0) 2px,
    rgba(0, 0, 0, 0.22) 2px,
    rgba(0, 0, 0, 0.22) 4px
  );
  mix-blend-mode: overlay;
}

.vydra-glitch-splash__rgb {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  background: center center / 100% auto no-repeat url('../assets/vydra_skull_splash.png');
  opacity: 0;
  mix-blend-mode: screen;
}

.vydra-glitch-splash__rgb--r {
  filter: hue-rotate(-30deg) saturate(2);
}

.vydra-glitch-splash__rgb--g {
  filter: hue-rotate(80deg) saturate(1.6);
}

.vydra-glitch-splash__rgb--b {
  filter: hue-rotate(200deg) saturate(1.8);
}

@keyframes vydraSplashFadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes vydraScanFlicker {
  0%,
  100% {
    opacity: 0.2;
  }
  15%,
  45%,
  75% {
    opacity: 0.45;
  }
  30%,
  60% {
    opacity: 0.15;
  }
}

@keyframes vydraScanIdle {
  0%,
  100% {
    opacity: 0.26;
  }
  50% {
    opacity: 0.4;
  }
}

@keyframes vydraSkullIdleGlitch {
  0% {
    transform: translate(0, 0) scale(1);
    filter: brightness(1) contrast(1.02);
  }
  25% {
    transform: translate(-3px, 1px) scale(1.003);
    filter: brightness(1.1) contrast(1.08) saturate(1.05);
  }
  50% {
    transform: translate(2px, -2px) scale(0.997);
    filter: brightness(0.94) contrast(1.1);
  }
  75% {
    transform: translate(-1px, 2px) scale(1.002);
    filter: brightness(1.06) contrast(1.04);
  }
}

@keyframes vydraRgbIdleR {
  0%,
  55%,
  100% {
    opacity: 0;
    transform: translate(0, 0);
  }
  20% {
    opacity: 0.2;
    transform: translate(-5px, 1px);
  }
  40% {
    opacity: 0.14;
    transform: translate(-3px, -1px);
  }
}

@keyframes vydraRgbIdleG {
  0%,
  60%,
  100% {
    opacity: 0;
    transform: translate(0, 0);
  }
  25% {
    opacity: 0.16;
    transform: translate(4px, -2px);
  }
  45% {
    opacity: 0.11;
    transform: translate(6px, 1px);
  }
}

@keyframes vydraRgbIdleB {
  0%,
  50%,
  100% {
    opacity: 0;
    transform: translate(0, 0);
  }
  30% {
    opacity: 0.18;
    transform: translate(0, 4px);
  }
  70% {
    opacity: 0.12;
    transform: translate(0, -3px);
  }
}

@keyframes vydraSkullGlitch {
  0% {
    opacity: 0;
    transform: scale(1.12) translate(0, 0);
    filter: brightness(2.5) contrast(1.8) drop-shadow(0 0 20px #f0f);
  }
  8% {
    opacity: 1;
    transform: scale(1.05) translate(-6px, 2px);
    filter: brightness(1.2) contrast(1.4) drop-shadow(4px 0 0 rgba(255, 0, 120, 0.7))
      drop-shadow(-4px 0 0 rgba(0, 255, 255, 0.6));
  }
  18% {
    transform: scale(1.04) translate(5px, -3px);
    filter: brightness(0.6) contrast(2) invert(0.15);
  }
  28% {
    transform: scale(1.03) translate(-3px, 0);
    clip-path: inset(0 0 0 0);
  }
  38% {
    transform: scale(1.03) translate(2px, 4px);
    clip-path: inset(8% 0 12% 0);
  }
  48% {
    transform: scale(1.02) translate(-4px, -2px);
    clip-path: inset(0 5% 0 0);
  }
  58% {
    transform: scale(1.02) translate(0, 0);
    filter: brightness(1.1) contrast(1.2) drop-shadow(3px 0 0 rgba(255, 50, 150, 0.5))
      drop-shadow(-3px 0 0 rgba(50, 255, 255, 0.45));
  }
  72% {
    transform: scale(1.01) translate(3px, 1px);
  }
  85% {
    opacity: 1;
    transform: scale(1) translate(0, 0);
    filter: brightness(1) contrast(1.1) drop-shadow(0 0 24px rgba(255, 80, 200, 0.4));
  }
  92% {
    opacity: 0.85;
    transform: scale(0.98) translate(-8px, 0);
    filter: brightness(1.8) contrast(1.5);
  }
  100% {
    opacity: 0;
    transform: scale(1.08) translate(0, 0);
    filter: brightness(3) blur(2px);
  }
}

@keyframes vydraRgbR {
  0%,
  100% {
    opacity: 0;
    transform: translate(0, 0);
  }
  10% {
    opacity: 0.55;
    transform: translate(-10px, 2px);
  }
  25% {
    opacity: 0.35;
    transform: translate(-6px, -2px);
  }
  50% {
    opacity: 0.25;
    transform: translate(-4px, 1px);
  }
  80% {
    opacity: 0.4;
    transform: translate(-8px, 0);
  }
}

@keyframes vydraRgbG {
  0%,
  100% {
    opacity: 0;
    transform: translate(0, 0);
  }
  12% {
    opacity: 0.4;
    transform: translate(8px, -3px);
  }
  35% {
    opacity: 0.3;
    transform: translate(5px, 2px);
  }
  55% {
    opacity: 0.2;
    transform: translate(3px, -1px);
  }
}

@keyframes vydraRgbB {
  0%,
  100% {
    opacity: 0;
    transform: translate(0, 0);
  }
  14% {
    opacity: 0.45;
    transform: translate(0, 6px);
  }
  40% {
    opacity: 0.28;
    transform: translate(0, -4px);
  }
  70% {
    opacity: 0.35;
    transform: translate(0, 5px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .vydra-glitch-splash.is-active .vydra-glitch-splash__skull {
    animation: vydraSkullGlitch 0.09s steps(1, end) forwards;
  }

  .vydra-glitch-splash.is-active .vydra-glitch-splash__skull-wrap {
    animation: none;
  }

  .vydra-glitch-splash.is-active .vydra-glitch-splash__scanlines {
    animation: vydraScanFlicker 0.09s linear forwards;
  }

  .vydra-glitch-splash.is-active .vydra-glitch-splash__rgb--r,
  .vydra-glitch-splash.is-active .vydra-glitch-splash__rgb--g,
  .vydra-glitch-splash.is-active .vydra-glitch-splash__rgb--b {
    animation: none;
    display: none;
  }
}
