/* A dropdown cannot escape the stacking context of its containing box.
   Promote only the containers of an open menu, including nested boxes.
   :has() also covers controls inserted/replaced by renderUI and updateSelectizeInput.
   Native selectInput(selectize = FALSE) keeps the browser's own popup. */
:is(.box, .box-body, .card, .card-body, .panel, .panel-body, .custom-box,
    .well, .shiny-input-container, .row, .bslib-grid, .content-panel,
    .control-card, .panel-card, .filter-panel):has(
      .selectize-input.dropdown-active,
      .bootstrap-select.open,
      .bootstrap-select.show,
      select:focus
    ) {
  position: relative;
  z-index: 100 !important;
  overflow: visible !important;
}

/* A sibling control in the same box must not paint over the open list. */
.selectize-control:has(.selectize-input.dropdown-active) {
  z-index: 101 !important;
}

.selectize-dropdown,
.bootstrap-select .dropdown-menu {
  z-index: 10050 !important;
}

/* Scroll the choices, rather than the surrounding box. */
.selectize-dropdown .selectize-dropdown-content {
  max-height: min(var(--drop-maxh, 240px), 50vh);
  overflow-y: auto;
  overscroll-behavior: contain;
}
