/* --- styles.css (updated with performance optimizations) --- */

/* General styles (keep existing styles) */
:root {
  --fg-primary: #222222; /* Darker primary text for better contrast */
  --fg-secondary: #555555; /* Darker secondary text for better contrast */
  --bg-primary: #f9f9f9; /* Light grey background, similar to image */
  --bg-secondary: #fff; /* White for sections and thumbnails */
  --border-primary: #ddd; /* Light grey border */
  --border-secondary: #eee; /* Very light grey border */
  --color-present: #b09200; /* Further darkened yellow for WCAG 3:1 contrast ratio */
  --color-correct: #2e7735; /* Darker green for better contrast */
}

body {
  font-family: Arial, sans-serif;
  text-align: center;
  background-color: var(--bg-primary);
  color: var(--fg-primary);
  margin: 0;
  padding: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header Styles */
header {
  background-color: var(--bg-secondary); /* White header background */
  padding: 20px 20px; /* Increased top/bottom padding */
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05); /* Subtle shadow */
  position: relative;
  overflow: hidden;
  display: flex;
  justify-content: center;
  align-items: center;
  border-bottom: 1px solid var(--border-primary); /* Add bottom border */
  contain: layout; /* Contain layout repaints */
}

header::before {
  content: none; /* Remove yellow top border */
}

.header-content {
  max-width: 1200px;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.logo {
  font-size: 3.5em; /* Larger logo */
  margin-bottom: 5px; /* Reduced margin */
  color: var(--color-present); /* Yellow logo color */
}

h1 {
  font-size: 2.8em; /* Slightly smaller main header */
  margin-bottom: 5px; /* Reduced margin */
  margin-top: 5px; /* Reduced margin */
  text-shadow: none; /* Removed text shadow */
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: bold; /* Slightly bolder font weight */
  color: var(--fg-primary);
}

.subtitle {
  font-size: 1.2em; /* Smaller subtitle */
  color: var(--fg-primary); /* Changed from secondary to primary for contrast */
  font-weight: 500; /* Slightly bolder for better readability */
  max-width: 700px;
  margin: 0 auto;
  line-height: 1.5;
}

@media (max-width: 768px) {
  h1 {
    font-size: 2em;
  }
  .subtitle {
    font-size: 1em;
  }
  .logo {
    font-size: 2.8em;
  }
  header {
    padding: 20px 15px;
  }
}

/* Main Content Styles */
main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px; /* Reduced main padding */
  flex-grow: 1;
}

.game-selection {
  text-align: center;
  padding: 30px 0; /* Add padding around game selection */
  contain: content; /* Contain layout changes */
}

.description {
  font-size: 1.1em; /* Slightly smaller description text */
  color: var(--fg-primary); /* Changed from secondary to primary for contrast */
  font-weight: 500; /* Slightly bolder for better readability */
  line-height: 1.6;
  max-width: 750px; /* Slightly wider description max-width */
  margin: 0 auto 35px; /* Increased bottom margin */
}

/* Thumbnail Styles */
.thumbnails {
  display: flex;
  justify-content: center;
  gap: 25px; /* Reduced gap between thumbnails */
  flex-wrap: wrap;
  margin-top: 10px; /* Reduced top margin */
}

.thumbnail-link {
  text-decoration: none;
  display: block;
}

.thumbnail {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-top: 0;
  margin-right: 0;
  border-radius: 8px;
  background-color: var(--bg-secondary); /* White thumbnail background */
  padding: 15px; /* Reduced thumbnail padding */
  transition: transform 0.3s ease;
  will-change: transform; /* GPU acceleration hint */
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1); /* Lighter shadow */
  width: 349px; /* Width to accommodate 319px image + 30px padding */
  border: 1px solid var(--border-secondary); /* Add border to thumbnails */
  contain: layout; /* Contain layout changes */
}

.thumbnail:hover {
  transform: translateY(-5px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15); /* Slightly stronger shadow on hover */
}

/* Add explicit width/height and aspect-ratio to prevent layout shifts */
.thumbnail img {
  width: 100%;
  height: auto;
  aspect-ratio: 319/327; /* Maintain exact image aspect ratio */
  display: block;
  border-radius: 8px;
  margin-bottom: 10px; /* Reduced margin below image */
  backface-visibility: hidden; /* Reduce paint operations during animations */
}

.thumbnail-text {
  color: var(--fg-primary);
  font-weight: bold;
  margin-top: 0;
  font-size: 1.1em;
  margin-bottom: 10px; /* Reduced margin below thumbnail text */
}

