/* 01 The swarm: the trace pill and its card (js/trace.js), after the app's trace-pill.tsx and trace-chart.tsx. */

.tr { --tr-card: #0d1020; --tr-raise: #141831; font-size: 13px; color: var(--text); }

/* The pill, and the card that hangs from it. */
.tr-top { display: flex; align-items: center; gap: 12px; padding-left: 14px; }
.tr-pill {
  position: relative; display: inline-flex; align-items: center; gap: 10px; height: 30px; padding: 0 13px 0 12px;
  border: 1px solid var(--line-2); border-radius: 999px; background: var(--tr-card);
  font: 500 11.5px/1 var(--font-mono); color: var(--muted); font-variant-numeric: tabular-nums;
}
.tr-pill::after { content: ""; position: absolute; left: 26px; top: 100%; width: 1px; height: 11px; background: var(--line-2); }
.tr-leds { display: inline-flex; gap: 4px; }
.tr-leds i { width: 7px; height: 7px; background: color-mix(in srgb, var(--c) 18%, var(--tr-card)); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--c) 32%, transparent); transition: background-color 0.45s, box-shadow 0.45s; }
.tr-leds i.on { background: var(--c); box-shadow: 0 0 3px color-mix(in srgb, var(--c) 75%, transparent), 0 0 9px color-mix(in srgb, var(--c) 40%, transparent); animation: tr-breathe 2.4s ease-in-out infinite; }
.tr-leds i:nth-child(2).on { animation-delay: -0.7s; }
.tr-leds i:nth-child(3).on { animation-delay: -1.4s; }
.tr-leds i:nth-child(4).on { animation-delay: -2.1s; }
.tr-leds i:nth-child(5).on { animation-delay: -0.35s; }
@keyframes tr-breathe { 0%, 100% { opacity: 1; } 50% { opacity: 0.66; } }
.tr-count b { color: var(--paper); font-weight: 600; transition: color 0.3s; }
.tr-pill.tr-idle .tr-count b { color: var(--muted); }
.tr-speed { margin-left: auto; font: 500 10.5px/1 var(--font-mono); letter-spacing: 0.04em; color: var(--dim); }

.tr-card {
  position: relative; margin-top: 10px; background: var(--tr-card); border: 1px solid var(--line-2); border-radius: 14px;
  box-shadow: 0 30px 60px -30px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(0, 0, 0, 0.25);
}

