/* --- Navigation Bar --- */
nav {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 80px;
    background: var(--nav-bg-color);
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 50px;
    z-index: 1000;
    border-bottom: 1px solid var(--border-color);
    transition: all 0.3s ease;
}

nav.scrolled {
    height: 70px;
    background: var(--nav-scrolled-bg);
    box-shadow: 0 4px 20px var(--shadow-color);
}

.nav-left {
    display: flex;
    align-items: center;
}

.nav-brand {
    font-weight: 800;
    font-size: 2em;
    letter-spacing: -0.5px;
    background: linear-gradient(135deg, var(--accent-color), var(--accent-hover-color));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    cursor: pointer;
    transform: translateZ(0);
    transition: transform 0.3s ease;
}

.nav-brand:hover {
    transform: scale(1.02);
}

.nav-center {
    flex-grow: 1;
    display: flex;
    justify-content: center;
    padding: 0 40px;
    max-width: 600px;
    min-width: 0;
}

.search-container {
    position: relative;
    width: 100%;
    min-width: 0;
}

#searchInput {
    width: 100%;
    height: 42px;
    padding: 0 40px 0 44px;
    border-radius: 999px;
    font-size: 15px;
    font-weight: 700;
    background-color: var(--input-bg-color);
    border: 2px solid transparent;
    color: var(--text-color);
    transition: background-color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

#searchInput::placeholder {
    color: var(--text-color-faint);
    font-weight: 600;
}

#searchInput:hover {
    background-color: var(--card-hover-bg-color);
}

#searchInput:focus {
    border-color: var(--accent-color);
    background-color: var(--input-bg-color);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.search-container .fa-search {
    position: absolute;
    left: 18px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-color-muted);
    font-size: 0.9em;
    transition: color 0.3s ease;
    pointer-events: none;
}

/* Keyboard hint: pressing "/" focuses the field */
.search-kbd {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    min-width: 24px;
    height: 24px;
    padding: 0 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 7px;
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-color-faint);
    font-family: var(--font-sans);
    font-size: 12px;
    font-weight: 800;
    pointer-events: none;
}

:root.light-theme .search-kbd {
    background: rgba(16, 20, 32, 0.06);
}

/* Icon sits before the input, so :focus-within is the reliable trigger */
.search-container:focus-within .fa-search {
    color: var(--accent-color);
}

.nav-right {
    display: flex;
    align-items: center;
    gap: 20px;
}

.mobile-menu-btn {
    display: none;
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: var(--input-bg-color);
    color: var(--text-color);
    border: 1px solid var(--border-color);
    font-size: 1.1em;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 8px;
}

.nav-links a {
    padding: 8px 16px;
    color: var(--text-color-muted);
    font-weight: 600;
    font-size: 0.95em;
    border-radius: 10px;
    transition: all 0.3s ease;
    position: relative;
}

.nav-links a:hover {
    color: var(--text-color);
    background: var(--hover-tint);
}

.nav-links a:focus-visible {
    outline: 2px solid var(--accent-color);
    outline-offset: 2px;
}    .nav-links a.active {
        color: var(--accent-color);
        background: var(--accent-soft);
    }

.nav-links a.active::after {
    content: '';
    position: absolute;
    bottom: 4px;
    left: 50%;
    transform: translateX(-50%);
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: var(--accent-color);
}

/* Same 44px control height as the theme/menu/profile buttons in the nav */
.login-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 0 24px;
    border-radius: 999px;
    font-weight: 800;
    background: var(--accent-color);
    color: var(--on-accent-color);
    transition: background-color 0.15s ease, transform 0.25s ease;
}

.login-button:focus-visible {
    outline: 2px solid var(--accent-color);
    outline-offset: 2px;
}

.login-button:hover {
    background: var(--accent-hover-color);
    transform: scale(1.04);
}

/* Profiles */
.profile-icon {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--accent-color);
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: 800;
    color: var(--on-accent-color);
    cursor: pointer;
    transition: all 0.3s ease;
    overflow: hidden;
}

.profile-icon img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.profile-icon:hover {
    transform: scale(1.05);
}

.nav-icon-btn {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: var(--input-bg-color);
    color: var(--text-color);
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.1em;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid var(--border-color);
}

.nav-icon-btn:hover {
    background: var(--card-hover-bg-color);
    border-color: var(--accent-color);
    color: var(--accent-color);
    transform: translateY(-2px);
}

.nav-icon-btn:focus-visible,
.mobile-menu-btn:focus-visible {
    outline: 2px solid var(--accent-color);
    outline-offset: 2px;
}

#profile-container-wrapper {
    display: flex;
    align-items: center;
}

.profile-dropdown {
    position: absolute;
    top: calc(100% + 15px);
    right: 0;
    background: var(--modal-bg-color);
    border-radius: 16px;
    box-shadow: 0 10px 40px var(--shadow-color);
    width: 220px;
    overflow: hidden;
    display: none;
    z-index: 1001;
    border: 1px solid var(--border-color);
    animation: slideDown 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.profile-dropdown.active {
    display: block;
}

.profile-dropdown a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 20px;
    color: var(--text-color);
    font-size: 0.9em;
    font-weight: 500;
    transition: background 0.2s ease;
}

.profile-dropdown a:hover {
    background: var(--hover-tint);
    color: var(--accent-color);
}

/* Medium screens: keep the search, just compact everything to fit */
@media (max-width: 1024px) {
    nav {
        padding: 0 24px;
    }

    .nav-center {
        padding: 0 16px;
        max-width: none;
        min-width: 170px;
    }

    #searchInput {
        padding: 0 36px 0 40px;
    }

    .search-container .fa-search {
        left: 14px;
    }

    .search-kbd {
        display: none;
    }

    .nav-links {
        gap: 2px;
    }

    .nav-links a {
        padding: 8px 11px;
        font-size: 0.9em;
    }

    .nav-right {
        gap: 12px;
    }
}

@media (max-width: 768px) {
    nav { padding: 0 16px; }
    .nav-brand { font-size: 1.55em; }
    .mobile-menu-btn { display: inline-flex; align-items: center; justify-content: center; }
    .nav-right { gap: 8px; }
    /* Search relocates into the dropdown menu via JS */
    .nav-center { display: none; }
    .nav-links {
        display: none;
        position: absolute;
        top: calc(100% + 6px);
        left: 16px;
        right: 16px;
        padding: 12px;
        flex-direction: column;
        align-items: stretch;
        gap: 4px;
        background: var(--modal-bg-color);
        border: 1px solid var(--border-color);
        border-radius: 16px;
        box-shadow: 0 15px 35px var(--shadow-color);
        max-height: calc(100vh - 96px);
        overflow-y: auto;
    }
    .nav-links.mobile-open { display: flex; }
    .nav-links a { padding: 14px 16px; }
    .nav-links .search-container { margin-bottom: 8px; }
}
