/**
 * @file
 * The page around the Chosen widgets, and nothing about the widgets.
 *
 * The point of the example is to look at what the theme does to Chosen, so
 * nothing here styles a `.chosen-*` class. What it does instead is give each
 * widget room: a dropdown is positioned over whatever follows it, so several
 * of them open at once land on top of each other unless the page is spread
 * out first.
 *
 * Plain CSS with fallbacks, like the rest of this module: the page has to be
 * usable in a theme that defines none of these variables.
 */

.chosen-example__item {
  margin-block: 1.5rem 2rem;
  max-width: 40rem;
}

.chosen-example__item > h4 {
  margin-block: 0 0.25rem;
}

.chosen-example__item > p {
  margin-block: 0 0.75rem;
  max-width: 34rem;
  color: var(--color-text-muted, inherit);
}

/* An open drop is out of flow, so the space under a widget has to be asked
 * for. Enough for the tallest drop the page can produce, which is the one with
 * a search field over a full-height result list. */
.chosen-example--reserved .chosen-example__item {
  margin-block-end: 22rem;
}

.chosen-example--reserved .chosen-example__table td {
  padding-block-end: 22rem;
}

/* The last of the open widgets needs somewhere to open into, whether or not
 * the page has been spread out. */
.chosen-example {
  padding-block-end: 24rem;
}

/* The toolbar. Sticky, because the whole point of it is to change the state of
 * something further down the page than it is. */
.chosen-example-toolbar {
  position: sticky;
  top: 0;
  z-index: 2000;
  margin-block-end: 2rem;
  padding: 0.75rem 1rem 1rem;
  border: var(--border-width, 1px) solid var(--color-border, currentColor);
  background: var(--color-surface, #fff);
}

.chosen-example-toolbar__title {
  margin-block: 0 0.25rem;
}

.chosen-example-toolbar__help {
  margin-block: 0 0.75rem;
  max-width: 44rem;
}

.chosen-example-toolbar__controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.5rem;
}

.chosen-example-toolbar__controls .form-item {
  flex: 1 1 12rem;
  min-width: 0;
  margin-block: 0;
}

/* The description of a control is the sentence saying what it does, and there
 * are five of them side by side: full size they would be longer than the
 * controls they explain. */
.chosen-example-toolbar__controls .description {
  font-size: 0.85em;
}

.chosen-example-toolbar__buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-block-start: 0.75rem;
}

/* The width a select gets in the last column of a table, which is the case
 * that decides what the widget does with a label it cannot fit. */
.chosen-example__narrow {
  max-width: 14rem;
}

.chosen-example__narrow .chosen-container {
  max-width: 100%;
}

/* A row of exposed filters: two widgets and the button that applies them, all
 * on one line and sharing a baseline. */
.chosen-example__inline {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 1rem;
}

.chosen-example__inline .form-item {
  margin-block: 0;
}

.chosen-example__table {
  width: 100%;
}

/* Auto layout would hand the whole width to whichever column holds the longest
 * option label, which is not how a real table of widgets is sized. */
.chosen-example__table th:first-child,
.chosen-example__table td:first-child {
  width: 25%;
}
