/* ============================================================
   animations.css — Page Transitions, Micro-interactions
   ============================================================ */

/* ── Keyframes ────────────────────────────────────────────── */
@keyframes spin {
  to { transform: rotate(360deg); }
}

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

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

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

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

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

@keyframes slideUp {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}

@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.92); }
  to   { opacity: 1; transform: scale(1); }
}

@keyframes popIn {
  0%   { opacity: 0; transform: scale(0.8); }
  70%  { transform: scale(1.05); }
  100% { opacity: 1; transform: scale(1); }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.5; }
}

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50%       { transform: translateY(-6px); }
}

@keyframes shimmer {
  from { background-position: -200px 0; }
  to   { background-position: calc(200px + 100%) 0; }
}

@keyframes ripple {
  to { transform: scale(4); opacity: 0; }
}

/* ── Page Transitions ─────────────────────────────────────── */
.page-enter {
  animation: pageEnter var(--transition-slow) cubic-bezier(0.4, 0, 0.2, 1) both;
}

@keyframes pageEnter {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

.page-enter-right {
  animation: slideInRight 280ms cubic-bezier(0.4, 0, 0.2, 1) both;
}

.page-exit {
  animation: pageExit 200ms ease both;
}

@keyframes pageExit {
  to { opacity: 0; transform: translateY(-8px); }
}

/* ── Staggered Children ───────────────────────────────────── */
.stagger > * {
  opacity: 0;
  animation: fadeInUp 350ms cubic-bezier(0.4, 0, 0.2, 1) both;
}

.stagger > *:nth-child(1)  { animation-delay: 50ms; }
.stagger > *:nth-child(2)  { animation-delay: 100ms; }
.stagger > *:nth-child(3)  { animation-delay: 150ms; }
.stagger > *:nth-child(4)  { animation-delay: 200ms; }
.stagger > *:nth-child(5)  { animation-delay: 250ms; }
.stagger > *:nth-child(6)  { animation-delay: 300ms; }
.stagger > *:nth-child(7)  { animation-delay: 350ms; }
.stagger > *:nth-child(8)  { animation-delay: 400ms; }

/* ── Utility Animation Classes ────────────────────────────── */
.animate-fadeIn     { animation: fadeIn var(--transition-base) both; }
.animate-fadeInUp   { animation: fadeInUp 350ms cubic-bezier(0.4,0,0.2,1) both; }
.animate-fadeInDown { animation: fadeInDown 300ms ease both; }
.animate-scaleIn    { animation: scaleIn 250ms cubic-bezier(0.4,0,0.2,1) both; }
.animate-popIn      { animation: popIn 350ms cubic-bezier(0.175,0.885,0.32,1.275) both; }
.animate-spin       { animation: spin 0.7s linear infinite; }
.animate-pulse      { animation: pulse 2s ease infinite; }
.animate-bounce     { animation: bounce 1s ease infinite; }

/* ── Ripple Effect ────────────────────────────────────────── */
.ripple-container {
  position: relative;
  overflow: hidden;
}

.ripple-wave {
  position: absolute;
  border-radius: 50%;
  background: rgba(255,255,255,0.3);
  transform: scale(0);
  animation: ripple 600ms linear;
  pointer-events: none;
}

/* ── Spinner ──────────────────────────────────────────────── */
.spinner {
  width: 24px; height: 24px;
  border: 2.5px solid var(--color-border);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}

.spinner--sm { width: 16px; height: 16px; border-width: 2px; }
.spinner--lg { width: 40px; height: 40px; border-width: 3px; }
.spinner--white {
  border-color: rgba(255,255,255,0.3);
  border-top-color: #fff;
}

/* ── Dot Loader ───────────────────────────────────────────── */
.dot-loader {
  display: flex; gap: 6px; align-items: center;
}

.dot-loader span {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--color-primary);
  animation: bounce 0.8s ease infinite;
}

.dot-loader span:nth-child(2) { animation-delay: 0.15s; }
.dot-loader span:nth-child(3) { animation-delay: 0.30s; }

/* ── Toast Animations ─────────────────────────────────────── */
.toast-enter {
  animation: toastIn 350ms cubic-bezier(0.175,0.885,0.32,1.275) both;
}

.toast-exit {
  animation: toastOut 250ms ease both;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateY(20px) scale(0.9); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes toastOut {
  to { opacity: 0; transform: translateY(8px) scale(0.95); }
}

/* ── Card hover lift (desktop) ────────────────────────────── */
@media (hover: hover) {
  .stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
  }
  .card:hover {
    box-shadow: var(--shadow-md);
  }
}
