/**
 * GameHubJS - Games CSS
 * Shared styles for all game pages, lobby, and play containers.
 * Mobile-first, dark theme, fully responsive.
 * 
 * NOTE: Chat-specific styles live in chat.css (loaded by chat pages).
 * 
 * Filename: app/static/css/games.css
 * Signed: admin@thepandadev.com
 */

/* ============================================
   Game Lobby
   ============================================ */
.game-lobby {
    padding: 1rem 0;
}

.game-lobby .lobby-header {
    margin-bottom: 1.5rem;
}

.game-lobby .lobby-header h2 {
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.game-lobby .lobby-header .subtitle {
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* Game Filters */
.game-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    padding: 0.75rem 1rem;
    background: var(--bg-card);
    border-radius: 0.75rem;
    border: 1px solid rgba(255,255,255,0.05);
}

.game-filters .filter-btn {
    padding: 0.4rem 1.2rem;
    border-radius: 2rem;
    border: 1px solid rgba(255,255,255,0.1);
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.85rem;
    transition: all 0.2s;
    cursor: pointer;
}

.game-filters .filter-btn:hover {
    background: rgba(108, 99, 255, 0.1);
    border-color: var(--brand-primary);
    color: var(--text-primary);
}

.game-filters .filter-btn.active {
    background: var(--brand-primary);
    border-color: var(--brand-primary);
    color: white;
}

/* Game Grid */
.game-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1.5rem;
}

.game-grid .game-card {
    background: var(--bg-card);
    border: 1px solid rgba(255,255,255,0.05);
    border-radius: 1rem;
    overflow: hidden;
    transition: all 0.3s ease;
    cursor: pointer;
}

.game-grid .game-card:hover {
    transform: translateY(-6px);
    box-shadow: 0 12px 40px rgba(108, 99, 255, 0.15);
    border-color: var(--brand-primary);
}

.game-grid .game-card .game-thumbnail {
    position: relative;
    width: 100%;
    aspect-ratio: 16/9;
    background: var(--bg-secondary);
    overflow: hidden;
}

