/* Enhanced UI Styles for Itch.io Highlights - W33Keys */
/* CSS Variables for Dark/Light Mode Toggle */
:root {
  --color-bg: #111827;
  --color-bg-secondary: #1f2937;
  --color-bg-tertiary: #374151;
  --color-fg: #f9fafb;
  --color-fg-secondary: #d1d5db;
  --color-fg-muted: #9ca3af;
  --color-accent: #8b5cf6;
  --color-accent-hover: #7c3aed;
  --color-success: #10b981;
  --color-warning: #f59e0b;
  --color-error: #ef4444;
  --color-itch: #fa5c5c;
  --border-radius: 0.75rem;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
}

/* Enhanced Grid Layout */
.grid-enhanced {
  margin-top: 2rem;
}

/* Content grid uses CSS Grid with flexible card sizing */
#content-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
  gap: 2rem;
  width: 100%;
}

/* Mobile responsive adjustment */
@media (max-width: 640px) {
  #content-grid {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }
}

@media (min-width: 768px) {
  .grid-enhanced {
    margin-top: 2.5rem;
  }
  
  #content-grid {
    gap: 2.5rem;
  }
}

/* Light Mode */
[data-theme="light"] {
  --color-bg: #ffffff;
  --color-bg-secondary: #f9fafb;
  --color-bg-tertiary: #e5e7eb;
  --color-fg: #111827;
  --color-fg-secondary: #374151;
  --color-fg-muted: #6b7280;
}

/* Accessibility: Respect user's motion preferences */
@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;
  }
}

/* Enhanced Hero Section */
.hero-enhanced {
  background: linear-gradient(135deg, var(--color-bg) 0%, #4c1d95 50%, var(--color-bg) 100%);
  position: relative;
  overflow: hidden;
}

.hero-enhanced::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: radial-gradient(circle at 50% 50%, rgba(139, 92, 246, 0.1) 0%, transparent 70%);
  pointer-events: none;
}

