/* css */
/********************************
 * Navigation Styles
 ********************************/

/* Navigation Container */
.wiki-navigation,
.home-links,
.store-links {
    display: flex;
    justify-content: center;
    gap: 2rem;
    padding: 1rem 0;
    background-color: #1b1b1b;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
}

/* Navigation Links */
.wiki-navigation a,
.home-links a,
.store-links a {
    color: #4d0eb3;
    text-decoration: none;
    font-size: 1rem;
    font-weight: bold;
    transition: color 0.3s ease-in-out, text-decoration 0.3s ease-in-out;
}
.wiki-navigation a:hover,
.home-links a:hover,
.store-links a:hover {
    color: #7603ff;
    text-decoration: underline;
}

:root {
    --nav-top-offset: 150px; /* keep this in sync with .side-nav top */
}

/* Sidebar (desktop default) */
.side-nav {
    width: 250px;
    /* Allow sidebar to grow, then scroll when exceeding viewport minus header spacing */
    position: sticky;
    top: var(--nav-top-offset);
    background: #1b1b1b linear-gradient(180deg, #1b1b1b, #111);
    padding: 1rem;
    margin-left: 1rem;
    z-index: 1000;
    /* Cap the visible area so it never grows past the viewport */
    max-height: calc(95vh - var(--nav-top-offset));
    overflow-y: auto;
    border-radius: 8px;
    box-shadow: 5px 0 10px rgba(0, 0, 0, 0.3);
    scrollbar-width: thin;
    scrollbar-color: #4d0eb3 #1b1b1b;
    transition: transform 0.3s ease;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Sidebar Heading */
.side-nav h2 {
    color: #4d0eb3;
    text-align: center;
    margin-bottom: 1.5rem;
}

/* Categories and Subcategories headers */
.category,
.subcategory-title {
    color: #e0e0e0;
    padding: 0.6rem 1.2rem;
    cursor: pointer;
    font-weight: bold;
    background-color: #1b1b1b;
    border-bottom: 1px solid #2d2d2d;
    transition: background-color 0.3s ease, transform 0.2s ease;
    list-style-type: none;
    user-select: none;
    outline: none;
}

/* Visual cue when open */
.category[aria-expanded="true"],
.subcategory-title[aria-expanded="true"] {
    background-color: #222222;
}

/* Hover/active feedback */
.category:hover,
.subcategory-title:hover {
    background-color: #292929;
    transform: translateX(5px);
}
.category:active,
.subcategory-title:active {
    transform: scale(0.98);
    background-color: #4d0eb3;
    color: #ffffff;
}

/* Arrow rotation state */
.arrow {
    display: inline-block;
    transition: transform 0.25s ease;
    margin-right: 0.35rem;
    color: #b79cff;
}
.arrow.rotated {
    transform: rotate(-90deg);
}

/* Subcategory Behavior - animated accordion (collapsed by default) */
.subcategory {
    display: block; /* keep in flow for measurement */
    max-height: 0;
    overflow: hidden;
    padding: 0;
    margin: 0;
    list-style: none;
    transition: max-height 0.3s ease, padding 0.3s ease;
    will-change: max-height;
    background-color: #151515;
    border-left: 2px solid #2a2a2a;
}

/* When active (JS toggles), add inner padding for spacing */
.subcategory.active {
    padding-top: 0.25rem;
    padding-bottom: 0.25rem;
}

/* Links inside subcategories */
.subcategory li a {
    display: block;
    color: #dcd3ff;
    text-decoration: none;
    font-weight: 600;
    padding: 0.5rem 0.75rem 0.5rem 1.6rem;
    border-left: 3px solid transparent;
    transition: background-color 0.2s ease, color 0.2s ease, border-left-color 0.2s ease;
}
.subcategory li a:hover {
    background-color: #1e1e1e;
    color: #ffffff;
}

/* Indicate current page */
.subcategory li a.is-current {
    background: linear-gradient(90deg, rgba(77,14,179,0.18), rgba(77,14,179,0.05));
    color: #ffffff;
    border-left-color: #4d0eb3;
}

/* Keyboard focus styles */
.category:focus-visible,
.subcategory-title:focus-visible,
.subcategory li a:focus-visible {
    outline: 2px solid #4d0eb3;
    outline-offset: 2px;
    border-radius: 4px;
}

/* Mobile/off-canvas behavior */
@media (max-width: 1024px) {
    .side-nav {
        position: fixed;
        top: 0;
        left: 0;
        height: 85vh;
        max-height: 100vh; /* full viewport */
        margin-left: 0;
        border-radius: 0;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        width: 80vw;
        max-width: 320px;
        box-shadow: 10px 0 20px rgba(0,0,0,0.5);
        z-index: 1100;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
    }
    .side-nav.open {
        transform: translateX(0);
    }
}

/* Backdrop */
.nav-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    z-index: 1090;
}
.nav-backdrop.active {
    opacity: 1;
    visibility: visible;
}

/* Scrollbar Customization */
.side-nav::-webkit-scrollbar {
    width: 8px;
}
.side-nav::-webkit-scrollbar-track {
    background: #1b1b1b;
}
.side-nav::-webkit-scrollbar-thumb {
    background: #4d0eb3;
    border-radius: 5px;
}
.side-nav::-webkit-scrollbar-thumb:hover {
    background: #7603ff;
}

/* Optional floating toggle button for mobile (injected by JS) */
.nav-toggle-btn {
    position: fixed;
    left: 0.75rem;
    bottom: 1rem;
    width: 46px;
    height: 46px;
    border-radius: 50%;
    border: 1px solid #2b2b2b;
    background: radial-gradient(circle at 30% 30%, #2a2144, #151226);
    color: #e9e3ff;
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1150;
    box-shadow: 0 6px 16px rgba(0,0,0,0.35);
    cursor: pointer;
}
.nav-toggle-btn:active {
    transform: scale(0.98);
}
@media (max-width: 1024px) {
    .nav-toggle-btn {
        display: inline-flex;
    }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    .subcategory,
    .side-nav,
    .nav-backdrop,
    .arrow {
        transition: none !important;
    }
}