/* ===============================================
   Micro Animations - Enhanced for 2024-2025 UX
   Mobile Optimized with Performance & Accessibility
   Based on Latest Research: Subtle, Purposeful, Engaging
   =============================================== */

/* ========== Base Animation Classes ========== */

/* Enhanced Fade In Animations - Smoother, More Natural */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(30px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes fadeInDown {
  from {
    opacity: 0;
    transform: translateY(-30px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes fadeInLeft {
  from {
    opacity: 0;
    transform: translateX(-30px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateX(0) scale(1);
  }
}

@keyframes fadeInRight {
  from {
    opacity: 0;
    transform: translateX(30px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateX(0) scale(1);
  }
}

@keyframes fadeInScale {
  from {
    opacity: 0;
    transform: scale(0.9);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* Enhanced Text Animations - More Subtle and Professional */
@keyframes textGlow {
  0%, 100% {
    text-shadow: 0 0 8px rgba(79, 70, 229, 0.4);
  }
  50% {
    text-shadow: 0 0 16px rgba(79, 70, 229, 0.7), 0 0 24px rgba(79, 70, 229, 0.5);
  }
}

@keyframes textShimmer {
  0% {
    background-position: -1000px 0;
  }
  100% {
    background-position: 1000px 0;
  }
}

@keyframes letterFloat {
  0%, 100% {
    transform: translateY(0) rotate(0deg);
  }
  50% {
    transform: translateY(-3px) rotate(1deg);
  }
}

/* Refined Pulse & Bounce - Less Aggressive */
@keyframes subtlePulse {
  0%, 100% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(1.02);
    opacity: 0.95;
  }
}

@keyframes gentleBounce {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-8px);
  }
}

@keyframes microShake {
  0%, 100% {
    transform: translateX(0);
  }
  10%, 30%, 50%, 70%, 90% {
    transform: translateX(-1px);
  }
  20%, 40%, 60%, 80% {
    transform: translateX(1px);
  }
}

/* Smooth Rotating Animations */
@keyframes slowRotate {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

@keyframes wobble {
  0%, 100% {
    transform: rotate(0deg);
  }
  25% {
    transform: rotate(2deg);
  }
  75% {
    transform: rotate(-2deg);
  }
}

/* Enhanced Gradient Animations */
@keyframes gradientShift {
  0% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
  100% {
    background-position: 0% 50%;
  }
}

@keyframes borderGlow {
  0%, 100% {
    border-color: rgba(79, 70, 229, 0.4);
    box-shadow: 0 0 8px rgba(79, 70, 229, 0.2);
  }
  50% {
    border-color: rgba(79, 70, 229, 0.8);
    box-shadow: 0 0 16px rgba(79, 70, 229, 0.5);
  }
}

/* ========== Applied Classes ========== */

/* Enhanced entrance animations - Staggered for better UX */
.animate-fade-in-up {
  animation: fadeInUp 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

.animate-fade-in-down {
  animation: fadeInDown 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

.animate-fade-in-left {
  animation: fadeInLeft 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

.animate-fade-in-right {
  animation: fadeInRight 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

.animate-fade-in-scale {
  animation: fadeInScale 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Stagger delays for sequential animations */
.stagger-1 { animation-delay: 0.1s; }
.stagger-2 { animation-delay: 0.2s; }
.stagger-3 { animation-delay: 0.3s; }
.stagger-4 { animation-delay: 0.4s; }
.stagger-5 { animation-delay: 0.5s; }

/* Text effects - More refined */
.text-glow {
  animation: textGlow 4s ease-in-out infinite;
}

.text-shimmer {
  background: linear-gradient(90deg, #333 0%, #666 50%, #333 100%);
  background-size: 200% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: textShimmer 4s linear infinite;
}

.hover-letter-float span {
  display: inline-block;
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.hover-letter-float:hover span {
  animation: letterFloat 0.6s ease infinite;
}

.hover-letter-float span:nth-child(2n) {
  animation-delay: 0.1s;
}

.hover-letter-float span:nth-child(3n) {
  animation-delay: 0.2s;
}

/* Enhanced Interactive hover effects - Subtler feedback */
.hover-pulse:hover {
  animation: subtlePulse 1.5s ease infinite;
}

.hover-bounce:hover {
  animation: gentleBounce 0.6s ease;
}

.hover-shake:hover {
  animation: microShake 0.6s ease;
}

.hover-rotate:hover {
  animation: slowRotate 3s linear infinite;
}

.hover-wobble:hover {
  animation: wobble 0.6s ease;
}

/* Advanced Button micro-interactions - 2024 trends */
.btn-micro {
  position: relative;
  overflow: hidden;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  transform: translateZ(0); /* GPU acceleration */
}

.btn-micro::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  transform: translate(-50%, -50%);
  transition: width 0.5s ease, height 0.5s ease;
}

.btn-micro:hover::before {
  width: 250px;
  height: 250px;
}

.btn-micro:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.btn-micro:active {
  transform: translateY(0);
  transition: all 0.1s ease;
}

/* Enhanced Card animations - More sophisticated */
.card-hover-lift {
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  transform: translateZ(0);
}

.card-hover-lift:hover {
  transform: translateY(-6px) scale(1.01);
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.12);
}

.card-tilt {
  transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  transform-style: preserve-3d;
}

.card-tilt:hover {
  transform: perspective(800px) rotateY(3deg) rotateX(-2deg);
}

/* Smooth underline effect - Refined */
.underline-animation {
  position: relative;
  text-decoration: none;
}

.underline-animation::after {
  content: '';
  position: absolute;
  width: 0;
  height: 2px;
  bottom: -2px;
  left: 50%;
  background: linear-gradient(90deg, #4f46e5, #7c3aed);
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  transform: translateX(-50%);
}

.underline-animation:hover::after {
  width: 100%;
  left: 0;
  transform: translateX(0);
}

/* Loading dots animation */
@keyframes loadingDot {
  0%, 80%, 100% {
    transform: scale(0);
    opacity: 0.5;
  }
  40% {
    transform: scale(1);
    opacity: 1;
  }
}

.loading-dots span {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  animation: loadingDot 1.4s infinite ease-in-out both;
}

.loading-dots span:nth-child(1) {
  animation-delay: -0.32s;
}

.loading-dots span:nth-child(2) {
  animation-delay: -0.16s;
}

/* Skeleton loading effect - Enhanced */
@keyframes skeleton {
  0% {
    background-position: -200px 0;
  }
  100% {
    background-position: calc(200px + 100%) 0;
  }
}

.skeleton-loading {
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200px 100%;
  animation: skeleton 1.8s ease-in-out infinite;
  color: transparent;
  pointer-events: none;
}

.skeleton-loading::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.4), transparent);
  animation: skeleton-shine 1.8s ease-in-out infinite;
}

@keyframes skeleton-shine {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

/* Scroll indicator - Subtle */
@keyframes scrollIndicator {
  0% {
    transform: translateY(0);
    opacity: 0.7;
  }
  100% {
    transform: translateY(12px);
    opacity: 0;
  }
}

.scroll-indicator {
  animation: scrollIndicator 2.5s ease-in-out infinite;
}

/* Number counter animation - Smooth */
@keyframes countUp {
  from {
    opacity: 0;
    transform: translateY(15px) scale(0.9);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.count-up {
  animation: countUp 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Floating elements - Refined */
@keyframes float {
  0%, 100% {
    transform: translateY(0) rotate(0deg);
  }
  50% {
    transform: translateY(-15px) rotate(1deg);
  }
}

.floating {
  animation: float 4s ease-in-out infinite;
}

.floating-delayed {
  animation: float 4s ease-in-out infinite;
  animation-delay: 2s;
}

/* ========== New 2024-2025 Micro-Animation Trends ========== */

/* Scroll-triggered reveal animations */
@keyframes slideInFromBottom {
  from {
    opacity: 0;
    transform: translateY(50px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes slideInFromLeft {
  from {
    opacity: 0;
    transform: translateX(-50px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateX(0) scale(1);
  }
}

@keyframes slideInFromRight {
  from {
    opacity: 0;
    transform: translateX(50px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateX(0) scale(1);
  }
}

.scroll-reveal-bottom {
  opacity: 0;
  transform: translateY(50px) scale(0.95);
  transition: all 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

.scroll-reveal-bottom.revealed {
  animation: slideInFromBottom 0.8s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.scroll-reveal-left {
  opacity: 0;
  transform: translateX(-50px) scale(0.95);
  transition: all 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

.scroll-reveal-left.revealed {
  animation: slideInFromLeft 0.8s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.scroll-reveal-right {
  opacity: 0;
  transform: translateX(50px) scale(0.95);
  transition: all 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

.scroll-reveal-right.revealed {
  animation: slideInFromRight 0.8s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* Fallback: Ensure text is always visible */
/* For users with reduced motion or if JavaScript fails */
@media (prefers-reduced-motion: reduce) {
  .scroll-reveal-bottom,
  .scroll-reveal-left,
  .scroll-reveal-right {
    opacity: 1 !important;
    transform: none !important;
    animation: none !important;
  }
}

/* Additional fallback for no-JS scenarios */
.no-js .scroll-reveal-bottom,
.no-js .scroll-reveal-left,
.no-js .scroll-reveal-right {
  opacity: 1 !important;
  transform: none !important;
  animation: none !important;
}

/* Enhanced button states with micro-feedback */
.btn-primary {
  position: relative;
  overflow: hidden;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-primary::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  transform: translate(-50%, -50%);
  transition: width 0.6s ease, height 0.6s ease;
}

.btn-primary:hover::before {
  width: 300px;
  height: 300px;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

.btn-primary:active {
  transform: translateY(0);
  transition: all 0.1s ease;
}

/* Success/Error state animations */
@keyframes successCheck {
  0% {
    opacity: 0;
    transform: scale(0.3) rotate(45deg);
  }
  50% {
    opacity: 1;
    transform: scale(1.1) rotate(45deg);
  }
  100% {
    opacity: 1;
    transform: scale(1) rotate(45deg);
  }
}

.success-check {
  animation: successCheck 0.6s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

@keyframes errorShake {
  0%, 100% { transform: translateX(0); }
  10%, 30%, 50%, 70%, 90% { transform: translateX(-3px); }
  20%, 40%, 60%, 80% { transform: translateX(3px); }
}

.error-shake {
  animation: errorShake 0.6s ease-in-out;
}

/* Loading spinner - Modern */
@keyframes spinSmooth {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.loading-spinner {
  border: 3px solid rgba(255, 255, 255, 0.1);
  border-top: 3px solid currentColor;
  border-radius: 50%;
  width: 24px;
  height: 24px;
  animation: spinSmooth 1s linear infinite;
}

/* Enhanced form interactions */
.input-focus-glow {
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.input-focus-glow:focus {
  transform: scale(1.01);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.input-success {
  animation: successPulse 0.6s ease-out;
}

@keyframes successPulse {
  0% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.4); }
  70% { box-shadow: 0 0 0 10px rgba(34, 197, 94, 0); }
  100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); }
}

/* Tab switching animations */
@keyframes tabSlide {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.tab-content {
  animation: tabSlide 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Modal/Dialog animations */
@keyframes modalEnter {
  from {
    opacity: 0;
    transform: scale(0.9) translateY(-20px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

@keyframes modalExit {
  from {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
  to {
    opacity: 0;
    transform: scale(0.9) translateY(-20px);
  }
}

.modal-enter {
  animation: modalEnter 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-exit {
  animation: modalExit 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Enhanced tooltip animations */
@keyframes tooltipEnter {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes tooltipExit {
  from {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
  to {
    opacity: 0;
    transform: translateY(8px) scale(0.95);
  }
}

.tooltip-enter {
  animation: tooltipEnter 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.tooltip-exit {
  animation: tooltipExit 0.15s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ========== Mobile Optimizations ========== */

/* Reduce animations on mobile for better performance */
@media (max-width: 768px) {
  /* Simplify animations */
  .animate-fade-in-up,
  .animate-fade-in-down,
  .animate-fade-in-left,
  .animate-fade-in-right {
    animation-duration: 0.4s;
  }
  
  /* Disable complex animations on mobile */
  .card-tilt:hover {
    transform: translateY(-5px);
  }
  
  /* Reduce particle effects */
  .btn-micro::before {
    display: none;
  }
  
  /* Optimize hover effects for touch */
  .hover-pulse:active {
    transform: scale(0.98);
  }
  
  .card-hover-lift:active {
    transform: translateY(-4px) scale(1.01);
  }
}

/* Reduce motion for accessibility */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  
  .floating,
  .floating-delayed,
  .scroll-indicator {
    animation: none;
  }
}

/* Touch device optimizations */
@media (hover: none) {
  .hover-letter-float:active span,
  .hover-pulse:active,
  .hover-bounce:active {
    animation-play-state: running;
  }
}

/* High performance GPU acceleration */
.gpu-accelerated {
  transform: translateZ(0);
  will-change: transform;
  backface-visibility: hidden;
  perspective: 1000px;
}

/* Smooth transitions for all interactive elements */
button,
a,
.card,
.interactive {
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Responsive text animations */
@media (max-width: 640px) {
  .text-glow {
    animation: none;
    text-shadow: 0 0 4px rgba(79, 70, 229, 0.3);
  }
  
  .text-shimmer {
    animation-duration: 5s;
  }
}

/* Performance optimization for battery saving */
@media (prefers-reduced-data: reduce) {
  .skeleton-loading,
  .loading-dots span,
  .loading-spinner {
    animation: none;
  }

  .floating,
  .floating-delayed {
    animation: none;
  }
}

/* Enhanced mobile optimizations - 2024 standards */
@media (max-width: 768px) {
  /* Simplify complex animations */
  .animate-fade-in-up,
  .animate-fade-in-down,
  .animate-fade-in-left,
  .animate-fade-in-right {
    animation-duration: 0.5s;
  }

  /* Reduce motion for card interactions */
  .card-tilt:hover {
    transform: translateY(-3px);
  }

  /* Optimize button effects */
  .btn-micro::before {
    display: none;
  }

  .btn-primary::before {
    width: 200px;
    height: 200px;
  }

  /* Touch-friendly hover states */
  .hover-pulse:active {
    transform: scale(0.98);
  }

  .card-hover-lift:active {
    transform: translateY(-3px) scale(1.005);
  }

  /* Reduce floating animations */
  .floating,
  .floating-delayed {
    animation-duration: 6s;
  }

  /* Simplify scroll reveals */
  .scroll-reveal-bottom,
  .scroll-reveal-left,
  .scroll-reveal-right {
    opacity: 0;
    transform: translateY(20px);
  }

  .scroll-reveal-bottom.revealed,
  .scroll-reveal-left.revealed,
  .scroll-reveal-right.revealed {
    animation-duration: 0.6s;
  }
}

/* Respect reduced motion preferences - Enhanced accessibility */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .floating,
  .floating-delayed,
  .scroll-indicator,
  .text-glow,
  .text-shimmer {
    animation: none !important;
  }

  .card-tilt,
  .card-hover-lift {
    transition: none !important;
  }

  .scroll-reveal-bottom,
  .scroll-reveal-left,
  .scroll-reveal-right {
    opacity: 1 !important;
    transform: none !important;
  }
}

/* Touch device optimizations - Better mobile UX */
@media (hover: none) and (pointer: coarse) {
  .hover-letter-float:active span,
  .hover-pulse:active,
  .hover-bounce:active,
  .hover-shake:active {
    animation-play-state: running;
  }

  /* Add touch feedback */
  .card-hover-lift:active {
    transform: scale(0.98);
    transition: transform 0.1s ease;
  }

  .btn-primary:active {
    transform: scale(0.95);
  }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  .text-glow {
    text-shadow: 0 0 2px currentColor;
  }

  .borderGlow {
    border-color: currentColor;
    box-shadow: 0 0 4px currentColor;
  }
}

/* Responsive text animations - Optimized */
@media (max-width: 640px) {
  .text-glow {
    animation: none;
    text-shadow: 0 0 4px rgba(79, 70, 229, 0.3);
  }

  .text-shimmer {
    animation-duration: 6s;
  }

  /* Reduce stagger delays on mobile */
  .stagger-1 { animation-delay: 0.05s; }
  .stagger-2 { animation-delay: 0.1s; }
  .stagger-3 { animation-delay: 0.15s; }
  .stagger-4 { animation-delay: 0.2s; }
  .stagger-5 { animation-delay: 0.25s; }
}