/* ============================================================
   SAPORI — Animations & Keyframes
   Premium Italian Recipe PWA
   ============================================================ */

/* ============================================================
   KEYFRAMES
   ============================================================ */

/* — Fade — */
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

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

/* — Slide — */
@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slideInRight {
  from {
    opacity: 0;
    transform: translateX(60px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes slideOutLeft {
  from {
    opacity: 1;
    transform: translateX(0);
  }
  to {
    opacity: 0;
    transform: translateX(-60px);
  }
}

/* — Scale — */
@keyframes scaleIn {
  from {
    opacity: 0;
    transform: scale(0.85);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* — Shimmer (loading placeholder) — */
@keyframes shimmer {
  0% {
    background-position: -200% 0;
  }
  100% {
    background-position: 200% 0;
  }
}

/* — Heart Beat (favorite toggle) — */
@keyframes heartBeat {
  0% {
    transform: scale(1);
  }
  15% {
    transform: scale(1.35);
  }
  30% {
    transform: scale(0.9);
  }
  45% {
    transform: scale(1.15);
  }
  60% {
    transform: scale(0.95);
  }
  100% {
    transform: scale(1);
  }
}

/* — Shake (form validation error) — */
@keyframes shake {
  0%, 100% {
    transform: translateX(0);
  }
  10%, 50%, 90% {
    transform: translateX(-6px);
  }
  30%, 70% {
    transform: translateX(6px);
  }
}

/* — Pulse (FAB button) — */
@keyframes pulse {
  0% {
    box-shadow: 0 0 0 0 var(--primary-light);
  }
  50% {
    box-shadow: 0 0 0 12px transparent;
  }
  100% {
    box-shadow: 0 0 0 0 transparent;
  }
}

/* — Ripple (button click) — */
@keyframes ripple {
  0% {
    transform: scale(0);
    opacity: 0.5;
  }
  100% {
    transform: scale(4);
    opacity: 0;
  }
}

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

/* — Slide Up Enter for modals — */
@keyframes modalSlideUp {
  from {
    opacity: 0;
    transform: translateY(40px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* — Toast slide-in — */
@keyframes toastSlideIn {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* — Toast slide-out — */
@keyframes toastSlideOut {
  from {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
  to {
    opacity: 0;
    transform: translateY(20px) scale(0.95);
  }
}

/* — Spin — */
@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

/* — Bounce In — */
@keyframes bounceIn {
  0% {
    opacity: 0;
    transform: scale(0.3);
  }
  50% {
    transform: scale(1.05);
  }
  70% {
    transform: scale(0.95);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

/* — Icon Rotate (theme toggle) — */
@keyframes iconRotate {
  from {
    opacity: 0;
    transform: rotate(-90deg) scale(0.5);
  }
  to {
    opacity: 1;
    transform: rotate(0) scale(1);
  }
}

/* ============================================================
   UTILITY ANIMATION CLASSES
   ============================================================ */
.animate-fade-in {
  animation: fadeIn 0.4s ease both;
}

.animate-slide-up {
  animation: slideUp 0.5s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.animate-scale-in {
  animation: scaleIn 0.4s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.animate-slide-down {
  animation: slideDown 0.4s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.animate-slide-in-right {
  animation: slideInRight 0.5s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.animate-slide-out-left {
  animation: slideOutLeft 0.4s ease both;
}

.animate-heart-beat {
  animation: heartBeat 0.6s ease both;
}

.animate-shake {
  animation: shake 0.5s ease both;
}

.animate-bounce-in {
  animation: bounceIn 0.5s cubic-bezier(0.22, 1, 0.36, 1) both;
}

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

.animate-spin {
  animation: spin 1s linear infinite;
}

/* Loading shimmer placeholder */
.shimmer {
  background: linear-gradient(
    90deg,
    var(--bg-tertiary) 25%,
    var(--bg-secondary) 50%,
    var(--bg-tertiary) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.8s ease-in-out infinite;
  border-radius: var(--radius-sm);
}

/* ============================================================
   STAGGER DELAYS (for lists / grids)
   ============================================================ */
.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; }
.stagger-6 { animation-delay: 0.3s; }
.stagger-7 { animation-delay: 0.35s; }
.stagger-8 { animation-delay: 0.4s; }

/* ============================================================
   REDUCED MOTION — respect user preferences
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }

  .animate-fade-in,
  .animate-slide-up,
  .animate-scale-in,
  .animate-slide-down,
  .animate-slide-in-right,
  .animate-slide-out-left,
  .animate-heart-beat,
  .animate-shake,
  .animate-bounce-in,
  .animate-float,
  .animate-spin,
  .shimmer {
    animation: none !important;
    opacity: 1 !important;
    transform: none !important;
  }
}
