/*
 * The console's pages and charts, on the shell (console.css) and in its trim
 * (tokens.css). The data is the only thing here allowed to be loud: marks are
 * thin and carry the one hue, axes and grids are solid hairlines a step off
 * the surface, and every word and figure is trim.
 */

/* ── The page: a filter row above everything it scopes, then the cards ── */

.signal-shell { height: 100%; }

.signal-filters {
  display: flex;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 10px 14px;
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--shell-line);
}
.signal-filters .console-field .console-input { min-width: 0; }
.signal-presets { display: inline-flex; border: 1px solid var(--shell-line-strong); border-radius: var(--r-2); overflow: hidden; }
.signal-presets button {
  height: 32px;
  padding: 0 12px;
  border: none;
  border-right: 1px solid var(--shell-line);
  background: transparent;
  color: var(--shell-fg-dim);
  font: inherit;
  font-weight: 500;
  cursor: pointer;
}
.signal-presets button:last-child { border-right: none; }
.signal-presets button:hover, .signal-presets button:focus-visible { background: var(--shell-raised-2); color: var(--shell-fg-bright); outline: none; }
.signal-presets button[aria-pressed="true"] { background: var(--trim-bright); color: var(--bg-dark); }
.signal-filters-note { margin-left: auto; align-self: center; text-align: right; color: var(--shell-fg-faint); font-size: var(--fs-1); line-height: 1.5; }

/* The page holds its last render, dimmed, while a new one is read: nothing jumps. */
.signal-body { transition: opacity .16s ease; }
.signal-body.is-reading { opacity: .45; pointer-events: none; }

.signal-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); gap: 16px; align-items: start; }
.signal-grid > .is-wide { grid-column: 1 / -1; }
.signal-grid .console-card { margin-bottom: 0; min-width: 0; }
.signal-section { margin: 26px 0 12px; font-family: var(--font-mono); font-size: var(--fs-1); font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--shell-fg-dim); }
.signal-section:first-child { margin-top: 0; }
.signal-question { margin: -4px 0 14px; max-width: 78ch; color: var(--shell-fg-dim); line-height: 1.5; }
.signal-question b { font-weight: 600; color: var(--shell-fg); }

/* The sample every chart is of: said once, by the range (README §5.2). */
.signal-badge {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 8px;
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--shell-fg-dim);
  border: 1px solid var(--shell-line-strong);
  white-space: nowrap;
}
.signal-badge.is-down { color: var(--color-red); border-color: rgba(var(--color-red-rgb), .5); }
.signal-badge.is-held { color: var(--color-orange); border-color: rgba(var(--color-orange-rgb), .45); }

.signal-game-select { width: 100%; height: 32px; margin: 10px 0 2px; font-weight: 600; }
.is-collapsed .signal-game-select { display: none; }
.signal-nav-label { padding: 12px 10px 4px; font-family: var(--font-mono); font-size: 10px; letter-spacing: .12em; text-transform: uppercase; color: var(--shell-fg-faint); }
.is-collapsed .signal-nav-label { display: none; }

.signal-key { font-family: var(--font-mono); font-size: var(--fs-1); color: var(--shell-fg-bright); overflow-wrap: anywhere; user-select: all; }
.signal-feedback { display: grid; gap: 12px; }
.signal-feedback-text { margin: 8px 0 10px; color: var(--shell-fg-bright); font-size: var(--fs-3); line-height: 1.55; white-space: pre-wrap; overflow-wrap: anywhere; }
.signal-tabs { display: flex; gap: 6px; margin-bottom: 14px; }
textarea.console-input { width: 100%; height: 150px; padding: 10px; font-family: var(--font-mono); font-size: var(--fs-1); line-height: 1.5; resize: vertical; }

/* ── A chart's card ── */

