/**
 * ROUGESWORLD - Transition Effects
 * Epic cinematic transition animations for Time Warp system
 */

/* === TRANSITION OVERLAY BASE === */
.transition-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 9999;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  background: radial-gradient(circle at center, rgba(0, 20, 0, 0.95), rgba(0, 0, 0, 0.98));
  transition: opacity 0.3s ease-in-out, visibility 0.3s ease-in-out;
  overflow: hidden;
}

.transition-overlay.active {
  opacity: 1;
  visibility: visible;
  pointer-events: all;
}

/* === TIME WARP EFFECT === */
.time-warp-effect {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 10;
  overflow: hidden;
}

/* Warp Lines - Epic Cinematic Effect */
.warp-lines {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 300px;
  height: 300px;
  opacity: 0;
  transition: opacity 0.2s ease-in-out;
  z-index: 15;
}

.warp-lines.active {
  opacity: 1;
  animation: epicTimeWarp 1.5s cubic-bezier(0.215, 0.61, 0.355, 1) forwards;
}

@keyframes epicTimeWarp {
  0% {
    transform: translate(-50%, -50%) scale(0.2) rotate(0deg);
    opacity: 0;
    filter: blur(15px) brightness(0.5);
  }
  10% {
    opacity: 0.6;
    transform: translate(-50%, -50%) scale(0.6) rotate(30deg);
    filter: blur(8px) brightness(0.8);
  }
  25% {
    opacity: 0.9;
    transform: translate(-50%, -50%) scale(1.0) rotate(60deg);
    filter: blur(2px) brightness(1.2);
  }
  50% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.5) rotate(120deg);
    filter: blur(0px) brightness(1.5);
  }
  75% {
    opacity: 0.8;
    transform: translate(-50%, -50%) scale(2.5) rotate(240deg);
    filter: blur(5px) brightness(1.2);
  }
  100% {
    transform: translate(-50%, -50%) scale(4) rotate(360deg);
    opacity: 0;
    filter: blur(20px) brightness(0.5);
  }
}

/* Warp Rings - Epic Expanding Energy Rings */
.warp-ring {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  border: 2px solid #00ff00;
  border-radius: 50%;
  width: 60px;
  height: 60px;
  opacity: 0;
  animation: epicRingExpansion 1.2s cubic-bezier(0.19, 1, 0.22, 1) forwards;
  box-shadow: 
    0 0 20px rgba(0, 255, 0, 0.8),
    inset 0 0 20px rgba(0, 255, 0, 0.3);
  mix-blend-mode: screen;
}

.warp-ring:nth-child(odd) {
  border-color: #66ff66;
  animation-delay: 0.1s;
}

.warp-ring:nth-child(3n) {
  border-color: #00cc00;
  animation-delay: 0.2s;
  animation-duration: 1.4s;
}

.warp-ring:nth-child(4n) {
  border-color: #33ff33;
  animation-delay: 0.15s;
  animation-duration: 1.3s;
}

/* Digital code ring - inner ring with binary/hex pattern */
.warp-ring::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 90%;
  height: 90%;
  border-radius: 50%;
  background: 
    repeating-conic-gradient(
      rgba(0, 255, 0, 0.1) 0deg 10deg,
      rgba(0, 255, 0, 0.2) 10deg 20deg
    );
  opacity: 0.7;
  animation: ringRotate 3s linear infinite;
}

/* Digital code ring - outer ring with binary/hex pattern */
.warp-ring::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 110%;
  height: 110%;
  border-radius: 50%;
  background: 
    repeating-conic-gradient(
      rgba(0, 255, 0, 0.1) 0deg 5deg,
      rgba(0, 255, 0, 0.05) 5deg 10deg
    );
  opacity: 0.5;
  animation: ringRotate 2s linear infinite reverse;
}

@keyframes ringRotate {
  from { transform: translate(-50%, -50%) rotate(0deg); }
  to { transform: translate(-50%, -50%) rotate(360deg); }
}

