/* Modern CSS Reset */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* Variables */
:root,
:root[data-theme="dark"] {
  /* Dark Theme Colors */
  --bg-primary: #1a1a1a;
  --bg-secondary: #252525;
  --bg-tertiary: #333333;
  --text-primary: #f5f5f5;
  --text-secondary: #b3b3b3;
  --accent: #6c63ff;
  --accent-hover: #5a52d5;
  --accent-rgb: 108, 99, 255;
  --success: #4caf50;
  --warning: #ff9800;
  --danger: #f44336;
  --border-radius: 8px;
  --transition: all 0.3s ease;
  --shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  --container-width: 1200px;
}

/* Blue Theme */
:root[data-theme="blue"] {
  --bg-primary: #0f1419;
  --bg-secondary: #1a232d;
  --bg-tertiary: #232d3a;
  --text-primary: #e8f0f8;
  --text-secondary: #a8b8c8;
  --accent: #00a8ff;
  --accent-hover: #0088d4;
  --accent-rgb: 0, 168, 255;
  --success: #00d98e;
  --warning: #ffb700;
  --danger: #ff5757;
}

/* Purple Theme */
:root[data-theme="purple"] {
  --bg-primary: #1a0f2e;
  --bg-secondary: #2d1b47;
  --bg-tertiary: #3d2a5a;
  --text-primary: #f0e8ff;
  --text-secondary: #c8b8d8;
  --accent: #9d4edd;
  --accent-hover: #7b2cbf;
  --accent-rgb: 157, 78, 221;
  --success: #52b788;
  --warning: #ffd60a;
  --danger: #ff6b6b;
}

/* Rainbow Theme */
:root[data-theme="rainbow"] {
  --bg-primary: #1a1a1a;
  --bg-secondary: #252525;
  --bg-tertiary: #333333;
  --text-primary: #f5f5f5;
  --text-secondary: #b3b3b3;
  --accent: #ff6b6b;
  --accent-hover: #ff5252;
  --accent-rgb: 255, 107, 107;
  --success: #51cf66;
  --warning: #ffd93d;
  --danger: #ff6b9d;
  animation: rainbowFade 8s ease-in-out infinite;
  --accent-gradient: linear-gradient(90deg, #ff6b6b, #ffb86d, #ffd93d, #a4d65e, #51cf66, #25c4d6, #00a8ff, #9d4edd);
}

@keyframes rainbowFade {
  0% {
    --accent: #ff6b6b;
    --accent-rgb: 255, 107, 107;
    opacity: 1;
  }
  12.5% {
    --accent: #ffb86d;
    --accent-rgb: 255, 184, 109;
  }
  25% {
    --accent: #ffd93d;
    --accent-rgb: 255, 217, 61;
  }
  37.5% {
    --accent: #a4d65e;
    --accent-rgb: 164, 214, 94;
  }
  50% {
    --accent: #51cf66;
    --accent-rgb: 81, 207, 102;
  }
  62.5% {
    --accent: #25c4d6;
    --accent-rgb: 37, 196, 214;
  }
  75% {
    --accent: #00a8ff;
    --accent-rgb: 0, 168, 255;
  }
  87.5% {
    --accent: #9d4edd;
    --accent-rgb: 157, 78, 221;
  }
  100% {
    --accent: #ff6b6b;
    --accent-rgb: 255, 107, 107;
    opacity: 1;
  }
}

/* Animated gradient movement for elements that use accent as background */
@keyframes rainbowShift {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

:root[data-theme="rainbow"] .btn.primary,
:root[data-theme="rainbow"] .favorite-btn,
:root[data-theme="rainbow"] .control-btn,
:root[data-theme="rainbow"] .btn.secondary:hover,
:root[data-theme="rainbow"] .game-controls .control-btn {
  background-image: var(--accent-gradient);
  background-size: 200% 100%;
  animation: rainbowShift 6s linear infinite;
  color: white !important;
  border-color: transparent !important;
}

:root[data-theme="rainbow"] .section-title::after,
:root[data-theme="rainbow"] .nav-links a.active::after {
  background-image: var(--accent-gradient);
  background-size: 200% 100%;
  animation: rainbowShift 6s linear infinite;
}

:root[data-theme="rainbow"] .hero .highlight {
  background-image: var(--accent-gradient);
  background-size: 200% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: rainbowShift 6s linear infinite;
}

/* Base Styles */
html {
  scroll-behavior: smooth;
}

body {
  font-family: 'Poppins', sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  overflow-x: hidden;
}

.container {
  width: 100%;
  max-width: var(--container-width);
  margin: 0 auto;
  padding: 0 20px;
}

a {
  text-decoration: none;
  color: inherit;
  transition: var(--transition);
}

ul {
  list-style: none;
}

img {
  max-width: 100%;
  height: auto;
}

/* Section Styles */
section {
  padding: 80px 0;
}

.section-title {
  font-size: 2.5rem;
  margin-bottom: 2rem;
  text-align: center;
  position: relative;
  color: var(--text-primary);
}

.section-title::after {
  content: '';
  position: absolute;
  bottom: -10px;
  left: 50%;
  transform: translateX(-50%);
  width: 60px;
  height: 3px;
  background-color: var(--accent);
}

/* Header & Navigation */
header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background-color: rgba(26, 26, 26, 0.95);
  backdrop-filter: blur(10px);
  z-index: 1000;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  padding: 1rem 0;
}

header .container {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.logo h1 {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text-primary);
}

/* Style for logo link */
.logo a {
    text-decoration: none;
    color: inherit;
}

.nav-links {
  display: flex;
  gap: 2rem;
  align-items: center;
  list-style: none;
  margin: 0;
  padding: 0;
}

.nav-links a {
  color: var(--text-secondary);
  font-weight: 500;
  position: relative;
  padding: 0.5rem 0;
}

.nav-links a:hover,
.nav-links a.active {
  color: var(--accent);
}

.nav-links a::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 0;
  height: 2px;
  background-color: var(--accent);
  transition: var(--transition);
}

