/**
 * Lightweight Mobile Menu - Styles v2.0
 * Modern, lightweight CSS with multi-level sliding panels
 * Improved animations inspired by premium designs
 */

:root {
    --ymm-duration-fast: 0.15s;
    --ymm-duration-normal: 0.25s;
    --ymm-cubic-smooth: cubic-bezier(0.4, 0, 0.2, 1);
}

/* ========================================
   Container & Reset
   ======================================== */
.ymm-container {
    position: relative;
    display: inline-block; 
    z-index: 9999;
}

.ymm-container * {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* ========================================
   Burger Button
   ======================================== */
.ymm-burger {
    display: flex;
    flex-direction: column;
    justify-content: space-around;
    width: 40px;
    height: 40px;
    padding: 8px;
    background: transparent;
    border: none;
    cursor: pointer;
    z-index: 10000;
    position: relative;
    transition: transform var(--ymm-duration-fast) ease;
}

.ymm-burger:hover {
    transform: scale(1.05);
}

.ymm-burger:focus {
    outline: 2px solid #4a90e2;
    outline-offset: 2px;
}

.ymm-burger span {
    width: 100%;
    height: 3px;
    background-color: #000;
    border-radius: 2px;
    transition: all var(--ymm-duration-normal) var(--ymm-cubic-smooth);
    transform-origin: center;
}

/* Active state - transform burger to X */
.ymm-container.active .ymm-burger span:nth-child(1) {
    transform: translateY(9px) rotate(45deg);
}

.ymm-container.active .ymm-burger span:nth-child(2) {
    opacity: 0;
    transform: scale(0);
}

.ymm-container.active .ymm-burger span:nth-child(3) {
    transform: translateY(-9px) rotate(-45deg);
}

/* ========================================
   Overlay
   ======================================== */
.ymm-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 var(--ymm-duration-normal) var(--ymm-cubic-smooth), 
                visibility var(--ymm-duration-normal) var(--ymm-cubic-smooth);
}

.ymm-container.active .ymm-overlay {
    opacity: 1;
    visibility: visible;
}

/* ========================================
   Menu Panel (Main Container)
   ======================================== */
.ymm-menu-panel {
    position: fixed;
    top: 0;
    left: 0;
    height: 100%;
    width: 100vw;
    max-width: 100%;
    background-color: #ffffff;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    overflow: hidden;
    z-index: 10002;
    
    /* Hide scrollbar for webkit browsers */
    -webkit-overflow-scrolling: touch;
}

/* ========================================
   Panels Container (for sliding panels)
   ======================================== */
.ymm-panels-container {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

.ymm-panel {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: inherit;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 60px 20px 20px;
    display: none;
}

.ymm-panel::-webkit-scrollbar {
    width: 6px;
}

.ymm-panel::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.05);
}

.ymm-panel::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 3px;
}

.ymm-panel::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.3);
}

.ymm-panel-active {
    display: block;
}

/* ========================================
   Panel Header (Back button + Title)
   ======================================== */
.ymm-panel-header {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    padding: 15px 20px;
    background: linear-gradient(to bottom, rgba(255,255,255,1) 0%, rgba(255,255,255,0.95) 100%);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
    z-index: 10;
    display: flex;
    align-items: center;
    gap: 12px;
}

.ymm-back-button {
    display: flex;
    align-items: center;
    gap: 6px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    color: #4a90e2;
    transition: all 0.2s ease;
}

.ymm-back-button:hover {
    background-color: rgba(74, 144, 226, 0.1);
}

.ymm-back-button:focus {
    outline: 2px solid #4a90e2;
    outline-offset: 2px;
}

.ymm-back-button svg {
    width: 14px;
    height: 14px;
}

