/*
 * The overview at /admin (docs/admin.md §7).
 *
 * Loaded by that one page — via content_for(:stylesheet) in
 * app/views/admin/dashboards/show.html.erb — because the engine ships no card or grid
 * component and this is not the public site's theme. It is hand-written CSS on purpose:
 * there is no build step in this repository, so a card is a border, a grid and a hover
 * rule, not a framework.
 *
 * The dark description over each card is the whole interaction: nothing is loaded, no
 * JavaScript is involved, and it opens on keyboard focus exactly as it opens on hover.
 */

/* The engine's own h2 sits at body size, which reads as a caption rather than as the title
 * of a section — and this page is read as a list of sections. */
.admin-section h2 {
  border-bottom: 1px solid #e0e0e0;
  font-size: 1.15em;
  margin-bottom: 0.75rem;
  padding-bottom: 0.35rem;
}

.admin-metrics {
  display: grid;
  gap: 0.75rem;
  grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr));
  margin-bottom: 1rem;
}

.admin-metric {
  background-color: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  padding: 0.75rem 0.9rem;
  position: relative;
}

.admin-metric:hover,
.admin-metric:focus-within {
  border-color: #9e9e9e;
}

/* A card is a tab stop, so a keyboard user gets a ring as well as the description — the
   engine's own focus style, spelled out here because this file cannot read its Sass
   variables. */
.admin-metric:focus-visible {
  outline: 2px solid #1f1f1f;
  outline-offset: 2px;
}

.admin-metric__label {
  color: #5c5c5c;
  display: block;
  font-size: 0.8em;
  line-height: 1.4;
}

.admin-metric__value {
  display: block;
  font-size: 1.7em;
  font-variant-numeric: tabular-nums;
  line-height: 1.25;
  margin-top: 0.2rem;
}

/* A value that is not a count — a timestamp, the target statuses — reads at label size
   rather than at the size a one- or two-digit number is designed for. */
.admin-metric--text .admin-metric__value {
  font-size: 0.95em;
}

/* The one thing the page marks: somebody has to do something about this number. */
.admin-metric--alarm {
  border-color: #d93025;
}

.admin-metric--alarm .admin-metric__value {
  color: #b3261e;
  font-weight: bold;
}

/* What it means, and what to do about it. Hidden until the card is hovered or focused,
   so the page stays a wall of numbers until a number is questioned.

   As wide as its card, not wider: an absolutely positioned box still counts toward the
   document's scroll width, so a 24rem tooltip on a right-hand column card gives every
   visitor a horizontal scrollbar. The card is the bound, which is also the one width that
   never depends on which column the card landed in. */
.admin-metric__note {
  background-color: #1f1f1f;
  border-radius: 6px;
  color: #fff;
  font-size: 0.85em;
  left: 0;
  line-height: 1.55;
  opacity: 0;
  overflow-wrap: break-word;
  padding: 0.6rem 0.75rem;
  position: absolute;
  top: calc(100% + 0.3rem);
  transition: opacity 120ms ease-in-out;
  visibility: hidden;
  width: 100%;
  z-index: 2;
}

.admin-metric:hover .admin-metric__note,
.admin-metric:focus-within .admin-metric__note {
  opacity: 1;
  visibility: visible;
}

/* `button_to` wraps its button in a form of its own, which is a block element: inside a
   table cell it would put the button on a line below the row's own baseline. */
.admin-row-action {
  display: inline;
  margin: 0;
}

/*
 * The summary line on every dashboard index page (app/views/admin/application/index.html.erb,
 * docs/admin.md §8): the size of the list, then one chip per collection filter with its
 * own count. The chips are links into the engine's search box syntax (`<name>:`), so
 * there is no JavaScript here either.
 */
/* The summary belongs to the header block, not to the table: the engine's header
 * (.main-content__header, padding 1rem 2rem) draws the divider under itself, so when a
 * summary follows, the divider moves down to sit under the chips instead — one line
 * between "what this list is" and the rows, not one between the title and the chips.
 * `:has()` is fine here: the admin is an operator page on a current browser. */
.main-content__header:has(+ .admin-summary) {
  border-bottom: 0;
  padding-bottom: 0.5rem;
}

.admin-summary {
  align-items: baseline;
  border-bottom: 1px solid #dfe0e1;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.5rem;
  padding: 0 2rem 1rem;
}

.admin-summary__total {
  margin: 0;
}

.admin-summary__filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  list-style: none;
  margin: 0;
  padding: 0;
}

.admin-summary__chip {
  border: 1px solid #c8c8c8;
  border-radius: 999px;
  color: inherit;
  display: inline-block;
  font-size: 0.9em;
  padding: 0.15rem 0.7rem;
  text-decoration: none;
}

.admin-summary__chip:hover,
.admin-summary__chip:focus {
  border-color: #1a1a1a;
}

.admin-summary__chip--active {
  background: #1a1a1a;
  border-color: #1a1a1a;
  color: #ffffff;
}

.admin-summary__count {
  font-variant-numeric: tabular-nums;
  margin-left: 0.3rem;
  opacity: 0.75;
}