/* The header: the run's title, Earlier and Later, the status line. */
.tr-head { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 3px 12px; padding: 14px 16px 6px; }
.tr-title { font-size: 14px; font-weight: 550; color: var(--paper); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: 1.35; }
.tr-sub { grid-column: 1 / -1; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tr-sub.tr-running::before {
  content: ""; display: inline-block; width: 6px; height: 6px; margin: 0 7px 1px 0; background: var(--mint);
  box-shadow: 0 0 6px var(--mint); animation: tr-breathe 1.6s ease-in-out infinite;
}
.tr-nav { display: flex; gap: 2px; margin-top: -2px; }
.tr-btn {
  display: inline-flex; align-items: center; gap: 4px; height: 26px; padding: 0 8px; border: 0; border-radius: 6px; background: none;
  font-size: 11.5px; color: var(--muted); cursor: pointer; transition: background-color 0.15s, color 0.15s;
}
.tr-btn:hover:not(:disabled) { background: var(--tr-raise); color: var(--paper); }
.tr-btn:disabled { opacity: 0.38; cursor: default; }
.tr-btn:focus-visible { outline-offset: 0; }
.tr-chev { width: 6px; height: 10px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: square; }

/* The lanes: names in a column left of the plot, or over each lane when narrow. */
.tr-body { position: relative; padding: 6px 16px 4px; }
.tr-plot { position: relative; }
.tr-canvas { margin-left: 172px; touch-action: pan-y pinch-zoom; border-radius: 2px; }
.tr-canvas:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }
.tr-lanes { position: absolute; inset: 0 auto 0 0; width: 172px; margin: 0; padding: 0; list-style: none; pointer-events: none; }
.tr-lane { position: absolute; left: 0; right: 0; display: flex; flex-direction: column; justify-content: center; gap: 4px; padding-right: 8px; transition: opacity 0.4s; }
.tr-lane.idle { opacity: 0.4; }
.tr-lane-name { display: flex; align-items: center; gap: 7px; min-width: 0; }
.tr-lane-name b { font-weight: 550; font-size: 12.5px; color: var(--paper); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tr-lane-led { flex: none; width: 7px; height: 7px; margin: 0 2px; background: var(--c); transition: box-shadow 0.4s; }
.tr-lane.on .tr-lane-led { box-shadow: 0 0 3px var(--c), 0 0 9px color-mix(in srgb, var(--c) 55%, transparent); }
.tr-lane-model { display: flex; align-items: center; gap: 7px; min-width: 0; font-size: 10.5px; color: var(--muted); }
.tr-lane-model span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tr-mark { flex: none; width: 11px; height: 11px; color: var(--muted); }

.tr-narrow .tr-canvas { margin-left: 0; }
.tr-narrow .tr-lanes { width: 100%; }
.tr-narrow .tr-lane { flex-direction: row; justify-content: flex-start; align-items: center; gap: 9px; padding: 0; }
.tr-narrow .tr-lane-name, .tr-narrow .tr-lane-model { background: var(--tr-card); padding-right: 6px; }
.tr-narrow .tr-lane-model { margin-left: -6px; gap: 5px; }
.tr-narrow .tr-title { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.tr-narrow .tr-lane-name b { font-size: 12px; }

/* The tooltip: what a stretch was, how long, and its turn's tokens and cost. */
.tr-tip {
  position: absolute; left: 0; top: 0; z-index: 5; display: grid; gap: 4px; padding: 10px 12px; border-radius: 9px;
  background: var(--tr-raise); border: 1px solid var(--line-2); box-shadow: 0 16px 34px -12px rgba(0, 0, 0, 0.75);
  pointer-events: none; opacity: 0; visibility: hidden; transition: opacity 0.12s, visibility 0s 0.12s;
}
.tr-tip.show { opacity: 1; visibility: visible; transition: opacity 0.12s; }
.tr-tip p { margin: 0; }
.tr-tip-who { display: flex; align-items: center; gap: 7px; min-width: 0; font-size: 11.5px; }
.tr-tip-who i { flex: none; width: 7px; height: 7px; background: var(--c); }
.tr-tip-who b { font-weight: 600; color: var(--paper); flex: none; }
.tr-tip-who span { color: var(--dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tr-tip-title {
  font-size: 13px; font-weight: 600; line-height: 1.35; color: var(--paper);
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.tr-tip-facts { font-size: 11.5px; line-height: 1.35; color: var(--muted); font-variant-numeric: tabular-nums; }
.tr-tip-turn { font-size: 11px; line-height: 1.35; color: var(--dim); font-variant-numeric: tabular-nums; }
.tr-tip-turn:empty { display: none; }
.tr-tip .bad { color: var(--bad); }
.tr-tip-links { display: grid; gap: 3px; }
.tr-tip-links:empty { display: none; }
.tr-tip-links p { font-size: 11.5px; line-height: 1.4; color: var(--dim); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.tr-tip-dir { color: var(--muted); }
.tr-tip-links q { color: var(--text); quotes: none; }

/* The legend for the stretches, in a neutral shade (the lanes give the colours). */
.tr-key {
  display: flex; flex-wrap: wrap; gap: 8px 16px; margin: 0; padding: 11px 16px 13px; list-style: none;
  border-top: 1px solid var(--line); font-size: 11px; color: var(--dim);
}
.tr-key li { display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; }
.tr-sw { --k: var(--muted); position: relative; width: 16px; height: 9px; border-radius: 2px; flex: none; }
.tr-sw-tool { background: var(--k); }
.tr-sw-think { background: repeating-conic-gradient(var(--k) 0 25%, color-mix(in srgb, var(--k) 30%, var(--tr-card)) 0 50%) 0 0 / 4px 4px; }
.tr-sw-write { background: var(--paper); }
.tr-sw-wait { border: 1px dashed var(--k); }
.tr-sw-retry { border: 1px solid color-mix(in srgb, var(--k) 65%, transparent); background: color-mix(in srgb, var(--k) 12%, transparent); }
.tr-sw-retry::after { content: ""; position: absolute; left: 3px; top: 1px; width: 2px; bottom: 1px; background: var(--bad); }
.tr-sw-fail { background: color-mix(in srgb, var(--k) 25%, transparent); }
.tr-sw-fail::after { content: ""; position: absolute; left: 0; right: 0; top: 11px; height: 2px; background: var(--bad); }
.tr-sw-link { height: 1px; border-radius: 0; background: none; border-top: 1px dotted var(--k); }
.tr-sw-link::before { content: ""; position: absolute; left: -1px; top: -3px; width: 4px; height: 4px; border-radius: 50%; background: var(--k); }
.tr-sw-you { width: 9px; height: 9px; border-radius: 50%; border: 1.5px solid var(--accent); }

.tr-sr { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

@media (prefers-reduced-motion: reduce) {
  .tr-leds i.on, .tr-sub.tr-running::before { animation: none; }
  .tr-tip, .tr-lane, .tr-leds i { transition: none; }
}
@media (max-width: 480px) {
  .tr-top { padding-left: 10px; }
  .tr-head { padding: 12px 12px 4px; }
  .tr-body { padding: 4px 12px 2px; }
  .tr-key { padding: 10px 12px 12px; gap: 7px 12px; }
}
