/**
 * Mobile Menu Styles - Topbar + Slide-in Panel
 * EyePress - Accessible Mobile Navigation
 *
 * @package EyePress
 */

/* ========================================
   Mobile Menu Bar (Topbar)
   ======================================== */
.mobile-menu-bar {
    display: none;
    background: #003663;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15);
    position: fixed;
    width: 100%;
    top: 0;
    left: 0;
    z-index: 100000;
}

/* Smooth transition for scroll state */
.mobile-menu-bar {
    transition: top 0.3s ease, box-shadow 0.3s ease;
}

/* Scrolling state */
.mobile-menu-bar.scrolling {
    top: 0;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
}

/* Admin bar offset for sticky mobile topbar */
.admin-bar .mobile-menu-bar {
    top: 32px;
}

.admin-bar .mobile-menu-bar.scrolling {
    top: 0;
}

@media screen and (max-width: 600px) {

    .admin-bar .mobile-menu-bar,
    .admin-bar .mobile-menu-panel {
        top: 46px;
    }
}

/* Mobile Topbar: Logo + Hamburger */
.mobile-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 0;
    gap: 12px;
}

.mobile-topbar-logo {
    flex: 1;
    min-width: 0;
}

.mobile-topbar-logo a {
    display: inline-flex;
    align-items: center;
    text-decoration: none;
}

.mobile-topbar-logo img {
    max-height: 40px;
    width: auto;
    display: block;
}

.mobile-topbar-logo .mobile-site-title {
    color: #fff;
    font-size: 18px;
    font-weight: 700;
    text-decoration: none;
    line-height: 1.3;
    letter-spacing: 0.5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mobile-topbar-logo .mobile-site-title:hover,
.mobile-topbar-logo .mobile-site-title:focus {
    color: rgba(255, 255, 255, 0.85);
    text-decoration: none;
}

.mobile-topbar-logo .custom-logo-link {
    display: inline-flex;
}

.mobile-topbar-logo .custom-logo {
    max-height: 40px;
    width: auto;
}

/* ========================================
   Mobile Menu Hamburger Button
   ======================================== */
.mobile-menu-bar .menu-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    background: rgba(255, 255, 255, 0.15);
    border: none;
    border-radius: 6px;
    padding: 8px;
    color: #fff;
    cursor: pointer;
    transition: background 0.25s ease;
    min-width: 44px;
    min-height: 44px;
    position: relative;
}

.mobile-menu-bar .menu-btn:hover {
    background: rgba(255, 255, 255, 0.25);
}

.mobile-menu-bar .menu-btn:focus {
    outline: 2px solid #fff;
    outline-offset: 2px;
    background: rgba(255, 255, 255, 0.25);
}

.mobile-menu-bar .menu-btn:focus:not(:focus-visible) {
    outline: none;
}

.mobile-menu-bar .menu-btn:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 2px;
}

.mobile-menu-bar .menu-btn:active {
    background: rgba(255, 255, 255, 0.35);
}

/* SVG Icon Styles */
.menu-btn .hamburger-icon,
.menu-btn .close-icon {
    width: 26px;
    height: 26px;
    transition: transform 0.4s cubic-bezier(0.68, -0.35, 0.265, 1.35), opacity 0.25s ease;
    transform-origin: center;
}

/* Hamburger → X morph animation */
.mobile-menu-bar.menu-open .menu-btn .close-icon {
    animation: iconSpinIn 0.4s cubic-bezier(0.68, -0.35, 0.265, 1.35) forwards;
}

@keyframes iconSpinIn {
    0% { transform: rotate(-90deg) scale(0.5); opacity: 0; }
    100% { transform: rotate(0) scale(1); opacity: 1; }
}

/* Screen Reader Only Text */
.mobile-menu-bar .sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Icon State Management */
.menu-btn .mopen,
.menu-btn .mclose {
    display: flex;
    align-items: center;
    justify-content: center;
}

.menu-btn .mclose {
    display: none;
}

/* Active State - Toggle icons */
.mobile-menu-bar.menu-open .menu-btn .mopen {
    display: none;
}

.mobile-menu-bar.menu-open .menu-btn .mclose {
    display: flex;
}

/* ========================================
   Overlay
   ======================================== */
