/*header*/

.wp-site-blocks header {
    position: sticky;
    top: 0;
    z-index: 1000000;
}
.logged-in .wp-site-blocks header {
    top: 30px;
}

/*separator*/

.wp-block-separator.is-style-bmg-white-faint {
    border: none;
    border-bottom-width: 1px;
    opacity: 0.5;
}

/*search*/

/* Search lives in the flow, sized like the icon */
.header-search {
    position: relative;
    display: inline-flex;
    align-items: center;
}

/* hide label visually */
.header-search .wp-block-search__label {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    border: 0;
    clip: rect(0 0 0 0);
    overflow: hidden;
}

/* input is taken OUT of layout */
.header-search .wp-block-search__input {
    position: absolute;
    right: 100%; /* opens to the left of the icon */
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    opacity: 0;
    padding: 0;
    border: none;
    transition:
        width 0.25s ease,
        opacity 0.25s ease,
        padding 0.25s ease,
        border 0.25s ease;
    background: #ffffff;
    border-radius: 999px;
}

/* expand when focused */
.header-search:focus-within .wp-block-search__input {
    width: 230px;
    margin-right: 10px;
    opacity: 1;
    padding: 10px;
    border: none;
}

/* icon button */
.header-search .wp-block-search__button {
    position: relative;
    min-width: 2.25rem;
    min-height: 2.25rem;
    margin: 0;
    padding: 0;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    text-indent: -9999px; /* hide text */
    background: none;
}

/* magnifying glass */
.header-search .wp-block-search__button::before {
    content: "";
    display: block;
    width: 20px;
    height: 20px;
    filter: invert(97%) sepia(18%) saturate(1%) hue-rotate(156deg) brightness(105%) contrast(100%);
    background-repeat: no-repeat;
    background-position: center;
    background-size: contain;
    background-image: url("../../icons/search_icon.png");
}

.header-actions {
    display: flex;
    align-items: center;
}

/* Login stays on the left edge */
.header-actions__login {
    margin-right: auto; /* pushes everything else away */
}

/* Register hugs the right edge */
.header-actions__register {
    margin-left: auto; /* pushes itself to the far right */
}

/* Give the center icon some breathing room */
.header-search {
    margin-inline: 1.5rem; /* space between login and icon, icon and register */
}

/*navigation*/

.bmg-header-bottom-row ul.wp-block-navigation__container {
    row-gap: 20px;
}

.bmg-header-bottom-row .wp-block-navigation .wp-block-navigation__submenu-icon {
    width: 15px !important;
    height: 8px !important;
    margin-left: -5px !important;
    background-repeat: no-repeat;
    background-position: center;
    background-size: contain;
    background-image: url(../../icons/sub_menu_icon.png);
}

.bmg-header-bottom-row .wp-block-navigation .wp-block-navigation__submenu-icon svg {
    display: none !important;
}

/* ----------------- */
/* SCROLLED */

.bmg-header-top-row {
    max-height: 260px; /* safer buffer */
    overflow: hidden;
    transition:
        opacity 200ms ease,
        padding 260ms ease,
        max-height 160ms cubic-bezier(0.2, 0.8, 0.2, 1) 220ms;
}

.header-scrolled .bmg-header-top-row {
    max-height: 0;
    padding: 0 !important;
}

/*logos*/

/* shared logo animation */
.bmg-header-branding-group .ymca-logo img,
.bmg-header-bottom-row .ymca-logo img {
    transform-origin: left center;
    transition:
        transform 260ms cubic-bezier(0.2, 0.8, 0.2, 1),
        opacity 180ms ease;
    will-change: transform, opacity;
}

/* TOP logo visible by default */
.bmg-header-branding-group .ymca-logo img {
    transform: scale(1);
    opacity: 1;
}

/* hide top logo on scroll */
.header-scrolled .bmg-header-branding-group .ymca-logo img {
    transform: scale(0.7);
    opacity: 0;
    pointer-events: none;
}

/* bottom logo hidden by default */
.bmg-header-bottom-row .ymca-logo img {
    transform: scale(0.7);
    opacity: 0;
    pointer-events: none;
}

/* show bottom logo on scroll */
.header-scrolled .bmg-header-bottom-row .ymca-logo img {
    transform: scale(1);
    opacity: 1;
    pointer-events: auto;
}

/*scroll detector*/
.bmg-header-sentinel {
    position: absolute;
    top: 100px;
    height: 40px;
    width: 100%;
    opacity: 0;
    z-index: -100;
    pointer-events: none;
}

/*tablet*/

@media (max-width: 740px) {
    /*buttons*/
    .bmg-header-button-group .wp-block-group {
        /*FOR NOW:*/
        display: none;
    }
}

/*mobile*/

@media (max-width: 599px) {
    /*container*/
    .wp-block-group.bmg-header {
        display: flex;
        justify-content: space-between;

        padding: 25px 35px;
    }

    /*top row*/
    .wp-block-group.bmg-header-top-row {
        margin: 0 !important;
    }

    /*branding*/
    .bmg-header-branding-group .wp-block-group {
        /* flex-direction: column; */
        /* align-items: start; */
        gap: 20px;

        transition: all 0.35s ease;
    }
    .header-scrolled .bmg-header-branding-group .wp-block-group {
        gap: 0;

        transition: all 0.35s ease;
    }
    .bmg-header-top-row > div {
        padding-top: 0 !important;
    }

    /*separator*/
    .bmg-header .wp-block-separator.is-style-bmg-white-faint {
        display: none;
    }

    /*bottom row*/
    .wp-block-group.bmg-header-bottom-row {
        margin: 0 !important;
        padding-top: 20px;

        justify-content: space-between;
        align-items: center;
    }

    .bmg-header-bottom-row .ymca-logo img {
        width: 60px !important;
    }

    .bmg-header-bottom-row nav {
        justify-content: end;
        padding-right: 20px;
    }

    /*mobile nav*/
    .bmg-header-bottom-row ul.wp-block-navigation__container {
        width: 80%;
        padding: 20px !important;
        gap: 15px !important;
    }
    .bmg-header-bottom-row ul.wp-block-navigation__container li ul {
        padding: 0 !important;
    }
    .bmg-header-bottom-row ul.wp-block-navigation__container li {
        width: 100%;
        align-items: start !important;
        text-align: left;
        justify-content: start;
    }

    /*icon*/
    .wp-block-navigation__responsive-container-open svg {
        display: none;
    }
    .wp-block-navigation__responsive-container-open::before {
        content: "";
        display: inline-block;
        width: 30px;
        height: 25px;

        background-image: url(../../icons/menu_toggle_icon.png);
        background-repeat: no-repeat;
        background-position: center;
        background-size: contain;
        filter: invert(99%) sepia(0%) saturate(2%) hue-rotate(86deg) brightness(102%) contrast(100%);

        /* keep the button clickable */
        pointer-events: none;
    }

    .bmg-header-bottom-row ul.wp-block-navigation__container li button span {
        font-size: 20px;
        font-weight: 700;
    }
    /*sub menu*/
    .bmg-header-bottom-row ul.wp-block-navigation__container li ul {
        padding-left: 15px !important;
    }
    .bmg-header-bottom-row ul.wp-block-navigation__container li ul li a {
        padding: 10px 0 !important;
        font-weight: 500;
    }
}
