/* Animation Keyframes */

/* Float Animation for Background Elements */
@keyframes float {
  0%, 100% {
    transform: translateY(0px) rotate(0deg);
  }
  33% {
    transform: translateY(-10px) rotate(1deg);
  }
  66% {
    transform: translateY(-5px) rotate(-1deg);
  }
}

/* Pulse Animation for Avatar Ring */
@keyframes pulse {
  0%, 100% {
    opacity: 0.3;
    transform: scale(1);
  }
  50% {
    opacity: 0.8;
    transform: scale(1.05);
  }
}

/* Shimmer Animation for Loading Effects */
@keyframes shimmer {
  0% {
    background-position: -200px 0;
  }
  100% {
    background-position: calc(200px + 100%) 0;
  }
}

/* Bounce Animation for Success States */
@keyframes bounce {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-5px);
  }
}

/* Scale In Animation for Elements */
@keyframes scaleIn {
  0% {
    opacity: 0;
    transform: scale(0.8);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

/* Slide In From Bottom */
@keyframes slideInFromBottom {
  0% {
    opacity: 0;
    transform: translateY(30px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Slide In From Left */
@keyframes slideInFromLeft {
  0% {
    opacity: 0;
    transform: translateX(-30px);
  }
  100% {
    opacity: 1;
    transform: translateX(0);
  }
}

/* Slide In From Right */
@keyframes slideInFromRight {
  0% {
    opacity: 0;
    transform: translateX(30px);
  }
  100% {
    opacity: 1;
    transform: translateX(0);
  }
}

/* Fade In Animation */
@keyframes fadeIn {
  0% {
    opacity: 0;
  }
  100% {
    opacity: 1;
  }
}

/* Glow Animation */
@keyframes glow {
  0%, 100% {
    box-shadow: 0 0 10px var(--primary-color)30;
  }
  50% {
    box-shadow: 0 0 30px var(--primary-color)60, 0 0 40px var(--primary-color)30;
  }
}

/* Confetti Animation */
@keyframes confetti-fall {
  0% {
    transform: translateY(-100vh) rotate(0deg);
    opacity: 1;
  }
  100% {
    transform: translateY(100vh) rotate(360deg);
    opacity: 0;
  }
}

/* Celebration Spark Animation */
@keyframes celebrationSpark {
  0% {
    transform: scale(0) rotate(0deg);
    opacity: 1;
  }
  50% {
    transform: scale(1) rotate(180deg);
    opacity: 0.8;
  }
  100% {
    transform: scale(0) rotate(360deg);
    opacity: 0;
  }
}

/* Progressive Enhancement Animation */
@keyframes enhanceUnlock {
  0% {
    filter: saturate(0.7) brightness(0.9);
    transform: scale(0.98);
  }
  100% {
    filter: saturate(1) brightness(1);
    transform: scale(1);
  }
}

/* Typewriter Animation */
@keyframes typewriter {
  0% {
    width: 0;
  }
  100% {
    width: 100%;
  }
}

/* Heart Beat Animation */
@keyframes heartBeat {
  0%, 100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.1);
  }
}

/* Animation Classes */

/* Page Load Animations */
.animate-page-load {
  animation: fadeIn 0.8s ease-out forwards;
}

.animate-slide-in-bottom {
  opacity: 0;
  animation: slideInFromBottom 0.6s ease-out forwards;
}

.animate-slide-in-left {
  opacity: 0;
  animation: slideInFromLeft 0.6s ease-out forwards;
}

.animate-slide-in-right {
  opacity: 0;
  animation: slideInFromRight 0.6s ease-out forwards;
}

.animate-scale-in {
  opacity: 0;
  animation: scaleIn 0.5s ease-out forwards;
}

/* Stagger Animation Delays */
.animate-delay-100 { animation-delay: 0.1s; }
.animate-delay-200 { animation-delay: 0.2s; }
.animate-delay-300 { animation-delay: 0.3s; }
.animate-delay-400 { animation-delay: 0.4s; }
.animate-delay-500 { animation-delay: 0.5s; }
.animate-delay-600 { animation-delay: 0.6s; }
.animate-delay-700 { animation-delay: 0.7s; }
.animate-delay-800 { animation-delay: 0.8s; }

/* Hover Animations */
.animate-hover-bounce:hover {
  animation: bounce 0.5s ease infinite;
}

.animate-hover-glow:hover {
  animation: glow 1s ease infinite;
}

.animate-hover-pulse:hover {
  animation: pulse 1s ease infinite;
}

/* Success and Celebration Animations */
.animate-success-bounce {
  animation: bounce 0.6s ease;
}

.animate-celebration {
  animation: heartBeat 0.6s ease;
}

/* Loading Animation */
.loading-shimmer {
  background: linear-gradient(90deg, 
    var(--bg-tertiary) 0%, 
    var(--border-color) 50%, 
    var(--bg-tertiary) 100%);
  background-size: 200px 100%;
  animation: shimmer 1.5s infinite;
}

/* Progressive Enhancement Animation */
.animate-enhance {
  animation: enhanceUnlock 1s ease-out forwards;
}

/* Confetti Animation Classes */
.confetti {
  position: absolute;
  width: 10px;
  height: 10px;
  animation: confetti-fall 2s linear forwards;
}

.confetti.square {
  background: var(--primary-color);
}

.confetti.circle {
  background: var(--secondary-color);
  border-radius: 50%;
}

.confetti.triangle {
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-bottom: 10px solid var(--accent-color);
  background: none;
}

/* Celebration Spark Animation */
.celebration-spark {
  position: absolute;
  width: 6px;
  height: 6px;
  background: var(--primary-color);
  border-radius: 50%;
  animation: celebrationSpark 0.8s ease-out forwards;
}

/* Social Card Follow Animation */
.social-card.following {
  animation: heartBeat 0.6s ease;
}

.social-card.following .avatar {
  animation: pulse 0.8s ease;
}

/* Download Button Enhancement Animation */
.download-btn.enhancing {
  animation: glow 0.8s ease;
  position: relative;
  overflow: hidden;
}

.download-btn.enhancing::after {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
  animation: shimmer 0.8s ease;
}

/* Workflow Section Enhancement */
.workflow-section.enhancing {
  animation: enhanceUnlock 1.2s ease-out forwards;
}

/* Progress Bar Animation */
.progress-bar.animating {
  transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Theme Transition Animation */
body.theme-transitioning * {
  transition: background-color 0.3s ease, 
              color 0.3s ease, 
              border-color 0.3s ease, 
              box-shadow 0.3s ease !important;
}

/* Rainbow Border Animation Classes */

/* SVG Rainbow Stroke Animation */
.rainbow-stroke-svg {
  stroke-width: 3;
  fill: none;
  stroke: url(#rainbowGradient);
  stroke-dasharray: 100%;
  animation: rainbowStroke 3s ease-in-out infinite;
}

/* CSS Rainbow Border for Regular Elements */
.rainbow-border {
  position: relative;
  background: var(--bg-primary);
  border-radius: 12px;
  overflow: hidden;
}

.rainbow-border::before {
  content: '';
  position: absolute;
  top: -2px;
  left: -2px;
  right: -2px;
  bottom: -2px;
  background: linear-gradient(
    45deg,
    #ff0000, #ff7700, #ffdd00, #88ff00,
    #00ff88, #00ddff, #0077ff, #3300ff,
    #8800ff, #ff00dd, #ff0077, #ff0000
  );
  background-size: 400% 400%;
  border-radius: inherit;
  z-index: -1;
  animation: flowingRainbow 4s ease-in-out infinite;
}

.rainbow-border::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  right: 2px;
  bottom: 2px;
  background: var(--bg-primary);
  border-radius: inherit;
  z-index: -1;
}

/* Rainbow Border for Circular Elements (like avatars) */
.rainbow-border-circle {
  position: relative;
  border-radius: 50% !important;
}

.rainbow-border-circle::before {
  border-radius: 50% !important;
}

.rainbow-border-circle::after {
  border-radius: 50% !important;
}

/* Slower Rainbow Animation Variant */
.rainbow-border-slow::before {
  animation: flowingRainbow 8s ease-in-out infinite;
}

/* Hover Activated Rainbow Border */
.rainbow-border-hover:hover::before {
  animation: flowingRainbow 2s ease-in-out infinite;
}

/* Rainbow Text Effect */
.rainbow-text {
  background: linear-gradient(
    45deg,
    #ff0000, #ff7700, #ffdd00, #88ff00,
    #00ff88, #00ddff, #0077ff, #3300ff,
    #8800ff, #ff00dd, #ff0077, #ff0000
  );
  background-size: 400% 400%;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: flowingRainbow 4s ease-in-out infinite;
}

/* Scroll Reveal Animations */
.reveal {
  opacity: 0;
  transform: translateY(30px);
  transition: all 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.reveal.active {
  opacity: 1;
  transform: translateY(0);
}

/* Mobile-Specific Animations */
@media (max-width: 768px) {
  /* Reduce animation intensity on mobile for better performance */
  .animate-slide-in-bottom,
  .animate-slide-in-left,
  .animate-slide-in-right {
    animation-duration: 0.4s;
  }
  
  /* Disable complex animations on mobile */
  .animate-hover-glow:hover,
  .animate-hover-bounce:hover {
    animation: none;
  }
  
  /* Disable rainbow animations on mobile for performance */
  .rainbow-border,
  .rainbow-stroke-svg {
    animation: none !important;
  }
  
  /* Simplified confetti for mobile */
  .confetti {
    animation-duration: 1.5s;
  }
}

/* Rainbow Border Stroke Animation */
@keyframes rainbowStroke {
  0% {
    stroke-dashoffset: 100%;
    filter: hue-rotate(0deg);
  }
  50% {
    stroke-dashoffset: 0%;
    filter: hue-rotate(180deg);
  }
  100% {
    stroke-dashoffset: -100%;
    filter: hue-rotate(360deg);
  }
}

/* Rainbow Border CSS Animation (for non-SVG elements) */
@keyframes rainbowBorder {
  0% {
    background-position: 0% 50%;
    filter: hue-rotate(0deg);
  }
  50% {
    background-position: 100% 50%;
    filter: hue-rotate(180deg);
  }
  100% {
    background-position: 0% 50%;
    filter: hue-rotate(360deg);
  }
}

/* Flowing Rainbow Animation */
@keyframes flowingRainbow {
  0% {
    background-position: 0% 0%;
    filter: hue-rotate(0deg) brightness(1.2);
  }
  25% {
    background-position: 100% 0%;
    filter: hue-rotate(90deg) brightness(1.3);
  }
  50% {
    background-position: 100% 100%;
    filter: hue-rotate(180deg) brightness(1.2);
  }
  75% {
    background-position: 0% 100%;
    filter: hue-rotate(270deg) brightness(1.3);
  }
  100% {
    background-position: 0% 0%;
    filter: hue-rotate(360deg) brightness(1.2);
  }
}

/* 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;
  }
  
  .animate-page-load,
  .animate-slide-in-bottom,
  .animate-slide-in-left,
  .animate-slide-in-right,
  .animate-scale-in,
  .loading-shimmer,
  .confetti,
  .celebration-spark {
    animation: none !important;
    opacity: 1 !important;
    transform: none !important;
  }
}