/**
 * Shared Game Header Styling
 * Dark header bar matching main Vault display pages
 */

.game-top-bar {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(0, 0, 0, 0.95);
    backdrop-filter: blur(10px);
    z-index: 10000 !important;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    margin: 0 !important;
    transition: background-color 0.5s ease;
}

.game-header-left {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    align-items: flex-start;
}

.game-header-scoreboard {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.9);
}

.scoreboard-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.scoreboard-avatar {
    display: inline-flex;
    width: 28px;
    height: 28px;
    flex-shrink: 0;
}

.scoreboard-avatar[hidden] {
    display: none;
}

.scoreboard-avatar-face {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    overflow: hidden;
}

.scoreboard-label {
    font-weight: 500;
    opacity: 0.8;
}

.scoreboard-value {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--game-primary, #FAB719);
}

.scoreboard-card-count {
    font-size: 0.75rem;
    opacity: 0.7;
    font-weight: 400;
    margin-left: 0.25rem;
}

.scoreboard-separator {
    opacity: 0.6;
    font-weight: 500;
}

.game-top-bar .game-title-header {
    font-size: 1.8rem;
    font-family: "Rockwell", "Rockwell Nova", "Roboto Slab", serif;
    font-weight: 400;
    letter-spacing: 2px;
    /* Use CSS custom property for theme color, fallback to default yellow */
    color: var(--game-header-title-color, var(--game-primary, #FAB719));
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
    margin: 0;
}

.game-top-bar .button-group {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.game-top-bar .top-bar-btn {
    background: rgba(255, 255, 255, 0.2);
    border: 2px solid white;
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
    font-family: "Rockwell", "Rockwell Nova", "Roboto Slab", serif;
}

.game-top-bar .top-bar-btn i {
    font-size: 1rem;
    display: inline-block;
}

.game-top-bar .top-bar-btn .btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.game-top-bar .top-bar-btn:hover {
    background: white;
    color: #C90C0F;
}

.game-top-bar .top-bar-btn.gamesroom-btn {
    background: rgba(250, 183, 25, 0.3);
    border-color: #FAB719;
}

.game-top-bar .top-bar-btn.gamesroom-btn:hover {
    background: #FAB719;
    color: #1f2937;
}

/* Add top padding to body/content to account for fixed header */
body.with-game-header {
    padding-top: 80px;
}

/* Burger menu for mobile — vault panel, not a system sheet */
.game-header-burger {
    display: none;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    min-height: 44px;
    background: rgba(250, 183, 25, 0.12);
    border: 1px solid rgba(250, 183, 25, 0.45);
    border-radius: 10px;
    color: #FAB719;
    font-size: 1.15rem;
    cursor: pointer;
    padding: 0.45rem;
    transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease, transform 0.15s ease;
}

.game-header-burger:hover,
.game-header-burger[aria-expanded="true"] {
    background: #C90C0F;
    border-color: #C90C0F;
    color: #fff;
    transform: none;
}

.game-header-lobby-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    flex-shrink: 0;
    border-radius: 10px;
    border: 1px solid rgba(250, 183, 25, 0.45);
    background: rgba(250, 183, 25, 0.12);
    color: #FAB719;
    text-decoration: none;
    font-size: 1.75rem;
    font-weight: 500;
    line-height: 1;
    z-index: 10001;
    transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.game-header-lobby-close .fa-xmark {
    font-size: 1.2rem;
}

.game-header-lobby-close .fa-xmark::before {
    display: none;
}

.game-header-lobby-close:hover,
.game-header-lobby-close:focus-visible {
    background: #C90C0F;
    border-color: #C90C0F;
    color: #fff;
    outline: none;
}

.game-header-mobile-nav {
    display: none;
    position: fixed;
    top: 0;
    right: 0;
    width: min(320px, 92vw);
    height: 100vh;
    height: 100dvh;
    background:
        linear-gradient(180deg, rgba(250, 183, 25, 0.08), transparent 18%),
        linear-gradient(160deg, #1a2332 0%, #121a28 48%, #0b1220 100%);
    border-left: 1px solid rgba(250, 183, 25, 0.28);
    box-shadow: -18px 0 40px rgba(0, 0, 0, 0.45), inset 1px 0 0 rgba(250, 183, 25, 0.12);
    padding: calc(1.15rem + env(safe-area-inset-top, 0px)) 1.15rem calc(1.35rem + env(safe-area-inset-bottom, 0px));
    z-index: 10050;
    transform: translateX(105%);
    transition: transform 0.32s cubic-bezier(0.22, 1, 0.36, 1);
    overflow-y: auto;
    pointer-events: none;
}

.game-header-mobile-nav.active {
    transform: translateX(0);
    right: 0;
    pointer-events: auto;
}

.game-header-mobile-nav-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid rgba(250, 183, 25, 0.28);
}

.game-header-mobile-auth {
    margin: 0 0 1rem;
}

.game-header-mobile-auth .gv-topbar-profile {
    max-width: 100%;
}

.game-header-mobile-auth .user-display-name {
    color: #f8fafc;
}

.game-header-mobile-brand {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    min-width: 0;
}

.game-header-mobile-brand img {
    width: 38px;
    height: 38px;
    border-radius: 8px;
    object-fit: contain;
    background: #0b1220;
    border: 1px solid rgba(250, 183, 25, 0.35);
}

.game-header-mobile-kicker {
    margin: 0;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: #FAB719;
}

.game-header-mobile-nav-header h2 {
    color: #f4f1ea;
    font-family: "Rockwell", "Rockwell Nova", "Roboto Slab", serif;
    font-size: 1.1rem;
    font-weight: 700;
    margin: 0;
    line-height: 1.15;
}

.game-header-close-menu {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    min-height: 44px;
    background: rgba(201, 12, 15, 0.16);
    border: 1px solid rgba(201, 12, 15, 0.5);
    border-radius: 10px;
    color: #fff;
    font-size: 1.1rem;
    cursor: pointer;
    padding: 0.45rem;
}

.game-header-close-menu:hover {
    background: #C90C0F;
    border-color: #C90C0F;
    color: #fff;
}

.game-header-mobile-buttons {
    display: grid;
    gap: 0.5rem;
}

.game-header-mobile-nav .top-bar-btn {
    width: 100%;
    margin-bottom: 0;
    justify-content: flex-start;
    min-height: 48px;
    padding: 0.75rem 0.95rem;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.05);
    color: #f4f1ea;
    font-family: "Rockwell", "Rockwell Nova", "Roboto Slab", serif;
}

.game-header-mobile-nav .top-bar-btn i,
.game-header-mobile-nav .top-bar-btn .btn-icon {
    color: #FAB719;
    width: 1.2rem;
    text-align: center;
}

.game-header-mobile-nav .top-bar-btn:hover,
.game-header-mobile-nav .top-bar-btn:focus-visible {
    background: #C90C0F;
    border-color: #C90C0F;
    color: #fff;
}

.game-header-mobile-nav .top-bar-btn:hover i,
.game-header-mobile-nav .top-bar-btn:focus-visible i,
.game-header-mobile-nav .top-bar-btn:hover .btn-icon,
.game-header-mobile-nav .top-bar-btn:focus-visible .btn-icon {
    color: #fff;
}

.game-header-mobile-nav .top-bar-btn.gamesroom-btn {
    background: rgba(250, 183, 25, 0.14);
    border-color: rgba(250, 183, 25, 0.55);
    color: #FAB719;
}

.game-header-mobile-nav .top-bar-btn.gamesroom-btn:hover,
.game-header-mobile-nav .top-bar-btn.gamesroom-btn:focus-visible {
    background: #FAB719;
    border-color: #FAB719;
    color: #1a120c;
}

.game-header-mobile-nav .top-bar-btn.gamesroom-btn:hover i,
.game-header-mobile-nav .top-bar-btn.gamesroom-btn:focus-visible i {
    color: #1a120c;
}

.game-header-mobile-overlay {
    display: none;
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    background:
        radial-gradient(ellipse 70% 50% at 100% 0%, rgba(201, 12, 15, 0.22), transparent 55%),
        rgba(5, 8, 14, 0.72);
    z-index: 10040;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.28s ease;
}

.game-header-mobile-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

/* Mobile responsive */
@media (max-width: 768px) {
    .game-top-bar {
        padding: 0.75rem 1rem;
        flex-wrap: nowrap;
        gap: 1rem;
    }
    
    .game-top-bar .game-title-header {
        font-size: 1.2rem;
        letter-spacing: 1px;
        flex: 1;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    
    .game-top-bar .button-group {
        display: none;
    }
    
    .game-header-burger {
        display: flex;
        flex-shrink: 0;
        position: relative;
        z-index: 10001;
    }

    .game-header-lobby-close {
        display: inline-flex;
        position: relative;
        z-index: 10001;
    }
    
    .game-header-mobile-nav {
        display: block;
    }
    
    .game-header-mobile-overlay {
        display: block;
    }

    /* Ensure all top bar buttons have high z-index on mobile */
    .game-top-bar .top-bar-btn,
    .game-header-close-menu {
        position: relative;
        z-index: 10001;
    }
    
    body.with-game-header {
        padding-top: 70px;
    }
}

@media (max-width: 480px) {
    .game-top-bar {
        padding: 0.75rem;
    }
    
    .game-top-bar .game-title-header {
        font-size: 1rem;
    }

    /* Ensure buttons remain on top on smaller mobile screens */
    .game-header-burger,
    .game-header-lobby-close,
    .game-top-bar .top-bar-btn,
    .game-header-close-menu {
        position: relative;
        z-index: 10001;
    }
    
    body.with-game-header {
        padding-top: 65px;
    }
}

/* ============================================================================
   GAME-SPECIFIC TITLE COLOR OVERRIDES
   Each game can set its theme color via CSS custom property or body class
   ============================================================================ */

/* Mathdle - Red theme */
.mathdle-page .game-top-bar .game-title-header {
    color: var(--game-primary, #C90C0F) !important;
}

/* Yahtzee - Blue theme */
body:has(#yahtzee-menu) .game-top-bar .game-title-header,
body:has(.yahtzee-menu) .game-top-bar .game-title-header {
    color: var(--game-primary, #007bff) !important;
}

/* Countdown - Sky blue theme */
body:has(#countdown-menu) .game-top-bar .game-title-header,
body:has(.countdown-menu) .game-top-bar .game-title-header {
    color: var(--game-primary, #0EA5E9) !important;
}

/* Nim 21 - Indigo theme */
body:has(#nim21-menu) .game-top-bar .game-title-header,
body:has(.nim21-menu) .game-top-bar .game-title-header {
    color: var(--game-primary, #6366f1) !important;
}

/* Triggle - Coral red theme */
body:has(#triggle-menu) .game-top-bar .game-title-header,
body:has(.triggle-menu) .game-top-bar .game-title-header {
    color: var(--game-primary, #FF6B6B) !important;
}

/* Number One - Red theme */
body:has(#numero-uno-menu) .game-top-bar .game-title-header,
body:has(.numero-uno-menu) .game-top-bar .game-title-header {
    color: var(--game-primary, #E74C3C) !important;
}

/* Pwordle - Use game's primary color */
body:has(#pwordle-menu) .game-top-bar .game-title-header,
body:has(.pwordle-menu) .game-top-bar .game-title-header {
    color: var(--game-primary, #FAB719) !important;
}

/* Maths Connections - Use game's primary color */
body:has(#connections-menu) .game-top-bar .game-title-header,
body:has(.connections-menu) .game-top-bar .game-title-header {
    color: var(--game-primary, #FAB719) !important;
}

/* Battleships - Blue theme */
body:has(#battleships-game) .game-top-bar .game-title-header,
body:has(.battleships-menu) .game-top-bar .game-title-header {
    color: var(--game-primary, #3B82F6) !important;
}

/* Solitaire - Use game's primary color */
body:has(#solitaire-menu) .game-top-bar .game-title-header,
body:has(.solitaire-menu) .game-top-bar .game-title-header {
    color: var(--game-primary, #FAB719) !important;
}

/* Sudoku - Use game's primary color */
body:has(#sudoku-menu) .game-top-bar .game-title-header,
body:has(.sudoku-menu) .game-top-bar .game-title-header {
    color: var(--game-primary, #FAB719) !important;
}

/* RPSD Plus - Use game's primary color */
body:has(#rpsdplus-menu) .game-top-bar .game-title-header,
body:has(.rpsdplus-menu) .game-top-bar .game-title-header {
    color: var(--game-primary, #FAB719) !important;
}

/* Can You Sort It - Use game's primary color */
body:has(#canyousortit-menu) .game-top-bar .game-title-header,
body:has(.canyousortit-menu) .game-top-bar .game-title-header {
    color: var(--game-primary, #FAB719) !important;
}

