/* Numbers and the screens made of them, built only from the kit's tokens: a number with its label (nasaq-stat), the
   row that holds several (nasaq-statgrid), and a whole page that says one thing (nasaq-emptystate--page). */

/* ---------- nasaq-statgrid: numbers side by side. As many in a row as there are (five at most), then two, then one,
   by the room the row has and never by the screen: a row is always full, and a last one left alone takes the whole
   row. Three stand in a row or one under the other, never two and one. The steps are worked out here, with no media
   query: a width under the room `--nasaq-stat-min` needs for that many turns the next step on. ---------- */
.nasaq-statgrid { --nasaq-stat-min: 148px; --nasaq-stat-gap: var(--nasaq-space-4); --nasaq-stat-n: 4; --nasaq-stat-mid: 2;
  --nasaq-stat-w-n: calc((100% - (var(--nasaq-stat-n) - 1) * var(--nasaq-stat-gap)) / var(--nasaq-stat-n) - 0.5px);
  --nasaq-stat-w-mid: calc((100% - (var(--nasaq-stat-mid) - 1) * var(--nasaq-stat-gap)) / var(--nasaq-stat-mid) - 0.5px);
  --nasaq-stat-under-n: calc((var(--nasaq-stat-n) * var(--nasaq-stat-min) + (var(--nasaq-stat-n) - 1) * var(--nasaq-stat-gap) - 100%) * 999);
  --nasaq-stat-under-mid: calc((var(--nasaq-stat-mid) * var(--nasaq-stat-min) + (var(--nasaq-stat-mid) - 1) * var(--nasaq-stat-gap) - 100%) * 999);
  display: flex; flex-wrap: wrap; gap: var(--nasaq-stat-gap); margin: 0; min-inline-size: 0; }
.nasaq-statgrid > * { flex: 1 1 clamp(var(--nasaq-stat-w-n), var(--nasaq-stat-under-n),
  clamp(var(--nasaq-stat-w-mid), var(--nasaq-stat-under-mid), 100%)); min-inline-size: 0; }
.nasaq-statgrid:has(> :last-child:nth-child(1)) { --nasaq-stat-n: 1; --nasaq-stat-mid: 1; }
.nasaq-statgrid:has(> :last-child:nth-child(2)) { --nasaq-stat-n: 2; --nasaq-stat-mid: 1; }
.nasaq-statgrid:has(> :last-child:nth-child(3)) { --nasaq-stat-n: 3; --nasaq-stat-mid: 1; }
.nasaq-statgrid:has(> :last-child:nth-child(5)) { --nasaq-stat-n: 5; }
.nasaq-statgrid:has(> :last-child:nth-child(6)), .nasaq-statgrid:has(> :last-child:nth-child(9)) { --nasaq-stat-n: 3; }

/* ---------- nasaq-stat: one number with its label. __label, __value (a dt and a dd when the row is a dl), and under them __sub (one short line, kept when
   empty so cards in a row are one height) or __meter (a bar, 0 to 100). __state stands where the number would: a
   badge, or the word of what the link does. --inline: the label and the number on one line. --current: the one the
   screen is about now; --live: the accent square before its value (the lesson now, nothing else). In a card the
   numbers are the card's own: no frame of their own. ---------- */
.nasaq-stat { display: flex; flex-direction: column; align-items: flex-start; gap: var(--nasaq-hair);
  padding: var(--nasaq-card-pad); background: var(--nasaq-surface); border: 1px solid var(--nasaq-border);
  border-radius: var(--nasaq-radius); color: var(--nasaq-text); line-height: 1.5; text-decoration: none;
  transition: border-color .15s ease, background-color .15s ease; }
a.nasaq-stat { color: var(--nasaq-text); }
a.nasaq-stat:hover { border-color: var(--nasaq-primary); color: var(--nasaq-text); }
.nasaq-stat__label, .nasaq-stat > dt { margin: 0; font-size: var(--nasaq-text-sm); font-weight: 500; color: var(--nasaq-muted); }
.nasaq-stat__value, .nasaq-stat > dd { margin: 0; font-size: var(--nasaq-text-3xl); font-weight: 500; line-height: 1.35;
  font-variant-numeric: tabular-nums; }
