/* INP Optimizations for CasinoRankr - Mobile-First Performance */

/* ===== CRITICAL INP OPTIMIZATIONS ===== */

/* 1. Optimize touch targets for mobile */
.voting button,
.upvote,
.downvote,
.thumbs-up,
.thumbs-down,
.play-now-button,
.signup-button,
.casino-cta,
.location-casino-btn {
  /* Minimum 44px touch target for mobile accessibility */
  min-width: 44px;
  min-height: 44px;
  
  /* Use transform for better performance */
  transform: translateZ(0);
  backface-visibility: hidden;
  will-change: transform;
  
  /* Optimize transitions for better INP - reduced duration */
  transition: transform 0.08s ease, background-color 0.15s ease, opacity 0.1s ease;
  
  /* Improve touch responsiveness */
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  
  /* Prevent text selection on mobile */
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  
  /* Hardware acceleration for better performance */
  -webkit-transform: translateZ(0);
  -moz-transform: translateZ(0);
  -ms-transform: translateZ(0);
  transform: translateZ(0);
}

/* 2. Immediate visual feedback for critical interactions - faster response */
.voting button:active,
.upvote:active,
.downvote:active,
.thumbs-up:active,
.thumbs-down:active,
.play-now-button:active,
.signup-button:active,
.casino-cta:active,
.location-casino-btn:active {
  transform: scale(0.96) translateZ(0);
  transition: transform 0.03s ease;
}

/* 3. JavaScript-controlled interaction states for immediate feedback */
.touch-active {
  transform: scale(0.98) translateZ(0) !important;
  transition: transform 0.05s ease !important;
}

.click-active {
  transform: scale(0.95) translateZ(0) !important;
  transition: transform 0.08s ease !important;
  background-color: rgba(74, 159, 255, 0.1) !important;
}

.focus-active {
  outline: 2px solid var(--primary-color) !important;
  outline-offset: 2px !important;
  box-shadow: 0 0 0 4px rgba(74, 159, 255, 0.1) !important;
}

.keyboard-active {
  transform: scale(0.97) translateZ(0) !important;
  transition: transform 0.06s ease !important;
  background-color: rgba(74, 159, 255, 0.15) !important;
}

/* 4. Optimize hover states for desktop (disabled on touch devices) */
@media (hover: hover) {
  .voting button:hover,
  .upvote:hover,
  .downvote:hover,
  .thumbs-up:hover,
  .thumbs-down:hover,
  .play-now-button:hover,
  .signup-button:hover,
  .casino-cta:hover,
  .location-casino-btn:hover {
    transform: translateY(-1px) translateZ(0);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  }
}

/* 5. Disable hover effects on touch devices */
@media (hover: none) {
  .voting button:hover,
  .upvote:hover,
  .downvote:hover,
  .thumbs-up:hover,
  .thumbs-down:hover,
  .play-now-button:hover,
  .signup-button:hover,
  .casino-cta:hover,
  .location-casino-btn:hover {
    transform: none;
    box-shadow: none;
  }
}

/* ===== FILTER INTERACTIONS OPTIMIZATION ===== */

/* 6. Optimize filter interactions */
select,
input[type="search"],
input[type="text"] {
  /* Use transform for better performance */
  transform: translateZ(0);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  
  /* Improve touch targets */
  min-height: 44px;
  padding: 12px 16px;
  
  /* Prevent iOS zoom on focus */
  font-size: 16px;
  
  /* Hardware acceleration */
  -webkit-transform: translateZ(0);
  -moz-transform: translateZ(0);
  -ms-transform: translateZ(0);
  transform: translateZ(0);
}

/* 7. Optimize focus states for better INP */
select:focus,
input[type="search"]:focus,
input[type="text"]:focus {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(74, 159, 255, 0.1);
}

/* ===== GLOBAL PERFORMANCE OPTIMIZATIONS ===== */

/* 8. Optimize scrolling performance */
html {
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}

body {
  /* Optimize for mobile performance */
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeSpeed;
}

/* 9. Optimize casino card interactions */
.casino {
  /* Hardware acceleration for all casino cards */
  transform: translateZ(0);
  backface-visibility: hidden;
  will-change: transform;
  
  /* Optimize transitions */
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  
  /* Prevent layout shifts */
  contain: layout style paint;
}

.casino:active {
  transform: scale(0.98) translateZ(0);
  transition: transform 0.05s ease;
}

/* Casino interaction states */
.casino.touch-active {
  transform: scale(0.99) translateZ(0) !important;
  transition: transform 0.05s ease !important;
}

.casino.click-active {
  transform: scale(0.97) translateZ(0) !important;
  transition: transform 0.08s ease !important;
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2) !important;
}

.casino.focus-active {
  outline: 2px solid var(--primary-color) !important;
  outline-offset: 2px !important;
  box-shadow: 0 0 0 4px rgba(74, 159, 255, 0.1) !important;
}

/* ===== VOTING SYSTEM OPTIMIZATIONS ===== */

