/* animations.css - Animation definitions for QuickPlate marketing site */

/* ===========================
   Animation Variables
   =========================== */
:root {
  --ease-spring-snappy: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-spring-natural: cubic-bezier(0.22, 1.2, 0.36, 1);
  --ease-spring-soft: cubic-bezier(0.25, 1, 0.5, 1);
  --ease-bounce: cubic-bezier(0.68, -0.55, 0.265, 1.55);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
}

/* ===========================
   Scroll-Triggered Animations
   =========================== */

/* Base animate on scroll */
.animate-on-scroll {
  opacity: 0;
  transform: translateY(40px);
  transition: opacity 0.6s var(--ease-out),
              transform 0.6s var(--ease-spring-natural);
}

.animate-on-scroll.visible {
  opacity: 1;
  transform: translateY(0);
}

/* Pop scale animation */
.pop-scale {
  opacity: 0;
  transform: scale(0.85);
  transition: opacity 0.6s var(--ease-out),
              transform 0.6s var(--ease-spring-snappy);
}

.pop-scale.visible {
  opacity: 1;
  transform: scale(1);
}

/* Slide from left */
.pop-left {
  opacity: 0;
  transform: translateX(-60px);
  transition: opacity 0.6s var(--ease-out),
              transform 0.6s var(--ease-spring-natural);
}

.pop-left.visible {
  opacity: 1;
  transform: translateX(0);
}

/* Slide from right */
.pop-right {
  opacity: 0;
  transform: translateX(60px);
  transition: opacity 0.6s var(--ease-out),
              transform 0.6s var(--ease-spring-natural);
}

.pop-right.visible {
  opacity: 1;
  transform: translateX(0);
}

/* Rotate in */
.pop-rotate {
  opacity: 0;
  transform: rotate(-10deg) scale(0.9);
  transition: opacity 0.6s var(--ease-out),
              transform 0.6s var(--ease-spring-snappy);
}

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

/* Staggered children delays */
.stagger-children > *:nth-child(1) { transition-delay: 0ms; }
.stagger-children > *:nth-child(2) { transition-delay: 100ms; }
.stagger-children > *:nth-child(3) { transition-delay: 200ms; }
.stagger-children > *:nth-child(4) { transition-delay: 300ms; }
.stagger-children > *:nth-child(5) { transition-delay: 400ms; }
.stagger-children > *:nth-child(6) { transition-delay: 500ms; }

/* ===========================
   Sparkle Effects
   =========================== */

.sparkle {
  position: absolute;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  pointer-events: none;
  /* Animation applied via sparkle--up or sparkle--down classes */
}

.sparkle--star {
  clip-path: polygon(50% 0%, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
  width: 12px;
  height: 12px;
  border-radius: 0;
}

.sparkle--diamond {
  clip-path: polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%);
  width: 10px;
  height: 10px;
  border-radius: 0;
}

/* Default sparkle animation (upward) */
@keyframes sparkle-float-up {
  0% {
    opacity: 1;
    transform: translateY(0) scale(1) rotate(0deg);
  }
  50% {
    opacity: 0.8;
  }
  100% {
    opacity: 0;
    transform: translateY(-120px) scale(0.4) rotate(180deg);
  }
}

/* Downward sparkle animation */
@keyframes sparkle-float-down {
  0% {
    opacity: 1;
    transform: translateY(0) scale(1) rotate(0deg);
  }
  50% {
    opacity: 0.8;
  }
  100% {
    opacity: 0;
    transform: translateY(120px) scale(0.4) rotate(-180deg);
  }
}

/* Direction-based sparkle classes */
.sparkle--up {
  animation: sparkle-float-up 2s ease-out forwards;
}

.sparkle--down {
  animation: sparkle-float-down 2s ease-out forwards;
}

/* ===========================
   Continuous Ambient Animations
   =========================== */

/* Floating animation */
@keyframes float {
  0%, 100% { transform: translateY(0px); }
  50% { transform: translateY(-12px); }
}

.float {
  animation: float 4s ease-in-out infinite;
}

/* Pulse glow for CTA buttons */
@keyframes pulse-glow {
  0%, 100% {
    box-shadow: 0 4px 14px rgba(139, 92, 246, 0.4),
                0 0 20px rgba(139, 92, 246, 0.2);
  }
  50% {
    box-shadow: 0 4px 20px rgba(139, 92, 246, 0.6),
                0 0 40px rgba(139, 92, 246, 0.4);
  }
}

.pulse-glow {
  animation: pulse-glow 2.5s ease-in-out infinite;
}

/* Scroll indicator bounce - subtle animation */
@keyframes bounce-down {
  0%, 100% { transform: rotate(45deg) translateY(0); }
  50% { transform: rotate(45deg) translateY(4px); }
}

