/* ============================================
   RESPONSIVE DESIGN - ENHANCED
   ============================================ */

/* Large Desktop (1400px+) */
@media (min-width: 1400px) {
    .container-custom {
        max-width: 1320px;
    }
}

/* Desktop (1200px - 1399px) */
@media (max-width: 1399px) {
    .container-custom {
        max-width: 1140px;
    }
}

/* Tablet Landscape (992px - 1199px) */
@media (max-width: 1199px) {
    .container-custom {
        max-width: 960px;
    }
    
    .custom-grid {
        grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
        gap: 1.5rem;
    }
    
    .product-grid {
        grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
        gap: 1.5rem;
    }
    
    .hero {
        padding: 100px 5% 70px;
    }
    
    .section-padding {
        padding: 4.5rem 5%;
    }
}

/* Tablet Portrait (768px - 991px) */
@media (max-width: 991px) {
    /* Layout adjustments */
    .custom-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1.5rem;
    }
    
    .screenshot-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .product-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
    
    /* Hero section */
    .hero {
        min-height: 90vh;
        padding: 100px 5% 60px;
    }
    
    .title-hero {
        font-size: 2rem;
        margin-bottom: 1.25rem;
    }
    
    .text-hero {
        font-size: 1rem;
    }
    
    /* Buttons */
    .btndiv {
        flex-direction: column;
        width: 100%;
        gap: 1rem;
    }
    
    .eightbit-btn {
        width: 100%;
        max-width: 400px;
    }
    
    /* Sections */
    .section-padding {
        padding: 4rem 5%;
    }
    
    .section-divider {
        margin: 3rem 5%;
    }
    
    .section-title {
        font-size: 2rem;
    }
    
    /* Product cards */
    .product-card {
        border-radius: 10px;
    }
    
    .product-img {
        height: 200px;
    }
    
    .product-content {
        padding: 1.25rem;
    }
    
    .product-card h3 {
        font-size: 1.1rem;
        line-height: 1.5;
    }
    
    /* Game cards */
    .cardblog h3 {
        font-size: 1.1rem;
    }
    
    .imgblog {
        height: 200px;
    }
    
    /* Footer */
    .footer {
        padding: 1.25rem 5% 1.5rem;
    }
    
    /* Navigation - Mobile menu trigger */
    .navbar-toggler {
        display: block;
    }
    
    .navbar-nav {
        display: none;
        position: fixed;
        top: 70px;
        left: 0;
        right: 0;
        background: rgba(0, 12, 36, 0.98);
        backdrop-filter: blur(15px);
        -webkit-backdrop-filter: blur(15px);
        padding: 1.5rem;
        border-top: 2px solid rgba(195, 0, 255, 0.3);
        border-bottom: 2px solid rgba(195, 0, 255, 0.3);
        flex-direction: column;
        gap: 0.5rem;
        animation: slideDown 0.3s ease-out;
        max-height: calc(100vh - 70px);
        overflow-y: auto;
        z-index: 999;
    }
    
    @keyframes slideDown {
        from {
            opacity: 0;
            transform: translateY(-10px);
        }
        to {
            opacity: 1;
            transform: translateY(0);
        }
    }
    
    .navbar-nav.active {
        display: flex;
    }
    
    .nav-item {
        width: 100%;
        margin: 0.25rem 0;
    }
    
    .btn-primary,
    .btn-nav {
        width: 100%;
        justify-content: center;
        text-align: center;
    }
    
    /* Game detail page */
    .game-header {
        padding: 5rem 5% 1.5rem;
    }
    
    .emulator-wrapper {
        padding: 1.5rem;
    }
    
    .emulator-frame {
        min-height: 500px;
    }
    
    .control-list {
        grid-template-columns: 1fr;
    }
}

