/* Say versus do — behavioural signals beside survey sentiment
 * /dept/cs?tab=surveys  (block: #svy-behavior, rail: #svy-drawer-sidecar)
 *
 * Every colour resolves from --svy-tone, which the .svy-tone-* classes in
 * survey_dashboard.css set. Nothing here declares a hex value, so the surface
 * follows the active theme on the light palettes as well as the dark ones. The
 * .sbx- prefix keeps it out of the survey dashboard's namespace while both
 * files style the same panel.
 */

/* Re-derive the tone pair on our own scopes: --svy-ink / --svy-tint are
   substituted where DECLARED, so a card that only sets --svy-tone would
   otherwise paint with the panel's accent ink. */
.sbx-quad, .sbx-dim, .sbx-verdict, .sbx-motion, .sbx-delta, .sbx-side-score {
  --svy-ink: color-mix(in srgb, var(--svy-tone) 78%, var(--text-primary));
  --svy-tint: color-mix(in srgb, var(--svy-tone) 15%, transparent);
}

.sbx-grain {
  margin: 0 0 14px;
  font-size: 11.5px;
  line-height: 1.55;
  color: var(--text-secondary);
  max-width: 78ch;
}
.sbx-grain.small { font-size: 10.5px; color: var(--text-muted); margin: 14px 0 0; }
.sbx-note { padding: 8px 14px; font-size: 11px; color: var(--text-muted); }
.sbx-sub {
  display: block;
  font-size: 10.5px;
  color: var(--text-muted);
  line-height: 1.4;
  margin-top: 2px;
}
.sbx-link { color: var(--svy-ink, var(--accent)); font-weight: 600; text-decoration: none; }
.sbx-link:hover { text-decoration: underline; }

/* ══ alignment quadrants ══════════════════════════════════════════════ */
.sbx-quads {
  display: grid;
  /* min() so a narrow viewport can go below the ideal card instead of
     overflowing the block, which is overflow:hidden. */
  grid-template-columns: repeat(auto-fit, minmax(min(260px, 100%), 1fr));
  gap: 12px;
  margin-bottom: 18px;
}
.sbx-quad {
  border: 1px solid var(--border);
  border-left: 3px solid var(--svy-tone);
  border-radius: 10px;
  background: var(--bg-card);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
/* An expanded roster is a table, so the card takes the full row rather than
   staying in its grid track and scrolling a 6-column table inside 260px. */
.sbx-quad.open { grid-column: 1 / -1; }
.sbx-quad-head {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 13px 14px;
  border: none;
  background: none;
  font: inherit;
  text-align: left;
  cursor: pointer;
  color: inherit;
}
.sbx-quad-head[disabled] { cursor: default; opacity: .75; }
.sbx-quad-head:not([disabled]):hover { background: var(--svy-tint); }
.sbx-quad-count {
  display: flex;
  align-items: baseline;
  gap: 4px;
  font-size: 26px;
  font-weight: 800;
  line-height: 1;
  color: var(--svy-ink);
  font-variant-numeric: tabular-nums;
  flex: none;
  min-width: 42px;
}
.sbx-quad-count .unit { font-size: 11px; font-weight: 600; color: var(--text-muted); }
.sbx-quad-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.sbx-quad-label { font-size: 12.5px; font-weight: 700; color: var(--text-primary); }
.sbx-quad-blurb { font-size: 10.5px; color: var(--text-muted); line-height: 1.35; }
.sbx-caret { margin-left: auto; color: var(--text-muted); font-size: 11px; flex: none; }
.sbx-quad-action {
  padding: 0 14px 12px;
  font-size: 11px;
  line-height: 1.5;
  color: var(--text-secondary);
}
.sbx-roster { border-top: 1px solid var(--border); overflow-x: auto; }
.sbx-roster .svy-table { min-width: 720px; }

.sbx-reasons {
  margin: 5px 0 0;
  padding: 0 0 0 14px;
  font-size: 10.5px;
  line-height: 1.5;
  color: var(--text-secondary);
}
.sbx-reasons li { margin-bottom: 2px; }

/* Five stubs, one per dimension: a shape rather than five numbers, so a
   roster row can be scanned. Risk is drawn on its inverted tone, so a tall
   red stub always means "worse" whichever dimension it is. */
.sbx-mini { display: inline-flex; align-items: flex-end; gap: 2px; height: 14px; }
.sbx-mini i {
  display: block;
  width: 4px;
  min-height: 3px;
  border-radius: 1px;
  background: var(--svy-tone);
}

/* ══ cohort strip / dimension bars ════════════════════════════════════ */
.sbx-cohort, .sbx-intent, .sbx-unmeasured {
  padding-top: 14px;
  margin-top: 14px;
  border-top: 1px solid var(--border);
}
.sbx-cohort-head {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 10px;
}
.sbx-dims {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(180px, 100%), 1fr));
  gap: 12px 16px;
}
.sbx-dims.tight { grid-template-columns: 1fr; gap: 10px; }
.sbx-dim { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.sbx-dim-top { display: flex; align-items: baseline; gap: 6px; }
.sbx-dim-label {
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-muted);
}
.sbx-inv { font-style: normal; margin-left: 3px; opacity: .8; }
.sbx-dim-val {
  margin-left: auto;
  font-size: 17px;
  font-weight: 700;
  line-height: 1;
  color: var(--svy-ink);
  font-variant-numeric: tabular-nums;
  display: flex;
  align-items: baseline;
  gap: 5px;
}
.sbx-delta { font-size: 10.5px; font-weight: 700; color: var(--svy-ink); }
.sbx-dim-note { font-size: 10px; color: var(--text-muted); line-height: 1.4; }
.sbx-dim-note.dim { opacity: .8; }