.viz-card { margin: 0; }
.viz-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.viz-head h2 { margin: 0; font-size: var(--fs-3); font-weight: 600; color: var(--shell-fg-bright); }
.viz-sub { margin: 3px 0 0; color: var(--shell-fg-dim); font-size: var(--fs-1); line-height: 1.45; }
.viz-toggle { height: 24px; padding: 0 8px; font-size: var(--fs-0); flex: none; }
.viz-plot[hidden], .viz-twin[hidden] { display: none; }
.viz-twin { max-height: 320px; overflow: auto; }
.viz-table td, .viz-table th { padding: 6px 10px; font-size: var(--fs-1); }
.viz-table .is-number, .viz-heat .is-number { text-align: right; font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.viz-empty { margin: 0; padding: 22px 0; color: var(--shell-fg-faint); text-align: center; line-height: 1.5; }

.viz-legend { display: flex; flex-wrap: wrap; gap: 4px 16px; margin: 0 0 10px; padding: 0; list-style: none; font-size: var(--fs-1); color: var(--shell-fg); }
.viz-legend li { display: inline-flex; align-items: center; gap: 6px; }
.viz-legend-note { color: var(--shell-fg-faint); font-family: var(--font-mono); }
.viz-key { display: inline-block; width: 10px; height: 10px; flex: none; border-radius: 2px; }
.viz-key.is-line { height: 2px; width: 14px; border-radius: 1px; }

/* ── Tiles ── */

.viz-tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.viz-card .viz-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.viz-tile { padding: 14px 16px; background: var(--shell-raised); border: 1px solid var(--shell-line); border-radius: var(--r-3); min-width: 0; }
.viz-tile-label { font-size: var(--fs-1); color: var(--shell-fg-dim); }
/* A large standalone figure: the reading face, its own proportional digits. */
.viz-tile-value { margin-top: 4px; font-family: var(--font-sans); font-size: 28px; font-weight: 600; line-height: 1.15; color: var(--shell-fg-bright); }
.viz-tile-value.is-withheld { color: var(--shell-fg-faint); }
.viz-tile-note { margin-top: 3px; font-size: var(--fs-0); color: var(--shell-fg-faint); line-height: 1.4; }

/* ── SVG charts ── */

.viz-responsive { min-width: 0; }
.viz-svg { display: block; width: 100%; height: auto; overflow: visible; }
.viz-grid { stroke: rgba(var(--trim-rgb), .11); stroke-width: 1; }
.viz-baseline { stroke: rgba(var(--trim-rgb), .3); stroke-width: 1; }
.viz-axis-label { fill: var(--trim-dim); font-family: var(--font-mono); font-size: 10px; font-variant-numeric: tabular-nums; }
.viz-axis-label.is-end, .viz-flow-label.is-end { text-anchor: end; }
.viz-axis-label.is-middle { text-anchor: middle; }
.viz-line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
/* A marker wears a ring of the surface, so it stays legible where it crosses a line. */
.viz-dot { stroke: #161616; stroke-width: 2; }
.viz-hair { stroke: rgba(var(--trim-rgb), .5); stroke-width: 1; pointer-events: none; }
.viz-hit { fill: transparent; cursor: crosshair; outline: none; }
.viz-hit:focus-visible { stroke: rgba(var(--trim-rgb), .5); stroke-width: 1; }
.viz-provisional { fill: rgba(var(--color-orange-rgb), .06); }
.viz-bar { fill: var(--series-1); }
.viz-bar.is-median { fill: var(--ramp-8); }
.viz-withheld { fill: rgba(var(--trim-rgb), .3); }
.viz-ribbon { fill: var(--series-1); opacity: .3; outline: none; transition: opacity .1s; }
.viz-ribbon:hover, .viz-ribbon:focus-visible { opacity: .8; }
.viz-node { fill: var(--trim); }
.viz-flow-label { fill: var(--trim); font-family: var(--font-sans); font-size: 11px; white-space: pre; }

/* ── Bars and rates: a name, a bar, a figure a row ── */

.viz-bars, .viz-rates { margin: 0; padding: 0; list-style: none; display: grid; gap: 7px; }
.viz-bars li, .viz-rates li {
  display: grid;
  grid-template-columns: min(var(--viz-name, 12ch), 46%) minmax(0, 1fr) 64px;
  grid-template-areas: "name track value" "name note note";
  align-items: center;
  column-gap: 10px;
  border-radius: var(--r-1);
  outline: none;
}
.viz-bars li:hover, .viz-bars li:focus-visible, .viz-rates li:hover, .viz-rates li:focus-visible { background: var(--shell-raised); }
.viz-bars-name { grid-area: name; display: flex; align-items: center; gap: 6px; min-width: 0; color: var(--shell-fg); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.viz-bars-track, .viz-rates-track { grid-area: track; position: relative; height: 12px; }
/* Thin, square on the baseline, rounded at the data end. */
.viz-bars-fill, .viz-rates-fill { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 0 4px 4px 0; background: var(--series-1); }
.viz-bars-withheld { position: absolute; left: 0; top: 3px; bottom: 3px; width: 10px; border-radius: 0 3px 3px 0; background: rgba(var(--trim-rgb), .3); }
.viz-rates-track { background: rgba(var(--trim-rgb), .06); border-radius: 0 4px 4px 0; }
/* The 95% interval: a hairline across the bar's end, with its two ends marked. */
.viz-rates-whisker { position: absolute; top: 50%; height: 0; border-top: 1.5px solid var(--trim-bright); }
.viz-rates-whisker::before, .viz-rates-whisker::after { content: ""; position: absolute; top: -5px; height: 8.5px; border-left: 1.5px solid var(--trim-bright); }
.viz-rates-whisker::before { left: 0; }
.viz-rates-whisker::after { right: 0; }
.viz-bars-value { grid-area: value; text-align: right; font-family: var(--font-mono); font-size: var(--fs-1); font-variant-numeric: tabular-nums; color: var(--shell-fg-bright); white-space: nowrap; }
.viz-bars-value.is-withheld { color: var(--shell-fg-faint); }
.viz-bars-note { grid-area: note; font-size: var(--fs-0); color: var(--shell-fg-faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.viz-bars li:not(:has(.viz-bars-note)) { grid-template-areas: "name track value"; }
.viz-pair + .viz-pair { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--shell-line); }
.viz-pair-title { margin: 0 0 8px; font-size: var(--fs-1); color: var(--shell-fg-dim); }

/* ── Segmented: one whole, split ── */

.viz-segmented { display: flex; gap: 2px; height: 28px; margin-bottom: 10px; }
.viz-segment {
  display: flex;
  align-items: center;
  min-width: 3px;
  flex-basis: 0;
  padding: 0 7px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: var(--fs-0);
  font-weight: 600;
  color: #ffffff;
  white-space: nowrap;
  overflow: hidden;
  outline: none;
}
.viz-segment.is-dark-ink { color: #0b0b0b; }
.viz-segment:hover, .viz-segment:focus-visible { filter: brightness(1.18); }

/* ── Heat: the retention triangle ── */

.viz-heat { width: 100%; border-collapse: separate; border-spacing: 2px; font-size: var(--fs-1); }
.viz-heat th { padding: 4px 8px; font-family: var(--font-mono); font-size: var(--fs-0); font-weight: 500; color: var(--shell-fg-faint); text-align: left; white-space: nowrap; }
.viz-heat thead th { letter-spacing: .08em; text-transform: uppercase; }
.viz-heat td { padding: 4px 8px; color: var(--shell-fg); }
.viz-heat td.is-withheld { color: var(--shell-fg-faint); }
.viz-heat-cell { min-width: 46px; text-align: center; border-radius: 3px; font-family: var(--font-mono); font-variant-numeric: tabular-nums; color: #ffffff; outline: none; }
.viz-heat-cell.is-dark-ink { color: #0b0b0b; }
.viz-heat-cell.is-pending, .viz-heat-cell.is-withheld { color: var(--shell-fg-faint); background: rgba(var(--trim-rgb), .04); }
.viz-heat-cell:focus-visible { box-shadow: 0 0 0 2px var(--trim-bright); }
.viz-heat-wrap { overflow-x: auto; }

/* ── The tooltip: one, shared ── */

.viz-tip {
  position: fixed;
  z-index: 50;
  left: 0;
  top: 0;
  max-width: 280px;
  padding: 8px 10px;
  background: #1f1f1f;
  border: 1px solid var(--shell-line-strong);
  border-radius: var(--r-2);
  box-shadow: 0 8px 28px rgba(0, 0, 0, .5);
  font-size: var(--fs-1);
  color: var(--shell-fg);
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
}
.viz-tip.is-on { opacity: 1; visibility: visible; }
.viz-tip-title { margin-bottom: 4px; font-family: var(--font-mono); font-size: var(--fs-0); letter-spacing: .06em; text-transform: uppercase; color: var(--shell-fg-dim); }
.viz-tip-row { display: flex; align-items: center; gap: 6px; line-height: 1.5; }
.viz-tip-row .viz-key { width: 12px; height: 2px; border-radius: 1px; }
.viz-tip-row strong { font-family: var(--font-mono); font-weight: 600; color: var(--shell-fg-bright); }

/* The menu's items are links here, so the address is the page: drawn as the shell draws an item. */
a.console-item { text-decoration: none; }
a.console-button { text-decoration: none; }

@media (max-width: 1000px) {
  .viz-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 720px) {
  .signal-grid { grid-template-columns: minmax(0, 1fr); }
  .signal-filters-note { margin-left: 0; text-align: left; }
}

@media (prefers-reduced-motion: reduce) {
  .signal-body, .viz-ribbon { transition: none; }
}

/* ── Brands, and the walkthrough ── */

.signal-stream-list { margin: 8px 0 0; padding: 0; list-style: none; display: grid; gap: 8px; }
.signal-stream-list li { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 10px; }
.signal-stream-select optgroup { font-style: normal; color: var(--shell-fg-dim); }

.signal-connect { display: grid; gap: 16px; }
.signal-connect .console-card { margin-bottom: 0; }
.signal-step .console-card-head { margin-bottom: 4px; }
.signal-step-n {
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 24px;
  flex: none;
  border-radius: 50%;
  font-family: var(--font-mono);
  font-size: var(--fs-1);
  font-weight: 700;
  color: var(--bg-dark);
  background: var(--trim-bright);
}
.signal-form { display: grid; gap: 14px; }
.signal-fieldset { margin: 0; padding: 10px 12px 12px; display: flex; flex-wrap: wrap; gap: 8px 18px; border: 1px solid var(--shell-line); border-radius: var(--r-2); }
.signal-fieldset legend { padding: 0 6px; font-size: var(--fs-1); color: var(--shell-fg-dim); }
.signal-choice { display: inline-flex; align-items: center; gap: 7px; color: var(--shell-fg); cursor: pointer; }
.signal-choice input { accent-color: var(--trim-bright); }
.signal-code { position: relative; }
.signal-code .console-code { margin-bottom: 8px; white-space: pre; }
.signal-code > button { position: absolute; top: 6px; right: 6px; height: 26px; }
.signal-file-wrap { display: grid; gap: 4px; margin-bottom: 12px; }
.signal-file-name { font-family: var(--font-mono); font-size: var(--fs-1); color: var(--shell-fg-dim); }
textarea.signal-file { height: auto; min-height: 120px; white-space: pre; overflow-wrap: normal; overflow-x: auto; }
.signal-diagnostics { margin: 0; padding-left: 18px; display: grid; gap: 4px; color: var(--shell-fg); font-size: var(--fs-1); line-height: 1.5; }
.signal-list { margin: 0 0 12px; padding-left: 20px; display: grid; gap: 6px; line-height: 1.5; color: var(--shell-fg); }
.signal-checklist { margin: 0 0 14px; padding: 0; list-style: none; display: grid; gap: 8px; }
.signal-checklist li { display: flex; align-items: baseline; gap: 10px; color: var(--shell-fg-dim); }
.signal-checklist li.is-done { color: var(--shell-fg-bright); }
.signal-tick { width: 16px; flex: none; text-align: center; font-weight: 700; color: var(--shell-fg-faint); }
.is-done .signal-tick { color: var(--color-green); }
.console-standing.is-held { color: var(--color-orange); }

/* A table wider than its card (a brand's seven columns on a phone) scrolls inside the card, not off it. */
.console-card:has(> .console-table) { overflow-x: auto; }
