/* Rootpad v3: Metrics page (docs/design-v3/DESIGN.md §5.6, mock panel 6). Owner: M (METRICS). Loaded after
   css/site.css by metricas.html only. Every rule is scoped under the page's main class (.metrics-page), uses the
   tokens of site.css only, declares no keyframes, no transition and no motion block (DESIGN §2.5, §8.2): the base
   components (stat tiles §3.8, chart frame §3.13, lists §3.18, defs) are only placed and sized here. */

/* ------------------------------------------------------------ head: the mock's title and lead, close to the cards */
.metrics-page .page-head {
  padding-bottom: var(--s5);
}

/* ------------------------------------------------------------ the four stat cards (M1–M4) */
/* each tile its own card (§3.8 standalone); 2 × 2 on phones and tablets, one row of four from 900 px (the mock) */
.metrics-page #metrics-chain .stat-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--s3);
}
.metrics-page .stat-grid.cards .stat {
  display: flex;
  flex-direction: column;
  padding: var(--s4);
}
.metrics-page .stat dt {
  font-size: 14px;
}
.metrics-page .stat-v {
  font-size: 22px;
}
/* the narrowest phones (QA T-METRICS-2): at 320 px a value box is 104 px, and at 22 px "0.0018 ETH" (121 px) left its
   "ETH" alone on a second line; 18 px keeps it and "123.45 ETH" on one line, a longer value still wraps at its space */
@media (max-width: 359px) {
  .metrics-page .stat-v { font-size: 18px; }
}
.metrics-page .stat-sub {
  margin-top: var(--s2);
}
.metrics-page .stat-sub.up {
  font-weight: 700;
}
.metrics-page .stat-sub .sk {
  display: inline-block;
  width: 9ch;
  height: 12px;
}
@media (min-width: 600px) {
  .metrics-page #metrics-chain .stat-grid {
    gap: var(--s4);
  }
  .metrics-page .stat-grid.cards .stat {
    padding: var(--s5);
  }
  .metrics-page .stat-v {
    font-size: var(--fs-num);
  }
}
@media (min-width: 900px) {
  .metrics-page #metrics-chain .stat-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}
/* under the cards: the block they were read at, the history's own block, the scope, a history state */
.metrics-page #metrics-chain > p,
.metrics-page #metrics-chain > div {
  max-width: 75ch;
  margin: var(--s3) 0 0;
}
.metrics-page #metrics-chain > .mx-state {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s3);
  margin: 0;
}
.metrics-page #metrics-chain > .mx-state > .alert {
  margin: 0;
}
.metrics-page #metrics-chain > .not-live {
  max-width: none;
  margin: 0;
}
.metrics-page #metrics-chain .not-live h3 {
  margin-top: 0;
}
.metrics-page .mx-alert {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s2) var(--s3);
}
.metrics-page .mx-alert p {
  flex: 1 1 24ch;
  margin: 0;
}

/* ------------------------------------------------------------ Protocol activity (M5, §3.13 bars + line) */
.metrics-page .mx-activity {
  margin: var(--s6) 0 0;
}
.metrics-page .mx-activity .chart-head {
  align-items: center;
}
.metrics-page .mx-activity h2 {
  margin: 0;
}
/* the ranges: three small boxed buttons (the mock), the chosen one in the soft accent; 44 px tall on phones */
.metrics-page .range-seg {
  gap: var(--s2);
  padding: 0;
  background: none;
}
.metrics-page .range-seg button {
  min-width: 56px;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--card-2);
}
.metrics-page .range-seg button[aria-pressed='true'] {
  border-color: var(--line-strong);
  background: var(--accent-soft);
  color: var(--accent);
}
/* phones and touch screens (§9.2, QA T-CHROME-4): the ranges are whole 44-px tap targets; with a mouse they keep 36 px */
@media (max-width: 899px), (any-pointer: coarse) {
  .metrics-page .range-seg button { min-height: 44px; }
  /* every "Try again" of the page (the cards, the lists, the chart's own) is 44 px tall on phones too (M-K1) */
  .metrics-page .btn.sm { min-height: 44px; }
}
.metrics-page .mx-chart .chart-legend {
  margin-bottom: var(--s3);
}
/* an empty range: its message inside a dashed frame (nothing that looks like data) */
.metrics-page .mx-chart .chart-empty:not(.sk) {
  padding: var(--s5);
  border: 1px dashed var(--line);
  border-radius: var(--r);
}
/* the loading block and the empty range take the chart's own height (300 px from 600 px): no jump between ranges */
@media (min-width: 600px) {
  .metrics-page .mx-chart .chart-empty {
    min-height: 300px;
  }
}
.metrics-page .mx-chart > .alert {
  margin: 0;
}
.metrics-page .mx-chart .chart-to {
  margin: var(--s2) 0 0;
  color: var(--soft);
  font-size: 13px;
}