/* Mobile Landscape & Small Tablets (576px - 767px) */
@media (max-width: 767px) {
    /* Typography */
    .title-hero {
        font-size: 1.5rem;
        line-height: 1.3;
    }
    
    .section-title {
        font-size: 1.5rem;
        margin-bottom: 1.25rem;
    }
    
    /* Layout */
    .custom-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
    
    .section-padding {
        padding: 3.5rem 5%;
    }
    
    /* Navigation */
    #navbar {
        padding: 0.75rem 5%;
    }
    
    body {
        padding-top: 60px;
    }
    
    .logonav {
        height: 36px;
    }
    
    .navbar-nav {
        padding: 1.25rem;
        top: 60px;
    }
    
    /* Cards */
    .cardblog {
        border-radius: 10px;
    }
    
    .cardblog h3 {
        font-size: 1rem;
        line-height: 1.5;
    }
    
    .imgblog {
        height: 180px;
    }
    
    .imgblog::after {
        font-size: 1.5rem;
    }
    
    .contentblog {
        padding: 1.25rem;
    }
    
    .titlegames {
        font-size: 0.9rem;
    }
    
    /* Product cards */
    .product-card {
        border-radius: 10px;
    }
    
    .product-img {
        height: 180px;
    }
    
    .product-content {
        padding: 1.25rem;
    }
    
    .product-card h3 {
        font-size: 1rem;
        line-height: 1.5;
    }
    
    .product-subtitle {
        font-size: 0.65rem;
    }
    
    .product-card p {
        font-size: 0.9rem;
    }
    
    /* Buttons */
    .btn-nav {
        font-size: 0.65rem;
        padding: 0.75rem 1.25rem;
    }
    
    .eightbit-btn {
        font-size: 0.75rem;
        padding: 0.875rem 1.5rem;
    }
    
    /* Footer */
    .footer {
        padding: 1.25rem 5% 1.5rem;
    }
    
    .footer-bottom {
        flex-direction: column;
        text-align: center;
        gap: 1.5rem;
    }
    
    .social-links {
        justify-content: center;
    }
    
    .footer-title {
        margin-top: 2rem;
    }
    
    /* Hero */
    .hero {
        min-height: 85vh;
        padding: 90px 5% 50px;
    }
    
    /* Background orbs - slightly smaller */
    .bg-orb-1 {
        width: 450px;
        height: 450px;
    }
    
    .bg-orb-2 {
        width: 400px;
        height: 400px;
    }
    
    /* Game detail */
    .game-title {
        font-size: 1.75rem;
    }
    
    .game-meta {
        gap: 1rem;
        font-size: 0.85rem;
    }
    
    .emulator-wrapper {
        padding: 1.25rem;
    }
    
    .emulator-frame {
        min-height: 450px;
    }
    
    .game-description {
        padding: 2.5rem 5%;
    }
    
    .game-description p {
        font-size: 1rem;
    }
    
    .game-controls {
        padding: 1.5rem;
    }
    
    .game-controls h3 {
        font-size: 1rem;
    }
}

