/* ================================================
   GLITCH EFFECTS - CYBERPUNK 2077 STYLE
   ================================================ */

/* ================================================
   TEXT GLITCH EFFECT
   ================================================ */
.glitch {
  position: relative;
  animation: glitchSkew 2s infinite linear alternate-reverse;
}

.glitch::before,
.glitch::after {
  content: attr(data-text);
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

.glitch::before {
  color: var(--primary);
  animation: glitchTop 1s infinite linear alternate-reverse;
  clip-path: polygon(0 0, 100% 0, 100% 33%, 0 33%);
}

.glitch::after {
  color: var(--secondary);
  animation: glitchBottom 1.5s infinite linear alternate-reverse;
  clip-path: polygon(0 67%, 100% 67%, 100% 100%, 0 100%);
}

@keyframes glitchTop {
  0% { transform: translate(0); }
  20% { transform: translate(-3px, 3px); }
  40% { transform: translate(-3px, -3px); }
  60% { transform: translate(3px, 3px); }
  80% { transform: translate(3px, -3px); }
  100% { transform: translate(0); }
}

@keyframes glitchBottom {
  0% { transform: translate(0); }
  20% { transform: translate(3px, -3px); }
  40% { transform: translate(3px, 3px); }
  60% { transform: translate(-3px, -3px); }
  80% { transform: translate(-3px, 3px); }
  100% { transform: translate(0); }
}

@keyframes glitchSkew {
  0% { transform: skew(0deg); }
  10% { transform: skew(1deg); }
  20% { transform: skew(-1deg); }
  30% { transform: skew(0.5deg); }
  40% { transform: skew(-0.5deg); }
  50% { transform: skew(0deg); }
  100% { transform: skew(0deg); }
}

/* Light Glitch - Subtle version */
.glitch-light {
  position: relative;
}

.glitch-light:hover {
  animation: glitchLight 0.3s linear;
}

@keyframes glitchLight {
  0% { transform: translate(0); filter: none; }
  20% { transform: translate(-2px, 1px); filter: hue-rotate(90deg); }
  40% { transform: translate(2px, -1px); }
  60% { transform: translate(-1px, -1px); filter: hue-rotate(-90deg); }
  80% { transform: translate(1px, 1px); }
  100% { transform: translate(0); filter: none; }
}

/* ================================================
   CHROMATIC ABERRATION
   ================================================ */
.chromatic {
  position: relative;
}

.chromatic::before,
.chromatic::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.chromatic::before {
  background: inherit;
  filter: url('#chromatic-red');
  opacity: 0;
  animation: chromaticShift 4s ease-in-out infinite;
}

.chromatic::after {
  background: inherit;
  filter: url('#chromatic-blue');
  opacity: 0;
  animation: chromaticShift 4s ease-in-out infinite reverse;
}

@keyframes chromaticShift {
  0%, 100% { opacity: 0; transform: translate(0); }
  50% { opacity: 0.5; transform: translate(2px, 0); }
}

/* ================================================
   SCREEN FLICKER
   ================================================ */
.flicker {
  animation: flicker 0.15s infinite;
}

@keyframes flicker {
  0% { opacity: 0.97; }
  5% { opacity: 0.9; }
  10% { opacity: 0.97; }
  15% { opacity: 0.94; }
  20% { opacity: 0.98; }
  50% { opacity: 0.96; }
  80% { opacity: 0.94; }
  90% { opacity: 0.97; }
  100% { opacity: 0.96; }
}

/* ================================================
   DIGITAL NOISE BURST
   ================================================ */
.noise-burst {
  position: relative;
}

.noise-burst.active::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(196, 92, 38, 0.03) 2px,
    rgba(196, 92, 38, 0.03) 4px
  );
  animation: noiseBurst 0.1s steps(4) infinite;
  pointer-events: none;
}

