/* ==========================================================================
   AI-PKM Animation System — animations.css
   Keyframes, Utility Classes, Micro-interactions, Reduced Motion
   ========================================================================== */

/* --------------------------------------------------------------------------
   Keyframes
   -------------------------------------------------------------------------- */
@keyframes fadeInUp {
  from {
    opacity: 0;
    -webkit-transform: translateY(20px);
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    -webkit-transform: translateY(0);
    transform: translateY(0);
  }
}

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

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

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

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

@keyframes slideOutRight {
  from {
    -webkit-transform: translateX(0);
    transform: translateX(0);
  }
  to {
    -webkit-transform: translateX(120%);
    transform: translateX(120%);
  }
}

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

@keyframes spin {
  to {
    -webkit-transform: rotate(360deg);
    transform: rotate(360deg);
  }
}

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

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

@keyframes breathe {
  0%,
  100% {
    box-shadow: 0 0 8px rgba(99, 102, 241, 0.2);
  }
  50% {
    box-shadow: 0 0 20px rgba(99, 102, 241, 0.4);
  }
}

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

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

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

@keyframes typewriter {
  from {
    width: 0;
  }
  to {
    width: 100%;
  }
}

/* --------------------------------------------------------------------------
   Animation Utility Classes
   -------------------------------------------------------------------------- */
.animate-fade-in-up {
  -webkit-animation: fadeInUp 0.4s cubic-bezier(0.4, 0, 0.2, 1) both;
  animation: fadeInUp 0.4s cubic-bezier(0.4, 0, 0.2, 1) both;
}

.animate-fade-in {
  -webkit-animation: fadeIn 0.3s ease both;
  animation: fadeIn 0.3s ease both;
}

.animate-scale-in {
  -webkit-animation: scaleIn 0.3s ease both;
  animation: scaleIn 0.3s ease both;
}

.animate-slide-in-right {
  -webkit-animation: slideInRight 0.3s ease both;
  animation: slideInRight 0.3s ease both;
}

/* --------------------------------------------------------------------------
   Staggered Card Entrance
   Uses --i CSS custom property for per-card delay (set via inline style)
   -------------------------------------------------------------------------- */
.note-card {
  -webkit-animation: fadeInUp 0.4s cubic-bezier(0.4, 0, 0.2, 1) both;
  animation: fadeInUp 0.4s cubic-bezier(0.4, 0, 0.2, 1) both;
  -webkit-animation-delay: calc(var(--i, 0) * 60ms);
  animation-delay: calc(var(--i, 0) * 60ms);
}

/* --------------------------------------------------------------------------
   Hover Micro-Interactions
   -------------------------------------------------------------------------- */
.note-card {
  -webkit-transition: transform 0.3s ease, box-shadow 0.3s ease, border-color 0.3s ease;
  transition: transform 0.3s ease, box-shadow 0.3s ease, border-color 0.3s ease;
}

.btn-new-note {
  -webkit-transition: transform 0.2s ease, box-shadow 0.2s ease, -webkit-filter 0.2s ease;
  transition: transform 0.2s ease, box-shadow 0.2s ease, filter 0.2s ease;
}

.nav-item {
  -webkit-transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

/* --------------------------------------------------------------------------
   Ripple Effect on Buttons
   -------------------------------------------------------------------------- */
.ripple {
  position: relative;
  overflow: hidden;
}

.ripple::after {
  content: '';
  position: absolute;
  width: 100px;
  height: 100px;
  background: rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  -webkit-transform: scale(0);
  transform: scale(0);
  opacity: 1;
  pointer-events: none;
  top: 50%;
  left: 50%;
  margin-top: -50px;
  margin-left: -50px;
}

.ripple:active::after {
  -webkit-animation: ripple 0.6s ease-out;
  animation: ripple 0.6s ease-out;
}

/* --------------------------------------------------------------------------
   Search Highlight Pulse
   -------------------------------------------------------------------------- */
mark,
.highlight {
  background: rgba(245, 158, 11, 0.3);
  color: inherit;
  border-radius: 2px;
  padding: 1px 2px;
  -webkit-animation: pulse 2s ease-in-out 1;
  animation: pulse 2s ease-in-out 1;
}

/* --------------------------------------------------------------------------
   Modal Enter / Exit
   -------------------------------------------------------------------------- */
.modal-overlay.active .modal {
  -webkit-animation: scaleIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) both;
  animation: scaleIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

/* --------------------------------------------------------------------------
   Toast Enter / Exit
   -------------------------------------------------------------------------- */
.toast.show {
  -webkit-animation: slideInRight 0.4s ease both;
  animation: slideInRight 0.4s ease both;
}

.toast.hide {
  -webkit-animation: slideOutRight 0.3s ease both;
  animation: slideOutRight 0.3s ease both;
}

/* --------------------------------------------------------------------------
   Gradient Text Animation (Logo)
   -------------------------------------------------------------------------- */
.gradient-text {
  background: linear-gradient(135deg, #6366f1, #8b5cf6, #a855f7, #6366f1);
  background-size: 300% 300%;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  -webkit-animation: gradientShift 4s ease infinite;
  animation: gradientShift 4s ease infinite;
}

/* --------------------------------------------------------------------------
   Breathing Glow for Pinned Cards
   -------------------------------------------------------------------------- */
.note-card.pinned {
  -webkit-animation: breathe 3s ease-in-out infinite;
  animation: breathe 3s ease-in-out infinite;
}

/* --------------------------------------------------------------------------
   Floating Animation for Empty State Icon
   -------------------------------------------------------------------------- */
.empty-state-icon {
  -webkit-animation: float 3s ease-in-out infinite;
  animation: float 3s ease-in-out infinite;
}

/* --------------------------------------------------------------------------
   Skeleton Loading Shimmer
   -------------------------------------------------------------------------- */
.skeleton {
  background: linear-gradient(
    90deg,
    var(--bg-glass) 25%,
    var(--bg-hover) 50%,
    var(--bg-glass) 75%
  );
  background-size: 400% 100%;
  -webkit-animation: shimmer 1.5s ease infinite;
  animation: shimmer 1.5s ease infinite;
  border-radius: var(--radius-md);
}

.skeleton-text {
  height: 14px;
  margin-bottom: 8px;
  border-radius: 4px;
}

.skeleton-text:last-child {
  width: 60%;
}

.skeleton-title {
  height: 20px;
  width: 70%;
  margin-bottom: 12px;
  border-radius: 4px;
}

.skeleton-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
}

/* --------------------------------------------------------------------------
   Reduced Motion Preference
   Respects user accessibility settings by disabling animations
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    -webkit-animation-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    -webkit-animation-iteration-count: 1 !important;
    animation-iteration-count: 1 !important;
    -webkit-transition-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
