/* Navigation Menu Styles */

/* Header Flex Container - Strict Alignment */
.ym-header-flex-container {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    flex-wrap: nowrap !important;
    width: 100%;
    position: relative;
    /* For mobile positioning context */
}

/* Logo Area Alignment */
.ym-header-brand {
    display: flex !important;
    align-items: center !important;
    margin: 0 !important;
    padding: 0 !important;
    line-height: 0 !important;
}

.ym-header-brand a {
    display: flex;
    align-items: center;
    border: none;
    text-decoration: none;
}

.ym-header-brand img {
    margin: 0 !important;
    display: block;
    max-height: 60px;
    height: auto;
}

/* Navigation Area Alignment */
.ym-main-nav-wrapper {
    display: flex !important;
    align-items: center !important;
    margin: 0 !important;
    margin-left: auto !important;
    height: 100%;
}

.ym-nav-menu {
    display: flex;
    gap: 30px;
    list-style: none;
    margin: 0;
    padding: 0;
    align-items: center;
}

.ym-nav-menu li {
    position: relative;
    display: flex;
    align-items: center;
    line-height: normal;
}

.ym-nav-menu a {
    text-decoration: none;
    color: #1e293b;
    font-weight: 600;
    font-size: 15px;
    letter-spacing: -0.01em;
    padding: 8px 0;
    position: relative;
    transition: all 0.2s ease;
    display: inline-flex;
    /* Changed to align text and svg */
    align-items: center;
    gap: 6px;
    /* Gap for arrow */
}

/* Dropdown Arrow Indicator */
.ym-nav-menu .menu-item-has-children>a:before {
    content: '';
    display: block;
    width: 0;
    height: 0;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-top: 5px solid currentColor;
    /* Dynamic color based on text */
    margin-top: 1px;
    order: 2;
    /* Move to right */
    opacity: 0.6;
}