/* 10. Optimize voting button performance */
.voting button {
  /* Hardware acceleration */
  transform: translateZ(0);
  backface-visibility: hidden;
  will-change: transform, opacity;
  
  /* Faster transitions for better INP */
  transition: transform 0.08s ease, opacity 0.1s ease, background-color 0.15s ease;
  
  /* Prevent layout shifts */
  contain: layout style paint;
}

.voting button:active {
  transform: scale(0.94) translateZ(0);
  transition: transform 0.03s ease;
}

.voting button.active {
  transform: translateZ(0);
  transition: all 0.1s ease;
}

.voting button.voting {
  pointer-events: none;
  opacity: 0.7;
}

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

/* Voting button interaction states */
.voting button.touch-active {
  transform: scale(0.96) translateZ(0) !important;
  transition: transform 0.05s ease !important;
}

.voting button.click-active {
  transform: scale(0.92) translateZ(0) !important;
  transition: transform 0.08s ease !important;
  background-color: rgba(74, 159, 255, 0.15) !important;
}

.voting button.focus-active {
  outline: 2px solid var(--primary-color) !important;
  outline-offset: 2px !important;
  box-shadow: 0 0 0 4px rgba(74, 159, 255, 0.1) !important;
}

.voting button.keyboard-active {
  transform: scale(0.94) translateZ(0) !important;
  transition: transform 0.06s ease !important;
  background-color: rgba(74, 159, 255, 0.2) !important;
}

/* 11. Optimize vote feedback animations */
.vote-toast {
  /* Hardware acceleration */
  transform: translateZ(0);
  backface-visibility: hidden;
  will-change: transform, opacity;
  
  /* Faster animations */
  animation: fadeInUp 0.2s ease, fadeOut 0.15s ease 2s forwards;
  
  /* Prevent layout shifts */
  contain: layout style paint;
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(10px) translateZ(0);
  }
  to {
    opacity: 1;
    transform: translateY(0) translateZ(0);
  }
}

/* ===== ACCESSIBILITY AND FOCUS OPTIMIZATIONS ===== */

/* 11. Optimize focus indicators for better INP */
button:focus-visible,
select:focus-visible,
input:focus-visible {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
  transition: outline 0.1s ease;
}

button:focus:not(:focus-visible),
select:focus:not(:focus-visible),
input:focus:not(:focus-visible) {
  outline: none;
}

/* 12. Optimize disabled states */
button:disabled,
select:disabled,
input:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  pointer-events: none;
  transform: translateZ(0);
}

/* ===== MOBILE-SPECIFIC OPTIMIZATIONS ===== */

@media (max-width: 768px) {
  /* 13. Enhanced mobile touch targets */
  .voting button,
  .play-now-button,
  .signup-button,
  .casino-cta {
    min-width: 48px;
    min-height: 48px;
    padding: 12px;
    
    /* Faster touch response */
    transition: transform 0.06s ease, background-color 0.12s ease;
  }
  
  /* 14. Optimize casino card interactions on mobile */
  .casino {
    /* Reduce transition duration for mobile */
    transition: transform 0.12s ease, box-shadow 0.12s ease;
  }
  
  /* 15. Optimize form elements on mobile */
  select,
  input[type="search"] {
    min-height: 48px;
    font-size: 16px;
    padding: 14px 16px;
  }
  
  /* 16. Optimize navigation interactions */
  .mobile-nav-link {
    min-height: 48px;
    padding: 12px 16px;
    transition: background-color 0.1s ease;
  }
  
  /* 17. Optimize social icon interactions */
  .mobile-header-social a {
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.08s ease;
  }
  
  /* Mobile-specific interaction states */
  .touch-active {
    transform: scale(0.97) translateZ(0) !important;
    transition: transform 0.04s ease !important;
  }
  
  .click-active {
    transform: scale(0.93) translateZ(0) !important;
    transition: transform 0.06s ease !important;
  }
  
  .keyboard-active {
    transform: scale(0.95) translateZ(0) !important;
    transition: transform 0.05s ease !important;
  }
}

/* ===== 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;
  }
  
  .voting button:active,
  .play-now-button:active,
  .signup-button:active,
  .casino-cta:active,
  .touch-active,
  .click-active,
  .keyboard-active {
    transform: none;
    transition: none;
  }
}

/* ===== HIGH CONTRAST SUPPORT ===== */

@media (prefers-contrast: high) {
  .voting button,
  .play-now-button,
  .signup-button,
  .casino-cta {
    border: 2px solid currentColor;
    background-color: transparent;
    color: currentColor;
  }
  
  .voting button:focus-visible,
  .play-now-button:focus-visible,
  .signup-button:focus-visible,
  .casino-cta:focus-visible,
  .focus-active {
    outline: 3px solid currentColor;
    outline-offset: 2px;
  }
}

/* ===== PERFORMANCE MONITORING ===== */

/* 18. Add performance monitoring classes */
.voting button,
.play-now-button,
.signup-button,
.casino-cta {
  /* Add data attribute for performance monitoring */
  position: relative;
}

/* 19. Optimize mobile navigation performance */
.mobile-nav {
  /* Hardware acceleration */
  transform: translateZ(0);
  backface-visibility: hidden;
  will-change: transform;
}

