/**
 * Menu Navigation Styles - CORRECTED VERSION
 * 
 * @package Blocksy_Child
 * 
 * CHANGES:
 * 1. Fixed CSS variables: --brand-* → --theme-palette-color-*
 * 2. Added admin bar offset for mobile menu (when logged in)
 */

/* ============================================
   DESKTOP NAVIGATION (≥690px)
   ============================================ */

.main-navigation {
    display: none;
    align-items: center;
    height: 100%;
}

.nav-menu {
    display: flex;
    list-style: none;
    margin: 0;
    padding: 0;
    gap: 3px;
    align-items: center;
}

.menu-item {
    position: relative;
    display: flex;
    align-items: center;
}

.menu-item a {
    display: flex;
    align-items: center;
    height: 100%;
    padding: 8px;
    font-family: var(--font-condensed);
    font-size: 16px;
    font-weight: 500;
    color: var(--theme-palette-color-3); /* Brand Secondary */
    text-decoration: none;
    transition: color 0.3s ease;
    white-space: nowrap;
}

.menu-item a:hover {
    color: var(--theme-palette-color-1); /* Brand Primary */
}

/* Active menu item styles */
.menu-item.current-menu-item > a,
.menu-item.current-menu-ancestor > a {
    color: var(--theme-palette-color-1); /* Brand Primary */
}

/* Dropdown indicator (chevron down, changes to X on open) */
.menu-item-has-children > a::after {
    content: '';
    display: inline-block;
    width: 12px;
    height: 12px;
    margin-left: 0.5rem;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' stroke='currentColor' viewBox='0 0 24 24'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'/%3E%3C/svg%3E");
    background-size: contain;
    background-repeat: no-repeat;
    transition: all 0.3s ease;
}

/* Dropdown Menu */
.sub-menu {
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 200px;
    background: white;
    list-style: none;
    padding: 0;
    margin: 0;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: opacity 0.3s ease, transform 0.3s ease, visibility 0.3s ease;
    z-index: 100;
}

/* Show submenu on hover OR when parent has .is-open class (click) */
.menu-item-has-children:hover .sub-menu,
.menu-item-has-children.is-open .sub-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* Right-align submenu ONLY for last menu item to prevent overflow */
.nav-menu > .menu-item:last-child .sub-menu {
    left: auto;
    right: 0;
}

/* Show X icon when dropdown is open (hover OR click) */
.menu-item-has-children:hover > a::after,
.menu-item-has-children.is-open > a::after {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' stroke='currentColor' viewBox='0 0 24 24'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M6 18L18 6M6 6l12 12'/%3E%3C/svg%3E");
}

.sub-menu .menu-item {
    display: block;
}

.sub-menu .menu-item a {
    display: block;
    padding: 0.75rem 1.5rem;
    font-size: 16px;
    color: var(--theme-palette-color-3); /* Brand Secondary */
    text-decoration: none;
    transition: background-color 0.2s ease, color 0.2s ease;
    height: auto;
}

.sub-menu .menu-item a:hover {
    background-color: #f8f8f8;
    color: var(--theme-palette-color-1); /* Brand Primary */
}

/* Active submenu item */
.sub-menu .menu-item.current-menu-item a {
    background-color: var(--theme-palette-color-1); /* Brand Primary */
    color: white;
}

/* ============================================
   HAMBURGER TOGGLE (Mobile Only)
   ============================================ */

.hamburger-toggle {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    color: var(--theme-palette-color-1); /* Brand Primary */
    transition: color 0.3s ease;
}

.hamburger-toggle:hover {
    color: var(--theme-palette-color-2); /* Brand Primary Dark */
}

.hamburger-icon {
    width: 32px;
    height: 32px;
}

/* ============================================
   MOBILE MENU OVERLAY & SIDEBAR
   ============================================ */

