/* ================= STORAGE EXPLORER — THE THREE CHARTS =================
   One prefix per sheet — `sx-` the shell, `sxc-` this file, `sxr-` retention, `sxp-` the drawer; css-class-collision-check.py reports two sheets
   declaring one bare class. Every class here starts `sxc-`. It does not style its hosts (`.sx-tree`, `.sx-agechart`, `.sx-donutwrap` are
   alt-storage.css's). Tokens only; the chart text roles are the shared `.a-chart-axis` / `.a-chart-val` and the series colours
   `--a-chart-1..6` (DS-A07). Colour is never the only signal (sys_design-system.md §18): legend text and a border + ✓ carry identity too.
   The treemap has no per-scope hue on purpose: area is the message, text is identity. */

/* ---------- screen-reader-only, this file's own (the collision check forbids extending `.a-sr`) ---------- */
.alt-app .sxc-sr{
  position:absolute; width:1px; height:1px; margin:-1px; padding:0; overflow:hidden; clip:rect(0 0 0 0); white-space:nowrap; border:0;
}

/* ---------- the shared readout ----------
   FIXED, so it is positioned against the viewport whichever scroll container the mark sits in. A layer, so its z-index is a token. The look is
   the popover's (`.a-chart-tip`, alt-admin-components.css); only position and pointer behaviour are this file's. */
.alt-app .sxc-tip{ position:fixed; z-index:var(--z-float); pointer-events:none; }
.alt-app .sxc-tip-t{ font-weight:600; margin-bottom:var(--a-1); }
.alt-app .sxc-tip-r{ display:flex; gap:var(--a-3); justify-content:space-between; }
.alt-app .sxc-tip-k{ color:var(--a-dim); }
.alt-app .sxc-tip-v{ font-variant-numeric:tabular-nums; text-align:right; }

/* ---------- empty and degraded ---------- */
.alt-app .sxc-empty{
  display:flex; flex-direction:column; gap:var(--a-1); padding:var(--a-5);
  border:1px dashed var(--a-line); border-radius:var(--a-r); background:var(--a-bg);
}
.alt-app .sxc-empty-t{ margin:0; font-size:var(--a-fs-13); font-weight:600; line-height:var(--a-lh-ui); color:var(--a-text); }
.alt-app .sxc-empty-d{ margin:0; font-size:var(--a-fs-12); line-height:var(--a-lh-ui); color:var(--a-dim); max-width:62ch; }

/* A caveat is not a warning band: it is the sentence that keeps a figure honest, in the hint role (DS-48). */
.alt-app .sxc-note{
  display:flex; align-items:center; flex-wrap:wrap; gap:var(--a-1) var(--a-2); margin:var(--a-2) 0 0;
  font-size:var(--a-fs-12); font-weight:400; line-height:var(--a-lh-ui); color:var(--a-dim); max-width:78ch;
}
.alt-app .sxc-note.is-warn{ color:var(--a-amber); }
.alt-app .sxc-key{
  width:var(--a-dot); height:var(--a-dot); border-radius:var(--a-r-sm); flex:0 0 auto; border:1px solid var(--a-line-strong);
}
.alt-app .sxc-key.is-exact{ background:var(--a-chart-1); }
.alt-app .sxc-key.is-est{ background:var(--a-blue-soft); }
.alt-app .sxc-key-l{ margin-inline-end:var(--a-3); }

/* THE SELECTED MARK. A glyph rather than an icon: it survives a stylesheet that failed to load, and it is the half of "selected" that is not colour. */
.alt-app .sxc-tick{ flex:0 0 auto; font-size:var(--a-fs-11); line-height:var(--a-lh-tight); color:var(--a-blue-text); margin-inline-end:var(--a-1); }

/* ============ 1 · THE TREEMAP ============ */

/* THE CANVAS HAS ITS OWN HEIGHT, and the JS measures THIS element rather than the host: squarify needs a real aspect ratio, and a box that
   reports zero produces a column of slivers. */
