/**
 * KMOnlineSolutions - Sticky (Portal) for Elementor Free.
 *
 * Two layers (both driven by the same wppm-sticky--top / --bottom classes):
 *  1) CSS position:sticky fallback — works for in-content elements whose
 *     parent is tall (sidebars, in-page containers). Pure CSS, no jump.
 *  2) JS position:fixed takeover (assets/js/sticky.js) — required for site
 *     headers rendered inside short template wrappers
 *     (e.g. .ekit-template-content-header), where sticky has no room to
 *     travel. The JS adds .wppm-sticky--fixed + a placeholder.
 *
 * Controls (per element, via Elementor selectors):
 *   --wppm-sticky-offset  top/bottom offset in px (responsive)
 *   --wppm-sticky-z-index stacking order
 *
 * Device visibility uses wppm-sticky-on-{desktop,tablet,mobile} classes
 * added in before_render (see PHP). Breakpoints match Elementor defaults:
 * desktop >1024px, tablet 768-1024px, mobile <768px.
 */

.elementor-element.wppm-sticky--top {
  position: -webkit-sticky;
  position: sticky;
  top: var(--wppm-sticky-offset, 0px);
  z-index: var(--wppm-sticky-z-index, 99);
}

.elementor-element.wppm-sticky--bottom {
  position: -webkit-sticky;
  position: sticky;
  bottom: var(--wppm-sticky-offset, 0px);
  z-index: var(--wppm-sticky-z-index, 99);
}

/* JS fixed takeover: higher specificity beats the sticky rules above. */
.wppm-sticky--top.wppm-sticky--fixed,
.wppm-sticky--bottom.wppm-sticky--fixed {
  position: fixed !important;
  left: 0;
  right: auto;
}

/* Placeholder holds the layout slot while the element is fixed. */
.wppm-sticky-placeholder {
  pointer-events: none;
  visibility: hidden;
}

/* Logged-in WP admin bar pushes fixed viewport down — compensate so a
   top-sticky container never slides under it. */
.admin-bar .wppm-sticky--top {
  top: calc(var(--wppm-sticky-offset, 0px) + 32px);
}

@media screen and (max-width: 782px) {
  .admin-bar .wppm-sticky--top {
    top: calc(var(--wppm-sticky-offset, 0px) + 46px);
  }
}

/* Sticky On devices: reset to static where the element is not enabled. */
@media (min-width: 1025px) {
  .wppm-sticky--top:not(.wppm-sticky-on-desktop),
  .wppm-sticky--bottom:not(.wppm-sticky-on-desktop) {
    position: static !important;
    top: auto;
    bottom: auto;
  }
}

@media (min-width: 768px) and (max-width: 1024px) {
  .wppm-sticky--top:not(.wppm-sticky-on-tablet),
  .wppm-sticky--bottom:not(.wppm-sticky-on-tablet) {
    position: static !important;
    top: auto;
    bottom: auto;
  }
}

@media (max-width: 767px) {
  .wppm-sticky--top:not(.wppm-sticky-on-mobile),
  .wppm-sticky--bottom:not(.wppm-sticky-on-mobile) {
    position: static !important;
    top: auto;
    bottom: auto;
  }
}
