/* ==========================================================================
   GCC Asset Command — 4. Data display
   --------------------------------------------------------------------------
   Built to a fixed spec so every chart in the app reads as one system:
     · bars fill ~78% of their track (capped 64px), 4px rounded data-end,
       square at the baseline — a proportional cap, so the bar-to-gap ratio
       holds at any card width instead of stranding thin bars in a wide card
     · lines 2px; markers >= 8px carrying a 2px surface ring
     · area fills at ~10% opacity; gridlines hairline, SOLID, one step off surface
     · a 2px surface gap separates touching fills (stack segments, adjacent bars)
     · text always wears text tokens — never the series color
     · every chart has a table-view twin; tooltips enhance, never gate
   ========================================================================== */

/* ------------------------------------------------------------ Stat tile -- */
.stat {
  display: flex; flex-direction: column; gap: .25rem; min-width: 0;
}
.stat-label {
  font-size: var(--fs-xs); color: var(--ink-muted); font-weight: 500;
  display: flex; align-items: center; gap: .375rem; min-width: 0;
}
.stat-label .i { width: 14px; height: 14px; flex: none; }
.stat-value {
  font-size: var(--fs-stat); font-weight: 650; line-height: 1.05;
  letter-spacing: -.03em; color: var(--ink);
  /* proportional figures on purpose — tabular-nums looks loose at this size */
}
.stat-value .unit { font-size: .55em; font-weight: 600; color: var(--ink-muted); letter-spacing: 0; }
.stat-foot {
  display: flex; align-items: center; gap: .4375rem; flex-wrap: wrap;
  font-size: var(--fs-2xs); color: var(--ink-muted); margin-top: .0625rem;
}
.stat-tile {
  display: flex; flex-direction: column; gap: .3125rem;
  padding: var(--card-pad);
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); box-shadow: var(--shadow-1);
  min-width: 0;
}
a.stat-tile { color: inherit; text-decoration: none; transition: border-color .14s var(--ease), box-shadow .14s var(--ease), transform .14s var(--ease); }
a.stat-tile:hover { text-decoration: none; border-color: var(--line-strong); box-shadow: var(--shadow-2); transform: translateY(-1px); }
.stat-tile .spark { margin-top: .25rem; }
/* Tiles stretch to the tallest in the row, so pin the footnote to the bottom.
   Without this a foot that wraps to two lines leaves every other tile's foot
   floating at a different height. */
.stat-tile .stat-foot { margin-top: auto; padding-top: .25rem; }
.stat-tile .stat-foot + .stat-foot { margin-top: 0; padding-top: 0; }

/* Delta — signed, against a named period. Color = direction x whether up is
   good; it always ships with an arrow glyph so it is never color-alone. */
