/* RANGO — Medición con cámara en el test (rd-pose.js). Solo variables de design/tokens.css. */

/* el vídeo espejo y el lienzo de la superposición comparten caja */
.pose-stage { position: relative; }
.pose-stage video { display: block; max-height: 64vh; margin-left: auto; margin-right: auto; }
.pose-canvas {
  position: absolute;
  left: 0;
  top: 0;
  pointer-events: none;
  border-radius: var(--r-md);
}
.pose-canvas[hidden] { display: none; }

.pose-panel {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  margin: var(--sp-1) 0 var(--sp-4);
}
.pose-panel[hidden] { display: none; }
.pose-frame {
  margin: 0;
  font-size: var(--fs-body);
  line-height: 1.5;
  color: var(--text-1);
}
.pose-small { margin: 0; font-size: var(--fs-sm); line-height: 1.5; color: var(--text-3); }

/* carga diferida del modelo */
.pose-load { display: flex; flex-direction: column; gap: var(--sp-2); }
.pose-load[hidden] { display: none; }
.pose-load-row { display: flex; align-items: center; gap: var(--sp-2); margin: 0; font-size: var(--fs-body); color: var(--text-2); font-variant-numeric: tabular-nums; }
.pose-spin {
  flex: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid var(--hairline-strong);
  border-top-color: var(--performance-blue);
  animation: poseSpin 0.9s linear infinite;
}
@keyframes poseSpin { to { transform: rotate(360deg); } }
.pose-bar { height: 6px; border-radius: var(--r-pill); background: var(--surface-3); overflow: hidden; }
.pose-bar i { display: block; width: 0; height: 100%; border-radius: inherit; background: var(--performance-blue); transition: width 0.25s var(--ease-out-strong); }

/* lectura en vivo */
.pose-live { display: flex; flex-direction: column; gap: var(--sp-3); }
.pose-live[hidden] { display: none; }
.pose-quality {
  margin: 0;
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--r-sm);
  font-size: var(--fs-sm);
  line-height: 1.45;
  color: var(--text-2);
  background: var(--surface-3);
}
.pose-quality:empty { display: none; }
.pose-quality[data-state="ok"] { color: var(--teal-text); box-shadow: inset 0 0 0 1px var(--hairline-strong); }
.pose-quality[data-state="hint"] { color: var(--text-1); box-shadow: inset 3px 0 0 var(--module-protocolos); }
.pose-quality[data-state="bad"] { color: var(--text-1); box-shadow: inset 3px 0 0 var(--coral-text); }

.pose-readout { display: flex; align-items: baseline; justify-content: space-between; gap: var(--sp-3); }
.pose-readout-cap { font-size: var(--fs-sm); color: var(--text-2); }
.pose-readout-num {
  font-family: var(--font-display);
  font-size: 40px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  color: var(--text-1);
}
.pose-phase {
  margin: 0;
  font-family: var(--font-display);
  font-size: var(--fs-lg);
  font-weight: 600;
  color: var(--performance-blue);
  font-variant-numeric: tabular-nums;
}
.pose-phase[hidden] { display: none; }

.pose-result {
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r-md);
  background: var(--surface-2);
  box-shadow: inset 0 0 0 1px var(--hairline-strong);
}
.pose-result[hidden] { display: none; }
.pose-result-main { margin: 0; font-family: var(--font-display); font-size: var(--fs-lg); font-weight: 600; color: var(--text-1); font-variant-numeric: tabular-nums; }
.pose-result[data-good="1"] .pose-result-main { color: var(--teal-text); }
.pose-result-extra { margin: 0; font-size: var(--fs-sm); color: var(--text-1); }
.pose-result[data-state="fail"] { font-size: var(--fs-sm); line-height: 1.5; color: var(--text-1); box-shadow: inset 3px 0 0 var(--module-protocolos); }

.pose-actions { display: flex; gap: var(--sp-2); }
.pose-actions .btn { flex: 1; margin-top: 0; min-height: 48px; }
.pose-actions .btn[hidden] { display: none; }
.pose-error { margin: 0; font-size: var(--fs-sm); line-height: 1.5; color: var(--text-1); }
.pose-error[hidden] { display: none; }

/* etiqueta «Medido · 34°» en la respuesta que corresponde */
.pose-chip-tag {
  margin-left: auto;
  padding: 2px var(--sp-2);
  border-radius: var(--r-pill);
  font-size: var(--fs-micro);
  font-weight: 600;
  white-space: nowrap;
  color: var(--text-1);
  background: var(--performance-blue);
  font-variant-numeric: tabular-nums;
}
#testRunOptions .chip { gap: var(--sp-2); }

