/* csv-to-chart: the live chart preview (moved under the editor), its readout and table view, and the options grid.
   Family styles in ../text-tools.css. The chart itself carries its own colours as SVG attributes. */
.result.chart-result { background: var(--matrix-surface); border: 1px solid var(--matrix-border); }
.chart-result h2 { color: var(--matrix-text); }
.chart-problem { margin: var(--matrix-space-16) 0 0; }

/* the preview: the chart at its real size, never wider than the panel */
.chart-figure { position: relative; margin: var(--matrix-space-12) 0; }
.chart-frame { width: fit-content; max-width: 100%; border-radius: var(--matrix-radius-control); }
.chart-frame:focus-visible { outline: 2px solid var(--matrix-focus); outline-offset: 4px; }
.chart-svg { display: block; width: 100%; height: auto; border-radius: var(--matrix-radius-control); }

/* the readout that follows the pointer or the arrow keys */
.chart-tip { position: absolute; z-index: 2; margin: 0; max-width: min(280px, 100%); box-sizing: border-box; padding: var(--matrix-space-8) var(--matrix-space-12); display: grid; gap: 2px;
  background: var(--matrix-surface-raised); color: var(--matrix-text); border: 1px solid var(--matrix-border); border-radius: var(--matrix-radius-control);
  box-shadow: var(--matrix-shadow-popover); font-size: var(--matrix-type-caption); line-height: 1.4; pointer-events: none; }
.chart-tip[hidden] { display: none; }
.chart-tip-label { color: var(--matrix-muted); }
.chart-tip-row { display: flex; align-items: center; gap: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chart-tip-row strong { font-variant-numeric: tabular-nums; }
.chart-tip-key { display: inline-block; flex: none; width: 12px; height: 2px; border-radius: 1px; }

/* the table twin */
.chart-table { margin-top: var(--matrix-space-12); }
.chart-table summary { cursor: pointer; font-weight: 600; min-height: 32px; display: flex; align-items: center; }
.chart-table-scroll { max-height: 50vh; overflow: auto; margin-top: var(--matrix-space-8); border: 1px solid var(--matrix-border); border-radius: var(--matrix-radius-control); background: var(--matrix-surface); }
.chart-table table { border-collapse: collapse; width: 100%; font-size: var(--matrix-type-control); }
.chart-table caption { text-align: left; padding: var(--matrix-space-8) var(--matrix-space-12); color: var(--matrix-muted); }
.chart-table th, .chart-table td { padding: 4px var(--matrix-space-12); border-top: 1px solid var(--matrix-border); text-align: right; font-variant-numeric: tabular-nums; }
.chart-table th[scope="row"], .chart-table thead th:first-child { text-align: left; font-weight: 500; }
.chart-table thead th { position: sticky; top: 0; background: var(--matrix-surface-subtle); }
.sheet-warnings { margin: var(--matrix-space-8) 0; padding-left: 1.2em; font-size: var(--matrix-type-control); }

/* options: a compact grid so the chart and its controls fit on few screens */
.options.chart-options { grid-template-columns: repeat(auto-fit, minmax(min(260px, 100%), 1fr)); align-items: start; }
.chart-options .option-group { align-self: stretch; align-content: start; }
/* a long label wraps beside its box instead of dropping below it */
.chart-options .option-row { flex-wrap: nowrap; }
.chart-options .option-row input[type="radio"], .chart-options .option-row input[type="checkbox"] { flex: none; }
.chart-options .option-row label { flex: 1; min-width: 0; }
.chart-field { display: grid; gap: 4px; }
.chart-field label, .chart-subhead { font-weight: 500; }
.chart-subhead { margin: var(--matrix-space-8) 0 0; }
.chart-field input[type="text"], .chart-field select { width: 100%; box-sizing: border-box; }
.chart-series { display: grid; gap: 2px; max-height: 260px; overflow: auto; }
.option-hint[hidden] { display: none; }
.option-hint { margin: 0; font-size: var(--matrix-type-caption); line-height: var(--matrix-leading-caption); }
.option-row.is-disabled label { color: var(--matrix-disabled-text); }

/* on a phone, every setting but the chart type sits in a section that opens on a tap (csv-to-chart.js; Lucy's #203) */
.chart-section { border: 1px solid var(--matrix-border); border-radius: var(--matrix-radius-control); background: var(--matrix-surface); }
.chart-section > summary { cursor: pointer; font-weight: 600; min-height: var(--matrix-control-min-height); display: flex; align-items: center; padding-inline: var(--matrix-space-16); }
.chart-section > summary:focus-visible { outline: 2px solid var(--matrix-focus); outline-offset: 2px; border-radius: var(--matrix-radius-control); }
.chart-section[open] { display: grid; gap: var(--matrix-space-12); padding-bottom: var(--matrix-space-12); }
.chart-section[open] > summary { border-bottom: 1px solid var(--matrix-border); }
.chart-section > .option-group { margin-inline: var(--matrix-space-12); }