.mobile-menu-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.55);
    z-index: 100001;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.4s cubic-bezier(0.4, 0, 0.2, 1), visibility 0s 0.4s,
        backdrop-filter 0.4s ease, -webkit-backdrop-filter 0.4s ease;
    backdrop-filter: blur(0px);
    -webkit-backdrop-filter: blur(0px);
}

.mobile-menu-overlay.active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    transition: opacity 0.4s cubic-bezier(0.4, 0, 0.2, 1), visibility 0s 0s,
        backdrop-filter 0.4s ease, -webkit-backdrop-filter 0.4s ease;
}

/* ========================================
   Slide-in Menu Panel
   ======================================== */
.mobile-menu-panel {
    position: fixed;
    top: 0;
    left: 0;
    width: 300px;
    max-width: 85vw;
    height: 100vh;
    height: 100dvh;
    background: #fff;
    z-index: 999999;
    overflow-y: auto;
    overflow-x: hidden;
    box-shadow: 4px 0 25px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    transform: translateX(-105%);
    visibility: hidden;
    transition: transform 0.45s cubic-bezier(0.23, 1, 0.32, 1), visibility 0s 0.45s,
        box-shadow 0.45s ease;
}

.admin-bar .mobile-menu-panel {
    top: 32px;
    height: calc(100vh - 32px);
    height: calc(100dvh - 32px);
}

@media screen and (max-width: 782px) {
    .admin-bar .mobile-menu-panel {
        top: 46px;
        height: calc(100vh - 46px);
        height: calc(100dvh - 46px);
    }
}

.mobile-menu-panel.panel-open {
    transform: translateX(0);
    visibility: visible;
    box-shadow: 4px 0 40px rgba(0, 0, 0, 0.3);
    transition: transform 0.45s cubic-bezier(0.23, 1, 0.32, 1), visibility 0s 0s,
        box-shadow 0.45s ease;
}

/* ========================================
   Panel Header: Logo + Close
   ======================================== */
.mobile-panel-header {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding: 14px 16px;
    background: #003663;
    flex-shrink: 0;
    gap: 10px;
    opacity: 0;
    transform: translateY(-10px);
    transition: opacity 0.3s ease, transform 0.3s ease;
    transition-delay: 0s;
}

.mobile-panel-header .mobile-panel-logo {
    display: none;
}

.mobile-menu-panel.panel-open .mobile-panel-header {
    opacity: 1;
    transform: translateY(0);
    transition-delay: 0.15s;
}

.mobile-panel-logo {
    flex: 1;
    min-width: 0;
}

.mobile-panel-logo img {
    max-height: 36px;
    width: auto;
    display: block;
}

.mobile-panel-logo .custom-logo-link {
    display: inline-flex;
}

.mobile-panel-logo .custom-logo {
    max-height: 36px;
    width: auto;
}

.mobile-panel-logo .mobile-site-title {
    color: #fff;
    font-size: 16px;
    font-weight: 700;
    text-decoration: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    letter-spacing: 0.3px;
}

.mobile-panel-logo .mobile-site-title:hover,
.mobile-panel-logo .mobile-site-title:focus {
    color: rgba(255, 255, 255, 0.85);
    text-decoration: none;
}

/* ========================================
   Close Button in Panel
   ======================================== */
.menu-close-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    background: rgba(255, 255, 255, 0.15);
    border: none;
    border-radius: 50%;
    padding: 6px;
    color: #fff;
    cursor: pointer;
    transition: background 0.25s ease, transform 0.25s ease;
    min-width: 38px;
    min-height: 38px;
    width: 38px;
    height: 38px;
}

.menu-close-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: rotate(90deg) scale(1.1);
}

.mobile-menu-panel.panel-open .menu-close-btn {
    animation: closeBtnSpinIn 0.5s cubic-bezier(0.68, -0.35, 0.265, 1.35) 0.25s both;
}

@keyframes closeBtnSpinIn {
    0% { transform: rotate(-180deg) scale(0); opacity: 0; }
    100% { transform: rotate(0) scale(1); opacity: 1; }
}

.menu-close-btn:focus {
    outline: 2px solid #fff;
    outline-offset: 2px;
    background: rgba(255, 255, 255, 0.3);
}

.menu-close-btn:focus:not(:focus-visible) {
    outline: none;
}

.menu-close-btn:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 2px;
}

