﻿/* =====================================================
   CropPulse – Animations CSS
   Micro-animations, transitions, and entrance effects
   ===================================================== */

/* ── Keyframes ──────────────────────────────────────── */
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(30px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes fadeDown {
  from { opacity: 0; transform: translateY(-30px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes fadeLeft {
  from { opacity: 0; transform: translateX(30px); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes fadeRight {
  from { opacity: 0; transform: translateX(-30px); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.85); }
  to   { opacity: 1; transform: scale(1); }
}
@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50%       { transform: scale(1.05); opacity: 0.8; }
}
@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50%       { transform: translateY(-8px); }
}
@keyframes spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}
@keyframes spinReverse {
  from { transform: rotate(360deg); }
  to   { transform: rotate(0deg); }
}
@keyframes float {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  33%       { transform: translateY(-12px) rotate(2deg); }
  66%       { transform: translateY(-6px) rotate(-2deg); }
}
@keyframes glow {
  0%, 100% { box-shadow: 0 0 20px rgba(22,163,74,0.2); }
  50%       { box-shadow: 0 0 40px rgba(22,163,74,0.5); }
}
@keyframes shimmer {
  from { background-position: 200% 0; }
  to   { background-position: -200% 0; }
}
@keyframes numberCount {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes drawCircle {
  from { stroke-dashoffset: 283; }
  to   { stroke-dashoffset: var(--target-offset, 0); }
}
@keyframes waveScroll {
  0%   { background-position-x: 0; }
  100% { background-position-x: 1440px; }
}
@keyframes leafSway {
  0%, 100% { transform: rotate(-3deg) scale(1); }
  50%       { transform: rotate(3deg) scale(1.02); }
}

/* ── Entrance Animations ────────────────────────────── */
.animate-fade-in    { animation: fadeIn   0.5s ease forwards; }
.animate-fade-up    { animation: fadeUp   0.6s ease forwards; }
.animate-fade-down  { animation: fadeDown 0.6s ease forwards; }
.animate-fade-left  { animation: fadeLeft 0.6s ease forwards; }
.animate-fade-right { animation: fadeRight 0.6s ease forwards; }
.animate-scale-in   { animation: scaleIn  0.5s ease forwards; }
.animate-float      { animation: float    4s ease-in-out infinite; }
.animate-pulse      { animation: pulse    2s ease-in-out infinite; }
.animate-bounce     { animation: bounce   1.5s ease-in-out infinite; }
.animate-glow       { animation: glow     2.5s ease-in-out infinite; }
.animate-spin       { animation: spin     1s linear infinite; }

/* ── Delay Utilities ────────────────────────────────── */
.delay-100 { animation-delay: 0.1s; }
.delay-200 { animation-delay: 0.2s; }
.delay-300 { animation-delay: 0.3s; }
.delay-400 { animation-delay: 0.4s; }
.delay-500 { animation-delay: 0.5s; }
.delay-600 { animation-delay: 0.6s; }
.delay-700 { animation-delay: 0.7s; }
.delay-800 { animation-delay: 0.8s; }

/* Initially hidden for staggered entrance */
.anim-hidden { opacity: 0; }

/* ── Hover Effects ──────────────────────────────────── */
.hover-lift {
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}
.hover-lift:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 30px rgba(0,0,0,0.3);
}
.hover-scale {
  transition: transform 0.2s ease;
}
.hover-scale:hover { transform: scale(1.04); }

.hover-glow-green {
  transition: box-shadow 0.25s ease;
}
.hover-glow-green:hover {
  box-shadow: 0 0 30px rgba(22,163,74,0.35);
}

/* ── Loading Spinner ────────────────────────────────── */
.ag-spinner {
  width: 40px; height: 40px;
  border: 3px solid rgba(22,163,74,0.2);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
.ag-spinner-sm {
  width: 20px; height: 20px;
  border-width: 2px;
}
.ag-spinner-lg {
  width: 60px; height: 60px;
  border-width: 4px;
}

.loading-overlay {
  position: fixed; inset: 0; z-index: 9000;
  background: var(--bg-overlay);
  display: flex; align-items: center; justify-content: center;
  flex-direction: column; gap: 1rem;
  backdrop-filter: blur(8px);
}
.loading-overlay .load-text {
  color: var(--text-secondary); font-size: 0.9rem;
  animation: pulse 1.5s ease infinite;
}

/* ── Page Transition ────────────────────────────────── */
.page-enter {
  animation: fadeUp 0.5s ease forwards;
}

/* ── Hero Particle Field ─────────────────────────────── */
.hero-particles {
  position: absolute; inset: 0; overflow: hidden; pointer-events: none;
}
.hero-particles .particle {
  position: absolute; width: 4px; height: 4px;
  background: var(--primary-light);
  border-radius: 50%; opacity: 0;
  animation: particleFloat linear infinite;
}
@keyframes particleFloat {
  0%   { transform: translateY(100vh) scale(0); opacity: 0; }
  10%  { opacity: 0.6; }
  90%  { opacity: 0.3; }
  100% { transform: translateY(-10px) scale(1); opacity: 0; }
}

/* ── Ripple Effect ───────────────────────────────────── */
.ripple {
  position: relative; overflow: hidden;
}
.ripple::after {
  content: '';
  position: absolute;
  border-radius: 50%;
  background: rgba(255,255,255,0.25);
  transform: scale(0);
  animation: rippleEffect 0.6s linear;
  pointer-events: none;
}
@keyframes rippleEffect {
  to { transform: scale(4); opacity: 0; }
}

/* ── Number Counter Animation ─────────────────────────── */
.counter-animate {
  animation: numberCount 0.5s ease forwards;
}

/* ── Progress Bar Fill Animation ──────────────────────── */
.progress-fill-animate .ag-progress-bar {
  width: 0;
  transition: width 1.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── Image Preview Animation ──────────────────────────── */
.img-preview-enter {
  animation: scaleIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

/* ── Notification Bell Shake ──────────────────────────── */
@keyframes bellShake {
  0%, 100% { transform: rotate(0); }
  20%       { transform: rotate(-15deg); }
  40%       { transform: rotate(15deg); }
  60%       { transform: rotate(-10deg); }
  80%       { transform: rotate(8deg); }
}
.bell-shake { animation: bellShake 0.6s ease; }

/* ── Map Marker Pulse ─────────────────────────────────── */
@keyframes markerPulse {
  0%   { transform: scale(1); opacity: 1; }
  50%  { transform: scale(1.3); opacity: 0.5; }
  100% { transform: scale(1.6); opacity: 0; }
}
.marker-pulse::after {
  content: '';
  position: absolute; inset: -4px;
  border-radius: 50%;
  border: 2px solid currentColor;
  animation: markerPulse 1.5s ease-out infinite;
}

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