/* ============================================================================
   GAMES SITE MOBILE STYLES
   Shared mobile stylesheet for games.html and games subdomain
   ============================================================================ */

/* ============================================================================
   MOBILE TOUCH & INTERACTION FIXES
   ============================================================================ */

/* Ensure touch events work on mobile */
html {
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

/* Ensure all interactive elements are touchable */
button, a, input, select, textarea {
    touch-action: manipulation;
}

/* ============================================================================
   TOUCH TARGET SIZES - WCAG AA Compliance
   Minimum 44x44px for all interactive elements on mobile
   ============================================================================ */

@media (max-width: 768px) {
    /* Buttons and clickable elements */
    button, .btn, .btn-primary, .btn-secondary, 
    .game-menu-button, .game-card, 
    [role="button"], .clickable {
        min-width: 44px;
        min-height: 44px;
        padding: 8px 12px;
    }
    
    /* Grid cells for games (Battleships, Sudoku, etc.) */
    .grid-cell, .board-cell, .sudoku-cell,
    .cell, [data-cell], [data-row][data-col] {
        min-width: 44px;
        min-height: 44px;
    }
    
    /* Cards - ensure they're readable and touchable */
    .card, .playing-card, .game-card-item {
        min-width: 60px; /* Cards need to be larger for readability */
        min-height: 84px;
    }
    
    /* Small UI elements - combine into larger touch targets */
    .icon-button, .close-btn, .menu-toggle {
        min-width: 44px;
        min-height: 44px;
        padding: 8px;
    }
    
    /* Form inputs */
    input[type="text"], input[type="number"], 
    input[type="password"], input[type="email"],
    select, textarea {
        min-height: 44px;
        padding: 8px 12px;
    }
    
    /* Links and navigation items */
    a, .nav-link, .menu-item {
        min-height: 44px;
        padding: 8px 12px;
        display: inline-flex;
        align-items: center;
    }
    
    /* Ensure adequate spacing between touch targets */
    button + button, .btn + .btn,
    .grid-cell + .grid-cell {
        margin-left: 8px;
        margin-top: 8px;
    }
    
    /* Game-specific touch targets */
    .dice, .peg, .can-item, .character-item {
        min-width: 44px;
        min-height: 44px;
    }
    
    /* Number buttons (Countdown, etc.) */
    .number-btn, .num-button, [data-number] {
        min-width: 48px;
        min-height: 48px;
        font-size: 1.2rem;
    }
}

/* Force login screen to be interactive on mobile */
.login-screen, .login-container, .login-box {
    touch-action: auto !important;
    pointer-events: auto !important;
}

/* Ensure form elements work on mobile */
.login-screen input,
.login-screen button,
.login-screen a,
.login-screen .btn,
.login-screen .btn-link {
    touch-action: manipulation !important;
    pointer-events: auto !important;
    cursor: pointer !important;
}

/* Nuclear option: Force ALL interactive elements to work */
button, 
a, 
input, 
textarea, 
select, 
[role="button"], 
.btn, 
.btn-link,
.btn-primary, 
.btn-secondary,
.burger-menu, 
.close-menu,
.game-card,
.auth-toggle button,
#auth-continue-guest,
[type="submit"] {
    pointer-events: auto !important;
    cursor: pointer !important;
    touch-action: manipulation !important;
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1) !important;
}

/* Make sure game cards are always clickable */
.game-card, .game-card * {
    pointer-events: auto !important;
}

/* Override any blocking styles on forms */
form, .auth-form, .login-box {
    pointer-events: auto !important;
}

/* Ensure user display elements are touchable */
.user-display, .user-display *, 
.profile-avatar, .profile-badge,
#user-display-container, #user-display-container *,
#mobile-user-display-container, #mobile-user-display-container * {
    pointer-events: auto !important;
    touch-action: manipulation !important;
}

/* Allow text selection in inputs and textareas */
input, textarea {
    -webkit-user-select: text !important;
    user-select: text !important;
}

/* ============================================================================
   MOBILE NAVIGATION
   ============================================================================ */

.burger-menu {
    display: none;
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--primary-color, #C90C0F);
    cursor: pointer;
    padding: 0.5rem;
    transition: transform 0.3s ease, background-color 0.2s ease;
    -webkit-tap-highlight-color: rgba(201, 12, 15, 0.1);
    border-radius: 4px;
    position: relative;
    z-index: 9999;
}

.burger-menu:hover {
    transform: scale(1.1);
    background-color: rgba(201, 12, 15, 0.1);
}

.burger-menu:active {
    transform: scale(0.95);
    background-color: rgba(201, 12, 15, 0.2);
}