.nav-links a:hover::after,
.nav-links a.active::after {
  width: 100%;
}

.mobile-menu-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
}

.bar {
  display: block;
  width: 25px;
  height: 3px;
  margin: 5px 0;
  background-color: var(--text-primary);
  transition: var(--transition);
}

/* Hero Section */
.hero {
  min-height: 100vh;
  display: flex;
  align-items: center;
  padding-top: 80px;
  background: linear-gradient(135deg, rgba(26, 26, 26, 0.95), rgba(37, 37, 37, 0.95)), url('https://source.unsplash.com/random/1920x1080/?math') no-repeat center center/cover;
}

.hero-content {
  max-width: 800px;
  text-align: center;
  margin: 0 auto;
}

.hero-content h2 {
  font-size: 3.5rem;
  margin-bottom: 1.5rem;
  line-height: 1.2;
}

.highlight {
  color: var(--accent);
}

.hero-content p {
  font-size: 1.2rem;
  color: var(--text-secondary);
  margin-bottom: 2rem;
}

.cta-buttons {
  display: flex;
  gap: 1rem;
  justify-content: center;
}

.btn {
  display: inline-block;
  padding: 12px 30px;
  border-radius: var(--border-radius);
  font-weight: 500;
  transition: var(--transition);
  cursor: pointer;
  text-align: center;
}

.btn.primary {
  background-color: var(--accent);
  color: white;
}

.btn.primary:hover {
  background-color: var(--accent-hover);
  transform: translateY(-3px);
  box-shadow: var(--shadow);
}

.btn.secondary {
  background-color: transparent;
  border: 2px solid var(--accent);
  color: var(--accent);
}

.btn.secondary:hover {
  background-color: var(--accent);
  color: white;
  transform: translateY(-3px);
  box-shadow: var(--shadow);
}

/* Featured Games */
.games-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 2rem;
  margin-top: 2rem;
}

