/* Mega Menu Styles for Thailand Guide */

.nav-links {
    display: flex; /* Ensure they are visible on desktop */
}

.dropdown-group {
    position: relative;
    display: flex;
    align-items: center;
}

.dropdown-toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
}

.dropdown-icon {
    width: 12px;
    height: 12px;
    transition: transform 0.3s ease;
    opacity: 0.7;
}

/* Dropdown Menu (Mega Menu) */
.dropdown-menu.mega-menu {
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(10px);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 1000;
    margin-top: 1.5rem; /* Visual gap */
}

/* Localized invisible bridge: only exactly as wide as the toggle link! */
.dropdown-group::after {
    content: "";
    position: absolute;
    bottom: -1.5rem;
    left: 0;
    right: 0;
    height: 1.5rem;
    background: transparent;
    z-index: 1;
}

/* The massive 800px wide invisible bridge was removed because it overlapped adjacent top-level links */

@media (min-width: 1025px) {
    .dropdown-group:hover .dropdown-menu {
        opacity: 1;
        visibility: visible;
        transform: translateX(-50%) translateY(0px);
    }

    .dropdown-group:hover .dropdown-icon {
        transform: rotate(180deg);
    }
}

.mega-menu-inner {
    background-color: rgba(18, 18, 18, 0.85); /* Dark translucent base */
    background-image: 
        linear-gradient(110deg, transparent 20%, rgba(255, 255, 255, 0.05) 25%, transparent 30%),
        linear-gradient(to bottom, rgba(18, 18, 18, 0.4), rgba(0, 0, 0, 0.6));
    backdrop-filter: blur(25px); /* Strong glass blur */
    -webkit-backdrop-filter: blur(25px);
    border: 1px solid rgba(255, 255, 255, 0.15); /* Soft highlight border */
    border-radius: 1rem;
    padding: 2.5rem;
    display: flex;
    gap: 4rem;
    box-shadow: 
        0 20px 40px rgba(0, 0, 0, 0.6),
        inset 0 1px 1px rgba(255, 255, 255, 0.1); /* Inner rim highlight */
    position: relative;
    min-width: 500px;
    overflow: hidden; /* Clips the internal gradients */
}

/* Subtle gloss overlay */
.mega-menu-inner::after {
    content: "";
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at top left, rgba(255, 255, 255, 0.05), transparent 60%);
    pointer-events: none;
    z-index: -1;
}

/* Top arrow - modified for glass */
.mega-menu-inner::before {
    content: "";
    position: absolute;
    top: -6px;
    left: 50%;
    transform: translateX(-50%) rotate(45deg);
    width: 12px;
    height: 12px;
    background-color: rgba(18, 18, 18, 0.95);
    backdrop-filter: blur(25px);
    border-left: 1px solid rgba(255, 255, 255, 0.15);
    border-top: 1px solid rgba(255, 255, 255, 0.15);
    z-index: 1;
}

.mega-menu-column {
    flex: 1;
    min-width: 180px;
}

.mega-menu-heading {
    font-family: var(--font-headline);
    font-size: 0.75rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    color: var(--tertiary); /* Saffron brand color */
    margin-bottom: 1.5rem;
    display: block;
    border-bottom: 1px solid rgba(253, 157, 26, 0.2); /* Subtle underline */
    padding-bottom: 0.5rem;
}

.mega-menu-column .mega-menu-heading:not(:first-child) {
    margin-top: 2.5rem; /* Space between sections in one column */
}

.mega-menu-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.mega-menu-link {
    font-family: var(--font-body);
    font-size: 0.95rem;
    color: rgba(255, 255, 255, 0.6);
    transition: all 0.2s ease;
    white-space: nowrap;
    display: block;
}

.mega-menu-link:hover {
    color: #ffffff;
    transform: translateX(4px);
}

/* CTA variant — saffron "→ All X" links at the bottom of each column.
   Doubled-up class selector raises specificity so the mobile @media
   override of .mega-menu-link doesn't recolor these. */
.mega-menu-link.mega-menu-link--cta {
    color: var(--tertiary);
    font-weight: 700;
}

/* Wrapper spacing for CTA list items */
.mega-menu-list-item--spaced    { margin-top: 1.5rem; }
.mega-menu-list-item--spaced-sm { margin-top: 0.5rem; }

/* Second Level Sub-menu */
.mega-submenu-list {
    list-style: none;
    padding: 0.5rem 0 0.5rem 1.25rem; /* Indent nested links */
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    position: relative;
}

/* Connecting line for nested items */
.mega-submenu-list::before {
    content: "";
    position: absolute;
    left: 0.25rem;
    top: 0;
    bottom: 0.75rem;
    width: 1px;
    background: rgba(255, 255, 255, 0.1);
}

.mega-submenu-link {
    font-family: var(--font-body);
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.45);
    transition: all 0.2s ease;
    display: block;
    position: relative;
}