.game-grid .game-card .game-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.game-grid .game-card .game-thumbnail .game-icon {
    font-size: 3rem;
    opacity: 0.2;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.game-grid .game-card .game-thumbnail .game-badge {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    padding: 0.2rem 0.6rem;
    border-radius: 1rem;
    font-size: 0.6rem;
    font-weight: 600;
    text-transform: uppercase;
    background: rgba(0,0,0,0.7);
    color: white;
}

.game-grid .game-card .game-thumbnail .game-badge.type-2d {
    background: rgba(108, 99, 255, 0.8);
}

.game-grid .game-card .game-thumbnail .game-badge.type-3d {
    background: rgba(255, 101, 132, 0.8);
}

.game-grid .game-card .game-thumbnail .game-badge.featured {
    top: 0.5rem;
    left: 0.5rem;
    right: auto;
    background: rgba(255, 193, 7, 0.9);
    color: #0f0f1a;
}

.game-grid .game-card .game-body {
    padding: 0.75rem 1rem;
}

.game-grid .game-card .game-body .game-title {
    font-weight: 600;
    font-size: 0.95rem;
    margin-bottom: 0.1rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.game-grid .game-card .game-body .game-meta {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.game-grid .game-card .game-body .game-stats {
    display: flex;
    gap: 1rem;
    margin-top: 0.5rem;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.game-grid .game-card .game-body .game-stats i {
    margin-right: 0.2rem;
}

/* ============================================
   Game Play Container
   ============================================ */
.game-play-container {
    height: calc(100vh - 200px);
    min-height: 400px;
    position: relative;
    background: var(--bg-primary);
    border-radius: 1rem;
    overflow: hidden;
    border: 1px solid rgba(255,255,255,0.05);
}

.game-play-container .game-frame {
    width: 100%;
    height: 100%;
    border: none;
    background: var(--bg-primary);
}

.game-play-container .game-loading {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--bg-primary);
    z-index: 10;
    transition: opacity 0.5s ease;
}

.game-play-container .game-loading.hidden {
    opacity: 0;
    pointer-events: none;
}

.game-play-container .game-loading .spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(108, 99, 255, 0.1);
    border-top-color: var(--brand-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.game-play-container .game-loading p {
    margin-top: 1rem;
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* Game Controls Overlay (Fullscreen) */
.game-controls-overlay {
    position: absolute;
    bottom: 1rem;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: rgba(0,0,0,0.7);
    border-radius: 2rem;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255,255,255,0.05);
    z-index: 5;
}

.game-controls-overlay .ctrl-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: rgba(255,255,255,0.05);
    color: white;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.game-controls-overlay .ctrl-btn:hover {
    background: rgba(255,255,255,0.1);
}

.game-controls-overlay .ctrl-btn:active {
    transform: scale(0.9);
}

/* ============================================
   Mobile D-Pad (Game Play) — Fixed: No overlap
   ============================================ */
.game-dpad {
    display: none;
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
}

.game-dpad.visible {
    display: flex;
}

.game-dpad .dpad-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.3rem;
}

.game-dpad .dpad-row {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
}

.game-dpad .dpad-actions {
    display: flex;
    gap: 0.3rem;
    justify-content: center;
}

.game-dpad .dpad-btn {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: 1px solid rgba(255,255,255,0.15);
    background: rgba(26, 26, 46, 0.9);
    color: #fff;
    font-size: 1.15rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.1s ease;
    touch-action: none;
    -webkit-tap-highlight-color: transparent;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
}

.game-dpad .dpad-btn:active,
.game-dpad .dpad-btn.pressed {
    background: linear-gradient(135deg, #6c63ff, #ff6584);
    transform: scale(0.92);
    box-shadow: 0 2px 10px rgba(108, 99, 255, 0.5);
    border-color: transparent;
}

.game-dpad .dpad-btn.action-primary {
    background: rgba(108, 99, 255, 0.5);
    border-color: rgba(108, 99, 255, 0.6);
}

.game-dpad .dpad-btn.action-secondary {
    background: rgba(255, 101, 132, 0.45);
    border-color: rgba(255, 101, 132, 0.55);
}

.game-dpad .dpad-btn.action-tertiary {
    background: rgba(255, 217, 61, 0.45);
    border-color: rgba(255, 217, 61, 0.55);
    color: #ffd93d;
}

.game-dpad .dpad-btn-text {
    font-size: 0.55rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    line-height: 1;
}

/* ============================================
   Leaderboard
   ============================================ */
.leaderboard-container {
    max-width: 1000px;
    margin: 0 auto;
}

.leaderboard-table {
    width: 100%;
    border-collapse: collapse;
}

.leaderboard-table thead th {
    padding: 0.75rem 0.5rem;
    text-align: left;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    border-bottom: 1px solid rgba(255,255,255,0.05);
    font-weight: 600;
}

.leaderboard-table tbody td {
    padding: 0.6rem 0.5rem;
    border-bottom: 1px solid rgba(255,255,255,0.03);
}

.leaderboard-table .rank-cell {
    font-weight: 700;
    width: 50px;
    text-align: center;
}

.leaderboard-table .rank-cell .medal {
    font-size: 1.2rem;
}

.leaderboard-table .player-cell {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.leaderboard-table .player-cell .avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    overflow: hidden;
    background: var(--bg-secondary);
}

.leaderboard-table .player-cell .avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.leaderboard-table .player-cell .avatar-placeholder {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--brand-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.8rem;
    color: white;
}

.leaderboard-table .score-cell {
    font-weight: 600;
    color: var(--brand-primary);
}

.leaderboard-table .user-row {
    background: rgba(108, 99, 255, 0.05);
}

.leaderboard-table .rank-gold {
    background: rgba(255, 215, 0, 0.05);
}

.leaderboard-table .rank-silver {
    background: rgba(192, 192, 192, 0.05);
}

.leaderboard-table .rank-bronze {
    background: rgba(205, 127, 50, 0.05);
}

/* User Rank Banner */
.user-rank-banner {
    padding: 1rem 1.5rem;
    background: var(--bg-card);
    border-radius: 1rem;
    border: 1px solid var(--brand-primary);
    margin-top: 1.5rem;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
}

.user-rank-banner .rank-number {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--brand-primary);
}

/* ============================================
   NOTE: Chat styles moved to app/static/css/chat.css
   Loaded only on chat pages via chat/room.html
   ============================================ */

/* ============================================
   Mobile Responsive
   ============================================ */
@media (max-width: 768px) {
    .game-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 1rem;
    }
    
    .game-play-container {
        height: calc(100vh - 180px);
        min-height: 350px;
    }
    
    .leaderboard-table thead {
        display: none;
    }
    
    .leaderboard-table tbody tr {
        display: block;
        padding: 0.5rem;
        border-bottom: 1px solid rgba(255,255,255,0.05);
    }
    
    .leaderboard-table tbody td {
        display: flex;
        justify-content: space-between;
        padding: 0.2rem 0;
        border: none;
    }
    
    .leaderboard-table tbody td::before {
        content: attr(data-label);
        color: var(--text-muted);
        font-size: 0.75rem;
        font-weight: 500;
    }
    
    .user-rank-banner {
        flex-direction: column;
        text-align: center;
        gap: 0.5rem;
    }
}

@media (max-width: 480px) {
    .game-grid {
        grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
        gap: 0.75rem;
    }
    
    .game-filters {
        flex-wrap: nowrap;
        overflow-x: auto;
        padding: 0.5rem;
        gap: 0.3rem;
    }
    
    .game-filters .filter-btn {
        font-size: 0.75rem;
        padding: 0.3rem 0.8rem;
        white-space: nowrap;
    }
    
    .game-play-container {
        height: calc(100vh - 160px);
        min-height: 280px;
    }
    
    .game-controls-overlay {
        bottom: 0.5rem;
        padding: 0.3rem 0.5rem;
    }
    
    .game-controls-overlay .ctrl-btn {
        width: 30px;
        height: 30px;
        font-size: 0.8rem;
    }
    
    .game-dpad .dpad-btn {
        width: 46px;
        height: 46px;
        font-size: 1rem;
    }
}

@media (max-width: 400px) {
    .game-dpad .dpad-btn {
        width: 42px;
        height: 42px;
        font-size: 0.95rem;
    }
    
    .game-dpad .dpad-btn-text {
        font-size: 0.5rem;
    }
}

/* ============================================
   Reduced Motion
   ============================================ */
@media (prefers-reduced-motion: reduce) {
    .game-grid .game-card,
    .game-play-container .game-frame {
        transition: none;
    }
}

/* End of file: app/static/css/games.css */
/* Signed: admin@thepandadev.com */