.topbar {
    position: fixed;
    left: 0;
    top: -65vh; /* Hide above viewport initially */
    width: 100%;
    height: 70vh;
    background-color: var(--secondary);
    border-bottom: 1px solid var(--accent);
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 2em;
    padding: 4em;
    z-index: 1001;
    transition: top 0.2s;
}

.topbar:hover {
    top: 0; /* Slide down into view */
}

.topbar-category {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1em;
    padding: 1em;
    border-radius: 0.8em;
    background-color: rgba(0, 0, 0, 0.2);
}

.topbar-category h3 {
    color: var(--white);
    margin: 0 0 0.5em 0;
    font-size: 1.2em;
    text-align: center;
    opacity: 0.8;
}

.topbar a[button] {
    display: flex;
    align-items: center;
    text-decoration: none;
    color: var(--white);
    padding: 0.8em 1.2em;
    border-radius: 0.5em;
    transition: background-color 0.2s, transform 0.1s;
    min-width: 120px;
    width: 100%;
    justify-content: flex-start;
    margin: 0.2em 0;
}

.topbar a[button]:hover {
    background-color: var(--accent);
    transform: translateY(-2px);
}

.topbar a[button] .icon {
    font-size: 1.5em;
    margin-right: 0.5em;
}

.topbar a[button] .label {
    font-size: 1em;
    white-space: nowrap;
}

/* Remove the first p tag styling if it's not needed */
.topbar p:first-child {
    display: none;
}

.nav [button], .nav .parent [button] {
    display: flex;
    align-items: center;
    width: 100%;
    line-height: 1em;
    text-decoration: none;
    margin: 0.5em 0;
    background: none;
    border: none;
    background-color: transparent;
    color: inherit;
    cursor: pointer;
    transition: background 10s;
    padding: 0.5em;
    border-radius: 0.5em;
}

.nav [button] .icon, .nav .parent [button] .icon {
    margin-right: 0.5em;
    font-size: 1.5em; /* Adjust icon size */
    display: inline-block;
}

.nav [button] .label, .nav .parent [button] .label {
    display: none;
    white-space: nowrap;
    transition: opacity 0.2s;
    opacity: 0;
}

.nav:hover [button] .label, .nav:hover .parent [button] .label {
    display: inline;
    opacity: 1;
    margin-left: 0.5em;
}

/* Optional: highlight button on hover */
.nav [button]:hover, .nav .parent [button]:hover {
    background-color: var(--accent);
}

.mobile-navbar-top, .mobile-navbar-overlay, .mobile-navbar-content {
    display: none; /* Hide mobile navbar by default */
}

.settings {
    background-color: var(--secondary);
    position: fixed;
    left:100%;
    top: 25%;
    transform: translateY(-25%);
    height: 75vh;
    width: 75vw;
    z-index: 10000;
    border: 1px solid var(--accent);
    border-radius: var(--main-br-radius);
    padding: 1em;
    box-shadow: 4px 4px 20px rgba(0, 0, 0, 1);

    *:not(img) {
        z-index: 1;
    }

    img {
        position: absolute;
        bottom:0;
        right: 0;
        width: 25em;
        z-index: 0;
    }

    hr {
        z-index: 0;
    }
}

.settings div{
    display: flex;
    align-items: center;
    margin-bottom: 1em;
}

.settings label {
    margin-right: 1em;
}

.settings.active {
    animation: slide-in 0.25s forwards;
}

.settings.inactive {
    animation: slide-out 0.25s forwards;
}

@keyframes slide-in {
    0% {
        left: 100%;
    }
    100% {
        left: 25%;
    }
}

@keyframes slide-out {
    0% {
        left: 25%;
    }
    100% {
        left: 100%;
    }
}

/* Hide settings image when screen too small */
@media only screen and (max-width: 1400px) {
    .topbar {
        display:none !important;
    }

    .settings img {
        display: none;
    }

    .settings {
        width: 100vw;
        height: 70vh;
    }

    @keyframes slide-in {
        0% {
            left: -100%;
        }
        100% {
            left: 0%;
        }
    }

    @keyframes slide-out {
        0% {
            left: 25%;
        }
        100% {
            left: 100%;
        }
    }
}

/* Mobile Navbar Styles */
.mobile-navbar {
    display: none;
}

@media (max-width: 800px) {
    .nav {
        display: none !important;
    }
    .mobile-navbar-top {
        display: block;
        position: fixed;
        top: 0; left: 0; right: 0;
        width: 100vw;
        height: 48px;
        background: var(--secondary, #16213E);
        z-index: 3000;
        box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    }
    .mobile-navbar-top button {
        width: 100%;
        height: 100%;
        background: none;
        border: none;
        color: var(--white, #F0F6FF);
        font-size: 1.2em;
        font-weight: bold;
        letter-spacing: 0.1em;
        cursor: pointer;
    }
    .mobile-navbar-overlay {
        display: none;
        position: fixed;
        z-index: 4000;
        top: 0; left: 0; width: 100vw; height: 100vh;
        background: rgba(20, 20, 40, 0.98);
        transition: opacity 0.2s;
    }
    .mobile-navbar-overlay.active {
        display: block;
        opacity: 1;
    }
    .mobile-navbar-content {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: flex-start;
        padding-top: 64px;
        height: 100%;
        overflow-y: auto;           /* Make content scrollable */
        max-height: 100vh;          /* Prevent overflow beyond viewport */
        box-sizing: border-box;     /* Ensure padding is included in height */
        position: relative;         /* For close button positioning */
    }
    .mobile-navbar-content nav {
        width: 100%;
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 0.5em; /* Reduced gap */
    }
    .mobile-navbar-content nav a {
        color: var(--white, #F0F6FF);
        font-size: 1.3em;
        text-decoration: none;
        padding: 0.7em 2em;
        border-radius: 0.5em;
        width: 80%;
        text-align: left;
        display: flex;
        align-items: center;
        gap: 0.7em;
        transition: background 0.2s;
    }
    .mobile-navbar-content nav a.mobile-nav-btn {
        background: var(--secondary, #16213E);
        border: 1px solid var(--accent, #0F52BA);
        color: var(--white, #F0F6FF);
        font-size: 1.15em;
        text-decoration: none;
        padding: 0.7em 2em;
        border-radius: 0.5em;
        width: 80%;
        text-align: left;
        display: flex;
        align-items: center;
        gap: 0.7em;
        margin-bottom: 0; /* Remove extra margin between buttons */
        transition: background 0.2s, border 0.2s;
    }
    .mobile-navbar-content nav a.mobile-nav-btn:active,
    .mobile-navbar-content nav a.mobile-nav-btn:hover {
        background: var(--accent, #0F52BA);
        border: 1px solid var(--white, #F0F6FF);
    }
    .mobile-navbar-content .close-btn {
        position: absolute;
        width: 2em;
        height: 2em;
        top: 12px;
        right: 18px;
        background: none;
        border: none;
        color: var(--white, #F0F6FF);
        font-size: 2em;
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 0;
        line-height: 1;
    }
}