@keyframes epicRingExpansion {
  0% {
    width: 60px;
    height: 60px;
    opacity: 0;
    border-width: 3px;
    box-shadow: 
      0 0 20px rgba(0, 255, 0, 0.8),
      inset 0 0 20px rgba(0, 255, 0, 0.3);
    filter: hue-rotate(0deg);
  }
  10% {
    opacity: 0.7;
    border-width: 2.5px;
    box-shadow: 
      0 0 30px rgba(0, 255, 0, 0.9),
      inset 0 0 25px rgba(0, 255, 0, 0.4);
  }
  30% {
    opacity: 1;
    border-width: 2px;
    box-shadow: 
      0 0 50px rgba(0, 255, 0, 1),
      inset 0 0 35px rgba(0, 255, 0, 0.6);
    filter: hue-rotate(30deg) brightness(1.2);
  }
  60% {
    width: 400px;
    height: 400px;
    opacity: 0.8;
    border-width: 1px;
    box-shadow: 
      0 0 70px rgba(0, 255, 0, 0.8),
      inset 0 0 50px rgba(0, 255, 0, 0.4);
    filter: hue-rotate(60deg) brightness(1.1);
  }
  100% {
    width: 800px;
    height: 800px;
    opacity: 0;
    border-width: 0.5px;
    box-shadow: 
      0 0 100px rgba(0, 255, 0, 0),
      inset 0 0 60px rgba(0, 255, 0, 0);
    filter: hue-rotate(90deg) brightness(1);
  }
}

/* Warp Text - Epic Cinematic Style */
.warp-text {
  position: relative;
  z-index: 15;
  font-family: 'VT323', monospace;
  font-size: 2.8rem;
  color: #00ff00;
  text-align: center;
  margin-bottom: 2rem;
  text-shadow: 
    0 0 15px #00ff00,
    0 0 30px #00ff00,
    0 0 45px #00ff00,
    0 0 60px rgba(0, 255, 0, 0.5);
  animation: epicTextPulse 0.15s infinite alternate;
  letter-spacing: 0.15em;
  font-weight: bold;
  text-transform: uppercase;
  position: relative;
  overflow: hidden;
}

/* Matrix code overlay on text */
.warp-text::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: 
    linear-gradient(90deg, 
      rgba(0, 255, 0, 0) 0%,
      rgba(0, 255, 0, 0.2) 50%,
      rgba(0, 255, 0, 0) 100%);
  animation: textScanline 2s linear infinite;
  z-index: -1;
  pointer-events: none;
}

/* Text glitch effect */
.warp-text::after {
  content: attr(data-text);
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  color: transparent;
  text-shadow: 
    2px 0 1px rgba(255, 0, 0, 0.7),
    -2px 0 1px rgba(0, 0, 255, 0.7);
  animation: textGlitch 0.3s infinite alternate;
  z-index: -1;
  opacity: 0.5;
}

@keyframes textScanline {
  0% {
    transform: translateX(-100%);
  }
  100% {
    transform: translateX(100%);
  }
}

@keyframes textGlitch {
  0% {
    transform: translateX(-2px) skewX(3deg);
  }
  10% {
    transform: translateX(2px) skewX(0deg);
  }
  20% {
    transform: translateX(-1px) skewX(-3deg);
  }
  30% {
    transform: translateX(0px) skewX(0deg);
  }
  40% {
    transform: translateX(1px) skewX(3deg);
  }
  100% {
    transform: translateX(0px) skewX(0deg);
  }
}

@keyframes epicTextPulse {
  0% {
    text-shadow: 
      0 0 15px #00ff00,
      0 0 30px #00ff00,
      0 0 45px #00ff00,
      0 0 60px rgba(0, 255, 0, 0.5);
    transform: scale(1);
    filter: brightness(1);
  }
  50% {
    text-shadow: 
      0 0 18px #00ff00,
      0 0 35px #00ff00,
      0 0 50px #00ff00,
      0 0 70px rgba(0, 255, 0, 0.6);
    transform: scale(1.01);
    filter: brightness(1.1);
  }
  100% {
    text-shadow: 
      0 0 20px #00ff00,
      0 0 40px #00ff00,
      0 0 60px #00ff00,
      0 0 80px rgba(0, 255, 0, 0.8),
      2px 0 0 rgba(255, 0, 0, 0.7),
      -2px 0 0 rgba(0, 0, 255, 0.7);
    transform: scale(1.02);
    filter: brightness(1.2);
  }
}

/* Progress Bar */
.warp-progress {
  position: relative;
  z-index: 15;
  width: 400px;
  height: 4px;
  background: rgba(0, 255, 0, 0.2);
  border-radius: 2px;
  overflow: hidden;
  box-shadow: 
    0 0 10px rgba(0, 255, 0, 0.5),
    inset 0 0 10px rgba(0, 255, 0, 0.2);
}

.progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, 
    #00ff00 0%, 
    #66ff66 50%, 
    #00ff00 100%);
  border-radius: 2px;
  box-shadow: 
    0 0 15px #00ff00,
    0 0 30px rgba(0, 255, 0, 0.5);
  animation: progressPulse 0.5s ease-in-out infinite alternate;
  transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes progressPulse {
  0% {
    box-shadow: 
      0 0 15px #00ff00,
      0 0 30px rgba(0, 255, 0, 0.5);
  }
  100% {
    box-shadow: 
      0 0 25px #00ff00,
      0 0 50px rgba(0, 255, 0, 0.8);
  }
}

/* === MATRIX INTENSIFY OVERLAY === */
.matrix-intensify-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 5;
  opacity: 0;
  transition: opacity 0.3s ease-in-out;
  background: radial-gradient(circle at center, 
    rgba(0, 255, 0, 0.1) 0%, 
    transparent 70%);
}

.matrix-intensify-overlay.active {
  opacity: 1;
  animation: matrixIntensify 0.8s ease-in-out;
}

@keyframes matrixIntensify {
  0%, 100% {
    background: radial-gradient(circle at center, 
      rgba(0, 255, 0, 0.1) 0%, 
      transparent 70%);
  }
  50% {
    background: radial-gradient(circle at center, 
      rgba(0, 255, 0, 0.3) 0%, 
      rgba(0, 255, 0, 0.1) 50%,
      transparent 70%);
  }
}

/* Matrix Characters in Transition */
.matrix-char-transition {
  position: absolute;
  font-family: 'VT323', monospace;
  font-size: 1.5rem;
  color: #00ff00;
  opacity: 0;
  animation: matrixCharFall 2s linear forwards;
  text-shadow: 0 0 10px #00ff00;
}

@keyframes matrixCharFall {
  0% {
    opacity: 1;
    transform: translateY(-100vh) scale(0.5);
  }
  50% {
    opacity: 0.8;
    transform: translateY(50vh) scale(1);
  }
  100% {
    opacity: 0;
    transform: translateY(150vh) scale(0.5);
  }
}

/* === GLITCH OVERLAY === */
.glitch-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 8;
  opacity: 0;
  transition: opacity 0.1s ease-in-out;
}

.glitch-overlay.active {
  opacity: 1;
  animation: glitchFlicker 0.3s ease-in-out;
}

@keyframes glitchFlicker {
  0%, 100% { opacity: 1; }
  10% { opacity: 0.8; }
  20% { opacity: 1; }
  30% { opacity: 0.6; }
  40% { opacity: 1; }
  50% { opacity: 0.9; }
  60% { opacity: 0.4; }
  70% { opacity: 1; }
  80% { opacity: 0.7; }
  90% { opacity: 1; }
}

/* Glitch Bars */
.glitch-bar {
  position: absolute;
  left: 0;
  width: 100%;
  background: linear-gradient(90deg, 
    transparent 0%,
    rgba(255, 0, 0, 0.8) 25%,
    rgba(0, 255, 0, 0.8) 50%,
    rgba(0, 0, 255, 0.8) 75%,
    transparent 100%);
  animation: glitchBarSlide 0.1s ease-in-out infinite;
  mix-blend-mode: screen;
}

@keyframes glitchBarSlide {
  0% {
    transform: translateX(-100%);
    opacity: 1;
  }
  50% {
    transform: translateX(0%);
    opacity: 0.8;
  }
  100% {
    transform: translateX(100%);
    opacity: 0;
  }
}

/* === CINEMATIC EFFECTS === */

/* Bullet Time Effect */
.bullet-time-effect {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 12;
  opacity: 0;
  background: radial-gradient(ellipse at center,
    transparent 30%,
    rgba(0, 0, 0, 0.8) 70%);
  animation: bulletTimeWarp 2s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

@keyframes bulletTimeWarp {
  0% {
    opacity: 0;
    transform: scale(1);
  }
  30% {
    opacity: 1;
    transform: scale(1.1);
  }
  70% {
    opacity: 0.8;
    transform: scale(0.95);
  }
  100% {
    opacity: 0;
    transform: scale(1);
  }
}

/* Lens Flare Effect */
.lens-flare {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 2px;
  height: 2px;
  background: #ffffff;
  border-radius: 50%;
  opacity: 0;
  animation: lensFlareExplosion 1s ease-out forwards;
  z-index: 20;
}

@keyframes lensFlareExplosion {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(1);
    box-shadow: 0 0 0 rgba(255, 255, 255, 0);
  }
  10% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
    box-shadow: 
      0 0 20px rgba(255, 255, 255, 1),
      0 0 40px rgba(0, 255, 0, 0.8),
      0 0 60px rgba(0, 255, 0, 0.6);
  }
  50% {
    opacity: 0.8;
    transform: translate(-50%, -50%) scale(50);
    box-shadow: 
      0 0 100px rgba(255, 255, 255, 0.8),
      0 0 200px rgba(0, 255, 0, 0.6),
      0 0 300px rgba(0, 255, 0, 0.4);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(100);
    box-shadow: 
      0 0 200px rgba(255, 255, 255, 0),
      0 0 400px rgba(0, 255, 0, 0),
      0 0 600px rgba(0, 255, 0, 0);
  }
}

