/* Capture (Record and Follow), design "Challenge capture": the reference on top, your camera below, each labelled;
   a Recording pill and timer; a ring record button between round tools; a steady-phone tip. Tokens only. */
.capture[data-chrome] .ref-row { display: flex; flex-direction: column; gap: var(--space-3); }
.capture[data-chrome] .ref { order: -1; width: 100%; border-radius: var(--radius-lg); }
/* a video gets the design's frame; a 3D reference keeps its own height, controls included */
.capture[data-chrome] .ref-stage:has(> video.ref-media) { aspect-ratio: 4 / 3; }
.capture[data-chrome] .ref-stage:not(:has(> video.ref-media)) { aspect-ratio: 4 / 5; }
/* the 3D viewer's legend moves right, so the Reference routine pill has the top-left corner */
.capture[data-chrome] .ref-figure .sr-legend { left: auto; right: var(--space-3); }
.capture[data-chrome] .cam { aspect-ratio: 4 / 3; }
.capture[data-chrome] .ref-bar { background: transparent; padding: var(--space-2) 0 0; }

.cap-pill { position: absolute; z-index: 2; display: inline-flex; align-items: center; padding: 4px 12px; border-radius: var(--radius-pill);
  border: 1.5px solid var(--color-accent); background: var(--color-scrim); color: var(--color-accent);
  font: var(--weight-semibold) var(--text-sm)/1.4 var(--font-sans); pointer-events: none; }
/* the camera pill never sits on the camera's own text: it shows once the camera is live, not over "Open the camera..." (TICKET-336 T6) */
.capture[data-chrome] .cam:not([data-state="preview"]):not([data-state="counting"]):not([data-state="recording"]):not([data-state="take"]) .cap-pill { display: none; }
.cap-pill-top { top: var(--space-3); left: var(--space-3); }
/* the recording clock and its dot sit under the camera badge, never on it (TICKET-200) */
.capture[data-chrome] .cam .rc-rec { top: calc(var(--space-3) + 36px); left: calc(var(--space-3) + 16px); }
.capture[data-chrome] .cam[data-state="recording"]::after { top: calc(var(--space-3) + 36px + 7px); left: var(--space-3); }

/* the title sits under the reference, never over it: a 3D reference keeps its own controls at the bottom */
.cap-ref-meta { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3);
  padding: var(--space-3) var(--space-4); background: var(--card-fill); }
.cap-ref-meta > div { min-width: 0; } /* a long unbroken title wraps instead of widening the page */
.cap-ref-title { overflow-wrap: anywhere; margin: 0; font: var(--weight-bold) var(--text-lg)/1.2 var(--font-sans); color: var(--color-on-media); }
.cap-ref-sub { margin: 2px 0 0; font-size: var(--text-sm); color: var(--color-text-muted); }
.cap-watch { flex: none; display: inline-flex; align-items: center; min-height: var(--target-min); padding: 0 var(--space-4); border-radius: var(--radius-md);
  border: 1.5px solid var(--color-text-muted); color: var(--color-on-media); text-decoration: none; font-weight: var(--weight-semibold); white-space: nowrap; }
button.cap-watch { background: transparent; font-family: inherit; font-size: inherit; cursor: pointer; }
.cap-watch:focus-visible { outline: 2px solid var(--color-accent); outline-offset: 2px; }

/* controls: Recording pill and timer on one line, then the ring between the round tools */
.cap-controls { display: grid !important; grid-template-columns: 1fr auto; align-items: center; row-gap: var(--space-4); margin-top: var(--space-4); }
.cap-controls > .row { grid-column: 1 / -1; justify-content: center; align-items: center; gap: var(--space-6); }
.cap-controls .timer { font: var(--weight-bold) var(--text-md)/1 var(--font-mono); color: var(--color-text); }
.cap-rec-pill { justify-self: start; display: inline-flex; align-items: center; gap: 8px; padding: 6px 14px; border-radius: var(--radius-pill);
  border: 1.5px solid var(--color-accent); background: var(--color-accent-soft); color: var(--color-accent); font-weight: var(--weight-semibold);
  visibility: hidden; }
.cap-rec-pill::before { content: ""; width: 8px; height: 8px; border-radius: var(--radius-pill); background: var(--color-accent); }
.capture:has(.cam[data-state="recording"]) .cap-rec-pill { visibility: visible; }

/* the record button is a ring; Stop is the ring with a square inside */
body .cap-controls [data-testid="cam-start"]:not([hidden]), body .cap-controls [data-testid="cam-stop"]:not([hidden]) {
  display: grid; place-items: center; width: 84px; height: 84px; min-height: 0; padding: 0; border-radius: var(--radius-pill);
  border: 8px solid var(--color-accent); background: transparent; color: transparent; font-size: 0; }