.menu-close-btn svg {
    width: 20px;
    height: 20px;
}

/* ========================================
   Navigation inside Panel
   ======================================== */
.mobile-menu-panel .mobile-navigation {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 20px;
}

/* Body scroll lock when menu is open */
body.mobile-menu-is-open {
    overflow: hidden;
}

/* ========================================
   Dropdown Toggle Button (injected via JS)
   ======================================== */
.mobile-menu-panel .submenu-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 48px;
    min-height: 48px;
    background: none;
    border: none;
    border-left: 1px solid #eee;
    color: #666;
    cursor: pointer;
    padding: 0;
    transition: background 0.2s ease, color 0.2s ease;
}

.mobile-menu-panel .submenu-toggle:hover {
    background: #f0f0f0;
    color: #003663;
}

.mobile-menu-panel .submenu-toggle:focus {
    outline: 2px solid #003663;
    outline-offset: -2px;
    background: #f0f0f0;
    color: #003663;
}

.mobile-menu-panel .submenu-toggle:focus:not(:focus-visible) {
    outline: none;
}

.mobile-menu-panel .submenu-toggle:focus-visible {
    outline: 2px solid #003663;
    outline-offset: -2px;
}

/* Chevron icon */
.mobile-menu-panel .submenu-toggle .toggle-icon {
    width: 18px;
    height: 18px;
    transition: transform 0.35s cubic-bezier(0.68, -0.35, 0.265, 1.35);
    pointer-events: none;
}

/* Rotate chevron when submenu is open */
.mobile-menu-panel .menu-item-has-children.submenu-open>.submenu-toggle .toggle-icon,
.mobile-menu-panel .page_item_has_children.submenu-open>.submenu-toggle .toggle-icon {
    transform: rotate(180deg);
}

.mobile-menu-panel .menu-item-has-children.submenu-open>.submenu-toggle,
.mobile-menu-panel .page_item_has_children.submenu-open>.submenu-toggle {
    background: #f0f0f0;
    color: #003663;
}

/* ========================================
   Responsive: Show Mobile Menu
   ======================================== */
