/*
 * TAG Legal Desk v2.1, J109: Stats (js\v21_stats.js) and the one balance line in the Canteen.
 * The desk's own tokens and glass only (bible 5): nothing here sets a colour of its own, so Light, Dark, Eucalypt,
 * Harbour, High contrast and the Canteen themes all follow. Numbers use tabular figures. No inline styles: the bars
 * take their length from a custom property set through the CSSOM. 390 px wide works with no page scroll sideways
 * (the two tables scroll inside their own framed region, which the keyboard can reach).
 * Welfare first: while the core marks the page data-quiet every Stats element hides at once.
 */

:root[data-quiet="on"] .v21s,
:root[data-quiet="on"] .v21s-prof { display: none !important; }

/* ---------- the Canteen: "142 Leaf Tokens (your points)" ---------- */
.v21c-bal .v21c-bal-pts { font-weight: 500; color: var(--ink-2); }
.v21c-tree-line { margin: 0; }
@media (max-width: 480px) {
  .v21c-bal .v21c-bal-pts { display: none; }
}

/* ---------- the sheet ---------- */
.v21s { display: grid; gap: 24px; min-width: 0; }
.v21s-intro { margin: 0; max-width: 72ch; }
.v21s-source { max-width: 72ch; }
.v21s-sec { display: grid; gap: 12px; min-width: 0; }
.v21s-h { margin: 0; font-size: .75rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); }
.v21s-num, .v21s-big, .v21s .stat .n, .v21s-prof .stat .n { font-family: var(--font-num, inherit); font-variant-numeric: tabular-nums; }

/* ---------- the team leaders: big friendly cards ---------- */
.v21s-leaders { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; }
.v21s-leader { display: grid; align-content: start; gap: 8px; padding: 16px; border-radius: var(--r-card); min-width: 0; }
.v21s-leader-h { margin: 0; font-size: .875rem; line-height: 1.25rem; font-weight: 700; color: var(--ink-2); }
.v21s-leader-av { display: flex; gap: 0; }
.v21s-leader-av .av + .av { margin-left: -12px; }
.v21s-leader-who { margin: 0; font-weight: 700; overflow-wrap: anywhere; }
.v21s-leader-n { margin: 0; display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px; }
.v21s-big { font-size: 2rem; line-height: 2.25rem; font-weight: 750; letter-spacing: -.01em; color: var(--brand-text); }
.v21s-unit { color: var(--ink-2); }
.v21s-leader-none { margin: 0; }

/* ---------- the tables ---------- */
.v21s-table-wrap { max-width: 100%; overflow-x: auto; border-radius: 16px; border: 1px solid var(--glass-edge); background: var(--glass-1); box-shadow: inset 0 1px 0 var(--glass-hi), 0 0 0 1px var(--glass-rim); }
.v21s-table-wrap:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.v21s-table { width: 100%; border-collapse: collapse; font-size: .875rem; line-height: 1.25rem; }
.v21s-table th, .v21s-table td { padding: 8px 10px; text-align: left; vertical-align: middle; border-bottom: 1px solid var(--glass-rim); }
.v21s-table tbody tr:last-child > * { border-bottom: 0; }
.v21s-table thead th { font-size: .75rem; font-weight: 700; color: var(--ink-2); white-space: nowrap; }
.v21s-table .v21s-th-n, .v21s-table .v21s-td-n { text-align: right; }
.v21s-table .v21s-td-n { white-space: nowrap; }
.v21s-who { position: sticky; left: 0; z-index: 1; background: var(--solid); font-weight: 600; white-space: nowrap; min-width: 140px; max-width: 220px; }
.v21s-who > .av { vertical-align: middle; margin-right: 8px; }
.v21s-who > .ell { display: inline-block; max-width: 150px; vertical-align: middle; }
.v21s-table thead .v21s-th-name { position: sticky; left: 0; z-index: 2; background: var(--solid); }
.v21s-me > * { background: var(--brand-soft); }
.v21s-me > .v21s-who { background: var(--solid-2); }
.v21s-sort { display: inline-flex; align-items: center; gap: 4px; min-height: 44px; padding: 0 6px; margin: -8px -6px; border: 0; border-radius: 10px; background: transparent; color: inherit; font: inherit; font-weight: 700; cursor: pointer; }
.v21s-sort:hover { background: var(--glass-hover); }
.v21s-sort:focus-visible { outline: 3px solid var(--focus); outline-offset: 0; }
.v21s-arrow { display: inline-block; min-width: .75em; font-size: .625rem; color: var(--brand-text); }
[aria-sort="none"] .v21s-arrow { min-width: 0; }
.v21s-none { color: var(--ink-3); }
.v21s-best td { min-width: 132px; }
.v21s-bestc { display: grid; gap: 2px; justify-items: start; }
.v21s-when { display: block; }
.v21s-tag { margin-top: 4px; white-space: nowrap; }

