/* Optimized Button Hover Effects - Performance Focused */

/* Base button styles with hardware acceleration */
.btn {
  position: relative;
  text-decoration: none;
  transition: all 0.2s ease; /* Reduced from 0.3s */
  transform: translate3d(0, 0, 0); /* Enable hardware acceleration */
  will-change: transform, opacity; /* Hint to browser for optimization */
  backface-visibility: hidden; /* Prevent flickering */
}

/* Primary button styles */
.primary-btn {
  background-color: var(--primary);
  color: white;
}

.primary-btn:hover {
  background-color: var(--accent);
  transform: translate3d(0, -1px, 0); /* Reduced from -3px */
  opacity: 0.95;
}

.primary-btn:active {
  transform: translate3d(0, 0, 0);
  opacity: 1;
}

/* Secondary button styles */
.secondary-btn {
  background-color: transparent;
  color: var(--primary);
  border: 2px solid var(--primary);
}

.secondary-btn:hover {
  background-color: var(--primary);
  color: white;
  transform: translate3d(0, -1px, 0); /* Reduced from -3px */
  opacity: 0.95;
}

.secondary-btn:active {
  transform: translate3d(0, 0, 0);
  opacity: 1;
}

/* Small button variant */
.small-btn {
  padding: 8px 15px;
  font-size: 0.9rem;
}

/* Focus states for accessibility */
.btn:focus {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  transform: translate3d(0, -1px, 0);
}

/* Loading state */
.btn.loading {
  opacity: 0.7;
  cursor: not-allowed;
  pointer-events: none;
}

.btn.loading::after {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  margin: auto;
  border: 2px solid transparent;
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

/* Optimized spinner animation */
@keyframes spin {
  0% {
    transform: translate(-50%, -50%) rotate(0deg);
  }
  100% {
    transform: translate(-50%, -50%) rotate(360deg);
  }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
  .btn {
    transition: all 0.1s ease; /* Faster transitions on touch */
  }

  .btn:hover {
    transform: none; /* Remove hover transforms on touch devices */
  }

  .btn:active {
    transform: scale(0.98);
    opacity: 0.8;
  }
}

/* Reduced motion preferences */
@media (prefers-reduced-motion: reduce) {
  .btn {
    transition: color 0.2s ease, background-color 0.2s ease;
    transform: none !important;
    animation: none !important;
  }

  .btn:hover,
  .btn:focus,
  .btn:active {
    transform: none !important;
  }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  .btn {
    border: 2px solid currentColor;
  }
}

/* Performance optimizations for older devices */
@media (max-width: 768px) {
  .btn {
    transition: background-color 0.15s ease, color 0.15s ease;
    will-change: auto; /* Reduce will-change on mobile */
  }

  .btn:hover {
    transform: none; /* Remove transforms on mobile for better performance */
  }
}

/* Remove expensive effects on very small screens */
@media (max-width: 480px) {
  .btn {
    transition: opacity 0.1s ease;
  }

  .btn:hover {
    opacity: 0.8;
    transform: none;
  }
}
