/* 🧭 Trace the shooter — the editor's Trace panel and the inspector checkbox.
 *
 * Its own file, like ai-targets.css, so the shared style.css is untouched.
 * Tokens only (style.css's, in every theme): the path colours are read by
 * trace.js from --accent (faster), --muted (slower) and --text (steady), so
 * the legend below and the line on the video are the same colours.
 * Mobile-first: nothing has a fixed width and every child may shrink, so a
 * 390 px phone never scrolls sideways.
 */

.tr [hidden], .tr[hidden] { display: none !important; }
.tr { min-width: 0; max-width: 100%; box-sizing: border-box; }
.tr .seg-label { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; }
.tr-est { font-size: 11px; font-weight: 500; color: var(--muted); }

.tr-angle-row { display: flex; align-items: center; gap: 8px; margin: 6px 0; min-width: 0; }
.tr-angle-row label { color: var(--muted); font-size: 13px; flex: 0 0 auto; }
.tr-angle-row select { flex: 1 1 auto; min-width: 0; max-width: 100%; }

.tr-line { font-size: 13px; line-height: 1.45; overflow-wrap: anywhere; color: var(--text); }
.tr-line.err { color: var(--pen-ink); }

/* The picture. The <video> letterboxes itself (object-fit: contain); the
   canvas sits over the whole box and trace-core's displayRect() says where
   the picture is inside it. The canvas takes the pointer only while the
   person is being asked to click the shooter. */
.tr-stage {
  position: relative; width: 100%; aspect-ratio: 16 / 9; max-height: 60vh;
  margin: 8px 0; background: var(--bg2); border: 1px solid var(--line);
  border-radius: 12px; overflow: hidden; min-width: 0;
}
.tr-stage video, .tr-stage canvas {
  position: absolute; inset: 0; width: 100%; height: 100%; display: block;
}
.tr-stage video { object-fit: contain; background: var(--bg2); }
.tr-stage canvas { pointer-events: none; touch-action: none; }
.tr-stage.clicking canvas { pointer-events: auto; cursor: crosshair; }
.tr-stage.clicking { border-color: var(--accent); }
/* On a measured trace a tap on a stop's circle corrects the trace from it.
   A swipe still scrolls the page: only a waited-for tap owns the gesture. */
.tr-stage.stops canvas { pointer-events: auto; touch-action: manipulation; }

/* The people outlined at this frame, one button each, under the picture: a
   fingertip finds a 44 px button where it misses a figure 26 px wide. */
.tr-people { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 8px; min-width: 0; }
.tr-person {
  display: inline-flex; align-items: center; gap: 8px; min-height: 44px; min-width: 44px;
  padding: 4px 12px 4px 4px; font-size: 13px; flex: 0 1 auto;
}
.tr-person canvas {
  width: 48px; height: 64px; flex: 0 0 auto; border-radius: 6px; background: var(--bg2);
}
.tr-person.suggested { border-color: var(--accent); color: var(--accent2); font-weight: 650; }

.tr-free { display: flex; align-items: center; gap: 6px; min-width: 0; margin-bottom: 6px; }
.tr-free .btn { min-height: 40px; padding: 6px 10px; font-size: 13px; flex: 0 0 auto; }
.tr-free input[type=range] { flex: 1 1 auto; min-width: 0; }

.tr-status { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; min-height: 22px; }
.tr-badge {
  display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px;
  font-weight: 650; border: 1px solid var(--line2); color: var(--text); background: var(--panel2);
}
.tr-badge.moving { border-color: var(--accent); color: var(--accent2); }
.tr-badge.lost { border-color: var(--pen-ink); color: var(--pen-ink); }

.tr-progress { margin: 6px 0; min-width: 0; }
.tr-bar { height: 6px; border-radius: 999px; background: var(--line); overflow: hidden; }
.tr-bar span { display: block; height: 100%; width: 0; background: var(--accent); transition: width .3s ease; }

.tr-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; min-width: 0; }
.tr-actions .btn { min-height: 44px; flex: 1 1 auto; min-width: 0; }
.tr-actions .btn:disabled { opacity: .5; cursor: default; }

/* Stops: one chip each, the run's position decides which is lit. */
.tr-stops { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0; min-width: 0; }
.tr-stop {
  padding: 4px 10px; border-radius: 10px; font-size: 12px; line-height: 1.35;
  border: 1px solid var(--line); color: var(--muted); background: var(--panel2);
  overflow-wrap: anywhere; min-width: 0;
}
.tr-stop.done { color: var(--text); border-color: var(--line2); }
.tr-stop.current { color: var(--text); border-color: var(--accent); background: var(--panel); font-weight: 650; }
/* A measured trace's chips are buttons: a tap says the trace is on the wrong
   person from that stop. */
button.tr-stop { min-height: 44px; font: inherit; font-size: 12px; text-align: left; cursor: pointer; }

.tr-facts { font-size: 13px; line-height: 1.45; color: var(--text); overflow-wrap: anywhere; margin: 6px 0; }
.tr-facts:empty { display: none; }

.tr-gaps, .tr-notes { list-style: none; margin: 6px 0; padding: 0; min-width: 0; }
.tr-gaps:empty, .tr-notes:empty { display: none; }
.tr-gaps li {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; font-size: 13px;
  line-height: 1.4; padding: 6px 0; border-top: 1px solid var(--line); overflow-wrap: anywhere;
}
.tr-gaps li.here { color: var(--pen-ink); }
.tr-gaps .btn { min-height: 40px; padding: 6px 12px; font-size: 13px; }
.tr-notes li { font-size: 12px; color: var(--muted); line-height: 1.45; padding: 3px 0; overflow-wrap: anywhere; }

/* The inspector's checkbox (Layout tab, inside an added angle). */
.tr-stationary {
  display: flex; align-items: flex-start; gap: 10px; margin: 8px 0; min-height: 44px;
  font-size: 13px; line-height: 1.4; color: var(--text); min-width: 0;
}
.tr-stationary.hidden { display: none !important; }
.tr-stationary input { flex: 0 0 auto; width: 22px; height: 22px; margin: 0; }
.tr-stationary span { min-width: 0; overflow-wrap: anywhere; }

/* The panel's own "which clip did not move" boxes: the inspector's checkbox,
   one per clip, with the sentence above them. */
.tr-pick { margin: 4px 0 8px; min-width: 0; }
.tr-pick.hidden { display: none !important; }
.tr-pick-row {
  display: flex; align-items: flex-start; gap: 10px; margin: 8px 0; min-height: 44px;
  font-size: 13px; line-height: 1.4; color: var(--text); min-width: 0;
}
.tr-pick-row.hidden { display: none !important; }
.tr-pick-row input { flex: 0 0 auto; width: 22px; height: 22px; margin: 0; }
.tr-pick-row span { min-width: 0; overflow-wrap: anywhere; }

/* The legend in the sentence under the picture: the same tokens the line on
   the video is drawn with. */
.tr-key.faster { color: var(--accent); font-weight: 650; }
.tr-key.steady { color: var(--text); font-weight: 650; }
.tr-key.slower { color: var(--muted); font-weight: 650; }
.tr-warn { color: var(--pen-ink); }
