/* ==========================================================================
   ANIMATIONS & KEYFRAMES
   ========================================================================== */

/* --------------------------------------------------------------------------
   KEYFRAMES
   -------------------------------------------------------------------------- */

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

/* Refraction overlay — used on generated content cards */
@keyframes refractionStep {
  0%   { opacity: var(--refraction-opacity); transform: translateX(-100%) skewX(-15deg); }
  100% { opacity: 0;                          transform: translateX(200%) skewX(-15deg); }
}

/* Gold shimmer — used on accented surfaces */
@keyframes goldShimmer {
  0%   { background-position: 0% 50%; }
  50%  { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

/* Typewriter cursor blink */
@keyframes blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0; }
}

/* Toast slide-in from bottom */
@keyframes toastIn {
  from { opacity: 0; transform: translateY(16px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

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

/* Score rating fill */
@keyframes ratingFill {
  from { transform: scale(1); }
  25%  { transform: scale(1.3); }
  50%  { transform: scale(0.9); }
  to   { transform: scale(1); }
}

/* --------------------------------------------------------------------------
   ANIMATION UTILITY CLASSES
   -------------------------------------------------------------------------- */

.anim-fade-in {
  animation: fadeIn var(--dur-base) var(--ease-out) both;
}

.anim-fade-in--slow {
  animation: fadeIn var(--dur-slow) var(--ease-out) both;
}

.anim-slide-up {
  animation: slideUp var(--dur-slow) var(--ease-out) both;
}

.anim-slide-down {
  animation: slideDown var(--dur-slow) var(--ease-out) both;
}

.anim-scale-in {
  animation: scaleIn var(--dur-base) var(--ease-spring) both;
}

.anim-shimmer {
  background: linear-gradient(
    90deg,
    var(--surface-2) 0%,
    var(--surface-3) 50%,
    var(--surface-2) 100%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s var(--ease-in-out) infinite;
}

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

.anim-pulse {
  animation: pulse 2s var(--ease-in-out) infinite;
}

.anim-bounce {
  animation: bounce 1.2s var(--ease-in-out) infinite;
}

/* --------------------------------------------------------------------------
   STAGGER HELPERS
   Apply to list containers — children delay by --stagger multiplier.
   -------------------------------------------------------------------------- */
.anim-stagger > * {
  animation: slideUp var(--dur-slow) var(--ease-out) both;
}

.anim-stagger > *:nth-child(1) { animation-delay: 0ms; }
.anim-stagger > *:nth-child(2) { animation-delay: 60ms; }
.anim-stagger > *:nth-child(3) { animation-delay: 120ms; }
.anim-stagger > *:nth-child(4) { animation-delay: 180ms; }
.anim-stagger > *:nth-child(5) { animation-delay: 240ms; }
.anim-stagger > *:nth-child(6) { animation-delay: 300ms; }
.anim-stagger > *:nth-child(7) { animation-delay: 360ms; }
.anim-stagger > *:nth-child(8) { animation-delay: 420ms; }
.anim-stagger > *:nth-child(n+9) { animation-delay: 480ms; }

/* --------------------------------------------------------------------------
   REFRACTION OVERLAY
   Decorative light-sweep effect on generated content panels.
   -------------------------------------------------------------------------- */
.refraction-overlay {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  border-radius: inherit;
}

.refraction-overlay::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 60%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255, 255, 255, 0.04) 50%,
    transparent 100%
  );
  animation: refractionStep 4s var(--ease-in-out) infinite;
  animation-delay: 2s;
}

/* --------------------------------------------------------------------------
   SKELETON LOADERS
   -------------------------------------------------------------------------- */
.skeleton {
  border-radius: var(--radius-sm);
  background: linear-gradient(
    90deg,
    var(--surface-2) 0%,
    var(--surface-3) 50%,
    var(--surface-2) 100%
  );
  background-size: 200% 100%;
  animation: shimmer 1.4s var(--ease-in-out) infinite;
}

.skeleton--text {
  height: 13px;
  width: 100%;
}

.skeleton--text-sm {
  height: 11px;
  width: 60%;
}

.skeleton--heading {
  height: 24px;
  width: 40%;
}

.skeleton--block {
  height: 80px;
  width: 100%;
}

/* --------------------------------------------------------------------------
   MOTION PREFERENCE
   Respect prefers-reduced-motion at system level.
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
