/**
 * Chosen, the site's only stylesheet for it. biopama_libraries/chosen
 * initialises the plugin and gives its markup Bootstrap's own classes
 * (form-select, dropdown-menu, form-control); Bootstrap's tokens then carry
 * the page theme (light, dark, the site preset, the CT grey skin). This file
 * holds the structure the plugin needs and the site's few tweaks, written at
 * a specificity that also outranks the vendor stylesheet the contrib chosen
 * module still loads until it is uninstalled (biopama_libraries/chosen does
 * not load it). Override by being more specific or later, never with
 * !important.
 */

/* ---- Container ------------------------------------------------------- */

.chosen-container {
  position: relative;
  display: inline-block;
  vertical-align: middle;
  /* The plugin sets the width inline from the select; this floor keeps a
     control usable when the select measured 0 (hidden at init). Size a
     control by sizing the select or its parent (e.g. .biopama-country-control
     in biopama_libraries toolPage.css). */
  min-width: 6.25rem;
  text-align: start;
  user-select: none;
}

.chosen-container * {
  box-sizing: border-box;
}

.chosen-container.chosen-disabled {
  opacity: 0.65;
  pointer-events: none;
}

/* ---- Closed box (single: a.form-select) ------------------------------ */

.chosen-container .chosen-single.form-select,
.chosen-container-active.chosen-with-drop .chosen-single.form-select {
  height: auto;
  padding: 0.375rem 2.25rem 0.375rem 0.75rem;
  overflow: hidden;
  line-height: 1.5;
  color: var(--bs-body-color);
  white-space: nowrap;
  text-decoration: none;
  text-overflow: ellipsis;
  background-color: var(--bs-body-bg);
  background-image: var(--bs-form-select-bg-img), var(--bs-form-select-bg-icon, none);
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  background-size: 16px 12px;
  border: var(--bs-border-width) solid var(--bs-border-color);
  border-radius: var(--bs-border-radius);
  box-shadow: none;
  cursor: pointer;
}

.chosen-container-single .chosen-single.form-select span {
  display: block;
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Placeholder tone. */
.chosen-container .chosen-single.form-select.chosen-default {
  color: var(--bs-secondary-color);
}

/* The plugin's own arrow gives way to Bootstrap's background-image arrow
   (specificity above contrib's .container-inline rule). */
.chosen-container.chosen-container-single .chosen-single.form-select div {
  display: none;
}

/* Focus and open state (the anchor never takes focus itself). */
.chosen-container.chosen-container-active .chosen-single.form-select,
.chosen-container.chosen-container-active .chosen-choices.form-control {
  border-color: var(--bs-primary);
}

/* ---- Open list (.dropdown-menu) -------------------------------------- */

.chosen-container .chosen-drop.dropdown-menu {
  --bs-dropdown-min-width: 100%;
  top: 100%;
  left: 0;
  width: 100%;
  margin: 0;
  padding: 0.25rem 0;
  color: var(--bs-dropdown-color);
  background-color: var(--bs-dropdown-bg);
  border: var(--bs-dropdown-border-width) solid var(--bs-dropdown-border-color);
  border-radius: var(--bs-dropdown-border-radius);
  box-shadow: none;
}

.chosen-container.chosen-with-drop .chosen-drop.dropdown-menu {
  display: block;
}

.chosen-container .chosen-search {
  padding: 0.25rem 0.5rem;
}

.chosen-container.chosen-container-single-nosearch .chosen-search {
  display: none;
}

.chosen-container-single .chosen-search input.form-control {
  margin: 0;
  padding: 0.25rem 0.5rem;
  font-family: inherit;
  line-height: 1.5;
  background-image: none;
  border-radius: var(--bs-border-radius-sm);
  box-shadow: none;
}

.chosen-container .chosen-results {
  max-height: 15rem;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  list-style: none;
}

.chosen-container .chosen-results li {
  display: none;
  padding: var(--bs-dropdown-item-padding-y) var(--bs-dropdown-item-padding-x);
  font-size: inherit;
  line-height: 1.5;
  color: var(--bs-dropdown-link-color);
  cursor: pointer;
}

.chosen-container .chosen-results li.active-result,
.chosen-container .chosen-results li.group-result,
.chosen-container .chosen-results li.disabled-result,
.chosen-container .chosen-results li.no-results,
.chosen-container-single .chosen-results li.result-selected {
  display: list-item;
}

/* A chosen option leaves the list of a multiple select. */
.chosen-container-multi .chosen-results li.result-selected {
  display: none;
}

.chosen-container .chosen-results li.highlighted {
  color: var(--bs-dropdown-link-hover-color);
  background-color: var(--bs-dropdown-link-hover-bg);
  background-image: none;
}

.chosen-container .chosen-results li.group-result {
  color: var(--bs-dropdown-header-color);
  font-weight: 600;
  cursor: default;
}

.chosen-container .chosen-results li.group-option {
  padding-left: calc(var(--bs-dropdown-item-padding-x) + 0.75rem);
}

.chosen-container .chosen-results li.disabled-result,
.chosen-container .chosen-results li.no-results,
.chosen-container-single .chosen-results li.result-selected {
  color: var(--bs-dropdown-link-disabled-color);
  background: none;
  cursor: default;
}

.chosen-container .chosen-results li em {
  font-style: normal;
  text-decoration: underline;
}

/* ---- Multiple (ul.form-control with chips) --------------------------- */

.chosen-container-multi .chosen-choices.form-control {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  height: auto;
  margin: 0;
  padding: 0.375rem 0.75rem;
  list-style: none;
  background-color: var(--bs-body-bg);
  background-image: none;
  border: var(--bs-border-width) solid var(--bs-border-color);
  box-shadow: none;
  cursor: text;
}

.chosen-container-multi .chosen-choices li.search-choice {
  position: static;
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  margin: 0;
  padding: 0.125rem 0.5rem;
  line-height: 1.5;
  color: inherit;
  background-color: var(--bs-tertiary-bg);
  background-image: none;
  border: 0;
  border-radius: var(--bs-border-radius);
  box-shadow: none;
}

.chosen-container-multi .chosen-choices li.search-choice .search-choice-close {
  position: static;
  width: auto;
  height: auto;
  padding: 0;
  font-size: inherit;
  line-height: 1;
  color: inherit;
  background: none;
  border: 0;
  opacity: 0.6;
  cursor: pointer;
}

.chosen-container-multi .chosen-choices li.search-choice .search-choice-close::before {
  content: "\00d7";
  font-weight: 700;
}

.chosen-container-multi .chosen-choices li.search-choice .search-choice-close:hover {
  opacity: 1;
}

.chosen-container-multi .chosen-choices li.search-field {
  flex: 1 1 4rem;
  margin: 0;
  padding: 0;
}

.chosen-container-multi .chosen-choices li.search-field input[type="text"] {
  width: 100%;
  height: auto;
  margin: 0;
  padding: 0;
  font-family: inherit;
  line-height: 1.5;
  color: inherit;
  background: transparent;
  border: 0;
  outline: 0;
  box-shadow: none;
}

/* ---- Site rules ------------------------------------------------------ */

/* Chosen-enhanced selects inside an exposed-filter row: same size as the
   other (form-control-lg) controls. */
.akp-exposed-form .chosen-container-single .chosen-single.form-select {
  padding: 0.5rem 2.25rem 0.5rem 1rem;
  font-size: 1.25rem;
}

/* CT grey skin: the widget reads the skin's form and dropdown tokens
   (ct_override.css); only the border tone is its own. */
.akp-skin-ct .chosen-container {
  --bs-border-color: rgba(255, 255, 255, 0.15);
}
