/* ─────────────────────────────────────────────────────────────────────────────
   animations.css
   All keyframe animations and transition utilities for The Foundry.
   These are used throughout the app to create smooth, polished micro-interactions.
───────────────────────────────────────────────────────────────────────────── */


/* ── Fade In ─────────────────────────────────────────────────────────────── */
/* Used when a section loads or a modal appears */

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

.animate-fade-in {
  animation: fadeIn 200ms ease forwards;
}


/* ── Fade In Up ──────────────────────────────────────────────────────────── */
/* Cards slide up slightly as they appear — creates a sense of depth */

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

.animate-fade-in-up {
  animation: fadeInUp 300ms ease forwards;
}

/* Staggered animation for multiple cards appearing in sequence */
.animate-stagger > *:nth-child(1) { animation-delay: 0ms; }
.animate-stagger > *:nth-child(2) { animation-delay: 60ms; }
.animate-stagger > *:nth-child(3) { animation-delay: 120ms; }
.animate-stagger > *:nth-child(4) { animation-delay: 180ms; }
.animate-stagger > *:nth-child(5) { animation-delay: 240ms; }
.animate-stagger > *:nth-child(6) { animation-delay: 300ms; }


/* ── Slide Down ──────────────────────────────────────────────────────────── */
/* Used for the forgot password panel sliding down inside the login card */

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
    max-height: 0;
  }
  to {
    opacity: 1;
    transform: translateY(0);
    max-height: 400px;
  }
}

.animate-slide-down {
  animation: slideDown 300ms ease forwards;
}


/* ── Slide Up ────────────────────────────────────────────────────────────── */
/* Used for modals and bottom sheets on mobile */

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

.animate-slide-up {
  animation: slideUp 300ms ease forwards;
}


/* ── Scale In ────────────────────────────────────────────────────────────── */
/* Used for modals on desktop — they slightly scale up as they appear */

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

.animate-scale-in {
  animation: scaleIn 250ms ease forwards;
}


/* ── Shake ───────────────────────────────────────────────────────────────── */
/* Applied to the login form when credentials are wrong */

@keyframes shake {
  0%   { transform: translateX(0); }
  15%  { transform: translateX(-6px); }
  30%  { transform: translateX(5px); }
  45%  { transform: translateX(-4px); }
  60%  { transform: translateX(3px); }
  75%  { transform: translateX(-2px); }
  90%  { transform: translateX(1px); }
  100% { transform: translateX(0); }
}

.animate-shake {
  animation: shake 0.4s ease;
}


/* ── Pulse ───────────────────────────────────────────────────────────────── */
/* Used for the "reconnecting" dot on the offline page and status indicators */

@keyframes pulse {
  0%, 100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.4;
    transform: scale(0.8);
  }
}

.animate-pulse {
  animation: pulse 2s ease-in-out infinite;
}


/* ── Spin ────────────────────────────────────────────────────────────────── */
/* Continuous rotation — used for loading spinners */

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

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


/* ── Gradient Shift ──────────────────────────────────────────────────────── */
/* The slow-moving background gradient on the login screen */

@keyframes gradientShift {
  0%   { background-position: 0% 50%; }
  50%  { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}


/* ── Bounce In ───────────────────────────────────────────────────────────── */
/* Used for badges and notification counts appearing */

@keyframes bounceIn {
  0%   { transform: scale(0); opacity: 0; }
  60%  { transform: scale(1.15); opacity: 1; }
  80%  { transform: scale(0.95); }
  100% { transform: scale(1); }
}

.animate-bounce-in {
  animation: bounceIn 350ms cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}


/* ── Ripple ──────────────────────────────────────────────────────────────── */
/* A subtle ripple effect for button taps on mobile */

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

.btn-ripple {
  position: relative;
  overflow: hidden;
}

.btn-ripple::after {
  content: '';
  position: absolute;
  width: 100%;
  padding-top: 100%;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.3);
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0);
  opacity: 0;
}

.btn-ripple:active::after {
  animation: ripple 400ms ease-out;
}


/* ── Avatar Upload Preview ───────────────────────────────────────────────── */
/* The avatar smoothly fades in when a new image is loaded */

@keyframes avatarLoad {
  from { opacity: 0; transform: scale(0.9); }
  to   { opacity: 1; transform: scale(1); }
}

.avatar-loaded {
  animation: avatarLoad 250ms ease forwards;
}


/* ── Section Transition ──────────────────────────────────────────────────── */
/* When switching nav sections, the content fades out then back in */

.section-exit {
  animation: fadeOut 100ms ease forwards;
}

.section-enter {
  animation: fadeIn 200ms ease forwards;
}

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


/* ── Sidebar Slide ───────────────────────────────────────────────────────── */
/* Profile panel sliding in from the left on desktop */

@keyframes slideInLeft {
  from { transform: translateX(-100%); }
  to   { transform: translateX(0); }
}

@keyframes slideOutLeft {
  from { transform: translateX(0); }
  to   { transform: translateX(-100%); }
}


/* ── Number Count Up ─────────────────────────────────────────────────────── */
/* Stat card numbers animate in with a subtle fade+slide */

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

.animate-count-in {
  animation: countIn 400ms ease forwards;
}


/* ── Reduced Motion ──────────────────────────────────────────────────────── */
/* Respects the user's system-level "Reduce Motion" accessibility preference.
   If they've turned on reduce motion, we disable all animations. */

@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;
  }
}
