/* --- Styles for the Enhanced Universal Animated Index Menu --- */

/* 1. The Index/Close Button Container */
.index-menu-button {
    background: none;
    border: none;
    cursor: pointer;
    z-index: 10001 !important; /* Always above header content */
    transition: transform 0.4s cubic-bezier(0.68, -0.55, 0.27, 1.55);
    padding: 5px;
    backface-visibility: hidden;
    width: 28px;
    height: 28px;
    position: relative;
}

/* Style for the icons inside the button */
.index-menu-button svg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    transition: opacity 0.3s ease-in-out, transform 0.3s ease-in-out;
    stroke: #111827; /* Default dark color */
}

#index-close-icon {
    opacity: 0;
    transform: rotate(-90deg) scale(0.7);
}

.index-menu-button.active #index-open-icon {
    opacity: 0;
    transform: rotate(90deg) scale(0.7);
}
.index-menu-button.active #index-close-icon {
    opacity: 1;
    transform: rotate(0deg) scale(1);
    stroke: #111827 !important;
}

/* Body & HTML Scroll Lock when Menu is open */
body.menu-open,
html.menu-open {
    overflow: hidden !important;
    height: 100vh !important;
}

/* 3. The Full-Screen Menu Overlay */
.index-menu-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    z-index: 9998 !important; /* Kept under the header (9999) so close button is clickable */
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding-top: 70px; /* Shifted up: directly below the header bar */
    overflow-y: auto;
}

.index-menu-overlay.active {
    opacity: 1;
    pointer-events: all;
}

/* 4. The Content Inside the Menu */
.index-menu-content {
    max-width: 500px;
    width: 90%;
    padding: 1.5rem 0;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1) 0.05s, transform 0.3s cubic-bezier(0.4, 0, 0.2, 1) 0.05s;
    display: flex;
    flex-direction: column;
}

.index-menu-overlay.active .index-menu-content {
    opacity: 1;
    transform: translateY(0);
}

/* Search Box Container */
.search-box-container {
    position: relative;
    margin-bottom: 2rem;
    width: 100%;
}

/* Search Box Input */
.index-search-box {
    width: 100%;
    font-size: 1rem;
    font-family: 'Inter', sans-serif;
    font-weight: 500;
    padding: 12px 16px 12px 42px;
    border: 1px solid #e5e7eb;
    background-color: #f9fafb;
    outline: none;
    transition: all 0.2s ease;
    color: #111827;
    border-radius: 12px;
    box-sizing: border-box;
}
.index-search-box::placeholder {
    color: #9ca3af;
}
.index-search-box:focus {
    border-color: #0073e6;
    background-color: #ffffff;
    box-shadow: 0 0 0 4px rgba(0, 115, 230, 0.1);
}

/* Search Icon Styling */
.search-icon {
    position: absolute;
    top: 50%;
    left: 14px;
    transform: translateY(-50%);
    color: #9ca3af;
    pointer-events: none;
    display: flex;
    align-items: center;
}
.search-icon svg {
     width: 18px;
     height: 18px;
}

/* 6. Main Navigation Links (Table-Like Box Layout with Borders) */
.index-main-nav {
    display: flex;
    flex-direction: column;
    gap: 0;
    padding: 0;
    margin-bottom: 1.5rem;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    overflow: hidden;
    background-color: #ffffff;
}

.index-main-nav > div,
.index-main-nav > a {
    text-decoration: none;
    color: #374151;
    font-weight: 700;
    font-size: 1.1rem;
    font-family: 'Inter', sans-serif;
    padding: 14px 18px;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    transition: all 0.2s ease;
    box-sizing: border-box;
}

.index-main-nav > div:last-child,
.index-main-nav > a:last-child {
    border-bottom: none;
}

.index-main-nav > div:hover,
.index-main-nav > a:hover {
    color: #0073e6;
    background-color: #f9fafb;
}