.sbx-track {
  position: relative;
  display: block;
  height: 7px;
  border-radius: 999px;
  background: var(--svy-track);
}
.sbx-fill {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: var(--svy-tone);
  transition: width .45s cubic-bezier(.22, .61, .36, 1);
}
/* The book median. Drawn ON the track rather than printed beside it because
   the GAP is the finding, and a gap is a distance. */
.sbx-tick {
  position: absolute;
  top: -3px;
  width: 2px;
  height: 13px;
  margin-left: -1px;
  border-radius: 1px;
  background: var(--text-primary);
  opacity: .55;
}

.sbx-parts {
  margin: 2px 0 0;
  padding: 0;
  list-style: none;
  font-size: 10.5px;
  color: var(--text-secondary);
}
.sbx-parts li,
.sbx-facts li {
  display: flex;
  gap: 8px;
  padding: 3px 0;
  border-bottom: 1px solid color-mix(in srgb, var(--border) 55%, transparent);
}
.sbx-parts li:last-child, .sbx-facts li:last-child { border-bottom: none; }
.sbx-parts li span, .sbx-facts li span {
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  gap: 0;
  min-width: 0;
}
/* Help bubble trigger is already margin-left'd; keep it from wrapping alone. */
.sbx-parts li .svy-help { flex: 0 0 auto; }
.sbx-parts li b, .sbx-facts li b {
  margin-left: auto;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  text-align: right;
}
.sbx-facts {
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 11px;
}

/* ══ chips ════════════════════════════════════════════════════════════ */
.sbx-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.sbx-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-secondary);
  font-size: 10.5px;
  color: var(--text-secondary);
}
.sbx-chip b { color: var(--text-primary); }

.sbx-chans { display: flex; flex-wrap: wrap; gap: 5px; }
.sbx-chan {
  padding: 3px 9px;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 10.5px;
  color: var(--text-muted);
  /* An off channel is legible but plainly absent — greying it out entirely
     would read as "not applicable" rather than "no signal here". */
  opacity: .6;
}
.sbx-chan.on {
  border-color: color-mix(in srgb, var(--success) 40%, transparent);
  background: color-mix(in srgb, var(--success) 12%, transparent);
  color: color-mix(in srgb, var(--success) 78%, var(--text-primary));
  opacity: 1;
  font-weight: 600;
}

