/* Mobile & TV/Firestick Optimization CSS */

/* Prevent horizontal scroll on all devices */
html, body {
    overflow-x: hidden;
    max-width: 100vw;
}

/* Ensure main content doesn't overlap with mobile menu button */
@media (max-width: 768px) {
    .hero-content {
        padding-top: 80px !important;
    }

    /* Make sure sidebar doesn't cover content when closed */
    .sidebar:not(.active) {
        pointer-events: none;
    }

    .sidebar.active {
        pointer-events: all;
    }

    /* Overlay when sidebar is open */
    .sidebar.active::before {
        content: '';
        position: fixed;
        top: 0;
        left: 280px;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: -1;
    }

    /* Ensure mobile button is always visible and clickable */
    .mobile-sidebar-btn {
        position: fixed !important;
        top: 20px !important;
        left: 20px !important;
        z-index: 1002 !important;
        touch-action: manipulation;
        -webkit-tap-highlight-color: transparent;
    }

    /* Prevent text selection on buttons for better mobile UX */
    .btn, .mobile-sidebar-btn, .sidebar-toggle {
        user-select: none;
        -webkit-user-select: none;
        -webkit-touch-callout: none;
    }

    /* Better tap targets for mobile */
    .nav-link {
        min-height: 48px;
        display: flex;
        align-items: center;
        padding: 12px 16px;
    }

    /* Fix game cards on mobile */
    .game-card {
        width: 100%;
        max-width: 100%;
    }

    .game-image img {
        width: 100%;
        height: auto;
        object-fit: cover;
    }

    /* Ensure buttons are full width on mobile */
    .game-link, .tool-link, .console-link {
        width: 100% !important;
        text-align: center;
        justify-content: center;
    }

    /* Fix hero stats spacing on mobile */
    .hero-stats {
        width: 100%;
        max-width: 100%;
        overflow: hidden;
    }

    .stat {
        flex: 1;
        min-width: 0;
    }

    /* Improve touch scrolling */
    .sidebar-nav {
        -webkit-overflow-scrolling: touch;
    }

    /* Fix footer on mobile */
    .footer-content {
        grid-template-columns: 1fr !important;
        gap: 2rem;
    }

    .footer-section {
        width: 100%;
        text-align: center;
    }
}

/* Extra small phones */
@media (max-width: 480px) {
    /* Reduce padding on very small screens */
    .container {
        padding-left: 1rem !important;
        padding-right: 1rem !important;
    }

    .main-content {
        padding-left: 0.5rem !important;
        padding-right: 0.5rem !important;
    }

    /* Make text more readable */
    .hero-title {
        font-size: 2rem !important;
    }

    .hero-subtitle {
        font-size: 1rem !important;
    }

    /* Better button sizing for small phones */
    .btn {
        padding: 0.75rem 1rem !important;
        font-size: 0.9rem !important;
    }

    /* Fix card spacing */
    .games-grid, .tools-grid, .console-grid {
        gap: 1rem !important;
    }
}

/* TV/Firestick specific optimizations */
@media (min-width: 1280px) {
    /* Larger click targets for TV remotes */
    .nav-link {
        padding: 1rem 1.5rem;
        font-size: 1.1rem;
    }

    /* Make buttons more prominent for TV */
    .btn {
        min-height: 60px;
        font-size: 1.1rem;
    }

    /* Better focus states for TV navigation */
    .nav-link:focus,
    .btn:focus,
    .game-link:focus {
        outline: 3px solid var(--primary-color);
        outline-offset: 3px;
    }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
    /* Remove hover effects on touch devices */
    .game-card:hover,
    .tool-card:hover,
    .console-card:hover {
        transform: none !important;
    }

    /* Larger tap targets */
    .btn,
    .game-link,
    .nav-link {
        min-height: 44px;
        padding: 12px 20px;
    }

    /* Better active states */
    .btn:active {
        transform: scale(0.98);
        opacity: 0.9;
    }
}

/* Landscape mobile devices */
@media (max-width: 896px) and (orientation: landscape) {
    .hero {
        min-height: 100vh !important;
    }

    .hero-content {
        padding: 2rem 1rem !important;
    }

    .sidebar {
        max-width: 60vw !important;
    }
}

/* Prevent text size adjustment on iOS */
@supports (-webkit-touch-callout: none) {
    html {
        -webkit-text-size-adjust: 100%;
    }
}

/* Fix for notched devices (iPhone X, etc.) */
@supports (padding: max(0px)) {
    body {
        padding-left: env(safe-area-inset-left);
        padding-right: env(safe-area-inset-right);
    }

    .mobile-sidebar-btn {
        left: max(20px, env(safe-area-inset-left)) !important;
    }
}

/* Ensure images don't break layout */
img {
    max-width: 100%;
    height: auto;
}

/* Fix for flex/grid overflow issues */
.games-grid,
.tools-grid,
.console-grid,
.cheats-grid {
    width: 100%;
    max-width: 100%;
}

/* Accessibility improvements */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .btn {
        border: 2px solid currentColor;
    }

    .game-card,
    .tool-card,
    .console-card {
        border: 2px solid var(--border-color);
    }
}

/* Dark mode specific fixes */
@media (prefers-color-scheme: dark) {
    /* Already dark by default, ensure proper contrast */
    .mobile-sidebar-btn {
        background: rgba(30, 41, 59, 0.95);
        backdrop-filter: blur(10px);
    }
}

/* Fix z-index stacking issues */
.mobile-sidebar-btn {
    z-index: 1002;
}

.sidebar {
    z-index: 1001;
}

.main-content {
    z-index: 1;
}

/* Ensure clickable areas don't overlap */
.game-card,
.tool-card,
.console-card {
    position: relative;
    z-index: 1;
}

/* Fix console card links being unclickable */
.console-card {
    pointer-events: all !important;
}

.console-link {
    pointer-events: all !important;
    position: relative;
    z-index: 10;
    cursor: pointer;
    -webkit-tap-highlight-color: rgba(99, 102, 241, 0.3);
}

.console-image {
    pointer-events: none;
}

.console-info {
    pointer-events: all;
}

/* Fix for cards being too wide on tablets */
@media (min-width: 769px) and (max-width: 1024px) {
    .games-grid,
    .tools-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Smooth scrolling for better UX */
@media (prefers-reduced-motion: no-preference) {
    html {
        scroll-behavior: smooth;
    }
}

/* Fix potential sidebar overlay issues */
@media (max-width: 768px) {
    /* Add backdrop when sidebar is open */
    body.sidebar-open::before {
        content: '';
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 1000;
        backdrop-filter: blur(2px);
    }

    /* Ensure sidebar is above backdrop */
    .sidebar.active {
        z-index: 1001;
    }

    /* Ensure mobile button is above everything */
    .mobile-sidebar-btn {
        z-index: 1003 !important;
    }
}

/* Fix for card images maintaining aspect ratio */
.game-image,
.cheat-image {
    position: relative;
    width: 100%;
    padding-top: 56.25%; /* 16:9 aspect ratio */
    overflow: hidden;
    border-radius: var(--border-radius) var(--border-radius) 0 0;
}

.game-image img,
.cheat-image img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Ensure info cards don't overflow */
.info-card,
.warning-card {
    max-width: 100%;
    overflow-wrap: break-word;
    word-wrap: break-word;
}

/* Better list spacing on mobile */
@media (max-width: 768px) {
    ol, ul {
        padding-left: 1.5rem;
    }

    li {
        margin-bottom: 0.5rem;
    }
}