.mega-submenu-link::before {
    content: "—";
    position: absolute;
    left: -0.75rem;
    opacity: 0.3;
}

.mega-submenu-link:hover {
    color: var(--tertiary); /* Saffron on hover */
    transform: translateX(2px);
}

.group-title {
    font-weight: 700;
    color: rgba(255, 255, 255, 0.9) !important;
    cursor: default;
}

/* Mobile Adjustments */
@media (max-width: 1024px) {
    .nav-bar.menu-is-open {
        background: transparent !important;
        backdrop-filter: none !important;
        border-bottom-color: rgba(255, 255, 255, 0.1) !important;
    }

    .nav-container {
        overflow: visible !important;
    }

    .nav-links {
        position: fixed;
        top: 0;
        right: -100%;
        width: 100%;
        height: 100vh;
        background: rgba(10, 10, 10, 0.98); /* Slightly darker for better link pop */
        backdrop-filter: blur(35px);
        -webkit-backdrop-filter: blur(35px);
        flex-direction: column;
        padding: 100px 2.5rem 3rem;
        transition: right 0.5s cubic-bezier(0.16, 1, 0.3, 1);
        z-index: 999;
        overflow-y: auto;
        display: flex; 
        gap: 0;
        visibility: visible !important;
        opacity: 1 !important;
    }

    .nav-links.is-active {
        right: 0;
    }

    /* Hamburger Animation */
    .mobile-menu-toggle {
        display: flex;
        flex-direction: column;
        justify-content: center;
        gap: 6px;
        width: 30px;
        height: 30px;
        z-index: 1001;
        position: relative;
        cursor: pointer;
        background: none;
        border: none;
        padding: 0;
    }

    .hamburger-line {
        display: block;
        width: 100%;
        height: 2px;
        background-color: var(--on-surface);
        transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
        border-radius: 2px;
    }

    .nav-bar.menu-is-open .hamburger-line {
        background-color: #ffffff;
    }

    .mobile-menu-toggle.is-open .hamburger-line:nth-child(1) {
        transform: translateY(8px) rotate(45deg);
    }

    .mobile-menu-toggle.is-open .hamburger-line:nth-child(2) {
        opacity: 0;
        transform: translateX(10px);
    }

    .mobile-menu-toggle.is-open .hamburger-line:nth-child(3) {
        transform: translateY(-8px) rotate(-45deg);
    }

    .dropdown-group {
        width: 100%;
        flex-direction: column;
        align-items: flex-start;
        border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    }

    .dropdown-toggle {
        width: 100%;
        padding: 1.25rem 0;
        justify-content: space-between;
        font-size: 1.25rem;
        font-weight: 600;
        letter-spacing: 0.02em;
        color: rgba(255, 255, 255, 0.9) !important; /* Force visibility on dark mobile background */
    }

    .nav-link {
        color: rgba(255, 255, 255, 0.9) !important;
        width: 100%;
        padding: 1.25rem 0;
        border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    }

    .nav-link:hover,
    .dropdown-toggle:hover {
        color: #ffffff !important;
        opacity: 1 !important;
    }

    .dropdown-icon {
        width: 18px;
        height: 18px;
    }

    /* Mobile Accordion Logic */
    .dropdown-menu.mega-menu {
        position: static;
        transform: none !important; /* Prevent desktop centering transform from shifting menu off-screen */
        opacity: 1 !important;
        visibility: visible !important;
        display: none; /* Controlled by JS */
        padding: 0;
        width: 100%;
        transition: none;
    }

    .dropdown-group.is-open .dropdown-menu {
        display: block;
        padding-bottom: 2rem;
    }

    .dropdown-group.is-open .dropdown-icon {
        transform: rotate(180deg);
    }

    .mega-menu-inner {
        background: transparent;
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
        border: none;
        border-radius: 0; /* Remove desktop corner radius */
        padding: 0;
        flex-direction: column;
        gap: 2rem;
        min-width: 100% !important;
        box-shadow: none;
        overflow: visible; /* Ensure selection isn't clipped */
    }

    .mega-menu-inner::before,
    .mega-menu-inner::after {
        display: none;
    }

    .mega-menu-column {
        min-width: 100%;
    }

    .mega-menu-heading {
        font-size: 0.7rem;
        margin-bottom: 1rem;
        opacity: 0.6;
    }

    .mega-menu-link {
        font-size: 1.1rem;
        padding: 0.5rem 0;
        white-space: normal;
        color: rgba(255, 255, 255, 0.85); /* Boosted for mobile */
    }

    .mega-menu-link:hover {
        transform: none;
        color: #ffffff !important;
    }

    .mega-submenu-list {
        padding-left: 1.5rem;
        margin-top: 0.5rem;
        margin-bottom: 1rem;
    }

    .mega-submenu-link {
        font-size: 1.05rem;
        padding: 0.4rem 0;
        color: rgba(255, 255, 255, 0.6);
    }
}