.alt-app .sxc-canvas{
  position:relative; width:100%; height:clamp(280px, 40vh, 440px); border-radius:var(--a-r); overflow:hidden; background:var(--a-bg);
}
.alt-app .sxc-tile{ position:absolute; display:flex; flex-direction:column; padding:var(--a-sp-2); min-width:0; min-height:0; }
.alt-app .sxc-tile-head{
  flex:1 1 auto; min-width:0; min-height:0; display:flex; flex-direction:column; align-items:flex-start; justify-content:flex-start;
  gap:1px; padding:var(--a-2); text-align:left; font:inherit; cursor:pointer;
  color:var(--a-text); background:var(--a-blue-soft); border:1px solid var(--a-line); border-radius:var(--a-r-sm); overflow:hidden;
}
.alt-app .sxc-tile-head:hover{ background:var(--a-blue-fill); }
/* SELECTED IS A BORDER WEIGHT FIRST: the inset ring the rest of the suite uses for a chosen thing (§7), and the ✓ inside carries it without colour. */
.alt-app .sxc-tile.is-on > .sxc-tile-head{ border-color:var(--a-blue); border-width:2px; box-shadow:0 0 0 1px var(--a-blue) inset; }
.alt-app .sxc-tile-l{
  display:flex; align-items:center; min-width:0; max-width:100%; font-weight:600; font-size:var(--a-fs-12); line-height:var(--a-lh-tight);
}
.alt-app .sxc-tile-n{ overflow:hidden; text-overflow:ellipsis; white-space:nowrap; min-width:0; }
.alt-app .sxc-tile-v{ font-size:var(--a-fs-12); line-height:var(--a-lh-tight); font-variant-numeric:tabular-nums; color:var(--a-text); }
.alt-app .sxc-tile-s{ font-size:var(--a-fs-11); line-height:var(--a-lh-tight); color:var(--a-dim); }
/* Value and subtitle are flex items of the head (a column, `align-items:flex-start`), whose min-width is `auto` = the text's own width: in a
   narrow tile they poked past the head and were only clipped, so the head reported a scrollable overflow of 1-2px. Same truncation as the name. */
