/* ==========================================================================
   Animations & Effects
   ========================================================================== */

/* Typewriter Utilities */
.typewriter {
  overflow: hidden;
  border-right: .15em solid var(--accent-primary);
  white-space: nowrap;
  margin: 0 auto;
  letter-spacing: .15em;
  animation: typing 2.5s steps(40, end), blink-caret .75s step-end infinite;
}

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

@keyframes blink-caret {
  from, to { border-color: transparent }
  50% { border-color: var(--accent-primary) }
}

.type-wrap { display: inline-block; }

/* Scroll Reveal Classes (Hooked with IntersectionObserver) */
.reveal {
  opacity: 0;
  transition: all 0.8s cubic-bezier(0.5, 0, 0, 1);
  will-change: transform, opacity;
}

.reveal.active {
  opacity: 1;
  transform: none;
}

.reveal-up { transform: translateY(50px); }
.reveal-down { transform: translateY(-50px); }
.reveal-left { transform: translateX(-50px); }
.reveal-right { transform: translateX(50px); }
.reveal-fade { transform: scale(0.95); }

/* Delay Utilities */
.delay-100 { transition-delay: 100ms; }
.delay-200 { transition-delay: 200ms; }
.delay-300 { transition-delay: 300ms; }
.delay-400 { transition-delay: 400ms; }
.delay-500 { transition-delay: 500ms; }

/* Continuous Background Animations */
.bg-animated-grid {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background-image: 
    linear-gradient(rgba(0, 170, 255, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 170, 255, 0.05) 1px, transparent 1px);
  background-size: 50px 50px;
  background-position: center center;
  z-index: 0;
  opacity: 0.5;
  animation: moveGrid 20s linear infinite;
  pointer-events: none;
}

[data-theme="light"] .bg-animated-grid {
  background-image: 
    linear-gradient(rgba(0, 136, 255, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 136, 255, 0.03) 1px, transparent 1px);
}

@keyframes moveGrid {
  0% { transform: translateY(0); }
  100% { transform: translateY(50px); }
}

.bg-glow-blob {
  position: absolute;
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, rgba(0, 170, 255, 0.15) 0%, rgba(0,0,0,0) 70%);
  border-radius: 50%;
  filter: blur(40px);
  z-index: 0;
  pointer-events: none;
  animation: floatOrb 10s ease-in-out infinite alternate;
}

[data-theme="light"] .bg-glow-blob {
  background: radial-gradient(circle, rgba(0, 136, 255, 0.1) 0%, rgba(255,255,255,0) 70%);
}

@keyframes floatOrb {
  0% { transform: translate(0, 0) scale(1); }
  33% { transform: translate(30px, -50px) scale(1.1); }
  66% { transform: translate(-20px, 20px) scale(0.9); }
  100% { transform: translate(0, 0) scale(1); }
}

/* Scanline Effect */
.scanlines {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: linear-gradient(
    to bottom,
    rgba(255,255,255,0),
    rgba(255,255,255,0) 50%,
    rgba(0,0,0,0.05) 50%,
    rgba(0,0,0,0.05)
  );
  background-size: 100% 4px;
  z-index: 9999;
  pointer-events: none;
  opacity: 0.3;
}

/* Float Animation */
.anim-float {
  animation: floating 3s ease-in-out infinite;
}

@keyframes floating {
  0% { transform: translateY(0px); }
  50% { transform: translateY(-10px); }
  100% { transform: translateY(0px); }
}

/* Pulse Glow */
.anim-pulse {
  animation: pulsing 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

@keyframes pulsing {
  0%, 100% { opacity: 1; transform: scale(1); box-shadow: 0 0 10px rgba(0,170,255,0.4); }
  50% { opacity: .7; transform: scale(1.05); box-shadow: 0 0 25px rgba(0,170,255,0.8); }
}

/* Page Transition overlay */
.page-transition {
  position: fixed;
  top: 0; left: 0;
  width: 100vw; height: 100vh;
  background: var(--bg-primary);
  z-index: 99999;
  pointer-events: none;
  display: flex;
  justify-content: center;
  align-items: center;
  transition: opacity 0.5s ease-out;
}

.page-transition.fade-out {
  opacity: 0;
}

.loader-line {
  width: 200px;
  height: 2px;
  background: rgba(0, 170, 255, 0.2);
  position: relative;
  overflow: hidden;
}

.loader-line::after {
  content: '';
  position: absolute;
  top: 0; left: 0;
  height: 100%; width: 50%;
  background: var(--accent-primary);
  animation: loadingLine 1s ease-in-out infinite;
}

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