/* Dropdown Specific Styles */
.dropdown-toggle {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.dropdown-toggle::after {
    content: '▼';
    font-size: 0.65em;
    margin-left: 0.5rem;
    transition: transform 0.2s ease;
    color: #9ca3af;
}
.nav-item-dropdown.open .dropdown-toggle::after {
    transform: rotate(180deg);
    color: #0073e6;
}

.categories-dropdown {
    list-style: none;
    padding: 0;
    margin: 0;
    background-color: transparent;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    width: 100%;
}
.nav-item-dropdown.open .categories-dropdown {
    max-height: 450px;
    overflow-y: auto;
    margin-top: 0;
    border-left: none;
    margin-left: 0;
    border-top: 1px solid #e5e7eb;
    background-color: #f9fafb;
}
.categories-dropdown li {
    border-bottom: 1px solid #f3f4f6;
}
.categories-dropdown li:last-child {
    border-bottom: none;
}
.categories-dropdown li a {
    display: block;
    padding: 12px 18px 12px 32px;
    text-decoration: none;
    color: #4b5563;
    font-size: 0.95rem;
    font-weight: 600;
    font-family: 'Inter', sans-serif;
    transition: all 0.2s ease;
    border-radius: 0;
}
.categories-dropdown li a:hover {
    background-color: rgba(0, 115, 230, 0.06);
    color: #0073e6;
}

/* 7. Results List (Search Results) */
#index-results-list {
    list-style: none;
    padding: 0;
    margin: 0;
    max-height: 35vh;
    overflow-y: auto;
    transition: all 0.2s ease;
}
#index-results-list.has-results {
    border-bottom: 1px dashed #e5e7eb;
    padding-bottom: 1rem;
    margin-bottom: 1.5rem;
}
#index-results-list li a {
    display: block;
    padding: 10px 14px;
    text-decoration: none;
    color: #4b5563;
    font-size: 0.95rem;
    font-weight: 600;
    font-family: 'Inter', sans-serif;
    transition: all 0.2s ease;
    border-radius: 8px;
    border-bottom: none;
    margin-bottom: 2px;
}
#index-results-list li a:hover {
    background-color: rgba(0, 115, 230, 0.06);
    color: #0073e6;
}

/* Home Link SVG Animation in Drawer */
.home-link-with-logo {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.menu-home-logo {
    width: 20px;
    height: 20px;
    margin-left: 1rem;
    color: #3498db;
    flex-shrink: 0;
}

.menu-home-logo .tmp-text {
    font-family: 'Merriweather', serif;
    font-size: 80px;
    font-weight: bold;
    fill: #000000;
}

.menu-home-logo .square {
    fill: currentColor;
}

.menu-home-logo .rotating-circle {
    transform-origin: center;
    animation: rotate 10s linear infinite;
    stroke: currentColor;
    stroke-width: 4;
}

@keyframes rotate {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

@media (max-width: 768px) {
    .index-menu-overlay { padding-top: 60px; } /* Pushed up on mobile */
    .index-search-box { font-size: 0.95rem; }
    .index-main-nav > div, .index-main-nav > a { font-size: 1rem; padding: 12px 16px; }
}

/* --- Dark Mode Specific Styles (Fully fixed to html.dark-mode!) --- */
html.dark-mode .index-menu-overlay { 
    background-color: rgba(17, 24, 39, 0.97); 
}
html.dark-mode .index-menu-button svg { 
    stroke: var(--dark-text-primary); 
}
html.dark-mode .index-menu-button.active #index-close-icon {
    stroke: var(--dark-text-primary) !important;
}
html.dark-mode .index-search-box {
    background-color: #1f2937;
    color: var(--dark-text-primary);
    border-color: #374151;
}
html.dark-mode .index-search-box::placeholder { 
    color: var(--dark-text-secondary); 
}
html.dark-mode .index-search-box:focus {
    border-color: var(--dark-accent-primary);
    background-color: #111827;
    box-shadow: 0 0 0 4px rgba(96, 165, 250, 0.15);
}
html.dark-mode .search-icon { 
    color: var(--dark-text-secondary); 
}

/* Dark Mode Navigation Borders */
html.dark-mode .index-main-nav {
    border-color: #374151;
    background-color: #1f2937;
}

html.dark-mode .index-main-nav > div, 
html.dark-mode .index-main-nav > a {
    color: var(--dark-text-primary);
    border-bottom-color: #374151;
}

html.dark-mode .index-main-nav > div:hover, 
html.dark-mode .index-main-nav > a:hover {
    color: var(--dark-accent-primary);
    background-color: #111827;
}
html.dark-mode .categories-dropdown {
    background-color: #111827;
}
html.dark-mode .categories-dropdown li {
    border-bottom-color: #1f2937;
}
html.dark-mode .categories-dropdown li a { 
    color: var(--dark-text-secondary); 
}
html.dark-mode .categories-dropdown li a:hover {
    background-color: rgba(96, 165, 250, 0.08);
    color: var(--dark-accent-primary);
}

html.dark-mode #index-results-list.has-results {
    border-bottom-color: #374151;
}
html.dark-mode #index-results-list li a {
    color: var(--dark-text-secondary);
}
html.dark-mode #index-results-list li a:hover {
    background-color: rgba(96, 165, 250, 0.08);
    color: var(--dark-accent-primary);
}

html.dark-mode .menu-home-logo {
   color: #60a5fa;
}
html.dark-mode .menu-home-logo .tmp-text {
    fill: #ffffff;
}