header {
    --header-height: 100px;
    position: sticky; top: 0;
    background: linear-gradient(#FEF3DE, #FEF3DEaa 54%);
    backdrop-filter: blur(8px);
    box-shadow: 0 1px 0px 0px #3332;
    z-index: 100;
    width: 100%;
    transition: 
        transform 0.4s ease-in-out,
        background 0.4s ease-in-out,
        backdrop-filter 0.4s ease-in-out,
        box-shadow 0.4s ease-in-out;
    height: var(--header-height); 
    margin-bottom: calc( -1 * var(--header-height) );
    color: #425B63;

    display: flex;
    justify-content: space-between;
    align-items: center;
    > .wp-block-group { 
        width: 100%;
        > .wp-block-group { 
            width: 100%;
            > * { display: flex; width: 50%; }
            > :nth-child(1) { justify-content: left; }
            > :nth-child(2) { justify-content: center; max-width: fit-content; }
            > :nth-child(3) { justify-content: end; }
            * { text-wrap: nowrap; }
        }
    }
    img.custom-logo {
        height: 80px;
        width: auto;
        filter: none;
        transition: opacity 0.4s ease-in-out;
    }
    &::before {
        content:''; display: block;
        position: absolute; top: 0; left: 0;
        width: 100%; height: 142%; 
        background: linear-gradient(#0000, #0000);
        transition: all 0.4s ease-in-out;
        pointer-events: none; user-select: none;
    }

    &.at-top {
        background: #fff0;
        color: var(--wp--preset--color--cream);
        backdrop-filter: blur(0px);
        box-shadow: 0 1px 0px 0px #0000;
        &::before { opacity: 1; background: linear-gradient( hsl(from var(--wp--preset--color--teal) h s calc(l - 16) / 0.8), hsl(from var(--wp--preset--color--teal) h s calc(l - 16) / 0)); }

        .wp-block-buttons .wp-block-button:nth-child(1) .wp-element-button { background: rgb(from #5B7755 r g b / 64%); }
    }

    .wp-block-buttons .wp-block-button:nth-child(1) .wp-element-button { 
        background: rgb(from #5B7755 r g b / 84%);
        color:  var(--wp--preset--color--cream);
        &:hover{ 
            background: rgb(from var(--wp--preset--color--teal) r g b / 100%);
            border: 1px solid var(--wp--preset--color--cream); 
        }
    }

    ul.wp-block-navigation__submenu-container {
        top: 54px !important;
        > li a {
            white-space: nowrap;
            &:hover { background: #0002; }
            border-bottom: 1px solid #0001;
        }
    }
    nav ul { gap: 0.42em 1.64em !important; }
    nav li.wp-block-navigation-item.wp-block-navigation-link a { display: block; position: relative; }
    nav li.wp-block-navigation-item.wp-block-navigation-link a::before { content:''; position: absolute; display: block; width: 0%; height: 1px; background: var(--wp--preset--color--teal); bottom: 0; left: 0; transition: all 0.2s ease-in-out; }
    &.at-top nav li.wp-block-navigation-item.wp-block-navigation-link a::before { background: var(--wp--preset--color--cream); }
    nav li.wp-block-navigation-item.wp-block-navigation-link a:hover::before,
    nav li.wp-block-navigation-item.wp-block-navigation-link.current-menu-item a::before { width: 100%; }
}
@media screen and (max-width: 1200px) {
    header ul.wp-block-navigation__container.wp-block-navigation { display: none; }
    header .has-modal-open.is-menu-open ul.wp-block-navigation__container.wp-block-navigation { display: block; }
    nav li.wp-block-navigation-item.wp-block-navigation-link a::before { display: none; height: 0px; }
}
.wp-block-navigation__responsive-container-open svg { width: 32px; height: 32px; }


/* Full-screen navigation. Keep the core dialog and keyboard behavior intact. */
header:has(.wp-block-navigation__responsive-container.is-menu-open),
header.has-mobile-menu-open {
    backdrop-filter: none;
    transform: none;
    z-index: 100001;
    transition: none;
}
header .wp-block-navigation__responsive-container-open {
    min-width: 48px;
    min-height: 48px;
    align-items: center;
    justify-content: center;
}
header .willows-menu-brand,
header .willows-menu-actions { display: none; }
header .wp-block-navigation .wp-block-navigation__responsive-container.is-menu-open {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100vh;
    height: 100dvh;
    max-height: none;
    box-sizing: border-box;
    overflow-y: auto;
    overscroll-behavior: contain;
    background: var(--wp--preset--color--cream, #fef3de);
    color: var(--wp--preset--color--teal, #425b63);
    padding: max(20px, env(safe-area-inset-top)) max(24px, env(safe-area-inset-right)) max(32px, env(safe-area-inset-bottom)) max(24px, env(safe-area-inset-left));
}
header .wp-block-navigation .wp-block-navigation__responsive-container.is-menu-open .wp-block-navigation__responsive-close {
    width: 100%;
    max-width: 560px;
    margin: 0 auto;
}
header .wp-block-navigation .wp-block-navigation__responsive-container.is-menu-open .wp-block-navigation__responsive-dialog {
    position: relative;
    margin-top: 0;
}
header .wp-block-navigation .wp-block-navigation__responsive-container.is-menu-open .wp-block-navigation__responsive-container-close {
    top: 0;
    right: 0;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    padding: 12px;
    border: 1px solid rgba(66, 91, 99, .25);
    border-radius: 50%;
    color: inherit;
    background: transparent;
}
header .wp-block-navigation .wp-block-navigation__responsive-container.is-menu-open .willows-menu-brand {
    display: flex;
    justify-content: center;
    margin: 0 56px;
    padding: 16px 0 32px;
}
header .wp-block-navigation .wp-block-navigation__responsive-container.is-menu-open .willows-menu-brand a {
    display: inline-flex;
    justify-content: center;
    max-width: 100%;
}
header .wp-block-navigation .wp-block-navigation__responsive-container.is-menu-open .willows-menu-brand img.custom-logo {
    display: block;
    width: 160px;
    height: auto;
    max-width: 100%;
    max-height: 110px;
    object-fit: contain;
    filter: none;
    transition: none;
}
header .wp-block-navigation .wp-block-navigation__responsive-container.is-menu-open .wp-block-navigation__responsive-container-content {
    padding-top: 24px;
    align-items: stretch;
    gap: 32px;
}
header .wp-block-navigation .wp-block-navigation__responsive-container.is-menu-open :is(.wp-block-navigation__container, .wp-block-page-list) {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    width: 100%;
    gap: 0;
    margin: 0;
    padding: 0;
    list-style: none;
}
header .wp-block-navigation .wp-block-navigation__responsive-container.is-menu-open .wp-block-navigation-item {
    width: 100%;
    align-items: stretch;
    gap: 0;
}
header .wp-block-navigation .wp-block-navigation__responsive-container.is-menu-open .wp-block-navigation-item__content {
    display: block;
    width: 100%;
    box-sizing: border-box;
    min-height: 56px;
    padding: 16px 12px;
    border-bottom: 1px solid rgba(66, 91, 99, .2);
    background: transparent;
    color: inherit;
    text-align: left;
    text-decoration: none;
    white-space: normal;
    text-wrap: wrap;
    overflow-wrap: anywhere;
    font-family: "freight-neo-pro", sans-serif;
    font-size: clamp(1.5rem, 5vw, 2rem);
    font-weight: 500;
    line-height: 1.2;
    letter-spacing: 0;
    text-transform: none;
}
header .wp-block-navigation .wp-block-navigation__responsive-container.is-menu-open .wp-block-navigation-item__content:hover,
header .wp-block-navigation .wp-block-navigation__responsive-container.is-menu-open .wp-block-navigation-item__content[aria-current="page"] {
    background: rgba(66, 91, 99, .07);
}
header .wp-block-navigation .wp-block-navigation__responsive-container.is-menu-open .wp-block-navigation-item__content[aria-current="page"] {
    box-shadow: inset 3px 0 currentColor;
}
header .wp-block-navigation .wp-block-navigation__responsive-container.is-menu-open ul.wp-block-navigation__submenu-container {
    top: auto !important;
    width: 100%;
    padding: 0 0 12px 20px;
    box-sizing: border-box;
    border: 0;
}
header .wp-block-navigation .wp-block-navigation__responsive-container.is-menu-open .wp-block-navigation__submenu-container .wp-block-navigation-item__content {
    font-family: "PT Sans", sans-serif;
    font-size: 1.125rem;
    min-height: 48px;
    padding: 12px;
}
header .wp-block-navigation .wp-block-navigation__responsive-container.is-menu-open .willows-menu-actions {
    display: grid;
    width: 100%;
    gap: 12px;
    padding-top: 32px;
}
/* Hide mirrored actions in desktop navigation; keep native button styles. */
header .willows-menu-actions { display: none; }
header .wp-block-navigation .wp-block-navigation__responsive-container.is-menu-open .willows-menu-actions .wp-block-button {
    width: 100%;
    margin: 0;
}
header .wp-block-navigation .wp-block-navigation__responsive-container.is-menu-open .willows-menu-actions .wp-block-button__link {
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    width: 100%;
    min-height: 48px;
    font-family: "PT Sans", sans-serif;
}
header .wp-block-navigation .wp-block-navigation__responsive-container.is-menu-open :is(a, button):focus-visible {
    outline: 2px solid currentColor;
    outline-offset: 4px;
}
header.has-mobile-menu-open .wp-block-site-logo { visibility: hidden; }
body.admin-bar header .wp-block-navigation .wp-block-navigation__responsive-container.is-menu-open {
    top: 32px;
    height: calc(100dvh - 32px);
}
@media (max-width: 782px) {
    body.admin-bar header .wp-block-navigation .wp-block-navigation__responsive-container.is-menu-open {
        top: 46px;
        height: calc(100dvh - 46px);
    }
}
/* Initial at-top setup should not animate from the default header appearance. */
header:not(.header-transitions-ready),
header:not(.header-transitions-ready)::before,
header:not(.header-transitions-ready)::after,
header:not(.header-transitions-ready) *,
header:not(.header-transitions-ready) *::before,
header:not(.header-transitions-ready) *::after {
    transition: none !important;
}
@media (prefers-reduced-motion: reduce) {
    header, header img.custom-logo { transition: none; }
}

@media screen and (max-width: 1200px) {
    header > .wp-block-group > .wp-block-group { 
        flex-direction: row-reverse; 
        > nav:nth-child(1) { justify-content: right; }
        > :nth-child(3) { display: none; }
    }
}
/* Match the specificity of the core overlay rules, including logged-in layouts. */
html.has-modal-open body.admin-bar header .wp-block-navigation .is-menu-open .wp-block-navigation__responsive-dialog { margin-top: 0; }
header .wp-block-navigation .is-menu-open .wp-block-navigation__responsive-container-content .has-child ul.wp-block-navigation__submenu-container {
    padding: 0 0 12px 20px;
    min-width: 0;
    width: 100%;
}
header .wp-block-navigation .is-menu-open .wp-block-navigation-item__label {
    white-space: normal;
    text-wrap: wrap;
}

/* Use the same mobile breakpoint as the header layout. */
@media (max-width: 1200px) {
    header .wp-block-navigation__responsive-container-open:not(.always-shown) { display: flex; }
    header .wp-block-navigation__responsive-container:not(.is-menu-open) { display: none; }
}


/* Exact theme cream over the logo alpha; fade back to the original artwork. */
header .custom-logo-link.willows-tinted-logo {
    position: relative;
    display: inline-block;
    line-height: 0;
}
header .willows-tinted-logo img.custom-logo { display: block; opacity: 1; }
header .willows-tinted-logo::after {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: var(--wp--preset--color--cream, #fef3de);
    -webkit-mask: var(--header-logo-mask) center / contain no-repeat;
    mask: var(--header-logo-mask) center / contain no-repeat;
    opacity: 0;
    transition: opacity .4s ease-in-out;
}
header.at-top .willows-tinted-logo img.custom-logo { opacity: 0; }
header.at-top .willows-tinted-logo::after { opacity: 1; }
@media (prefers-reduced-motion: reduce) {
    header .willows-tinted-logo::after { transition: none; }
}

/* Keep the desktop CTAs together; tablet layouts use the menu copies. */
@media (min-width: 1201px) {
    header > .wp-block-group > .wp-block-group > .wp-block-buttons {
        flex-wrap: nowrap;
    }
    header > .wp-block-group > .wp-block-group > .wp-block-buttons > .wp-block-button {
        flex-shrink: 0;
    }
}

/* Compact homepage branding on phones; retain the centered menu control. */
@media (max-width: 767px) {
    body.home header .wp-block-site-logo img.custom-logo {
        height: 60px;
        width: auto;
    }
}