@keyframes noiseBurst {
  0% { transform: translateY(0); }
  25% { transform: translateY(-2px); }
  50% { transform: translateY(1px); }
  75% { transform: translateY(-1px); }
  100% { transform: translateY(0); }
}

/* ================================================
   DATA CORRUPTION EFFECT
   ================================================ */
.corrupt {
  position: relative;
}

.corrupt::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(196, 92, 38, 0.08) 45%,
    rgba(212, 168, 75, 0.08) 55%,
    transparent 100%
  );
  background-size: 200% 100%;
  animation: corruptScan 2s linear infinite;
  pointer-events: none;
}

@keyframes corruptScan {
  0% { background-position: -100% 0; }
  100% { background-position: 100% 0; }
}

/* ================================================
   HOLOGRAM EFFECT - MILITECH STYLE
   ================================================ */
.hologram {
  position: relative;
  color: var(--secondary);
  text-shadow: 
    0 0 10px var(--secondary-glow),
    0 0 20px var(--secondary-glow),
    0 2px 0 var(--primary);
  animation: hologramFlicker 4s ease-in-out infinite;
}

@keyframes hologramFlicker {
  0%, 100% { 
    opacity: 1; 
    text-shadow: 
      0 0 10px var(--secondary-glow),
      0 0 20px var(--secondary-glow),
      0 2px 0 var(--primary);
  }
  92% { 
    opacity: 1; 
  }
  93% { 
    opacity: 0.85;
    text-shadow: 
      0 0 5px var(--secondary-glow),
      0 0 10px var(--secondary-glow);
  }
  94% { 
    opacity: 1;
  }
  96% { 
    opacity: 0.9;
    text-shadow: 
      2px 0 10px var(--primary-glow),
      -2px 0 10px var(--secondary-glow);
  }
  97% { 
    opacity: 1; 
  }
}

/* ================================================
   MATRIX RAIN (Background decoration)
   ================================================ */
.matrix-rain {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: -1;
  opacity: 0.05;
  overflow: hidden;
}

.matrix-column {
  position: absolute;
  top: -100%;
  font-family: var(--font-mono);
  font-size: 14px;
  line-height: 1.2;
  color: var(--secondary);
  text-shadow: 0 0 10px var(--secondary-glow);
  animation: matrixFall linear infinite;
  writing-mode: vertical-rl;
}

@keyframes matrixFall {
  0% { transform: translateY(0); }
  100% { transform: translateY(300%); }
}

/* ================================================
   TARGETING RETICLE
   ================================================ */
.reticle {
  position: relative;
}

.reticle::before,
.reticle::after {
  content: '';
  position: absolute;
  border: 1px solid var(--primary);
  opacity: 0;
  transition: all 0.3s ease;
}

.reticle::before {
  top: -5px;
  left: -5px;
  right: -5px;
  bottom: -5px;
  border-radius: 2px;
}

.reticle::after {
  top: 50%;
  left: 50%;
  width: 10px;
  height: 10px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
}

.reticle:hover::before,
.reticle:hover::after {
  opacity: 1;
}

.reticle:hover::before {
  animation: reticleExpand 0.3s ease forwards;
}

@keyframes reticleExpand {
  0% { 
    top: 50%;
    left: 50%;
    right: 50%;
    bottom: 50%;
  }
  100% {
    top: -5px;
    left: -5px;
    right: -5px;
    bottom: -5px;
  }
}

/* ================================================
   CRT SCREEN EFFECT
   ================================================ */
.crt-effect {
  position: relative;
}

.crt-effect::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    rgba(18, 16, 16, 0) 50%,
    rgba(0, 0, 0, 0.15) 50%
  );
  background-size: 100% 4px;
  pointer-events: none;
  z-index: 10;
}

.crt-effect::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(
    ellipse at center,
    transparent 0%,
    rgba(0, 0, 0, 0.2) 100%
  );
  pointer-events: none;
  z-index: 11;
}

/* ================================================
   POWER-UP ANIMATION
   ================================================ */
