/* ===== Dropdown Base ===== */
/* ===== Dropdown Menu (Glassmorphic) ===== */
.dropdown {
    position: relative;
}

.dropdown-toggle {
    cursor: pointer;
    display: inline-block;
}

/* 1. The Default State */
/* Dropdown menu hidden by default */
.dropdown-menu {
    display: none;
    position: absolute;
    /* top: 150%; */
    left: -10px;
    min-width: 180px;
    border-radius: 12px;
    padding: 12px 0;
    z-index: 1000;
    opacity: 0;
    transform: translateY(10px);
    /* transition: opacity 0.3s ease, transform 0.3s ease; */

    visibility: hidden;
    /* ADD THIS: A small delay (0.2s) when mouse leaves so it doesn't flicker shut */
    transition: opacity 0.3s ease, transform 0.3s ease, visibility 0s linear 0.2s;
    /* CRITICAL: Ensure there's no physical gap. 
       If your menu is lower down, use a transparent border to bridge the gap */
    border-top: 10px solid transparent;
    /* margin-top: -10px; */
}

/* 2. The Hover State */
/* Show dropdown on hover */
.dropdown:hover .dropdown-menu,
.dropdown-menu:hover {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);

    /* Remove the delay on hover-in so it feels instant */
    transition-delay: 0s;
}

.dropdown:hover .dropdown-menu {
    display: block;
}

.glass-dropdown {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.5);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
}

/* Dropdown menu links */
.dropdown-menu li {
    list-style: none;
}

.dropdown-menu a {
    display: block;
    /* color: #fff; */
    padding: 8px 16px;
    text-decoration: none;
    transition: background 0.3s;
}

.dropdown-menu a:hover {
    background-color: #444;
}

.dropdown-menu li {
    padding: 8px 20px;
}

/* Default link style */
.dropdown-menu li a {
    color: #475569 !important;
    font-size: 1rem;
    display: block;
    width: 100%;
    transition: all 0.3s ease;
    padding: 10px 15px;
    display: block;
    text-decoration: none;
}

.dropdown-menu li a:hover {
    color: var(--color-primary) !important;
    transform: translateX(5px);
    /* Slide right on hover */
}

/* The Active State - When the user is scrolling that section */
.dropdown-menu li a.active {
    color: #E95420;
    /* Ubuntu Orange */
    font-weight: bold;
    background: rgba(255, 255, 255, 0.1);
    /* Subtle glass highlight */
    border-left: 3px solid #E95420;
    /* Visual indicator on the side */
}

/* Arrow indicator (base) */
.dropdown-toggle::after {
    content: "▾";
    display: inline-block;
    margin-left: 6px;
    /* This transition automatically handles BOTH the forward (0 to 180) 
       and reverse (180 back to 0) animations. */
    transition: transform 0.3s ease;
}

/* Rotate arrow upward when HOVERING over the dropdown wrapper */
.dropdown:hover .dropdown-toggle::after {
    transform: rotate(180deg);
}

/* ===== Mobile Dropdown and Hamburger ===== */
@media (max-width: 768px) {
    .dropdown-menu {
        position: static;
        /* Prevents overlap */
        /* background: #333; */
        /* background: transparent; */
        border: none;
        display: none;
        /* Handled by mobile JS */
        width: 100%;
        /* padding-left: 16px; */
        border-radius: 10px;
        overflow: hidden;
        max-height: 0;
        transition: max-height 0.3s ease;

        background: rgba(30, 41, 59, 0.85);
        /* order work for this BG */

        box-shadow: 1px 4px 8px rgba(0, 0, 0, 0.3);
        border: 1px solid rgba(255, 255, 255, 0.2);
        backdrop-filter: blur(10px);
        will-change: max-height;
    }

    body.dark .dropdown-menu {
        background: rgba(15, 23, 42, 0.85);
        /* order work for this BG */
        box-shadow: 0 8px 32px rgba(255, 255, 255, 0.2);
        border: 1px solid rgba(255, 255, 255, 0.2);
        backdrop-filter: blur(10px);
        will-change: max-height;
    }

    nav.scrolled .dropdown-menu {
        /* order work for this BG */
        box-shadow: 0 8px 12px rgba(0, 0, 0, 0.5);
    }

    body.dark nav.scrolled .dropdown-menu {
        background: rgba(15, 23, 42, 0.85);
        /* order work for this BG */
        box-shadow: 0 8px 12px rgba(255, 255, 255, 0.2);
    }

    .dropdown.open .dropdown-menu {
        max-height: 500px;
        /* Adjust as needed */
    }

    .dropdown-menu li a {
        color: #ffffff !important;
        font-size: 1rem;
        display: block;
        width: 100%;
    }

    /* Mobile view click/tap effect */
    /* Target the active state when JS adds the 'open' class */
    .dropdown.open .dropdown-toggle::after {
        transform: rotate(180deg);
    }

    /* Optional: Disable the hover effect on mobile to prevent "sticky" tap bugs */
    .dropdown:hover .dropdown-toggle::after {
        transform: rotate(0deg);
    }

    /* Make sure the arrow stays rotated as long as the menu is open, 
       even if the user taps elsewhere on the dropdown */
    .dropdown.open:hover .dropdown-toggle::after {
        transform: rotate(180deg);
    }
}