/* ===== Site Header - Single Row Layout ===== */

/* Prevent any child element from causing horizontal scroll */
body { overflow-x: hidden; }

/* Global box-sizing reset — required so percentage-width float layouts (e.g. .games 48%×2)
   don't overflow their containers when padding is also percentage-based. */
*, *::before, *::after { box-sizing: border-box; }

:root {
    --hd-bar: 64px; /* single row height on desktop */
}

/* ===== Outer container ===== */
.header-modern {
    position: sticky;
    top: 0;
    z-index: 1000;
    width: 100%;
    background: linear-gradient(135deg, #0285e5 0%, #0061b8 100%);
    box-shadow: 0 2px 16px rgba(2,133,229,0.32);
}

/* ===== Max-width wrapper ===== */
.header-wrapper {
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
    padding: 0 20px;
    box-sizing: border-box;
}

/* ===== Single-row flex container ===== */
.header-container {
    display: flex;
    align-items: stretch;   /* children fill the full height */
    height: var(--hd-bar);
}

/* ===== Logo ===== */
.header-logo {
    display: flex;
    align-items: center;
    flex-shrink: 0;
    padding-right: 8px;
}

.logo-link {
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    transition: opacity .2s;
}
.logo-link:hover { opacity: .85; }

.logo-icon { font-size: 1.7em; line-height: 1; }
.logo-text {
    font-size: 1.2em;
    font-weight: 700;
    color: #ffffff;
    letter-spacing: -0.3px;
    white-space: nowrap;
}

/* ===== Nav – flex: 1, fills space between logo and search ===== */
.nav-menu {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: stretch;
}

.nav-list {
    display: flex;
    align-items: stretch;
    list-style: none;
    margin: 0;
    padding: 0;
    height: 100%;
}

.nav-list li {
    display: flex;
    align-items: center;
}

.nav-link {
    display: flex;
    align-items: center;
    padding: 0 16px;
    height: 100%;
    text-decoration: none;
    color: rgba(255,255,255,0.82);
    font-weight: 500;
    font-size: 0.95em;
    white-space: nowrap;
    position: relative;
    transition: color .18s;
}
.nav-link:hover { color: #ffffff; }
.nav-link.active { color: #ffffff; font-weight: 700; }
.nav-link.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 10px;
    right: 10px;
    height: 3px;
    background: #ffffff;
    border-radius: 2px 2px 0 0;
}

/* ===== Search – right of nav ===== */
.header-search {
    display: flex;
    align-items: center;
    flex-shrink: 0;
    max-width: 360px;
    min-width: 160px;
    padding-left: 12px;
}

.search-form {
    display: flex;
    align-items: center;
    background: rgba(255,255,255,0.16);
    border: 1px solid rgba(255,255,255,0.35);
    border-radius: 999px;
    padding: 6px 6px 6px 14px;
    gap: 6px;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    transition: background .2s;
    width: 100%;
}
.search-form:focus-within { background: rgba(255,255,255,0.24); }

.search-input {
    flex: 1;
    min-width: 0;
    border: none;
    background: transparent;
    color: #ffffff;
    font-size: 0.9em;
    font-family: inherit;
    outline: none;
}
.search-input::placeholder { color: rgba(255,255,255,0.6); }

/* Override app.css input[type=search] white-background rule */
.search-form input[type=search],
.search-form input[type=search]:focus {
    background: transparent;
    background-color: transparent;
    background-image: none;
    border: none;
    border-color: transparent;
    box-shadow: none;
    border-radius: 0;
    width: auto;
    padding: 0;
    color: #ffffff;
}

.search-btn {
    flex-shrink: 0;
    background: rgba(255,255,255,0.2);
    border: none;
    border-radius: 999px;
    cursor: pointer;
    padding: 5px 13px;
    color: #ffffff;
    font-size: 0.8em;
    font-weight: 600;
    transition: background .2s;
    white-space: nowrap;
}
.search-btn:hover { background: rgba(255,255,255,0.32); }

/* ===== Hamburger – hidden on desktop ===== */
.hamburger-menu {
    display: none;
    flex-direction: column;
    justify-content: center;
    background: transparent;
    border: none;
    cursor: pointer;
    gap: 6px;
    padding: 8px;
    flex-shrink: 0;
    margin-left: 8px;
}
.hamburger-menu span {
    display: block;
    width: 24px;
    height: 2.5px;
    background: #ffffff;
    border-radius: 2px;
    transition: transform .3s ease, opacity .2s ease;
    transform-origin: center;
}
/* X animation: center-to-center distance = 8.5px */
.hamburger-menu.active span:nth-child(1) { transform: translateY(8.5px) rotate(45deg); }
.hamburger-menu.active span:nth-child(2) { opacity: 0; transform: scaleX(0); }
.hamburger-menu.active span:nth-child(3) { transform: translateY(-8.5px) rotate(-45deg); }

/* ===== MOBILE: nav collapses to fixed dropdown ===== */
@media (max-width: 768px) {
    :root { --hd-bar: 56px; }

    .header-wrapper { padding: 0 14px; }

    /* Show hamburger */
    .hamburger-menu { display: flex; }

    /* Collapse nav into hidden dropdown */
    .nav-menu {
        flex: none;
        display: none;
        position: fixed;
        top: var(--hd-bar);       /* synced to actual header height via CSS var */
        left: 0;
        right: 0;
        /* Do NOT use width:100vw — it includes scrollbar and causes horizontal overflow */
        max-height: calc(100vh - var(--hd-bar));
        overflow-y: auto;
        background: linear-gradient(135deg, #0285e5 0%, #0061b8 100%);
        box-shadow: 0 8px 24px rgba(2,133,229,0.28);
        border-top: 1px solid rgba(255,255,255,0.15);
        animation: hdrSlideDown .28s ease-out;
    }
    .nav-menu.active { display: block; }

    /* Stack links vertically */
    .nav-list {
        flex-direction: column;
        height: auto;
        padding: 6px 0;
    }
    .nav-list li { border-bottom: 1px solid rgba(255,255,255,0.08); }
    .nav-list li:last-child { border-bottom: none; }

    .nav-link {
        height: 50px;
        padding: 0 20px;
        justify-content: flex-start;
        color: rgba(255,255,255,0.88);
    }
    .nav-link.active::after { display: none; }
    .nav-link.active {
        background: rgba(255,255,255,0.12);
        border-left: 3px solid rgba(255,255,255,0.9);
        padding-left: 17px;
    }

    /* Search stays visible, expands to fill space */
    .header-search { flex: 1; max-width: none; min-width: 0; padding-left: 8px; }
}

@media (max-width: 480px) {
    :root { --hd-bar: 52px; }
    .header-wrapper { padding: 0 12px; }
    .logo-text { font-size: 1.05em; }
    .logo-icon { font-size: 1.5em; }
    .search-form { padding: 5px 5px 5px 12px; }
    .search-input { font-size: 0.85em; }
    .search-btn { padding: 4px 10px; font-size: 0.76em; }
}

@media (max-width: 360px) {
    :root { --hd-bar: 48px; }
    .header-wrapper { padding: 0 10px; }
    .logo-text { display: none; }
    .logo-icon { font-size: 1.4em; }
    .hamburger-menu { padding: 6px; margin-left: 4px; }
    .hamburger-menu span { width: 20px; }
}

/* Slide-down animation OUTSIDE media query for full browser compat */
@keyframes hdrSlideDown {
    from { opacity: 0; transform: translateY(-8px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Hide legacy header elements */
.header, .pc_menu { display: none !important; }

/* Search icon */
.icon-search::before { content: ''; font-size: 0.9em; }