.game-card {
  background-color: var(--bg-secondary);
  border-radius: var(--border-radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: var(--transition);
  height: 100%;
  display: flex;
  flex-direction: column;
  cursor: pointer;
  position: relative;
}

.game-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
}

.game-image {
  position: relative;
  width: 100%;
  padding-bottom: 56.25%; /* 16:9 Aspect Ratio */
  overflow: hidden;
}

.game-image img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.5s ease;
}

.game-card:hover .game-image img {
  transform: scale(1.05);
}

.game-info {
  padding: 1.5rem;
  flex-grow: 1;
  display: flex;
  flex-direction: column;
}

.game-info h3 {
  font-size: 1.2rem;
  margin-bottom: 0.5rem;
  color: var(--text-primary);
}

.game-description {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-bottom: 1rem;
  flex-grow: 1;
}

.game-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.tag {
  background-color: var(--bg-tertiary);
  color: var(--text-secondary);
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 0.8rem;
  text-transform: capitalize;
}

/* FLASH tag special styling */
/* Note: :contains() pseudo-selector is not valid CSS - use JavaScript for text-based styling if needed */

/* Categories Section */
.category-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 2rem;
  margin-top: 2rem;
}

.category-card {
  background-color: var(--bg-secondary);
  border-radius: var(--border-radius);
  padding: 2rem 1rem;
  text-align: center;
  box-shadow: var(--shadow);
  transition: var(--transition);
  cursor: pointer;
}

.category-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
}

/* Add styles for active category card */
.category-card.active {
  border: 2px solid var(--accent);
  transform: translateY(-5px);
}

.category-card.active .category-icon {
  color: var(--accent);
}

.category-icon {
  font-size: 2.5rem;
  margin-bottom: 1rem;
  color: var(--text-secondary);
  transition: var(--transition);
}

.category-card:hover .category-icon {
  color: var(--accent);
}

.category-card h3 {
  font-size: 1.2rem;
  color: var(--text-primary);
}

/* About Section */
.about-content {
  max-width: 800px;
  margin: 0 auto;
  text-align: center;
}

.about-content p {
  margin-bottom: 1.5rem;
  color: var(--text-secondary);
}

/* Contact Form */
.contact-wrapper {
  max-width: 600px;
  margin: 0 auto;
}

.contact-form {
  background-color: var(--bg-secondary);
  padding: 2rem;
  border-radius: var(--border-radius);
  box-shadow: var(--shadow);
}

.form-group {
  margin-bottom: 1.5rem;
}

label {
  display: block;
  margin-bottom: 0.5rem;
  color: var(--text-primary);
}

input,
textarea {
  width: 100%;
  padding: 10px;
  border: 1px solid var(--bg-tertiary);
  border-radius: var(--border-radius);
  background-color: var(--bg-tertiary);
  color: var(--text-primary);
  font-family: 'Poppins', sans-serif;
  resize: vertical;
  transition: var(--transition);
}

input:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
}

/* Footer */
footer {
  background-color: var(--bg-secondary);
  padding: 3rem 0 1.5rem;
  margin-top: 4rem;
}

.footer-content {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 2rem;
  margin-bottom: 2rem;
}

.footer-section h3 {
  font-size: 1.2rem;
  margin-bottom: 1rem;
  color: var(--text-primary);
}

.footer-section p,
.footer-section li {
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
}

.footer-section ul li {
  margin-bottom: 0.5rem;
}

.social-icons {
  display: flex;
  gap: 1rem;
}

.social-icons a {
  display: inline-block;
  width: 36px;
  height: 36px;
  background-color: var(--bg-tertiary);
  border-radius: 50%;
  text-align: center;
  line-height: 36px;
  color: var(--text-secondary);
  transition: var(--transition);
}

.social-icons a:hover {
  background-color: var(--accent);
  color: white;
  transform: translateY(-3px);
}

.footer-bottom {
  text-align: center;
  padding-top: 1.5rem;
  border-top: 1px solid var(--bg-tertiary);
}

