/*
 * The viewer's own layout, on top of moqtap's design system (tokens.css and
 * bundle.css, vendored unchanged). Colours, type and spacing come only from
 * the design system's variables; this file arranges the page and nothing
 * more. A file, not inline: the view origin serves `style-src 'self'`.
 */

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

.vw-app {
  display: flex;
  flex-direction: column;
  height: 100%;
}

/* -------------------------------------------------------------- header --- */

.vw-header {
  flex-shrink: 0;
  min-width: 0;
}
.vw-title {
  margin: 0;
}
.vw-logo {
  display: inline-flex;
  align-items: center;
  line-height: 0;
  color: var(--ink);
}
/* The wordmark at the compact header's logo height. */
.vw-logo svg {
  display: block;
  height: 13.47px;
  width: auto;
}
.vw-facts {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex-shrink: 1;
  min-width: 0;
}
.vw-spacer {
  flex: 1;
}
@media (max-width: 480px) {
  .vw-facts {
    display: none;
  }
}

/* ---------------------------------------------------------------- tabs --- */

.vw-tabs {
  flex-shrink: 0;
  background: var(--surface);
}

/* ------------------------------------------------------------- surface --- */

.vw-surface {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.vw-results {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}
.vw-panel {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

/* --------------------------------------------------------- empty state --- */

.vw-empty {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  padding: var(--space-4);
}
.vw-drop {
  width: min(32rem, 100%);
}
.vw-drop p {
  margin: 0 0 var(--space-2);
  max-width: 42ch;
}
.vw-error {
  width: min(32rem, 100%);
}

.vw-overlay {
  position: fixed;
  inset: 0;
  z-index: var(--z-dialog);
  pointer-events: none;
}
.vw-overlay-target {
  width: min(32rem, 100%);
  min-height: 12rem;
}

/* ------------------------------------------------------------ overview --- */

.vw-overview {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding: var(--space-3);
}
.vw-card {
  width: 100%;
  max-width: 72rem;
  margin: 0 auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
}
.vw-card > .mq-kv {
  padding: var(--space-2) var(--space-3) var(--space-3);
}
.vw-card-note {
  margin: 0;
  padding: var(--space-2) var(--space-3) var(--space-3);
}
.vw-findings > .mq-finding:last-child {
  border-bottom: 0;
}

.vw-heading {
  display: flex;
  align-items: baseline;
  gap: var(--space-1);
  margin: 0;
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--line);
  color: var(--ink);
  font-family: var(--type-tool-label-family);
  font-size: var(--type-tool-label-size);
  line-height: var(--type-tool-label-line);
  font-weight: 600;
}

.vw-id {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  max-width: 100%;
}
/* A track alias after its series swatch, as in the design system's legend. */
.vw-track {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
}

.vw-id > .mq-addr {
  min-width: 0;
}

/* ----------------------------------------------------------- log panes --- */

@media (min-width: 561px) {
  .vw-split {
    grid-template-columns: minmax(0, 2fr) minmax(0, 3fr);
  }
}
.vw-split {
  flex: 1;
  min-height: 0;
}
.mq-split-pane > .vw-logpane {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.vw-log {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}
.vw-log:focus-visible {
  outline-offset: -2px;
}

.vw-detail {
  padding: var(--space-3);
  background: var(--bg);
}
.vw-detail:focus-visible {
  outline-offset: -2px;
}
.vw-detail > * + * {
  margin-top: var(--space-2);
}
.vw-detail-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--space-1) var(--space-3);
}
.vw-detail-title {
  margin: 0;
  font-family: var(--type-code-family);
  font-size: var(--type-code-size);
  line-height: var(--type-code-line);
  font-weight: 600;
  color: var(--ink);
  overflow-wrap: anywhere;
}
.vw-cite {
  font-size: var(--type-caption-size);
}
.vw-detail-copy {
  margin-left: auto;
  align-self: center;
}
.vw-subhead {
  margin: var(--space-4) 0 0;
  color: var(--ink);
  font-family: var(--type-tool-label-family);
  font-size: var(--type-tool-label-size);
  line-height: var(--type-tool-label-line);
  font-weight: 600;
}
.vw-note {
  margin: 0;
}
.vw-reserved {
  color: var(--warning);
}
.vw-detail .mq-tree,
.vw-opaque {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: var(--space-2);
}
.vw-opaque {
  margin: 0;
  font-family: var(--type-data-family);
  font-size: var(--type-data-size);
  line-height: var(--type-data-line);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.vw-hex {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
}
.vw-objects {
  max-height: 24rem;
  overflow: auto;
}
.vw-objects .mq-table td {
  padding: 2px var(--space-3);
}

.vw-tracks {
  flex: 0 1 auto;
  min-height: 0;
  overflow: auto;
  margin: var(--space-3);
}
.vw-tracks .mq-table td {
  padding: 2px var(--space-3);
}

.vw-panel-empty {
  flex: 1;
  justify-content: center;
}

/* --------------------------------------------------------- connections --- */

.vw-connbar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-1) var(--space-3);
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.vw-connbar .mq-label {
  margin: 0;
}
.vw-conn {
  width: auto;
  max-width: 100%;
}
.vw-conn-tag {
  color: var(--ink-muted);
  font-weight: 400;
}