.hero-title {
  font-size: clamp(2.5rem, 8vw, 5rem);
  line-height: 1.1;
  font-weight: 800;
  background: linear-gradient(135deg, var(--color-fg) 0%, var(--color-accent) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero-subtitle {
  font-size: clamp(1.25rem, 4vw, 1.75rem);
  line-height: 1.6;
  color: var(--color-fg-secondary);
  max-width: 42rem;
  margin: 0 auto;
}

/* Enhanced Button Styles */
.btn-enhanced {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 1rem 2rem;
  font-size: 1.125rem;
  font-weight: 600;
  border-radius: var(--border-radius);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  text-decoration: none;
  border: none;
  cursor: pointer;
  min-width: 180px;
  position: relative;
  overflow: hidden;
}

.btn-enhanced:focus {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

.btn-primary {
  background: var(--color-itch);
  color: white;
  box-shadow: var(--shadow-md);
}

.btn-primary:hover {
  background: #e53e3e;
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.btn-secondary {
  background: var(--color-accent);
  color: white;
  box-shadow: var(--shadow-md);
}

.btn-secondary:hover {
  background: var(--color-accent-hover);
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

/* Enhanced Filter Tabs */
.filter-tabs {
  background: var(--color-bg-secondary);
  border-radius: var(--border-radius);
  padding: 0.5rem;
  display: flex;
  gap: 0.25rem;
}

.filter-tab {
  flex: 1;
  padding: 0.75rem 1.5rem;
  border-radius: calc(var(--border-radius) - 0.25rem);
  font-weight: 600;
  text-align: center;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
  border: none;
  background: transparent;
  color: var(--color-fg-muted);
  position: relative;
}

.filter-tab:hover {
  color: var(--color-fg-secondary);
  background: var(--color-bg-tertiary);
}

.filter-tab.active {
  background: var(--color-accent);
  color: white;
  box-shadow: var(--shadow-sm);
}

.filter-tab:focus {
  outline: 2px solid var(--color-accent);
  outline-offset: -2px;
}

/* Enhanced Search and Filter Controls */
.search-enhanced {
  position: relative;
  min-width: 300px;
}

.search-enhanced input {
  width: 100%;
  padding: 1rem 1rem 1rem 3rem;
  background: var(--color-bg-secondary);
  border: 2px solid var(--color-bg-tertiary);
  border-radius: var(--border-radius);
  color: var(--color-fg);
  font-size: 1rem;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.search-enhanced input:focus {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.1);
}

.search-enhanced .search-icon {
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--color-fg-muted);
  pointer-events: none;
}

.select-enhanced {
  padding: 1rem;
  background: var(--color-bg-secondary);
  border: 2px solid var(--color-bg-tertiary);
  border-radius: var(--border-radius);
  color: var(--color-fg);
  font-size: 1rem;
  min-width: 180px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.select-enhanced:focus {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.1);
}

/* Enhanced Card Styles */
.card-enhanced {
  background: var(--color-bg-secondary);
  border-radius: var(--border-radius);
  overflow: hidden;
  box-shadow: var(--shadow-md);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  cursor: pointer;
  border: 1px solid var(--color-bg-tertiary);
}

.card-enhanced:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-xl);
  border-color: var(--color-accent);
}

.card-enhanced:focus {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

.card-image {
  width: 100%;
  height: 200px;
  object-fit: cover;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.card-enhanced:hover .card-image {
  transform: scale(1.05);
}

.card-content {
  padding: 2rem;
}

.card-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--color-fg);
  margin-bottom: 0.5rem;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-description {
  color: var(--color-fg-secondary);
  font-size: 0.95rem;
  line-height: 1.6;
  margin-bottom: 1rem;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Enhanced Badge System */
.badges-container {
  position: absolute;
  top: 1.5rem;
  left: 1.5rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  z-index: 10;
}

.badge-enhanced {
  padding: 0.375rem 0.75rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(8px);
}

.badge-game {
  background: rgba(16, 185, 129, 0.9);
  color: white;
}

.badge-asset {
  background: rgba(139, 92, 246, 0.9);
  color: white;
}

.badge-featured {
  background: rgba(245, 158, 11, 0.9);
  color: white;
}

.badge-free {
  background: rgba(34, 197, 94, 0.9);
  color: white;
}

.badge-sale {
  background: rgba(239, 68, 68, 0.9);
  color: white;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.8; }
}

/* Price Display */
.price-container {
  display: flex;
  flex-direction: column;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--color-bg-tertiary);
}

.price-display {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--color-success);
  margin-bottom: 0.75rem;
  text-align: center;
}

.price-original {
  text-decoration: line-through;
  color: var(--color-fg-muted);
  font-size: 1rem;
  margin-right: 0.5rem;
}

.price-sale {
  color: var(--color-error);
}

/* Card Button Styles */
.card-enhanced button {
  min-height: 40px;
  font-weight: 600;
  letter-spacing: 0.025em;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.card-enhanced button:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.card-enhanced button:active {
  transform: translateY(0);
}

/* Favorite Button */
.favorite-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.5rem;
  border-radius: 50%;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  color: var(--color-fg-muted);
}

.favorite-btn:hover {
  color: var(--color-error);
  background: rgba(239, 68, 68, 0.1);
}

.favorite-btn.favorited {
  color: var(--color-error);
}

.favorite-btn:focus {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

/* Dark Mode Toggle */
.theme-toggle {
  background: var(--color-bg-secondary);
  border: 2px solid var(--color-bg-tertiary);
  border-radius: 9999px;
  padding: 0.5rem;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  color: var(--color-fg);
}

.theme-toggle:hover {
  border-color: var(--color-accent);
}

.theme-toggle:focus {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

/* Enhanced Grid Layout */
.grid-enhanced {
  margin-top: 2rem;
}

/* Content grid uses Tailwind classes for responsive layout:
   grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-6 */

@media (min-width: 768px) {
  .grid-enhanced {
    margin-top: 2.5rem;
  }
}

/* Loading States */
.loading-enhanced {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4rem 2rem;
  color: var(--color-fg-muted);
}

.spinner-enhanced {
  width: 3rem;
  height: 3rem;
  border: 3px solid var(--color-bg-tertiary);
  border-top: 3px solid var(--color-accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 1rem;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Tooltip Styles */
.tooltip {
  position: relative;
  display: inline-block;
}

.tooltip::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 125%;
  left: 50%;
  transform: translateX(-50%);
  background: var(--color-bg);
  color: var(--color-fg);
  padding: 0.5rem 0.75rem;
  border-radius: 0.375rem;
  font-size: 0.875rem;
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: var(--shadow-lg);
  z-index: 1000;
}

.tooltip::before {
  content: '';
  position: absolute;
  bottom: 120%;
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: var(--color-bg);
  opacity: 0;
  visibility: hidden;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.tooltip:hover::after,
.tooltip:hover::before {
  opacity: 1;
  visibility: visible;
}

/* Enhanced Statistics Cards */
.stats-enhanced {
  background: var(--color-bg-secondary);
  border-radius: var(--border-radius);
  padding: 2rem;
  text-align: center;
  border: 1px solid var(--color-bg-tertiary);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.stats-enhanced:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
  border-color: var(--color-accent);
}

.stats-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
  display: block;
}

.stats-number {
  font-size: 2.5rem;
  font-weight: 800;
  color: var(--color-fg);
  display: block;
  margin-bottom: 0.5rem;
}

.stats-label {
  color: var(--color-fg-secondary);
  font-size: 1.125rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.stats-detail {
  color: var(--color-fg-muted);
  font-size: 0.875rem;
}

/* Enhanced Modal */
.modal-enhanced {
  background: var(--color-bg);
  border-radius: var(--border-radius);
  border: 1px solid var(--color-bg-tertiary);
  max-width: 600px;
  width: 90%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-xl);
}

.modal-header {
  position: relative;
  height: 250px;
  background: var(--color-bg-secondary);
  overflow: hidden;
}

.modal-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.modal-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: rgba(0, 0, 0, 0.7);
  color: white;
  border: none;
  border-radius: 50%;
  width: 2.5rem;
  height: 2.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal-close:hover {
  background: rgba(0, 0, 0, 0.9);
}

.modal-body {
  padding: 2rem;
}

/* Responsive Design */
@media (max-width: 768px) {
  .hero-title {
    font-size: 2.5rem;
  }
  
  .hero-subtitle {
    font-size: 1.25rem;
  }
  
  .btn-enhanced {
    min-width: 100%;
    margin-bottom: 1rem;
  }
  
  .search-enhanced {
    min-width: 100%;
    margin-bottom: 1rem;
  }
  
  .select-enhanced {
    min-width: 100%;
  }
  
  .grid-enhanced {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }
  
  .filter-tabs {
    flex-direction: column;
  }
  
  .filter-tab {
    flex: none;
  }
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
  :root {
    --color-bg: #000000;
    --color-bg-secondary: #1a1a1a;
    --color-bg-tertiary: #333333;
    --color-fg: #ffffff;
    --color-fg-secondary: #e5e5e5;
    --color-fg-muted: #cccccc;
  }
  
  .card-enhanced {
    border: 2px solid var(--color-accent);
  }
  
  .btn-enhanced {
    border: 2px solid currentColor;
  }
}

/* Enhanced Modal Styles inspired by index.html */
.game-details-modal-content {
    background: linear-gradient(135deg, rgba(31, 41, 55, 0.95) 0%, rgba(17, 24, 39, 0.95) 100%);
    border: 1px solid transparent;
    background-clip: padding-box;
    position: relative;
}

.game-details-modal-content::before {
    content: '';
    position: absolute;
    inset: 0;
    padding: 1px;
    background: linear-gradient(135deg, rgba(147, 51, 234, 0.5), rgba(59, 130, 246, 0.5), rgba(236, 72, 153, 0.5));
    border-radius: inherit;
    mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    mask-composite: xor;
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    pointer-events: none;
}

/* Fade-in animations */
.fade-in-up {
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.6s ease-out;
}

.modal.show .fade-in-up {
    opacity: 1;
    transform: translateY(0);
}

.fade-in-up:nth-child(1) { transition-delay: 0.1s; }
.fade-in-up:nth-child(2) { transition-delay: 0.2s; }
.fade-in-up:nth-child(3) { transition-delay: 0.3s; }

/* Game cover animations */
.game-cover-animate {
    transition: transform 0.3s ease-out, box-shadow 0.3s ease-out;
}

.modal.show .game-cover-animate {
    animation: vendorFadeIn 0.8s ease-out 0.3s both;
}

@keyframes vendorFadeIn {
    from {
        opacity: 0;
        transform: translateY(30px) scale(0.9);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Enhanced close button */
.close-btn {
    backdrop-filter: blur(10px);
    transition: all 0.2s ease-out;
}

.close-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 0 20px rgba(147, 51, 234, 0.5);
}

/* Text glow effect */
.glow {
    text-shadow: 0 0 10px rgba(147, 51, 234, 0.3), 0 0 20px rgba(147, 51, 234, 0.2);
}

/* Enhanced grid cards in modal */
.game-details-modal-content .bg-gray-800 {
    transition: all 0.3s ease-out;
    background: linear-gradient(135deg, rgba(31, 41, 55, 0.8) 0%, rgba(17, 24, 39, 0.8) 100%);
}

.game-details-modal-content .bg-gray-800:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
}

/* Staggered animations for grid items */
.modal.show .bg-gray-800:nth-child(1) { animation: fadeInUp 0.6s ease-out 0.4s both; }
.modal.show .bg-gray-800:nth-child(2) { animation: fadeInUp 0.6s ease-out 0.5s both; }
.modal.show .bg-gray-800:nth-child(3) { animation: fadeInUp 0.6s ease-out 0.6s both; }
.modal.show .bg-gray-800:nth-child(4) { animation: fadeInUp 0.6s ease-out 0.7s both; }

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Enhanced tags animations */
.modal.show [class*="bg-gradient-to-r"]:nth-child(1) { animation: fadeInRight 0.6s ease-out 0.8s both; }
.modal.show [class*="bg-gradient-to-r"]:nth-child(2) { animation: fadeInRight 0.6s ease-out 0.9s both; }
.modal.show [class*="bg-gradient-to-r"]:nth-child(3) { animation: fadeInRight 0.6s ease-out 1.0s both; }
.modal.show [class*="bg-gradient-to-r"]:nth-child(4) { animation: fadeInRight 0.6s ease-out 1.1s both; }
.modal.show [class*="bg-gradient-to-r"]:nth-child(5) { animation: fadeInRight 0.6s ease-out 1.2s both; }

@keyframes fadeInRight {
    from {
        opacity: 0;
        transform: translateX(30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Modal backdrop enhancement */
.modal {
    backdrop-filter: blur(8px);
}

.modal.show {
    backdrop-filter: blur(12px);
}

/* Button hover enhancements for modal */
.game-details-modal-content a:hover,
.game-details-modal-content button:hover {
    box-shadow: 0 0 30px rgba(147, 51, 234, 0.4);
}

/* Special offer section enhancement */
.bg-gradient-to-r.from-red-900\/50 {
    background: linear-gradient(to right, rgba(127, 29, 29, 0.5), rgba(153, 27, 27, 0.5));
    animation: pulse 2s ease-in-out infinite alternate;
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 20px rgba(239, 68, 68, 0.3);
    }
    100% {
        box-shadow: 0 0 40px rgba(239, 68, 68, 0.5);
    }
}
