/* ============================================================
   SWD Navigation — Modern Mega Menu
   ============================================================ */

/* ----- Reset helpers ----- */
.no-margin { margin: 0; }
.no-padding { padding: 0; }

/* ============================================================
   NAV BASE
   ============================================================ */
header nav {
    display: block;
    position: relative;
}

ul.grt-menu {
    display: flex;
    align-items: center;
    margin: 0;
    padding: 0;
    list-style: none;
    gap: 2px;
    flex-wrap: nowrap;
}

ul.grt-menu::after {
    content: "";
    display: table;
    clear: both;
}

/* Top-level items */
ul.grt-menu > li {
    position: relative;
    display: inline-flex;
    align-items: center;
    padding: 0;
    margin: 0;
}

/* Top-level links */
ul.grt-menu > li > a {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 9px 12px;
    font-size: 20px;
    font-weight: 600;
    color: #ffffff !important;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-family: 'Merriweather', serif;
    border-radius: 6px;
    transition: color 0.25s ease, background 0.25s ease;
    cursor: pointer;
    white-space: nowrap;
    text-decoration: none !important;
}

ul.grt-menu > li > a:hover,
ul.grt-menu > li.grt-dropdown:hover > a {
    color: #f69221 !important;
    background: rgba(246, 146, 33, 0.10);
    text-decoration: none !important;
}

/* Nav item icons */
.nav-icon {
    font-size: 13px;
    opacity: 0.80;
    color: #00d2ff;
    transition: color 0.25s ease, opacity 0.25s ease, transform 0.25s ease;
    flex-shrink: 0;
}
ul.grt-menu > li > a:hover .nav-icon,
ul.grt-menu > li.grt-dropdown:hover > a .nav-icon {
    color: #f69221;
    opacity: 1;
    transform: scale(1.15);
}

/* Active page underline */
ul.grt-menu > li.active > a {
    color: #ffffff;
}
ul.grt-menu > li.active > a::after {
    content: '';
    position: absolute;
    bottom: 4px;
    left: 14px;
    right: 14px;
    height: 2px;
    background: linear-gradient(to right, #00d2ff, #528ac8);
    border-radius: 2px;
    box-shadow: 0 0 8px rgba(0, 210, 255, 0.60);
}

/* Caret icon */
.nav-caret {
    font-size: 11px;
    opacity: 0.7;
    transition: transform 0.25s ease;
}
ul.grt-menu > li.grt-dropdown:hover .nav-caret {
    transform: rotate(180deg);
}

/* ============================================================
   MOBILE HAMBURGER BUTTON
   ============================================================ */
.grt-mobile-button {
    display: none;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 4px;
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    z-index: 200;
}
.grt-mobile-button:focus { outline: none; }

.grt-mobile-button .line1,
.grt-mobile-button .line2,
.grt-mobile-button .line3 {
    display: block;
    width: 28px;
    height: 3px;
    background: #b8cce4;
    border-radius: 2px;
    margin: 5px 0;
    transition: all 0.35s ease;
}

/* Open state — X */
.grt-mobile-button-open .line1 {
    transform: rotate(-45deg) translate(-6px, 4px);
    background: #f69221;
}
.grt-mobile-button-open .line2 { opacity: 0; }
.grt-mobile-button-open .line3 {
    transform: rotate(45deg) translate(-6px, -5px);
    background: #f69221;
}

.body-overflow { overflow: hidden; }

/* ============================================================
   SIMPLE DROPDOWN  (non-mega)
   ============================================================ */
ul.grt-menu li.grt-dropdown:not(.mega-dropdown) ul.grt-dropdown-list {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    background: rgba(6, 15, 30, 0.97);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-radius: 10px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(82, 138, 200, 0.15);
    border-top: 2px solid rgba(0, 210, 255, 0.50);
    min-width: 200px;
    padding: 8px 0;
    z-index: 1000;
    animation: fadeSlideDown 0.22s ease;
    list-style: none;
    margin: 0;
}

ul.grt-menu li.grt-dropdown:not(.mega-dropdown):hover > ul.grt-dropdown-list {
    display: block;
}

ul.grt-menu li.grt-dropdown:not(.mega-dropdown) ul.grt-dropdown-list li {
    display: block;
    padding: 0;
    border: none;
}

ul.grt-menu li.grt-dropdown:not(.mega-dropdown) ul.grt-dropdown-list li a {
    display: block;
    padding: 10px 18px;
    font-size: 13px;
    color: #b8cce4;
    text-transform: none;
    font-family: 'Merriweather', serif;
    font-weight: 400;
    line-height: 1.4;
    transition: color 0.2s ease, padding-left 0.2s ease;
    text-decoration: none;
}

ul.grt-menu li.grt-dropdown:not(.mega-dropdown) ul.grt-dropdown-list li a:hover {
    color: #f69221;
    padding-left: 24px;
    background: rgba(246, 146, 33, 0.08);
}

/* ============================================================
   MEGA MENU PANEL
   ============================================================ */
.mega-panel {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: rgba(6, 15, 30, 0.97);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 14px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.65), 0 0 0 1px rgba(82, 138, 200, 0.18);
    border-top: 2px solid rgba(0, 210, 255, 0.55);
    padding: 20px;
    z-index: 1000;
    min-width: 560px;
    animation: fadeSlideDown 0.22s ease;
}