/* Hover Effect: Underline */
.ym-nav-menu a:after {
    content: '';
    position: absolute;
    width: 0;
    height: 2px;
    bottom: -2px;
    left: 0;
    background-color: var(--ym-primary, #0073aa);
    transition: width 0.3s ease;
}

/* Adjust hover effect to account for arrow width if needed, but width: 100% works fine */
.ym-nav-menu a:hover:after {
    width: 100%;
}

.ym-nav-menu a:hover {
    color: var(--ym-primary, #0073aa);
}

/* Submenus - Visual Compact Refinement */
.ym-nav-menu .sub-menu {
    display: block;
    opacity: 0;
    visibility: hidden;
    position: absolute;
    top: 100%;
    margin-top: 10px;
    /* Push down visually */
    left: 0;
    /* Align left with parent */
    background: #ffffff;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    /* Softer shadow */
    min-width: 180px;
    /* Slightly narrower */
    padding: 6px 0;
    /* Minimal padding */
    z-index: 100;
    border-radius: 6px;
    /* Slightly rounded */
    transform: translateY(10px);
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    border: 1px solid #e2e8f0;
}

/* Invisible bridge to keep hover active */
.ym-nav-menu .sub-menu:before {
    content: '';
    position: absolute;
    top: -10px;
    /* Cover the margin gap */
    left: 0;
    width: 100%;
    height: 10px;
    background: transparent;
}

.ym-nav-menu li:hover>.sub-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.ym-nav-menu .sub-menu li {
    display: block;
    width: 100%;
}

.ym-nav-menu .sub-menu a {
    display: block;
    /* Full width click area */
    padding: 8px 16px;
    /* Compact padding */
    font-size: 14px;
    color: #475569;
    font-weight: 500;
    width: 100%;
    box-sizing: border-box;
}

.ym-nav-menu .sub-menu .menu-item-has-children>a:before {
    transform: rotate(-90deg);
    /* Rotate arrow for sublevels if any */
}

.ym-nav-menu .sub-menu a:after {
    display: none;
    /* No underline in submenus */
}

.ym-nav-menu .sub-menu a:hover {
    background: #f1f5f9;
    color: var(--ym-primary, #0073aa);
    padding-left: 20px;
    /* Sutil movement */
}

/* Mobile Toggle Button */
.ym-mobile-menu-toggle {
    display: none;
    background: none;
    border: none;
    padding: 5px;
    cursor: pointer;
    color: var(--wp--preset--color--contrast, #1e293b);
    transition: color 0.2s ease;
}

.ym-mobile-menu-toggle .dashicons {
    font-size: 28px;
    width: 28px;
    height: 28px;
}

/* Footer Menu Styles */
.ym-footer-nav-wrapper {
    display: flex;
    justify-content: center;
    width: 100%;
    margin-bottom: 20px;
    /* Space before copyright */
}

.ym-nav-footer {
    list-style: none !important;
    margin: 0 !important;
    padding: 0 !important;
    display: flex;
    flex-wrap: wrap;
    gap: 15px 25px;
    /* Row / Column gap */
    justify-content: center;
    width: 100%;
}


.ym-nav-footer li {
    margin: 0 !important;
    padding: 0 !important;
    display: inline-block;
}

/* Force footer color to override generic nav styles */
.ym-nav-footer,
.ym-nav-footer a,
.wp-block-group.has-contrast-background-color .ym-nav-footer a {
    color: var(--wp--preset--color--base, #ffffff) !important;
}

.ym-nav-footer a {
    text-decoration: none;
    opacity: 0.8;
    font-size: var(--wp--preset--font-size--small, 0.875rem);
    transition: opacity 0.2s ease;
    padding: 5px;
    display: inline-block;
}

.ym-nav-footer a:hover {
    opacity: 1;
    text-decoration: underline;
}

/* Default state for Close Button & Submenu Toggle (Hidden on Desktop) */
.ym-mobile-menu-close,
.ym-submenu-toggle {
    display: none;
}

/* FIX: Hide Wordpress Skip Link */
.skip-link {
    display: none !important;
}

/* Mobile Responsiveness */
@media screen and (max-width: 768px) {

    /* Footer Menu Specific - Override Main Menu Vertical Stack */
    .ym-nav-footer {
        flex-direction: row !important;
        /* Force row layout */
        flex-wrap: wrap !important;
        /* Allow wrapping */
        justify-content: center !important;
        /* Center align */
        gap: 10px 15px !important;
        /* Smaller gaps */
        width: 100% !important;
    }

    .ym-nav-footer li {
        width: auto !important;
        /* Flex item width */
        border: none !important;
        /* Remove separator */
        margin: 0 !important;
    }

    /* FIX: Force footer links to be white on mobile, overriding general nav rules */
    .ym-nav-footer a,
    .wp-block-group.has-contrast-background-color .ym-nav-footer a {
        color: var(--wp--preset--color--base, #ffffff) !important;
        width: auto !important;
        /* Reset 100% width from main nav */
        display: inline-block !important;
        /* Reset block display */
        padding: 5px !important;
        font-weight: normal !important;
        border-bottom: none !important;
        /* Remove border from main nav */
    }


    /* Toggle Button Details */
    .ym-mobile-menu-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
        z-index: 1001;
        margin: 0;
        padding: 0;
        line-height: 0;
        height: 40px;
        width: 40px;
    }

    /* Hide Header Ad on Mobile */
    .ym-header-ad-slot {
        display: none !important;
    }

    /* Force Vertical Center Alignment in Header */
    .ym-header-flex-container {
        flex-wrap: nowrap !important;
        align-items: center !important;
        min-height: 60px;
    }

    .ym-header-brand {
        flex-grow: 1;
    }

    /* Off-Canvas Drawer (Sheets) - Right to Left */
    body .ym-main-nav-wrapper {
        display: flex !important;
        position: fixed !important;
        /* Force fixed */
        top: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        /* Ensure stretches to bottom */
        height: 100vh !important;
        height: 100dvh !important;
        /* Mobile viewport support */
        width: 85% !important;
        max-width: 320px !important;
        background: #ffffff !important;
        z-index: 999999 !important;
        /* Super high Z-Index */
        flex-direction: column;
        align-items: flex-start !important;
        padding: 24px;
        margin: 0 !important;

        /* Animation: Slide In from Right */
        transform: translateX(100%);
        visibility: hidden;
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), visibility 0.3s;
        box-shadow: -5px 0 25px rgba(0, 0, 0, 0.15);
    }

    /* Close Button Styles */
    .ym-mobile-menu-close {
        display: flex;
        align-self: flex-end;
        /* Align to right */
        background: none;
        border: none;
        padding: 8px;
        cursor: pointer;
        color: #64748b;
        margin-bottom: 20px;
        margin-right: -8px;
        /* Align visually with padding */
    }

    .ym-mobile-menu-close .dashicons {
        font-size: 24px;
        width: 24px;
        height: 24px;
    }

    /* Mobile Menu ACTIVE State */
    .ym-main-nav-wrapper.is-active {
        transform: translateX(0);
        visibility: visible;
    }

    /* UL Styling for Mobile */
    .ym-nav-menu {
        flex-direction: column;
        width: 100%;
        gap: 0;
    }

    .ym-nav-menu li {
        width: 100%;
        border-bottom: 1px solid #f1f5f9;
        display: flex !important;
        /* Force flex */
        flex-wrap: wrap;
        align-items: center;
        justify-content: space-between;
        position: relative;
    }

    /* Remove old CSS arrows */
    .ym-nav-menu .menu-item-has-children>a:before {
        display: none !important;
    }

    /* Submenu Toggle Button */
    .ym-submenu-toggle {
        width: 44px;
        height: 44px;
        /* Touch target */
        display: flex;
        align-items: center;
        justify-content: center;
        background: none;
        border: none;
        border-left: 1px solid #f8fafc;
        /* Subtle separator */
        color: #64748b;
        cursor: pointer;
    }

    .ym-nav-menu li:last-child {
        border-bottom: none;
    }

    .ym-nav-menu>li>a {
        flex-grow: 1;
        /* Take remaining space */
        width: auto !important;
        /* Let flex handle it */
        padding: 16px 0;
        font-size: 18px;
        font-weight: 500;
        color: #0f172a;
    }

    /* Mobile Submenus - Reset Desktop Styles */
    .ym-nav-menu .sub-menu {
        position: static !important;
        /* Force flow layout */
        box-shadow: none !important;
        /* Remove desktop popup shadow */
        transform: none !important;
        /* Remove desktop default transform */
        opacity: 1 !important;
        /* Remove desktop invisible state */
        visibility: visible !important;
        /* Remove desktop invisible state */
        background: #f8fafc !important;
        /* Slightly different bg for nesting context */
        border: none !important;
        border-top: 1px solid #e2e8f0 !important;
        border-radius: 0 !important;

        width: 100%;
        flex-basis: 100%;
        padding: 0;
        margin: 0;
        display: none;
        /* Controlled by JS toggle */
    }

    /* Invisible bridge kill */
    .ym-nav-menu .sub-menu:before {
        display: none !important;
    }

    /* Show when open */
    .ym-nav-menu li.menu-item-has-children.menu-open>.sub-menu {
        display: block !important;
        /* Ensure it overrides any hidden state */
    }

    .ym-nav-menu .sub-menu a {
        padding: 12px 16px 12px 24px;
        /* More left padding for hierarchy */
        font-size: 15px;
        color: #64748b;
        display: block;
        width: 100%;
        border-bottom: 1px solid #f1f5f9;
        font-weight: 400;
        /* Lighter weight than parents */
    }

    .ym-nav-menu .sub-menu li:last-child a {
        border-bottom: none;
    }
}

@keyframes ymSlideDown {
    from {
        opacity: 0;
        transform: translateY(-5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}