/* ══ intent table ═════════════════════════════════════════════════════ */
.sbx-intent .svy-table { min-width: 640px; }

/* ══ drawer split + sidecar ═══════════════════════════════════════════ */
/* Narrow: ONE scroller for the whole split. Two independently scrolling
   panes stacked vertically would each need a height nobody can give them —
   the result is a pane you can only see three lines of. Wide: the split
   becomes the clipping row and each pane scrolls itself. */
.svy-drawer-split {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
}
.svy-drawer-split .svy-drawer-body { overflow: visible; }
.svy-drawer-sidecar {
  padding: 14px 20px 24px;
  background: var(--svy-nested);
  border-top: 1px solid var(--border);
}
.sbx-side-empty {
  padding: 14px 0;
  font-size: 11.5px;
  color: var(--text-muted);
  line-height: 1.5;
}
.sbx-side-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.sbx-side-eyebrow {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--text-muted);
}
.sbx-side-score { display: flex; align-items: baseline; gap: 7px; }
.sbx-side-num {
  font-size: 26px;
  font-weight: 800;
  line-height: 1;
  color: var(--svy-ink);
  font-variant-numeric: tabular-nums;
}
.sbx-side-band { font-size: 10.5px; font-weight: 600; color: var(--text-muted); }

.sbx-verdict {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 11px 13px;
  border: 1px solid color-mix(in srgb, var(--svy-tone) 32%, transparent);
  border-left: 3px solid var(--svy-tone);
  border-radius: 9px;
  background: var(--svy-tint);
}
.sbx-verdict-label { font-size: 12px; font-weight: 700; color: var(--svy-ink); }
.sbx-verdict-blurb { font-size: 10.5px; color: var(--text-secondary); line-height: 1.45; }
.sbx-verdict-action { font-size: 10.5px; color: var(--text-primary); line-height: 1.5; }

.sbx-side-block {
  padding-top: 12px;
  margin-top: 12px;
  border-top: 1px solid var(--border);
}
.sbx-side-title {
  display: flex;
  align-items: baseline;
  gap: 6px;
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-muted);
  margin-bottom: 8px;
}
/* The unit of every number in the block it heads. Stated once at the top
   rather than repeated per row, and never omitted: a bare 100 beside a model
   name reads as a probability. */
.sbx-scale {
  margin-left: auto;
  font-weight: 600;
  letter-spacing: .02em;
  text-transform: none;
  opacity: .75;
}
.sbx-motion {
  font-size: 12.5px;
  color: var(--svy-ink);
  font-weight: 600;
}
.sbx-motion b { font-size: 16px; }

/* Side by side once there is room for both columns: the answer sheet is
   narrow text and the rail is compact tiles, so 1000px is where neither has
   to be squeezed. */
@media (min-width: 1000px) {
  .svy-drawer-panel { width: min(1040px, 96vw); }
  .svy-drawer-split { flex-direction: row; overflow: hidden; }
  .svy-drawer-split .svy-drawer-body {
    flex: 1 1 auto;
    min-width: 0;
    overflow-y: auto;
  }
  .svy-drawer-sidecar {
    flex: 0 0 340px;
    overflow-y: auto;
    border-top: none;
    border-left: 1px solid var(--border);
  }
}

@media (max-width: 999px) {
  /* Stacked: the rail goes first. The answers are already summarised in the
     row that was clicked; the behaviour is what the operator came for. */
  .svy-drawer-sidecar { order: -1; border-top: none; border-bottom: 1px solid var(--border); }
}

@media (prefers-reduced-motion: reduce) {
  .sbx-fill { transition: none; }
}
