/* Matrix-Style Typing Animation for Auto-Explore Feature Names */

.matrix-typing-overlay {
  position: fixed;
  top: 20vh;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  pointer-events: none;
  font-family: 'VT323', 'Courier New', monospace;
  font-size: 4rem;
  font-weight: 400;
  color: #ffe900; /* Yellow text like Matrix */
  text-shadow: 
    1px 1px 2px #000000,
    -1px -1px 2px #000000,
    1px -1px 2px #000000,
    -1px 1px 2px #000000,
    0 0 8px #000000,
    0 0 12px #ffe900, /* Yellow glow */
    0 0 20px rgba(64, 64, 64, 0.8), /* Dark gray glow */
    0 0 30px rgba(32, 32, 32, 0.6), /* Larger dark gray glow */
    0 0 40px rgba(16, 16, 16, 0.4); /* Outermost transparent glow */
  text-align: center;
  width: 80vw;
  max-width: 1200px;
  min-height: 120px;
  word-wrap: break-word;
  word-break: normal;
  overflow-wrap: break-word;
  hyphens: none;
  white-space: normal;
  letter-spacing: 0.1em;
  line-height: 1.2;
  opacity: 0;
  transition: opacity 0.3s ease-in-out;
  /* Beautiful gradient glow background */
  background: 
    radial-gradient(ellipse 800px 300px at center, 
      rgba(0, 0, 0, 0.7) 0%, 
      rgba(0, 0, 0, 0.5) 30%, 
      rgba(0, 0, 0, 0.3) 50%, 
      rgba(0, 0, 0, 0.1) 70%, 
      transparent 90%);
  padding: 2rem;
  border-radius: 20px;
}

/* Description text styling - smaller font below main title */
.matrix-typing-description {
  font-family: 'VT323', 'Courier New', monospace;
  font-size: 2rem; /* Smaller than main title (4rem) */
  font-weight: 300;
  color: #ffe900; /* Same yellow as main text */
  text-shadow: 
    1px 1px 1px #000000,
    -1px -1px 1px #000000,
    1px -1px 1px #000000,
    -1px 1px 1px #000000,
    0 0 6px #000000,
    0 0 8px #ffe900, /* Subtle yellow glow */
    0 0 15px rgba(64, 64, 64, 0.7), /* Dark gray glow */
    0 0 25px rgba(32, 32, 32, 0.5), /* Larger dark gray glow */
    0 0 35px rgba(16, 16, 16, 0.3); /* Outermost transparent glow */
  text-align: center;
  width: 80vw;
  max-width: 1200px;
  min-height: 60px;
  word-wrap: break-word;
  word-break: normal;
  overflow-wrap: break-word;
  hyphens: none;
  white-space: normal;
  letter-spacing: 0.05em;
  line-height: 1.3;
  margin-top: 1rem;
  opacity: 0;
  transition: opacity 0.3s ease-in-out;
}

.matrix-typing-overlay.visible {
  opacity: 1;
}

.matrix-typing-description.visible {
  opacity: 1;
}

.matrix-typing-text {
  position: relative;
  display: inline-block;
}

/* Matrix cursor - blinking underscore */
.matrix-typing-cursor {
  display: inline-block;
  color: #ffe900; /* Yellow cursor */
  animation: matrix-cursor-blink 0.8s infinite;
  font-weight: bold;
  text-shadow: 
    2px 2px 0px #000000,
    -2px -2px 0px #000000,
    2px -2px 0px #000000,
    -2px 2px 0px #000000,
    0 0 15px #ffe900; /* Yellow glow for cursor */
}

@keyframes matrix-cursor-blink {
  0%, 49% {
    opacity: 1;
  }
  50%, 100% {
    opacity: 0;
  }
}

/* Character typing animation with Matrix-style effects */
.matrix-char {
  opacity: 1 !important; /* Force visibility */
  display: inline-block;
  transform: scaleY(1) scaleX(1); /* Ensure normal scale */
  filter: blur(0px) brightness(1); /* Ensure normal appearance */
  animation: matrix-char-appear 0.1s ease-out forwards;
}

@keyframes matrix-char-appear {
  0% {
    opacity: 0.3;
    transform: scaleY(0.3) scaleX(0.8);
    filter: blur(2px) brightness(1.5);
  }
  50% {
    opacity: 0.8;
    transform: scaleY(1.1) scaleX(1.05);
    filter: blur(0px) brightness(1.2);
  }
  100% {
    opacity: 1 !important;
    transform: scaleY(1) scaleX(1);
    filter: blur(0px) brightness(1);
  }
}

