/* Glossary specific styling */
.glossary-container {
    display: flex;
    gap: 2rem;
    margin-top: 2rem;
}

.glossary-sidebar {
    position: fixed;
    top: 100px; /* Initial position */
    height: 85vh;
    width: 280px;
    flex-shrink: 0;
    padding: 1rem;
    background: rgba(30, 30, 30, 0.5);
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(5px);
    z-index: 10;
}

.glossary-content {
    flex: 1;
    margin-left: 300px; /* Space for the sidebar */
}

.glossary-search {
    margin-bottom: 1.5rem;
    width: 100%;
    padding: 0.75rem;
    background: #111;
    border: 1px solid #444;
    border-radius: 4px;
    color: #fff;
}

.glossary-search:focus {
    border-color: var(--brand-color);
    outline: none;
}

.glossary-index {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.glossary-index-item {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: #222;
    border-radius: 4px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.glossary-index-item:hover,
.glossary-index-item.active {
    background: var(--brand-color);
    color: white;
}

.glossary-nav {
    list-style: none;
    padding: 0;
    margin: 0;
    max-height: 60vh;
    overflow-y: auto;
    scrollbar-width: thin;
}

.glossary-nav::-webkit-scrollbar {
    width: 6px;
}

.glossary-nav::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 3px;
}

.glossary-nav::-webkit-scrollbar-thumb {
    background: var(--brand-color);
    border-radius: 3px;
}

.glossary-nav-item {
    padding: 0.5rem 0;
}

.glossary-nav-link {
    display: block;
    padding: 0.5rem;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.glossary-nav-link:hover,
.glossary-nav-link.active {
    background: rgba(16, 81, 185, 0.2);
    color: white;
}

.glossary-entry {
    margin-bottom: 2.5rem;
    padding-bottom: 2.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    scroll-margin-top: 100px;
}

.glossary-entry:last-child {
    border-bottom: none;
}

.glossary-entry h2 {
    color: white;
    font-size: 1.8rem;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
}

.glossary-entry h2::before {
    content: "#";
    color: var(--brand-color);
    margin-right: 0.5rem;
    font-weight: 300;
    opacity: 0.7;
}

.glossary-entry p {
    margin-bottom: 1rem;
    line-height: 1.8;
    color: #ccc;
}

.glossary-entry strong {
    color: white;
}

.glossary-letter-heading {
    font-size: 2rem;
    color: var(--brand-color);
    margin: 2rem 0 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--brand-color);
}

/* Mobile adjustments */
@media (max-width: 768px) {
    .glossary-container {
        flex-direction: column;
    }

    .glossary-sidebar {
        position: relative;
        width: 100%;
        top: auto;
        margin-bottom: 2rem;
    }
    
    .glossary-content {
        margin-left: 0;
    }
}

/* No results message */
#no-results {
    display: none;
    padding: 2rem;
    text-align: center;
    background: rgba(255, 0, 0, 0.1);
    border-radius: 8px;
    margin: 2rem 0;
}

/* ---------- DESKTOP (≥ 769 px) ---------- */
@media (min-width: 769px) {
    .glossary-sidebar {
        position: absolute; /* Change from sticky to absolute */
        top: 0; /* Initial position, will be controlled by JS */
        align-self: flex-start;
        width: 280px;
        height: auto; /* Auto height based on content */
        max-height: calc(100vh - 80px); /* Viewport height minus navbar height */
        padding: 1rem;
        background: rgba(30, 30, 30, 0.5);
        border-radius: 8px;
        border: 1px solid rgba(255, 255, 255, 0.1);
        backdrop-filter: blur(5px);
        overflow-y: auto;
        scrollbar-width: thin;
        z-index: 10;
        transform: translateY(0); /* Initial transform for JS control */
        transition: transform 0.05s ease-out; /* Smooth movement */
    }

    .glossary-container {
        position: relative; /* Create positioning context */
    }

    .glossary-content {
        flex: 1 1 0;
        margin-left: 300px; /* Add space for sidebar */
    }

    /* Remove max-height limitation from nav since parent now scrolls */
    .glossary-nav {
        max-height: none;
        overflow-y: visible;
    }
}

/* Keep the existing scrollbar styling but move it to the sidebar */
.glossary-sidebar::-webkit-scrollbar {
    width: 6px;
}

.glossary-sidebar::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 3px;
}

.glossary-sidebar::-webkit-scrollbar-thumb {
    background: var(--brand-color);
    border-radius: 3px;
}

