/* One session's timings (src/e2e/session-timings-render.ts, blob-backend
   specs/053 revision 2): the summary and the turn table, shown in the Session
   Viewer's Timings tab. Builds on session-viewer.css (the panel carries `.sv`,
   so `.sv-card`, `.sv-inline-msg` and the colour tokens apply). Every class
   here uses the `st-` prefix and is not scoped to one tab (research R23). */

.st-timings {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}
.st-warn {
  margin: 0;
  background: var(--sv-amber-bg);
  color: var(--sv-amber-ink);
}
.st-panelmsg {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin: 0;
  color: var(--muted);
}
.st-panelmsg.is-error {
  color: var(--sv-red-ink);
}

/* ── Summary (FR-015) ─────────────────────────────────────────────────── */
.st-slowline {
  margin: 0 0 10px;
  font-size: 13px;
  font-weight: 700;
  color: var(--sv-green-ink);
}
.st-slowline.has-slow {
  color: var(--sv-red-ink);
}
.st-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 10px;
  margin-bottom: 10px;
}
.st-card {
  padding: 12px 14px;
}
.st-card-h {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  margin: 0 0 8px;
  font-size: 13px;
}
.st-n {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  white-space: nowrap;
}
/* avg · p50 on the first line, p95 · max on the second: four values in one
   row of a ~200px card left each ~40px, and "654 ms" ran into its neighbour. */
.st-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px 12px;
  margin: 0;
  font-variant-numeric: tabular-nums;
}
.st-stat dt,
.st-total dt {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
}
.st-stat dd,
.st-total dd {
  margin: 2px 0 0;
}
.st-stat dd {
  white-space: nowrap;
}
.st-card-empty,
.st-card-est {
  margin: 4px 0 0;
  font-size: 12px;
  color: var(--muted);
}
.st-totals {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px 18px;
  margin: 0;
  padding: 14px 18px;
}

