/* ==========================================================================
   Elementor Drilldown Mobile Menu v1.7.0
   Author: Agencia SEO Orbitalia — orbitalia.com

   All rules scoped under .drilldown-active — zero desktop impact.

   Structure (Elementor nav-menu widget):
   ┌ div.elementor-widget-nav-menu  ← $widget (.drilldown-active added here)
   │  ├ nav.elementor-nav-menu--main  ← desktop nav (hidden on mobile)
   │  ├ div.elementor-menu-toggle     ← hamburger button
   │  └ nav.elementor-nav-menu--dropdown  ← MOBILE dropdown container
   │     └ ul.elementor-nav-menu        ← root UL (Level 0)
   │        ├ li.menu-item > a
   │        └ li.menu-item-has-children > a
   │           └ ul.sub-menu            ← Level 1 (also has .elementor-nav-menu--dropdown!)
   │              └ li.menu-item-has-children > a
   │                 └ ul.sub-menu      ← Level 2+
   ========================================================================== */

/* ==========================================================================
   1. DROPDOWN NAV CONTAINER — override Elementor inline styles
   ========================================================================== */

.drilldown-active nav.elementor-nav-menu--dropdown {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100vw !important;
    max-width: 100vw !important;
    height: 100vh !important;
    height: 100dvh !important;
    max-height: none !important;
    /* Nav itself doesn't scroll — the root UL flex child handles scrolling */
    overflow: hidden !important;
    z-index: 9999 !important;
    display: flex !important;
    flex-direction: column !important;
    visibility: visible !important;
    opacity: 1 !important;
    pointer-events: auto !important;
    /* Reset Elementor's inline --menu-height */
    --menu-height: 100vh !important;
    /* Default dark bg — uses background-color (not shorthand) so Elementor's
       Group_Control_Background can override with background-color/background-image */
    background-color: #1a2332;
    background-image: none;
    color: #e8ecf1;
}

/* ==========================================================================
   2. ROOT UL (Level 0)
   ========================================================================== */

.drilldown-active nav.elementor-nav-menu--dropdown>ul.elementor-nav-menu {
    list-style: none !important;
    margin: 0 !important;
    padding: 0 !important;
    width: 100% !important;
    /* position:relative so sub-menus (position:absolute) are contained within this UL,
       which already sits below the logo/close thanks to the nav's flex layout */
    position: relative !important;
    flex: 1;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    /* Flex column so WPML switcher can use margin-top:auto to stick to bottom */
    display: flex !important;
    flex-direction: column !important;
}

/* ==========================================================================
   3. SUB-MENUS — hidden off-screen to the right
   ========================================================================== */

/* Sub-menus: hidden off-screen, positioned relative to the <nav> (fixed container).
   High specificity to beat Elementor's .elementor-nav-menu--dropdown styles on these ULs. */
.drilldown-active ul.sub-menu,
.drilldown-active ul.sub-menu.elementor-nav-menu--dropdown,
.drilldown-active nav.elementor-nav-menu--dropdown ul.sub-menu {
    list-style: none !important;
    margin: 0 !important;
    padding: 0 !important;
    /* Absolute inside the root UL (which is position:relative and sits below the logo).
       No JS-calculated offset needed — the root UL already starts after the logo. */
    position: absolute !important;
    top: 0 !important;
    left: -9999px !important;
    width: 100% !important;
    height: 100% !important;
    z-index: 10;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    -webkit-overflow-scrolling: touch !important;
    overscroll-behavior: contain !important;
    /* CRITICAL: override SmartMenus + Elementor */
    display: block !important;
    /* Hidden by default — drilldown-level-active brings it on screen */
    visibility: hidden !important;
    pointer-events: none !important;
    /* Default background — same as nav. Widget controls override via
       Elementor's generated CSS (selector targets both nav and ul.sub-menu) */
    background-color: #1a2332;
    background-image: none;
    color: #e8ecf1;
    /* Reset Elementor sub-menu styles */
    min-width: 0 !important;
    max-width: none !important;
    box-shadow: none !important;
    border: none !important;
    border-radius: 0 !important;
    right: auto !important;
    bottom: auto !important;
}