/* Mobile Portrait (320px - 575px) */
@media (max-width: 575px) {
    /* Typography */
    .title-hero {
        font-size: 1.25rem;
        margin-bottom: 1rem;
    }
    
    .text-hero {
        font-size: 0.9rem;
        line-height: 1.5;
    }
    
    .section-title {
        font-size: 1.25rem;
    }
    
    /* Hero */
    .hero {
        padding: 80px 5% 40px;
        min-height: 80vh;
    }
    
    /* Buttons */
    .eightbit-btn {
        font-size: 0.7rem;
        padding: 0.875rem 1.25rem;
    }
    
    .btndiv {
        gap: 0.875rem;
        margin-top: 2rem;
    }
    
    .btn-nav {
        font-size: 0.65rem;
        padding: 0.75rem 1.25rem;
    }
    
    .btn-nav img,
    .btn-nav .icon {
        width: 16px;
        height: 16px;
    }
    
    /* Sections */
    .section-padding {
        padding: 3rem 5%;
    }
    
    /* Cards */
    .imgblog {
        height: 180px;
    }
    
    .cardblog {
        border-radius: 8px;
    }
    
    .cardblog h3 {
        font-size: 0.9rem;
    }
    
    .contentblog {
        padding: 1rem;
    }
    
    .titlegames {
        font-size: 0.85rem;
        margin-bottom: 1rem;
    }
    
    /* Product cards */
    .product-card {
        border-radius: 8px;
    }
    
    .product-img {
        height: 180px;
    }
    
    .product-content {
        padding: 1rem;
    }
    
    .product-card h3 {
        font-size: 0.9rem;
    }
    
    .product-subtitle {
        font-size: 0.6rem;
    }
    
    .product-card p {
        font-size: 0.9rem;
        line-height: 1.6;
        margin-bottom: 1.5rem;
    }
    
    .emailtext {
        font-size: 0.95rem;
    }
    
    /* Footer */
    .footer {
        padding: 1.25rem 5% 1.5rem;
    }
    
    .footer-brand {
        margin-bottom: 0.75rem;
        font-size: 1rem;
    }
    
    .footer-description {
        font-size: 0.85rem;
        line-height: 1.5;
    }
    
    .footer-title {
        font-size: 0.75rem;
        margin-top: 2rem;
        margin-bottom: 1.25rem;
    }
    
    .footer-links a {
        font-size: 0.85rem;
    }
    
    .footer-links li {
        margin-bottom: 0.5rem;
    }
    
    .social-links {
        justify-content: center;
        margin-top: 1.5rem;
        gap: 1.5rem;
    }
    
    .social-links a {
        font-size: 0.85rem;
    }
    
    .footer-copyright {
        font-size: 0.8rem;
    }
    
    .footer-bottom {
        padding-top: 1rem;
        margin-top: 1rem;
    }
    
    /* Background orbs - smaller for performance */
    .bg-orb-1 {
        width: 400px;
        height: 400px;
    }
    
    .bg-orb-2 {
        width: 350px;
        height: 350px;
    }
    
    /* Category filters */
    .category-filters {
        gap: 0.75rem;
        margin-bottom: 2rem;
    }
    
    .category-btn {
        font-size: 0.6rem;
        padding: 0.625rem 1.25rem;
    }
    
    /* Game detail */
    .game-header {
        padding: 4.5rem 5% 1.5rem;
    }
    
    .game-title {
        font-size: 1.5rem;
        line-height: 1.3;
    }
    
    .game-meta {
        flex-direction: column;
        gap: 0.75rem;
    }
    
    .game-meta-label {
        font-size: 0.6rem;
    }
    
    .emulator-container {
        padding: 0 3%;
    }
    
    .emulator-wrapper {
        padding: 1rem;
        border-width: 2px;
    }
    
    .emulator-frame {
        min-height: 400px;
    }
    
    .game-description {
        padding: 2rem 5%;
    }
    
    .game-description p {
        font-size: 0.95rem;
        line-height: 1.7;
    }
    
    .game-controls {
        padding: 1.25rem;
        margin-top: 1.5rem;
    }
    
    .game-controls h3 {
        font-size: 0.9rem;
        margin-bottom: 1.25rem;
    }
    
    .control-item {
        padding: 0.625rem;
    }
    
    .control-key {
        font-size: 0.65rem;
    }
    
    .control-action {
        font-size: 0.85rem;
    }
    
    .back-btn {
        font-size: 0.65rem;
        margin: 1.5rem 0;
    }
}

/* Extra Small Devices (< 375px) */
@media (max-width: 374px) {
    .title-hero {
        font-size: 1.1rem;
    }
    
    .screenshot-grid {
        grid-template-columns: 1fr;
    }
    
    .section-title {
        font-size: 1.1rem;
    }
    
    .eightbit-btn {
        font-size: 0.65rem;
        padding: 0.75rem 1rem;
    }
    
    .btn-nav {
        font-size: 0.6rem;
        padding: 0.65rem 1rem;
    }
    
    .cardblog h3 {
        font-size: 0.85rem;
    }
    
    .product-card h3 {
        font-size: 1.1rem;
    }
    
    .product-img {
        height: 160px;
    }
    
    .imgblog {
        height: 160px;
    }
    
    .section-padding {
        padding: 2.5rem 5%;
    }
    
    .game-title {
        font-size: 1.25rem;
    }
    
    .emulator-frame {
        min-height: 350px;
    }
}

/* Landscape Mode Fix for Mobile Devices */
@media (max-height: 500px) and (orientation: landscape) {
    .hero {
        min-height: auto;
        padding: 100px 5% 50px;
    }
    
    .title-hero {
        font-size: 1.5rem;
        margin-bottom: 1rem;
    }
    
    .text-hero {
        font-size: 0.85rem;
    }
    
    .btndiv {
        margin-top: 1.5rem;
        flex-direction: row;
        gap: 1rem;
    }
    
    .eightbit-btn {
        padding: 0.75rem 1.5rem;
        width: auto;
    }
    
    .section-padding {
        padding: 3rem 5%;
    }
    
    #navbar {
        padding: 0.5rem 3%;
    }
    
    .logonav {
        height: 32px;
    }
}

