/* =====================================================================
   REDISEÑO 2026 — Mi cuerpo (#screen-test)
   Score animado, mapa corporal con estados, lista de zonas con minibarras,
   tarjeta de tendencia. Solo tokens de design/tokens.css.
   Se carga después del <style> principal: gana por cascada.
   ===================================================================== */

/* ---------- score ---------- */
#screen-test .card-cap { color: var(--text-3); }
#screen-test .test-score-head { gap: var(--sp-5); margin-bottom: 0; }
#screen-test .test-score-head .num {
  font-size: var(--fs-metric);
  letter-spacing: -0.02em;
  min-width: 2ch;           /* la cuenta 0 → valor no mueve el subtítulo */
}
#screen-test .test-score-head small {
  font-size: var(--fs-sm);
  letter-spacing: 0;
  text-transform: none;
  font-weight: 500;
  color: var(--text-3);
  margin-top: var(--sp-2);
}
.score-ring-svg { flex-shrink: 0; }

/* ---------- tendencia (solo espaciado y tipografía) ---------- */
#trendCard .card-cap { margin-bottom: var(--sp-3); }
#trendChartWrap { min-width: 0; }
#trendChartWrap .detail-row { margin: 0; font-size: var(--fs-sm); line-height: 1.5; color: var(--text-3); }
#trendChartWrap .spark { height: 88px; margin-bottom: var(--sp-1); }
#trendChartWrap .spark-meta { margin-top: var(--sp-3); gap: var(--sp-3); }
#trendChartWrap .spark-meta b { font-size: var(--fs-body); }
#trendChartWrap .pro-lock { min-height: 44px; }

/* ---------- mapa corporal ---------- */
#screen-test .body-map-wrap { padding: var(--sp-2) 0 0; }
#bodyMap .body-sil { stroke: var(--text-3); stroke-opacity: 0.6; fill: none; }

/* base común de cada articulación */
#bodyMap .joint { outline: none; }
#bodyMap .joint .dot {
  fill: none; stroke: none;
  transition: fill 320ms var(--ease-out-strong), stroke 320ms var(--ease-out-strong), stroke-opacity 320ms var(--ease-out-strong);
}
#bodyMap .joint .halo {
  opacity: 0; fill: var(--text-3);
  transition: opacity 320ms var(--ease-out-strong), fill 320ms var(--ease-out-strong);
}
/* anillo de selección: 2 px azul de marca, oculto hasta que se elige */
#bodyMap .joint .sel-ring {
  fill: none;
  stroke: var(--performance-blue);
  stroke-width: 2;
  opacity: 0;
  transform: scale(0.82);
  transform-origin: center; transform-box: fill-box;
  transition: opacity 240ms var(--ease-out-strong), transform 320ms var(--ease-out-strong), stroke 200ms ease;
}

/* SIN DATOS: anillo discontinuo tenue, sin relleno ni halo */
#bodyMap .joint[data-state="none"] .dot {
  fill: none;
  stroke: var(--text-3); stroke-opacity: 0.7; stroke-width: 1.5; stroke-dasharray: 2.6 2.4;
}
#bodyMap .joint[data-state="none"] .halo { opacity: 0; }

/* BIEN: relleno teal con halo suave */
#bodyMap .joint[data-state="ok"]  .dot  { fill: var(--score-alto); }
#bodyMap .joint[data-state="ok"]  .halo { fill: var(--score-alto); opacity: 0.2; }
/* LIMITADA: ámbar */
#bodyMap .joint[data-state="mid"] .dot  { fill: var(--score-medio); }
#bodyMap .joint[data-state="mid"] .halo { fill: var(--score-medio); opacity: 0.16; }
/* MUY BAJA: coral, solo por debajo del umbral más bajo */
#bodyMap .joint[data-state="low"] .dot  { fill: var(--score-bajo); }
#bodyMap .joint[data-state="low"] .halo { fill: var(--score-bajo); opacity: 0.18; }

/* SELECCIONADA: anillo azul + halo azul que respira despacio */
#bodyMap .joint.selected .sel-ring { opacity: 1; transform: none; }
#bodyMap .joint.selected .halo {
  fill: var(--performance-blue);
  opacity: 0.3;
  transform-origin: center; transform-box: fill-box;
  animation: jointHaloBreath 4.2s ease-in-out infinite;
}
@keyframes jointHaloBreath {
  0%, 100% { opacity: 0.16; transform: scale(0.94); }
  50%      { opacity: 0.4;  transform: scale(1.22); }
}
/* teclado: el foco se ve aunque la articulación no esté seleccionada */
#bodyMap .joint:focus-visible .sel-ring { opacity: 1; transform: none; stroke: var(--text-1); }
#bodyMap .joint.selected:focus-visible .sel-ring { stroke: var(--performance-blue); stroke-width: 2.5; }
/* sin evaluación todavía: la articulación no responde, así que no lo aparenta */
#bodyMap .joint[aria-disabled="true"] { cursor: default; }
@media (hover: hover) and (pointer: fine) {
  #bodyMap .joint:not(.selected):not([data-state="none"]):hover .halo { opacity: 0.34; }
  #bodyMap .joint:not(.selected):not([aria-disabled="true"]):hover .sel-ring { opacity: 0.45; transform: none; }
}