.scroll-arrow {
  animation: bounce-down 2.5s ease-in-out infinite;
}

/* Waveform animation for voice feature */
@keyframes waveform {
  0%, 100% { height: 12px; }
  50% { height: 32px; }
}

.waveform-bar {
  animation: waveform 0.5s ease-in-out infinite;
}

.waveform-bar:nth-child(1) { animation-delay: 0ms; }
.waveform-bar:nth-child(2) { animation-delay: 100ms; }
.waveform-bar:nth-child(3) { animation-delay: 200ms; }
.waveform-bar:nth-child(4) { animation-delay: 100ms; }
.waveform-bar:nth-child(5) { animation-delay: 0ms; }

/* Macro bar animations in feature icon */
@keyframes macro-grow {
  0%, 100% { transform: scaleX(0.7); }
  50% { transform: scaleX(1); }
}

.feature-icon--insights .macro-bar {
  animation: macro-grow 2s ease-in-out infinite;
  transform-origin: left center;
}

.feature-icon--insights .macro-bar--protein { animation-delay: 0ms; }
.feature-icon--insights .macro-bar--carbs { animation-delay: 150ms; }
.feature-icon--insights .macro-bar--fats { animation-delay: 300ms; }

/* CTA glow rotation */
@keyframes rotate-glow {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.cta-glow {
  animation: rotate-glow 15s linear infinite;
}

/* ===========================
   Progress Bar Fill Animation
   =========================== */

/* Progress bars animate when visible */
.visible .animated-fill[data-width="65"] {
  width: 65%;
}

.visible .animated-fill[data-width="72"] {
  width: 72%;
}

.visible .animated-fill[data-width="58"] {
  width: 58%;
}

.visible .animated-fill[data-width="45"] {
  width: 45%;
}

/* ===========================
   Hover Animations
   =========================== */

/* Icon bounce on hover */
.feature-icon:hover {
  animation: icon-bounce 0.5s var(--ease-spring-snappy);
}

@keyframes icon-bounce {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.1); }
}

/* Card subtle tilt on hover */
.feature-card {
  transition: transform 0.4s var(--ease-spring-natural),
              box-shadow 0.3s ease;
}

.feature-card:hover {
  transform: translateY(-8px) rotateX(2deg);
}

/* Food card slide on hover */
.food-card-mini {
  transition: transform 0.3s var(--ease-spring-snappy),
              box-shadow 0.3s ease;
}

.food-card-mini:hover {
  transform: translateX(8px);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.12);
}

/* Testimonial card lift */
.testimonial-card {
  transition: transform 0.4s var(--ease-spring-natural),
              box-shadow 0.3s ease;
}

.testimonial-card:hover {
  transform: translateY(-6px);
  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.1);
}

/* Nav link underline effect */
.nav-links a:not(.btn) {
  position: relative;
}

.nav-links a:not(.btn)::after {
  content: '';
  position: absolute;
  bottom: -4px;
  left: 0;
  width: 0;
  height: 2px;
  background: var(--primary);
  transition: width 0.3s var(--ease-spring-snappy);
}

.nav-links a:not(.btn):hover::after {
  width: 100%;
}

/* Store button press effect */
.store-button:active {
  transform: scale(0.95);
}

/* ===========================
   Phone Mockup Animations
   =========================== */

/* Subtle phone float */
.hero-phone .phone-frame {
  animation: phone-float 6s ease-in-out infinite;
}

@keyframes phone-float {
  0%, 100% { transform: translateY(0) rotateY(0deg); }
  25% { transform: translateY(-8px) rotateY(2deg); }
  50% { transform: translateY(-4px) rotateY(0deg); }
  75% { transform: translateY(-10px) rotateY(-2deg); }
}

/* Mock progress bar animation */
.mock-cal-fill {
  animation: mock-progress 3s ease-in-out infinite;
}

@keyframes mock-progress {
  0%, 100% { width: 60%; }
  50% { width: 68%; }
}

.mock-macro-bar {
  animation: mock-macro 2.5s ease-in-out infinite;
}

.mock-macro-protein { animation-delay: 0ms; }
.mock-macro-carbs { animation-delay: 200ms; }
.mock-macro-fats { animation-delay: 400ms; }

@keyframes mock-macro {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

/* ===========================
   Loading States (for future use)
   =========================== */

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

.loading-shimmer {
  background: linear-gradient(
    90deg,
    var(--border-light) 25%,
    var(--surface) 50%,
    var(--border-light) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
}

/* ===========================
   Reduced Motion Support
   =========================== */

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

  .animate-on-scroll,
  .pop-scale,
  .pop-left,
  .pop-right,
  .pop-rotate {
    opacity: 1;
    transform: none;
  }

  .sparkle {
    display: none;
  }
}
