/**
 * Helova Core Store 4.14.6 — search geometry and modal-state corrections.
 * This replaces the 4.14.5 layer-lifting workaround.
 */

/* -------------------------------------------------------------------------
 * Desktop search: expand within the existing header; never move the header or
 * its template part, and do not add a page-wide blur on desktop.
 * ---------------------------------------------------------------------- */
body.helova-search-open .helova-search-header-v4146,
body.home.helova-search-open .helova-search-header-v4146 {
  z-index: 10110 !important;
  overflow: visible !important;
  opacity: 1 !important;
  visibility: visible !important;
  filter: none !important;
}

body.helova-search-open .helova-core-actions,
body.helova-search-open .helova-core-search {
  z-index: 10120 !important;
  overflow: visible !important;
  opacity: 1 !important;
  visibility: visible !important;
}

body.helova-search-open .helova-core-search.is-open .wp-block-search__inside-wrapper {
  z-index: 10130 !important;
  opacity: 1 !important;
  visibility: visible !important;
  pointer-events: auto !important;
}

body.helova-search-open .helova-core-search.is-open input {
  opacity: 1 !important;
  visibility: visible !important;
  pointer-events: auto !important;
}

/* Closing the panel returns focus to the trigger. Earlier :focus-within rules
 * must not visually reopen the panel after its is-open class is removed. */
.helova-core-search:not(.is-open):focus-within .wp-block-search__inside-wrapper {
  width: var(--helova-header-control-size, 44px) !important;
  min-width: var(--helova-header-control-size, 44px) !important;
  height: var(--helova-header-control-size, 44px) !important;
  min-height: var(--helova-header-control-size, 44px) !important;
  padding: 0 !important;
  overflow: hidden !important;
  border-radius: 999px !important;
  box-shadow: none !important;
}

.helova-core-search:not(.is-open):focus-within input {
  flex: 0 1 0 !important;
  width: 0 !important;
  min-width: 0 !important;
  padding: 0 !important;
  overflow: hidden !important;
  opacity: 0 !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

.helova-core-search:not(.is-open):focus-within .helova-search-close-v4140,
.helova-core-search:not(.is-open):focus-within .helova-search-close-v4131 {
  display: none !important;
}

@media (min-width: 900px) {
  html.helova-search-open,
  body.helova-search-open {
    overflow-x: hidden !important;
    overflow-y: auto !important;
  }

  body.helova-search-open .helova-search-scrim {
    display: none !important;
  }

  body.helova-search-open .helova-core-search.is-open .wp-block-search__inside-wrapper {
    position: absolute !important;
    top: 0 !important;
    right: 0 !important;
    left: auto !important;
    width: min(340px, 36vw) !important;
    min-width: 260px !important;
    max-width: min(340px, 36vw) !important;
    height: var(--helova-header-control-size, 44px) !important;
    min-height: var(--helova-header-control-size, 44px) !important;
    margin: 0 !important;
    overflow: visible !important;
    background: rgba(var(--helova-search-background-rgb), var(--helova-search-alpha)) !important;
    box-shadow: 0 18px 48px rgba(54, 29, 36, .18) !important;
    transform: none !important;
  }
}

/* -------------------------------------------------------------------------
 * Mobile navigation: the native close control remains fully interactive.
 * Closed containers can never retain an invisible full-viewport hit area.
 * ---------------------------------------------------------------------- */
@media (max-width: 899px) {
  .helova-core-navigation .wp-block-navigation__responsive-container.is-menu-open
  .wp-block-navigation__responsive-container-close {
    z-index: 30 !important;
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto !important;
    touch-action: manipulation !important;
  }

  .helova-core-navigation .wp-block-navigation__responsive-container:not(.is-menu-open) {
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
  }

  html:not(.helova-mobile-menu-open),
  body:not(.helova-mobile-menu-open) {
    overscroll-behavior: auto;
  }
}

/* Preserve the validated Mini-Cart stacking fix from 4.14.5. */
.helova-core-cart-overlay-v4145 {
  position: fixed !important;
  z-index: 10300 !important;
  inset: 0 !important;
  isolation: isolate !important;
}

.helova-core-cart-overlay-v4145 .helova-core-cart-drawer-layer-v4145,
.helova-core-cart-overlay-v4145 .wc-block-mini-cart__drawer {
  position: fixed !important;
  z-index: 10310 !important;
  top: 0 !important;
  bottom: 0 !important;
  height: 100dvh !important;
  max-height: 100dvh !important;
}

body.helova-mini-cart-open .helova-core-announcement,
body.helova-mini-cart-open .helova-core-header,
body.helova-mini-cart-open .helova-header-layer-v4142 {
  z-index: 1000 !important;
}

@media (prefers-reduced-motion: reduce) {
  body.helova-search-open .helova-core-search.is-open .wp-block-search__inside-wrapper {
    transition: none !important;
  }
}