/* Shockwave Effect */
.shockwave {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 10px;
  height: 10px;
  border: 2px solid rgba(0, 255, 0, 0.8);
  border-radius: 50%;
  opacity: 0;
  animation: shockwaveExpansion 1.5s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
  z-index: 18;
}

@keyframes shockwaveExpansion {
  0% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
    border-width: 3px;
  }
  50% {
    opacity: 0.6;
    transform: translate(-50%, -50%) scale(50);
    border-width: 2px;
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(100);
    border-width: 1px;
  }
}

/* Digital Distortion Grid */
.digital-grid {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 6;
  opacity: 0;
  background-image: 
    linear-gradient(rgba(0, 255, 0, 0.15) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 255, 0, 0.15) 1px, transparent 1px);
  background-size: 40px 40px;
  animation: digitalGridPulse 2s cubic-bezier(0.19, 1, 0.22, 1);
  pointer-events: none;
}

/* Binary overlay on grid */
.digital-grid::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-image: 
    repeating-linear-gradient(0deg, 
      transparent 0px, 
      transparent 20px, 
      rgba(0, 255, 0, 0.05) 20px, 
      rgba(0, 255, 0, 0.05) 40px);
  opacity: 0.7;
  animation: binaryScroll 20s linear infinite;
}

/* Hexadecimal overlay on grid */
.digital-grid::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-image: 
    repeating-linear-gradient(90deg, 
      transparent 0px, 
      transparent 30px, 
      rgba(0, 255, 0, 0.07) 30px, 
      rgba(0, 255, 0, 0.07) 60px);
  opacity: 0.5;
  animation: hexScroll 15s linear infinite reverse;
}

@keyframes binaryScroll {
  from { background-position: 0 0; }
  to { background-position: 0 1000px; }
}

@keyframes hexScroll {
  from { background-position: 0 0; }
  to { background-position: 1000px 0; }
}

@keyframes digitalGridPulse {
  0% {
    opacity: 0;
    transform: scale(1);
    background-size: 60px 60px;
  }
  20% {
    opacity: 0.2;
    transform: scale(1.02);
    background-size: 50px 50px;
  }
  50% {
    opacity: 0.4;
    transform: scale(1.05);
    background-size: 40px 40px;
  }
  80% {
    opacity: 0.2;
    transform: scale(1.02);
    background-size: 50px 50px;
  }
  100% {
    opacity: 0;
    transform: scale(1);
    background-size: 60px 60px;
  }
}

/* === RESPONSIVE DESIGN === */
@media (max-width: 768px) {
  .warp-text {
    font-size: 1.8rem;
    margin-bottom: 1.5rem;
  }
  
  .warp-progress {
    width: 300px;
  }
  
  .matrix-char-transition {
    font-size: 1.2rem;
  }
}

@media (max-width: 480px) {
  .warp-text {
    font-size: 1.4rem;
    margin-bottom: 1rem;
  }
  
  .warp-progress {
    width: 250px;
    height: 3px;
  }
  
  .matrix-char-transition {
    font-size: 1rem;
  }
}

/* === PERFORMANCE OPTIMIZATIONS === */
.transition-overlay * {
  will-change: transform, opacity;
  backface-visibility: hidden;
  transform-style: preserve-3d;
}

/* Reduce motion for accessibility */
@media (prefers-reduced-motion: reduce) {
  .warp-lines.active {
    animation: none;
    opacity: 0.5;
  }
  
  .warp-ring {
    animation: none;
    opacity: 0.3;
  }
  
  .matrix-char-transition {
    animation: none;
    opacity: 0.5;
  }
  
  .glitch-overlay.active {
    animation: none;
    opacity: 0.7;
  }
}