/*
 * Shared navigation drawer for SpawningPool.org.
 * Served at /nav.css and used by every page together with /nav.js.
 *
 * The drawer is a fixed rail on the left: 56px collapsed, 240px expanded.
 * Pages reserve space for it via .main-content-pane padding, which nav.js
 * drives with the body.nav-expanded class. On narrow screens (<600px) the
 * expanded drawer overlays the content behind a dimming scrim instead of
 * pushing it.
 */

:root {
    --nav-width-collapsed: 56px;
    --nav-width-expanded: 240px;
    --nav-bg: rgba(8, 10, 14, 0.72);
    --nav-accent: #6ee7c8;
    --nav-ease: cubic-bezier(0.33, 1, 0.68, 1);
    --nav-speed: 0.32s;
}

.unselectable {
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -khtml-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/* ---- Drawer shell ---------------------------------------------------- */

.nav-drawer {
    position: fixed;
    top: 0;
    left: 0;
    height: 100%;
    width: var(--nav-width-collapsed);
    display: flex;
    flex-direction: column;
    background-color: var(--nav-bg);
    -webkit-backdrop-filter: blur(14px) saturate(130%);
    backdrop-filter: blur(14px) saturate(130%);
    border-right: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 2px 0 24px rgba(0, 0, 0, 0.35);
    box-sizing: border-box;
    padding: 8px;
    overflow-x: hidden;
    overflow-y: auto;
    white-space: nowrap;
    z-index: 1000;
    transition: width var(--nav-speed) var(--nav-ease);
}

.nav-drawer.expanded {
    width: var(--nav-width-expanded);
}

/* ---- Toggle button (animated hamburger) ------------------------------ */

.nav-toggle {
    display: flex;
    align-items: center;
    width: 100%;
    min-height: 40px;
    margin: 0 0 8px 0;
    padding: 0;
    border: none;
    border-radius: 10px;
    background: transparent;
    color: #fff;
    font: inherit;
    cursor: pointer;
    flex-shrink: 0;
}

.nav-toggle:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.nav-toggle-box {
    position: relative;
    width: 40px;
    height: 40px;
    flex: 0 0 40px;
    display: inline-block;
}

.nav-toggle-bar {
    position: absolute;
    left: 11px;
    width: 18px;
    height: 2px;
    border-radius: 1px;
    background-color: #fff;
    transition: transform var(--nav-speed) var(--nav-ease),
                opacity calc(var(--nav-speed) / 2) linear;
}

.nav-toggle-bar:nth-child(1) { top: 13px; }
.nav-toggle-bar:nth-child(2) { top: 19px; }
.nav-toggle-bar:nth-child(3) { top: 25px; }

/* Morph the three bars into an X while the drawer is open. */
.nav-drawer.expanded .nav-toggle-bar:nth-child(1) {
    transform: translateY(6px) rotate(45deg);
}
.nav-drawer.expanded .nav-toggle-bar:nth-child(2) {
    opacity: 0;
    transform: translateX(-6px);
}
.nav-drawer.expanded .nav-toggle-bar:nth-child(3) {
    transform: translateY(-6px) rotate(-45deg);
}

.nav-title {
    font-size: 17px;
    font-weight: bold;
    letter-spacing: 0.4px;
    color: #fff;
}

/* ---- Nav items -------------------------------------------------------- */

.nav-links {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1 1 auto;
}

.nav-footer {
    flex-shrink: 0;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding-top: 8px;
    margin-top: 8px;
}

.nav-item {
    position: relative;
    display: flex;
    align-items: center;
    min-height: 40px;
    border-radius: 10px;
    color: rgba(255, 255, 255, 0.82);
    text-decoration: none;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.nav-item:hover {
    background-color: rgba(255, 255, 255, 0.1);
    color: #fff;
}

.nav-item:active {
    background-color: rgba(255, 255, 255, 0.16);
}

.nav-icon {
    width: 40px;
    height: 40px;
    flex: 0 0 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.nav-icon svg {
    width: 20px;
    height: 20px;
    stroke: currentColor;
    fill: none;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* Labels stay in the DOM so they can fade/slide instead of popping. */
.nav-label,
.nav-title {
    opacity: 0;
    transform: translateX(-8px);
    transition: opacity calc(var(--nav-speed) / 2) linear,
                transform var(--nav-speed) var(--nav-ease);
    pointer-events: none;
}

.nav-drawer.expanded .nav-label,
.nav-drawer.expanded .nav-title {
    opacity: 1;
    transform: translateX(0);
    pointer-events: auto;
    transition-delay: 0.08s;
}

/* Active page: accent tint plus a small indicator bar on the left edge. */
.nav-item.active {
    background-color: rgba(110, 231, 200, 0.12);
    color: var(--nav-accent);
}

.nav-item.active:hover {
    background-color: rgba(110, 231, 200, 0.18);
}

.nav-item.active::before {
    content: "";
    position: absolute;
    left: -8px; /* sit on the drawer edge, outside the rounded pill */
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 22px;
    border-radius: 0 3px 3px 0;
    background-color: var(--nav-accent);
}

/* Keyboard focus */
.nav-toggle:focus-visible,
.nav-item:focus-visible {
    outline: 2px solid var(--nav-accent);
    outline-offset: -2px;
}

/* ---- Content pane coupling -------------------------------------------- */

.main-content-pane,
.footer-pane-content {
    padding-left: var(--nav-width-collapsed);
    transition: padding-left var(--nav-speed) var(--nav-ease);
}

@media (min-width: 600px) {
    body.nav-expanded .main-content-pane,
    body.nav-expanded .footer-pane-content {
        padding-left: var(--nav-width-expanded);
    }
}

/* ---- Mobile: overlay + scrim instead of pushing content --------------- */

.nav-scrim {
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.5);
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--nav-speed) linear;
    z-index: 999;
}

@media (max-width: 599px) {
    .nav-drawer.expanded {
        width: min(76vw, var(--nav-width-expanded));
        box-shadow: 4px 0 32px rgba(0, 0, 0, 0.6);
    }

    body.nav-expanded .nav-scrim {
        opacity: 1;
        pointer-events: auto;
    }
}

/* Respect users who prefer reduced motion. */
@media (prefers-reduced-motion: reduce) {
    .nav-drawer,
    .nav-toggle-bar,
    .nav-label,
    .nav-title,
    .nav-scrim,
    .main-content-pane,
    .footer-pane-content {
        transition: none !important;
    }
}

/* Suppress transitions while restoring the saved state on page load. */
.nav-no-anim,
.nav-no-anim * {
    transition: none !important;
}