.footer-bottom p {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

/* Additional styles for the all games section */
.all-games {
  padding-top: 40px;
}

.games-list-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 2rem;
  margin-top: 2rem;
}

/* Update category icons to match new categories */
.category-card .category-icon i.fa-gamepad,
.category-card .category-icon i.fa-puzzle-piece,
.category-card .category-icon i.fa-running,
.category-card .category-icon i.fa-brain,
.category-card .category-icon i.fa-tachometer-alt,
.category-card .category-icon i.fa-basketball-ball {
  font-size: 2.5rem;
}

/* Game Cards Enhanced Styling */
.game-image img {
  opacity: 0.9;
}

.game-card:hover .game-image img {
  opacity: 1;
}

.game-description {
  line-height: 1.4;
}

.game-tags {
  margin-top: auto;
}

.tag {
  font-weight: 500;
}

/* Game Categories */
#all-games .section-title {
  margin-bottom: 1.5rem;
}

/* Search bar */
.search-container {
  max-width: 600px;
  margin: 2rem auto;
  position: relative;
}

.search-box {
  display: flex;
  position: relative;
}

.search-input {
  width: 100%;
  padding: 12px 50px 12px 15px;
  border-radius: var(--border-radius);
  border: 2px solid var(--bg-tertiary);
  background-color: var(--bg-tertiary);
  color: var(--text-primary);
  font-family: 'Poppins', sans-serif;
  transition: all 0.3s ease;
}

.search-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(108, 99, 255, 0.2);
}

.search-button {
  position: absolute;
  right: 5px;
  top: 50%;
  transform: translateY(-50%);
  background-color: var(--accent);
  border: none;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  color: white;
  cursor: pointer;
  transition: all 0.2s ease;
}

.search-button:hover {
  background-color: var(--accent-hover);
}

/* Advanced search styling */
.search-suggestions {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background-color: var(--bg-secondary);
  border-radius: 0 0 8px 8px;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  z-index: 100;
  max-height: 300px;
  overflow-y: auto;
  display: none;
}

.search-container {
  position: relative;
}

.search-suggestion {
  padding: 12px 15px;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: background-color 0.2s;
  cursor: pointer;
  border-bottom: 1px solid var(--bg-tertiary);
}

.search-suggestion:hover {
  background-color: var(--bg-tertiary);
}

.search-suggestion:last-child {
  border-bottom: none;
}

.suggestion-thumb {
  width: 40px;
  height: 40px;
  object-fit: cover;
  border-radius: 4px;
  flex-shrink: 0;
}

.suggestion-info {
  flex-grow: 1;
}

.suggestion-title {
  font-weight: 500;
  margin-bottom: 4px;
}

.suggestion-tags {
  display: flex;
  gap: 5px;
}

.suggestion-tags span {
  font-size: 0.7rem;
  padding: 2px 6px;
  background-color: var(--bg-tertiary);
  border-radius: 4px;
  color: var(--text-secondary);
}

/* Scrollbar styling for suggestions */
.search-suggestions::-webkit-scrollbar {
  width: 8px;
}

.search-suggestions::-webkit-scrollbar-track {
  background: var(--bg-tertiary);
  border-radius: 0 0 8px 0;
}

.search-suggestions::-webkit-scrollbar-thumb {
  background-color: var(--accent);
  border-radius: 4px;
}

/* Responsive Styles */
@media screen and (max-width: 768px) {
  .hero-content h2 {
    font-size: 2.5rem;
  }

  .mobile-menu-toggle {
    display: block;
    z-index: 1001;
  }

  .nav-links {
    position: fixed;
    top: 0;
    right: -100%;
    height: 100vh;
    width: 80%;
    max-width: 400px;
    background-color: var(--bg-secondary);
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 2rem;
    transition: right 0.3s ease;
    z-index: 1000;
  }

  .nav-links.active {
    right: 0;
    box-shadow: -5px 0 15px rgba(0, 0, 0, 0.1);
  }

  .cta-buttons {
    flex-direction: column;
    align-items: center;
  }

  .btn {
    width: 100%;
    margin-bottom: 1rem;
  }

  .footer-content {
    grid-template-columns: 1fr;
    text-align: center;
  }

  .social-icons {
    justify-content: center;
  }

  .mobile-menu-toggle.active .bar:nth-child(1) {
    transform: rotate(45deg) translate(5px, 5px);
  }

  .mobile-menu-toggle.active .bar:nth-child(2) {
    opacity: 0;
  }

  .mobile-menu-toggle.active .bar:nth-child(3) {
    transform: rotate(-45deg) translate(7px, -6px);
  }
}

