/**
 * Animation Styles - Light Editorial Theme
 * Smooth, refined transitions and keyframe animations
 */

/* ===========================================
   FADE ANIMATIONS
   =========================================== */

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

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

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

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

.animate-fade-in {
  animation: fadeIn var(--transition-base) ease-out;
}

.animate-fade-in-up {
  animation: fadeInUp var(--transition-base) ease-out;
}

.animate-fade-in-down {
  animation: fadeInDown var(--transition-base) ease-out;
}

/* ===========================================
   SLIDE ANIMATIONS
   =========================================== */

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

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

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

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

/* ===========================================
   SCALE ANIMATIONS
   =========================================== */

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

@keyframes scaleOut {
  from {
    opacity: 1;
    transform: scale(1);
  }
  to {
    opacity: 0;
    transform: scale(0.95);
  }
}

.animate-scale-in {
  animation: scaleIn var(--transition-base) ease-out;
}

/* ===========================================
   PULSE & BOUNCE
   =========================================== */

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

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

@keyframes heartbeat {
  0%, 100% {
    transform: scale(1);
  }
  25% {
    transform: scale(1.1);
  }
  50% {
    transform: scale(1);
  }
  75% {
    transform: scale(1.1);
  }
}

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

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

/* ===========================================
   SPIN ANIMATION (for loaders)
   =========================================== */

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

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

/* ===========================================
   VARIATION CROSSFADE (for product cards)
   =========================================== */

.variation-crossfade {
  position: relative;
}

.variation-crossfade-item {
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity var(--transition-slow) ease-in-out;
}

.variation-crossfade-item.is-active {
  opacity: 1;
}

/* ===========================================
   SKELETON LOADING
   =========================================== */

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

.skeleton {
  background-color: var(--color-border);
  background-image: linear-gradient(
    90deg,
    var(--color-border) 0px,
    #f0f0f0 40px,
    var(--color-border) 80px
  );
  background-size: 200px 100%;
  background-repeat: no-repeat;
  animation: shimmer 1.5s ease-in-out infinite;
  border-radius: var(--radius-md);
}

.skeleton-text {
  height: 1em;
  margin-bottom: var(--spacing-2);
}

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

.skeleton-circle {
  border-radius: var(--radius-full);
}

.skeleton-card {
  height: 300px;
}

/* ===========================================
   HOVER LIFT EFFECT
   =========================================== */

.hover-lift {
  transition: transform var(--transition-base), box-shadow var(--transition-base);
}

.hover-lift:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
}

/* ===========================================
   STAGGER ANIMATION (for lists)
   =========================================== */

[data-stagger] > * {
  opacity: 0;
  animation: fadeInUp var(--transition-base) ease-out forwards;
}

[data-stagger] > *:nth-child(1) { animation-delay: 0ms; }
[data-stagger] > *:nth-child(2) { animation-delay: 50ms; }
[data-stagger] > *:nth-child(3) { animation-delay: 100ms; }
[data-stagger] > *:nth-child(4) { animation-delay: 150ms; }
[data-stagger] > *:nth-child(5) { animation-delay: 200ms; }
[data-stagger] > *:nth-child(6) { animation-delay: 250ms; }
[data-stagger] > *:nth-child(7) { animation-delay: 300ms; }
[data-stagger] > *:nth-child(8) { animation-delay: 350ms; }
[data-stagger] > *:nth-child(9) { animation-delay: 400ms; }
[data-stagger] > *:nth-child(10) { animation-delay: 450ms; }
[data-stagger] > *:nth-child(11) { animation-delay: 500ms; }
[data-stagger] > *:nth-child(12) { animation-delay: 550ms; }

/* ===========================================
   STAR TWINKLE (for star map preview)
   =========================================== */

@keyframes twinkle {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.3;
  }
}

.star-twinkle {
  animation: twinkle 3s ease-in-out infinite;
}

.star-twinkle:nth-child(odd) {
  animation-delay: 1s;
}

.star-twinkle:nth-child(3n) {
  animation-delay: 2s;
  animation-duration: 4s;
}

/* ===========================================
   PAGE TRANSITIONS
   =========================================== */

.page-enter {
  opacity: 0;
  transform: translateY(10px);
}

.page-enter-active {
  opacity: 1;
  transform: translateY(0);
  transition: opacity var(--transition-base), transform var(--transition-base);
}

.page-exit {
  opacity: 1;
}

.page-exit-active {
  opacity: 0;
  transition: opacity var(--transition-fast);
}

/* ===========================================
   BUTTON LOADING STATE
   =========================================== */

.btn.is-loading {
  position: relative;
  color: transparent;
  pointer-events: none;
}

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

.btn-primary.is-loading::after {
  border-top-color: var(--color-text-inverse);
}

/* ===========================================
   REDUCED MOTION
   =========================================== */

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

  .animate-pulse,
  .animate-bounce,
  .animate-spin,
  .skeleton {
    animation: none;
  }
}

/* ===========================================
   SMOOTH HOVER TRANSITIONS
   =========================================== */

.smooth-hover {
  transition: all var(--transition-base) var(--ease-smooth);
}

.smooth-hover:hover {
  transform: translateY(-2px);
}

/* ===========================================
   CONTENT REVEAL
   =========================================== */

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

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

.animate-reveal {
  animation: revealFromBottom 0.6s var(--ease-smooth) forwards;
}

.animate-reveal-left {
  animation: revealFromLeft 0.6s var(--ease-smooth) forwards;
}

/* ===========================================
   MODAL ANIMATIONS
   =========================================== */

@keyframes modalEnter {
  from {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
}

@keyframes modalExit {
  from {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
  to {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.96);
  }
}

@keyframes backdropFadeIn {
  from {
    opacity: 0;
    backdrop-filter: blur(0);
  }
  to {
    opacity: 1;
    backdrop-filter: blur(8px);
  }
}

/* ===========================================
   DRAWER ANIMATIONS
   =========================================== */

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

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

/* ===========================================
   INTERACTIVE FEEDBACK
   =========================================== */

.tap-feedback {
  transition: transform var(--transition-fast);
}

.tap-feedback:active {
  transform: scale(0.98);
}

/* Selection bounce for theme swatches etc */
@keyframes selectBounce {
  0% {
    transform: scale(1);
  }
  40% {
    transform: scale(1.12);
  }
  100% {
    transform: scale(1.08);
  }
}

.animate-select {
  animation: selectBounce 0.3s var(--ease-spring);
}

/* ===========================================
   PREVIEW LOADING STATES
   =========================================== */

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

.preview-loading {
  animation: previewFade 1.2s ease-in-out infinite;
}

/* Smooth opacity transition for preview updates */
.preview-updating {
  opacity: 0.7;
  transition: opacity var(--transition-fast);
}

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

@keyframes toastEnter {
  from {
    opacity: 0;
    transform: translateX(100%) scale(0.9);
  }
  to {
    opacity: 1;
    transform: translateX(0) scale(1);
  }
}

@keyframes toastExit {
  from {
    opacity: 1;
    transform: translateX(0) scale(1);
  }
  to {
    opacity: 0;
    transform: translateX(100%) scale(0.9);
  }
}

.toast-enter {
  animation: toastEnter 0.3s var(--ease-spring) forwards;
}

.toast-exit {
  animation: toastExit 0.2s var(--ease-in) forwards;
}
