/* ========================================
   CUSTOM HEADER - CSS
   Save as: custom-header.css in your theme folder
   ======================================== */

/* SET BODY TO 2000PX MAX WIDTH */
html {
    overflow-x: hidden !important;
}

body {
    overflow-x: hidden !important;
    max-width: 2000px !important;
    width: 100% !important;
    margin: 0 auto !important;
    padding: 0 !important;
}

.site,
#page {
    overflow-x: hidden !important;
    max-width: 100% !important;
    width: 100% !important;
}

/* Override GeneratePress sticky navigation */
.main-navigation.sticky-navigation-transition,
.main-navigation.sticky-enabled {
    position: relative !important;
}

/* Sticky wrapper for middle + bottom bars */
.mh-header-sticky-wrapper {
    transition: box-shadow 0.3s ease;
}

.mh-header-sticky-wrapper.scrolled {
    box-shadow: none;
}

/* Fix parent overflow that breaks sticky positioning */
body, 
html,
body > *:not(.mh-custom-header),
.site,
.site-header {
    overflow-x: visible !important;
    overflow-y: visible !important;
}

.mh-custom-header {
    width: 100%;
    position: relative;
    z-index: 1000;
}

.mh-header-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* TOP BAR */
.mh-header-top-bar {
    padding: 10px 0;
    border-bottom: 1px solid #e0e0e0;
}

/* MIDDLE BAR */
.mh-header-middle-bar {
    display: flex;
    align-items: center;
}

.mh-header-middle-bar .mh-header-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    height: 100%;
}

.mh-header-branding {
    display: flex;
    align-items: center;
    gap: 15px;
}

.mh-header-logo img {
    max-height: 50px;
    width: auto;
    display: block;
}

.mh-header-site-title a {
    text-decoration: none;
    transition: opacity 0.3s;
}

.mh-header-site-title a:hover {
    opacity: 0.7;
}

.mh-header-right {
    display: flex;
    align-items: center;
    gap: 20px;
}

.mh-header-social {
    display: flex;
    align-items: center;
    gap: 15px;
}

.mh-social-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    transition: opacity 0.3s, transform 0.3s;
}

.mh-social-icon:hover {
    opacity: 0.7;
    transform: translateY(-2px);
}

.mh-social-icon i {
    display: block;
    line-height: 1;
}

.mh-header-search {
    display: flex;
    align-items: center;
    gap: 10px;
    position: relative;
}

.mh-search-icon {
    background: none;
    border: none;
    padding: 5px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.3s;
}

.mh-search-icon:hover {
    opacity: 0.7;
}

.mh-search-icon i {
    line-height: 1;
}

.mh-search-bar {
    display: none;
}

.mh-search-bar.active {
    display: block;
}

.mh-search-bar form {
    display: flex;
    align-items: center;
}

.mh-search-bar input[type="search"] {
    padding: 8px 12px;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    font-size: 14px;
    width: 200px;
}

/* BOTTOM BAR - STICKY NAVIGATION */
.mh-header-bottom-bar {
    position: sticky !important;
    top: 0 !important;
    z-index: 9999 !important;
    transition: box-shadow 0.3s ease;
}

.mh-header-bottom-bar.scrolled {
    box-shadow: none;
}

.mh-header-navigation {
    width: 100%;
}

.mh-nav-menu {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    align-items: center;
}

.mh-nav-menu > li {
    position: relative;
}

.mh-nav-menu > li > a {
    display: block;
    padding: 20px 0;
    text-decoration: none;
    transition: color 0.3s;
    position: relative;
}

.mh-nav-menu .sub-menu {
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 200px;
    list-style: none;
    margin: 0;
    padding: 10px 0;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: opacity 0.3s, transform 0.3s, visibility 0.3s;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    background: #fff;
    border: 1px solid #e0e0e0;
}

.mh-nav-menu > li:hover > .sub-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.mh-nav-menu .sub-menu li {
    position: relative;
}

.mh-nav-menu .sub-menu a {
    display: block;
    padding: 10px 20px;
    text-decoration: none;
    transition: background-color 0.3s, color 0.3s;
}

.mh-nav-menu .sub-menu a:hover {
    background-color: rgba(0, 0, 0, 0.05);
}

.mh-nav-menu .sub-menu .sub-menu {
    top: 0;
    left: 100%;
}

/* MOBILE HEADER */
.mh-header-mobile {
    display: none;
}

/* Force mobile header to be ready for sticky */
@media (max-width: 900px) {
    .mh-header-mobile {
        position: relative;
        width: 100%;
        z-index: 999;
    }
    
    /* When JavaScript makes it sticky, ensure it stays */
    .mh-header-mobile[style*="position: fixed"],
    .mh-header-mobile[style*="position:fixed"] {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        width: 100% !important;
        z-index: 99999 !important;
    }
    
    /* Keep spacer visible */
    .mobile-header-spacer {
        display: block !important;
        width: 100% !important;
    }
}

.mh-header-mobile .mh-header-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 100%;
    margin: 0 auto;
    width: 100%;
    padding: 0 20px;
}

.mh-header-mobile .mh-header-branding {
    display: flex;
    align-items: center;
    gap: 10px;
    /* Default: left aligned */
}

.mh-mobile-menu-toggle {
    background: none;
    border: none;
    padding: 5px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 4px;
    flex-shrink: 0;
    z-index: 10;
}

