/* ============================================================
   PS5 PORTFOLIO — ANIMATIONS
   Keyframes and animation utilities
   ============================================================ */

/* ── Entrance animations ── */
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

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

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

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

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

/* ── Avatar / hero glow pulse ── */
@keyframes pulseGlow {
  0%, 100% {
    box-shadow:
      0 0 12px 2px var(--color-accent),
      0 0 32px 6px color-mix(in srgb, var(--color-accent) 40%, transparent),
      0 0 64px 12px color-mix(in srgb, var(--color-accent) 20%, transparent);
  }
  50% {
    box-shadow:
      0 0 20px 4px var(--color-accent),
      0 0 60px 14px color-mix(in srgb, var(--color-accent) 55%, transparent),
      0 0 100px 24px color-mix(in srgb, var(--color-accent) 25%, transparent);
  }
}

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

/* ── Game cover subtle lift ── */
@keyframes coverHover {
  from {
    transform: translateY(0) scale(1);
  }
  to {
    transform: translateY(-8px) scale(1.04);
  }
}

/* ── Background gradient shift ── */
@keyframes backgroundShift {
  0% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
  100% {
    background-position: 0% 50%;
  }
}

/* ── Shimmer sweep (skeleton/loading) ── */
@keyframes shimmer {
  0% {
    background-position: -400px 0;
  }
  100% {
    background-position: 400px 0;
  }
}

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

/* ── PS button press bounce ── */
@keyframes pressDown {
  0%, 100% {
    transform: scale(1);
  }
  50% {
    transform: scale(0.88);
  }
}

/* ── Carousel scroll reveal ── */
@keyframes carouselReveal {
  from {
    opacity: 0;
    transform: scale(0.9) rotateY(-8deg);
  }
  to {
    opacity: 1;
    transform: scale(1) rotateY(0deg);
  }
}

/* ── Glow ring for selected state ── */
@keyframes selectedRing {
  0%, 100% {
    outline-color: var(--color-accent);
    outline-offset: 4px;
  }
  50% {
    outline-color: var(--color-secondary);
    outline-offset: 6px;
  }
}

/* ── Number count up ── */
@keyframes countUp {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ── Stagger wave ── */
@keyframes wave {
  0%, 40%, 100% {
    transform: scaleY(0.4);
  }
  20% {
    transform: scaleY(1);
  }
}

/* ── Detail panel slide-in ── */
@keyframes panelSlideIn {
  from {
    opacity: 0;
    transform: translateX(40px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* ============================================================
   ANIMATION UTILITY CLASSES
   ============================================================ */

/* Scroll-triggered reveal — add class via JS/Stimulus */
.animate-in {
  animation: slideUp 0.55s cubic-bezier(0.22, 1, 0.36, 1) both;
}

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

.animate-in--scale {
  animation: scaleIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.animate-in--slide-left {
  animation: slideLeft 0.5s cubic-bezier(0.22, 1, 0.36, 1) both;
}

/* Stagger children — apply delay via CSS custom property or nth-child overrides */
.stagger-children > * {
  --stagger-delay: 0ms;
  animation: slideUp 0.5s cubic-bezier(0.22, 1, 0.36, 1) var(--stagger-delay) both;
}

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

/* Float utility */
.animate-float {
  animation: float 4s ease-in-out infinite;
}

/* Transition shorthand */
.transition-all {
  transition: all 300ms ease-in-out;
}

.transition-transform {
  transition: transform 300ms ease-in-out;
}

.transition-opacity {
  transition: opacity 300ms ease-in-out;
}

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

  .animate-float,
  .animate-in,
  .animate-in--fade,
  .animate-in--scale,
  .animate-in--slide-left,
  .stagger-children > * {
    animation: none;
    opacity: 1;
    transform: none;
  }
}
