/* ===== Portal Animations ===== */

/* ===== Keyframe Definitions ===== */

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeOut {
  from {
    opacity: 1;
    transform: translateY(0);
  }
  to {
    opacity: 0;
    transform: translateY(-20px);
  }
}

@keyframes slideInUp {
  from {
    opacity: 0;
    transform: translateY(50px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slideInDown {
  from {
    opacity: 0;
    transform: translateY(-50px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slideInLeft {
  from {
    opacity: 0;
    transform: translateX(-50px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes slideInRight {
  from {
    opacity: 0;
    transform: translateX(50px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes scaleIn {
  from {
    opacity: 0;
    transform: scale(0.8);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes scaleOut {
  from {
    opacity: 1;
    transform: scale(1);
  }
  to {
    opacity: 0;
    transform: scale(0.8);
  }
}

@keyframes bounce {
  0%,
  20%,
  50%,
  80%,
  100% {
    transform: translateY(0);
  }
  40% {
    transform: translateY(-10px);
  }
  60% {
    transform: translateY(-5px);
  }
}

@keyframes shake {
  0%,
  100% {
    transform: translateX(0);
  }
  10%,
  30%,
  50%,
  70%,
  90% {
    transform: translateX(-2px);
  }
  20%,
  40%,
  60%,
  80% {
    transform: translateX(2px);
  }
}

@keyframes pulse {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.05);
  }
}

@keyframes glow {
  from {
    box-shadow: 0 0 5px rgba(102, 126, 234, 0.3);
  }
  to {
    box-shadow: 0 0 20px rgba(102, 126, 234, 0.6),
      0 0 30px rgba(102, 126, 234, 0.4);
  }
}

@keyframes shimmer {
  0% {
    transform: translateX(-100%);
  }
  100% {
    transform: translateX(100%);
  }
}

@keyframes rotate {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

@keyframes float {
  0%,
  100% {
    transform: translateY(0px);
  }
  50% {
    transform: translateY(-10px);
  }
}

@keyframes ripple {
  0% {
    transform: scale(0);
    opacity: 1;
  }
  100% {
    transform: scale(4);
    opacity: 0;
  }
}

/* ===== Animation Classes ===== */

.animate-fade-in {
  animation: fadeIn 0.6s ease-out forwards;
}

.animate-fade-out {
  animation: fadeOut 0.4s ease-out forwards;
}

.animate-slide-in-up {
  animation: slideInUp 0.6s ease-out forwards;
}

.animate-slide-in-down {
  animation: slideInDown 0.6s ease-out forwards;
}

.animate-slide-in-left {
  animation: slideInLeft 0.6s ease-out forwards;
}

.animate-slide-in-right {
  animation: slideInRight 0.6s ease-out forwards;
}

.animate-scale-in {
  animation: scaleIn 0.5s ease-out forwards;
}

.animate-scale-out {
  animation: scaleOut 0.3s ease-out forwards;
}

.animate-bounce {
  animation: bounce 2s infinite;
}

.animate-shake {
  animation: shake 0.5s ease-out;
}

.animate-pulse {
  animation: pulse 2s infinite;
}

.animate-glow {
  animation: glow 2s ease-in-out infinite alternate;
}

.animate-float {
  animation: float 3s ease-in-out infinite;
}

.animate-rotate {
  animation: rotate 2s linear infinite;
}

/* ===== Staggered Animations ===== */

.stagger-children > * {
  opacity: 0;
  transform: translateY(20px);
}

.stagger-children.animate > *:nth-child(1) {
  animation: fadeIn 0.6s ease-out 0.1s forwards;
}

.stagger-children.animate > *:nth-child(2) {
  animation: fadeIn 0.6s ease-out 0.2s forwards;
}

.stagger-children.animate > *:nth-child(3) {
  animation: fadeIn 0.6s ease-out 0.3s forwards;
}

.stagger-children.animate > *:nth-child(4) {
  animation: fadeIn 0.6s ease-out 0.4s forwards;
}

.stagger-children.animate > *:nth-child(5) {
  animation: fadeIn 0.6s ease-out 0.5s forwards;
}

.stagger-children.animate > *:nth-child(6) {
  animation: fadeIn 0.6s ease-out 0.6s forwards;
}

.stagger-children.animate > *:nth-child(7) {
  animation: fadeIn 0.6s ease-out 0.7s forwards;
}

.stagger-children.animate > *:nth-child(8) {
  animation: fadeIn 0.6s ease-out 0.8s forwards;
}

/* ===== Loading Animations ===== */

.loading-shimmer {
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0) 0%,
    rgba(255, 255, 255, 0.4) 50%,
    rgba(255, 255, 255, 0) 100%
  );
  background-size: 200% 100%;
  animation: shimmer 2s infinite;
}

.loading-skeleton {
  background: linear-gradient(
    90deg,
    var(--bg-tertiary) 25%,
    var(--bg-primary) 50%,
    var(--bg-tertiary) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 2s infinite;
  border-radius: var(--radius-md);
}

.loading-dots::after {
  content: "";
  animation: loadingDots 1.5s infinite;
}

@keyframes loadingDots {
  0%,
  20% {
    content: ".";
  }
  40% {
    content: "..";
  }
  60%,
  100% {
    content: "...";
  }
}

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 4px solid rgba(102, 126, 234, 0.2);
  border-top: 4px solid var(--primary-color);
  border-radius: 50%;
  animation: rotate 1s linear infinite;
  margin: 0 auto;
}

.loading-spinner.small {
  width: 20px;
  height: 20px;
  border-width: 2px;
}

.loading-spinner.large {
  width: 60px;
  height: 60px;
  border-width: 6px;
}

/* ===== Interactive Animations ===== */

.btn-ripple {
  position: relative;
  overflow: hidden;
}

.btn-ripple::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.3);
  transform: translate(-50%, -50%);
  transition: width 0.6s, height 0.6s;
}

.btn-ripple:active::before {
  width: 300px;
  height: 300px;
}

.hover-lift {
  transition: transform var(--transition-normal),
    box-shadow var(--transition-normal);
}

.hover-lift:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
}

.hover-scale {
  transition: transform var(--transition-fast);
}

.hover-scale:hover {
  transform: scale(1.05);
}

.hover-rotate {
  transition: transform var(--transition-normal);
}

.hover-rotate:hover {
  transform: rotate(5deg);
}

.hover-glow {
  transition: box-shadow var(--transition-normal);
}

.hover-glow:hover {
  box-shadow: 0 0 20px rgba(102, 126, 234, 0.4);
}

/* ===== Page Transition Animations ===== */

.page-enter {
  opacity: 0;
  transform: translateX(100px);
}

.page-enter-active {
  opacity: 1;
  transform: translateX(0);
  transition: opacity 0.3s ease-out, transform 0.3s ease-out;
}

.page-exit {
  opacity: 1;
  transform: translateX(0);
}

.page-exit-active {
  opacity: 0;
  transform: translateX(-100px);
  transition: opacity 0.3s ease-out, transform 0.3s ease-out;
}

/* ===== Filter Animations ===== */

.filter-enter {
  opacity: 0;
  transform: scale(0.8) translateY(-20px);
}

.filter-enter-active {
  opacity: 1;
  transform: scale(1) translateY(0);
  transition: all 0.3s ease-out;
}

.filter-exit {
  opacity: 1;
  transform: scale(1) translateY(0);
}

.filter-exit-active {
  opacity: 0;
  transform: scale(0.8) translateY(-20px);
  transition: all 0.2s ease-out;
}

/* ===== Game Card Entry Animations ===== */

.game-card-enter {
  opacity: 0;
  transform: scale(0.8) rotateY(90deg);
}

.game-card-enter-active {
  opacity: 1;
  transform: scale(1) rotateY(0deg);
  transition: all 0.6s ease-out;
}

.game-card-exit {
  opacity: 1;
  transform: scale(1) rotateY(0deg);
}

.game-card-exit-active {
  opacity: 0;
  transform: scale(0.8) rotateY(-90deg);
  transition: all 0.4s ease-out;
}

/* ===== Notification Animations ===== */

.notification-enter {
  opacity: 0;
  transform: translateX(100%);
}

.notification-enter-active {
  opacity: 1;
  transform: translateX(0);
  transition: all 0.3s ease-out;
}

.notification-exit {
  opacity: 1;
  transform: translateX(0);
}

.notification-exit-active {
  opacity: 0;
  transform: translateX(100%);
  transition: all 0.3s ease-out;
}

/* ===== Modal Animations ===== */

.modal-backdrop {
  background: rgba(0, 0, 0, 0.5);
  transition: opacity var(--transition-normal);
}

.modal-backdrop.entering {
  opacity: 0;
}

.modal-backdrop.entered {
  opacity: 1;
}

.modal-backdrop.exiting {
  opacity: 0;
}

.modal-content {
  transition: transform var(--transition-normal),
    opacity var(--transition-normal);
}

.modal-content.entering {
  opacity: 0;
  transform: scale(0.8) translateY(-50px);
}

.modal-content.entered {
  opacity: 1;
  transform: scale(1) translateY(0);
}

.modal-content.exiting {
  opacity: 0;
  transform: scale(0.8) translateY(-50px);
}

/* ===== Reduced Motion Support ===== */

@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-bounce,
  .animate-float,
  .animate-pulse,
  .animate-rotate {
    animation: none;
  }

  .loading-spinner {
    border-color: var(--primary-color);
    border-top-color: transparent;
  }

  .hover-lift:hover,
  .hover-scale:hover,
  .hover-rotate:hover {
    transform: none;
  }
}

/* ===== Performance Optimizations ===== */

.animate-gpu {
  transform: translateZ(0);
  backface-visibility: hidden;
  perspective: 1000px;
}

.will-change-transform {
  will-change: transform;
}

.will-change-opacity {
  will-change: opacity;
}

.will-change-auto {
  will-change: auto;
}

/* ===== Custom Easing Functions ===== */

.ease-spring {
  transition-timing-function: cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.ease-bounce {
  transition-timing-function: cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.ease-elastic {
  transition-timing-function: cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.ease-back {
  transition-timing-function: cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ===== Utility Animation Classes ===== */

.delay-100 {
  animation-delay: 0.1s;
}
.delay-200 {
  animation-delay: 0.2s;
}
.delay-300 {
  animation-delay: 0.3s;
}
.delay-400 {
  animation-delay: 0.4s;
}
.delay-500 {
  animation-delay: 0.5s;
}

.duration-fast {
  animation-duration: 0.15s;
}
.duration-normal {
  animation-duration: 0.3s;
}
.duration-slow {
  animation-duration: 0.5s;
}
.duration-slower {
  animation-duration: 1s;
}

.animate-infinite {
  animation-iteration-count: infinite;
}
.animate-once {
  animation-iteration-count: 1;
}
.animate-twice {
  animation-iteration-count: 2;
}

.animate-forwards {
  animation-fill-mode: forwards;
}
.animate-backwards {
  animation-fill-mode: backwards;
}
.animate-both {
  animation-fill-mode: both;
}
