nav {
    position: sticky;
    top: 0;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 18px;
    min-height: 56px;
    width: 100%;
    box-sizing: border-box;
    background-color: rgba(255, 255, 255, 0.9);
    border: 1px solid var(--accent);
    border-top: none;
    border-radius: 0 0 12px 12px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.2);
    backdrop-filter: blur(10px);
    z-index: 5;
    transition: transform 300ms ease, background-color 180ms ease, border-color 180ms ease, box-shadow 180ms ease;
    transform: translateY(0);
}

nav.nav-hidden {
    transform: translateY(-100%);
}

nav.scrolled {
    background-color: rgba(12, 17, 31, 0.9);
    border-color: rgba(246, 174, 45, 0.55);
    border-top: none;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.32);
}

/* Force dark nav theme for non-index pages */
.navBar.force-dark-nav {
    background-color: rgba(12, 17, 31, 0.9);
    border-color: rgba(246, 174, 45, 0.55);
    border-top: none;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.32);
}
.navBar.force-dark-nav .links a {
    background-color: rgba(255, 255, 255, 0.08);
    color: var(--accent);
    border-color: rgba(246, 174, 45, 0.55);
}
.navBar.force-dark-nav .links a:hover {
    background-color: rgba(255, 255, 255, 0.16);
}

.links {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: 1fr;
    gap: 12px;
    margin-left: auto;
    align-items: center;
    transition: max-height 200ms ease, padding 200ms ease;
}

.links a {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 110px;
    background-color: rgba(255, 255, 255, 0.95);
    padding: 10px 12px;
    min-height: 44px;
    text-align: center;
    text-decoration: none;
    border-radius: 12px;
    font-weight: bold;
    border: 2px solid var(--accent);
    color: var(--accent);
    transition: color 150ms ease, background-color 150ms ease, border-color 150ms ease, box-shadow 150ms ease;
}

.links a:hover {
    color: var(--accent-strong);
    background-color: rgba(255, 255, 255, 0.8);
}

.links a:active {
    color: #0b1222;
    background-color: var(--accent);
}

.links a:focus-visible {
    outline: 3px solid var(--accent-strong);
    outline-offset: 2px;
}

.links a.active {
    background-color: var(--accent);
    color: #0b1222;
    border-color: var(--accent-strong);
    box-shadow: 0 0 0 2px rgba(246, 174, 45, 0.25);
}

nav.scrolled .links a {
    background-color: rgba(255, 255, 255, 0.08);
    color: var(--accent);
    border-color: rgba(246, 174, 45, 0.55);
}

nav.scrolled .links a:hover {
    background-color: rgba(255, 255, 255, 0.16);
}

#logo {
    height: 50px;
    width: auto;
}

.menu-toggle {
    display: none;
    margin-left: auto;
    background: none;
    border: 2px solid rgba(246, 174, 45, 0.65);
    border-radius: 10px;
    padding: 8px;
    height: 44px;
    width: 48px;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: border-color 150ms ease, background-color 150ms ease;
}

.menu-toggle span {
    display: block;
    width: 22px;
    height: 2px;
    background: var(--accent);
    margin: 3px 0;
    transition: transform 200ms ease, opacity 200ms ease, background-color 150ms ease;
}

.menu-toggle:focus-visible {
    outline: 3px solid var(--accent-strong);
    outline-offset: 2px;
}

.navBar.open .menu-toggle span:nth-child(2) {
    transform: translateY(5px) rotate(45deg);
}

.navBar.open .menu-toggle span:nth-child(3) {
    opacity: 0;
}

.navBar.open .menu-toggle span:nth-child(4) {
    transform: translateY(-5px) rotate(-45deg);
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

@media (max-width: 916px) {
    nav {
        gap: 10px;
        padding: 8px 14px;
        border-radius: 0 0 10px 10px;
    }

    #logo {
        height: 46px;
    }

    .menu-toggle {
        display: inline-flex;
    }

    .links {
        display: flex;
        flex-direction: column;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: rgba(12, 17, 31, 0.96);
        border: 1px solid rgba(246, 174, 45, 0.5);
        box-shadow: 0 12px 30px rgba(0, 0, 0, 0.3);
        border-radius: 0 0 12px 12px;
        padding: 0 18px;
        max-height: 0;
        overflow: hidden;
        gap: 12px;
        margin: 0;
    }

    .navBar.open .links {
        max-height: 320px;
        padding: 12px 18px 16px;
    }

    .links a {
        width: 100%;
        text-align: left;
        background: rgba(255, 255, 255, 0.08);
        border-color: rgba(246, 174, 45, 0.55);
        color: var(--accent);
    }
}