/* 20. Optimize body scrolling */
body {
  /* Optimize scroll performance */
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
}

/* 21. Optimize search input performance */
input[type="search"] {
  /* Prevent layout shifts */
  contain: layout style paint;
}

/* 22. Optimize select dropdown performance */
select {
  /* Hardware acceleration */
  transform: translateZ(0);
  backface-visibility: hidden;
}

/* ===== ANIMATION OPTIMIZATIONS ===== */

@keyframes scoreUpdate {
  0% {
    transform: scale(1) translateZ(0);
  }
  50% {
    transform: scale(1.1) translateZ(0);
  }
  100% {
    transform: scale(1) translateZ(0);
  }
}

.vote-count {
  /* Hardware acceleration for vote count animations */
  transform: translateZ(0);
  backface-visibility: hidden;
  will-change: transform;
}

@keyframes cooldownPulse {
  0%, 100% {
    opacity: 1;
    transform: scale(1) translateZ(0);
  }
  50% {
    opacity: 0.7;
    transform: scale(0.95) translateZ(0);
  }
}

.voting button.cooldown {
  animation: cooldownPulse 1s ease-in-out infinite;
  pointer-events: none;
}

/* ===== LOADING STATE OPTIMIZATIONS ===== */

.voting {
  /* Optimize loading states */
  position: relative;
  contain: layout style paint;
}

.vote-count {
  /* Hardware acceleration for vote counts */
  transform: translateZ(0);
  backface-visibility: hidden;
}

.voting button.loading {
  pointer-events: none;
  opacity: 0.8;
}

.voting button.loading::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 14px;
  height: 14px;
  margin: -7px 0 0 -7px;
  border: 2px solid transparent;
  border-top: 2px solid currentColor;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

/* ===== SHIMMER LOADING OPTIMIZATION ===== */

@keyframes loadingShimmer {
  0% {
    background-position: -200px 0;
  }
  100% {
    background-position: calc(200px + 100%) 0;
  }
}

.voting button,
.play-now-button,
.signup-button,
.casino-cta {
  /* Optimize loading states */
  position: relative;
  overflow: hidden;
}

.voting button.loading::before,
.play-now-button.loading::before,
.signup-button.loading::before,
.casino-cta.loading::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.1), transparent);
  background-size: 200px 100%;
  animation: loadingShimmer 1.5s infinite;
}

/* ===== MOBILE GRID OPTIMIZATIONS ===== */

@media (max-width: 768px) {
  /* 23. Optimize casino grid performance */
  .voting button,
  .play-now-button,
  .signup-button,
  .casino-cta {
    /* Reduce transition duration for mobile */
    transition: transform 0.08s ease, background-color 0.12s ease;
  }
  
  /* 24. Optimize grid layout performance */
  .casino-grid,
  .featured-casino-list {
    /* Hardware acceleration for grid containers */
    transform: translateZ(0);
    backface-visibility: hidden;
    will-change: transform;
  }
}

/* ===== FOCUS MANAGEMENT OPTIMIZATIONS ===== */

.voting button:focus-visible,
.play-now-button:focus-visible,
.signup-button:focus-visible,
.casino-cta:focus-visible {
  /* Optimize focus indicators */
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
  box-shadow: 0 0 0 4px rgba(74, 159, 255, 0.1);
  transition: outline 0.1s ease, box-shadow 0.1s ease;
}

/* ===== ACCESSIBILITY ENHANCEMENTS ===== */

.voting button[aria-label] {
  /* Ensure proper accessibility */
  position: relative;
}

.voting button[aria-label]::before {
  content: attr(aria-label);
  position: absolute;
  top: -30px;
  left: 50%;
  transform: translateX(-50%) translateZ(0);
  background: rgba(0, 0, 0, 0.8);
  color: white;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 12px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
  z-index: 1000;
}

/* ===== SMALL SCREEN OPTIMIZATIONS ===== */

@media (max-width: 480px) {
  /* 25. Further optimize for very small screens */
  .voting button,
  .play-now-button,
  .signup-button,
  .casino-cta {
    min-width: 44px;
    min-height: 44px;
    padding: 10px;
    
    /* Even faster transitions for small screens */
    transition: transform 0.05s ease, background-color 0.1s ease;
  }
  
  .voting button:active,
  .play-now-button:active,
  .signup-button:active,
  .casino-cta:active {
    transform: scale(0.95) translateZ(0);
    transition: transform 0.02s ease;
  }
  
  /* Small screen interaction states */
  .touch-active {
    transform: scale(0.98) translateZ(0) !important;
    transition: transform 0.03s ease !important;
  }
  
  .click-active {
    transform: scale(0.94) translateZ(0) !important;
    transition: transform 0.05s ease !important;
  }
  
  .keyboard-active {
    transform: scale(0.96) translateZ(0) !important;
    transition: transform 0.04s ease !important;
  }
}

/* ===== HIGH DPI OPTIMIZATIONS ===== */

@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  /* 26. Optimize for high DPI displays */
  .voting button,
  .play-now-button,
  .signup-button,
  .casino-cta {
    /* Ensure crisp rendering on high DPI */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
  }
} 