/* ==========================================================================
   Advanced Animations - Text Effects & Page Transitions
   ========================================================================== */

/* ====================
   TEXT ANIMATIONS
   ==================== */

/* Typing Effect */
.typing-effect {
  overflow: hidden;
  border-right: 3px solid var(--primary-color);
  white-space: nowrap;
  animation: typing 3.5s steps(40, end), blink-caret 0.75s step-end infinite;
  display: inline-block;
}

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

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

/* Glitch Text Effect */
.glitch-text {
  position: relative;
  animation: glitch 1s linear infinite;
}

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

.glitch-text::before {
  left: 2px;
  text-shadow: -2px 0 #00a8ff;
  clip: rect(44px, 450px, 56px, 0);
  animation: glitch-anim 5s infinite linear alternate-reverse;
}

.glitch-text::after {
  left: -2px;
  text-shadow: -2px 0 #0047ab;
  clip: rect(44px, 450px, 56px, 0);
  animation: glitch-anim2 5s infinite linear alternate-reverse;
}

@keyframes glitch-anim {
  0% { clip: rect(10px, 9999px, 94px, 0); }
  20% { clip: rect(85px, 9999px, 140px, 0); }
  40% { clip: rect(47px, 9999px, 34px, 0); }
  60% { clip: rect(131px, 9999px, 74px, 0); }
  80% { clip: rect(61px, 9999px, 116px, 0); }
  100% { clip: rect(94px, 9999px, 24px, 0); }
}

@keyframes glitch-anim2 {
  0% { clip: rect(65px, 9999px, 119px, 0); }
  20% { clip: rect(36px, 9999px, 95px, 0); }
  40% { clip: rect(125px, 9999px, 32px, 0); }
  60% { clip: rect(78px, 9999px, 153px, 0); }
  80% { clip: rect(42px, 9999px, 98px, 0); }
  100% { clip: rect(107px, 9999px, 67px, 0); }
}

/* Text Reveal Animation */
.text-reveal {
  position: relative;
  overflow: hidden;
}

.text-reveal::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--primary-color);
  transform: translateX(-100%);
  animation: reveal 1.5s ease-in-out forwards;
}

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

/* Word-by-Word Animation */
.animate-words span {
  display: inline-block;
  opacity: 0;
  animation: fadeInWord 0.5s ease-out forwards;
}

.animate-words span:nth-child(1) { animation-delay: 0.1s; }
.animate-words span:nth-child(2) { animation-delay: 0.2s; }
.animate-words span:nth-child(3) { animation-delay: 0.3s; }
.animate-words span:nth-child(4) { animation-delay: 0.4s; }
.animate-words span:nth-child(5) { animation-delay: 0.5s; }
.animate-words span:nth-child(6) { animation-delay: 0.6s; }
.animate-words span:nth-child(7) { animation-delay: 0.7s; }
.animate-words span:nth-child(8) { animation-delay: 0.8s; }
.animate-words span:nth-child(9) { animation-delay: 0.9s; }
.animate-words span:nth-child(10) { animation-delay: 1s; }

@keyframes fadeInWord {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Gradient Text Animation */
.gradient-text-animated {
  background: linear-gradient(
    45deg,
    var(--primary-color),
    var(--secondary-color),
    var(--accent-color),
    var(--primary-light)
  );
  background-size: 300% 300%;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: gradientShift 4s ease infinite;
}

@keyframes gradientShift {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

/* Neon Text Effect */
.neon-text {
  color: #fff;
  text-shadow:
    0 0 7px var(--accent-color),
    0 0 10px var(--accent-color),
    0 0 21px var(--accent-color),
    0 0 42px var(--primary-color),
    0 0 82px var(--primary-color),
    0 0 92px var(--primary-color),
    0 0 102px var(--primary-color),
    0 0 151px var(--primary-color);
  animation: neonFlicker 1.5s infinite alternate;
}

@keyframes neonFlicker {
  0%, 19%, 21%, 23%, 25%, 54%, 56%, 100% {
    text-shadow:
      0 0 7px var(--accent-color),
      0 0 10px var(--accent-color),
      0 0 21px var(--accent-color),
      0 0 42px var(--primary-color),
      0 0 82px var(--primary-color),
      0 0 92px var(--primary-color),
      0 0 102px var(--primary-color),
      0 0 151px var(--primary-color);
  }
  20%, 24%, 55% {
    text-shadow: none;
  }
}

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

@keyframes float {
  0%, 100% {
    transform: translateY(0px);
  }
  50% {
    transform: translateY(-20px);
  }
}

/* Wobble Effect */
.wobble {
  animation: wobble 0.5s ease-in-out;
}

@keyframes wobble {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-10px) rotate(-5deg); }
  75% { transform: translateX(10px) rotate(5deg); }
}

/* ====================
   PAGE TRANSITIONS
   ==================== */

/* Page Load Animation */
.page-transition {
  animation: pageSlideIn 0.8s ease-out;
}

