/* Custom Header Block Styles */
.header-custom {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--wp--preset--spacing--s, 1rem);
    width: 100%;
    position: relative;
}

/* Logo Section */
.header-custom__logo {
    flex-shrink: 0;
    z-index: 1;
    height: var(--logo-height, 48px);
    display: flex;
    align-items: center;
}

.header-custom__logo a {
    display: flex;
    align-items: center;
    height: 100%;
    line-height: 0;
}

.header-custom__logo img {
    display: block;
    height: 100%;
    width: auto;
}

/* SVG logo styling */
.header-custom__logo svg {
    display: block;
    height: 100%;
    width: auto;
    fill: var(--wp--preset--color--contrast, #000);
}

/* Center Menu Section */
.header-custom__center {
    flex: 1 1 auto;
    display: none;
}

.header-custom__menu {
    display: flex;
    justify-content: flex-end;
    margin: auto;
}

/* Menu styles matching custom-menu behavior */
.header-custom__menu ul,
.header-custom__menu ul.menu {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    align-items: center;
    gap: 0.25rem;
    flex-wrap: wrap;
}

.header-custom__menu li {
    margin: 0;
    position: relative;
}

.header-custom__menu a {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: var(--wp--preset--spacing--xs) var(--wp--preset--spacing--s);
    text-decoration: none;
    color: var(--wp--preset--color--contrast, #000);
    transition: color 0.2s ease;
}

.header-custom__menu a:hover,
.header-custom__menu a:focus {
    color: var(--wp--preset--color--primary, #0073aa);
}

/* Current menu item styling */
.header-custom__menu .current-menu-item>a,
.header-custom__menu .current_page_item>a,
.header-custom__menu .current-menu-ancestor>a {
    color: var(--wp--preset--color--primary, #0073aa);
    font-weight: 600;
}

/* Menu item icons */
.header-custom__menu .menu-item-icon {
    display: inline-flex;
    align-items: center;
    flex-shrink: 0;
}

.header-custom__menu .menu-item-icon svg {
    width: 1.25rem;
    height: 1.25rem;
    stroke: currentColor;
    fill: none;
    stroke-width: 1.5;
}

/* CTA styling */
.header-custom__menu .is-cta>a {
    background-color: var(--wp--preset--color--primary, #0073aa);
    color: var(--wp--preset--color--base, #fff);
    border-radius: 0.25rem;
    font-weight: 600;
    padding: var(--wp--preset--spacing--xs) var(--wp--preset--spacing--m);
    transition: opacity 0.2s ease;
}

.header-custom__menu .is-cta>a:hover,
.header-custom__menu .is-cta>a:focus {
    opacity: 0.9;
}

/* Submenu styles */
.header-custom__menu .sub-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    text-align: left;
    min-width: 200px;
    background-color: var(--wp--preset--color--base, #fff);
    border: 1px solid var(--wp--preset--color--border, rgba(0, 0, 0, 0.1));
    border-radius: 0.25rem;
    box-shadow: 0px 1px 1px 0px rgba(0, 0, 0, 0.1);
    z-index: 100;
    opacity: 0;
    flex-direction: column;
}

.header-custom__menu li:hover>.sub-menu,
.header-custom__menu li:focus-within>.sub-menu {
    display: flex;
    opacity: 1;
}

.header-custom__menu .sub-menu li {
    display: block;
    width: 100%;
}

.header-custom__menu .sub-menu a {
    display: block;
    padding: 0.5rem 0.75rem;
    white-space: nowrap;
}

/* Chevron indicator for items with submenus */
.header-custom__menu .menu-item-has-children>a::after {
    content: "";
    display: inline-block;
    width: 0;
    height: 0;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-top: 4px solid currentColor;
    vertical-align: middle;
}

/* Right Section */
.header-custom__right {
    display: flex;
    align-items: center;
    gap: var(--wp--preset--spacing--xs, 0.33rem);
    flex-shrink: 0;
}

/* Social Icons */
.header-custom__social {
    display: none;
    align-items: center;
    gap: var(--wp--preset--spacing--xs, 0.33rem);
}

.header-custom__social a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--wp--preset--color--contrast, #000);
    transition: color 0.2s ease-in;
}

.header-custom__social a:hover,
.header-custom__social a:focus {
    color: var(--wp--preset--color--primary, #0066ff);
}

.header-custom__social svg {
    width: 1.5rem;
    height: 1.5rem;
    fill: currentColor;
}

/* Light/Dark Toggle */
.header-custom__theme-toggle {
    background: none;
    border: none;
    cursor: pointer;
    padding: var(--wp--preset--spacing--xs, 0.33rem);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--wp--preset--color--contrast, #000);
    transition: color 0.2s ease-in;
}

.header-custom__theme-toggle:hover,
.header-custom__theme-toggle:focus {
    color: var(--wp--preset--color--primary, #0066ff);
}

.header-custom__theme-toggle svg {
    width: 1.5rem;
    height: 1.5rem;
    stroke-width: 2;
}

/* Icon switching based on theme */
.header-custom__theme-toggle .theme-icon--sun {
    margin-top: 2px;
    display: none;
}

.header-custom__theme-toggle .theme-icon--moon {
    margin-top: 2px;
    display: block;
}

:root[data-theme="dark"] .header-custom__theme-toggle .theme-icon--sun {
    margin-top: 2px;
    display: block;
}

:root[data-theme="dark"] .header-custom__theme-toggle .theme-icon--moon {
    margin-top: 2px;
    display: none;
}

/* Mobile Menu Toggle */
.header-custom__toggle {
    background: none;
    border: none;
    cursor: pointer;
    font: inherit;
    display: inline-flex;
    align-items: center;
    /* gap: var(--wp--preset--spacing--xs, 0.33rem);
    padding: var(--wp--preset--spacing--xs, 0.33rem); */
    color: var(--wp--preset--color--contrast, #000);
}

.header-custom__toggle {
    transition: color 0.2s ease-in;
}

.header-custom__toggle:hover,
.header-custom__toggle:focus {
    color: var(--wp--preset--color--primary, #0066ff);
}

/* Mobile menu label (left of hamburger) */
.header-custom__toggle-label {
    font-size: 1.25rem;
    font-weight: 800;
    text-transform: uppercase;
    line-height: 1;
}

@media (min-width: 768px) {
    .header-custom:not(.force-mobile) .header-custom__toggle-label {
        display: none;

    }
}

/* Hamburger icon (bars-3) */
.header-custom__toggle svg {
    width: 1.75rem;
    height: 1.75rem;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    padding-left: var(--wp--preset--spacing--xs, 0.33rem);
}

/* Mobile Menu Overlay */
.header-custom__mobile-menu {
    position: fixed;
    top: 0;
    right: 0;
    width: 85vw;
    max-width: 400px;
    height: 100vh;
    background-color: var(--wp--preset--color--panel, #fff);
    transform: translateX(100%);
    transition: transform 0.3s ease;
    overflow-y: auto;
    z-index: 10000;
    padding: 4rem 1rem 1rem;
}

.header-custom.is-open .header-custom__mobile-menu {
    transform: translateX(0);
}

/* Close button */
.header-custom__close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: none;
    border: none;
    cursor: pointer;
    padding: var(--wp--preset--spacing--xs, 0.33rem);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--wp--preset--color--contrast, #000);
    transition: color 0.2s ease-in;
    z-index: 10001;
}

.header-custom__close:hover,
.header-custom__close:focus {
    color: var(--wp--preset--color--primary, #0066ff);
}

.header-custom__close svg {
    width: 1.5rem;
    height: 1.5rem;
}

/* Mobile menu list */
.header-custom__mobile-menu ul,
.header-custom__mobile-menu ul.menu {
    list-style: none;
    margin: 0;
    padding: 0;
}

.header-custom__mobile-menu li {
    margin: 0;
}

.header-custom__mobile-menu a {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    text-decoration: none;
    color: var(--wp--preset--color--contrast, #000);
    border-bottom: 1px solid var(--wp--preset--color--border, rgba(0, 0, 0, 0.1));
}

.header-custom__mobile-menu a:hover,
.header-custom__mobile-menu a:focus {
    color: var(--wp--preset--color--primary, #0073aa);
    background-color: var(--wp--preset--color--panel);
}

.header-custom__mobile-menu .sub-menu a {
    padding-left: var(--wp--preset--spacing--m);
}

/* Mobile CTA */
.header-custom__mobile-menu .is-cta>a {
    display: block;
    text-align: center;
    padding: 0.75rem 1.25rem;
    background-color: var(--wp--preset--color--primary, #0073aa);
    color: var(--wp--preset--color--base, #fff);
    border-radius: 0.25rem;
    font-weight: 600;
    margin: 1rem;
    border-bottom: none;
}

/* Force Mobile Mode */
.header-custom.force-mobile .header-custom__center {
    display: none;
}

.header-custom.force-mobile .header-custom__social {
    display: none;
}

.header-custom.force-mobile .header-custom__toggle {
    display: inline-flex;
    font-weight: 600;
    color: var(--wp--preset--color--contrast);
    transition: color 0.2s ease;
}

.header-custom.force-mobile .header-custom__toggle:hover {
    color: var(--wp--preset--color--primary);
}

.header-custom.force-mobile .header-custom__mobile-menu {
    display: block;
}

/* Desktop Styles */
@media (min-width: 768px) {

    /* Show center menu on desktop */
    .header-custom__center {
        display: flex;
    }

    /* Show social icons on desktop */
    .header-custom__social {
        display: flex;
    }

    /* Hide mobile toggle on desktop (unless forced) */
    .header-custom:not(.force-mobile) .header-custom__toggle {
        display: none;
    }

    /* Hide mobile menu on desktop (unless forced) */
    .header-custom:not(.force-mobile) .header-custom__mobile-menu {
        display: none;
    }

    /* Force mobile with desktop modal behavior */
    .header-custom.force-mobile.is-forced-mobile-desktop .header-custom__mobile-menu {
        /* Hide completely when closed - removes from layout and screen readers */
        display: none;
    }

    .header-custom.force-mobile.is-forced-mobile-desktop.is-open .header-custom__mobile-menu {
        /* Show when open with modal positioning */
        display: block;
        /* Reset side drawer positioning */
        width: 90vw;
        max-width: 600px;
        height: auto;
        max-height: 80vh;
        top: 50%;
        left: 50%;
        right: auto;
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
        border-radius: 0.25rem;
    }

    /* Backdrop overlay */
    .header-custom.force-mobile.is-forced-mobile-desktop.is-open::before {
        content: "";
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background-color: rgba(0, 0, 0, 0.5);
        z-index: 9999;
    }

    .header-custom__close {
        display: inline-flex;
    }
}