/**
 * Microinteractions CSS
 * Animations and effects for delightful user feedback
 */

/* Ripple Effect */
@keyframes ripple-animation {
  to {
    transform: scale(4);
    opacity: 0;
  }
}

.ripple {
  position: absolute;
  background: rgba(255, 255, 255, 0.5);
  border-radius: 50%;
  transform: scale(0);
  animation: ripple-animation 0.6s ease-out;
  pointer-events: none;
}

/* Button Press Effect */
button, .btn, .clickable {
  transition: all 0.15s ease;
  position: relative;
  overflow: hidden;
  transform-style: preserve-3d;
}

button:active, .btn:active, .clickable:active {
  transform: scale(0.95) translateZ(0);
}

/* Success Animation */
@keyframes success-pulse {
  0% { 
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(40, 167, 69, 0.7);
  }
  50% { 
    transform: scale(1.05);
    box-shadow: 0 0 0 10px rgba(40, 167, 69, 0);
  }
  100% { 
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(40, 167, 69, 0);
  }
}

.success-animation {
  animation: success-pulse 0.5s ease-out !important;
}

/* Error Shake */
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  10%, 30%, 50%, 70%, 90% { transform: translateX(-10px); }
  20%, 40%, 60%, 80% { transform: translateX(10px); }
}

.error-shake {
  animation: shake 0.5s ease-in-out !important;
}

/* Loading Spinner */
@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.loading-spinner {
  display: inline-block;
  margin-left: 8px;
  animation: spin 1s linear infinite;
  vertical-align: middle;
}

.loading-spinner svg {
  vertical-align: middle;
  display: inline-block;
}

/* Loading Button State */
button.loading {
  position: relative;
  color: transparent !important;
  pointer-events: none;
}

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

/* Skeleton Loading */
@keyframes skeleton-loading {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.skeleton {
  background: linear-gradient(
    90deg,
    #f0f0f0 25%,
    #e0e0e0 50%,
    #f0f0f0 75%
  );
  background-size: 200% 100%;
  animation: skeleton-loading 1.5s ease-in-out infinite;
  border-radius: 4px;
}

.skeleton-text {
  height: 12px;
  margin: 8px 0;
  border-radius: 4px;
}

.skeleton-button {
  height: 36px;
  width: 100px;
  border-radius: 18px;
}

.skeleton-card {
  height: 120px;
  margin: 16px 0;
  border-radius: 8px;
}

/* Tab Transitions */
@keyframes slide-in {
  from {
    opacity: 0;
    transform: translateX(20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

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

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.tab-content {
  animation: fade-in 0.3s ease-out;
}

.slide-transition {
  animation: slide-in 0.3s ease-out;
}

/* Game Card Hover Effects */
.game-card {
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  transform-origin: center;
}

.game-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
}

/* Join Button Special Effects */
@keyframes join-pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(0, 123, 255, 0.7);
  }
  70% {
    box-shadow: 0 0 0 10px rgba(0, 123, 255, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(0, 123, 255, 0);
  }
}

.join-button {
  position: relative;
  overflow: hidden;
  transition: all 0.3s ease;
}

.join-button:hover {
  transform: scale(1.05);
  animation: join-pulse 1.5s infinite;
}

/* Achievement Popup */
@keyframes slide-in-right {
  from {
    opacity: 0;
    transform: translateX(100%);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes slide-out-right {
  from {
    opacity: 1;
    transform: translateX(0);
  }
  to {
    opacity: 0;
    transform: translateX(100%);
  }
}

.achievement-popup {
  animation: slide-in-right 0.5s ease-out;
}

/* Particle Container */
.particle-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 10000;
}

/* Progress Ring */
.progress-ring {
  transform: rotate(-90deg);
}

.progress-ring-circle {
  fill: none;
  stroke: #e0e0e0;
  stroke-width: 2;
}

.progress-ring-progress {
  fill: none;
  stroke: #007bff;
  stroke-width: 2;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.3s ease;
}

/* Form Input Focus Effects */
input:focus,
textarea:focus,
select:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.25);
  transition: box-shadow 0.2s ease;
}

/* Toggle Switch Animation */
.toggle-switch {
  position: relative;
  width: 50px;
  height: 26px;
  background: #ccc;
  border-radius: 13px;
  transition: background 0.3s ease;
  cursor: pointer;
}

.toggle-switch.active {
  background: #4CAF50;
}

.toggle-switch::after {
  content: '';
  position: absolute;
  width: 22px;
  height: 22px;
  background: white;
  border-radius: 50%;
  top: 2px;
  left: 2px;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.toggle-switch.active::after {
  transform: translateX(24px);
}

/* Notification Badge Animation */
@keyframes badge-pop {
  0% { transform: scale(0); }
  50% { transform: scale(1.2); }
  100% { transform: scale(1); }
}

.notification-badge {
  animation: badge-pop 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

/* Card Flip Animation */
@keyframes card-flip {
  0% { transform: rotateY(0); }
  100% { transform: rotateY(180deg); }
}

.card-flip {
  animation: card-flip 0.6s ease-in-out;
  transform-style: preserve-3d;
}

/* Bounce Animation for CTAs */
@keyframes bounce {
  0%, 20%, 50%, 80%, 100% { transform: translateY(0); }
  40% { transform: translateY(-20px); }
  60% { transform: translateY(-10px); }
}

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

/* Pulse Animation for Live Indicators */
@keyframes pulse-dot {
  0% {
    transform: scale(0.95);
    box-shadow: 0 0 0 0 rgba(255, 82, 82, 0.7);
  }
  70% {
    transform: scale(1);
    box-shadow: 0 0 0 10px rgba(255, 82, 82, 0);
  }
  100% {
    transform: scale(0.95);
    box-shadow: 0 0 0 0 rgba(255, 82, 82, 0);
  }
}

.live-indicator {
  width: 8px;
  height: 8px;
  background: #ff5252;
  border-radius: 50%;
  display: inline-block;
  animation: pulse-dot 2s infinite;
}

/* Smooth Number Transitions */
.number-transition {
  transition: all 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Mobile Touch Feedback */
@media (hover: none) {
  button:active,
  .btn:active,
  .clickable:active {
    transform: scale(0.97);
    transition: transform 0.1s ease;
  }
}

/* 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;
  }
  
  .skeleton {
    animation: none;
    background: #f0f0f0;
  }
}

/* Dark Mode Adjustments */
@media (prefers-color-scheme: dark) {
  .ripple {
    background: rgba(255, 255, 255, 0.3);
  }
  
  .skeleton {
    background: linear-gradient(
      90deg,
      #2a2a2a 25%,
      #3a3a3a 50%,
      #2a2a2a 75%
    );
  }
  
  input:focus,
  textarea:focus,
  select:focus {
    box-shadow: 0 0 0 3px rgba(100, 149, 237, 0.35);
  }
}