/* ═══════════════════════════════════════════════════════════════
   megamenu.css - Mega Menu & Mobile Navigation
   ═══════════════════════════════════════════════════════════════ */

/* ── Nav button base — always white text in the glassmorphism bar */
.mega-nav-btn,
.mega-nav-btn *,
#nav-bar nav a,
#mega-btn-mob,
#mega-btn-mob * {
    color: inherit;
}

/* ── Nav button active state (aria-expanded) ─────────────────── */
.mega-nav-btn[aria-expanded="true"] {
    background: rgba(255,255,255,0.18) !important;
}

/* ── Task 4: Prevent color flicker on click / focus / active ────
   All nav-links / buttons stay their themed color at all states.
   No flash-to-default-blue or colour jump on tap (mobile).
   ─────────────────────────────────────────────────────────────── */
.mega-nav-btn:focus,
.mega-nav-btn:active,
#nav-bar nav a:focus,
#nav-bar nav a:active {
    outline: none !important;
    box-shadow: none !important;
    -webkit-tap-highlight-color: transparent !important;
}

/* Mobile All-Tools button — keep white at all interaction states */
#mega-btn-mob:focus,
#mega-btn-mob:active,
#mega-btn-mob:focus *,
#mega-btn-mob:active * {
    outline: none !important;
    box-shadow: none !important;
    -webkit-tap-highlight-color: transparent !important;
}

/* Mobile toggle (hamburger) */
#mobile-toggle:focus,
#mobile-toggle:active {
    outline: none !important;
    box-shadow: none !important;
    -webkit-tap-highlight-color: transparent !important;
}

/* ── Mega Menu Panel ─────────────────────────────────────────── */
.mega-panel {
    pointer-events: none;
}
.mega-panel.is-open {
    pointer-events: auto;
}

/* ── Mega Tab active ─────────────────────────────────────────── */
.mega-tab {
    -webkit-tap-highlight-color: transparent;
    flex-shrink: 0;
}

/* ── CRITICAL: Desktop mega-menu is NEVER shown on mobile ────── */
@media (max-width: 1023px) {
    #mega-menu {
        display: none !important;
        opacity: 0 !important;
        pointer-events: none !important;
        visibility: hidden !important;
        transform: none !important;
    }
    #mega-backdrop {
        display: none !important;
    }
}

/* ═══════════════════════════════════════════════════════════════
   MOBILE MENU — Full-width slide-down accordion panel
   ═══════════════════════════════════════════════════════════════ */

.mobile-menu-panel {
    -webkit-overflow-scrolling: touch;
    /* max-height managed by JS; cap so it never exceeds viewport */
    max-height: calc(100dvh - 62px);
    overflow-y: auto;
}

/* Mobile menu container — full width, no floating */
#mobile-menu {
    background: #ffffff !important;
    border-top: 1px solid rgba(0, 0, 0, 0.08) !important;
    box-shadow:
        0 8px 32px rgba(0, 0, 0, 0.10),
        0 2px 8px rgba(0, 0, 0, 0.06) !important;
    /* Prevent any overflow that could clip content */
    overflow-y: auto !important;
    overflow-x: hidden !important;
    /* No border-radius — full-width panel look */
    border-radius: 0 !important;
}

/* ── Search bar ──────────────────────────────────────────────── */
#mobile-menu input[type="text"] {
    background: #f8f8f8 !important;
    border: 1px solid #e5e7eb !important;
    color: #1c1917 !important;
    border-radius: 12px !important;
}
#mobile-menu input[type="text"]::placeholder {
    color: #9ca3af !important;
}
#mobile-menu input[type="text"]:focus {
    border-color: #6366f1 !important;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.12) !important;
    outline: none;
}