@media screen and (max-width: 991px) {

    .mobile-menu-bar {
        display: block;
        padding: 0;
    }

    /* Menu Items inside Panel */
    .mobile-menu-panel .wsm-menu-has {
        list-style: none;
        margin: 0;
        padding: 0;
        overflow: hidden;
    }

    .mobile-menu-panel .wsm-menu-has>li {
        border-bottom: 1px solid #eee;
    }

    .mobile-menu-panel .wsm-menu-has>li:last-child {
        border-bottom: none;
    }

    /* Menu item row */
    .mobile-menu-panel .wsm-menu-has li {
        position: relative;
        float: none;
        margin: 0;
        width: 100%;
        display: flex;
        justify-content: space-between;
    }

    .mobile-menu-panel .wsm-menu-has a {
        display: block;
        padding: 13px 16px;
        color: #333;
        text-decoration: none;
        font-weight: 500;
        font-size: 15px;
        line-height: 1.4;
        transition: background 0.2s ease, color 0.2s ease, padding-left 0.2s ease;
        position: relative;
        text-align: left;
    }

    /* Active hover indicator bar */
    .mobile-menu-panel .wsm-menu-has>li>a::after {
        content: '';
        position: absolute;
        left: 0;
        top: 0;
        bottom: 0;
        width: 3px;
        background: #003663;
        transform: scaleY(0);
        transition: transform 0.25s cubic-bezier(0.23, 1, 0.32, 1);
        border-radius: 0 3px 3px 0;
    }

    .mobile-menu-panel .wsm-menu-has>li>a:hover::after,
    .mobile-menu-panel .wsm-menu-has>li>a:focus::after {
        transform: scaleY(1);
    }

    .mobile-menu-panel .wsm-menu-has>li>a:hover {
        padding-left: 22px;
    }

    .mobile-menu-panel .wsm-menu-has a:hover,
    .mobile-menu-panel .wsm-menu-has a:focus {
        background: #f5f5f5;
        color: #003663;
    }

    .mobile-menu-panel .wsm-menu-has a:focus {
        outline: 2px solid #003663;
        outline-offset: -2px;
    }

    .mobile-menu-panel .wsm-menu-has a:focus:not(:focus-visible) {
        outline: none;
    }

    .mobile-menu-panel .wsm-menu-has a:focus-visible {
        outline: 2px solid #003663;
        outline-offset: -2px;
        background: #f0f8ff;
    }

    /* Parent items with children: flex row for link + toggle */
    .mobile-menu-panel .menu-item-has-children,
    .mobile-menu-panel .page_item_has_children {
        display: flex;
        flex-wrap: wrap;
        align-items: stretch;
    }

    .mobile-menu-panel .menu-item-has-children>a,
    .mobile-menu-panel .page_item_has_children>a {
        flex: 1;
        min-width: 0;
    }

    /* Sub-menu: full width below parent, animated */
    .mobile-menu-panel .wsm-menu-has .sub-menu {
        width: 100%;
        margin: 0;
        padding: 0;
        list-style: none;
        background: #fafafa;
        overflow: hidden;
        max-height: 0;
        opacity: 0;
        transition: max-height 0.4s cubic-bezier(0.23, 1, 0.32, 1),
            opacity 0.3s ease;
    }

    /* Open submenu */
    .mobile-menu-panel .menu-item-has-children.submenu-open>.sub-menu,
    .mobile-menu-panel .page_item_has_children.submenu-open>.sub-menu {
        max-height: 2000px;
        opacity: 1;
    }

    /* Submenu items stagger entrance */
    .mobile-menu-panel .submenu-open>.sub-menu>li {
        animation: submenuItemSlide 0.3s cubic-bezier(0.23, 1, 0.32, 1) both;
    }

    .mobile-menu-panel .submenu-open>.sub-menu>li:nth-child(1) { animation-delay: 0.03s; }
    .mobile-menu-panel .submenu-open>.sub-menu>li:nth-child(2) { animation-delay: 0.06s; }
    .mobile-menu-panel .submenu-open>.sub-menu>li:nth-child(3) { animation-delay: 0.09s; }
    .mobile-menu-panel .submenu-open>.sub-menu>li:nth-child(4) { animation-delay: 0.12s; }
    .mobile-menu-panel .submenu-open>.sub-menu>li:nth-child(5) { animation-delay: 0.15s; }
    .mobile-menu-panel .submenu-open>.sub-menu>li:nth-child(6) { animation-delay: 0.18s; }
    .mobile-menu-panel .submenu-open>.sub-menu>li:nth-child(7) { animation-delay: 0.21s; }
    .mobile-menu-panel .submenu-open>.sub-menu>li:nth-child(8) { animation-delay: 0.24s; }

    @keyframes submenuItemSlide {
        0% { opacity: 0; transform: translateX(-12px); }
        100% { opacity: 1; transform: translateX(0); }
    }

    .mobile-menu-panel .wsm-menu-has .sub-menu li {
        border-bottom: none;
        border-top: 1px solid #eee;
    }

    .mobile-menu-panel .wsm-menu-has .sub-menu a {
        padding: 11px 16px 11px 32px;
        font-size: 14px;
        color: #555;
        font-weight: 400;
        position: relative;
    }

    .mobile-menu-panel .wsm-menu-has .sub-menu a::before {
        content: '';
        position: absolute;
        left: 16px;
        top: 50%;
        transform: translateY(-50%) scale(1);
        width: 6px;
        height: 6px;
        border-radius: 50%;
        background: #ccc;
        transition: background 0.2s ease, transform 0.25s cubic-bezier(0.68, -0.35, 0.265, 1.35);
    }

    .mobile-menu-panel .wsm-menu-has .sub-menu a:hover::before,
    .mobile-menu-panel .wsm-menu-has .sub-menu a:focus::before {
        transform: translateY(-50%) scale(1.5);
        background: #003663;
    }

    .mobile-menu-panel .wsm-menu-has .sub-menu a:hover,
    .mobile-menu-panel .wsm-menu-has .sub-menu a:focus {
        background: #f0f0f0;
        color: #003663;
    }

    /* Nested sub-menu (3rd level) */
    .mobile-menu-panel .wsm-menu-has .sub-menu .sub-menu {
        background: #f5f5f5;
    }

    .mobile-menu-panel .wsm-menu-has .sub-menu .sub-menu a {
        padding-left: 48px;
        font-size: 13px;
    }

    .mobile-menu-panel .wsm-menu-has .sub-menu .sub-menu a::before {
        left: 32px;
        width: 5px;
        height: 5px;
        background: #ddd;
    }

    /* Mobile Panel Navigation List */
    .mobile-menu-panel .mobile-navigation ul {
        list-style: none;
    }

    .mobile-menu-panel .menu-item-has-children .sub-menu,
    .mobile-menu-panel .page_item_has_children .sub-menu {
        display: block;
    }

    /* High Contrast Mode Support */
    @media (prefers-contrast: high) {

        .mobile-menu-bar .menu-btn,
        .menu-close-btn {
            border: 2px solid #fff;
        }

        .mobile-menu-panel .wsm-menu-has a:focus {
            outline-width: 3px;
            background: #fff !important;
            color: #000 !important;
        }

        .mobile-menu-panel .submenu-toggle:focus {
            outline-width: 3px;
        }
    }

    /* Reduced Motion Support */
    @media (prefers-reduced-motion: reduce) {

        .mobile-menu-panel,
        .mobile-menu-overlay,
        .mobile-menu-bar .menu-btn,
        .menu-close-btn,
        .mobile-menu-panel .wsm-menu-has a,
        .mobile-menu-panel .wsm-menu-has .sub-menu,
        .mobile-menu-panel .submenu-toggle .toggle-icon,
        .mobile-panel-header,
        .mobile-menu-panel .wsm-menu-has>li,
        .mobile-menu-panel .submenu-open>.sub-menu>li {
            transition: none !important;
            animation: none !important;
        }

        .mobile-menu-panel.panel-open .menu-close-btn,
        .mobile-menu-bar.menu-open .menu-btn .close-icon {
            animation: none !important;
        }

        .mobile-menu-panel.panel-open .mobile-panel-header {
            opacity: 1;
            transform: none;
        }
    }

    /* Focus-visible support */
    .mobile-menu-panel a:focus-visible,
    .mobile-menu-panel button:focus-visible {
        outline: 2px solid #003663;
        outline-offset: -2px;
        z-index: 1;
        position: relative;
    }
}