.mh-mobile-menu-toggle span {
    display: block;
    width: 100%;
    background-color: currentColor;
    transition: transform 0.3s, opacity 0.3s;
}

.mh-mobile-menu-toggle.active span:nth-child(1) {
    transform: translateY(calc(100% + 4px)) rotate(45deg);
}

.mh-mobile-menu-toggle.active span:nth-child(2) {
    opacity: 0;
}

.mh-mobile-menu-toggle.active span:nth-child(3) {
    transform: translateY(calc(-100% - 4px)) rotate(-45deg);
}

.mh-header-mobile-spacer {
    width: 30px;
}

.mh-mobile-menu {
    position: fixed;
    top: 0;
    right: -100%;
    width: 85%;
    max-width: 500px;
    height: 100vh;
    background-color: #fff;
    transition: right 0.3s ease;
    z-index: 9999;
    box-shadow: -2px 0 10px rgba(0, 0, 0, 0.1);
    display: none; /* Completely remove from layout when not active */
    flex-direction: column;
    overflow: hidden;
    pointer-events: none;
}

.mh-mobile-menu.active {
    right: 0;
    pointer-events: auto;
    display: flex; /* Show as flex when active */
}

.mh-mobile-menu-header {
    padding: 20px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    display: flex;
    justify-content: flex-end;
    align-items: center;
    background-color: #fff;
    flex-shrink: 0;
}

.mh-mobile-menu-close {
    background: none;
    border: none;
    padding: 8px;
    cursor: pointer;
    font-size: 24px;
    line-height: 1;
    color: #000;
}

.mh-mobile-menu-close:hover {
    opacity: 0.7;
}

.mh-mobile-nav-menu {
    list-style: none;
    margin: 0;
    padding: 20px 0;
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.mh-mobile-nav-menu li {
    border-bottom: none;
}

.mh-mobile-nav-menu > li > a {
    display: block;
    padding: 18px 30px;
    text-decoration: none;
    transition: background-color 0.3s, color 0.3s;
}

/* Hide submenus in mobile */
.mh-mobile-nav-menu .sub-menu {
    display: none !important;
}

/* Mobile Menu Footer - Social & Search Icons */
.mh-mobile-menu-footer {
    padding: 25px 30px;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    gap: 20px;
    flex-shrink: 0;
    background-color: inherit;
}

.mh-mobile-menu-search {
    display: flex;
}

.mh-mobile-search-icon {
    background: none;
    border: none;
    padding: 8px;
    cursor: pointer;
    font-size: 20px;
    color: inherit;
    transition: opacity 0.3s;
}

.mh-mobile-search-icon:hover {
    opacity: 0.7;
}

.mh-mobile-menu-social {
    display: flex;
    align-items: center;
    gap: 15px;
    flex: 1;
}

.mh-mobile-social-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    font-size: 20px;
    color: inherit;
    transition: opacity 0.3s;
}

.mh-mobile-social-icon:hover {
    opacity: 0.7;
}

/* Mobile Search Overlay */
.mh-mobile-search-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.95);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    padding: 20px;
}

.mh-mobile-search-overlay.active {
    display: flex;
}

.mh-mobile-search-container {
    width: 100%;
    max-width: 600px;
    position: relative;
}

.mh-mobile-search-form {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.mh-mobile-search-form input[type="search"] {
    flex: 1;
    padding: 15px 20px;
    border: 2px solid #fff;
    background-color: transparent;
    color: #fff;
    font-size: 18px;
    border-radius: 4px;
}

.mh-mobile-search-form input[type="search"]::placeholder {
    color: rgba(255, 255, 255, 0.6);
}

.mh-mobile-search-form input[type="search"]:focus {
    outline: none;
    border-color: #fff;
}

.mh-mobile-search-submit {
    padding: 15px 25px;
    background-color: #fff;
    color: #000;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 18px;
}

.mh-mobile-search-submit:hover {
    opacity: 0.9;
}

.mh-mobile-search-close {
    position: absolute;
    top: -50px;
    right: 0;
    background: none;
    border: none;
    color: #fff;
    font-size: 30px;
    cursor: pointer;
    padding: 10px;
}

.mh-mobile-search-close:hover {
    opacity: 0.7;
}

/* Mobile menu overlay */
.mh-mobile-menu-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.5);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
    z-index: 9998;
    pointer-events: none;
}

.mh-mobile-menu-overlay.active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

/* RESPONSIVE */
@media (max-width: 900px) {
    .mh-header-top-bar,
    .mh-header-middle-bar,
    .mh-header-bottom-bar {
        display: none !important;
    }
    
    .mh-header-mobile {
        display: flex;
    }
    
    .mh-header-mobile .mh-header-logo img {
        max-height: 40px;
    }
    
    .mh-header-mobile .mh-header-site-title a {
        font-size: 18px;
    }
}

@media (max-width: 600px) {
    .mh-header-container {
        padding: 0 15px;
    }
    
    .mh-header-mobile .mh-header-logo img {
        max-height: 35px;
    }
    
    .mh-header-mobile .mh-header-site-title a {
        font-size: 16px;
    }
}

.mh-custom-header * {
    box-sizing: border-box;
}

.mh-custom-header a {
    color: inherit;
}

.mh-custom-header button {
    font-family: inherit;
    color: inherit;
}

.mh-custom-header button:focus,
.mh-custom-header a:focus {
    outline: 2px solid #0066cc;
    outline-offset: 2px;
}

@media print {
    .mh-custom-header {
        display: none;
    }
}