/* Survey statistics charts, shared by the admin app and the client portal (stats-view.js).
 * Colours: one hue for magnitude (brand blue), an accent for the one bar the story is about, and validated
 * categorical slots 1-3; each with its own dark-mode step. */
:root {
  --viz-fill: #2f6bed;       /* the one hue for magnitude (brand blue) */
  --viz-fill-soft: #86b6ef;  /* its lighter step, for the context series */
  --viz-accent: #eb6834;     /* emphasis: the one bar the story is about */
  --viz-cat-1: #2a78d6; --viz-cat-2: #eb6834; --viz-cat-3: #1baf7a;   /* validated categorical slots 1–3 */
  --viz-grid: #e4e9f3;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --viz-fill: #6f9bff; --viz-fill-soft: #2c4f8f; --viz-accent: #d95926;
    --viz-cat-1: #3987e5; --viz-cat-2: #d95926; --viz-cat-3: #199e70; --viz-grid: #1e2b45;
  }
}
:root[data-theme="dark"] {
  --viz-fill: #6f9bff; --viz-fill-soft: #2c4f8f; --viz-accent: #d95926;
  --viz-cat-1: #3987e5; --viz-cat-2: #d95926; --viz-cat-3: #199e70; --viz-grid: #1e2b45;
}
.viz-fill { fill: var(--viz-fill); background: var(--viz-fill); }
.viz-fill-soft { fill: var(--viz-fill-soft); background: var(--viz-fill-soft); }
.viz-fill-accent { fill: var(--viz-accent); background: var(--viz-accent); }
.viz-cat-1 { background: var(--viz-cat-1); } .viz-cat-2 { background: var(--viz-cat-2); } .viz-cat-3 { background: var(--viz-cat-3); }

.viz-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 18px; }
.viz-tile { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; display: grid; gap: 4px; }
.viz-tile-label { font-size: 13px; color: var(--text-soft); }
.viz-tile-value { font-size: 26px; font-weight: 700; color: var(--text); line-height: 1.1; }
.viz-tile-note { font-size: 12.5px; color: var(--text-faint); }

.viz-card h3 { margin-bottom: 4px; }
.viz-sub { margin: 0 0 14px; font-size: 13.5px; color: var(--text-soft); }
.viz-empty { padding: 8px 0; margin: 0; }
.viz-table { margin-top: 12px; font-size: 14px; }
.viz-table summary { cursor: pointer; color: var(--text-soft); font-size: 13px; }
.viz-table table { margin-top: 8px; }

.viz-hbars { display: grid; gap: 6px; }
.viz-hrow { display: grid; grid-template-columns: minmax(110px, 36%) 1fr minmax(56px, auto); gap: 10px; align-items: center;
  border-radius: 6px; padding: 2px 4px; }
.viz-hrow:hover, .viz-hrow:focus-visible { background: var(--surface-2); }
.viz-hrow:focus-visible { outline: 2px solid var(--blue); outline-offset: 1px; }
.viz-hlabel { font-size: 14px; color: var(--text); overflow-wrap: anywhere; }
.viz-hvalue { font-size: 13.5px; color: var(--text-soft); text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.viz-hbar { display: block; overflow: visible; }

.viz-colaxis { position: relative; padding-top: 16px; padding-bottom: 20px; }
.viz-ymax { position: absolute; top: 0; left: 0; font-size: 11.5px; color: var(--text-faint); font-variant-numeric: tabular-nums; }
.viz-cols { display: flex; align-items: stretch; gap: 2px; height: 150px; border-bottom: 1px solid var(--viz-grid); }
.viz-colslot { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; }
.viz-colgroup { flex: 1; display: flex; gap: 2px; align-items: flex-end; justify-content: center; }
.viz-colhit { flex: 1; max-width: 24px; height: 100%; display: flex; align-items: flex-end; border-radius: 4px; }
.viz-colhit:hover, .viz-colhit:focus-visible { background: var(--surface-2); }
.viz-colhit:focus-visible { outline: 2px solid var(--blue); outline-offset: 1px; }
.viz-col { width: 100%; border-radius: 4px 4px 0 0; }
.viz-colx { font-size: 11px; color: var(--text-faint); text-align: center; height: 0; overflow: visible; white-space: nowrap; transform: translateY(4px); }
.viz-cols + * { margin-top: 18px; }
.viz-two { display: grid; grid-template-columns: 3fr 2fr; gap: 20px; }
@media (max-width: 860px) { .viz-two { grid-template-columns: 1fr; } }

.viz-split { display: flex; gap: 2px; height: 22px; margin: 6px 0 10px; }
.viz-seg { min-width: 6px; } .viz-seg:first-child { border-radius: 4px 0 0 4px; } .viz-seg:last-child { border-radius: 0 4px 4px 0; }
.viz-seg:only-child { border-radius: 4px; } .viz-seg:hover, .viz-seg:focus-visible { filter: brightness(1.12); }
.viz-seg:focus-visible { outline: 2px solid var(--text); outline-offset: 1px; }

.viz-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 0 0 10px; font-size: 13px; color: var(--text-soft); }
.viz-key { display: inline-flex; align-items: center; gap: 6px; }
.viz-swatch { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }

.viz-tip { position: absolute; z-index: 60; background: var(--text); color: var(--bg); padding: 6px 10px;
  border-radius: 8px; font-size: 13px; display: grid; gap: 1px; box-shadow: var(--shadow-lg); max-width: 280px; }
.viz-tip b { font-size: 15px; } .viz-tip span { opacity: .8; }

.viz-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(330px, 1fr)); gap: 18px; }
.viz-grid > .card { margin: 0; }
.viz-body > * + * { margin-top: 18px; }
.viz-body > .viz-kpis + * { margin-top: 0; }
.viz-wrap { overflow-x: auto; }
.viz-wrap:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
table.viz-list { width: 100%; border-collapse: collapse; font-size: 14px; }
.viz-list th { text-align: left; font: 600 11px/1.2 var(--mono); letter-spacing: .8px; text-transform: uppercase;
  color: var(--text-faint); padding: 10px 12px; border-bottom: 1px solid var(--border); }
.viz-list td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
.viz-list tr:last-child td { border-bottom: none; }
.viz-list .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.viz-list .strong { font-weight: 700; }
.viz-counts { display: grid; grid-template-columns: 1fr auto; gap: 6px 16px; margin: 0; }
.viz-counts dd { margin: 0; text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
@media (max-width: 520px) { .viz-grid { grid-template-columns: 1fr; } .viz-hrow { grid-template-columns: minmax(90px, 40%) 1fr auto; } }
.viz-list td.strong { min-width: 15rem; }