/* ==========================================================================
   4. ANIMATION CLASSES (fade-based, no lateral movement)
   ========================================================================== */

/* Parent level: hide when a sub-menu is active.
   CRITICAL constraints on this rule:
   - Do NOT use opacity:0 — compositing context makes ALL descendants invisible
   - Do NOT use height:0 + overflow:hidden — clips position:absolute sub-menu children
   - USE visibility:hidden — children CAN override with visibility:visible
   - USE pointer-events:none — prevents interaction with hidden items */
.drilldown-active .drilldown-slide-out-left {
    visibility: hidden !important;
    pointer-events: none !important;
}

/* Direct children <li> of the hidden level: fully collapse them so they don't
   take up space, but sub-menu <ul> children (position:absolute) remain unaffected */
.drilldown-active .drilldown-slide-out-left > li {
    height: 0 !important;
    overflow: hidden !important;
    border: none !important;
    padding: 0 !important;
    margin: 0 !important;
}

/* Active sub-menu: bring on-screen, instant show */
.drilldown-active ul.sub-menu.drilldown-level-active,
.drilldown-active ul.sub-menu.elementor-nav-menu--dropdown.drilldown-level-active,
.drilldown-active nav.elementor-nav-menu--dropdown ul.sub-menu.drilldown-level-active {
    left: 0 !important;
    visibility: visible !important;
    display: block !important;
    pointer-events: auto !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
    overscroll-behavior: contain !important;
    padding-bottom: 60px !important;
}

/* Going back: hide sub-menu instantly */
.drilldown-active ul.sub-menu.drilldown-slide-out-right {
    left: -9999px !important;
    visibility: hidden !important;
    pointer-events: none !important;
}

/* Parent level re-appearing after back */
.drilldown-active .drilldown-slide-in-left {
    visibility: visible !important;
    pointer-events: auto !important;
}

/* Restore <li> items of a level coming back into view */
.drilldown-active .drilldown-slide-in-left > li {
    height: auto !important;
    overflow: visible !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08) !important;
}

/* ==========================================================================
   5. MENU ITEMS — base styles for good touch targets
   ========================================================================== */

.drilldown-active nav.elementor-nav-menu--dropdown li {
    display: block !important;
    position: static !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    float: none !important;
    width: auto !important;
    /* Reset Elementor's default — NO !important so widget controls can override */
    background: none;
}

.drilldown-active nav.elementor-nav-menu--dropdown li>a {
    display: flex !important;
    align-items: center !important;
    justify-content: flex-start !important;
    min-height: 48px !important;
    /* Extra left padding so text aligns with back-link text (after chevron + gap) */
    padding: 14px 20px 14px 48px;
    text-decoration: none !important;
    color: inherit;
    box-sizing: border-box !important;
    font-size: 15px;
    line-height: 1.4;
    /* Reset Elementor's link styles — NO !important on overridable props */
    background: transparent;
    border: none;
    white-space: normal !important;
    -webkit-tap-highlight-color: rgba(255, 255, 255, 0.05);
    transition: background-color 0.15s ease;
}

.drilldown-active nav.elementor-nav-menu--dropdown li>a:hover,
.drilldown-active nav.elementor-nav-menu--dropdown li>a:focus {
    background-color: rgba(255, 255, 255, 0.06);
    outline: none;
}

.drilldown-active nav.elementor-nav-menu--dropdown li>a:active {
    background-color: rgba(255, 255, 255, 0.1);
}

/* Current/active page item — no !important so widget Active Item BG control wins */
.drilldown-active nav.elementor-nav-menu--dropdown li.current-menu-item>a,
.drilldown-active nav.elementor-nav-menu--dropdown li.current_page_item>a {
    background-color: rgba(59, 130, 246, 0.15);
    font-weight: 600;
}

/* ==========================================================================
   6. HIDE SmartMenus .sub-arrow (Elementor's chevron-down)
   ========================================================================== */

.drilldown-active span.sub-arrow {
    display: none !important;
}

/* ==========================================================================
   7. CSS CHEVRON FALLBACK (when no custom icons set)
   ========================================================================== */

