/* AGRIBERA: the real header stays in normal flow and becomes sticky.
   Only the independently fixed shipping strip needs a measured top reservation. */
:root {
  --agribera-shipping-height: 0px;
  --agribera-admin-height: 0px;
  --agribera-header-height: 132px;
}
body #masthead .astra-icon[data-cart-total]::after {
  color: #fff !important;
  background: #214c35 !important;
  border: 1px solid #fff;
  min-width: 18px;
  width: auto;
  height: 18px;
  padding: 0 4px;
  box-sizing: border-box;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  line-height: 16px;
  text-shadow: none;
}
/* First-paint fallback, also useful if JavaScript is disabled. */
html:has(body #wfspb-top-bar.top_bar:not(.wfspb-hidden):not(.wfsb-hidden):not([hidden])) {
  --agribera-shipping-height: 39px;
}
html:has(body.admin-bar) { --agribera-admin-height: 32px; }
html:has(body #masthead) {
  scroll-padding-top: calc(var(--agribera-admin-height) + var(--agribera-shipping-height) + var(--agribera-header-height) + 16px);
}
/* Astra's body overflow-x:hidden creates a sticky scroll ancestor.
   Clip only that horizontal overflow; the existing drawer scroll locks still win. */
@supports (overflow: clip) {
  body { overflow-x: clip; }
}
body #page {
  padding-top: var(--agribera-shipping-height);
}
body #masthead.site-header {
  position: -webkit-sticky;
  position: sticky;
  top: calc(var(--agribera-admin-height) + var(--agribera-shipping-height));
  z-index: 990;
  background: #fff;
  overflow: visible;
  box-shadow: 0 5px 20px rgba(33,76,53,.08);
}
/* Leave both Astra navigation variants and the cart controls intact. */
body #masthead .ast-primary-header-bar.main-header-bar {
  padding-top: 10px;
  padding-bottom: 10px;
}
body #masthead .custom-logo {
  max-height: 64px;
  width: auto;
  max-width: 128px;
  object-fit: contain;
}
body #wfspb-top-bar.top_bar {
  top: var(--agribera-admin-height) !important;
  z-index: 995;
}
body #wfspb-top-bar .wfspb-progress-background {
  background: #dce6d9 !important;
  border-radius: 999px;
  box-shadow: none !important;
}
body #wfspb-current-progress {
  background: #e8af6b !important;
  border-radius: 999px;
  box-shadow: none !important;
}
body #wfspb-label { color: #173b28 !important; }
/* Astra drawers are siblings of #masthead inside #page, so they can cover
   the header and the shipping strip while their close controls stay reachable. */
body #astra-mobile-cart-drawer { z-index: 10000; }
body #ast-mobile-popup.active { z-index: 100000; }
@media (max-width: 921px) {
  :root { --agribera-header-height: 108px; }
  body #masthead .ast-primary-header-bar.main-header-bar {
    padding-top: 8px;
    padding-bottom: 8px;
  }
  body #masthead .custom-logo { max-height: 48px; max-width: 100px; }
}
@media (max-width: 782px) {
  html:has(body.admin-bar) { --agribera-admin-height: 46px; }
}
@media (max-width: 767px) {
  html:has(body #wfspb-top-bar.top_bar:not(.wfspb-hidden):not(.wfsb-hidden):not([hidden])) {
    --agribera-shipping-height: 44px;
  }
}
/* Astra's unused above-header row otherwise adds 50px below the shipping strip.
   Removing its minimum leaves any future row contents visible at natural height. */