.alt-app .sxc-tile-v,
.alt-app .sxc-tile-s{ min-width:0; max-width:100%; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.alt-app .sxc-tile-rows{ flex:0 0 auto; display:flex; flex-direction:column; gap:1px; padding:var(--a-sp-2) 0 0; min-width:0; overflow:hidden; }
.alt-app .sxc-cls{
  display:flex; align-items:center; justify-content:space-between; gap:var(--a-2); width:100%; min-width:0; height:var(--a-chip-h);
  padding:0 var(--a-2); font:inherit; font-size:var(--a-fs-11); line-height:var(--a-lh-tight); text-align:left; cursor:pointer;
  color:var(--a-text); background:var(--a-panel); border:1px solid transparent; border-radius:var(--a-r-sm);
}
.alt-app .sxc-cls:hover{ background:var(--a-raised); }
.alt-app .sxc-cls.is-on{ border-color:var(--a-blue); border-width:2px; background:var(--a-blue-soft); font-weight:600; }
.alt-app .sxc-cls-l{ overflow:hidden; text-overflow:ellipsis; white-space:nowrap; min-width:0; }
.alt-app .sxc-cls-v{ flex:0 0 auto; font-variant-numeric:tabular-nums; color:var(--a-dim); }
.alt-app .sxc-more{ font-size:var(--a-fs-11); line-height:var(--a-lh-tight); color:var(--a-faint); padding:0 var(--a-2); }

/* ---------- bar mode ---------- */
.alt-app .sxc-bars{ display:flex; flex-direction:column; gap:var(--a-2); }
.alt-app .sxc-bar{
  display:flex; flex-direction:column; gap:var(--a-1); width:100%; padding:var(--a-2) var(--a-3);
  font:inherit; text-align:left; cursor:pointer; color:var(--a-text); background:var(--a-panel);
  border:1px solid var(--a-line); border-radius:var(--a-r);
}
.alt-app .sxc-bar:hover{ background:var(--a-raised); }
.alt-app .sxc-bar.is-on{ border-color:var(--a-blue); border-width:2px; box-shadow:0 0 0 1px var(--a-blue) inset; }
.alt-app .sxc-bar-top{ display:flex; align-items:baseline; gap:var(--a-2); min-width:0; }
.alt-app .sxc-bar-l{
  flex:1 1 auto; min-width:0; font-weight:600; font-size:var(--a-fs-13); line-height:var(--a-lh-ui);
  overflow:hidden; text-overflow:ellipsis; white-space:nowrap;
}
.alt-app .sxc-bar-v{ flex:0 0 auto; font-variant-numeric:tabular-nums; font-size:var(--a-fs-13); font-weight:600; line-height:var(--a-lh-ui); }
/* THE TRACK IS A GRID ROW OF ITS OWN HEIGHT, so a fill can never be drawn over the label beneath it (§10). */
.alt-app .sxc-bar-track{
  display:flex; width:100%; height:var(--a-sp-8); border-radius:var(--a-r-pill); background:var(--a-bg); border:1px solid var(--a-line-soft); overflow:hidden;
}
.alt-app .sxc-bar-fill{ width:var(--sxc-v, 0%); height:100%; }
.alt-app .sxc-bar-fill.is-exact{ background:var(--a-chart-1); }
.alt-app .sxc-bar-fill.is-est{ background:var(--a-blue-soft); }
.alt-app .sxc-bar-sub{ font-size:var(--a-fs-11); line-height:var(--a-lh-tight); color:var(--a-dim); }

/* ---------- table mode ----------
   The table is `.a-table` in `.a-table-wrap` (alt-admin-components.css); this is only what is particular to it. Six columns of figures do not
   fit a phone, so the wrap scrolls inside itself rather than widening the page. */
.alt-app .sxc-table{ min-width:560px; }
.alt-app .sxc-tcell{
  display:inline-flex; align-items:center; max-width:32ch; padding:var(--a-sp-2) var(--a-1); margin-inline-start:calc(var(--a-1) * -1);
  font:inherit; font-weight:600; text-align:left; cursor:pointer;
  color:var(--a-text); background:none; border:1px solid transparent; border-radius:var(--a-r-sm);
}
.alt-app .sxc-tcell:hover{ background:var(--a-raised); }
.alt-app .sxc-tcell.is-on{ border-color:var(--a-blue); border-width:2px; }

/* ============ 2 · AGE DISTRIBUTION ============ */

/* AN EXPLICIT GRID, not flex: five equal tracks that a tall bar cannot overrun, and minmax(0,1fr) so a long band label cannot push the row wider. */
.alt-app .sxc-age{ display:grid; grid-template-columns:repeat(5, minmax(0, 1fr)); gap:var(--a-2); align-items:end; }
.alt-app .sxc-age-col{ min-width:0; display:flex; }
.alt-app .sxc-age-btn{
  flex:1 1 auto; min-width:0; display:flex; flex-direction:column; gap:var(--a-1); padding:var(--a-1); font:inherit; cursor:pointer;
  color:var(--a-text); background:none; border:1px solid transparent; border-radius:var(--a-r-sm);
}
.alt-app .sxc-age-btn:hover{ background:var(--a-raised); }
.alt-app .sxc-age-btn.is-on{ border-color:var(--a-blue); border-width:2px; background:var(--a-blue-soft); }
.alt-app .sxc-age-track{
  display:flex; flex-direction:column; justify-content:flex-end; align-items:center; gap:var(--a-1); height:150px; min-width:0;
}
/* The value label and the band label take the shared chart roles (`a-chart-val`, `a-chart-axis`); only their fit is here. */
.alt-app .sxc-age-val{ white-space:nowrap; overflow:hidden; text-overflow:ellipsis; max-width:100%; }
.alt-app .sxc-age-fill{
  width:100%; height:var(--sxc-v, 2%); min-height:var(--a-sp-2); background:var(--a-chart-1); border-radius:var(--a-r-sm) var(--a-r-sm) 0 0;
}
/* A BAND WITH NOTHING IN IT IS STILL A MEASUREMENT. It keeps its hairline and its "0" rather than disappearing. */
.alt-app .sxc-age-btn.is-zero > .sxc-age-track > .sxc-age-fill{ background:var(--a-line-strong); }
.alt-app .sxc-age-btn.is-on > .sxc-age-track > .sxc-age-fill{ background:var(--a-blue-text); }
.alt-app .sxc-age-lab{ display:flex; align-items:center; justify-content:center; gap:1px; text-align:center; overflow-wrap:anywhere; }
.alt-app .sxc-age-btn.is-on > .sxc-age-lab{ color:var(--a-text); font-weight:600; }

/* ============ 3 · DATA TYPE BREAKDOWN ============ */

.alt-app .sxc-donut{ display:grid; grid-template-columns:minmax(0, 168px) minmax(0, 1fr); gap:var(--a-4); align-items:center; }
/* The ring and its HTML centre (DS-A07: never SVG text in a viewBox). `.a-chart-centre` lays the figure over it. */
.alt-app .sxc-donut-fig{ display:block; width:100%; max-width:168px; }
.alt-app .sxc-donut-svg{ width:100%; height:auto; max-width:168px; display:block; }
.alt-app .sxc-slice{ fill:none; stroke-width:14; stroke:var(--a-line-strong); }
.alt-app .sxc-slice.is-live{ cursor:pointer; }
/* The selected slice thickens AND lightens: two signals, and the legend row beside it carries the word. Unselected slices stay whole (§7). */
.alt-app .sxc-slice.is-on{ stroke-width:19; }
.alt-app .sxc-s0{ stroke:var(--a-faint); }
.alt-app .sxc-s1{ stroke:var(--a-chart-1); }
.alt-app .sxc-s2{ stroke:var(--a-chart-2); }
.alt-app .sxc-s3{ stroke:var(--a-chart-3); }
.alt-app .sxc-s4{ stroke:var(--a-chart-4); }
.alt-app .sxc-s5{ stroke:var(--a-chart-5); }
/* The centre figure is the tile's: narrow enough to sit inside the ring's hole, and wrapped rather than clipped. */
.alt-app .sxc-donut-centre{ padding:0 var(--a-6); }
.alt-app .sxc-donut-val{ max-width:100%; overflow-wrap:anywhere; }

.alt-app .sxc-legend{ display:flex; flex-direction:column; gap:var(--a-sp-2); min-width:0; }
.alt-app .sxc-lg{
  display:flex; align-items:flex-start; gap:var(--a-2); width:100%; padding:var(--a-1) var(--a-2);
  font:inherit; font-size:var(--a-fs-12); line-height:var(--a-lh-ui); text-align:left; color:var(--a-text); background:none;
  border:1px solid transparent; border-radius:var(--a-r-sm);
}
.alt-app button.sxc-lg{ cursor:pointer; }
.alt-app button.sxc-lg:hover{ background:var(--a-raised); }
.alt-app .sxc-lg.is-on{ border-color:var(--a-blue); border-width:2px; background:var(--a-blue-soft); }
/* "Other" is not a control: there is no filter value meaning "every class outside the top five", so it is drawn as text and reads as text. */
.alt-app .sxc-lg.is-inert{ color:var(--a-dim); }
.alt-app .sxc-sw{
  flex:0 0 auto; width:var(--a-dot); height:var(--a-dot); margin-top:var(--a-sp-4); border-radius:var(--a-r-sm); border:1px solid var(--a-line-strong);
}
/* The swatch takes the series colour from the same class the slice does, so a legend can never disagree with the ring it labels. */
.alt-app .sxc-sw.sxc-s0{ background:var(--a-faint); }
.alt-app .sxc-sw.sxc-s1{ background:var(--a-chart-1); }
.alt-app .sxc-sw.sxc-s2{ background:var(--a-chart-2); }
.alt-app .sxc-sw.sxc-s3{ background:var(--a-chart-3); }
.alt-app .sxc-sw.sxc-s4{ background:var(--a-chart-4); }
.alt-app .sxc-sw.sxc-s5{ background:var(--a-chart-5); }
.alt-app .sxc-lg-b{ display:flex; flex-direction:column; min-width:0; flex:1 1 auto; }
.alt-app .sxc-lg-l{ display:flex; align-items:center; gap:var(--a-1); min-width:0; }
.alt-app .sxc-lg-v{ font-variant-numeric:tabular-nums; }

/* ---------- motion ----------
   Only colour and shadow transition, dropped under prefers-reduced-motion (alt-tokens.css zeroes --a-quick): nothing animates size or
   position, since a treemap tile easing into place is a wrong area mid-animation. */
.alt-app .sxc-tile-head,
.alt-app .sxc-cls,
.alt-app .sxc-bar,
.alt-app .sxc-age-btn,
.alt-app .sxc-lg,
.alt-app .sxc-tcell{ transition:background-color var(--a-quick) var(--a-ease), border-color var(--a-quick) var(--a-ease); }

/* ---------- narrow ----------
   The age chart turns on its side: five vertical tracks at 340px leave ~55px per band, too narrow for "181–365 days". The fill is a custom
   property so one number is a height or a width. */
@media (max-width: 560px){
  .alt-app .sxc-age{ grid-template-columns:minmax(0, 1fr); gap:var(--a-1); }
  .alt-app .sxc-age-btn{ flex-direction:row; align-items:center; gap:var(--a-2); }
  .alt-app .sxc-age-lab{ order:1; flex:0 0 9.5em; justify-content:flex-start; text-align:left; }
  .alt-app .sxc-age-track{ order:2; flex:1 1 auto; flex-direction:row; align-items:center; justify-content:flex-start; height:auto; width:100%; }
  .alt-app .sxc-age-fill{ order:1; height:var(--a-sp-12); min-height:0; width:var(--sxc-v, 2%); min-width:var(--a-sp-2); border-radius:0 var(--a-r-sm) var(--a-r-sm) 0; }
  .alt-app .sxc-age-val{ order:2; flex:0 0 auto; }

  .alt-app .sxc-donut{ grid-template-columns:minmax(0, 1fr); justify-items:center; }
  .alt-app .sxc-donut-fig,
  .alt-app .sxc-donut-svg{ max-width:200px; }
  .alt-app .sxc-legend{ width:100%; }
  /* Tall and narrow: at this width the horizontal split squarify prefers is exactly the wrong way round. */
  .alt-app .sxc-canvas{ height:clamp(320px, 68vh, 520px); }
}
