/**
 * Carbon Based Studio Mobile Menu — front-end styles.
 */

/* ==========================================================================
   CSS Custom Properties (Design Tokens)
   ========================================================================== */
:root {
    --cbsmm-menu-transition: 0.5s ease-in-out;
    --cbsmm-menu-z-overlay: 99997;
    --cbsmm-menu-z-sidebar: 99998;
    --cbsmm-menu-z-bottom: 100;
    --cbsmm-menu-z-header: 99;
    --cbsmm-bottom-menu-height: 60px;
    --cbsmm-mobile-header-height: 60px;
    --cbsmm-left-menu-width: 380px;
    --cbsmm-menu-icon-size: 24px;
    --cbsmm-menu-text-color: #ffffff;
    --cbsmm-menu-bg-overlay: rgba(0, 0, 0, 0.5);
}

/* ==========================================================================
   Desktop - Hide Mobile Menus
   ========================================================================== */
@media only screen and (min-width: 1025px) {
    .cbsmm-bottom-menu,
    .cbsmm-left-menu,
    .cbsmm-menu-overlay,
    .cbsmm-mobile-header {
        display: none;
    }
}

/* ==========================================================================
   Mobile Styles
   ========================================================================== */
@media only screen and (max-width: 1024px) {
    
    /* Hide desktop header and navigation on mobile */
    #masthead,
    .site-header,
    #site-navigation,
    .main-navigation,
    nav.primary-navigation,
    .desktop-menu,
    .top-bar,
    .header-navigation {
        display: none !important;
    }
    
    /* Smooth scrolling for Android/iOS - FIXED: Removed html overflow to stop stutter */
    body {
        overflow-x: hidden;
        max-width: 100%;
        -webkit-overflow-scrolling: touch;
    }
    
    /* Reserve space for fixed bottom menu (same targets as mobile header offset). */
    #page,
    #wrapper {
        margin-bottom: var(--cbsmm-bottom-menu-height);
    }
    
    /* Screen reader only text */
    .screen-reader-text {
        position: absolute;
        width: 1px;
        height: 1px;
        padding: 0;
        margin: -1px;
        overflow: hidden;
        clip: rect(0, 0, 0, 0);
        white-space: nowrap;
        border: 0;
    }
    
    /* ==========================================================================
       Mobile Header
       ========================================================================== */
    .cbsmm-mobile-header {
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        width: 100%;
        height: var(--cbsmm-mobile-header-height);
        z-index: var(--cbsmm-menu-z-header);
        background-color: var(--cbsmm-mobile-header-bg, #fff);
        color: var(--cbsmm-mobile-header-color, #333);
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
        will-change: transform;
        contain: layout style;
    }
    
    .cbsmm-mobile-header-link {
        display: block;
        width: 100%;
        height: 100%;
        overflow: hidden;
        color: inherit;
        text-decoration: none;
    }

    .cbsmm-mobile-header-brand {
        display: flex;
        align-items: center;
        gap: 12px;
        height: 100%;
        padding: 0 16px;
        box-sizing: border-box;
    }

    .cbsmm-mobile-header--align-center .cbsmm-mobile-header-brand {
        justify-content: center;
    }

    .cbsmm-mobile-header--align-right .cbsmm-mobile-header-brand {
        justify-content: flex-end;
    }

    .cbsmm-mobile-header-icon {
        display: block;
        width: var(--cbsmm-mobile-header-icon-size, 36px);
        height: var(--cbsmm-mobile-header-icon-size, 36px);
        flex-shrink: 0;
        object-fit: contain;
    }

    .cbsmm-mobile-header-title {
        display: flex;
        flex-direction: column;
        gap: 2px;
        min-width: 0;
        line-height: 1.25;
    }

    .cbsmm-mobile-header-brand-name {
        font-size: 18px;
        font-weight: 400;
    }

    .cbsmm-mobile-header-product {
        font-size: 16px;
        font-weight: 300;
    }

    .cbsmm-mobile-header--align-center .cbsmm-mobile-header-title {
        text-align: center;
    }

    .cbsmm-mobile-header--align-right .cbsmm-mobile-header-title {
        text-align: right;
    }
    
    .cbsmm-mobile-header-image {
        width: 100%;
        height: 100% !important;
        object-fit: cover;
        display: block;
    }
    
    /* Adjust page content for fixed header */
    body.has-cbsmm-header #page,
    body.has-cbsmm-header #wrapper {
        padding-top: var(--cbsmm-mobile-header-height);
    }
    
    /* Admin bar adjustments for mobile header */
    .admin-bar .cbsmm-mobile-header {
        top: 46px;
    }
    
    /* ==========================================================================
       Bottom Menu Bar
       ========================================================================== */
    .cbsmm-bottom-menu {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        height: var(--cbsmm-bottom-menu-height);
        background-color: #000; /* Fallback colour if no image is set */
        z-index: var(--cbsmm-menu-z-bottom);
        will-change: transform;
        contain: layout style;
    }
    
    .cbsmm-bottom-menu-items {
        display: flex;
        justify-content: space-between;
        align-items: center;
        height: 100%;
        margin: 0;
        padding: 0;
        list-style: none;
    }
    
    .cbsmm-bottom-menu-items > li {
        flex: 1;
        display: flex;
        justify-content: center;
        align-items: center;
        height: 100%;
        margin: 0;
        padding: 0;
        position: relative;
    }
    
    .cbsmm-bottom-menu-items a,
    .cbsmm-search-toggle {
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        width: 100%;
        height: 100%;
        color: var(--cbsmm-menu-text-color);
        text-decoration: none;
        cursor: pointer;
        background: none;
        border: none;
        font-size: 0;
    }
    
    .cbsmm-bottom-menu-items a:hover,
    .cbsmm-bottom-menu-items a:focus {
        color: #fff;
    }
    
    .cbsmm-bottom-menu-items a:focus {
    background-color: #ffffff00 !important;
    }
    
    /* Icon styling */
    .cbsmm-bottom-menu-items i,
    .cbsmm-bottom-menu-items svg {
        font-size: var(--cbsmm-menu-icon-size);
        line-height: var(--cbsmm-bottom-menu-height);
    }
    
    /* Hide text labels */
    .cbsmm-menu-text {
        display: none;
    }
    
    /* Menu icons using FontAwesome */
    .cbsmm-mobile-menu a::before {
        content: "\f0c9";
        font-family: "FontAwesome";
        font-size: var(--cbsmm-menu-icon-size);
    }
    
    .cbsmm-mobile-home a::before {
        content: "\f015";
        font-family: "FontAwesome";
        font-size: var(--cbsmm-menu-icon-size);
    }
    
    /* ==========================================================================
       Search Form
       ========================================================================== */
    .cbsmm-search-form {
        position: fixed;
        bottom: var(--cbsmm-bottom-menu-height);
        left: 0;
        right: 0;
        z-index: calc(var(--cbsmm-menu-z-bottom) + 1);
        padding: 0;
        border-radius: 0;
        border: none;
    }
    
    .cbsmm-search-form-inner {
        position: relative;
        background-color: #000; /* Fallback colour if no image is set */
        padding: 10px;
        height: var(--cbsmm-bottom-menu-height);
        box-sizing: border-box;
    }
    
    .cbsmm-search-input {
        width: 100%;
        max-width: 100%;
        height: 40px !important;
        padding-left: 45px !important;
        padding-right: 30px !important;
        border: 1px solid #eee;
        border-radius: 8px !important;
        font-size: 16px !important;
        box-sizing: border-box;
    }
    
    .cbsmm-search-input:focus {
        outline: 2px solid #0073aa;
        border-color: #0073aa;
    }
    
    .cbsmm-search-icon {
        position: absolute;
        left: 35px;
        top: 50%;
        transform: translate(-50%, -50%);
        color: #555;
        font-size: 18px;
        pointer-events: none;
    }
    
    /* ==========================================================================
       Left Slide-Out Menu
       ========================================================================== */
    
    /* Overlay backdrop */
    .cbsmm-menu-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: var(--cbsmm-menu-bg-overlay);
        z-index: var(--cbsmm-menu-z-overlay);
        opacity: 0;
        visibility: hidden;
        transition: opacity var(--cbsmm-menu-transition), visibility var(--cbsmm-menu-transition);
        touch-action: none;
        overscroll-behavior: none;
    }
    
    .cbsmm-menu-overlay.active {
        opacity: 1;
        visibility: visible;
    }
    
    /* Left menu panel */
    .cbsmm-left-menu {
        position: fixed;
        top: 0;
        left: 0;
        width: 80%;
        max-width: var(--cbsmm-left-menu-width);
        height: 100%;
        background: #f5f5f5;
        z-index: var(--cbsmm-menu-z-sidebar);
        transform: translateX(-100%);
        transition: transform var(--cbsmm-menu-transition);
        display: flex;
        flex-direction: column;
        overflow: hidden;
        overscroll-behavior: contain;
        will-change: transform;
    }
    
    .cbsmm-left-menu.active {
        transform: translateX(0);
    }
    
    /* Prevent body scroll when menu is open - FIXED: uses overflow instead of position:fixed */
    body.cbsmm-menu-open {
        overflow: hidden !important;
        height: 100%;
    }
    
    /* Header section */
    .cbsmm-left-menu-header,
    .cbsmm-left-menu-footer {
        flex-shrink: 0;
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 12px 16px;
        background-size: cover;
        background-position: left center;
        background-repeat: no-repeat;
        touch-action: none;
        overscroll-behavior: contain;
        box-sizing: border-box;
    }

    .cbsmm-left-menu-header {
        min-height: var(--cbsmm-left-header-height, 60px);
        background-color: var(--cbsmm-left-header-bg, #f5f5f5);
        color: var(--cbsmm-left-header-color, #333);
        border-bottom: 1px solid #ddd;
    }

    .cbsmm-left-menu-header--clickable {
        cursor: pointer;
        user-select: none;
    }

    .cbsmm-left-menu-header-text,
    .cbsmm-left-menu-footer-text,
    .cbsmm-close-menu-text {
        font-size: 18px;
        font-weight: 600;
        color: inherit;
        margin: 0;
    }

    .cbsmm-left-menu-header-close {
        background: none;
        border: none;
        font-size: 28px;
        line-height: 1;
        padding: 0;
        width: 32px;
        height: 32px;
        display: flex;
        align-items: center;
        justify-content: center;
        color: inherit;
        cursor: pointer;
        flex-shrink: 0;
    }

    .cbsmm-left-menu-bar--align-center .cbsmm-left-menu-header-text,
    .cbsmm-left-menu-bar--align-center .cbsmm-left-menu-footer-text {
        flex: 1;
        text-align: center;
    }

    .cbsmm-left-menu-bar--align-right .cbsmm-left-menu-header-text,
    .cbsmm-left-menu-bar--align-right .cbsmm-left-menu-footer-text {
        flex: 1;
        text-align: right;
    }

    .cbsmm-left-menu-header.cbsmm-left-menu-bar--align-center,
    .cbsmm-left-menu-header.cbsmm-left-menu-bar--align-right {
        position: relative;
    }

    .cbsmm-left-menu-header.cbsmm-left-menu-bar--align-center .cbsmm-left-menu-header-close,
    .cbsmm-left-menu-header.cbsmm-left-menu-bar--align-right .cbsmm-left-menu-header-close {
        position: absolute;
        right: 16px;
        top: 50%;
        transform: translateY(-50%);
    }

    .cbsmm-left-menu-header.cbsmm-left-menu-bar--align-center .cbsmm-left-menu-header-text,
    .cbsmm-left-menu-header.cbsmm-left-menu-bar--align-right .cbsmm-left-menu-header-text {
        padding-right: 36px;
    }

    .cbsmm-left-menu-header:hover,
    .cbsmm-left-menu-header:focus,
    .cbsmm-left-menu-footer.cbsmm-menu-close-trigger:hover,
    .cbsmm-left-menu-footer.cbsmm-menu-close-trigger:focus {
        opacity: 0.92;
    }
    
    /* Menu content area */
    .cbsmm-left-menu-content {
        flex: 1;
        overflow-y: auto;
        overflow-x: hidden;
        padding: 0;
        background: #fff;
        overscroll-behavior: contain;
        -webkit-overflow-scrolling: touch;
    }
    
    .cbsmm-left-menu-items {
        list-style: none;
        margin: 0;
        padding: 0;
    }
    
    .cbsmm-left-menu-items li {
        border-bottom: 1px solid #ddd;
        position: relative;
        display: flex;
        flex-wrap: wrap;
        background: #fff;
    }
    
    .cbsmm-left-menu-items a {
        display: block;
        flex: 1;
        padding: 16px 20px;
        color: #555;
        text-decoration: none;
        font-size: 18px;
        font-weight: 600;
        transition: background-color 0.2s;
        background: #fff;
    }
    
    /* This ensures the style only triggers for actual keyboard users */
    .cbsmm-left-menu-items a:focus-visible {
    background-color: #fff !important;
    color: #555 !important;
    outline: none !important;
    }

    /* This keeps the outline hidden for touch/mouse users */
    .cbsmm-left-menu-items a:focus {
    outline: none !important;
    }
    
    /* Active (clicked/tapped) state - visual feedback */
    .cbsmm-left-menu-items a:active {
        background-color: #d5d5d5 !important;
    }
    
    /* Current/active page styling */
    .cbsmm-left-menu-items .current-menu-item > a,
    .cbsmm-left-menu-items .current_page_item > a,
    .cbsmm-left-menu-items .current-menu-ancestor > a {
        background-color: #d5d5d5;
    }
    
    /* Parent items with dropdowns */
    .cbsmm-has-submenu {
        flex-direction: row;
    }
    
    .cbsmm-has-submenu > a {
        padding-right: 60px;
    }
    
    .cbsmm-submenu-toggle {
        flex: 0 0 50px;
        height: auto;
        min-height: 54px;
        background: #fff;
        border: none;
        cursor: pointer;
        color: #555 !important;
        font-size: 16px !important;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    .cbsmm-submenu-toggle:hover,
    .cbsmm-submenu-toggle:focus,
    .cbsmm-submenu-toggle:active {
        background: #fff;
        outline: none;
        color: #555 !important;
    }
    
    .cbsmm-submenu-toggle i {
        transition: transform 0.2s ease;
        display: block;
    }
    
    .cbsmm-submenu-toggle[aria-expanded="true"] i {
        transform: rotate(180deg);
    }
    
    /* Submenu styling - ANIMATION LOGIC */
    .cbsmm-submenu {
        list-style: none;
        margin: 0;
        padding: 0;
        background: #fff;
        width: 100%;
        flex-basis: 100%;
        
        /* Animation Logic - Base State */
        display: block !important;       /* Override default display:none */
        max-height: 0;                   /* Closed height */
        opacity: 0;                      /* Invisible */
        overflow: hidden;                /* Hide content */
        visibility: hidden;              /* Accessibility hide */
        /* NO transition here - this ensures it snaps shut instantly */
    }
    
    .cbsmm-submenu.active {
        /* Animation Logic - Active State */
        max-height: 2000px;              /* Open height */
        opacity: 1;                      /* Fully visible */
        visibility: visible;
        
        /* Transition is ONLY defined here. 
           This means it only runs when entering this state (Opening). */
        transition: max-height 0.4s ease-in-out, opacity 0.4s ease-in-out;
    }
    
    /* Add border-top to first submenu child for visual separation */
    .cbsmm-submenu.active li:first-child {
        border-top: 1px solid #ddd;
    }
    
    .cbsmm-submenu li {
        border-bottom: 1px solid #eee;
        background: #fff;
    }
    
    .cbsmm-submenu a {
        padding-left: 40px;
        font-size: 18px;
        color: #555;
        font-weight: 600;
        background: #fff;
    }
    
    .cbsmm-submenu a:hover,
    .cbsmm-submenu a:focus {
        background-color: #e8e8e8;
    }
    
    /* Active (clicked/tapped) state - visual feedback */
    .cbsmm-submenu a:active {
        background-color: #d5d5d5 !important;
    }
    
    /* Current/active submenu items - match top level */
    .cbsmm-submenu .current-menu-item > a,
    .cbsmm-submenu .current_page_item > a,
    .cbsmm-submenu .current-menu-ancestor > a {
        background-color: #d5d5d5;
    }
    
    /* Nested submenu - additional 20px indentation */
    .cbsmm-submenu .cbsmm-submenu a {
        padding-left: 60px;
    }
    
    /* Third level nesting */
    .cbsmm-submenu .cbsmm-submenu .cbsmm-submenu a {
        padding-left: 80px;
    }
    
    /* Footer section */
    .cbsmm-left-menu-footer {
        min-height: var(--cbsmm-left-footer-height, 60px);
        background-color: var(--cbsmm-left-footer-bg, #333);
        color: var(--cbsmm-left-footer-color, #fff);
        justify-content: center;
        border-top: 1px solid #ddd;
    }

    .cbsmm-left-menu-footer.cbsmm-menu-close-trigger {
        cursor: pointer;
        user-select: none;
    }

    .cbsmm-left-menu-bar--align-left.cbsmm-left-menu-footer {
        justify-content: flex-start;
    }

    .cbsmm-left-menu-bar--align-right.cbsmm-left-menu-footer {
        justify-content: flex-end;
    }
    
    /* Admin bar adjustments */
    .admin-bar .cbsmm-left-menu-header {
        margin-top: 32px;
    }
}

/* Admin bar adjustment for mobile */
@media only screen and (max-width: 782px) {
    .admin-bar .cbsmm-left-menu-header {
        margin-top: 46px;
    }
}

/* ==========================================================================
   Cache exclusion helper class
   ========================================================================== */
.cbsmm-no-cache {
	/* Optional: exclude elements with this class from full-page cache plugins. */
}

/* ==========================================================================
   Print Styles
   ========================================================================== */
@media print {
    .cbsmm-bottom-menu,
    .cbsmm-left-menu,
    .cbsmm-menu-overlay,
    .cbsmm-search-form,
    .cbsmm-mobile-header {
        display: none;
    }
}