/* Tablet Landscape (touch devices) */
@media (max-width: 1024px) and (orientation: landscape) {
    .hero {
        min-height: 100vh;
    }
    
    .emulator-frame {
        min-height: 500px;
    }
}

/* High DPI Displays (Retina) */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    /* Ensure images and graphics look sharp on retina displays */
    .imgblog img,
    .productsimgs {
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
    }
    
    /* Slightly reduce blur effects for better performance on retina */
    body::after {
        opacity: 0.003;
    }
}

/* Reduced Motion for Accessibility */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
    
    body::before,
    body::after {
        animation: none !important;
    }
    
    .bg-orb {
        animation: none !important;
    }
    
    .loading-spinner {
        animation: none !important;
        border-top-color: var(--purpl);
        border-bottom-color: var(--purpl);
    }
    
    .title-hero {
        animation: none !important;
    }
    
    .section-title::after {
        animation: none !important;
    }
    
    .productsimgs {
        animation: none !important;
    }
    
    html {
        scroll-behavior: auto;
    }
}

/* Dark mode support (if system prefers dark) */
@media (prefers-color-scheme: dark) {
    /* Already dark by default, but can enhance */
    body {
        background-color: var(--bg);
    }
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
    .cardblog,
    .product-card {
        border-width: 3px;
    }
    
    .btn-nav,
    .eightbit-btn {
        border-width: 3px;
    }
    
}

/* Print Styles */
@media print {
    body::before,
    body::after,
    .bg-orb,
    .imgcity,
    #navbar,
    .footer,
    .navbar-toggler,
    .btn-nav,
    .eightbit-btn,
    .loading {
        display: none !important;
    }
    
    body {
        background: white;
        color: black;
    }
    
    a {
        text-decoration: underline;
        color: black;
    }
    
    .hero {
        page-break-after: always;
        min-height: auto;
        padding: 2rem 1rem;
    }
    
    .section-padding {
        padding: 2rem 1rem;
    }
    
    .cardblog,
    .product-card {
        border: 2px solid black;
        page-break-inside: avoid;
    }
    
    .title-hero,
    .section-title {
        color: black;
        text-shadow: none;
    }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
    /* Larger tap targets for touch devices */
    .btn-primary,
    .btn-nav,
    .eightbit-btn {
        min-height: 44px; /* iOS recommendation */
        padding: 0.875rem 1.5rem;
    }
    
    .navbar-toggler {
        min-width: 44px;
        min-height: 44px;
    }
    
    .footer-links a,
    .social-links a {
        padding: 0.5rem;
        margin: -0.5rem;
    }
    
    /* Remove hover effects on touch devices */
    .cardblog:hover,
    .product-card:hover {
        transform: none;
    }
    
    /* Tap highlight color */
    * {
        -webkit-tap-highlight-color: rgba(195, 0, 255, 0.2);
    }
}

/* Specific device fixes */

/* iPhone X, XS, 11 Pro, 12 mini */
@media only screen 
  and (device-width: 375px) 
  and (device-height: 812px) 
  and (-webkit-device-pixel-ratio: 3) {
    .hero {
        padding: 100px 5% 60px;
        padding-bottom: env(safe-area-inset-bottom, 60px);
    }
}

/* iPhone XR, 11, 12, 12 Pro */
@media only screen 
  and (device-width: 414px) 
  and (device-height: 896px) 
  and (-webkit-device-pixel-ratio: 2) {
    .hero {
        padding: 100px 5% 60px;
        padding-bottom: env(safe-area-inset-bottom, 60px);
    }
}

/* Safe area insets for notched devices */
@supports (padding: env(safe-area-inset-top)) {
    #navbar {
        padding-top: calc(1rem + env(safe-area-inset-top));
    }
    
    .footer {
        padding-bottom: calc(2rem + env(safe-area-inset-bottom));
    }
}

/* ============================================
   UTILITY RESPONSIVE CLASSES
   ============================================ */

/* Hide on mobile */
@media (max-width: 767px) {
    .hide-mobile {
        display: none !important;
    }
}

/* Hide on tablet */
@media (min-width: 768px) and (max-width: 991px) {
    .hide-tablet {
        display: none !important;
    }
}

/* Hide on desktop */
@media (min-width: 992px) {
    .hide-desktop {
        display: none !important;
    }
}

/* Show only on mobile */
.show-mobile {
    display: none !important;
}

@media (max-width: 767px) {
    .show-mobile {
        display: block !important;
    }
}