/*
 * The Cosmic Studio — Shop V39 Sticky / Freeze Filter Patch
 * Shop-only enhancement layered after shop-v38.css.
 * No PHP catalogue, AJAX, search, sorting, pagination or backend changes.
 */

html.shop-v39-document{
  overflow-x:clip!important;
  overflow-y:auto!important;
}

html.shop-v39-document body.shop-v39-page{
  overflow-x:clip!important;
  overflow-y:visible!important;
}

/* Sticky positioning must not be clipped by a page wrapper. */
html.shop-v39-document body.shop-v39-page #main{
  overflow:visible!important;
  contain:none!important;
}

/* Keep the site header above the frozen shop filters. */
html.shop-v39-document body.shop-v39-page .site-header{
  z-index:1200!important;
}

/*
 * Freeze the complete filter block (category pills + all filter controls)
 * directly below the responsive site header on every viewport size.
 */
html.shop-v39-document body.cosmic-v15.shop-page.shop-v38-page.shop-v39-page
.shop-main-filter-section.shop-category-strip{
  position:-webkit-sticky!important;
  position:sticky!important;
  top:var(--shop-header-height,92px)!important;
  right:auto!important;
  bottom:auto!important;
  left:auto!important;
  z-index:1050!important;
  width:100%!important;
  max-width:none!important;
  margin:0!important;
  isolation:isolate!important;
  transform:translateZ(0)!important;
  -webkit-transform:translateZ(0)!important;
  backface-visibility:hidden!important;
  -webkit-backface-visibility:hidden!important;
  background:rgba(250,250,248,.985)!important;
  border-top:1px solid rgba(234,234,234,.88)!important;
  border-bottom:1px solid #EAEAEA!important;
  box-shadow:0 10px 30px rgba(18,55,42,.08)!important;
  -webkit-backdrop-filter:blur(18px)!important;
  backdrop-filter:blur(18px)!important;
}

/* Keep normal document scrolling. No nested vertical scroll container. */
html.shop-v39-document body.shop-v39-page .shop-main-filter-shell,
html.shop-v39-document body.shop-v39-page .shop-main-filter,
html.shop-v39-document body.shop-v39-page .shop-layout-v38,
html.shop-v39-document body.shop-v39-page .shop-main,
html.shop-v39-document body.shop-v39-page .shop-results-area{
  max-height:none!important;
  overflow-y:visible!important;
  overscroll-behavior-y:auto!important;
}

/* Horizontal controls remain accessible on compact screens without locking page scroll. */
html.shop-v39-document body.shop-v39-page .chip-row,
html.shop-v39-document body.shop-v39-page .shop-main-filter{
  -webkit-overflow-scrolling:touch;
  overscroll-behavior-x:contain!important;
}

/* Prevent focused controls from being hidden behind the frozen filter area. */
html.shop-v39-document body.shop-v39-page *{
  scroll-margin-top:calc(var(--shop-header-height,92px) + var(--shop-toolbar-height,118px) + 16px)!important;
}

/* Explicitly override V38's tablet rule that disabled sticky positioning. */
@media(max-width:991px){
  html.shop-v39-document body.cosmic-v15.shop-page.shop-v38-page.shop-v39-page
  .shop-main-filter-section.shop-category-strip{
    position:-webkit-sticky!important;
    position:sticky!important;
    top:var(--shop-header-height,78px)!important;
    z-index:1050!important;
  }
}

@media(max-width:767px){
  html.shop-v39-document body.cosmic-v15.shop-page.shop-v38-page.shop-v39-page
  .shop-main-filter-section.shop-category-strip{
    position:-webkit-sticky!important;
    position:sticky!important;
    top:var(--shop-header-height,72px)!important;
    z-index:1050!important;
    padding-top:6px!important;
    padding-bottom:7px!important;
    box-shadow:0 8px 22px rgba(18,55,42,.09)!important;
  }

  /* Category and filter rows scroll sideways only; vertical page scroll stays native. */
  html.shop-v39-document body.shop-v39-page .shop-filter-topline .chip-row,
  html.shop-v39-document body.shop-v39-page .shop-main-filter{
    overflow-x:auto!important;
    overflow-y:hidden!important;
    touch-action:pan-x pan-y!important;
  }
}

@media(prefers-reduced-motion:reduce){
  html.shop-v39-document body.shop-v39-page .shop-main-filter-section.shop-category-strip{
    transition:none!important;
  }
}