.nasaq-stat__state { display: flex; align-items: center; gap: var(--nasaq-space-2);
  min-block-size: calc(var(--nasaq-text-3xl) * 1.35); color: var(--nasaq-accent-strong);
  font-size: var(--nasaq-text-sm); font-weight: 500; }
.nasaq-stat__sub { min-block-size: 1.5em; font-size: var(--nasaq-text-xs); color: var(--nasaq-muted);
  font-variant-numeric: tabular-nums; }
.nasaq-stat__meter { display: block; align-self: stretch; block-size: var(--nasaq-space-1);
  margin-block: var(--nasaq-space-1); overflow: hidden; background: var(--nasaq-border);
  border-radius: var(--nasaq-hair); }
.nasaq-stat__meter > span { display: block; block-size: 100%; background: var(--nasaq-primary); }

.nasaq-stat--inline { flex-direction: row; align-items: center; justify-content: space-between;
  gap: var(--nasaq-space-3); min-block-size: var(--nasaq-row-h); padding: var(--nasaq-space-2) var(--nasaq-space-4); }
.nasaq-stat--inline .nasaq-stat__value, .nasaq-stat--inline > dd { font-size: var(--nasaq-text-xl); }

.nasaq-stat--current { background: var(--nasaq-primary); border-color: var(--nasaq-primary); color: var(--nasaq-on-primary); }
a.nasaq-stat.nasaq-stat--current, a.nasaq-stat.nasaq-stat--current:hover { color: var(--nasaq-on-primary);
  border-color: var(--nasaq-primary); }
.nasaq-stat--current .nasaq-stat__label, .nasaq-stat--current .nasaq-stat__sub { color: var(--nasaq-accent); }
.nasaq-stat--live .nasaq-stat__value { display: flex; align-items: center; gap: var(--nasaq-space-3); }
.nasaq-stat--live .nasaq-stat__value::before { content: ""; inline-size: 10px; block-size: 10px; flex: none;
  background: var(--nasaq-accent); }

.nasaq-card .nasaq-stat { padding: 0; background: none; border: 0; border-radius: 0; }
.nasaq-card .nasaq-stat--inline { justify-content: flex-start; min-block-size: 0; }

/* ---------- nasaq-emptystate--page: the whole page says one thing (an error, no connection, a closed link): the
   empty state at the size of a page. __code: the number of the error; the school's logo may stand in its place. */
.nasaq-emptystate--page { gap: var(--nasaq-space-4); padding-block: var(--nasaq-space-8); color: var(--nasaq-text); }
.nasaq-emptystate--page > .nasaq-i { inline-size: var(--nasaq-space-7); block-size: var(--nasaq-space-7);
  color: var(--nasaq-muted); }
.nasaq-emptystate--page .nasaq-emptystate__text { margin: 0; font-family: var(--nasaq-font-body);
  font-size: var(--nasaq-text-xl); font-weight: 400; }
.nasaq-emptystate__code { font-size: calc(var(--nasaq-text-3xl) * 2); line-height: 1.2; color: var(--nasaq-primary);
  font-variant-numeric: tabular-nums; }
.nasaq-emptystate--page .nasaq-logo { block-size: var(--nasaq-space-8); }
.nasaq-emptystate--page .nasaq-logo--en { block-size: var(--nasaq-space-7); }

@media (max-width: 760px) {
  .nasaq-statgrid { --nasaq-stat-gap: var(--nasaq-space-3); }
  /* the numbers stay at the kit's largest size; a word in a number's place steps down one size to stay on a line */
  .nasaq-stat--current .nasaq-stat__value { font-size: var(--nasaq-text-2xl); white-space: nowrap; }
  .nasaq-emptystate--page { padding-block: var(--nasaq-space-7); }
  .nasaq-emptystate--page .nasaq-emptystate__text { font-size: var(--nasaq-text-lg); }
}
@media print {
  .nasaq-stat { break-inside: avoid; }
}