body #masthead .ast-above-header-bar,
body #masthead .ast-above-header-bar :is(.site-above-header-wrap,.ast-builder-grid-row,.site-header-section,.header-widget-area) {
  min-height: 0 !important;
  height: auto !important;
  padding-top: 0 !important;
  padding-bottom: 0 !important;
  margin-top: 0 !important;
  margin-bottom: 0 !important;
}
/* Compact shipping notice. Extra wrapping may grow naturally; no message is clipped. */
body #wfspb-top-bar .wfspb-lining-layer {
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  height: auto;
  padding: 8px 12px;
}
body #wfspb-top-bar #wfspb-main-content {
  padding: 0 24px !important;
  line-height: 20px !important;
  overflow-wrap: break-word;
  white-space: normal;
}
/* On a wide screen the percentage fits beside the centered message. */
@media (min-width: 1025px) {
  body #wfspb-top-bar:has(> #wfspb-progress.wfsb-style-3:not(.wfsb-hidden):not(.wfspb-hidden)) .wfspb-lining-layer {
    padding-inline: 160px;
  }
  body #wfspb-top-bar #wfspb-progress.wfsb-style-3 {
    position: absolute;
    top: 50%;
    bottom: auto;
    right: 20px;
    left: auto;
    width: 120px;
    height: 14px;
    transform: translateY(-50%);
    padding: 0;
  }
  body #wfspb-top-bar #wfspb-progress.wfsb-style-3 .wfspb-progress-background,
  body #wfspb-top-bar #wfspb-current-progress {
    height: 14px;
    min-height: 14px;
  }
  body #wfspb-top-bar #wfspb-current-progress { position: static; }
  body #wfspb-top-bar #wfspb-label {
    position: absolute;
    inset: 0;
    font-size: 10px !important;
    line-height: 14px;
  }
}
/* If the progress bar is enabled on smaller screens it receives its own short row. */
@media (max-width: 1024px) {
  body #wfspb-top-bar #wfspb-progress.wfsb-style-3 {
    position: relative;
    inset: auto;
    width: min(280px,calc(100% - 32px));
    margin: 0 auto;
    padding: 0 0 5px;
    transform: none;
  }
  body #wfspb-top-bar:has(> #wfspb-progress.wfsb-style-3:not(.wfsb-hidden):not(.wfspb-hidden)) .wfspb-lining-layer { min-height: 30px; padding-block: 5px; }
}
@media (max-width: 767px) {
  body #wfspb-top-bar .wfspb-lining-layer { min-height: 44px !important; padding: 5px 10px; }
  body #wfspb-top-bar #wfspb-main-content { padding-inline: 18px !important; line-height: 17px !important; }
}
/* Toscana's native mobile shipping widget has a -32px bottom margin in Astra's
   saved settings. Keep its complete wrapped message inside the beige row. */
@media (max-width: 921px) {
  body #ast-mobile-header .ast-below-header-bar {
    box-sizing: border-box;
    min-height: 34px !important;
    height: auto !important;
    padding: 8px 12px !important;
  }
  body #ast-mobile-header .ast-below-header-bar :is(.ast-builder-grid-row,.site-header-below-section-center) {
    min-height: 0 !important;
    height: auto !important;
    min-width: 0;
    width: 100%;
  }
  body #ast-mobile-header .ast-below-header-bar [data-section="sidebar-widgets-header-widget-2"],
  body #ast-mobile-header .ast-below-header-bar #block-46 {
    box-sizing: border-box;
    min-width: 0;
    width: 100%;
    height: auto !important;
    margin: 0 !important;
    padding: 0 !important;
  }
  body #ast-mobile-header .ast-below-header-bar #block-46 p {
    margin: 0 !important;
    padding: 0 !important;
    font-size: 14px !important;
    line-height: 18px !important;
    text-align: center;
    white-space: normal;
    overflow-wrap: break-word;
  }
}
/* Only the desktop/mobile header shipping notes disappear in checkout. */
html:has(body.woocommerce-checkout),
body.woocommerce-checkout { --agribera-shipping-height: 0px !important; }
body.woocommerce-checkout #wfspb-top-bar,
body.woocommerce-checkout #masthead [data-section="sidebar-widgets-header-widget-1"],
body.woocommerce-checkout #masthead [data-section="sidebar-widgets-header-widget-2"],
body.woocommerce-checkout #masthead :is(#block-46,#block-48),
body.woocommerce-checkout #masthead .ast-below-header-wrap:has(:is(#block-46,#block-48)) {
  display: none !important;
}
@media (max-width: 921px) {
  body #ast-mobile-header .ast-button-wrap .menu-toggle.main-header-menu-toggle {
    border-radius: 12px !important;
  }
}