.play-button {
  display: inline-block;
  padding: 10px 22px; /* Slightly smaller button padding */
  background-color: var(--color-correct); /* Green background for play button */
  color: var(--bg-primary); /* Black text for play button */
  border-radius: 5px;
  font-weight: bold;
  text-transform: uppercase;
  font-size: 1.1em;
  transition: background-color 0.3s ease;
  border: none; /* Remove button border */
  cursor: pointer; /* Add cursor pointer */
  height: fit-content; /* Prevent layout shift */
  box-sizing: border-box; /* Include padding in element size */
}

.play-button:hover {
  background-color: #65bd5d; /* Slightly lighter green on hover */
}

/* Specific thumbnail styles if needed */
.hive-thumbnail .play-button {
  /* Add specific styles for Hive play button if needed */
}

.wordle-thumbnail .play-button {
  /* Add specific styles for Wordle play button if needed */
}


/* Footer Styles */
footer {
  background-color: var(--bg-secondary); /* White footer background */
  color: var(--fg-secondary);
  padding: 20px;
  text-align: center;
  border-top: 1px solid var(--border-primary); /* Add top border */
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-top: 40px; /* Add margin above footer */
  contain: layout; /* Contain layout changes */
}

.copyright {
  font-size: 0.85em; /* Smaller copyright text */
  margin-bottom: 8px; /* Reduced margin */
}

.footer-nav {
  display: flex;
  gap: 15px; /* Reduced gap in footer nav */
}

.footer-nav a {
  color: var(--fg-secondary);
  text-decoration: none;
  font-size: 0.85em; /* Smaller footer nav text */
  transition: color 0.3s ease;
}

.footer-nav a:hover {
  color: var(--fg-primary);
}


/* Light mode styles (adjust if needed, but base theme is now light) */
@media (prefers-color-scheme: light) {
  /* Light mode is now the default, these are adjustments if needed for forced light mode */
  :root {
    /* If you want to tweak light mode further, adjust these, otherwise defaults are set */
  }
}

/* Responsive adjustments (adjust as needed) */
@media (max-width: 900px) {
  .thumbnails {
    align-items: center;
    gap: 20px; /* Reduced gap on smaller screens */
  }
  .thumbnail {
    width: 90%; /* Wider thumbnails on smaller screens */
    max-width: 200px; /* Slightly larger max width */
  }
  .description {
    font-size: 1.1em;
    margin-bottom: 30px;
  }
  h1 {
    font-size: 2.5em;
  }
  .subtitle {
    font-size: 1.1em;
  }
  .logo {
    font-size: 3em;
  }
  main {
    padding: 15px;
  }
  .game-selection {
    padding: 25px 0;
  }
}

@media (max-width: 600px) {
  h1 {
    font-size: 1.8em;
  }
  .subtitle {
    font-size: 0.9em;
  }
  .logo {
    font-size: 2.5em;
  }
  .description {
    font-size: 1em;
  }
  .play-button {
    padding: 8px 18px;
    font-size: 1em;
  }
  .footer-nav {
    flex-direction: column;
    gap: 8px;
  }
  footer {
    padding: 15px;
  }
}
/* Manual pages styles */
.manual-container {
  max-width: 800px;
  margin: 0 auto;
  background-color: var(--bg-secondary);
  border-radius: 8px;
  padding: 25px;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
  border: 1px solid var(--border-secondary);
}

.manual-content {
  text-align: left;
  margin: 20px 0;
  line-height: 1.6;
}

.manual-content h2 {
  margin-top: 30px;
  margin-bottom: 15px;
  border-bottom: 1px solid var(--border-secondary);
  padding-bottom: 5px;
}

.manual-content ul, .manual-content ol {
  margin-left: 20px;
  margin-bottom: 20px;
}

.manual-content li {
  margin-bottom: 8px;
}

.cta-buttons {
  display: flex;
  justify-content: center;
  gap: 20px;
  margin-top: 40px;
  flex-wrap: wrap;
}

.home-button {
  display: inline-block;
  padding: 10px 22px;
  background-color: var(--fg-secondary);
  color: var(--bg-secondary);
  border-radius: 5px;
  font-weight: bold;
  text-transform: uppercase;
  font-size: 1.1em;
  transition: background-color 0.3s ease;
  text-decoration: none;
  height: fit-content; /* Prevent layout shift */
  box-sizing: border-box; /* Include padding in element size */
}

.home-button:hover {
  background-color: var(--fg-primary);
}

.manual-links {
  margin: 40px auto 20px;
  text-align: center;
}

.manual-buttons {
  display: flex;
  justify-content: center;
  gap: 20px;
  margin-top: 15px;
  flex-wrap: wrap;
}