/* ---------- jobs by kind ---------- */
.v21s-kinds { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.v21s-kind-card { display: grid; align-content: start; gap: 10px; padding: 14px 16px; border-radius: var(--r-card); min-width: 0; }
.v21s-kind-top { display: flex; align-items: center; gap: 8px; min-width: 0; }
.v21s-kind-top h4 { margin: 0; font-size: 1rem; font-weight: 700; min-width: 0; flex: 1 1 auto; }
.v21s-kind-total { white-space: nowrap; font-variant-numeric: tabular-nums; }
.v21s-kind-card > .meta { margin: 0; }
.v21s-kind-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.v21s-kind { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "name n" "bar bar"; column-gap: 12px; row-gap: 4px; align-items: baseline; }
.v21s-kind-name { grid-area: name; min-width: 0; overflow-wrap: anywhere; }
.v21s-kind-n { grid-area: n; font-weight: 700; }
.v21s-bar { grid-area: bar; display: block; height: 8px; border-radius: 999px; background: var(--brand-soft); overflow: hidden; }
.v21s-bar > i { display: block; height: 100%; border-radius: 999px; background: var(--accent); transform-origin: left center; transform: scaleX(var(--v21s-p, 0)); }

/* ---------- your profile ---------- */
.v21s-prof { display: grid; gap: 10px; }
.v21s-prof .v21s-stat .n { font-size: 1.375rem; }
.v21s-mine-src { margin: 0; }
.v21s-mine-src:empty { display: none; }

/* ---------- high contrast: black on white, borders, no glass ---------- */
:root[data-theme="high_contrast"] .v21s-table-wrap { background: #FFFFFF; border: 2px solid #000000; box-shadow: none; }
:root[data-theme="high_contrast"] .v21s-table th, :root[data-theme="high_contrast"] .v21s-table td { border-bottom: 1px solid #000000; }
:root[data-theme="high_contrast"] .v21s-who, :root[data-theme="high_contrast"] .v21s-table thead .v21s-th-name { background: #FFFFFF; }
:root[data-theme="high_contrast"] .v21s-me > * { background: #F2F2F2; }
:root[data-theme="high_contrast"] .v21s-bar { background: #FFFFFF; border: 1px solid #000000; }
:root[data-theme="high_contrast"] .v21s-bar > i { background: #000000; }
:root[data-theme="high_contrast"] .v21s-big { color: #000000; }
:root[data-theme="high_contrast"] .v21s-sort { text-decoration: underline; }

/* ---------- reduced glass: solid surfaces ---------- */
:root[data-glass="reduced"] .v21s-table-wrap { background: var(--solid); }

/* ---------- a phone: one column, the tables scroll inside their frame ---------- */
@media (max-width: 600px) {
  .v21s { gap: 20px; }
  .v21s-leaders { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .v21s-leader { padding: 12px; }
  .v21s-big { font-size: 1.5rem; line-height: 1.75rem; }
  .v21s-kinds { grid-template-columns: minmax(0, 1fr); }
  .v21s-who { min-width: 112px; }
  .v21s-who > .ell { max-width: 96px; }
}
@media (max-width: 360px) {
  .v21s-leaders { grid-template-columns: minmax(0, 1fr); }
}

/* J135 (28 Sep 2026): a bonus column heading (Snipes, Speeds, Bonus) has a tooltip; the dotted line says so. */
.v21s-th-bonus .v21s-sort > span:first-child { text-decoration: underline dotted; text-underline-offset: 3px; }