/* ── Category accordion header buttons ──────────────────────── */
#mobile-menu .mob-acc-btn {
    color: #1c1917 !important;
    border-radius: 12px !important;
    transition: background 0.15s ease !important;
    -webkit-tap-highlight-color: transparent !important;
}
#mobile-menu .mob-acc-btn:hover,
#mobile-menu .mob-acc-btn:active {
    background: #f4f4f5 !important;
}
#mobile-menu .mob-acc-btn:focus {
    outline: none !important;
    box-shadow: none !important;
}
#mobile-menu .mob-acc-btn .text-stone-800 {
    color: #1c1917 !important;
    font-size: 0.875rem !important;
    font-weight: 600 !important;
}
#mobile-menu .mob-acc-btn .text-stone-400 {
    color: #9ca3af !important;
    background: #f4f4f5 !important;
    font-size: 0.7rem !important;
    border-radius: 999px !important;
    padding: 2px 6px !important;
}
#mobile-menu .mob-chevron {
    color: #d1d5db !important;
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1) !important;
}

/* ── Section dividers ────────────────────────────────────────── */
#mobile-menu .mobile-section {
    border-bottom: 1px solid #f3f4f6 !important;
}
#mobile-menu .mobile-section:last-child {
    border-bottom: none !important;
}

/* ── Accordion body ──────────────────────────────────────────── */
#mobile-menu .mob-body {
    overflow: hidden;
}

/* Tool grid: 1 col on tiny phones, 2 col on normal phones */
#mobile-menu .mob-body .grid {
    grid-template-columns: 1fr !important;
    gap: 2px !important;
    padding: 0 4px 8px !important;
}
@media (min-width: 380px) {
    #mobile-menu .mob-body .grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 3px !important;
    }
}

/* ── Individual tool link items ──────────────────────────────── */
#mobile-menu .mob-body a {
    display: flex !important;
    align-items: center !important;
    gap: 10px !important;
    padding: 10px 12px !important;
    border-radius: 10px !important;
    text-decoration: none !important;
    transition: background 0.12s ease !important;
    min-height: 44px !important;
    -webkit-tap-highlight-color: transparent !important;
}
#mobile-menu .mob-body a:hover,
#mobile-menu .mob-body a:active {
    background: #f4f4f5 !important;
}
#mobile-menu .mob-body a:focus {
    outline: none !important;
}
#mobile-menu .mob-body .text-xs,
#mobile-menu .mob-body .text-stone-600 {
    color: #374151 !important;
    font-size: 0.8rem !important;
    font-weight: 500 !important;
    line-height: 1.3 !important;
}

/* Tool icon containers */
#mobile-menu .mob-body .w-7 {
    width: 30px !important;
    height: 30px !important;
    border-radius: 8px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    flex-shrink: 0 !important;
}

/* ── Bottom nav links ────────────────────────────────────────── */
#mobile-menu .px-4.py-3.border-t {
    border-top: 1px solid #f3f4f6 !important;
}
#mobile-menu .px-4.py-3.border-t a {
    color: #374151 !important;
    font-weight: 500 !important;
    border-radius: 10px !important;
    padding: 10px 12px !important;
    transition: background 0.12s ease !important;
    display: flex;
    align-items: center;
    -webkit-tap-highlight-color: transparent !important;
}
#mobile-menu .px-4.py-3.border-t a:hover {
    background: #f4f4f5 !important;
    color: #111827 !important;
}
#mobile-menu .px-4.py-3.border-t a:focus,
#mobile-menu .px-4.py-3.border-t a:active {
    outline: none !important;
}

/* ── Active "All Tools" mobile button ────────────────────────── */
#mega-btn-mob.mob-active {
    background: rgba(99, 102, 241, 0.10) !important;
    color: rgba(255, 255, 255, 0.95) !important;
}

/* ── Accordion chevron rotation ──────────────────────────────── */
.mob-acc-btn[aria-expanded="true"] .mob-chevron {
    transform: rotate(180deg);
}

/* ── Backdrop blur for mega menu ─────────────────────────────── */
#mega-backdrop.is-visible {
    opacity: 1;
}

/* ── Smooth entry animation for mobile menu ──────────────────── */
@media (max-width: 1023px) {
    #mobile-menu {
        /* max-height animation handled by JS; add smooth transition */
        transition: max-height 0.35s cubic-bezier(0.4, 0, 0.2, 1) !important;
    }
}