.power-up {
  animation: powerUp 1s ease-out forwards;
}

@keyframes powerUp {
  0% {
    opacity: 0;
    transform: scale(0.8);
    filter: brightness(3) saturate(0);
  }
  30% {
    opacity: 1;
    filter: brightness(2) saturate(0.5);
  }
  60% {
    transform: scale(1.02);
    filter: brightness(1.5) saturate(1);
  }
  100% {
    transform: scale(1);
    filter: brightness(1) saturate(1);
  }
}

/* ================================================
   ALERT PULSE
   ================================================ */
.alert-pulse {
  animation: alertPulse 1s ease-in-out infinite;
}

@keyframes alertPulse {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(201, 48, 44, 0.3);
  }
  50% {
    box-shadow: 0 0 0 8px rgba(201, 48, 44, 0);
  }
}

/* ================================================
   DATA STREAM
   ================================================ */
.data-stream {
  position: relative;
  overflow: hidden;
}

.data-stream::after {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 50%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(212, 168, 75, 0.08),
    transparent
  );
  animation: dataStream 3s linear infinite;
}

@keyframes dataStream {
  0% { left: -50%; }
  100% { left: 100%; }
}

/* ================================================
   NEW ITEM HIGHLIGHT
   ================================================ */
.new-item {
  animation: newItemGlow 2s ease-out;
}

@keyframes newItemGlow {
  0% {
    background: rgba(196, 92, 38, 0.15);
    box-shadow: 0 0 15px var(--primary-glow), inset 0 0 15px var(--primary-glow);
  }
  100% {
    background: transparent;
    box-shadow: none;
  }
}

/* ================================================
   SCANLINE HOVER
   ================================================ */
.scanline-hover {
  position: relative;
  overflow: hidden;
}

.scanline-hover::after {
  content: '';
  position: absolute;
  top: -100%;
  left: 0;
  width: 100%;
  height: 10px;
  background: linear-gradient(
    180deg,
    transparent,
    rgba(212, 168, 75, 0.2),
    transparent
  );
  opacity: 0;
  transition: opacity 0.3s ease;
}

.scanline-hover:hover::after {
  opacity: 1;
  animation: scanlineMove 1s linear infinite;
}

@keyframes scanlineMove {
  0% { top: -10px; }
  100% { top: 100%; }
}

/* ================================================
   CYBER BORDER ANIMATION - MILITECH STYLE
   ================================================ */
.cyber-border {
  position: relative;
}

.cyber-border::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: 1px solid transparent;
  background: linear-gradient(90deg, var(--primary), var(--secondary), var(--primary)) border-box;
  -webkit-mask: linear-gradient(#fff 0 0) padding-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  background-size: 200% 100%;
  animation: borderShift 3s linear infinite;
}

@keyframes borderShift {
  0% { background-position: 0% 0%; }
  100% { background-position: 200% 0%; }
}

/* ================================================
   TYPING EFFECT
   ================================================ */
.typing {
  overflow: hidden;
  border-right: 2px solid var(--primary);
  white-space: nowrap;
  animation: 
    typing 2s steps(30, end),
    blinkCaret 0.75s step-end infinite;
}

@keyframes typing {
  from { width: 0; }
  to { width: 100%; }
}

@keyframes blinkCaret {
  from, to { border-color: transparent; }
  50% { border-color: var(--primary); }
}

/* ================================================
   TRANSITION WIPE
   ================================================ */
.wipe-in {
  animation: wipeIn 0.5s ease-out forwards;
}

@keyframes wipeIn {
  0% {
    clip-path: polygon(0 0, 0 0, 0 100%, 0 100%);
  }
  100% {
    clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%);
  }
}

.wipe-out {
  animation: wipeOut 0.5s ease-in forwards;
}

@keyframes wipeOut {
  0% {
    clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%);
  }
  100% {
    clip-path: polygon(100% 0, 100% 0, 100% 100%, 100% 100%);
  }
}
