/* Intro text effects: unified light/dark styling */
#terminalText,
#scrambleText {
  font-family: var(--font-heading);
  margin: 0;
  word-wrap: break-word;
  letter-spacing: 0.01em;
}

/* Scramble placeholder characters */
#scrambleText .dud {
  display: inline-block;
  color: #38b2ac; /* teal aligned with theme */
  text-shadow: 0 0 8px rgba(56, 178, 172, 0.85),
    0 0 16px rgba(56, 178, 172, 0.6);
  opacity: 0.95;
}

/* Cyan neon terminal text (top layer) */
#terminalText {
  font-size: clamp(1.5em, 10vw, 4em);
  color: #00ffff;
  font-weight: 700;
  text-shadow: 0 0 10px rgba(0, 255, 255, 1), 0 0 20px rgba(0, 255, 255, 0.8),
    0 0 30px rgba(0, 255, 255, 0.6), 0 0 40px rgba(0, 255, 255, 0.4),
    0 0 60px rgba(0, 255, 255, 0.3), 0 0 80px rgba(0, 255, 255, 0.2);
  position: relative;
  filter: brightness(1.2);
  animation: neonPulse 2s ease-in-out infinite alternate;
  min-height: 1.6em;
  display: inline-flex;
  align-items: center;
  gap: 0.2em;
  z-index: 2;
}

#terminalText span:first-child {
  display: inline-block;
  min-width: 0.2em;
}

/* Teal neon scramble (half size) */
#scrambleText {
  font-size: clamp(0.75em, 5vw, 2em); /* half of terminal */
  font-weight: 800;
  color: #38b2ac; /* accent-dark */
  text-shadow: 0 0 10px rgba(56, 178, 172, 1), 0 0 20px rgba(56, 178, 172, 0.9),
    0 0 30px rgba(56, 178, 172, 0.7), 0 0 45px rgba(56, 178, 172, 0.5),
    0 0 65px rgba(56, 178, 172, 0.35), 0 0 90px rgba(56, 178, 172, 0.25);
  filter: brightness(1.15);
  opacity: 0.95;
  animation: neonGlassPulse 2.5s ease-in-out infinite;
  min-height: 1.4em;
}

/* Cursor */
.console-underscore {
  display: inline;
  font-size: 0.9em;
  color: var(--accent, #4fd1c5);
  animation: blink 0.7s steps(1) infinite;
}

@keyframes blink {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0;
  }
}

/* Keep both texts centered but not overlapping */
.intro-text-stack {
  display: grid;
  grid-template-rows: auto auto; /* two rows: scramble then terminal */
  justify-items: center;
  align-items: center;
  row-gap: 0.25em;
  height: clamp(140px, 22vw, 220px); /* prevents vertical jump */
  text-align: center;
  transition: opacity 320ms ease, transform 320ms ease;
  position: relative;
}

.intro-text-stack.is-hiding {
  opacity: 0;
  transform: translateY(12px);
}

.intro-text-stack > #scrambleText {
  grid-row: 1;
}
.intro-text-stack > #terminalText {
  grid-row: 2;
}

/* Animations */
@keyframes neonPulse {
  0% {
    text-shadow: 0 0 10px rgba(0, 255, 255, 1), 0 0 20px rgba(0, 255, 255, 0.8),
      0 0 30px rgba(0, 255, 255, 0.6), 0 0 40px rgba(0, 255, 255, 0.4),
      0 0 60px rgba(0, 255, 255, 0.3), 0 0 80px rgba(0, 255, 255, 0.2);
    filter: brightness(1.2);
    transform: scale(1);
  }
  100% {
    text-shadow: 0 0 15px rgba(0, 255, 255, 1), 0 0 25px rgba(0, 255, 255, 0.9),
      0 0 35px rgba(0, 255, 255, 0.7), 0 0 50px rgba(0, 255, 255, 0.5),
      0 0 70px rgba(0, 255, 255, 0.4), 0 0 100px rgba(0, 255, 255, 0.3);
    filter: brightness(1.4);
    transform: scale(1.02);
  }
}

@keyframes neonGlassPulse {
  0% {
    text-shadow: 0 0 10px rgba(56, 178, 172, 1),
      0 0 20px rgba(56, 178, 172, 0.85), 0 0 30px rgba(56, 178, 172, 0.7),
      0 0 40px rgba(56, 178, 172, 0.5), 0 0 60px rgba(56, 178, 172, 0.35),
      0 0 80px rgba(56, 178, 172, 0.25);
    filter: brightness(1.2);
    transform: scale(1);
  }
  50% {
    text-shadow: 0 0 20px rgba(56, 178, 172, 1),
      0 0 30px rgba(56, 178, 172, 0.95), 0 0 40px rgba(56, 178, 172, 0.75),
      0 0 60px rgba(56, 178, 172, 0.55), 0 0 80px rgba(56, 178, 172, 0.45),
      0 0 120px rgba(56, 178, 172, 0.35);
    filter: brightness(1.4);
    transform: scale(1.05);
  }
  100% {
    text-shadow: 0 0 10px rgba(56, 178, 172, 1),
      0 0 20px rgba(56, 178, 172, 0.85), 0 0 30px rgba(56, 178, 172, 0.7),
      0 0 40px rgba(56, 178, 172, 0.5), 0 0 60px rgba(56, 178, 172, 0.35),
      0 0 80px rgba(56, 178, 172, 0.25);
    filter: brightness(1.2);
    transform: scale(1);
  }
}

/* Mobile adjustments: keep scramble ~half of terminal */
@media (max-width: 600px) {
  #terminalText {
    font-size: clamp(1.2em, 8vw, 2.5em);
  }
  #scrambleText {
    font-size: clamp(0.6em, 4vw, 1.25em);
  }
}

@media (max-width: 426px) {
  #terminalText {
    font-size: clamp(1em, 7vw, 2em);
  }
  #scrambleText {
    font-size: clamp(0.5em, 3.5vw, 1em);
  }
}
