/* 
 *  Brain Games CSS
 * Apple-inspired design system with mobile optimization
 */

 :root {
    /* Color palette - Apple inspired */
    --primary-color: #0071e3;
    --primary-dark: #0051a3;
    --accent-color: #ff375f;
    --background-color: #f5f5f7;
    --card-color: #ffffff;
    --text-color: #1d1d1f;
    --text-secondary: #6e6e73;
    --border-color: #d2d2d7;
    --success-color: #32d74b;
    
    /* Typography */
    --font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
    
    /* Spacing */
    --spacing-xs: 0.25rem;
    --spacing-sm: 0.5rem;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
    --spacing-xl: 2rem;
    --spacing-xxl: 3rem;
    
    /* Border radius */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    
    /* Shadows */
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);
  }
  
  /* Base styles */
  * {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
  }
  
  html {
    font-size: 100%;
    scroll-behavior: smooth;
  }
  
  body {
    font-family: var(--font-family);
    color: var(--text-color);
    background-color: var(--background-color);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
  }
  
  h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    line-height: 1.2;
    margin-bottom: var(--spacing-md);
  }
  
  h1 {
    font-size: 2rem;
  }
  
  h2 {
    font-size: 1.75rem;
  }
  
  h3 {
    font-size: 1.25rem;
  }
  
  p {
    margin-bottom: var(--spacing-md);
  }
  
  a {
    color: var(--primary-color);
    text-decoration: none;
    transition: color 0.2s ease;
  }
  
  a:hover, a:focus {
    color: var(--primary-dark);
  }
  
  img {
    max-width: 100%;
    height: auto;
    display: block;
  }
  
  ul {
    list-style: none;
  }
  
  button, .cta-button, .play-button, .filter-btn {
    cursor: pointer;
    font-family: var(--font-family);
    border: none;
    transition: all 0.2s ease;
  }
  
  button:focus, a:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
  }
  
  section {
    padding: var(--spacing-xl) var(--spacing-md);
    margin-bottom: var(--spacing-xl);
  }
  
  /* Header styles */
  header {
    background-color: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--spacing-md) var(--spacing-md);
  }
  
  .logo-container {
    display: flex;
    align-items: center;
  }
  
  .logo {
    height: 40px;
    width: auto;
    margin-right: var(--spacing-sm);
  }
  
  #site-title {
    font-size: 1.25rem;
    margin-bottom: 0;
  }
  
  /* Mobile menu toggle */
  #menu-toggle {
    display: none;
    background: transparent;
    border: none;
    width: 40px;
    height: 40px;
    padding: var(--spacing-xs);
    position: relative;
    z-index: 101;
  }
  
  .menu-icon {
    display: block;
    position: relative;
    width: 100%;
    height: 2px;
    background-color: var(--text-color);
  }
  
  .menu-icon::before,
  .menu-icon::after {
    content: '';
    position: absolute;
    width: 100%;
    height: 2px;
    background-color: var(--text-color);
    transition: transform 0.2s ease;
  }
  
  .menu-icon::before {
    top: -8px;
  }
  
  .menu-icon::after {
    bottom: -8px;
  }
  
  #menu-toggle.active .menu-icon {
    background-color: transparent;
  }
  
  #menu-toggle.active .menu-icon::before {
    transform: translateY(8px) rotate(45deg);
  }
  
  #menu-toggle.active .menu-icon::after {
    transform: translateY(-8px) rotate(-45deg);
  }
  
  /* Navigation styles */
  nav {
    display: flex;
    align-items: center;
  }
  
  #main-menu {
    display: flex;
  }
  
  #main-menu li {
    margin-right: var(--spacing-lg);
  }
  
  #main-menu a {
    color: var(--text-color);
    font-weight: 500;
    padding: var(--spacing-xs) 0;
    position: relative;
  }
  
  #main-menu a::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 0;
    height: 2px;
    background-color: var(--primary-color);
    transition: width 0.2s ease;
  }
  
  #main-menu a:hover::after,
  #main-menu a:focus::after {
    width: 100%;
  }
  
  .language-selector {
    display: flex;
    align-items: center;
    margin-left: var(--spacing-md);
  }
  
  #language-label {
    margin-right: var(--spacing-xs);
    color: var(--text-secondary);
    font-size: 0.875rem;
  }
  
  #language-select {
    padding: var(--spacing-xs) var(--spacing-sm);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    background-color: var(--card-color);
    font-family: var(--font-family);
    cursor: pointer;
  }
  
  /* Hero section */
  .hero {
    text-align: center;
    padding: var(--spacing-xxl) var(--spacing-md);
    background: linear-gradient(135deg, #f0f0f3 0%, #e6e9f0 100%);
    border-radius: var(--radius-lg);
    margin: var(--spacing-lg) var(--spacing-md);
  }
  
  #hero-title {
    font-size: 2.5rem;
    margin-bottom: var(--spacing-md);
  }
  
  #hero-text {
    font-size: 1.25rem;
    color: var(--text-secondary);
    max-width: 700px;
    margin: 0 auto var(--spacing-lg);
  }
  
  .cta-button {
    display: inline-block;
    background-color: var(--primary-color);
    color: white;
    padding: var(--spacing-md) var(--spacing-xl);
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: 1.125rem;
    box-shadow: var(--shadow-sm);
  }
  
  .cta-button:hover, .cta-button:focus {
    background-color: var(--primary-dark);
    color: white;
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
  }
  
  /* Filters styles */
  .filters-container {
    background-color: var(--card-color);
    border-radius: var(--radius-lg);
    padding: var(--spacing-lg);
    margin-bottom: var(--spacing-xl);
    box-shadow: var(--shadow-sm);
  }
  
  .filter-group {
    margin-bottom: var(--spacing-lg);
  }
  
  .filter-group:last-child {
    margin-bottom: 0;
  }
  
  .filter-group h3 {
    font-size: 1rem;
    color: var(--text-secondary);
    margin-bottom: var(--spacing-sm);
  }
  
  .filter-options {
    display: flex;
    flex-wrap: wrap;
    gap: var(--spacing-sm);
  }
  
  .filter-btn {
    padding: var(--spacing-sm) var(--spacing-md);
    border-radius: var(--radius-sm);
    background-color: var(--background-color);
    color: var(--text-color);
    font-size: 0.875rem;
    font-weight: 500;
  }
  
  .filter-btn:hover, .filter-btn:focus {
    background-color: #e8e8ed;
  }
  
  .filter-btn.active {
    background-color: var(--primary-color);
    color: white;
  }
  
  /* Games grid */
  .games-section {
    padding-top: var(--spacing-lg);
  }
  
  #games-title, #featured-title, #daily-challenge-title {
    text-align: center;
    margin-bottom: var(--spacing-xl);
  }
  
  .games-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: var(--spacing-lg);
    max-width: 1200px;
    margin: 0 auto;
  }
  
  .game-card {
    background-color: var(--card-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    height: 100%;
    display: flex;
    flex-direction: column;
  }
  
  .game-card:hover, .game-card:focus-within {
    transform: translateY(-4px);
    box-shadow: var(--shadow-md);
  }
  
  .game-image {
    aspect-ratio: 16 / 9;
    object-fit: cover;
    width: 100%;
  }
  
  .game-info {
    padding: var(--spacing-lg);
    flex: 1;
    display: flex;
    flex-direction: column;
  }
  
  .game-title {
    font-size: 1.25rem;
    margin-bottom: var(--spacing-sm);
  }
  
  .game-description {
    color: var(--text-secondary);
    margin-bottom: var(--spacing-md);
    flex: 1;
  }
  
  .game-metadata {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-md);
  }
  
  .game-category {
    display: inline-block;
    padding: var(--spacing-xs) var(--spacing-sm);
    background-color: rgba(0, 113, 227, 0.1);
    color: var(--primary-color);
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 500;
  }
  
  .difficulty-meter {
    display: flex;
    gap: 3px;
  }
  
  .difficulty-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--border-color);
  }
  
  .difficulty-dot.active {
    background-color: var(--primary-color);
  }
  
  .play-button {
    display: block;
    background-color: var(--primary-color);
    color: white;
    text-align: center;
    padding: var(--spacing-sm) var(--spacing-md);
    border-radius: var(--radius-md);
    font-weight: 500;
    margin-top: auto;
  }
  
  .play-button:hover, .play-button:focus {
    background-color: var(--primary-dark);
    color: white;
  }
  
  .challenge-button {
    background-color: var(--accent-color);
  }
  
  .challenge-button:hover, .challenge-button:focus {
    background-color: #d92d50;
  }
  
  .no-games-message {
    grid-column: 1 / -1;
    text-align: center;
    padding: var(--spacing-xxl);
    color: var(--text-secondary);
  }
  
  /* Featured section */
  .featured-section {
    padding: var(--spacing-xl) var(--spacing-md);
    background-color: var(--card-color);
    border-radius: var(--radius-lg);
    margin: 0 var(--spacing-md) var(--spacing-xl);
  }
  
  .featured-slider {
    display: flex;
    overflow-x: auto;
    gap: var(--spacing-lg);
    padding: var(--spacing-md) 0;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
  }
  
  .featured-slider::-webkit-scrollbar {
    height: 6px;
  }
  
  .featured-slider::-webkit-scrollbar-track {
    background: var(--background-color);
    border-radius: 10px;
  }
  
  .featured-slider::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 10px;
  }
  
  .featured-card {
    min-width: 280px;
    scroll-snap-align: start;
  }
  
  /* Daily challenge */
  .daily-challenge {
    background: linear-gradient(135deg, #ff9966 0%, #ff5e62 100%);
    color: white;
    border-radius: var(--radius-lg);
    padding: var(--spacing-xl);
    margin: 0 var(--spacing-md) var(--spacing-xl);
    text-align: center;
  }
  
  #daily-challenge-title {
    color: white;
  }
  
  #daily-challenge-text {
    max-width: 600px;
    margin: 0 auto var(--spacing-lg);
  }
  
  .daily-challenge-card {
    max-width: 400px;
    margin: 0 auto;
    background: rgba(255, 255, 255, 0.9);
  }
  
  /* Footer styles */
  footer {
    background-color: var(--text-color);
    color: white;
    padding: var(--spacing-xl) var(--spacing-md);
  }
  
  .footer-columns {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: var(--spacing-xl);
    max-width: 1200px;
    margin: 0 auto var(--spacing-xl);
  }
  
  .footer-column h3 {
    font-size: 1.125rem;
    margin-bottom: var(--spacing-md);
    color: white;
  }
  
  .footer-column ul {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
  }
  
  .footer-column a {
    color: #a1a1a6;
    transition: color 0.2s ease;
  }
  
  .footer-column a:hover, .footer-column a:focus {
    color: white;
  }
  
  .social-links {
    display: flex;
    gap: var(--spacing-md);
  }
  
  .social-link {
    display: block;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: #333;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s ease;
  }
  
  .social-link:hover, .social-link:focus {
    background-color: var(--primary-color);
  }
  
  .social-icon {
    width: 20px;
    height: 20px;
    background-position: center;
    background-repeat: no-repeat;
    background-size: contain;
  }
  
  .facebook {
    background-image: url('data:image/svg+xml;charset=UTF-8,<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="white" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M18 2h-3a5 5 0 0 0-5 5v3H7v4h3v8h4v-8h3l1-4h-4V7a1 1 0 0 1 1-1h3z"></path></svg>');
  }
  
  .twitter {
    background-image: url('data:image/svg+xml;charset=UTF-8,<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="white" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M22 4s-.7 2.1-2 3.4c1.6 10-9.4 17.3-18 11.6 2.2.1 4.4-.6 6-2C3 15.5.5 9.6 3 5c2.2 2.6 5.6 4.1 9 4-.9-4.2 4-6.6 7-3.8 1.1 0 3-1.2 3-1.2z"></path></svg>');
  }
  
  .instagram {
    background-image: url('data:image/svg+xml;charset=UTF-8,<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="white" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="2" y="2" width="20" height="20" rx="5" ry="5"></rect><path d="M16 11.37A4 4 0 1 1 12.63 8 4 4 0 0 1 16 11.37z"></path><line x1="17.5" y1="6.5" x2="17.51" y2="6.5"></line></svg>');
  }
  
  #copyright {
    text-align: center;
    color: #a1a1a6;
    font-size: 0.875rem;
    margin-bottom: 0;
  }
  
  /* Mobile styles */
  @media (max-width: 768px) {
    h1 {
      font-size: 1.75rem;
    }
    
    h2 {
      font-size: 1.5rem;
    }
    
    #hero-title {
      font-size: 2rem;
    }
    
    #hero-text {
      font-size: 1rem;
    }
    
    /* Mobile navigation */
    #menu-toggle {
      display: block;
    }
    
    #main-navigation {
      position: fixed;
      top: 0;
      right: -100%;
      width: 80%;
      max-width: 300px;
      height: 100vh;
      background-color: var(--card-color);
      box-shadow: var(--shadow-lg);
      padding: 80px var(--spacing-lg) var(--spacing-lg);
      transition: right 0.3s ease;
      z-index: 100;
    }
    
    #main-navigation.active {
      right: 0;
    }
    
    #main-menu {
      flex-direction: column;
      margin-bottom: var(--spacing-xl);
    }
    
    #main-menu li {
      margin-right: 0;
      margin-bottom: var(--spacing-md);
    }
    
    .language-selector {
      margin-left: 0;
    }
    
    /* Filters adjustments */
    .filter-options {
      overflow-x: auto;
      padding-bottom: var(--spacing-sm);
      margin-bottom: var(--spacing-xs);
      -webkit-overflow-scrolling: touch;
    }
    
    .filter-btn {
      white-space: nowrap;
    }
    
    /* Game cards */
    .games-grid {
      grid-template-columns: 1fr;
    }
    
    /* Footer */
    .footer-columns {
      grid-template-columns: 1fr;
      gap: var(--spacing-lg);
    }
  }
  
  /* Tablet styles */
  @media (min-width: 769px) and (max-width: 1024px) {
    .games-grid {
      grid-template-columns: repeat(2, 1fr);
    }
  }
  
  /* Support for safe area insets on iOS */
  @supports (padding: max(0px)) {
    body {
      padding-left: max(var(--spacing-md), env(safe-area-inset-left));
      padding-right: max(var(--spacing-md), env(safe-area-inset-right));
    }
    
    header, footer {
      padding-left: max(var(--spacing-md), env(safe-area-inset-left));
      padding-right: max(var(--spacing-md), env(safe-area-inset-right));
    }
  }
  
  /* Animation for featured games */
  @keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
  }
  
  .featured-card {
    animation: fadeIn 0.5s ease forwards;
  }
  
  /* Additional accessibility styles */
  .sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
  }
  
  @media (prefers-reduced-motion: reduce) {
    * {
      animation-duration: 0.01ms !important;
      animation-iteration-count: 1 !important;
      transition-duration: 0.01ms !important;
      scroll-behavior: auto !important;
    }
  }
  @supports (-webkit-touch-callout: none) {
    /* iOS Safari specific styles */
    .game-card {
      /* Prevent flickering on scroll in iOS Safari */
      -webkit-backface-visibility: hidden;
    }
  }