/* Box Sash sitewide scroll stability — v1.0.0.
   Page sections still control their own local overflow and carousels. */

/* Remove conflicting scroll animation from legacy global-motion/page CSS.
   Native scrolling works with wheel, trackpad, keyboard and touch gestures. */
html {
  scroll-behavior: auto !important;
  overflow-x: hidden !important; /* fallback for browsers without overflow:clip */
  overflow-y: auto !important;
  touch-action: auto !important;
  overscroll-behavior-y: auto !important;
}

/* 'hidden' on body creates a second scrolling container when paired with y:auto.
   'clip' prevents sideways page drift without breaking sticky descendants. */
html body:not(.wp-admin):not(.modal-open):not(.no-scroll):not(.overflow-hidden) {
  overflow-x: hidden !important;
  overflow-y: visible !important;
  touch-action: auto !important;
  overscroll-behavior-y: auto !important;
}

@supports (overflow: clip) {
  html { overflow-x: clip !important; }
  html body:not(.wp-admin):not(.modal-open):not(.no-scroll):not(.overflow-hidden) {
    overflow-x: clip !important;
  }
}

/* Genuine open Box Sash dialogs must still prevent background scrolling. */
html.boxsash-modal-open {
  overflow-x: hidden !important;
  overflow-y: hidden !important;
}
@media (max-width: 680px) {
  html.boxsash-chat-is-open {
    overflow-x: hidden !important;
    overflow-y: hidden !important;
  }
}

/* Respect WordPress and other real modal locks; the rules above are not meant
   to defeat a dialog that is currently open. */
html.has-modal-open,
html.dialog-prevent-scroll {
  overflow-y: hidden !important;
}

/* Preserve normal anchor/keyboard movement even when older site files set
   html smooth-scrolling, including on motion-sensitive devices. */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto !important; }
}