@media screen and (max-width: 480px) {
  .hero-content h2 {
    font-size: 2rem;
  }

  .games-grid,
  .games-list-grid {
    grid-template-columns: 1fr;
  }

  .search-container {
    padding: 0 15px;
  }

  .section-title {
    font-size: 2rem;
  }
}

/* Add styling for no-image placeholder */
.no-image {
  background-color: var(--bg-tertiary);
  width: 100%;
  height: 100%;
  position: absolute;
  top: 0;
  left: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.no-image::after {
  content: 'No thumbnail';
  display: block;
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text-secondary);
  letter-spacing: 0.4px;
}

/* Image loading styles */
.image-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: var(--bg-tertiary);
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
}

.image-container img {
  opacity: 0;
  transition: opacity 0.3s ease-in-out;
}

.image-container.loaded img {
  opacity: 1;
}

.loading-indicator {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 30px;
  height: 30px;
  border: 3px solid var(--bg-tertiary);
  border-radius: 50%;
  border-top-color: var(--accent);
  animation: spin 1s linear infinite;
  z-index: 1;
  pointer-events: none;
}

.image-container.loaded .loading-indicator {
  display: none;
}

@keyframes spin {
  to {
    transform: translate(-50%, -50%) rotate(360deg);
  }
}

.image-container.error::after {
  content: "\f071";
  font-family: "Font Awesome 5 Free";
  font-weight: 900;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 2rem;
  color: var(--text-secondary);
}

/* Animated "No thumbnail" placeholder used when images fail to load */
.no-thumbnail {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(90deg, rgba(255,255,255,0.02) 0%, rgba(255,255,255,0.03) 50%, rgba(255,255,255,0.02) 100%);
  position: relative;
  overflow: hidden;
}

.no-thumbnail span {
  color: var(--text-secondary);
  font-weight: 700;
  font-size: 0.95rem;
  z-index: 2;
  padding: 10px 16px;
  border-radius: 6px;
  background: rgba(0,0,0,0.25);
  backdrop-filter: blur(4px);
}

.no-thumbnail::before {
  content: '';
  position: absolute;
  top: 0;
  left: -150%;
  width: 250%;
  height: 100%;
  background: linear-gradient(90deg, rgba(255,255,255,0.00) 0%, rgba(255,255,255,0.03) 50%, rgba(255,255,255,0.00) 100%);
  transform: skewX(-20deg);
  animation: shimmer 2.2s linear infinite;
  opacity: 0.6;
}

@keyframes shimmer {
  0% { left: -150%; }
  100% { left: 150%; }
}

/* Hardware acceleration for smooth transitions */
.optimize-gpu {
  transform: translateZ(0);
  will-change: transform;
  backface-visibility: hidden;
  perspective: 1000px;
}

/* Scroll sentinel styles */
.scroll-sentinel {
  width: 100%;
  height: 1px;
  opacity: 0;
}

/* Dark mode toggle */
.dark-mode-toggle {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 1.2rem;
  margin-left: 1rem;
  transition: color 0.3s ease;
}

.dark-mode-toggle:hover {
  color: var(--accent);
}

/* Progressive loading for game cards */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.game-card {
  animation: fadeIn 0.4s ease-out forwards;
}

/* Search results highlight */
.highlight-match {
  background-color: rgba(108, 99, 255, 0.2);
  color: var(--accent);
  padding: 0 2px;
}