@keyframes pageSlideIn {
  from {
    opacity: 0;
    transform: translateY(50px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Fade Transition */
.fade-transition {
  animation: fadeTransition 0.5s ease-in-out;
}

@keyframes fadeTransition {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Slide Up Page Transition */
.slide-up-transition {
  animation: slideUpPage 0.6s ease-out;
}

@keyframes slideUpPage {
  from {
    opacity: 0;
    transform: translateY(100vh);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ====================
   SECTION ANIMATIONS
   ==================== */

/* Zoom In on Scroll */
.zoom-in-scroll {
  transform: scale(0.8);
  opacity: 0;
  transition: all 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.zoom-in-scroll.animated {
  transform: scale(1);
  opacity: 1;
}

/* Slide and Fade */
.slide-fade {
  opacity: 0;
  transform: translateX(-50px);
  transition: all 0.7s ease-out;
}

.slide-fade.animated {
  opacity: 1;
  transform: translateX(0);
}

/* Rotate and Scale */
.rotate-scale {
  opacity: 0;
  transform: rotate(180deg) scale(0.5);
  transition: all 0.8s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.rotate-scale.animated {
  opacity: 1;
  transform: rotate(0) scale(1);
}

/* Flip In */
.flip-in {
  opacity: 0;
  transform: perspective(600px) rotateX(-90deg);
  transition: all 0.6s ease-out;
}

.flip-in.animated {
  opacity: 1;
  transform: perspective(600px) rotateX(0);
}

/* ====================
   HOVER ANIMATIONS
   ==================== */

/* Glow on Hover */
.hover-glow {
  transition: all 0.3s ease;
}

.hover-glow:hover {
  box-shadow: 0 0 20px var(--primary-color),
              0 0 40px var(--primary-color),
              0 0 60px var(--primary-color);
  transform: scale(1.05);
}

/* Lift on Hover */
.hover-lift {
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.hover-lift:hover {
  transform: translateY(-10px);
  box-shadow: 0 15px 35px rgba(0, 71, 171, 0.4);
}

/* Tilt on Hover */
.hover-tilt {
  transition: transform 0.3s ease;
}

.hover-tilt:hover {
  transform: perspective(1000px) rotateX(5deg) rotateY(5deg);
}

/* ====================
   LOADING ANIMATIONS
   ==================== */

/* Skeleton Loading */
.skeleton-loading {
  background: linear-gradient(
    90deg,
    var(--background-card) 25%,
    var(--background-light) 50%,
    var(--background-card) 75%
  );
  background-size: 200% 100%;
  animation: skeletonLoading 1.5s ease-in-out infinite;
  border-radius: 0;
}

@keyframes skeletonLoading {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Spinner */
.spinner {
  width: 50px;
  height: 50px;
  border: 4px solid var(--border-color);
  border-top-color: var(--primary-color);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Dots Loading */
.dots-loading span {
  display: inline-block;
  width: 10px;
  height: 10px;
  margin: 0 3px;
  background: var(--primary-color);
  border-radius: 50%;
  animation: dotsLoading 1.4s infinite ease-in-out both;
}

.dots-loading span:nth-child(1) { animation-delay: -0.32s; }
.dots-loading span:nth-child(2) { animation-delay: -0.16s; }

@keyframes dotsLoading {
  0%, 80%, 100% {
    transform: scale(0);
    opacity: 0.5;
  }
  40% {
    transform: scale(1);
    opacity: 1;
  }
}

/* ====================
   PARALLAX EFFECT
   ==================== */

.parallax-slow {
  transform: translateY(0);
  transition: transform 0.5s cubic-bezier(0, 0, 0, 1);
}

.parallax-medium {
  transform: translateY(0);
  transition: transform 0.3s cubic-bezier(0, 0, 0, 1);
}

.parallax-fast {
  transform: translateY(0);
  transition: transform 0.1s cubic-bezier(0, 0, 0, 1);
}

/* ====================
   UTILITY ANIMATIONS
   ==================== */

/* Attention Seeker */
.attention-shake {
  animation: shake 0.5s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}

@keyframes shake {
  10%, 90% { transform: translate3d(-1px, 0, 0); }
  20%, 80% { transform: translate3d(2px, 0, 0); }
  30%, 50%, 70% { transform: translate3d(-4px, 0, 0); }
  40%, 60% { transform: translate3d(4px, 0, 0); }
}

/* Heartbeat */
.heartbeat {
  animation: heartbeat 1.5s ease-in-out infinite;
}

@keyframes heartbeat {
  0%, 100% { transform: scale(1); }
  10%, 30% { transform: scale(0.9); }
  20%, 40% { transform: scale(1.1); }
}

/* Swing */
.swing {
  transform-origin: top center;
  animation: swing 2s ease-in-out infinite;
}

@keyframes swing {
  20% { transform: rotate(15deg); }
  40% { transform: rotate(-10deg); }
  60% { transform: rotate(5deg); }
  80% { transform: rotate(-5deg); }
  100% { transform: rotate(0deg); }
}

/* ====================
   RESPONSIVE ADJUSTMENTS
   ==================== */

@media (max-width: 768px) {
  /* Reduce animation intensity on mobile */
  .animate-on-scroll:nth-child(n) {
    transition-delay: 0s !important;
  }

  .typing-effect {
    animation-duration: 2s;
  }

  .float-animation {
    animation-duration: 2s;
  }

  /* Disable complex animations on mobile for performance */
  .glitch-text::before,
  .glitch-text::after {
    display: none;
  }

  .neon-text {
    text-shadow:
      0 0 7px var(--accent-color),
      0 0 10px var(--accent-color);
    animation: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  /* Respect user preference for reduced motion */
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
