/**
 * Cyberpunk Screen Glitch Effects
 * Strong full-page glitch overlay for music activation
 */

/* Main glitch overlay container */
.glitch-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 1000;
  opacity: 0;
  background: transparent;
  mix-blend-mode: screen;
}

.glitch-overlay.active {
  opacity: 1;
  animation: glitch-master 0.1s infinite linear;
}

/* RGB distortion layers */
.glitch-overlay::before,
.glitch-overlay::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255, 0, 0, 0.03) 25%,
    rgba(0, 255, 0, 0.03) 50%,
    rgba(0, 0, 255, 0.03) 75%,
    transparent 100%
  );
}

.glitch-overlay::before {
  animation: glitch-rgb-1 0.15s infinite linear;
  mix-blend-mode: multiply;
}

.glitch-overlay::after {
  animation: glitch-rgb-2 0.2s infinite linear;
  mix-blend-mode: overlay;
}

/* Scanlines effect */
.glitch-scanlines {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(255, 255, 255, 0.02) 2px,
    rgba(255, 255, 255, 0.02) 4px
  );
  pointer-events: none;
  z-index: 1001;
  opacity: 0;
  animation: scanlines-flicker 0.08s infinite linear;
}

.glitch-scanlines.active {
  opacity: 0.8;
}

/* Digital noise layer */
.glitch-noise {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><defs><filter id="noiseFilter"><feTurbulence type="turbulence" baseFrequency="0.9" numOctaves="1" stitchTiles="stitch"/><feColorMatrix type="saturate" values="0"/></filter></defs><rect width="100%" height="100%" filter="url(%23noiseFilter)" opacity="0.05"/></svg>');
  pointer-events: none;
  z-index: 1002;
  opacity: 0;
  mix-blend-mode: screen;
}

.glitch-noise.active {
  opacity: 1;
  animation: noise-shift 0.05s infinite linear;
}

.glitch-cross-pattern {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-image: 
    radial-gradient(circle at 25% 25%, rgba(255, 215, 255, 0.02) 2px, transparent 2px),
    radial-gradient(circle at 75% 75%, rgba(102, 240, 255, 0.02) 2px, transparent 2px),
    linear-gradient(45deg, transparent 49%, rgba(255, 215, 255, 0.01) 50%, transparent 51%),
    linear-gradient(-45deg, transparent 49%, rgba(102, 240, 255, 0.01) 50%, transparent 51%);
  background-size: 40px 40px, 40px 40px, 20px 20px, 20px 20px;
  pointer-events: none;
  z-index: 1003;
  opacity: 0;
}

.glitch-cross-pattern.active {
  opacity: 1;
  animation: cross-pattern-pulse 0.3s infinite ease-in-out;
}

/* Color distortion bands */
.glitch-bands {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: linear-gradient(
    0deg,
    transparent 0%,
    rgba(255, 0, 100, 0.05) 10%,
    transparent 20%,
    rgba(0, 255, 200, 0.05) 30%,
    transparent 40%,
    rgba(255, 0, 100, 0.05) 60%,
    transparent 70%,
    rgba(0, 255, 200, 0.05) 90%,
    transparent 100%
  );
  pointer-events: none;
  z-index: 1004;
  opacity: 0;
}

.glitch-bands.active {
  opacity: 1;
  animation: bands-distort 0.12s infinite linear;
}

/* Keyframe animations */
@keyframes glitch-master {
  0% { transform: translate(0); filter: hue-rotate(0deg); }
  10% { transform: translate(-2px, -1px); filter: hue-rotate(5deg); }
  20% { transform: translate(1px, 2px); filter: hue-rotate(-3deg); }
  30% { transform: translate(-1px, -2px); filter: hue-rotate(8deg); }
  40% { transform: translate(2px, 1px); filter: hue-rotate(-2deg); }
  50% { transform: translate(-2px, 2px); filter: hue-rotate(12deg); }
  60% { transform: translate(1px, -1px); filter: hue-rotate(-7deg); }
  70% { transform: translate(-1px, 1px); filter: hue-rotate(4deg); }
  80% { transform: translate(2px, -2px); filter: hue-rotate(-9deg); }
  90% { transform: translate(-2px, -1px); filter: hue-rotate(6deg); }
  100% { transform: translate(0); filter: hue-rotate(0deg); }
}

@keyframes glitch-rgb-1 {
  0% { transform: translateX(0) scale(1, 1); }
  33% { transform: translateX(-2px) scale(1, 0.98); }
  66% { transform: translateX(2px) scale(1, 1.02); }
  100% { transform: translateX(0) scale(1, 1); }
}

@keyframes glitch-rgb-2 {
  0% { transform: translateY(0) scaleX(1); }
  25% { transform: translateY(1px) scaleX(0.99); }
  50% { transform: translateY(-1px) scaleX(1.01); }
  75% { transform: translateY(2px) scaleX(0.98); }
  100% { transform: translateY(0) scaleX(1); }
}

@keyframes scanlines-flicker {
  0% { opacity: 0.8; transform: translateY(0); }
  50% { opacity: 0.6; transform: translateY(-1px); }
  100% { opacity: 0.8; transform: translateY(0); }
}

@keyframes noise-shift {
  0% { transform: translate(0, 0); }
  25% { transform: translate(-1px, 1px); }
  50% { transform: translate(1px, -1px); }
  75% { transform: translate(-1px, -1px); }
  100% { transform: translate(0, 0); }
}

@keyframes cross-pattern-pulse {
  0% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.3; transform: scale(1.02); }
  100% { opacity: 1; transform: scale(1); }
}

@keyframes bands-distort {
  0% { transform: skewX(0deg) translateX(0); }
  25% { transform: skewX(1deg) translateX(2px); }
  50% { transform: skewX(-1deg) translateX(-1px); }
  75% { transform: skewX(0.5deg) translateX(1px); }
  100% { transform: skewX(0deg) translateX(0); }
}

/* Mobile - Completely disable all glitch effects */
@media (max-width: 768px) and (any-hover: none), 
       (max-width: 768px) and (pointer: coarse) {
  .glitch-overlay,
  .glitch-overlay.active,
  .glitch-scanlines,
  .glitch-scanlines.active,
  .glitch-noise,
  .glitch-noise.active,
  .glitch-cross-pattern,
  .glitch-cross-pattern.active,
  .glitch-bands,
  .glitch-bands.active {
    display: none !important;
    animation: none !important;
    opacity: 0 !important;
  }
}