/**
 * @file
 * Red-list badges from the sos_redlist_badge formatter.
 *
 * The markup is a Bootstrap badge (.badge), see sos-redlist-badge.html.twig.
 * The category colours use Bootstrap's CSS variables, so they follow the
 * theme's palette and colour mode. The values after the variable names are
 * fallbacks for pages without Bootstrap CSS.
 *
 * The theme's Bootstrap CSS loads after this file, so .badge wins over a
 * single class here: the colours use two classes (.sos-redlist.sos-redlist--*)
 * and set --bs-badge-color, which .badge uses for the text colour.
 */

/* Fallback look without Bootstrap; .badge replaces these values. */
.sos-redlist {
  display: inline-block;
  padding: 0.35em 0.5em;
  border-radius: 0.375rem;
  font-size: 0.75em;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
  color: #fff;
  background-color: #6c757d;
}

/*
 * .badge aligns on the baseline, so its bottom padding hangs below the text
 * and the badge looks low next to the species name. Lift it a little.
 */
.sos-redlist.sos-redlist {
  margin-inline-start: 0.35em;
  vertical-align: 0.125em;
  cursor: help;
}

/*
 * .badge has line-height: 1, so where the capitals sit inside the badge
 * depends on the font's ascent and descent: with the theme's Roboto they sit
 * above the centre. Trimming the text box to the capital height centres them
 * with equal padding, whatever the font. The badge's bottom is then the
 * padding below the baseline, so it sits centred on the lowercase letters of
 * the species name without the lift above. Browsers without text-box keep the
 * rules above.
 */
@supports (text-box: trim-both cap alphabetic) {
  .sos-redlist.sos-redlist {
    --bs-badge-padding-y: 0.5em;
    vertical-align: baseline;
    text-box: trim-both cap alphabetic;
  }
}

/* Near threatened: subtle warning, with a border to show on white. */
.sos-redlist.sos-redlist--nt {
  --bs-badge-color: var(--bs-warning-text-emphasis, #664d03);
  color: var(--bs-badge-color);
  background-color: var(--bs-warning-bg-subtle, #fff3cd);
  box-shadow: inset 0 0 0 1px var(--bs-warning-border-subtle, #ffe69c);
}

/* Vulnerable: warning (yellow), dark text. */
.sos-redlist.sos-redlist--vu {
  --bs-badge-color: #000;
  color: var(--bs-badge-color);
  background-color: var(--bs-warning, #ffc107);
}

/* Endangered: orange. White text on orange is too low in contrast. */
.sos-redlist.sos-redlist--en {
  --bs-badge-color: #000;
  color: var(--bs-badge-color);
  background-color: var(--bs-orange, #fd7e14);
}

/* Critically endangered: danger (red). */
.sos-redlist.sos-redlist--cr {
  --bs-badge-color: #fff;
  color: var(--bs-badge-color);
  background-color: var(--bs-danger, #dc3545);
}

/* Regionally extinct: dark. */
.sos-redlist.sos-redlist--re {
  --bs-badge-color: #fff;
  color: var(--bs-badge-color);
  background-color: var(--bs-dark, #212529);
}