/* ------------------------------------------------------------ messages --- */

.vw-messages {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}
.vw-filterbar {
  flex-shrink: 0;
  padding: var(--space-1) var(--space-2);
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.vw-filter {
  max-width: 24rem;
}
.vw-messages-pane {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}
.vw-row--pending .mq-log__meta,
.vw-pending {
  color: var(--warning);
}
.vw-detail-copy {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
}
.vw-mode {
  display: inline-flex;
  gap: 2px;
  margin-top: var(--space-3);
}
.vw-mode .mq-btn[aria-pressed="true"] {
  background: var(--surface-selected);
  color: var(--ink);
}
.vw-jump {
  font-family: var(--type-code-family);
}
.vw-unknown-param {
  color: var(--ink-muted);
}

/* -------------------------------------------------------------- tracks --- */

.vw-tracks-panel {
  flex: 1;
  min-height: 0;
  overflow: auto;
}
.vw-tracks-panel > .vw-heading {
  border-bottom: 0;
}
.vw-tracks-sub {
  margin: var(--space-3) var(--space-3) 0;
}

/* ------------------------------------------------------------ timeline --- */

.vw-timeline {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}
.vw-tl {
  display: grid;
  grid-template-columns: minmax(8rem, 14rem) minmax(0, 1fr);
  margin: var(--space-3) var(--space-3) 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
}
.vw-tl-labels {
  border-right: 1px solid var(--line);
  min-width: 0;
}
/* One row of the chart: the same 22px as `ROW` in timeline.ts. */
.vw-tl-label {
  height: 22px;
  padding: 0 var(--space-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  line-height: 22px;
}
.vw-tl-label--group {
  font-weight: 600;
  color: var(--ink);
}
.vw-tl-scroll {
  overflow-x: auto;
  min-width: 0;
}
.vw-tl-scroll:focus-visible {
  outline-offset: -2px;
}
.vw-tl-svg {
  display: block;
}
.vw-tl-grid {
  stroke: var(--chart-grid);
  stroke-width: 1;
}
.vw-tl-tick {
  fill: var(--ink-muted);
  font: 400 11px var(--font-mono);
}
.vw-tl-band {
  fill: var(--info-soft);
}
.vw-tl-band-mark {
  fill: var(--info);
  fill-opacity: 0.35;
}
.vw-tl-msg-c2s {
  stroke: var(--dir-c2s);
  stroke-width: 1.5;
}
.vw-tl-msg-s2c {
  stroke: var(--dir-s2c);
  stroke-width: 1.5;
}
.vw-tl-msg-none {
  stroke: var(--ink-muted);
  stroke-width: 1.5;
}
.vw-tl-msg-error {
  stroke: var(--danger);
  stroke-width: 2;
}
.vw-tl-hit {
  fill: transparent;
  cursor: pointer;
}
.vw-tl-pending {
  fill: var(--warning);
}
.vw-tl-player {
  cursor: pointer;
}
.vw-tl-player polygon {
  fill: var(--team);
}
.vw-tl-player-label {
  fill: var(--ink);
  font: 400 11px var(--font-sans);
}
.vw-tl-cell {
  fill: var(--chart-1);
  cursor: pointer;
}
.vw-tl-d0 {
  fill-opacity: 0.08;
}
.vw-tl-d1 {
  fill-opacity: 0.3;
}
.vw-tl-d2 {
  fill-opacity: 0.5;
}
.vw-tl-d3 {
  fill-opacity: 0.7;
}
.vw-tl-d4 {
  fill-opacity: 0.9;
}
/* Shaded whole and lighter than any density, so its label reads on it. */
.vw-tl-cell.vw-tl-cell--marked {
  fill: var(--danger);
  fill-opacity: 0.3;
  stroke: var(--danger);
  stroke-width: 1;
}
.vw-tl-cell-label {
  fill: var(--ink);
  font: 500 11px var(--font-sans);
  pointer-events: none;
}
.vw-tl-cell--selected {
  stroke: var(--ink);
  stroke-width: 2;
}
.vw-tl-flight {
  fill: none;
  stroke: var(--line-strong);
  stroke-dasharray: 3 2;
}
.vw-tl-flight-stall {
  fill: var(--danger);
  fill-opacity: 0.4;
}
.vw-tl-object {
  stroke: var(--chart-1);
  stroke-width: 1;
}
.vw-tl-cursor {
  stroke: var(--focus-ring);
  stroke-width: 1.5;
  pointer-events: none;
}
.vw-tl-detail {
  margin: var(--space-2) var(--space-3) var(--space-3);
  min-height: 18px;
  font-size: 12px;
  color: var(--ink);
}
