/**
 * Desktop Layout Enhancements
 * Professional desktop layout optimization with clean English styling
 * Target: Desktop screens only (min-width: 769px)
 */

/* ========================================
   Desktop-Only Layout Fixes
   ======================================== */

@media (min-width: 769px) {
    /* Primary game grid only (do not affect hero/search lists) */
    .game-grid {
        display: grid !important;
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)) !important;
        gap: 16px !important;
        align-items: stretch;
    }

    /* Exactly 6 cards per row on standard desktops */
    @media (min-width: 1024px) {
        .game-grid {
            grid-template-columns: repeat(6, minmax(0, 1fr)) !important;
        }
    }

    /* Consistent thumbnail height for card grid */
    .game-grid .game-item img {
        width: 100% !important;
        height: 140px !important;
        object-fit: cover !important;
        border-radius: 8px !important;
    }

    /* Enhanced header layout for better spacing */
    #header .head-inner {
        max-width: var(--maxPageWidth, 1860px);
        margin: 0 auto;
        padding: 0 24px;
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 32px;
    }

    /* Fix overlapping "NEW" badges */
    .other-btn {
        display: flex;
        align-items: center;
        gap: 16px;
        position: relative;
        z-index: 10;
    }

    .menu-btn {
        position: relative;
        z-index: 11;
    }

    .menu-btn i.new {
        display: block;
        position: relative;
        z-index: 12;
    }

    /* Improved dropdown positioning */
    .new-games-pop-up {
        position: absolute;
        top: calc(100% + 12px);
        left: 0;
        right: auto;
        transform: none;
        z-index: 1000;
        background: white;
        border-radius: 16px;
        box-shadow: var(--shadow-mid);
        border: 1px solid rgba(93, 107, 132, 0.1);
        min-width: 220px;
        opacity: 0;
        visibility: hidden;
        transition: all 0.2s ease;
    }

    .menu-btn[data-newgames-toggle]:hover .new-games-pop-up,
    .new-games-pop-up:hover {
        opacity: 1;
        visibility: visible;
        transform: translateY(0);
    }

    /* Enhanced game grid layout - fixed 6 per row on desktop */
    .game-grid {
        display: grid !important;
        grid-template-columns: repeat(6, minmax(0, 1fr)) !important;
        gap: 16px !important;
        padding: 24px 0;
        max-width: var(--maxPageWidth, 1860px);
        margin: 0 auto;
    }

    .game-grid .post {
        background: var(--poki-card-bg, white);
        border-radius: 20px;
        overflow: hidden;
        transition: all 0.3s cubic-bezier(0.25, 0.1, 0.25, 1);
        box-shadow: var(--shadow-close);
        position: relative;
    }

    .game-grid .post:hover {
        transform: translateY(-8px) scale(1.02);
        box-shadow: var(--shadow-hover);
    }

    .game-grid .game-item {
        display: block;
        text-decoration: none;
        color: inherit;
        padding: 12px;
        position: relative;
    }

    .game-grid .game-item img {
        width: 100% !important;
        height: 140px !important;
        object-fit: cover;
        border-radius: 8px !important;
        margin-bottom: 8px;
        transition: transform 0.3s ease;
    }

    /* Game card badges optimization for smaller cards */
    .game-grid .card-flags {
        position: absolute;
        top: 16px;
        right: 16px;
        display: flex;
        gap: 4px;
        flex-direction: column;
        align-items: flex-end;
        z-index: 2;
    }

    .game-grid .badge {
        background: rgba(0, 156, 255, 0.95);
        color: white;
        padding: 2px 8px;
        border-radius: 12px;
        font-size: 10px;
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: 0.5px;
        box-shadow: 0 2px 8px rgba(0, 156, 255, 0.3);
        backdrop-filter: blur(4px);
    }

    .game-grid .badge.score {
        background: rgba(255, 159, 0, 0.95);
        box-shadow: 0 2px 8px rgba(255, 159, 0, 0.3);
    }

    .game-grid .post:hover .game-item img {
        transform: scale(1.05);
    }

    .game-grid .post-name {
        font-size: 13px;
        font-weight: 500;
        line-height: 1.3;
        color: var(--grey-3, #5d6b84);
        text-align: center;
        margin: 0;
        min-height: 32px;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 0 4px;
    }

    /* Load more button styling for desktop */
    .load-more-group {
        text-align: center;
        margin: 48px 0;
    }

    #loadMoreBtn {
        background: linear-gradient(135deg, var(--poki-blue, #009cff), var(--blue-5, #0074e0));
        color: white;
        border: none;
        padding: 16px 32px;
        border-radius: 24px;
        font-size: 16px;
        font-weight: 600;
        cursor: pointer;
        transition: all 0.3s ease;
        box-shadow: 0 4px 16px rgba(0, 156, 255, 0.3);
    }

    #loadMoreBtn:hover {
        transform: translateY(-2px);
        box-shadow: 0 8px 24px rgba(0, 156, 255, 0.4);
    }

    #loadMoreBtn:disabled {
        background: var(--grey-5, #bac9de);
        transform: none;
        box-shadow: none;
        cursor: not-allowed;
    }

    #loading {
        color: var(--poki-blue, #009cff);
        font-weight: 500;
        margin: 24px 0;
    }

    /* Section headers improvement */
    .section-head {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 32px;
        padding: 0 8px;
    }

    .section-head h2 {
        font-size: 2rem;
        font-weight: 700;
        color: var(--denim-blue, #002b50);
        margin: 0;
    }

    .tag-chip {
        background: var(--grey-7, #f0f5fc);
        color: var(--poki-blue, #009cff);
        padding: 8px 16px;
        border-radius: 16px;
        text-decoration: none;
        font-weight: 500;
        font-size: 14px;
        transition: all 0.2s ease;
        border: 1px solid transparent;
    }

    .tag-chip:hover {
        background: var(--poki-blue, #009cff);
        color: white;
        transform: translateY(-1px);
    }
    .poki-main {
        max-width: var(--maxPageWidth, 1860px);
        margin: 0 auto;
        padding: 24px;
        /* Remove forced min-height that created large empty space on short pages */
        min-height: auto;
    }

    /* Hero section enhancements */
    .poki-hero {
        background: linear-gradient(135deg, var(--grey-9, #f9fbff) 0%, white 100%);
        border-radius: 28px;
        padding: 48px;
        margin-bottom: 48px;
        box-shadow: var(--shadow-close);
    }

    .poki-hero h1 {
        font-size: clamp(2.5rem, 4vw, 3.5rem);
        font-weight: 700;
        color: var(--denim-blue, #002b50);
        margin-bottom: 24px;
        text-align: center;
    }

    /* Search enhancements */
    .search-form {
        flex: 1;
        max-width: 500px;
        margin: 0 24px;
    }

    .search-form form {
        display: flex;
        background: var(--grey-7, #f0f5fc);
        border-radius: 24px;
        padding: 4px;
        transition: box-shadow 0.2s ease;
    }

    .search-form form:focus-within {
        box-shadow: var(--shadow-close);
    }

    .search-form .search-input {
        flex: 1;
        border: none;
        background: transparent;
        padding: 12px 20px;
        font-size: 16px;
        outline: none;
        border-radius: 20px;
    }

    .search-form .btn {
        width: 48px;
        height: 48px;
        border: none;
        background: var(--poki-blue, #009cff);
        border-radius: 50%;
        cursor: pointer;
        transition: all 0.2s ease;
    }

    .search-form .btn:hover {
        background: var(--blue-5, #0074e0);
        transform: scale(1.05);
    }

    /* Navigation menu improvements */
    .menu {
        background: var(--pure-white, white);
        border-radius: 16px;
        box-shadow: var(--shadow-mid);
        margin-top: 16px;
    }

    .menu-ul {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 16px 24px;
    }

    .menu-ul li a {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 12px 20px;
        border-radius: 12px;
        text-decoration: none;
        color: var(--grey-3, #5d6b84);
        font-weight: 500;
        transition: all 0.2s ease;
    }

    .menu-ul li a:hover,
    .menu-ul li a.active {
        background: var(--grey-7, #f0f5fc);
        color: var(--poki-blue, #009cff);
        transform: translateY(-1px);
    }

    /* Category and tag styling */
    .category-grid,
    .tag-grid {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
        gap: 24px;
        margin: 32px 0;
    }

    /* Page title improvements */
    .page-title {
        font-size: 2.5rem;
        font-weight: 700;
        color: var(--denim-blue, #002b50);
        text-align: center;
        margin: 48px 0;
        position: relative;
    }

    .page-title::after {
        content: '';
        position: absolute;
        bottom: -16px;
        left: 50%;
        transform: translateX(-50%);
        width: 80px;
        height: 4px;
        background: linear-gradient(90deg, var(--poki-blue), var(--green-3));
        border-radius: 2px;
    }

    /* Footer spacing - sticky and compact */
    footer {
        margin-top: auto;
        padding: 24px;
        background: var(--grey-9, #f9fbff);
        border-top: 1px solid var(--grey-5, #bac9de);
    }
}

/* Large desktop optimizations - more games per row */
@media (min-width: 1400px) {
    .game-grid {
        grid-template-columns: repeat(6, minmax(0, 1fr)) !important;
        gap: 20px !important;
    }

    .poki-main {
        padding: 32px;
    }

    .poki-hero {
        padding: 48px;
        margin-bottom: 48px;
    }
}

/* Ultra-wide screen optimizations - maximum games display */
@media (min-width: 1920px) {
    .game-grid {
        grid-template-columns: repeat(6, minmax(0, 1fr)) !important;
        gap: 18px !important;
    }

    .poki-hero h1 {
        font-size: 3.5rem;
    }
}

/**
 * Accessibility and Performance Enhancements
 */

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .game-grid .post,
    .menu-ul li a,
    .search-form .btn {
        transition: none;
    }

    .game-grid .post:hover {
        transform: none;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .game-grid .post {
        border: 2px solid var(--grey-3, #5d6b84);
    }

    .menu-ul li a {
        border: 1px solid transparent;
    }

    .menu-ul li a:hover,
    .menu-ul li a.active {
        border-color: var(--poki-blue, #009cff);
    }
}

/* Focus management for keyboard navigation */
.game-grid .post:focus-within,
.menu-ul li a:focus {
    outline: 3px solid var(--poki-blue, #009cff);
    outline-offset: 2px;
}