/* ── Provenance (FR-013a): actual plain, estimate labelled, missing greyed ── */
.st-tv {
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.st-tv-server,
.st-tv-device {
  cursor: help;
}
.st-tv-estimate {
  color: var(--sv-amber-ink);
  cursor: help;
}
.st-est {
  font-size: 11px;
  font-weight: 700;
}
.st-tv-missing {
  color: var(--muted);
  font-style: italic;
}
.st-tv-na {
  color: var(--muted);
}
/* Slow figures (US5): never colour alone — bold and underlined too. */
.st-slow {
  color: var(--sv-red-ink);
  background: var(--sv-red-bg);
  border-radius: 6px;
  padding: 0 4px;
  font-weight: 800;
  text-decoration: underline dotted;
}
.st-note,
.st-int,
.st-sub {
  font-size: 11px;
  color: var(--muted);
}

/* ── Turn table: scrolls in its own box, first column sticks ──────────── */
.st-turncard {
  padding: 0;
  overflow: hidden;
}
.st-h {
  margin: 0;
  padding: 12px 18px;
  font-size: 14px;
}
.st-hint {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}
.st-turnwrap {
  overflow: auto;
  max-height: min(75vh, 1100px);
  -webkit-overflow-scrolling: touch;
}
.st-turns {
  width: 100%;
  min-width: 1240px;
  table-layout: auto;
  margin: 0;
  border: 0;
  border-radius: 0;
  overflow: visible;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
  line-height: 1.4;
  background: var(--surface);
}
.st-turns th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--sv-soft);
  padding: 11px 10px;
  font-size: 10px;
  line-height: 1.3;
  letter-spacing: 0.05em;
  vertical-align: bottom;
  border-bottom: 1px solid var(--border);
}
.st-turns td {
  padding: 10px;
  border-bottom: 0;
  vertical-align: top;
}
.st-turns th:first-child,
.st-turns td.st-c-n {
  position: sticky;
  left: 0;
  z-index: 1;
  padding-left: 18px;
  background: var(--surface);
  white-space: nowrap;
}
.st-turns th:first-child {
  z-index: 3;
  background: var(--sv-soft);
}
.st-turns tbody.st-turn {
  border-bottom: 1px solid var(--border);
}
.st-turns tbody.st-turn td {
  border-bottom: 1px solid var(--border);
}
.st-turns tbody.st-turn tr.st-row:has(+ tr.st-detail-row:not([hidden])) td {
  border-bottom: 0;
}
.st-turns tr.st-row {
  cursor: pointer;
}
.st-turns tr.st-row:hover,
.st-turns tr.st-row:focus-visible {
  background: var(--sv-hover);
  outline: none;
}
.st-turns tr.st-row:focus-visible td.st-c-n {
  box-shadow: inset 3px 0 0 var(--blue);
}
.st-turns tr.st-row.is-flash td {
  animation: st-flash 1.2s var(--sv-ease);
}
@keyframes st-flash {
  from {
    background: var(--sv-blue-bg);
  }
}
.st-turns tr.st-compact td {
  padding-top: 8px;
  padding-bottom: 8px;
}
.st-num {
  display: inline-block;
  min-width: 2ch;
  font-weight: 800;
  color: var(--muted);
}
.st-kind {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
  background: var(--sv-grey-bg);
  color: var(--sv-grey-ink);
}
.st-kind-child_turn {
  background: var(--sv-blue-bg);
  color: var(--sv-blue-ink);
}
.st-kind-blob_line,
.st-kind-poke_reaction,
.st-kind-continuation {
  background: var(--sv-green-bg);
  color: var(--sv-green-ink);
}
.st-kind-nudge,
.st-kind-signoff,
.st-kind-nudge_declined,
.st-kind-nudge_dropped {
  background: var(--sv-amber-bg);
  color: var(--sv-amber-ink);
}
.st-text {
  display: block;
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.st-facts {
  font-size: 12px;
  line-height: 1.6;
}
.st-fk {
  color: var(--muted);
  font-weight: 700;
}
.st-sep {
  color: var(--muted);
}
.st-jump {
  font-weight: 800;
  white-space: nowrap;
}

/* The expanded row: every figure with its source. */
.st-detail-row td {
  background: var(--sv-soft);
}
.st-dl {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 4px 24px;
  margin: 0;
  font-size: 12px;
}
.st-dl-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0 8px;
  align-items: baseline;
}
.st-dl-row dt {
  min-width: 140px;
  font-weight: 700;
  color: var(--muted);
}
.st-dl-row dd {
  margin: 0;
}
.st-dsrc,
.st-dnote {
  font-size: 11px;
  color: var(--muted);
}
.st-dsrc::before {
  content: '· ';
}
.st-noturns {
  padding: 0 18px 16px;
  color: var(--muted);
}

/* Phones: the summary cards stack, and the turn table stays a table that
   scrolls sideways inside its own box — the page itself never does. */
@media (max-width: 720px) {
  .st-cards {
    grid-template-columns: 1fr;
  }
  .st-totals {
    grid-template-columns: 1fr;
  }
  .st-turnwrap {
    overflow-x: auto;
    max-height: none;
  }
  .st-turns {
    min-width: 1100px;
  }
}

/* specs/055 FR-018: `?metric=` — the column focused, its slow figures and the
   first slow (or slowest) turn emphasised. */
.st-turns th.is-focus {
  color: var(--sv-blue-ink);
  box-shadow: inset 0 -3px 0 var(--sv-blue-ink);
}
.st-turns td.is-focus {
  background: var(--sv-blue-bg);
}
.st-focus-slow {
  font-weight: 800;
  outline: 2px solid var(--sv-red-ink);
  outline-offset: 1px;
}
.st-row.is-focus-row > td {
  box-shadow:
    inset 0 2px 0 var(--sv-blue-ink),
    inset 0 -2px 0 var(--sv-blue-ink);
}