/* Untyping animation (faster reverse) */
.matrix-char.untyping {
  animation: matrix-char-disappear 0.05s ease-in forwards;
}

@keyframes matrix-char-disappear {
  0% {
    opacity: 1;
    transform: scaleY(1) scaleX(1);
    filter: blur(0px) brightness(1);
  }
  30% {
    opacity: 0.6;
    transform: scaleY(0.8) scaleX(0.9);
    filter: blur(1px) brightness(1.3);
  }
  100% {
    opacity: 0;
    transform: scaleY(0.1) scaleX(0.7);
    filter: blur(4px) brightness(2);
  }
}

/* Glitch effect integration - adapting the existing glitch-text styles */
.matrix-typing-text.glitch {
  position: relative;
  display: inline-block;
  z-index: 2;
}

.matrix-typing-text.glitch::before,
.matrix-typing-text.glitch::after {
  content: attr(data-text);
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  color: #ffe900; /* Yellow for glitch */
  overflow: hidden;
  clip: rect(0, 9999px, 0, 0);
  text-shadow: 
    1px 1px 2px #000000,
    -1px -1px 2px #000000,
    1px -1px 2px #000000,
    -1px 1px 2px #000000,
    0 0 8px #000000,
    0 0 12px #ffe900; /* Yellow glow */
}

.matrix-typing-text.glitch::before {
  left: -2px;
  text-shadow: 
    1px 1px 2px #000000,
    -1px -1px 2px #000000,
    1px -1px 2px #000000,
    -1px 1px 2px #000000,
    0 0 8px #000000,
    2px 0 4px #00ffff,
    0 0 12px #ffe900; /* Yellow glow */
  animation: matrix-glitch-c2 1s infinite linear alternate-reverse;
}

.matrix-typing-text.glitch::after {
  left: 3px;
  text-shadow: 
    1px 1px 2px #000000,
    -1px -1px 2px #000000,
    1px -1px 2px #000000,
    -1px 1px 2px #000000,
    0 0 8px #000000,
    -2px 0 4px #ff0080,
    0 0 12px #ffe900; /* Yellow glow */
  animation: matrix-glitch-c1 2s infinite linear alternate-reverse;
}

.matrix-typing-text.glitch {
  transform: skewX(0deg) scaleY(1);
  animation: matrix-glitch-jitter 4s linear infinite;
}

/* Matrix glitch keyframes - adapted from cyberpunk-additions.css */
@keyframes matrix-glitch-c1 {
  0% { clip: rect(31px, 9999px, 94px, 0); }
  5% { clip: rect(70px, 9999px, 71px, 0); }
  10% { clip: rect(29px, 9999px, 83px, 0); }
  15% { clip: rect(16px, 9999px, 91px, 0); }
  20% { clip: rect(2px, 9999px, 23px, 0); }
  25% { clip: rect(60px, 9999px, 73px, 0); }
  30% { clip: rect(14px, 9999px, 56px, 0); }
  35% { clip: rect(89px, 9999px, 25px, 0); }
  40% { clip: rect(32px, 9999px, 12px, 0); }
  45% { clip: rect(67px, 9999px, 48px, 0); }
  50% { clip: rect(36px, 9999px, 53px, 0); }
  55% { clip: rect(72px, 9999px, 69px, 0); }
  60% { clip: rect(20px, 9999px, 33px, 0); }
  65% { clip: rect(54px, 9999px, 84px, 0); }
  70% { clip: rect(97px, 9999px, 95px, 0); }
  75% { clip: rect(62px, 9999px, 17px, 0); }
  80% { clip: rect(23px, 9999px, 46px, 0); }
  85% { clip: rect(19px, 9999px, 96px, 0); }
  90% { clip: rect(61px, 9999px, 36px, 0); }
  95% { clip: rect(83px, 9999px, 91px, 0); }
  100% { clip: rect(76px, 9999px, 40px, 0); }
}