.delta {
  display: inline-flex; align-items: center; gap: .1875rem;
  font-size: var(--fs-2xs); font-weight: 600; white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.delta .i { width: 12px; height: 12px; }
.delta-good { color: var(--ok-ink); }
.delta-bad  { color: var(--crit-ink); }
.delta-flat { color: var(--ink-muted); }

/* Hero figure — exactly one per view, in the same sans as everything else. */
.hero-figure {
  font-size: var(--fs-hero); font-weight: 680; line-height: 1;
  letter-spacing: -.035em; color: var(--ink);
}
.hero-label { font-size: var(--fs-sm); color: var(--ink-muted); }

/* ---------------------------------------------------------------- Meter -- */
/* A single ratio against a limit. Track is a lighter step of the fill's own
   ramp, so state reads across the whole bar. */
.meter {
  position: relative; height: 8px; border-radius: var(--r-pill);
  background: var(--seq-100); overflow: hidden;
}
.meter > i {
  display: block; height: 100%; border-radius: var(--r-pill);
  background: var(--seq-400);
  transition: width .5s var(--ease-out);
}
.meter-lg { height: 10px; }
.meter-sm { height: 5px; }
.meter-warn    { background: var(--warn-wash); }    .meter-warn > i    { background: var(--warn); }
.meter-crit    { background: var(--crit-wash); }    .meter-crit > i    { background: var(--crit); }
.meter-ok      { background: var(--ok-wash); }      .meter-ok > i      { background: var(--ok); }
.meter-serious { background: var(--serious-wash); } .meter-serious > i { background: var(--serious); }

/* Meter with a target notch */
.meter .notch {
  position: absolute; top: -2px; bottom: -2px; width: 2px;
  background: var(--ink-2); border-radius: 1px;
}

/* ------------------------------------------------------------- Bar list -- */
/* The workhorse for "compare magnitude, low -> high" over named rows.
   One hue (sequential slot 400) for every bar — a value-ramp on nominal
   categories would double-encode length as hue. */
.barlist { display: flex; flex-direction: column; gap: .5rem; }
.barlist-row { display: grid; grid-template-columns: 1fr auto; gap: .1875rem var(--sp-3); align-items: baseline; min-width: 0; }
.barlist-row > .k {
  font-size: var(--fs-xs); color: var(--ink-2); min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.barlist-row > .v {
  font-size: var(--fs-xs); font-weight: 600; color: var(--ink);
  font-variant-numeric: tabular-nums; white-space: nowrap; text-align: right;
}
.barlist-row > .track {
  grid-column: 1 / -1; height: 7px; border-radius: 0 var(--r-xs) var(--r-xs) 0;
  background: var(--surface-3); overflow: hidden;
}
.barlist-row > .track > i {
  display: block; height: 100%; min-width: 3px;
  border-radius: 0 var(--r-xs) var(--r-xs) 0;   /* square at the baseline */
  background: var(--bar, var(--seq-400));
  transition: width .55s var(--ease-out);
}
a.barlist-row { text-decoration: none; }
a.barlist-row:hover > .k { color: var(--accent-ink); }
a.barlist-row:hover > .track > i { filter: brightness(1.08); }
.barlist-row.dim > .track > i { background: var(--de-emph); }   /* emphasis form */

/* ----------------------------------------------------------- Column plot -- */
/* Trend over time. Container height includes the x-axis band so labels are
   never cropped into a nested scroll. */
.columns {
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
  align-items: end; gap: var(--col-gap, 4px);
  height: var(--plot-h, 132px);
  position: relative;
  padding-top: 1.25rem;   /* room for the direct-labelled endpoint */
}
.columns::before {
  /* baseline: solid hairline, one step off surface */
  content: ""; position: absolute; left: 0; right: 0; bottom: 0;
  height: 1px; background: var(--axis);
}
/* Scoped to .columns: a bare .col would collide with the .col flex-column
   layout utility (1-tokens.css) that unrelated pages/components rely on. */
.columns > .col {
  position: relative; display: flex; flex-direction: column; justify-content: flex-end;
  height: 100%; min-width: 0;
}
.columns > .col > i {
  /* Percentage, not a fixed 24px: a six-month trend in a 500px card was
     leaving ~56px of dead space between 24px bars. A proportional width keeps
     the bar-to-gap ratio near 3:1 whether the card is 380px or 700px wide. */
  display: block; width: 100%; max-width: min(78%, 64px); margin: 0 auto;
  min-height: 2px;
  background: var(--seq-300);
  border-radius: var(--r-xs) var(--r-xs) 0 0;   /* rounded data-end, square at base */
  transition: height .55s var(--ease-out), background-color .13s var(--ease);
}
.columns > .col.now > i { background: var(--seq-500); }
.columns > .col:hover > i { background: var(--seq-600); }
.col-label {
  position: absolute; inset: auto 0 -1.375rem 0;
  font-size: var(--fs-3xs); color: var(--ink-muted); text-align: center;
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
.col-value {
  position: absolute; inset: 0 0 auto 0; text-align: center;
  font-size: var(--fs-3xs); font-weight: 600; color: var(--ink-2);
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
.columns-wrap { padding-bottom: 1.5rem; }   /* the x-axis band */

/* Gridlines behind a plot — solid hairlines only */
.plot-grid {
  position: absolute; inset: 1.25rem 0 0 0; pointer-events: none;
  display: flex; flex-direction: column; justify-content: space-between;
}
.plot-grid > i { display: block; height: 1px; background: var(--grid); }

/* ------------------------------------------------------------ Sparkline -- */
/* One smoothed accent line over a soft gradient fill — the whole trend reads
   at a glance rather than fading into grey with only the last segment lit. */
.spark { display: block; width: 100%; height: 34px; overflow: visible; }
.spark .ln {
  fill: none; stroke: var(--accent); stroke-width: 2;
  stroke-linecap: round; stroke-linejoin: round;
}
.spark .dot { fill: var(--accent); stroke: var(--surface); stroke-width: 2; }  /* 2px surface ring */

/* --------------------------------------------------------------- Donut --- */
/* Part-to-whole at a glance only, <= 6 segments. Segments are separated by a
   2px surface gap, never by a stroke around the mark. */
.donut-wrap { display: flex; align-items: center; gap: var(--sp-5); flex-wrap: wrap; }
.donut { position: relative; flex: none; width: var(--donut-size, 132px); height: var(--donut-size, 132px); }
.donut svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.donut circle { fill: none; stroke-width: var(--donut-w, 14); }
.donut .seg { transition: stroke-dasharray .6s var(--ease-out), opacity .13s var(--ease); }
.donut .seg:hover { opacity: .82; }
.donut .track { stroke: var(--surface-3); }
.donut-center {
  position: absolute; inset: 0; display: grid; place-content: center; text-align: center;
}
.donut-center .v { font-size: var(--fs-2xl); font-weight: 650; line-height: 1; letter-spacing: -.03em; }
.donut-center .k { font-size: var(--fs-3xs); color: var(--ink-muted); margin-top: .1875rem; }

/* ---------------------------------------------------------- Stacked bar -- */
/* One horizontal bar for a status mix. 2px surface gap between segments. */
.stackbar {
  display: flex; height: 10px; border-radius: var(--r-pill); overflow: hidden;
  background: var(--surface-3); gap: 2px;
}
.stackbar > i, .stackbar > a {
  display: block; min-width: 2px; transition: flex-basis .5s var(--ease-out), filter .1s var(--ease);
}
.stackbar > i:first-child, .stackbar > a:first-child { border-radius: var(--r-pill) 0 0 var(--r-pill); }
.stackbar > i:last-child, .stackbar > a:last-child  { border-radius: 0 var(--r-pill) var(--r-pill) 0; }
.stackbar > a { cursor: pointer; text-decoration: none; }
.stackbar > a:hover, .stackbar > a:focus-visible { filter: brightness(1.1); text-decoration: none; }
.stackbar-lg { height: 14px; }

/* --------------------------------------------------------------- Legend -- */
/* Always present for two or more series; identity is never color-alone. */
.legend { display: flex; flex-wrap: wrap; gap: .375rem var(--sp-4); }
.legend-item {
  display: inline-flex; align-items: center; gap: .375rem;
  font-size: var(--fs-2xs); color: var(--ink-2); white-space: nowrap;
}
.legend-item .key { width: 9px; height: 9px; border-radius: 2px; flex: none; background: var(--k, var(--neutral)); }
.legend-item .key-line { width: 12px; height: 2px; border-radius: 1px; }
.legend-item .n { color: var(--ink-muted); font-variant-numeric: tabular-nums; }
.legend-col { flex-direction: column; gap: .5rem; }
.legend-col .legend-item { width: 100%; }
.legend-col .n { margin-left: auto; font-weight: 600; color: var(--ink); }
a.legend-item { cursor: pointer; }
a.legend-item:hover, a.legend-item:focus-visible { text-decoration: none; color: var(--accent-ink); }
a.legend-item:hover .n, a.legend-item:focus-visible .n { color: var(--accent-ink); }

/* -------------------------------------------------------------- Tooltip -- */
.viz-tip {
  position: fixed; z-index: 130; pointer-events: none;
  padding: .4375rem .5625rem; max-width: 260px;
  background: var(--surface); border: 1px solid var(--line-strong);
  border-radius: var(--r-sm); box-shadow: var(--shadow-3);
  font-size: var(--fs-2xs); color: var(--ink); line-height: 1.45;
  opacity: 0; transform: translateY(3px); transition: opacity .1s var(--ease), transform .1s var(--ease);
}
.viz-tip.on { opacity: 1; transform: none; }
.viz-tip b { font-weight: 650; }
.viz-tip .k { color: var(--ink-muted); }
/* Hit targets are bigger than the mark itself */
[data-tip] { cursor: default; }
.col, .donut .seg, .barlist-row, .stackbar > i { cursor: default; }
a.barlist-row, .donut a, .donut a .seg { cursor: pointer; }

/* ---------------------------------------------------- Table-view twin ---- */
/* Every chart ships one: the WCAG-clean equivalent, one <details> away. */
.viz-table { margin-top: var(--sp-3); }
.viz-table > summary {
  display: inline-flex; align-items: center; gap: .3125rem;
  font-size: var(--fs-2xs); color: var(--ink-muted); cursor: pointer;
  list-style: none; padding: .1875rem .375rem; margin-left: -.375rem;
  border-radius: var(--r-xs);
}
.viz-table > summary::-webkit-details-marker { display: none; }
.viz-table > summary:hover { background: var(--surface-2); color: var(--ink-2); }
.viz-table > summary .i { width: 13px; height: 13px; transition: transform .15s var(--ease); }
.viz-table[open] > summary .i { transform: rotate(90deg); }
.viz-table table { width: 100%; margin-top: .375rem; font-size: var(--fs-2xs); }
.viz-table th, .viz-table td {
  padding: .25rem .5rem; text-align: left; border-bottom: 1px solid var(--line);
}
.viz-table th { color: var(--ink-muted); font-weight: 600; }
.viz-table td.num, .viz-table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.viz-table tr:last-child td { border-bottom: 0; }

/* ------------------------------------------------------- Series palette -- */
/* A slot sets the MARK color only (--k for keys/strokes, --bar for fills).
   It deliberately does not set `color` — text always wears a text token, and
   the colored key beside it carries the identity. */
.s1 { --k: var(--series-1); --bar: var(--series-1); }
.s2 { --k: var(--series-2); --bar: var(--series-2); }
.s3 { --k: var(--series-3); --bar: var(--series-3); }
.s4 { --k: var(--series-4); --bar: var(--series-4); }
.s5 { --k: var(--series-5); --bar: var(--series-5); }
.s6 { --k: var(--series-6); --bar: var(--series-6); }
.s7 { --k: var(--series-7); --bar: var(--series-7); }
.s8 { --k: var(--series-8); --bar: var(--series-8); }
.so { --k: var(--series-other); --bar: var(--series-other); }

/* Status fills for status-encoded marks (never a series slot) */
.f-ok      { background: var(--ok); }
.f-warn    { background: var(--warn); }
.f-serious { background: var(--serious); }
.f-crit    { background: var(--crit); }
.f-info    { background: var(--accent); }
.f-neutral { background: var(--neutral); }
.f-muted   { background: var(--de-emph); }
.k-ok      { --k: var(--ok); }
.k-warn    { --k: var(--warn); }
.k-serious { --k: var(--serious); }
.k-crit    { --k: var(--crit); }
.k-info    { --k: var(--accent); }
.k-neutral { --k: var(--neutral); }
.k-muted   { --k: var(--de-emph); }

/* Texture — the accessibility channel. Opt-in only: forced-colors, print, or
   the a11y setting. 45 degrees and its 135 mirror, never horizontal/vertical. */
@media print, (forced-colors: active) {
  .stackbar > i:nth-child(2), .donut .seg:nth-child(3n+2) {
    background-image: repeating-linear-gradient(45deg,
      rgba(0,0,0,.34) 0 2px, transparent 2px 5px);
  }
  .stackbar > i:nth-child(3), .donut .seg:nth-child(3n) {
    background-image: repeating-linear-gradient(135deg,
      rgba(0,0,0,.34) 0 2px, transparent 2px 5px);
  }
}
html[data-texture="on"] .stackbar > i:nth-child(2n) {
  background-image: repeating-linear-gradient(45deg,
    rgba(255,255,255,.42) 0 2px, transparent 2px 5px);
}
html[data-texture="on"] .stackbar > i:nth-child(3n) {
  background-image: repeating-linear-gradient(135deg,
    rgba(255,255,255,.42) 0 2px, transparent 2px 5px);
}