body .cap-controls [data-testid="cam-start"]:not([hidden]):hover { background: var(--color-accent-soft); filter: none; }
body .cap-controls [data-testid="cam-start"]:disabled { opacity: 0.4; }
body .cap-controls [data-testid="cam-stop"]::after { content: ""; width: 26px; height: 26px; border-radius: 6px; background: var(--color-bad); }
/* Upload a video: a round tool beside the ring */
body .cap-controls label.btn.secondary { display: grid; place-items: center; width: 56px; height: 56px; min-height: 0; padding: 0;
  border-radius: var(--radius-pill); background: var(--card-fill-raised); border-color: var(--color-line); font-size: 0; }
body .cap-controls label.btn.secondary::before { content: "↑"; font-size: var(--text-lg); color: var(--color-text); }

.cap-tip { display: flex; align-items: center; gap: var(--space-3); margin: var(--space-4) 0 0; color: var(--color-text-muted); font-size: var(--text-sm); }
.cap-tip::before { content: ""; flex: none; width: 12px; height: 20px; border: 2px solid var(--color-text-muted); border-radius: 3px; }

/* Mirrored flips the picture only: the video, or the 3D canvas, never the viewer's text, legend or buttons */
body .ref[data-mirror="true"] .ref-media:not(video) { transform: none; }
body .ref[data-mirror="true"] .ref-media:not(video) canvas { transform: scaleX(-1); }

/* Live check (web/live-check.js, client 22d09a7): joints over the preview, a status chip, a cue line, the note. */
.live-canvas { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 2; }
.live-canvas.mirror { transform: scaleX(-1); }
.cam[data-state="take"] .live-canvas, .cam[data-state="idle"] .live-canvas { display: none; }
.live-chip { position: absolute; top: var(--space-3); right: var(--space-3); z-index: 3; margin: 0; padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-pill); background: var(--color-scrim); color: var(--color-on-media); font-size: var(--text-sm);
  max-width: calc(100% - 24px); }
.live-chip[data-ok="true"] { color: var(--color-accent); }
.live-chip[data-ok="false"] { color: var(--color-bad); }
.live-cue { position: absolute; left: var(--space-3); right: var(--space-3); bottom: var(--space-3); z-index: 3; margin: 0;
  padding: var(--space-2) var(--space-3); border-radius: var(--radius-sm); background: var(--color-scrim); color: var(--color-on-media);
  font-weight: var(--weight-semibold); text-align: center; }
.cam[data-state="take"] .live-chip, .cam[data-state="take"] .live-cue { display: none; }
.live-bar { display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap; margin-top: var(--space-2); }
.live-bar .live-note { margin: 0; flex: 1 1 240px; }

/* Follow the ghost (TICKET-264): the trainer's outline over the live preview, above the countdown veil */
.ghost-canvas { position: absolute; pointer-events: none; z-index: 4; }
.cam[data-state="take"] .ghost-canvas, .cam[data-state="idle"] .ghost-canvas { display: none; }
.ghost-panel { margin: var(--space-3) 0 0; }
.ghost-panel .row { flex-wrap: wrap; gap: var(--space-2); }
.ghost-step { margin: var(--space-2) 0; }

/* the small record button on the camera preview (capture.js camRec), like a video player's play button: a lime ring
   with a pink dot while the preview runs, a stop square while recording, hidden otherwise */
.cam-rec { position: absolute; left: 50%; bottom: var(--space-3); translate: -50% 0; z-index: 5; display: none; place-items: center;
  width: 36px; height: 36px; padding: 0; border: 2.5px solid var(--color-accent); border-radius: var(--radius-pill);
  background: var(--color-scrim-soft); cursor: pointer; }
.cam-rec::after { content: ""; width: 14px; height: 14px; border-radius: var(--radius-pill); background: var(--color-pink); }
.cam-rec::before { content: ""; position: absolute; inset: -5px; border-radius: var(--radius-pill); }   /* a 46 px tap area round the 36 px ring */
.cam[data-state="preview"] .cam-rec, .cam[data-state="recording"] .cam-rec { display: grid; }
.cam[data-state="recording"] .cam-rec::after { border-radius: 3px; }
.cam-rec:hover { background: var(--color-accent-soft); }
.cam-rec:focus-visible { outline: 2px solid var(--color-accent); outline-offset: 3px; }
.cam-rec:disabled { opacity: 0.4; cursor: default; }
