/* ============================================
   RESPONSIVE.CSS - Mobile-First Breakpoints
   Optimized for Low-End Android Devices
   FIXED HERO STATS ALIGNMENT
   ============================================ */

/* Mobile First - Base styles are for mobile */

/* Small Mobile Devices (320px - 480px) */
@media (max-width: 480px) {
    /* Hide hamburger menu and desktop nav on mobile - we have bottom nav */
    .nav-toggle,
    .nav-search-btn {
        display: none !important;
    }
    
    /* Hide desktop nav menu completely on mobile */
    .nav-menu {
        display: none !important;
    }
    
    /* Typography scaling for small screens */
    .hero-title {
        font-size: clamp(1.75rem, 10vw, 2.5rem);
    }
    
    .section-title {
        font-size: clamp(1.5rem, 8vw, 2rem);
    }
    
    /* Container adjustments */
    .container {
        padding: 0 var(--space-3);
    }
    
    /* Hero Section */
    .hero {
        min-height: calc(100vh - 120px);
    }
    
    .hero-container {
        padding: var(--space-8) var(--space-3);
    }
    
    .hero-badge {
        font-size: var(--font-xs);
        padding: var(--space-1) var(--space-3);
    }
    
    .hero-description {
        font-size: var(--font-sm);
        margin-bottom: var(--space-4);
    }
    
    /* FIXED: Stats - 2x2 Grid on mobile */
    .hero-stats {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: var(--space-3);
        width: 100%;
        margin-bottom: var(--space-6);
    }
    
    .stat {
        width: 100%;
        justify-content: flex-start;
        padding: var(--space-3);
        flex-direction: column;
        align-items: flex-start;
        text-align: left;
    }
    
    .stat-icon {
        margin-bottom: var(--space-2);
    }
    
    .stat-content {
        text-align: left;
    }
    
    .stat-number {
        font-size: var(--font-lg);
    }
    
    .stat-label {
        font-size: var(--font-xs);
    }
    
    /* Buttons */
    .hero-buttons {
        flex-direction: column;
        width: 100%;
    }
    
    .btn {
        width: 100%;
        justify-content: center;
    }
    
    /* Games Grid */
    .games-grid {
        grid-template-columns: 1fr;
        gap: var(--space-4);
    }
    
    .game-card {
        margin: 0;
    }
    
    .game-image {
        height: 160px;
    }
    
    .game-info {
        padding: var(--space-4);
    }
    
    .game-title {
        font-size: var(--font-lg);
    }
    
    .game-description {
        font-size: var(--font-sm);
        line-height: 1.4;
    }
    
    /* Categories */
    .category-chip {
        padding: var(--space-2) var(--space-3);
        font-size: var(--font-xs);
    }
    
    /* Features Grid */
    .features-grid {
        grid-template-columns: 1fr;
        gap: var(--space-4);
    }
    
    .feature {
        padding: var(--space-4);
    }
    
    /* Modal */
    .modal-content {
        width: 100%;
        height: 100%;
        max-width: none;
        max-height: none;
        border-radius: 0;
    }
    
    .modal-header {
        padding: var(--space-3);
    }
    
    .modal-title {
        font-size: var(--font-base);
    }
    
    .control-btn {
        width: 32px;
        height: 32px;
    }
    
    .control-btn svg {
        width: 16px;
        height: 16px;
    }
    
    /* Footer */
    .footer-content {
        grid-template-columns: 1fr;
        gap: var(--space-6);
        text-align: center;
    }
    
    /* Recent Games */
    .recent-games {
        grid-template-columns: 1fr;
        gap: var(--space-3);
    }
    
    /* CTA Box */
    .cta-box {
        padding: var(--space-6);
    }
    
    /* Logo text hide on very small screens */
    .logo-secondary {
        display: none;
    }
}

/* Tablet Portrait (481px - 768px) */
@media (min-width: 481px) and (max-width: 768px) {
    /* Hide hamburger and search on tablet - use bottom nav */
    .nav-toggle,
    .nav-search-btn {
        display: none !important;
    }
    
    /* Hide desktop nav menu */
    .nav-menu {
        display: none !important;
    }
    
    /* Hero adjustments */
    .hero-container {
        padding: var(--space-10) var(--space-4);
    }
    
    .hero-title {
        font-size: clamp(2rem, 6vw, 3rem);
    }
    
    /* FIXED: Stats - 2x2 Grid on tablet */
    .hero-stats {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: var(--space-4);
    }
    
    .stat {
        width: 100%;
        flex-direction: row;
        align-items: center;
        padding: var(--space-3) var(--space-4);
    }
    
    .stat-icon {
        margin-bottom: 0;
    }
    
    .stat-content {
        text-align: left;
    }
    
    /* Games Grid */
    .games-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: var(--space-4);
    }
    
    /* Features */
    .features-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    /* Recent Games */
    .recent-games {
        grid-template-columns: repeat(2, 1fr);
    }
    
    /* Modal */
    .modal-content {
        width: 95%;
        height: 90%;
        border-radius: var(--radius-xl);
    }
}

