/* ── Mega Menu Architecture ── */

/* Container for all nav links */
#mega-menu {
    position: relative;
    display: flex;
    align-items: center;
    height: 100%;
    /* Keep dropdown on top */
    z-index: 100;
}

.nav-item {
    position: relative;
    height: 100%;
    display: flex;
    align-items: center;
    z-index: 1; /* base stacking context */
}

/* Elevate stacking context when hovered so the dropdown appears above adjacent nav items */
.nav-item:hover {
    z-index: 10;
}

.nav-trigger {
    height: 100%;
    display: flex;
    align-items: center;
    cursor: pointer;
    background: none;
    border: none;
    font-size: var(--fs-body);
    color: var(--text-muted);
    text-decoration: none;
    transition: color 0.2s ease, text-shadow 0.2s ease;
    /* Required for calculating background position accurately */
    position: relative;
    z-index: 2;
}

/* Maintain bright white state when mouse moves inside the dropdown box */
.nav-item:hover .nav-trigger,
.nav-item.active .nav-trigger {
    color: #ffffff !important;
    text-shadow: 0 0 16px rgba(96, 165, 250, 0.45);
}

/* Expand the blue underline when mouse moves inside the dropdown box */
.nav-item:hover .nav-trigger::after,
.nav-item.active .nav-trigger::after {
    transform: scaleX(1);
}

/* Route-active state, rendered server-side by is_active_nav().
   Deliberately keyed off the anchor rather than .nav-item: the hover script
   owns .active on the wrapper and strips it on mouseout, which would erase
   the current-page marker the moment the visitor moved the mouse. A parent
   counts as active when the current page is any of its dropdown
   destinations, so /review-fix lights up Products. */
.nav-trigger.active {
    color: #ffffff;
}

.nav-trigger.active::after {
    transform: scaleX(1);
}

/* ── The Morphing Background Box ── */
.mega-bg {
    position: absolute;
    top: 60px; /* Adjust based on navbar height to sit below it */
    left: 0;
    background: rgba(10, 10, 15, 0.95);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    box-shadow: 0 50px 100px -20px rgba(0, 0, 0, 0.5), 0 30px 60px -30px rgba(0, 0, 0, 0.3);
    
    /* Default hidden state */
    opacity: 0;
    pointer-events: none;
    
    /* Transitions for width, height, and translation */
    transition: width 0.3s ease, height 0.3s ease, transform 0.3s ease, opacity 0.2s ease;
    
    /* Will be overwritten by JS inline styles */
    width: 0;
    height: 0;
    transform: translateX(0);
    transform-origin: top left;
    z-index: 1;
}

.mega-bg.open {
    opacity: 1;
    pointer-events: auto;
}

/* ── The Content inside the Dropdown ── */
.mega-content {
    position: absolute;
    top: 60px; /* Same as background */
    left: 50%;
    transform: translateX(-50%);
    
    /* Let JS handle the width/height to match bg, or let content dictate it */
    width: max-content;
    padding: 32px;
    
    /* Start hidden */
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.2s ease, visibility 0.2s;
    
    z-index: 2;
}

.nav-item.active .mega-content {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    /* Slight delay so background has time to slide before new content appears */
    transition: opacity 0.3s ease 0.1s, visibility 0s;
}

/* ── Grid Layouts for Content ── */
.mega-grid {
    display: flex;
    gap: 32px;
}

.mega-columns {
    display: flex;
    gap: 32px;
}

.mega-col {
    display: flex;
    flex-direction: column;
    min-width: 220px;
}

.mega-col-title {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin-bottom: 16px;
    font-weight: 600;
}

.mega-link-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.mega-link {
    display: flex;
    flex-direction: column;
    text-decoration: none;
    transition: transform 0.2s ease;
}

/* Reset .site-nav .nav-links a styles that leak into the mega menu */
.site-nav .nav-links .mega-content a {
    color: inherit !important;
    text-shadow: none !important;
}
.site-nav .nav-links .mega-content a::after {
    display: none !important;
}

.mega-link:hover {
    transform: translateX(4px);
}

.mega-link-title {
    font-size: 14px;
    color: var(--text-strong);
    font-weight: 500;
    margin-bottom: 2px;
}

.mega-link-subtitle {
    font-size: 13px;
    color: var(--text-muted);
}

.mega-link:hover .mega-link-title {
    color: var(--accent); /* blue/indigo highlight */
}

/* ── Promo Card ── */
.mega-promo {
    width: 260px;
    border-left: 1px solid rgba(255, 255, 255, 0.05);
    padding-left: 32px;
}

.mega-promo-link {
    display: flex;
    flex-direction: column;
    gap: 12px;
    text-decoration: none;
    border-radius: 8px;
    overflow: hidden;
    transition: opacity 0.2s ease;
}

.mega-promo-link:hover {
    opacity: 0.8;
}

.mega-promo-img {
    width: 100%;
    height: 140px;
    object-fit: cover;
    border-radius: 6px;
}

.mega-promo-text {
    display: flex;
    flex-direction: column;
}

.mega-promo-title {
    font-size: 14px;
    color: var(--text-strong);
    font-weight: 500;
    margin-bottom: 4px;
}

.mega-promo-desc {
    font-size: 13px;
    color: var(--text-muted);
    line-height: 1.4;
}

/* ── Mobile drawer: mega-menu children ──────────────────────────────────
   The drawer renders a dropdown parent as a heading and its children as an
   indented list, so the capabilities reachable from the desktop mega-menu
   are reachable on a phone too. Without this the parent was a link with no
   destination and the children did not render at all. */
.drawer-sublinks {
    gap: 10px;
    margin: 4px 0 8px 14px;
    padding-left: 12px;
    border-left: 1px solid rgba(255, 255, 255, 0.12);
}

.drawer-sublink {
    display: block;
    font-size: 0.95rem;
    line-height: 1.5;
    text-decoration: none;
}

.drawer-sublink:hover,
.drawer-sublink:focus-visible {
    color: var(--text-strong, #fff);
}
