/**
 * Location: /assets/css/stm-product-sidebar-sticky.css
 * Purpose:
 * - Single Product: Product sidebar me LAST widget ko proper sticky banana (GUARANTEED).
 * - Works even if widget wrapper (.stm-bigcard-sticky) is missing.
 *
 * Behavior:
 * - ✅ Sticky starts from its original render position (no jump above).
 * - ✅ Stays sticky while scrolling down until sidebar/container ends.
 * - ✅ Scroll up pe naturally original position par aa jata hai.
 *
 * Related JS:
 * - None (CSS-only, conflict-free).
 *
 * Linkage/Loader:
 * - Enqueued from /inc/enqueue/frontend.php ONLY on is_product() + stm_sidebar_product active.
 */

@media (min-width: 992px){

  /* ======================================================
     A) Kill common "sticky breakers" ONLY on single product
     (parents having overflow/transform/contain can disable sticky)
  ====================================================== */
  .single-product .stm-layout,
  .single-product .stm-layout__content,
  .single-product .stm-sidebar,
  .single-product .stm-sidebar__inner,
  .single-product .stm-sp__wrap,
  .single-product #primary,
  .single-product #content,
  .single-product main,
  .single-product .site,
  .single-product .site-content{
    overflow: visible !important;
    transform: none !important;
    contain: none !important;
  }

  /* ======================================================
     B) Disable global sidebar-inner sticky on product only
     (nested sticky conflicts)
  ====================================================== */
  .single-product .stm-sidebar__inner{
    position: relative !important;
    top: auto !important;
  }

  /* ======================================================
     C) Make product sidebar column stretch full height
     (so sticky can travel properly)
  ====================================================== */
  .single-product aside.stm-sidebar--product,
  .single-product aside.stm-sidebar--shop,
  .single-product aside.stm-sidebar{
    align-self: stretch !important;
    position: relative;
    overflow: visible !important;
  }

  .single-product aside.stm-sidebar--product .stm-sidebar__inner,
  .single-product aside.stm-sidebar--shop .stm-sidebar__inner,
  .single-product aside.stm-sidebar .stm-sidebar__inner{
    min-height: 100%;
    position: relative;
    overflow: visible !important;
  }

  /* ======================================================
     D) Primary method: if sticky wrapper exists, make it sticky
     (wrapper is added when checkbox enabled)
  ====================================================== */
  .single-product .stm-bigcard-sticky[data-stm-bigcard-sticky="1"]{
    position: sticky !important;
    top: 18px !important;
    z-index: 2;
  }

  /* ======================================================
     E) GUARANTEED fallback:
     If wrapper doesn't exist for any reason, make the LAST widget sticky.
     This matches your requirement because you keep sticky-enabled widget at the end.
  ====================================================== */
  .single-product aside.stm-sidebar--product .stm-sidebar__inner > .stm-widget:last-of-type,
  .single-product aside.stm-sidebar--product .stm-sidebar__inner > .widget:last-of-type,
  .single-product aside.stm-sidebar--shop .stm-sidebar__inner > .stm-widget:last-of-type,
  .single-product aside.stm-sidebar--shop .stm-sidebar__inner > .widget:last-of-type,
  .single-product aside.stm-sidebar .stm-sidebar__inner > .stm-widget:last-of-type,
  .single-product aside.stm-sidebar .stm-sidebar__inner > .widget:last-of-type{
    position: sticky !important;
    top: 18px !important;
    z-index: 2;
  }
}