ul.grt-menu li.mega-dropdown:hover > .mega-panel {
    display: block;
}

/* Transparent bridge fills the gap so the panel doesn't vanish mid-hover */
.mega-panel::before {
    content: '';
    position: absolute;
    top: -10px;
    left: 0;
    right: 0;
    height: 10px;
    background: transparent;
}

.mega-panel-inner {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

/* Individual mega link card */
.mega-link {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 14px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.04);
    border: 1.5px solid rgba(82, 138, 200, 0.15);
    text-decoration: none !important;
    transition: all 0.25s ease;
}

.mega-link:hover {
    background: rgba(0, 210, 255, 0.07);
    border-color: rgba(0, 210, 255, 0.40);
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0, 210, 255, 0.12);
    text-decoration: none !important;
}

/* Icon badge — AI blue gradient */
.mega-link-icon {
    flex-shrink: 0;
    width: 42px;
    height: 42px;
    border-radius: 10px;
    background: linear-gradient(135deg, #0f3a6e 0%, #1167a8 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #00d2ff;
    font-size: 17px;
    box-shadow: 0 4px 12px rgba(0, 120, 200, 0.40), inset 0 1px 0 rgba(0, 210, 255, 0.25);
    border: 1px solid rgba(0, 210, 255, 0.22);
    transition: transform 0.25s ease, background 0.25s ease, box-shadow 0.25s ease;
}
.mega-link:hover .mega-link-icon {
    transform: scale(1.1) rotate(-4deg);
    background: linear-gradient(135deg, #0a5090 0%, #0090d4 100%);
    box-shadow: 0 4px 16px rgba(0, 180, 255, 0.55), 0 0 24px rgba(0, 210, 255, 0.25);
}

/* Text body */
.mega-link-body {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
}
.mega-link-body strong {
    font-size: 13px;
    font-weight: 700;
    color: #c8d8ea;
    font-family: 'Merriweather', serif;
    line-height: 1.3;
    display: block;
}
.mega-link-body span {
    font-size: 11px;
    color: #5a7a9a;
    font-family: 'Merriweather Sans', sans-serif;
    line-height: 1.4;
    font-weight: 400;
}

/* Mobile-only plain list — hidden on desktop */
.mobile-only-list {
    display: none !important;
}

/* ============================================================
   ANIMATIONS
   ============================================================ */
@keyframes fadeSlideDown {
    from { opacity: 0; transform: translateX(-50%) translateY(-8px); }
    to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* ============================================================
   ACTIVE DROPDOWN (mobile toggled)
   ============================================================ */
ul.grt-menu li.grt-dropdown.active-dropdown > a {
    color: #00d2ff;
}

/* ============================================================
   RESPONSIVE — TABLET (768–991)
   ============================================================ */
@media (min-width: 768px) and (max-width: 991px) {
    ul.grt-menu > li > a {
        font-size: 14px;
        padding: 8px 9px;
    }
    .mega-panel { min-width: 400px; }
    .mega-panel-inner { grid-template-columns: repeat(2, 1fr); }
    /* Keep AI icon color on tablet */
    .mega-link-icon { color: #00d2ff; }
}

/* ============================================================
   RESPONSIVE — MOBILE (≤ 767px)
   ============================================================ */
@media (max-width: 767px) {

    .grt-mobile-button { display: block; }

    ul.grt-menu {
        display: none;
        flex-direction: column;
        align-items: stretch;
        gap: 0;
    }

    ul.grt-menu.open-grt-menu {
        display: flex;
        position: fixed;
        inset: 0;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: #060f1e;
        background-image: radial-gradient(circle, rgba(82,138,200,0.18) 1px, transparent 1px);
        background-size: 24px 24px;
        z-index: 100000;        /* must beat header (9999) and banner stacking contexts */
        overflow-y: auto;
        overflow-x: hidden;
        justify-content: center;
        padding: 70px 20px 40px;
        animation: fadeIn 0.3s ease;
    }

    ul.grt-menu > li {
        display: block;
        width: 100%;
        text-align: center;
    }

    ul.grt-menu > li > a {
        font-size: 17px;
        padding: 13px 16px;
        justify-content: center;
        border-radius: 8px;
        color: #ffffff;
        border-bottom: 1px solid rgba(82, 138, 200, 0.12);
    }
    ul.grt-menu > li > a:hover,
    ul.grt-menu > li > a:active {
        color: #f69221;
        background: rgba(246, 146, 33, 0.10);
    }
    /* Icons in mobile nav */
    ul.grt-menu > li > a .nav-icon {
        font-size: 16px;
    }

    /* Active dropdown parent highlight */
    ul.grt-menu li.grt-dropdown.active-dropdown > a {
        color: #00d2ff;
        background: rgba(0, 210, 255, 0.08);
        border-radius: 8px 8px 0 0;
    }

    /* Hide desktop mega panel on mobile */
    .mega-panel { display: none !important; }

    /* Show mobile list instead */
    .mobile-only-list {
        display: block !important;
        position: static !important;
        box-shadow: none !important;
        border: none !important;
        border-radius: 0 !important;
        animation: none !important;
        background: transparent !important;
        padding: 4px 8px 8px !important;
        margin: 0 !important;
    }

    .mobile-only-list li { display: block; padding: 0; }
    .mobile-only-list li a {
        display: block;
        padding: 10px 20px;
        font-size: 14px;
        color: #00d2ff !important;
        text-transform: none;
        font-family: 'Merriweather', serif;
        background: rgba(0, 210, 255, 0.07);
        border: 1px solid rgba(0, 210, 255, 0.12);
        border-radius: 6px;
        margin: 4px 0;
        text-decoration: none;
        transition: background 0.2s ease, border-color 0.2s ease;
    }
    .mobile-only-list li a:hover,
    .mobile-only-list li a:active {
        background: rgba(0, 210, 255, 0.15) !important;
        border-color: rgba(0, 210, 255, 0.35) !important;
        color: #fff !important;
    }

    /* Hidden by default on mobile, shown when parent is active */
    ul.grt-menu li.grt-dropdown:not(.active-dropdown) .mobile-only-list {
        display: none !important;
    }
    ul.grt-menu li.grt-dropdown.active-dropdown .mobile-only-list {
        display: block !important;
    }

    .grt-mobile-button-open {
        position: fixed;
        top: 18px;
        right: 18px;
        z-index: 100001;        /* above the mobile overlay */
    }
}
