/**
 * Mobile Drawer Menu Styles
 */

/* Mobile Menu Drawer */
.mobile-menu-drawer {
    position: fixed;
    top: 0;
    right: -320px; /* Start off-screen */
    width: 320px;
    max-width: 90vw;
    height: 100vh;
    background-color: var(--clr-surface-a0);
    z-index: 9999;
    overflow-y: auto;
    overflow-x: hidden; /* Prevent horizontal scrolling */
    transition: transform 0.3s ease-in-out;
    box-shadow: -5px 0 15px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
}

.mobile-menu-drawer.active {
    transform: translateX(-320px);
}

/* Mobile Menu Overlay */
.mobile-menu-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 9998;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.mobile-menu-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* Mobile Menu Header */
.mobile-menu-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    border-bottom: 1px solid var(--clr-surface-a20);
}

.mobile-menu-header .site-branding {
    flex: 1;
}

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

.mobile-menu-header .site-title {
    margin: 0;
    font-size: 1.25rem;
}

.mobile-menu-close {
    background: none;
    border: none;
    color: var(--clr-light-a0);
    font-size: 24px;
    cursor: pointer;
    padding: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s ease;
}

.mobile-menu-close:hover {
    color: var(--clr-primary-a0);
}

.close-icon {
    font-size: 28px;
    line-height: 1;
}

/* Mobile Menu Content */
.mobile-menu-content {
    flex: 1;
    overflow-y: auto;
}

.mobile-menu-items {
    list-style: none;
    margin: 0;
    padding: 0;
}

.mobile-menu-item {
    border-bottom: 1px solid var(--clr-surface-a20);
}

.mobile-menu-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    color: var(--clr-light-a0);
    text-decoration: none;
    transition: background-color 0.2s ease;
}

.mobile-menu-link:hover,
.mobile-menu-link:focus,
.mobile-menu-link.active {
    background-color: var(--clr-surface-a10);
    color: var(--clr-primary-a0);
}

/* Submenu Toggle Icon */
.submenu-toggle-icon {
    font-size: 20px;
    transition: transform 0.2s ease;
}

/* Mobile Submenu */
.mobile-submenu {
    position: fixed;
    top: 0;
    right: -320px;
    width: 320px;
    max-width: 90vw;
    height: 100vh;
    background-color: var(--clr-surface-a0);
    z-index: 10000;
    overflow-y: auto;
    overflow-x: hidden; /* Prevent horizontal scrolling */
    transition: transform 0.3s ease-in-out;
    list-style: none;
    margin: 0;
    padding: 0;
    box-sizing: border-box; /* Ensure padding doesn't add to width */
}

.mobile-submenu.active {
    transform: translateX(-320px);
}

/* Mobile Submenu Header */
.mobile-submenu-header {
    display: flex;
    align-items: center;
    padding: 16px;
    border-bottom: 1px solid var(--clr-surface-a20);
    background-color: var(--clr-surface-a10);
}

.mobile-submenu-back {
    background: none;
    border: none;
    color: var(--clr-light-a0);
    cursor: pointer;
    padding: 0;
    margin-right: 16px;
    display: flex;
    align-items: center;
    font-size: 16px;
    transition: color 0.2s ease;
}

.mobile-submenu-back:hover {
    color: var(--clr-primary-a0);
}

.back-icon {
    font-size: 20px;
    margin-right: 4px;
}

.mobile-submenu-title {
    font-weight: 600;
    color: var(--clr-light-a0);
    flex: 1;
    text-align: center;
    padding-right: 24px; /* Balance with back button */
}

/* Hide mobile menu on desktop */
@media (min-width: 992px) {
    .mobile-menu-drawer,
    .mobile-menu-overlay {
        display: none;
    }
}

/* Prevent scrolling when mobile menu is open */
body.mobile-menu-open {
    overflow: hidden;
}

/* Nested submenu styles */
.mobile-submenu .mobile-submenu {
    z-index: 10001; /* Higher z-index for nested submenus */
}

/* Ensure all menu items have proper box-sizing */
.mobile-menu-item,
.mobile-menu-link,
.mobile-submenu-header,
.mobile-submenu-back,
.mobile-submenu-title {
    box-sizing: border-box;
    width: 100%;
}

/* Ensure submenu toggle icon is properly aligned */
.submenu-toggle-icon {
    margin-left: 8px;
    display: inline-block;
}