/* ========================================
   Smaller Screens
   ======================================== */
@media (max-width: 767px) {
    .mobile-menu-panel {
        max-width: 90vw;
    }
}

@media (max-width: 480px) {
    .mobile-menu-panel {
        max-width: 95vw;
    }
}

/* ========================================
   Staggered Menu Item Entrance
   ======================================== */
.mobile-menu-panel .wsm-menu-has>li {
    opacity: 0;
    transform: translateX(-20px);
    transition: opacity 0.35s ease, transform 0.35s cubic-bezier(0.23, 1, 0.32, 1);
}

.mobile-menu-panel.panel-open .wsm-menu-has>li {
    opacity: 1;
    transform: translateX(0);
}

.mobile-menu-panel.panel-open .wsm-menu-has>li:nth-child(1) { transition-delay: 0.15s; }
.mobile-menu-panel.panel-open .wsm-menu-has>li:nth-child(2) { transition-delay: 0.19s; }
.mobile-menu-panel.panel-open .wsm-menu-has>li:nth-child(3) { transition-delay: 0.23s; }
.mobile-menu-panel.panel-open .wsm-menu-has>li:nth-child(4) { transition-delay: 0.27s; }
.mobile-menu-panel.panel-open .wsm-menu-has>li:nth-child(5) { transition-delay: 0.31s; }
.mobile-menu-panel.panel-open .wsm-menu-has>li:nth-child(6) { transition-delay: 0.35s; }
.mobile-menu-panel.panel-open .wsm-menu-has>li:nth-child(7) { transition-delay: 0.39s; }
.mobile-menu-panel.panel-open .wsm-menu-has>li:nth-child(8) { transition-delay: 0.43s; }
.mobile-menu-panel.panel-open .wsm-menu-has>li:nth-child(9) { transition-delay: 0.47s; }
.mobile-menu-panel.panel-open .wsm-menu-has>li:nth-child(10) { transition-delay: 0.51s; }
.mobile-menu-panel.panel-open .wsm-menu-has>li:nth-child(n+11) { transition-delay: 0.55s; }

/* ========================================
   Print Styles
   ======================================== */
@media print {

    .mobile-menu-bar,
    .mobile-menu-panel,
    .mobile-menu-overlay {
        display: none !important;
    }
}