/* leyenda breve bajo el mapa */
.map-legend {
  display: flex; flex-wrap: wrap; justify-content: center;
  gap: var(--sp-2) var(--sp-4);
  margin-top: var(--sp-3);
  font-size: var(--fs-sm); line-height: 1.2;
  color: var(--text-3);
}
.map-legend .lg { display: inline-flex; align-items: center; gap: var(--sp-2); }
.map-legend .lg[hidden] { display: none; }
.lg-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.lg-none { border: 1.5px dashed var(--text-3); }
.lg-ok   { background: var(--score-alto); }
.lg-mid  { background: var(--score-medio); }
.lg-low  { background: var(--score-bajo); }

/* panel de detalle de la articulación */
#screen-test .joint-detail {
  margin-top: var(--sp-4);
  padding: var(--sp-4);
  border-radius: var(--r-md);
  border: 1px solid var(--hairline);
  background: var(--surface-1);
  gap: var(--sp-3);
}
#screen-test .joint-detail > div { min-width: 0; }
#screen-test .joint-detail strong { font-size: var(--fs-body); line-height: 1.3; margin-bottom: 2px; }
#screen-test .joint-detail span { display: block; font-size: var(--fs-sm); line-height: 1.4; color: var(--text-2); }
#screen-test .joint-detail b { font-size: var(--fs-title); flex-shrink: 0; min-width: 2ch; text-align: right; }

/* ---------- lista "Todas las zonas" ---------- */
#zoneListRows .zone-empty { margin: 0; font-size: var(--fs-sm); line-height: 1.5; color: var(--text-3); }
.zone-mini {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  column-gap: var(--sp-3);
  row-gap: var(--sp-2);
  padding: var(--sp-3) 0;
  border-bottom: 1px solid var(--hairline);
  font-size: var(--fs-sm);
  --zc: var(--text-3);
}
.zone-mini:first-child { padding-top: 0; }
.zone-mini:last-child { padding-bottom: 0; border-bottom: none; }
.zone-mini[data-state="ok"]   { --zc: var(--score-alto); }
.zone-mini[data-state="mid"]  { --zc: var(--score-medio); }
.zone-mini[data-state="low"]  { --zc: var(--score-bajo); }
.zone-mini .zn { display: flex; align-items: center; gap: var(--sp-2); min-width: 0; color: var(--text-1); line-height: 1.3; }
.zone-mini .zn i { width: 8px; height: 8px; flex-shrink: 0; border-radius: 50%; background: var(--zc); }
.zone-mini[data-state="none"] .zn i { background: none; border: 1.5px dashed var(--text-3); }
.zone-mini b {
  font-family: var(--font-display);
  font-size: var(--fs-lg);
  font-weight: 700;
  line-height: 1;
  color: var(--zc);
  font-variant-numeric: tabular-nums;
  min-width: 2ch; text-align: right;
}
/* minibarra de nivel: pista + relleno del color de estado */
.zone-mini .zbar {
  grid-column: 1 / -1;
  display: block;
  height: 4px;
  border-radius: var(--r-pill);
  background: var(--surface-3);
  overflow: hidden;
}
.zone-mini .zfill {
  display: block;
  width: 100%; height: 100%;
  border-radius: var(--r-pill);
  background: var(--zc);
  transform-origin: left center;
  transform: scaleX(var(--v, 0));
}
.zone-mini[data-state="none"] .zfill { display: none; }

@media (prefers-reduced-motion: no-preference) {
  .zone-mini .zfill {
    animation: zoneBarIn 640ms var(--ease-out-strong) backwards;
    animation-delay: calc(160ms + var(--i, 0) * 50ms);
  }
}
@keyframes zoneBarIn { from { transform: scaleX(0); } }

/* ---------- movimiento reducido: todo estático ---------- */
@media (prefers-reduced-motion: reduce) {
  .score-ring-svg,
  #bodyMap .joint.selected .halo,
  .zone-mini .zfill { animation: none; }
  #scoreRing,
  #bodyMap .joint .dot, #bodyMap .joint .halo, #bodyMap .joint .sel-ring { transition: none; }
  #bodyMap .joint.selected .halo { opacity: 0.3; transform: none; }
}

/* La silueta es ahora un <g> y ocupa el primer :nth-of-type del svg: los retrasos
   nth-of-type(1..5) de la base quedaban desfasados (el tobillo entraba primero).
   Se fijan por articulación, de la cabeza a los pies. */
#bodyMap .joint[data-joint="hombro"]  { animation-delay: 60ms; }
#bodyMap .joint[data-joint="torax"]   { animation-delay: 120ms; }
#bodyMap .joint[data-joint="cadera"]  { animation-delay: 180ms; }
#bodyMap .joint[data-joint="rodilla"] { animation-delay: 240ms; }
#bodyMap .joint[data-joint="tobillo"] { animation-delay: 300ms; }