.manual-button {
  color: var(--fg-primary);
  text-decoration: none;
  padding: 12px 20px;
  border: 1px solid var(--border-primary);
  border-radius: 5px;
  background-color: var(--bg-secondary);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  height: fit-content; /* Prevent layout shift */
  box-sizing: border-box; /* Include padding in element size */
}

.manual-button:hover {
  transform: translateY(-3px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}
.special-rule {
  background-color: #f8f8f8;
  padding: 15px;
  border-left: 4px solid var(--color-correct);
  margin: 20px 0;
}

.language-selector {
  margin-top: 40px;
  text-align: center;
  border-top: 1px solid var(--border-primary);
  padding-top: 20px;
}

.language-links {
  display: flex;
  justify-content: center;
  gap: 15px;
  margin-top: 10px;
  flex-wrap: wrap;
}

.language-link {
  color: var(--fg-primary);
  text-decoration: none;
  padding: 5px 10px;
  border-radius: 4px;
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-primary);
  height: fit-content; /* Prevent layout shift */
  box-sizing: border-box; /* Include padding in element size */
}

.language-link:hover {
  background-color: var(--border-secondary);
}

/* SEO Content Section */
.seo-content {
  margin: 40px auto;
  text-align: left;
  padding: 20px;
  background-color: var(--bg-secondary);
  border-radius: 8px;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
  border: 1px solid var(--border-secondary);
  max-width: 1000px;
  /* Performance optimization - render only when visible */
  content-visibility: auto;
  contain-intrinsic-size: 1px 800px; /* Approximate reserved space */
}

.seo-content h2 {
  text-align: center;
  margin-bottom: 20px;
}

.seo-content p {
  line-height: 1.6;
  color: var(--fg-primary);
  margin-bottom: 15px;
}

.game-descriptions {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  margin: 25px 0;
}

.game-desc {
  flex: 1;
  min-width: 280px;
}

.game-desc h3 {
  margin-bottom: 10px;
  color: var(--fg-primary);
}

.benefits {
  background-color: var(--bg-primary);
  padding: 15px;
  border-radius: 6px;
  margin-top: 20px;
}

.benefits h3 {
  margin-bottom: 10px;
}

.benefits ul {
  padding-left: 20px;
  text-align: left;
}

.benefits li {
  margin-bottom: 8px;
  line-height: 1.4;
}

/* FAQ Section */
.faq-section {
  margin: 50px auto;
  max-width: 1000px;
  padding: 20px;
  background-color: var(--bg-secondary);
  border-radius: 8px;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
  border: 1px solid var(--border-secondary);
  /* Performance optimization - render only when visible */
  content-visibility: auto;
  contain-intrinsic-size: 1px 600px; /* Approximate reserved space */
}

.faq-section h2 {
  text-align: center;
  margin-bottom: 30px;
}

.faq-item {
  margin-bottom: 25px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border-primary);
  text-align: left;
}

.faq-item:last-child {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

.faq-item h3 {
  margin-bottom: 10px;
  color: var(--fg-primary);
  position: relative;
  cursor: pointer;
  padding-left: 15px;
}

.faq-item h3::before {
  content: "▸";
  position: absolute;
  left: 0;
  color: var(--color-correct);
}

.faq-item p {
  line-height: 1.6;
  color: var(--fg-secondary);
  margin-left: 15px;
}

.faq-item h3:hover {
  color: var(--color-correct);
}

/* Responsive adjustments for SEO and FAQ sections */
@media (max-width: 900px) {
  .game-descriptions {
    flex-direction: column;
  }

  .seo-content,
  .faq-section {
    padding: 15px;
    margin: 30px auto;
  }
}

@media (max-width: 600px) {
  .faq-item h3 {
    font-size: 1.1em;
  }

  .faq-item p,
  .seo-content p {
    font-size: 0.95em;
  }
}

/* Performance optimizations for animations */
@media (prefers-reduced-motion: reduce) {
  .thumbnail,
  .play-button,
  .manual-button,
  .home-button {
    transition: none;
  }

  .thumbnail:hover {
    transform: none;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
  }

  .manual-button:hover {
    transform: none;
  }

  /* Disable all animations for users who prefer reduced motion */
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    animation-delay: 0.01ms !important;
  }
}


/* Additional performance optimization - use font-display: swap */
@font-face {
  font-family: Arial;
  font-display: swap;
}

/* Add print styles to optimize for printing */
@media print {
  .play-button,
  .manual-button,
  .language-selector {
    display: none;
  }

  body {
    background-color: white;
    color: black;
  }

  .thumbnail {
    box-shadow: none;
    border: 1px solid #ccc;
  }
}