/* ------------------------------------------------------------ Top coins by Root vault (M6), Recent graduations (M7) */
/* side by side from 900 px (the mock), one under the other below */
.metrics-page .mx-lists {
  display: grid;
  gap: var(--s4);
  margin-top: var(--s4);
}
@media (min-width: 900px) {
  .metrics-page .mx-lists {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--s6);
    margin-top: var(--s6);
  }
}
.metrics-page .mx-lists > .card {
  display: flex;
  flex-direction: column;
  margin: 0;
}
.metrics-page .mx-lists h2 {
  margin-bottom: var(--s2);
  font-size: 19px;
}
.metrics-page .mx-lists .note,
.metrics-page .mx-lists .read-at {
  margin: var(--s3) 0 0;
}
.metrics-page .mx-top > .note {
  margin-top: auto;
  padding-top: var(--s3);
}
/* one row: rank · avatar 28 · name + $SYM · amount or time (right). The name link covers the row: a 48-px tap target */
.metrics-page .mx-top-list,
.metrics-page .grad-list {
  display: block;
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: mx-rank;
}
.metrics-page .mx-top-item,
.metrics-page li.grad-item {
  position: relative;
  display: grid;
  grid-template-columns: 20px 28px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  min-height: 52px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}
.metrics-page .mx-top-item:last-child,
.metrics-page li.grad-item:last-child {
  border-bottom: 0;
}
.metrics-page .mx-top-item .rank {
  color: var(--soft);
  font-size: 14px;
}
/* the graduations come without a rank: their place in the list, from a counter (decoration: the list says it) */
.metrics-page li.grad-item {
  counter-increment: mx-rank;
}
.metrics-page li.grad-item::before {
  content: counter(mx-rank);
  content: counter(mx-rank) / '';
  color: var(--soft);
  font-size: 14px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.metrics-page .mx-top-item .thumb,
.metrics-page li.grad-item .thumb {
  width: 28px;
  height: 28px;
}
.metrics-page .thumb.monogram {
  font-size: 13px;
}
.metrics-page .mx-top-name {
  min-width: 0;
}
.metrics-page .mx-coin,
.metrics-page li.grad-item a {
  color: var(--text);
  font-weight: 700;
  text-decoration: none;
  overflow-wrap: anywhere;
}
.metrics-page .mx-coin::after,
.metrics-page li.grad-item a::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: var(--r-sm);
}
.metrics-page a.mx-coin:hover,
.metrics-page li.grad-item a:hover {
  color: var(--accent-hover);
}
.metrics-page a.mx-coin:focus-visible,
.metrics-page li.grad-item a:focus-visible {
  outline: 0;
}
.metrics-page a.mx-coin:focus-visible::after,
.metrics-page li.grad-item a:focus-visible::after {
  outline: 2px solid var(--accent-hover);
  outline-offset: 2px;
}
.metrics-page .mx-top-name .coin-sym,
.metrics-page li.grad-item .coin-sym {
  display: inline;
  margin-left: 4px;
  font-weight: 400;
}
.metrics-page .mx-top-name .pill {
  margin-left: 6px;
  vertical-align: 1px;
}
.metrics-page .mx-top-name .row-warn {
  display: block;
}
.metrics-page .mx-top-eth {
  text-align: right;
  white-space: nowrap;
}
.metrics-page li.grad-item time,
.metrics-page li.grad-item .num {
  margin-left: 0;
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}
/* the parts with their own title (the exact ETH, the hidden-characters pill, a graduation's UTC date or block) sit
   above the row's link, so a pointer reaches their title, as site.css lifts them in the coin rows (M-K2) */
.metrics-page .mx-top-eth,
.metrics-page .mx-top-name .pill,
.metrics-page li.grad-item time,
.metrics-page li.grad-item .num {
  position: relative;
  z-index: 1;
}
/* the grey rows while reading */
.metrics-page .mx-top-item > .sk,
.metrics-page li.grad-item > .sk {
  grid-column: 1 / -1;
  width: 100%;
  height: 16px;
}
.metrics-page li.grad-item.mx-sk-row::before {
  content: none;
}

/* ------------------------------------------------------------ "What each number means" (chain definitions) */
.metrics-page details.defs {
  margin: var(--s6) 0 0;
}
.metrics-page details.defs > summary {
  font-size: 17px;
}
.metrics-page details.defs dd,
.metrics-page details.defs li {
  max-width: 75ch;
}
.metrics-page details.defs > ul {
  margin: var(--s3) 0 var(--s2);
  color: var(--muted);
  font-size: var(--fs-sm);
}
.metrics-page details.defs > ul strong {
  color: var(--text);
}

/* ------------------------------------------------------------ From the Fungi indexer (panels.renderMetrics) */
.metrics-page .mx-fungi {
  margin-top: var(--s8);
  padding-top: var(--s6);
  border-top: 1px solid var(--line);
}
.metrics-page .mx-fungi > h2 {
  margin-bottom: var(--s4);
}
/* one card per group, three side by side from 900 px; the notes and states under them at reading width */
.metrics-page #metrics-body {
  display: grid;
  gap: var(--s4);
}
.metrics-page #metrics-body > * {
  margin: 0;
}
.metrics-page #metrics-body > :not(.mx-group) {
  max-width: 75ch;
}
.metrics-page #metrics-body > p.tag.placeholder {
  width: fit-content;
}
@media (min-width: 900px) {
  .metrics-page #metrics-body {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: var(--s6);
  }
  .metrics-page #metrics-body > :not(.mx-group) {
    grid-column: 1 / -1;
  }
}
.metrics-page .mx-group h2 {
  margin: 0 0 var(--s2);
  font-size: 19px;
}
.metrics-page .mx-group .kv {
  margin: 0;
}
.metrics-page #metrics-body > .kv {
  padding: 8px 20px;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--card);
}
.metrics-page .mx-fungi-notes > .note {
  max-width: 75ch;
  margin: var(--s4) 0 0;
}