/* Overlay */
.mobile-menu-overlay {
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 40;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.mobile-menu-overlay.is-open {
    opacity: 1;
    pointer-events: auto;
}

/* Sidebar Drawer */
.mobile-menu-sidebar {
    position: fixed;
    top: 0;
    right: 0;
    width: 280px;
    height: 100%;
    background-color: var(--theme-palette-color-3); /* Brand Secondary */
    z-index: 50;
    transform: translateX(100%);
    transition: transform 0.3s ease;
    overflow-y: auto;
}

.mobile-menu-sidebar.is-open {
    transform: translateX(0);
}

/* Admin bar offset for mobile menu */
.admin-bar .mobile-menu-sidebar {
    top: 32px;
    height: calc(100% - 32px);
}

/* Admin bar offset for mobile (when < 783px WP admin bar changes height) */
@media screen and (max-width: 782px) {
    .admin-bar .mobile-menu-sidebar {
        top: 46px;
        height: calc(100% - 46px);
    }
}

/* Close Button - OUTSIDE sidebar, fixed position */
.mobile-menu-close {
    position: fixed;
    top: 0;
    right: 280px;
    width: 48px;
    height: 48px;
    background-color: var(--theme-palette-color-3); /* Brand Secondary */
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    z-index: 51;
}

.mobile-menu-close.is-visible {
    opacity: 1;
    pointer-events: auto;
}

.mobile-menu-close svg {
    width: 24px;
    height: 24px;
}

/* Admin bar offset for close button */
.admin-bar .mobile-menu-close {
    top: 32px;
}

@media screen and (max-width: 782px) {
    .admin-bar .mobile-menu-close {
        top: 46px;
    }
}

/* Mobile Menu Content */
.mobile-menu-content {
    padding: 20px;
}

.mobile-nav-menu {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0;
}

.mobile-nav-menu > .menu-item {
    margin-bottom: 0;
    display: block;
    width: 100%;
}

.mobile-nav-menu .menu-item > a,
.mobile-nav-menu .menu-item > button {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 0.75rem 1rem;
    font-family: var(--font-condensed);
    font-size: 16px;
    font-weight: 500;
    color: #cccccc;
    text-decoration: none;
    transition: background-color 0.2s ease, color 0.2s ease;
    border-radius: 0;
    background: none;
    border: none;
    text-align: left;
    cursor: pointer;
}

.mobile-nav-menu .menu-item > a:hover,
.mobile-nav-menu .menu-item > button:hover {
    background-color: rgba(227, 10, 108, 0.2);
    color: white;
}

/* Active parent item in mobile */
.mobile-nav-menu .menu-item.current-menu-ancestor > button,
.mobile-nav-menu .menu-item.current-menu-item > a {
    color: var(--theme-palette-color-1); /* Brand Primary */
    font-weight: 600;
}

/* Mobile menu toggle button with chevron */
.mobile-menu-toggle {
    position: relative;
}

.chevron-icon {
    width: 16px;
    height: 16px;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

/* Mobile Submenu - Hidden by default */
.mobile-nav-menu .sub-menu {
    position: static;
    display: block;
    width: 100%;
    opacity: 1;
    visibility: visible;
    transform: none;
    box-shadow: none;
    background: none;
    padding: 0;
    margin: 0;
    list-style: none;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.mobile-nav-menu .menu-item-has-children.is-open .sub-menu {
    max-height: 500px;
}

.mobile-nav-menu .sub-menu .menu-item {
    margin: 0;
    display: block;
    width: 100%;
}

.mobile-nav-menu .sub-menu .menu-item a {
    display: block;
    font-size: 16px;
    padding: 0.5rem 1rem 0.5rem 2.5rem;
    color: #cccccc;
    font-weight: 500;
    text-align: left;
    position: relative;
}

.mobile-nav-menu .sub-menu .menu-item a:hover {
    background-color: rgba(227, 10, 108, 0.2);
    color: white;
}

/* Active submenu item in mobile */
.mobile-nav-menu .sub-menu .menu-item.current-menu-item a {
    background-color: var(--theme-palette-color-1); /* Brand Primary */
    color: white;
    font-weight: 600;
}

/* Submenu chevron icon - absolute positioned on left */
.submenu-icon {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    width: 14px;
    height: 14px;
    flex-shrink: 0;
    opacity: 0.7;
    transition: opacity 0.2s ease, color 0.2s ease;
    color: inherit;
}

/* Chevron changes color on hover */
.mobile-nav-menu .sub-menu .menu-item a:hover .submenu-icon {
    opacity: 1;
    color: inherit;
}

/* Active item - icon inherits white color */
.mobile-nav-menu .sub-menu .menu-item.current-menu-item a .submenu-icon {
    opacity: 1;
    color: inherit;
}

/* ============================================
   SHOW DESKTOP NAV (≥690px)
   ============================================ */

@media (min-width: 690px) {
    .main-navigation {
        display: flex;
    }

    .hamburger-toggle {
        display: none;
    }
}

/* ============================================
   RESPONSIVE - MOBILE (<690px)
   ============================================ */

@media (max-width: 689px) {
    .main-header-container {
        padding-right: 12px;
    }
}