@keyframes matrix-glitch-c2 {
  0% { clip: rect(65px, 9999px, 100px, 0); }
  5% { clip: rect(52px, 9999px, 74px, 0); }
  10% { clip: rect(79px, 9999px, 85px, 0); }
  15% { clip: rect(75px, 9999px, 5px, 0); }
  20% { clip: rect(67px, 9999px, 61px, 0); }
  25% { clip: rect(14px, 9999px, 79px, 0); }
  30% { clip: rect(1px, 9999px, 66px, 0); }
  35% { clip: rect(86px, 9999px, 30px, 0); }
  40% { clip: rect(23px, 9999px, 98px, 0); }
  45% { clip: rect(85px, 9999px, 72px, 0); }
  50% { clip: rect(71px, 9999px, 75px, 0); }
  55% { clip: rect(2px, 9999px, 48px, 0); }
  60% { clip: rect(30px, 9999px, 16px, 0); }
  65% { clip: rect(59px, 9999px, 50px, 0); }
  70% { clip: rect(41px, 9999px, 62px, 0); }
  75% { clip: rect(2px, 9999px, 82px, 0); }
  80% { clip: rect(47px, 9999px, 73px, 0); }
  85% { clip: rect(3px, 9999px, 27px, 0); }
  90% { clip: rect(26px, 9999px, 55px, 0); }
  95% { clip: rect(42px, 9999px, 97px, 0); }
  100% { clip: rect(38px, 9999px, 49px, 0); }
}

@keyframes matrix-glitch-jitter {
  1%   { transform: scaleY(1) skewX(0deg); }
  1.5% { transform: scaleY(1.6) skewX(-30deg); }
  2%   { transform: scaleY(1) skewX(0deg); }
  51%  { transform: scaleX(1) scaleY(1) skewX(0deg); }
  52%  { transform: scaleX(1.2) scaleY(.6) skewX(40deg); }
  53%  { transform: scaleX(1) scaleY(1) skewX(0deg); }
}

/* Enhanced glow for dramatic effect */
.matrix-typing-overlay.dramatic {
  text-shadow: 
    1px 1px 3px #000000,
    -1px -1px 3px #000000,
    1px -1px 3px #000000,
    -1px 1px 3px #000000,
    0 0 12px #000000,
    0 0 20px #ffe900; /* Yellow glow for dramatic mode */
}

/* Random character flicker effect during typing - safer version */
.matrix-char.flicker {
  animation: matrix-char-flicker 0.1s ease-in-out;
}

@keyframes matrix-char-flicker {
  0%, 100% {
    opacity: 1 !important;
    filter: brightness(1);
  }
  50% {
    opacity: 0.7; /* Less dim to ensure visibility */
    filter: brightness(1.5) hue-rotate(60deg);
  }
}

/* Responsive design for mobile */
@media (max-width: 768px) {
  .matrix-typing-overlay {
    font-size: 2.5rem;
    top: 15vh;
    max-width: 95vw;
    padding: 0 10px;
  }
}

@media (max-width: 480px) {
  .matrix-typing-overlay {
    font-size: 2rem;
    top: 12vh;
    letter-spacing: 0.05em;
  }
}

/* Matrix character entrance animation */
.matrix-char {
  display: inline-block;
  transition: all 0.1s ease-out;
}

.matrix-char:nth-child(odd) {
  animation: matrix-char-shimmer 2s infinite ease-in-out;
  animation-delay: calc(var(--char-index, 0) * 0.1s);
}

.matrix-char:nth-child(even) {
  animation: matrix-char-pulse 1.5s infinite ease-in-out;
  animation-delay: calc(var(--char-index, 0) * 0.15s);
}

@keyframes matrix-char-shimmer {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(1.3) hue-rotate(10deg); }
}

@keyframes matrix-char-pulse {
  0%, 100% { text-shadow: 0 0 8px #000000, 0 0 12px #ffe900; }
  50% { text-shadow: 0 0 8px #000000, 0 0 18px #ffe900, 0 0 25px #ffff88; }
}

/* Enhanced flicker effect for Matrix characters */
.matrix-char.flicker {
  animation: matrix-intense-flicker 0.08s ease-in-out;
  filter: brightness(1.5) contrast(1.2);
}

@keyframes matrix-intense-flicker {
  0%, 100% {
    opacity: 1 !important;
    filter: brightness(1.5);
    text-shadow: 
      0 0 8px #000000, 
      0 0 20px #ffe900, 
      0 0 30px #ffff88;
  }
  25% {
    opacity: 0.7 !important;
    filter: brightness(0.8) hue-rotate(20deg);
  }
  75% {
    opacity: 1.2 !important;
    filter: brightness(1.8) contrast(1.5);
  }
}

/* Special effects for different typing speeds */
.matrix-typing-overlay.fast-type .matrix-char {
  animation-duration: 0.05s;
}

.matrix-typing-overlay.slow-type .matrix-char {
  animation-duration: 0.15s;
}

.matrix-typing-overlay.ultra-slow-type .matrix-char {
  animation-duration: 0.2s;
}