/**
 * EXAT Core — ช่วยให้ position: sticky ใน .sub-sticky ทำงาน
 *
 * สาเหตุที่ sticky ไม่ติดบ่อยๆ:
 * - body / ancestor ใช้ overflow-x: hidden (Chrome จะทำให้ sticky พัง)
 * - ancestor ใช้ overflow: hidden
 * - flex ลูกถูกยืด (ลอง align-self: flex-start)
 */

/* หน้าที่มี .sub-sticky — ใช้ clip แทน hidden แนวนอน (ไม่ตัด sticky แนวตั้ง) */
@supports (overflow: clip) {
  body:has(.sub-sticky) {
    overflow-x: clip;
  }
}

html.exat-core-sticky-disabled,
body.exat-core-sticky-disabled {
  overflow-x: visible;
}

html.exat-core-sticky-disabled .sub-sticky,
body.exat-core-sticky-disabled .sub-sticky {
  overflow: visible !important;
}

html.exat-core-sticky-disabled .sub-sticky :is(.elementor-element, .elementor-widget, .elementor-widget-wrap),
body.exat-core-sticky-disabled .sub-sticky :is(.elementor-element, .elementor-widget, .elementor-widget-wrap) {
  position: static !important;
  top: auto !important;
  transform: none !important;
  will-change: auto !important;
}

/* ธีมบางตัวใส่บน html — จำกัดเฉพาะเมื่อมีการ์ด sticky */
@supports (overflow: clip) {
  html:has(.sub-sticky) {
    overflow-x: clip;
  }
}

/* คอนเทนเนอร์การ์ด */
.sub-sticky {
  overflow: visible !important;
}

html.exat-core-sticky-disabled .sub-sticky,
body.exat-core-sticky-disabled .sub-sticky {
  overflow: visible !important;
}

/* Elementor: คอนเทนเนอร์ที่ห่อ .sub-sticky มักมี overflow */
.elementor-section:has(.sub-sticky),
.e-con:has(.sub-sticky),
.e-parent:has(.sub-sticky) {
  overflow: visible !important;
}

html.exat-core-sticky-disabled .elementor-section:has(.sub-sticky),
html.exat-core-sticky-disabled .e-con:has(.sub-sticky),
html.exat-core-sticky-disabled .e-parent:has(.sub-sticky),
body.exat-core-sticky-disabled .elementor-section:has(.sub-sticky),
body.exat-core-sticky-disabled .e-con:has(.sub-sticky),
body.exat-core-sticky-disabled .e-parent:has(.sub-sticky) {
  overflow: visible !important;
}

/* ลูกโดยตรง — sticky stack + flex */
.sub-sticky > .elementor-element {
  align-self: flex-start;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

html.exat-core-sticky-disabled .sub-sticky > .elementor-element,
body.exat-core-sticky-disabled .sub-sticky > .elementor-element {
  position: static !important;
  top: auto !important;
  transform: none !important;
  will-change: auto !important;
}

@media (max-width: 767px) {
  .sub-sticky, .sub-sticky * {
    position: static !important;
    top: auto !important;
    transform: none !important;
    will-change: auto !important;
  }
}

@media (min-width: 768px) and (max-width: 1024px) {
  .sub-sticky, .sub-sticky * {
    position: static !important;
    top: auto !important;
    transform: none !important;
    will-change: auto !important;
  }
}