/* Tablet Landscape & Small Desktop (769px - 1024px) */
@media (min-width: 769px) and (max-width: 1024px) {
    .container {
        padding: 0 var(--space-6);
    }
    
    /* Hero stats - 4 across on larger screens */
    .hero-stats {
        display: flex;
        flex-wrap: wrap;
        gap: var(--space-4);
    }
    
    .stat {
        flex: 1 1 calc(25% - var(--space-4));
        min-width: 150px;
    }
    
    .games-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: var(--space-5);
    }
    
    .features-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .recent-games {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Large Desktop (1025px+) */
@media (min-width: 1025px) {
    /* Hero stats - 4 across on desktop */
    .hero-stats {
        display: flex;
        flex-wrap: wrap;
        gap: var(--space-4);
    }
    
    .stat {
        flex: 0 1 auto;
    }
    
    .games-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .recent-games {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* Landscape Mode Optimizations */
@media (max-height: 500px) and (orientation: landscape) {
    .hero {
        min-height: auto;
        padding: var(--space-8) 0;
    }
    
    .hero-container {
        padding: var(--space-6) var(--space-4);
    }
    
    .hero-title {
        font-size: clamp(1.5rem, 5vw, 2rem);
        margin-bottom: var(--space-3);
    }
    
    .hero-description {
        font-size: var(--font-sm);
        margin-bottom: var(--space-4);
    }
    
    /* Stats - Horizontal in landscape */
    .hero-stats {
        display: flex;
        flex-wrap: nowrap;
        overflow-x: auto;
        margin-bottom: var(--space-4);
        gap: var(--space-3);
    }
    
    .stat {
        flex: 0 0 auto;
        padding: var(--space-2) var(--space-3);
        min-width: 120px;
    }
    
    .stat-number {
        font-size: var(--font-base);
    }
    
    .stat-label {
        font-size: var(--font-xs);
    }
    
    .hero-buttons {
        gap: var(--space-3);
    }
    
    .btn {
        padding: var(--space-2) var(--space-4);
        font-size: var(--font-sm);
    }
}

/* Touch Device Optimizations */
@media (hover: none) and (pointer: coarse) {
    /* Larger touch targets */
    .btn,
    .control-btn,
    .category-chip,
    .mobile-nav-item {
        min-height: 44px;
        min-width: 44px;
    }
    
    /* Remove hover effects, add active states */
    .game-card:hover {
        transform: none;
    }
    
    .game-card:active {
        transform: scale(0.98);
    }
    
    /* Always show play button on touch devices */
    .game-overlay {
        opacity: 1;
        background: rgba(0, 0, 0, 0.4);
    }
    
    .play-btn {
        background: var(--accent-blue);
        color: var(--text-primary);
    }
    
    /* Better tap feedback */
    * {
        -webkit-tap-highlight-color: rgba(59, 130, 246, 0.2);
    }
}

/* High DPI Displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    /* Optimize for retina displays */
    .game-icon-overlay,
    .logo-icon,
    svg {
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
    }
}

/* Dark Mode Support (System Preference) */
@media (prefers-color-scheme: dark) {
    /* Already dark by default, but can add overrides if needed */
}

/* Reduced Data Mode for Low-End Devices */
@media (prefers-reduced-data: reduce) {
    /* Disable heavy animations */
    .grid-overlay,
    .particles-canvas,
    .gradient-text {
        animation: none !important;
    }
    
    /* Remove complex backgrounds */
    .hero-background {
        background: var(--bg-primary);
    }
}

/* Print Styles */
@media print {
    .navbar,
    .mobile-nav,
    .hero-background,
    .game-modal,
    .footer {
        display: none;
    }
    
    body {
        background: white;
        color: black;
    }
    
    .hero {
        min-height: auto;
        background: white;
    }
}

/* Safe Area Insets for Notched Devices */
@supports (padding: max(0px)) {
    .navbar {
        padding-left: max(var(--space-4), env(safe-area-inset-left));
        padding-right: max(var(--space-4), env(safe-area-inset-right));
    }
    
    .mobile-nav {
        padding-bottom: max(var(--space-2), env(safe-area-inset-bottom));
    }
    
    .container {
        padding-left: max(var(--space-4), env(safe-area-inset-left));
        padding-right: max(var(--space-4), env(safe-area-inset-right));
    }
}

/* Aspect Ratio Support */
@supports (aspect-ratio: 1) {
    .game-image {
        aspect-ratio: 16 / 9;
        height: auto;
    }
}

/* Container Queries (Future-proofing) */
@supports (container-type: inline-size) {
    .game-card {
        container-type: inline-size;
    }
}

/* Performance: Reduce animations on low-end devices */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .reveal {
        opacity: 1;
        transform: none;
    }
}