/* Level 0: right chevron on parent items */
.drilldown-active li.menu-item-has-children>a::after {
    content: '';
    display: inline-block;
    width: 8px;
    height: 8px;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: rotate(-45deg);
    flex-shrink: 0;
    margin-left: auto;
    padding-left: 12px;
    opacity: 0.5;
}

/* Hide CSS fallback chevrons when custom icons exist */
.drilldown-active.drilldown-has-custom-icons li.menu-item-has-children>a::after {
    display: none !important;
}

.drilldown-active.drilldown-has-custom-icons .drilldown-chevron-back {
    display: none !important;
}

/* ==========================================================================
   8. CUSTOM ICONS
   ========================================================================== */

.drilldown-active .drilldown-custom-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    line-height: 1;
}

.drilldown-active .drilldown-custom-icon svg {
    fill: currentColor;
}

/* Submenu arrow & expand/collapse — pushed to the right */
.drilldown-active .drilldown-submenu-icon,
.drilldown-active .drilldown-expand-icon {
    margin-left: auto;
    padding-left: 12px;
    opacity: 0.6;
}

.drilldown-active .drilldown-back-icon {
    margin-right: 6px;
    opacity: 0.7;
}

/* ==========================================================================
   9. LOGO
   ========================================================================== */

.drilldown-active .drilldown-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 18px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    flex-shrink: 0;
}

.drilldown-active .drilldown-logo img {
    max-width: 70%;
    height: 40px;
    display: block;
    object-fit: contain;
}

/* ==========================================================================
   10. BACK BUTTON
   ========================================================================== */

.drilldown-active .drilldown-back {
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(0, 0, 0, 0.15) !important;
}

.drilldown-active .drilldown-back-link {
    display: flex !important;
    align-items: center !important;
    width: 100%;
    min-height: 48px !important;
    padding: 14px 20px;
    font-weight: 700;
    font-size: inherit;
    line-height: inherit;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    text-decoration: none !important;
    color: inherit;
    gap: 8px;
    transition: background-color 0.15s ease;
    /* Button reset (now <button> instead of <a> for SEO) */
    background: none;
    border: none;
    cursor: pointer;
    font-family: inherit;
    text-align: left;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

.drilldown-active .drilldown-back-link:hover,
.drilldown-active .drilldown-back-link:focus {
    background-color: rgba(0, 0, 0, 0.1);
}

.drilldown-active .drilldown-chevron-back {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-left: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: rotate(45deg);
    flex-shrink: 0;
}

/* "Visit parent" link (e.g. "All Diving Courses") */
.drilldown-active .drilldown-visit-parent>a {
    opacity: 0.85;
}

/* ==========================================================================
   11. CLOSE BUTTON
   ========================================================================== */

.drilldown-active .drilldown-close-btn {
    position: absolute;
    top: 14px;
    right: 14px;
    z-index: 10;
    background: none !important;
    border: none !important;
    color: inherit;
    font-size: 28px;
    line-height: 1;
    cursor: pointer;
    padding: 8px;
    opacity: 0.6;
    transition: opacity 0.15s ease;
    -webkit-tap-highlight-color: transparent;
}

.drilldown-active .drilldown-close-btn:hover,
.drilldown-active .drilldown-close-btn:focus {
    opacity: 1;
}

/* Hide Elementor's own toggle when drilldown is fullscreen */
.drilldown-active .elementor-menu-toggle {
    display: none !important;
}

/* ==========================================================================
   12. WPML LANGUAGE SWITCHER
   ========================================================================== */

.drilldown-active .drilldown-wpml-switcher {
    margin-top: auto !important;
    padding: 16px 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    border-bottom: none !important;
}

/* Reset WPML's own list styles inside the drilldown */
.drilldown-active .drilldown-wpml-switcher .wpml-ls ul {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    list-style: none;
    padding: 0;
    margin: 0;
}

.drilldown-active .drilldown-wpml-switcher .wpml-ls li {
    border-bottom: none !important;
    padding: 0;
}

.drilldown-active .drilldown-wpml-switcher .wpml-ls a {
    display: inline-flex !important;
    align-items: center;
    gap: 6px;
    padding: 6px 10px !important;
    min-height: auto !important;
    border-radius: 4px;
    opacity: 0.75;
    transition: opacity 0.15s ease;
}

.drilldown-active .drilldown-wpml-switcher .wpml-ls a:hover,
.drilldown-active .drilldown-wpml-switcher .wpml-ls a:focus {
    opacity: 1;
    background-color: rgba(255, 255, 255, 0.06);
}

.drilldown-active .drilldown-wpml-switcher .wpml-ls-flag {
    width: 20px;
    height: auto;
}

/* ==========================================================================
   13. BODY SCROLL LOCK
   ========================================================================== */

body.drilldown-menu-open {
    overflow: hidden !important;
}

/* ==========================================================================
   13. RTL SUPPORT
   ========================================================================== */

[dir="rtl"] .drilldown-active ul.sub-menu {
    left: auto !important;
    right: 100% !important;
}

[dir="rtl"] .drilldown-active ul.sub-menu.drilldown-level-active {
    right: 0 !important;
    left: auto !important;
}

[dir="rtl"] .drilldown-active ul.sub-menu.drilldown-slide-out-right {
    right: 100% !important;
    left: auto !important;
}

[dir="rtl"] .drilldown-active li.menu-item-has-children>a::after {
    transform: rotate(135deg);
    margin-left: 0;
    margin-right: auto;
    padding-left: 0;
    padding-right: 12px;
}

[dir="rtl"] .drilldown-active .drilldown-chevron-back {
    transform: rotate(-135deg);
}

[dir="rtl"] .drilldown-active .drilldown-submenu-icon,
[dir="rtl"] .drilldown-active .drilldown-expand-icon {
    margin-left: 0;
    margin-right: auto;
    padding-left: 0;
    padding-right: 12px;
}

[dir="rtl"] .drilldown-active .drilldown-back-icon {
    margin-right: 0;
    margin-left: 6px;
}

/* ==========================================================================
   14. DEBUG PANEL (on-screen overlay)
   ========================================================================== */

.drilldown-debug-panel {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 999999;
    background: rgba(15, 15, 25, 0.95);
    color: #d4d4d4;
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
    font-size: 11px;
    line-height: 1.5;
    border-top: 2px solid #3b82f6;
    max-height: 40vh;
    display: flex;
    flex-direction: column;
}

.drilldown-debug-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 10px;
    background: rgba(30, 30, 50, 0.95);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    flex-shrink: 0;
}

