/* Same effect as remp.fr: the header is sticky and, once scrolled, shrinks
   into a floating translucent pill (logo left, menu right).
   Astra renders two headers: #ast-desktop-header and .ast-mobile-header-wrap;
   both are the "pill" element, #masthead is the sticky wrapper. */

#masthead {
    position: sticky;
    top: var(--wp-admin--admin-bar--height, 0px);
    z-index: 999;
    /* JS pins the expanded height so the page never jumps while the pill animates */
    height: var(--crem-header-height, auto);
    pointer-events: none;
    background: transparent;
}

#masthead > * {
    pointer-events: auto;
}

/* Disables animations while JS measures the expanded header height */
.crem-no-anim,
.crem-no-anim * {
    transition: none !important;
    animation: none !important;
}

#ast-desktop-header,
#masthead .ast-mobile-header-wrap {
    max-width: 100vw; /* px-resolvable so max-width interpolates */
    margin: 0 auto;
    border-radius: 0;
    box-shadow: none;
    transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

#masthead .ast-above-header-bar,
#masthead .ast-primary-header-bar {
    transition: background-color 0.35s cubic-bezier(0.4, 0, 0.2, 1),
                border-color 0.35s cubic-bezier(0.4, 0, 0.2, 1),
                min-height 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

#masthead header .custom-logo-link img,
#masthead .custom-logo-link img {
    transition: width 0.35s cubic-bezier(0.4, 0, 0.2, 1),
                max-width 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ---- Scrolled: floating pill ---- */
#masthead.navbar-scrolled #ast-desktop-header,
#masthead.navbar-scrolled .ast-mobile-header-wrap {
    max-width: 1200px;
    width: calc(100% - 24px);
    margin-top: 10px;
    border-radius: 50px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    background-color: rgba(255, 255, 255, 0.85);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
}

#masthead.navbar-scrolled .ast-above-header-bar,
#masthead.navbar-scrolled .ast-primary-header-bar {
    background-color: transparent;
    border-bottom-color: transparent;
    min-height: 0;
}

#masthead.navbar-scrolled .site-above-header-wrap,
#masthead.navbar-scrolled .site-primary-header-wrap,
.ast-desktop #masthead.navbar-scrolled .ast-above-header-bar .site-above-header-wrap,
.ast-desktop #masthead.navbar-scrolled .ast-primary-header-bar .site-primary-header-wrap {
    min-height: 0;
}

#masthead.navbar-scrolled .ast-above-header-bar,
#masthead.navbar-scrolled .ast-primary-header-bar,
#masthead.navbar-scrolled .site-branding,
#masthead.navbar-scrolled .ast-builder-layout-element {
    padding-top: 0;
    padding-bottom: 0;
}

#masthead.navbar-scrolled .ast-container {
    padding-left: 24px;
    padding-right: 24px;
}

#masthead.navbar-scrolled .custom-logo-link img,
header#masthead.navbar-scrolled .custom-logo-link img {
    width: 39px;
    max-width: 39px;
    height: auto;
}

/* Desktop pill: logo left, then search / menu / social on the same row */
body.ast-desktop #masthead.navbar-scrolled #ast-desktop-header {
    display: flex;
    align-items: center;
    padding: 0;
}

#masthead.navbar-scrolled #ast-desktop-header .ast-above-header-wrap {
    flex: 0 0 auto;
}

#masthead.navbar-scrolled #ast-desktop-header .ast-main-header-wrap {
    flex: 1 1 auto;
    min-width: 0;
}

#masthead.navbar-scrolled #ast-desktop-header .ast-container {
    padding-left: 12px;
    padding-right: 12px;
}

#masthead.navbar-scrolled #ast-desktop-header .ast-above-header-wrap .ast-container {
    padding-left: 24px;
}

#masthead.navbar-scrolled #ast-desktop-header .ast-main-header-wrap .ast-container {
    padding-right: 24px;
}

/* Astra forces an 80px line-height on top-level menu items */
.ast-desktop #masthead.navbar-scrolled .ast-primary-header-bar .main-header-menu > .menu-item {
    line-height: 46px;
}

/* Mobile pill */
#masthead.navbar-scrolled .ast-mobile-header-wrap .ast-primary-header-bar {
    padding-top: 2px;
    padding-bottom: 2px;
}

#masthead.navbar-scrolled .ast-mobile-header-wrap .ast-mobile-header-content {
    border-radius: 20px;
    margin-top: 10px;
}

/* backdrop-filter would clip fixed-position descendants (open menus) */
body.ast-main-header-nav-open #masthead.navbar-scrolled #ast-desktop-header,
body.ast-main-header-nav-open #masthead.navbar-scrolled .ast-mobile-header-wrap {
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
}

/* ---- Mobile bar: menu button | search field | Facebook + Instagram ---- */
#masthead .ast-mobile-header-wrap .ast-primary-header-bar .ast-builder-grid-row {
    grid-template-columns: auto minmax(0, 1fr) auto !important;
    column-gap: 10px;
    align-items: center;
}

#masthead .ast-mobile-header-wrap .site-header-primary-section-center {
    min-width: 0;
}

/* Search always visible as an inline field (Astra's slide-search is icon-only) */
#masthead .ast-mobile-header-wrap .ast-header-search .ast-search-icon {
    display: none;
}

#masthead .ast-mobile-header-wrap .ast-header-search .ast-search-menu-icon.slide-search,
#masthead .ast-mobile-header-wrap .ast-header-search .ast-search-menu-icon.slide-search .search-form {
    position: static;
    width: 100%;
    max-width: none;
    visibility: visible;
    opacity: 1;
    transform: none;
    padding: 0;
    left: auto;
    right: auto;
}

#masthead .ast-mobile-header-wrap .ast-header-search .search-form {
    display: block;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 999px;
    overflow: hidden;
}

#masthead .ast-mobile-header-wrap .ast-header-search label {
    display: flex;
    align-items: center;
    width: 100%;
    margin: 0;
}

#masthead .ast-mobile-header-wrap .ast-header-search .search-field {
    flex: 1 1 auto;
    min-width: 0;
    width: 100%;
    height: 34px;
    padding: 0 6px 0 14px;
    border: 0;
    background: transparent;
    font-size: 14px;
}

#masthead .ast-mobile-header-wrap .ast-header-search .search-submit {
    position: static;
    flex: 0 0 auto;
    height: 34px;
    padding: 0 12px;
    background: transparent;
    color: inherit;
    border: 0;
}

#masthead .ast-mobile-header-wrap .ast-header-social-wrap .ast-builder-social-element {
    margin-left: 4px;
    margin-right: 0;
}

#masthead .ast-mobile-header-wrap .site-header-primary-section-left {
    gap: 10px;
    align-items: center;
}

/* Mobile logo: same size as the Facebook/Instagram icons (18px, Astra setting) */
#masthead .ast-mobile-header-wrap .custom-logo-link img,
#masthead.navbar-scrolled .ast-mobile-header-wrap .custom-logo-link img {
    width: 18px;
    max-width: 18px;
    height: 18px;
}
