/**
 * Animations - Design System Animations & Transitions
 *
 * Smooth, performant animations and transitions for micro-interactions.
 */

/* ============================================
   KEYFRAME ANIMATIONS
   ============================================ */

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

/* Fade Out */
@keyframes fadeOut {
  from {
    opacity: 1;
  }
  to {
    opacity: 0;
  }
}

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

/* Slide Down */
@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Slide Left */
@keyframes slideLeft {
  from {
    opacity: 0;
    transform: translateX(10px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* Slide Right */
@keyframes slideRight {
  from {
    opacity: 0;
    transform: translateX(-10px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

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

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

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

/* Bounce */
@keyframes bounce {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-10px);
  }
}

/* Shimmer (Loading) */
@keyframes shimmer {
  0% {
    background-position: -1000px 0;
  }
  100% {
    background-position: 1000px 0;
  }
}

/* ============================================
   ANIMATION UTILITIES
   ============================================ */

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

.animate-fade-out {
  animation: fadeOut 0.3s ease-in-out;
}

.animate-slide-up {
  animation: slideUp 0.3s ease-out;
}

.animate-slide-down {
  animation: slideDown 0.3s ease-out;
}

.animate-slide-left {
  animation: slideLeft 0.3s ease-out;
}

.animate-slide-right {
  animation: slideRight 0.3s ease-out;
}

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

.animate-pulse {
  animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

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

.animate-bounce {
  animation: bounce 1s ease-in-out infinite;
}

/* ============================================
   LOADING SKELETONS
   ============================================ */

.skeleton {
  background: linear-gradient(
    90deg,
    var(--color-gray-200) 0%,
    var(--color-gray-100) 50%,
    var(--color-gray-200) 100%
  );
  background-size: 1000px 100%;
  animation: shimmer 2s infinite;
}

.skeleton-text {
  height: var(--font-size-base);
  border-radius: var(--radius-md);
  margin-bottom: var(--spacing-2);
}

.skeleton-heading {
  height: 28px;
  border-radius: var(--radius-md);
  margin-bottom: var(--spacing-4);
}

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

.skeleton-image {
  width: 100%;
  height: 200px;
  border-radius: var(--radius-lg);
}

/* ============================================
   TRANSITION UTILITIES
   ============================================ */

/* All Properties */
.transition-all {
  transition: all var(--transition-base);
}

/* Specific Properties */
.transition-colors {
  transition: background-color var(--transition-base), border-color var(--transition-base), color var(--transition-base);
}

.transition-transform {
  transition: transform var(--transition-base);
}

.transition-opacity {
  transition: opacity var(--transition-base);
}

.transition-shadow {
  transition: box-shadow var(--transition-base);
}

/* Speed Variants */
.transition-fast {
  transition-duration: var(--transition-fast);
}

.transition-base {
  transition-duration: var(--transition-base);
}

.transition-slow {
  transition-duration: var(--transition-slow);
}

/* ============================================
   HOVER & ACTIVE EFFECTS
   ============================================ */

/* Scale Up on Hover */
.hover-scale-105:hover {
  transform: scale(1.05);
  transition: transform var(--transition-base);
}

.hover-scale-110:hover {
  transform: scale(1.1);
  transition: transform var(--transition-base);
}

/* Lift on Hover */
.hover-lift:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
  transition: var(--transition-base);
}

/* Darken on Hover */
.hover-darken:hover {
  filter: brightness(0.95);
  transition: filter var(--transition-base);
}

/* Shadow Increase on Hover */
.hover-shadow:hover {
  box-shadow: var(--shadow-lg);
  transition: box-shadow var(--transition-base);
}

/* Opacity Change on Hover */
.hover-opacity:hover {
  opacity: 0.8;
  transition: opacity var(--transition-base);
}

/* ============================================
   FOCUS STATES
   ============================================ */

/* Focus Ring */
.focus-ring:focus {
  outline: none;
  box-shadow: 0 0 0 3px var(--color-primary), var(--shadow-focus-soft);
  transition: box-shadow var(--transition-fast);
}

/* ============================================
   DISABLED & LOADING STATES
   ============================================ */

/* Disabled Opacity */
.disabled-opacity {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Disabled Grayscale */
.disabled-grayscale {
  filter: grayscale(100%);
  cursor: not-allowed;
}

/* Loading Spinner */
.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid var(--color-gray-300);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.spinner-sm {
  width: 16px;
  height: 16px;
  border-width: 2px;
}

.spinner-lg {
  width: 32px;
  height: 32px;
  border-width: 3px;
}

.spinner-white {
  border-color: var(--border-overlay-light);
  border-top-color: white;
}

/* Loading State for Buttons */
.btn.loading {
  position: relative;
  color: transparent;
}

.btn.loading::after {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  top: 50%;
  left: 50%;
  margin-top: -8px;
  margin-left: -8px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

/* ============================================
   TOAST NOTIFICATIONS
   ============================================ */

.toast {
  animation: slideUp 0.3s ease-out;
  opacity: 1;
  visibility: visible;
}

.toast.hide {
  animation: slideDown 0.3s ease-in forwards;
}

/* ============================================
   TOOLTIP EFFECTS
   ============================================ */

.tooltip {
  position: relative;
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--transition-base), visibility var(--transition-base);
}

.tooltip:hover {
  opacity: 1;
  visibility: visible;
}

.tooltip-content {
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  background-color: var(--text-primary);
  color: white;
  padding: var(--spacing-2) var(--spacing-3);
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm);
  white-space: nowrap;
  margin-bottom: var(--spacing-2);
  z-index: var(--z-tooltip);
}

.tooltip-content::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: var(--text-primary);
}

/* ============================================
   DROPDOWN ANIMATIONS
   ============================================ */

.dropdown-menu {
  animation: slideDown 0.2s ease-out;
}

.dropdown-menu.hide {
  animation: slideUp 0.2s ease-in forwards;
}

/* ============================================
   FORM FOCUS EFFECTS
   ============================================ */

input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-light);
  transition: box-shadow var(--transition-base), border-color var(--transition-base);
}

/* ============================================
   RESPONSIVE ANIMATIONS
   ============================================ */

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ============================================
   DARK MODE CONSIDERATIONS (Future)
   ============================================ */

/* @media (prefers-color-scheme: dark) {
  .skeleton {
    background: linear-gradient(
      90deg,
      var(--color-gray-700) 0%,
      var(--color-gray-600) 50%,
      var(--color-gray-700) 100%
    );
  }
} */