.drilldown-debug-title {
    font-weight: 700;
    color: #3b82f6;
    margin-right: auto;
}

.drilldown-debug-toggle,
.drilldown-debug-clear {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: #aaa;
    font-size: 10px;
    padding: 1px 8px;
    cursor: pointer;
    border-radius: 3px;
    font-family: inherit;
}

.drilldown-debug-toggle:hover,
.drilldown-debug-clear:hover {
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
}

.drilldown-debug-info {
    padding: 3px 10px;
    background: rgba(59, 130, 246, 0.1);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    flex-shrink: 0;
}

.drilldown-debug-sys {
    color: #60a5fa;
}

.drilldown-debug-log {
    overflow-y: auto;
    padding: 4px 0;
    flex: 1;
    min-height: 60px;
}

.drilldown-debug-line {
    padding: 2px 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    word-break: break-all;
}

.drilldown-debug-line:hover {
    background: rgba(255, 255, 255, 0.03);
}

.drilldown-debug-time {
    color: #666;
}

.drilldown-debug-type {
    font-weight: 600;
    min-width: 50px;
    display: inline-block;
}

.drilldown-debug-data {
    color: #888;
    font-size: 10px;
}

/* Log type colors */
.drilldown-debug-init .drilldown-debug-type {
    color: #a78bfa;
}

.drilldown-debug-info .drilldown-debug-type {
    color: #60a5fa;
}

.drilldown-debug-ok .drilldown-debug-type {
    color: #34d399;
}

.drilldown-debug-warn .drilldown-debug-type {
    color: #fbbf24;
}

.drilldown-debug-error .drilldown-debug-type {
    color: #f87171;
}

.drilldown-debug-event .drilldown-debug-type {
    color: #c084fc;
}

.drilldown-debug-minimized .drilldown-debug-info,
.drilldown-debug-minimized .drilldown-debug-log {
    display: none;
}

.drilldown-debug-minimized {
    max-height: none;
}