/* lector de pantalla: avisos moderados (sin leer cada fotograma) */
.pose-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) {
  .pose-spin { animation: none; border-top-color: var(--hairline-strong); }
  .pose-bar i { transition: none; }
}

/* vista sencilla / texto grande: lectura más grande y botones más altos */
html.rd-simple .pose-frame, html.rd-big-text .pose-frame { font-size: var(--fs-lg); }
html.rd-simple .pose-quality, html.rd-big-text .pose-quality,
html.rd-simple .pose-small, html.rd-big-text .pose-small { font-size: var(--fs-body); }
html.rd-simple .pose-readout-num { font-size: var(--fs-metric); }
html.rd-simple .pose-result-main, html.rd-big-text .pose-result-main { font-size: var(--fs-title); }
html.rd-simple .pose-actions .btn, html.rd-big-btn .pose-actions .btn { min-height: 56px; }
html.rd-simple .pose-actions { flex-direction: column; }

/* respuestas del test: objetivo táctil cómodo (≥ 44 px) también fuera de la vista sencilla */
#testRunOptions .chip { min-height: 48px; }

/* marcador sobre el vídeo: estado de la medición legible desde 2–3 m */
.pose-hud {
  position: absolute;
  left: 0;
  top: 0;
  pointer-events: none;
  border-radius: var(--r-md);
  box-shadow: inset 0 0 0 3px var(--hairline-strong);
  transition: box-shadow 0.25s var(--ease-out-strong);
}
.pose-hud[hidden] { display: none; }
.pose-hud[data-state="ready"], .pose-hud[data-state="count"], .pose-hud[data-state="done"] { box-shadow: inset 0 0 0 4px var(--recovery-teal); }
.pose-hud[data-state="rec"] { box-shadow: inset 0 0 0 4px var(--performance-blue); }
.pose-hud-pill {
  position: absolute;
  left: 50%;
  top: var(--sp-3);
  transform: translateX(-50%);
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  max-width: calc(100% - 24px);
  padding: 6px 14px;
  border-radius: var(--r-pill);
  font-family: var(--font-display);
  font-size: var(--fs-body);
  font-weight: 600;
  line-height: 1.3;
  text-align: center;
  color: var(--text-1);
  background: var(--surface-player);
  font-variant-numeric: tabular-nums;
}
.pose-hud-pill i { flex: none; width: 10px; height: 10px; border-radius: 50%; background: var(--text-3); }
.pose-hud[data-state="ready"] .pose-hud-pill i, .pose-hud[data-state="count"] .pose-hud-pill i, .pose-hud[data-state="done"] .pose-hud-pill i { background: var(--recovery-teal); }
.pose-hud[data-state="rec"] .pose-hud-pill i { background: var(--performance-blue); animation: poseRec 1s ease-in-out infinite; }
@keyframes poseRec { 50% { opacity: 0.25; } }
.pose-hud-count {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: clamp(64px, 22vw, 140px);
  font-weight: 700;
  line-height: 1;
  color: var(--bone-white);
  text-shadow: 0 2px 18px var(--obsidian-black);
  font-variant-numeric: tabular-nums;
}
.pose-hud-count:empty { display: none; }
.pose-hud[data-state="done"] .pose-hud-count { color: var(--recovery-teal); font-size: clamp(48px, 16vw, 104px); }
.pose-hud-bar {
  position: absolute;
  left: var(--sp-3);
  right: var(--sp-3);
  bottom: var(--sp-3);
  height: 6px;
  border-radius: var(--r-pill);
  background: var(--surface-player);
  overflow: hidden;
  display: none;
}
.pose-hud[data-state="rec"] .pose-hud-bar { display: block; }
.pose-hud-bar b { display: block; width: 0; height: 100%; border-radius: inherit; background: var(--performance-blue); transition: width 0.1s linear; }

.pose-how { margin: 0; font-size: var(--fs-sm); line-height: 1.5; color: var(--text-2); }
.pose-how[hidden] { display: none; }
.pose-voice {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 48px;
  padding: 0 14px;
  border-radius: var(--r-pill);
  border: 1px solid var(--hairline-strong);
  background: transparent;
  color: var(--text-3);
  font: inherit;
  font-size: var(--fs-sm);
  cursor: pointer;
}
.pose-voice.on { color: var(--text-1); border-color: var(--performance-blue); }

@media (prefers-reduced-motion: reduce) {
  .pose-hud[data-state="rec"] .pose-hud-pill i { animation: none; }
  .pose-hud, .pose-hud-bar b { transition: none; }
}
