/* ========================================
   GLITCH TEXT EFFECTS
   Efectos de interferencia y corrupción
   ======================================== */

/* === GLITCH RGB SPLIT === */
.glitch {
  position: relative;
  display: inline-block;
  font-weight: 700;
}

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

.glitch::before {
  left: 2px;
  text-shadow: -2px 0 var(--accent-blood);
  clip: rect(24px, 550px, 90px, 0);
  animation: glitch-anim-1 2s infinite linear alternate-reverse;
}

.glitch::after {
  left: -2px;
  text-shadow: -2px 0 var(--arcane-green);
  clip: rect(85px, 550px, 140px, 0);
  animation: glitch-anim-2 2.5s infinite linear alternate-reverse;
}

@keyframes glitch-anim-1 {
  0% { clip: rect(2px, 9999px, 64px, 0); }
  10% { clip: rect(90px, 9999px, 23px, 0); }
  20% { clip: rect(5px, 9999px, 73px, 0); }
  30% { clip: rect(42px, 9999px, 12px, 0); }
  40% { clip: rect(67px, 9999px, 98px, 0); }
  50% { clip: rect(15px, 9999px, 45px, 0); }
  60% { clip: rect(88px, 9999px, 6px, 0); }
  70% { clip: rect(31px, 9999px, 77px, 0); }
  80% { clip: rect(54px, 9999px, 29px, 0); }
  90% { clip: rect(9px, 9999px, 91px, 0); }
  100% { clip: rect(76px, 9999px, 38px, 0); }
}

@keyframes glitch-anim-2 {
  0% { clip: rect(65px, 9999px, 119px, 0); }
  10% { clip: rect(33px, 9999px, 8px, 0); }
  20% { clip: rect(99px, 9999px, 51px, 0); }
  30% { clip: rect(17px, 9999px, 84px, 0); }
  40% { clip: rect(72px, 9999px, 26px, 0); }
  50% { clip: rect(44px, 9999px, 93px, 0); }
  60% { clip: rect(11px, 9999px, 68px, 0); }
  70% { clip: rect(86px, 9999px, 3px, 0); }
  80% { clip: rect(59px, 9999px, 47px, 0); }
  90% { clip: rect(22px, 9999px, 101px, 0); }
  100% { clip: rect(95px, 9999px, 34px, 0); }
}

/* === GLITCH ON HOVER === */
.glitch-hover {
  position: relative;
  transition: all 0.3s ease;
}

.glitch-hover:hover {
  animation: glitch-skew 0.3s ease-in-out;
}

@keyframes glitch-skew {
  0% { transform: skew(0deg); }
  20% { transform: skew(-2deg); }
  40% { transform: skew(2deg); }
  60% { transform: skew(-1deg); }
  80% { transform: skew(1deg); }
  100% { transform: skew(0deg); }
}

/* === SCAN LINES CRT === */
.scan-lines {
  position: relative;
  overflow: hidden;
}

.scan-lines::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    transparent 50%,
    rgba(16, 185, 129, 0.05) 50%
  );
  background-size: 100% 4px;
  pointer-events: none;
  z-index: 10;
  animation: scan 8s linear infinite;
}

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

/* === DATA CORRUPTION === */
.data-corrupt {
  position: relative;
  display: inline-block;
}

.data-corrupt:hover::before {
  content: '█▓▒░';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  color: var(--arcane-green);
  opacity: 0.8;
  animation: corrupt 0.5s steps(5) infinite;
}

@keyframes corrupt {
  0%, 100% { opacity: 0; }
  50% { opacity: 1; }
}

/* === STATIC NOISE === */
.static-noise {
  position: relative;
}

.static-noise::after {
  content: '';
  position: absolute;
  top: -10%;
  left: -10%;
  width: 120%;
  height: 120%;
  background-image: url('data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIzMDAiIGhlaWdodD0iMzAwIj48ZmlsdGVyIGlkPSJhIiB4PSIwIiB5PSIwIj48ZmVUdXJidWxlbmNlIGJhc2VGcmVxdWVuY3k9Ii43NSIgc3RpdGNoVGlsZXM9InN0aXRjaCIgdHlwZT0iZnJhY3RhbE5vaXNlIi8+PGZlQ29sb3JNYXRyaXggdHlwZT0ic2F0dXJhdGUiIHZhbHVlcz0iMCIvPjwvZmlsdGVyPjxwYXRoIGQ9Ik0wIDBoMzAwdjMwMEgweiIgZmlsdGVyPSJ1cmwoI2EpIiBvcGFjaXR5PSIuMDUiLz48L3N2Zz4=');
  opacity: 0;
  pointer-events: none;
  animation: static 0.1s steps(10) infinite;
}

.static-noise:hover::after {
  opacity: 0.1;
}

@keyframes static {
  0%, 100% { transform: translate(0, 0); }
  10% { transform: translate(-5%, -5%); }
  20% { transform: translate(-10%, 5%); }
  30% { transform: translate(5%, -10%); }
  40% { transform: translate(-5%, 15%); }
  50% { transform: translate(-10%, 5%); }
  60% { transform: translate(15%, 0); }
  70% { transform: translate(0, 10%); }
  80% { transform: translate(-15%, 0); }
  90% { transform: translate(10%, 5%); }
}

/* === GLITCH TITLES (Aplicar a h1, h2) === */
h1.glitch-title,
h2.glitch-title {
  position: relative;
  font-weight: 700;
  color: var(--arcane-gold);
  text-shadow: var(--glow-gold);
}

h1.glitch-title::before,
h1.glitch-title::after,
h2.glitch-title::before,
h2.glitch-title::after {
  content: attr(data-text);
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  animation-duration: 3s;
  animation-timing-function: linear;
  animation-iteration-count: infinite;
}

h1.glitch-title::before,
h2.glitch-title::before {
  text-shadow: -2px 0 var(--accent-blood);
  animation-name: glitch-subtle-1;
}

h1.glitch-title::after,
h2.glitch-title::after {
  text-shadow: 2px 0 var(--arcane-green);
  animation-name: glitch-subtle-2;
}

@keyframes glitch-subtle-1 {
  0%, 90%, 100% { opacity: 0; }
  91%, 94% { opacity: 1; left: 2px; }
}

@keyframes glitch-subtle-2 {
  0%, 85%, 100% { opacity: 0; }
  86%, 89% { opacity: 1; left: -2px; }
}

/* === ACCESSIBILITY === */
@media (prefers-reduced-motion: reduce) {
  .glitch::before,
  .glitch::after,
  .scan-lines::before,
  .static-noise::after,
  .glitch-title::before,
  .glitch-title::after {
    animation: none;
  }
}
