/**
 * Executive Mobile Menu — Styles
 * Premium corporate off-canvas navigation
 * 
 * All selectors are prefixed with .emm- to avoid conflicts.
 * Visible only below 1024px via media queries.
 */

/* ==========================================================================
   CSS Custom Properties (Defaults — overridden inline by PHP)
   ========================================================================== */
:root {
    --emm-accent: #1B5E20;
    --emm-accent-hover: #144316;
    --emm-bg: #ffffff;
    --emm-text: #1a1a2e;
    --emm-text-secondary: #555770;
    --emm-border: #e8e8ed;
    --emm-overlay-bg: rgba(15, 15, 30, 0.55);
    --emm-panel-width: 320px;
    --emm-transition-speed: 0.35s;
    --emm-transition-ease: cubic-bezier(0.4, 0, 0.2, 1);
    --emm-radius: 8px;
    --emm-radius-sm: 6px;
    --emm-font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --emm-z-hamburger: 99998;
    --emm-z-overlay: 99999;
    --emm-z-panel: 100000;
}

/* ==========================================================================
   Reset — Prevent theme bleed
   ========================================================================== */
.emm-panel,
.emm-panel *,
.emm-hamburger,
.emm-hamburger *,
.emm-overlay {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ==========================================================================
   Hide everything above breakpoint
   ========================================================================== */
.emm-hamburger,
.emm-overlay,
.emm-panel {
    display: none;
}

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

    .emm-hamburger,
    .emm-overlay,
    .emm-panel {
        display: block;
    }

    /* ==================================================================
       Hamburger Trigger Button
       ================================================================== */
    .emm-hamburger {
        position: fixed;
        top: 12px;
        right: 12px;
        z-index: var(--emm-z-hamburger);
        width: 44px;
        height: 44px;
        border-radius: var(--emm-radius);
        border: none;
        background: var(--emm-accent);
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
        cursor: pointer;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 5px;
        padding: 0;
        -webkit-tap-highlight-color: transparent;
        transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
        outline: none;
    }

    .emm-hamburger:hover,
    .emm-hamburger:focus-visible {
        box-shadow: 0 4px 16px rgba(0, 0, 0, 0.22);
    }

    .emm-hamburger:active {
        transform: scale(0.95);
    }

    .emm-hamburger__line {
        display: block;
        width: 20px;
        height: 2px;
        background: #ffffff;
        border-radius: 2px;
        transition: transform var(--emm-transition-speed) var(--emm-transition-ease),
                    opacity var(--emm-transition-speed) var(--emm-transition-ease);
        pointer-events: none;
    }

    /* Hamburger → X animation when open */
    .emm-hamburger.emm-is-active .emm-hamburger__line:nth-child(1) {
        transform: translateY(7px) rotate(45deg);
    }

    .emm-hamburger.emm-is-active .emm-hamburger__line:nth-child(2) {
        opacity: 0;
        transform: scaleX(0);
    }

    .emm-hamburger.emm-is-active .emm-hamburger__line:nth-child(3) {
        transform: translateY(-7px) rotate(-45deg);
    }

    /* ==================================================================
       Overlay
       ================================================================== */
    .emm-overlay {
        position: fixed;
        inset: 0;
        z-index: var(--emm-z-overlay);
        background: var(--emm-overlay-bg);
        opacity: 0;
        visibility: hidden;
        transition: opacity var(--emm-transition-speed) var(--emm-transition-ease),
                    visibility var(--emm-transition-speed) var(--emm-transition-ease);
        -webkit-backdrop-filter: blur(2px);
        backdrop-filter: blur(2px);
    }

    .emm-overlay.emm-is-visible {
        opacity: 1;
        visibility: visible;
    }

    /* ==================================================================
       Off-Canvas Panel
       ================================================================== */
    .emm-panel {
        position: fixed;
        top: 0;
        right: 0;
        bottom: 0;
        z-index: var(--emm-z-panel);
        width: var(--emm-panel-width);
        max-width: 88vw;
        height: 100%;
        height: 100dvh;
        background: var(--emm-bg);
        font-family: var(--emm-font-family);
        color: var(--emm-text);
        display: flex;
        flex-direction: column;
        transform: translateX(100%);
        transition: transform var(--emm-transition-speed) var(--emm-transition-ease);
        overflow: hidden;
        -webkit-overflow-scrolling: touch;
        box-shadow: -8px 0 40px rgba(0, 0, 0, 0.12);
    }

    .emm-panel.emm-is-open {
        transform: translateX(0);
    }

    /* ==================================================================
       Panel Header
       ================================================================== */
    .emm-panel__header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 18px 20px;
        border-bottom: 1px solid var(--emm-border);
        flex-shrink: 0;
        background: var(--emm-bg);
    }

    .emm-panel__brand {
        display: flex;
        align-items: center;
        gap: 12px;
        min-width: 0;
        flex: 1;
    }

    .emm-panel__logo {
        width: auto;
        height: 36px;
        max-width: 100px;
        object-fit: contain;
        flex-shrink: 0;
        border-radius: 4px;
    }

    .emm-panel__site-name {
        font-size: 15px;
        font-weight: 700;
        color: var(--emm-text);
        letter-spacing: -0.01em;
        line-height: 1.2;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .emm-panel__close {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 40px;
        height: 40px;
        border: none;
        border-radius: var(--emm-radius);
        background: #f3f3f6;
        color: var(--emm-text);
        cursor: pointer;
        flex-shrink: 0;
        transition: background 0.2s ease, color 0.2s ease;
        -webkit-tap-highlight-color: transparent;
        outline: none;
    }

    .emm-panel__close:hover,
    .emm-panel__close:focus-visible {
        background: #e4e4ea;
        color: var(--emm-accent);
    }

    .emm-panel__close:active {
        background: #d6d6dd;
    }

    /* ==================================================================
       Scrollable Content Area
       ================================================================== */
    .emm-panel__content {
        flex: 1;
        overflow-y: auto;
        overflow-x: hidden;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
        padding: 8px 0;
    }

    /* Custom scrollbar */
    .emm-panel__content::-webkit-scrollbar {
        width: 4px;
    }

    .emm-panel__content::-webkit-scrollbar-track {
        background: transparent;
    }

    .emm-panel__content::-webkit-scrollbar-thumb {
        background: #d1d1d8;
        border-radius: 4px;
    }

    /* ==================================================================
       Menu List
       ================================================================== */
    .emm-menu {
        list-style: none;
        margin: 0;
        padding: 0;
    }

    .emm-submenu {
        list-style: none;
        margin: 0;
        padding: 0;
        max-height: 0;
        overflow: hidden;
        transition: max-height 0.4s var(--emm-transition-ease);
        background: #fafafc;
    }

    .emm-submenu.emm-submenu--open {
        max-height: 600px; /* Accommodates long submenus */
    }

    /* ==================================================================
       Menu Items
       ================================================================== */
    .emm-menu-item {
        list-style: none;
        border-bottom: 1px solid var(--emm-border);
    }

    .emm-menu-item:last-child {
        border-bottom: none;
    }

    .emm-submenu .emm-menu-item {
        border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    }

    .emm-submenu .emm-menu-item:last-child {
        border-bottom: none;
    }

    /* Row for items with children (link + toggle) */
    .emm-menu-item__row {
        display: flex;
        align-items: stretch;
    }

    /* ==================================================================
       Menu Links
       ================================================================== */
    .emm-menu-link {
        display: flex;
        align-items: center;
        width: 100%;
        padding: 16px 20px;
        font-size: 15px;
        font-weight: 500;
        color: var(--emm-text);
        text-decoration: none;
        line-height: 1.4;
        transition: background 0.15s ease, color 0.15s ease;
        -webkit-tap-highlight-color: transparent;
        min-height: 52px;
    }

    .emm-menu-link:visited {
        color: var(--emm-text);
    }

    .emm-menu-link:hover,
    .emm-menu-link:focus-visible {
        background: #f5f5f8;
        color: var(--emm-accent);
    }

    .emm-menu-link:active {
        background: #ededf2;
    }

    /* Parent link (shares row with toggle) */
    .emm-menu-link--parent {
        flex: 1;
        min-width: 0;
    }

    /* Depth styling */
    .emm-submenu--depth-0 .emm-menu-link {
        padding-left: 36px;
        font-size: 14px;
        font-weight: 400;
        color: var(--emm-text-secondary);
        min-height: 46px;
    }

    .emm-submenu--depth-0 .emm-menu-link:hover,
    .emm-submenu--depth-0 .emm-menu-link:focus-visible {
        color: var(--emm-accent);
    }

    .emm-submenu--depth-1 .emm-menu-link {
        padding-left: 52px;
        font-size: 13px;
        font-weight: 400;
        color: var(--emm-text-secondary);
        min-height: 42px;
    }

    /* ==================================================================
       Submenu Toggle Button (Chevron)
       ================================================================== */
    .emm-submenu-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 52px;
        flex-shrink: 0;
        border: none;
        border-left: 1px solid var(--emm-border);
        background: transparent;
        color: var(--emm-text-secondary);
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
        transition: background 0.15s ease, color 0.15s ease;
        outline: none;
    }

    .emm-submenu-toggle:hover,
    .emm-submenu-toggle:focus-visible {
        background: #f5f5f8;
        color: var(--emm-accent);
    }

    .emm-submenu-toggle:active {
        background: #ededf2;
    }

    .emm-chevron {
        transition: transform 0.3s var(--emm-transition-ease);
    }

    .emm-submenu-toggle[aria-expanded="true"] .emm-chevron {
        transform: rotate(180deg);
    }

    .emm-submenu-toggle[aria-expanded="true"] {
        color: var(--emm-accent);
    }

    /* ==================================================================
       Current / Active Menu Item
       ================================================================== */
    .emm-menu-item.current-menu-item > .emm-menu-link,
    .emm-menu-item.current-menu-item > .emm-menu-item__row > .emm-menu-link,
    .emm-menu-item.current-menu-ancestor > .emm-menu-item__row > .emm-menu-link {
        color: var(--emm-accent);
        font-weight: 600;
    }

    .emm-menu-item.current-menu-item > .emm-menu-link::before,
    .emm-menu-item.current-menu-item > .emm-menu-item__row > .emm-menu-link::before {
        content: '';
        display: block;
        position: absolute;
        left: 0;
        top: 50%;
        transform: translateY(-50%);
        width: 3px;
        height: 24px;
        background: var(--emm-accent);
        border-radius: 0 3px 3px 0;
    }

    .emm-menu-item.current-menu-item > .emm-menu-link,
    .emm-menu-item.current-menu-item > .emm-menu-item__row > .emm-menu-link {
        position: relative;
    }

    /* ==================================================================
       Panel Footer — Sticky CTA
       ================================================================== */
    .emm-panel__footer {
        flex-shrink: 0;
        padding: 16px 20px;
        padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
        border-top: 1px solid var(--emm-border);
        background: var(--emm-bg);
    }

    .emm-cta-button {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 10px;
        width: 100%;
        padding: 15px 24px;
        font-family: var(--emm-font-family);
        font-size: 15px;
        font-weight: 600;
        color: #ffffff;
        background: var(--emm-accent);
        border: none;
        border-radius: var(--emm-radius);
        text-decoration: none;
        text-align: center;
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
        transition: background 0.2s ease, transform 0.15s ease, box-shadow 0.2s ease;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
        letter-spacing: 0.01em;
    }

    .emm-cta-button:visited {
        color: #ffffff;
    }

    .emm-cta-button:hover,
    .emm-cta-button:focus-visible {
        background: var(--emm-accent-hover);
        box-shadow: 0 4px 16px rgba(0, 0, 0, 0.18);
        transform: translateY(-1px);
        color: #ffffff;
    }

    .emm-cta-button:active {
        transform: translateY(0);
        box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
    }

    .emm-cta-button svg {
        flex-shrink: 0;
    }

    /* ==================================================================
       Body Lock — prevent scroll when menu is open
       ================================================================== */
    body.emm-body-locked {
        overflow: hidden !important;
        position: fixed !important;
        width: 100% !important;
        height: 100% !important;
    }

    /* ==================================================================
       Animations — Stagger items on open
       ================================================================== */
    .emm-panel.emm-is-open .emm-menu > .emm-menu-item {
        animation: emmSlideIn 0.35s var(--emm-transition-ease) both;
    }

    .emm-panel.emm-is-open .emm-menu > .emm-menu-item:nth-child(1) { animation-delay: 0.05s; }
    .emm-panel.emm-is-open .emm-menu > .emm-menu-item:nth-child(2) { animation-delay: 0.08s; }
    .emm-panel.emm-is-open .emm-menu > .emm-menu-item:nth-child(3) { animation-delay: 0.11s; }
    .emm-panel.emm-is-open .emm-menu > .emm-menu-item:nth-child(4) { animation-delay: 0.14s; }
    .emm-panel.emm-is-open .emm-menu > .emm-menu-item:nth-child(5) { animation-delay: 0.17s; }
    .emm-panel.emm-is-open .emm-menu > .emm-menu-item:nth-child(6) { animation-delay: 0.20s; }
    .emm-panel.emm-is-open .emm-menu > .emm-menu-item:nth-child(7) { animation-delay: 0.23s; }
    .emm-panel.emm-is-open .emm-menu > .emm-menu-item:nth-child(8) { animation-delay: 0.26s; }
    .emm-panel.emm-is-open .emm-menu > .emm-menu-item:nth-child(9) { animation-delay: 0.29s; }
    .emm-panel.emm-is-open .emm-menu > .emm-menu-item:nth-child(10) { animation-delay: 0.32s; }

    @keyframes emmSlideIn {
        from {
            opacity: 0;
            transform: translateX(16px);
        }
        to {
            opacity: 1;
            transform: translateX(0);
        }
    }

    /* ==================================================================
       Accessibility — Focus styles
       ================================================================== */
    .emm-panel :focus-visible,
    .emm-hamburger:focus-visible {
        outline: 2px solid var(--emm-accent);
        outline-offset: 2px;
    }

    /* ==================================================================
       Safe area padding for notched devices
       ================================================================== */
    @supports (padding-top: env(safe-area-inset-top)) {
        .emm-panel__header {
            padding-top: calc(18px + env(safe-area-inset-top, 0px));
        }
    }

} /* END @media max-width: 1024px */

/* ==========================================================================
   Theme toggle hiding (applied globally when enabled via settings)
   These are injected via inline styles from PHP based on user-defined selector.
   This class is a fallback for common theme toggles.
   ========================================================================== */
@media screen and (max-width: 1024px) {
    .emm-hide-theme-toggle {
        display: none !important;
        visibility: hidden !important;
        opacity: 0 !important;
        pointer-events: none !important;
    }
}