.ymm-panel-title {
    font-size: 16px;
    font-weight: 600;
    color: #333;
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ========================================
   Close Button
   ======================================== */
.ymm-close {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 40px;
    height: 40px;
    background: transparent;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color var(--ymm-duration-fast) ease;
    z-index: 10003;
}

.ymm-close:hover {
    background-color: rgba(0, 0, 0, 0.05);
}

.ymm-close:focus {
    outline: 2px solid #4a90e2;
}

.ymm-close span {
    font-size: 32px;
    line-height: 1;
    color: inherit;
    font-weight: 300;
}

/* ========================================
   Menu Items
   ======================================== */
.ymm-menu,
.ymm-submenu {
    list-style: none;
    margin: 0;
    padding: 0;
}

.ymm-menu {
    margin-top: 0;
}

.ymm-menu > li {
    margin-bottom: 4px;
}

.ymm-menu > li > a,
.ymm-menu > li > .ymm-panel-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 14px 16px;
    color: #000;
    text-decoration: none;
    font-size: 16px;
    font-weight: 500;
    border-radius: 8px;
    transition: all var(--ymm-duration-fast) var(--ymm-cubic-smooth);
    position: relative;
    background: transparent;
    border: none;
    cursor: pointer;
    text-align: left;
}

.ymm-menu > li > a:hover,
.ymm-menu > li > a:focus,
.ymm-menu > li > .ymm-panel-trigger:hover,
.ymm-menu > li > .ymm-panel-trigger:focus {
    background-color: rgba(0, 0, 0, 0.05);
    padding-left: 20px;
    transform: translateX(2px);
}

/* ========================================
   Panel Trigger Buttons (items that open sliding panels)
   ======================================== */
.ymm-panel-trigger {
    font-family: inherit;
}

.ymm-panel-trigger span {
    flex: 1;
}

.ymm-arrow-icon {
    width: 8px;
    height: 12px;
    opacity: 0.5;
    transition: all var(--ymm-duration-fast) var(--ymm-cubic-smooth);
}

.ymm-panel-trigger:hover .ymm-arrow-icon,
.ymm-panel-trigger:focus .ymm-arrow-icon {
    opacity: 1;
    transform: translateX(2px);
}

/* ========================================
   Submenu (Accordion style for non-sliding items)
   ======================================== */
.ymm-has-children {
    position: relative;
}

.ymm-submenu-toggle {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    width: 36px;
    height: 36px;
    background: transparent;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s ease;
    z-index: 1;
}

.ymm-submenu-toggle:hover {
    background-color: rgba(0, 0, 0, 0.1);
}

.ymm-submenu-toggle svg {
    transition: transform 0.3s ease;
}

.ymm-submenu-toggle.active svg {
    transform: rotate(180deg);
}

.ymm-submenu {
    max-height: 0;
    overflow: hidden;
    padding-left: 20px;
    transition: max-height 0.3s ease;
}

.ymm-submenu.open {
    max-height: 1000px;
}

.ymm-submenu li {
    margin: 4px 0;
}

.ymm-submenu a {
    display: block;
    padding: 10px 12px;
    color: #000;
    text-decoration: none;
    font-size: 14px;
    border-radius: 6px;
    transition: all 0.2s ease;
    opacity: 0.8;
}

.ymm-submenu a:hover,
.ymm-submenu a:focus {
    background-color: rgba(0, 0, 0, 0.05);
    opacity: 1;
    padding-left: 16px;
}

/* ========================================
   Hidden Panel Data (templates)
   ======================================== */
.ymm-panel-data {
    display: none !important;
}

/* ========================================
   Responsive Design
   ======================================== */
@media (max-width: 480px) {
    .ymm-menu-panel {
        width: 100vw;
    }
}

@media (min-width: 1024px) {
    /* Optional: Hide on desktop if you want mobile-only */
    /* .ymm-container {
        display: none;
    } */
}

/* ========================================
   Accessibility
   ======================================== */
.ymm-burger:focus-visible,
.ymm-close:focus-visible,
.ymm-back-button:focus-visible,
.ymm-panel-trigger:focus-visible,
.ymm-submenu-toggle:focus-visible,
.ymm-menu a:focus-visible,
.ymm-submenu a:focus-visible {
    outline: 2px solid #4a90e2;
    outline-offset: 2px;
}

/* Reduced motion for accessibility */
@media (prefers-reduced-motion: reduce) {
    .ymm-burger,
    .ymm-burger span,
    .ymm-overlay,
    .ymm-menu-panel,
    .ymm-panel,
    .ymm-menu a,
    .ymm-panel-trigger,
    .ymm-submenu,
    .ymm-submenu-toggle svg,
    .ymm-back-button,
    .ymm-arrow-icon {
        transition: none !important;
        animation: none !important;
    }
}

/* ========================================
   Print Styles
   ======================================== */
@media print {
    .ymm-container {
        display: none;
    }
}