.mobile-nav {
    display: none;
    position: fixed;
    top: 0;
    right: -100%;
    width: 280px;
    height: 100vh;
    background: var(--surface, #FFFFFF);
    box-shadow: -2px 0 10px rgba(0, 0, 0, 0.1);
    padding: 2rem;
    z-index: 9998;
    transition: right 0.3s ease;
    overflow-y: auto;
    pointer-events: auto !important;
    touch-action: auto !important;
}

/* Ensure all mobile nav content is touchable */
.mobile-nav *, .mobile-nav-header *, .mobile-drawer * {
    pointer-events: auto !important;
}

.mobile-nav.active {
    right: 0;
}

.mobile-nav-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid var(--border-color, #e2e8f0);
}

.close-menu {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--primary-color, #C90C0F);
    cursor: pointer;
    padding: 0.5rem;
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    -webkit-tap-highlight-color: rgba(201, 12, 15, 0.1);
    border-radius: 4px;
    transition: background-color 0.2s ease;
    position: relative;
    z-index: 1;
}

.close-menu:hover {
    background-color: rgba(201, 12, 15, 0.1);
}

.close-menu:active {
    transform: scale(0.95);
    background-color: rgba(201, 12, 15, 0.2);
}

.mobile-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9997;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.mobile-overlay.active {
    opacity: 1;
}

/* ============================================================================
   DESKTOP & TABLET - Hide mobile structure
   ============================================================================ */

.game-mobile-item {
    display: none;
}

/* ============================================================================
   TABLET VIEW (max-width: 1024px)
   ============================================================================ */

@media (max-width: 1024px) {
    .game-card {
        flex: 0 1 calc(50% - 1rem);
    }
    
    .game-mobile-item {
        display: none;
    }
}

/* ============================================================================
   MOBILE VIEW (max-width: 768px)
   ============================================================================ */

@media (max-width: 768px) {
    /* Header adjustments */
    .header {
        padding: 1rem;
        margin-bottom: 2rem;
    }

    .header-content {
        gap: 1rem;
    }

    .header-text {
        flex: 1;
        overflow: hidden;
    }

    h1 {
        font-size: 1.5rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .user-display-wrapper {
        display: none;
    }

    /* Show burger menu */
    .burger-menu {
        display: flex;
        align-items: center;
        justify-content: center;
        flex-shrink: 0;
        min-width: 44px;
        min-height: 44px;
    }

    /* Show mobile navigation */
    .mobile-nav {
        display: block;
    }

    .mobile-overlay {
        display: block;
    }

    /* Container adjustments */
    .container {
        padding: 0 1rem 2rem;
    }

    /* Games grid adjustments - convert to list on mobile */
    .games-grid {
        display: flex;
        flex-direction: column;
        gap: 0.75rem;
        padding: 0;
    }

    /* Hide desktop card structure on mobile */
    .game-card .game-image,
    .game-card .game-content {
        display: none;
    }

    /* Show mobile list structure */
    .game-mobile-item {
        display: block;
        width: 100%;
    }

    /* Mobile list item styling */
    .game-card {
        display: block;
        flex: none;
        width: 100%;
        background: var(--surface, #FFFFFF);
        border: 2px solid var(--border-color, #e2e8f0);
        border-radius: 0.5rem;
        padding: 0;
        margin: 0;
        text-decoration: none;
        color: var(--text-primary, #1D1D1B);
        box-shadow: var(--shadow-md, 0 4px 6px -1px rgba(0, 0, 0, 0.1));
        transition: box-shadow 0.2s ease;
    }

    .game-card:active {
        box-shadow: var(--shadow-sm, 0 1px 2px 0 rgba(0, 0, 0, 0.05));
    }

    /* Mobile header row */
    .game-mobile-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 1rem;
        gap: 0.75rem;
    }

    .game-mobile-title {
        flex: 1;
        font-size: 1.1rem;
        font-weight: 700;
        color: var(--primary-color, #C90C0F);
        line-height: 1.3;
        display: flex;
        align-items: center;
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .daily-status-badge.mobile {
        display: inline-flex;
        position: static;
        margin: 0;
        padding: 0.25rem 0.5rem;
        font-size: 0.65rem;
        vertical-align: middle;
        flex-shrink: 0;
    }

    .daily-status-badge.mobile span {
        display: none;
    }

    /* Mobile actions (toggle + play button) */
    .game-mobile-actions {
        display: flex;
        align-items: center;
        gap: 0.5rem;
        flex-shrink: 0;
    }

    /* Dropdown toggle button */
    .game-mobile-toggle {
        background: transparent;
        border: 2px solid var(--border-color, #e2e8f0);
        border-radius: 0.375rem;
        width: 36px;
        height: 36px;
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        color: var(--text-secondary, #64748b);
        transition: all 0.2s ease;
        padding: 0;
        flex-shrink: 0;
    }

    .game-mobile-toggle:active {
        background-color: var(--border-color, #e2e8f0);
        transform: scale(0.95);
    }

    .game-mobile-toggle i {
        font-size: 0.85rem;
        transition: transform 0.2s ease;
    }

    /* Play button on mobile */
    .game-mobile-play {
        display: inline-flex;
        align-items: center;
        gap: 0.4rem;
        background: var(--primary-color, #C90C0F);
        color: white;
        padding: 0.5rem 1rem;
        border-radius: 0.375rem;
        font-weight: 600;
        font-size: 0.9rem;
        text-decoration: none;
        transition: background 0.2s ease;
        white-space: nowrap;
        flex-shrink: 0;
    }

    .game-mobile-play:active {
        background: var(--primary-hover, #a00a0c);
    }

    .game-mobile-play i {
        font-size: 0.8rem;
    }

    /* Mobile details dropdown */
    .game-mobile-details {
        max-height: 0;
        overflow: hidden;
        transition: max-height 0.3s ease, padding 0.3s ease;
        padding: 0 1rem;
        position: relative;
    }

    .game-mobile-details.open {
        max-height: 1000px;
        padding: 0 1rem 1rem 1rem;
    }

    /* Poster background at 50% opacity */
    .game-mobile-details.open::before {
        content: '';
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background-image: var(--poster-image, none);
        background-size: cover;
        background-position: center;
        background-repeat: no-repeat;
        opacity: 0.5;
        z-index: 0;
        pointer-events: none;
        border-radius: 0 0 0.5rem 0.5rem;
    }

    /* Ensure content is above background */
    .game-mobile-details.open > * {
        position: relative;
        z-index: 1;
    }

    .game-mobile-description {
        font-size: 0.9rem;
        color: var(--text-secondary, #64748b);
        line-height: 1.6;
        margin-bottom: 0.75rem;
    }

    /* Daily challenge stats styling */
    .game-mobile-daily-stats {
        margin-bottom: 0.75rem;
        padding: 0.75rem;
        background: rgba(255, 255, 255, 0.9);
        border-radius: 0.375rem;
        border: 1px solid var(--border-color, #e2e8f0);
    }

    .daily-stats-header {
        display: flex;
        align-items: center;
        gap: 0.5rem;
        font-size: 0.85rem;
        font-weight: 700;
        color: var(--primary-color, #C90C0F);
        margin-bottom: 0.5rem;
        text-transform: uppercase;
        letter-spacing: 0.05em;
    }

    .daily-stats-header i {
        color: var(--secondary-color, #FAB719);
    }

    .daily-stats-grid {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
    }

    .daily-stat-item {
        text-align: center;
    }

    .daily-stat-label {
        font-size: 0.75rem;
        color: var(--text-secondary, #64748b);
        margin-bottom: 0.25rem;
        text-transform: uppercase;
        letter-spacing: 0.05em;
    }

    .daily-stat-value {
        font-size: 1.25rem;
        font-weight: 700;
        color: var(--primary-color, #C90C0F);
    }

    .daily-stats-loading,
    .daily-stats-none,
    .daily-stats-error {
        font-size: 0.85rem;
        color: var(--text-secondary, #64748b);
        text-align: center;
        padding: 0.5rem;
        font-style: italic;
    }

    .daily-stats-error {
        color: #DC2626;
    }

    /* Stats bar in mobile dropdown */
    .game-mobile-details .stats-bar {
        padding: 0.6rem 0.75rem;
        gap: 0.35rem;
        margin-top: 0.5rem;
    }

    .game-mobile-details .stat-value {
        font-size: 1rem;
    }

    .game-mobile-details .stat-label {
        font-size: 0.65rem;
    }
}

/* ============================================================================
   SMALL MOBILE VIEW (max-width: 480px)
   ============================================================================ */

@media (max-width: 480px) {
    .header {
        padding: 0.75rem;
    }

    h1 {
        font-size: 1.25rem;
    }

    .game-mobile-header {
        padding: 0.875rem;
    }

    .game-mobile-title {
        font-size: 1rem;
    }

    .game-mobile-play {
        padding: 0.45rem 0.85rem;
        font-size: 0.85rem;
    }

    .game-mobile-toggle {
        width: 32px;
        height: 32px;
    }

    .game-mobile-details.open {
        padding: 0 0.875rem 0.875rem 0.875rem;
    }

    .game-mobile-description {
        font-size: 0.85rem;
    }
}


