/* ==========================================================================
   RANGO - Asistente (wizard) - rediseno 2026
   Solo tokens de design/tokens.css. Se carga despues del <style> principal.
   ========================================================================== */

/* ---- estructura: la pantalla es una columna para que el CTA quede abajo ---- */
#screen-wizard .screen-pad {
  display: flex;
  flex-direction: column;
  min-height: 100%;
  padding-bottom: 0; /* el respiro inferior lo pone .wiz-cta (dock + safe area) */
}
#screen-wizard .wiz-step { padding-bottom: var(--sp-6); }

/* ---- cabecera: atras + barra de progreso + contador ---- */
#screen-wizard .wiz-top { gap: var(--sp-3); margin-bottom: var(--sp-5); }
#screen-wizard .wiz-back { width: 44px; height: 44px; flex-shrink: 0; }
.wiz-progress {
  flex: 1;
  min-width: 0;
  height: 4px;
  border-radius: var(--r-pill);
  background: var(--hairline-strong);
  overflow: hidden;
}
.wiz-progress > i {
  display: block;
  width: 33.3%;
  height: 100%;
  border-radius: inherit;
  background: var(--gradient-principal);
  transition: width var(--dur-slow) var(--ease-out-strong);
}
.wiz-count {
  min-width: 3.4em;
  text-align: right;
  white-space: nowrap;
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}

/* ---- rotulos de grupo dentro del asistente ---- */
#screen-wizard .wiz-step .group-cap { margin: var(--sp-6) 0 var(--sp-3); }
#screen-wizard .wiz-step .group-cap:first-child { margin-top: 0; }

/* ---- opciones seleccionables (intensidad, zonas, tiempo, equipo) ---- */
.opt-grid { display: grid; gap: var(--sp-2); }
.opt-grid-int { grid-template-columns: minmax(0, 1fr); gap: var(--sp-3); }
.opt-grid-zone { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.opt-grid-time { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.opt-grid-eq { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-3); }

.opt,
#moveGrid .movement-card {
  --ck: 18px;      /* diametro de la marca de seleccion */
  --ck-o: 8px;     /* separacion a la esquina */
  --ckb: 2px;      /* grosor del trazo del check */
  position: relative;
  display: flex;
  min-width: 0;
  font-family: var(--font-body);
  font-size: var(--fs-sm);
  font-weight: 600;
  line-height: 1.25;
  text-align: left;
  color: var(--text-2);
  background: var(--surface-1);
  border: 1px solid var(--hairline-strong);
  border-radius: var(--r-md);
  cursor: pointer;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: transform var(--dur-fast) var(--ease-out-strong), border-color var(--dur-base) ease,
    background var(--dur-base) ease, color var(--dur-base) ease, box-shadow var(--dur-base) ease;
}
.opt:active,
#moveGrid .movement-card:active { transform: scale(0.97); }
.opt:focus-visible,
#moveGrid .movement-card:focus-visible { outline: 2px solid var(--performance-blue); outline-offset: 2px; }
.opt:disabled,
#moveGrid .movement-card:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }
@media (hover: hover) and (pointer: fine) {
  .opt:not(:disabled):not(.sel):hover,
  #moveGrid .movement-card:not(:disabled):not(.selected):hover { border-color: rgba(75, 111, 255, 0.5); color: var(--text-1); }
}

/* seleccionado: borde azul + fondo azul tenue */
.opt.sel,
#moveGrid .movement-card.selected {
  color: var(--text-1);
  background: rgba(75, 111, 255, 0.1);
  border-color: var(--performance-blue);
  box-shadow: inset 0 0 0 1px var(--performance-blue);
}

/* marca de check en la esquina: ::before = circulo, ::after = trazo */
.opt::before,
#moveGrid .movement-card::before {
  content: "";
  position: absolute;
  top: var(--ck-o);
  right: var(--ck-o);
  width: var(--ck);
  height: var(--ck);
  border-radius: 50%;
  background: var(--performance-blue);
  opacity: 0;
  transform: scale(0.5);
  pointer-events: none;
  transition: opacity var(--dur-base) ease, transform var(--dur-base) var(--ease-out-strong);
}
.opt::after,
#moveGrid .movement-card::after {
  content: "";
  position: absolute;
  top: calc(var(--ck-o) + var(--ck) / 2);
  right: calc(var(--ck-o) + var(--ck) / 2);
  box-sizing: content-box;
  width: calc(var(--ck) * 0.26);
  height: calc(var(--ck) * 0.5);
  border: solid var(--text-1);
  border-width: 0 var(--ckb) var(--ckb) 0;
  transform: translate(50%, -62%) rotate(45deg);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur-base) ease;
}
.opt.sel::before,
#moveGrid .movement-card.selected::before { opacity: 1; transform: none; }
.opt.sel::after,
#moveGrid .movement-card.selected::after { opacity: 1; }

/* ---- movimientos: 3 columnas, 100 px de alto ---- */
#moveGrid.movement-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--sp-3) var(--sp-2); margin-bottom: var(--sp-4); }
#moveGrid .movement-card {
  --ck: 16px;
  --ck-o: 8px;
  --ckb: 1.5px;
  flex-direction: column;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--sp-2);
  min-height: 100px;
  padding: var(--sp-3);
  font-size: var(--fs-sm);
  overflow-wrap: anywhere;
}
#moveGrid .movement-card[hidden] { display: none; }
.mv-ic {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  border-radius: var(--r-sm);
  background: rgba(244, 242, 237, 0.06);
  color: var(--text-3);
  transition: background var(--dur-base) ease, color var(--dur-base) ease;
}
#moveGrid .movement-card.selected .mv-ic { background: rgba(75, 111, 255, 0.18); color: var(--performance-blue); }
.mv-name { display: block; max-width: 100%; }

/* ---- intensidad: tarjetas apiladas con titulo + linea descriptiva ---- */
.opt-int {
  flex-direction: column;
  justify-content: center;
  gap: var(--sp-1);
  min-height: 72px;
  padding: var(--sp-4) 64px var(--sp-4) var(--sp-4);
}
.opt-title { font-family: var(--font-display); font-size: var(--fs-lg); font-weight: 600; color: var(--text-1); letter-spacing: -0.01em; }
.opt-sub { font-size: var(--fs-sm); font-weight: 400; color: var(--text-3); }
.opt.sel .opt-sub { color: var(--text-2); }
/* escalera de nivel: 4 barras, se rellenan segun la intensidad */
.int-meter {
  position: absolute;
  right: var(--sp-4);
  bottom: var(--sp-4);
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 15px;
}
.int-meter i { display: block; width: 4px; border-radius: 2px; background: var(--hairline-strong); transition: background var(--dur-base) ease; }
.int-meter i:nth-child(1) { height: 6px; }
.int-meter i:nth-child(2) { height: 9px; }
.int-meter i:nth-child(3) { height: 12px; }
.int-meter i:nth-child(4) { height: 15px; }
.int-meter[data-lv="1"] i:nth-child(-n+1),
.int-meter[data-lv="2"] i:nth-child(-n+2),
.int-meter[data-lv="3"] i:nth-child(-n+3),
.int-meter[data-lv="4"] i:nth-child(-n+4) { background: var(--text-3); }
.opt.sel .int-meter[data-lv="1"] i:nth-child(-n+1),
.opt.sel .int-meter[data-lv="2"] i:nth-child(-n+2),
.opt.sel .int-meter[data-lv="3"] i:nth-child(-n+3),
.opt.sel .int-meter[data-lv="4"] i:nth-child(-n+4) { background: var(--performance-blue); }

/* ---- zonas: mosaicos de 3 columnas, nombre corto, sin icono ---- */
.opt-zone {
  --ck: 12px;
  --ck-o: 4px;
  --ckb: 1.5px;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: var(--sp-2);
  text-align: center;
  border-radius: var(--r-sm);
  overflow-wrap: anywhere;
}

/* ---- tiempo: 5 mosaicos, numero grande en Sora + "min" ---- */
.opt-time {
  --ck: 12px;
  --ck-o: 4px;
  --ckb: 1.5px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 64px;
  padding: var(--sp-2) 0;
  text-align: center;
}
.opt-time b { font-family: var(--font-display); font-size: var(--fs-title); font-weight: 700; line-height: 1; color: var(--text-1); font-variant-numeric: tabular-nums; }
.opt-time span { font-size: var(--fs-micro); font-weight: 500; color: var(--text-3); }
.opt-time.sel span { color: var(--text-2); }

/* ---- equipo: 2 columnas con icono, minimo 56 px ---- */
.opt-eq {
  --ck: 14px;
  --ck-o: 6px;
  --ckb: 1.5px;
  align-items: center;
  gap: var(--sp-3);
  min-height: 56px;
  padding: var(--sp-2) var(--sp-3);
}
.opt-eq .row-icon { width: 32px; height: 32px; transition: background var(--dur-base) ease, color var(--dur-base) ease; }
.opt-eq.sel .row-icon { background: rgba(75, 111, 255, 0.18); color: var(--performance-blue); }
.opt-label { min-width: 0; overflow-wrap: anywhere; }

/* ---- senales de alerta: siguen como chips, con acento coral ---- */
#alertGroup .chip { text-align: center; }
#alertGroup .chip.alert.sel { border-color: var(--module-advertencia); background: rgba(241, 111, 97, 0.12); color: var(--coral-text); }

/* ---- CTA fijo sobre el dock flotante ---- */
.wiz-cta {
  --wiz-dock: calc(var(--sp-3) * 2 + 62px); /* separacion del dock (12) + dock (~62) + aire (12) */
  position: sticky;
  bottom: 0;
  z-index: 5;
  isolation: isolate;
  margin: auto calc(var(--sp-5) * -1) 0;
  padding: var(--sp-6) var(--sp-5) calc(var(--wiz-dock) + env(safe-area-inset-bottom));
  pointer-events: none; /* solo el boton captura toques; la banda de fundido deja pasar el scroll */
}
.wiz-cta > * { pointer-events: auto; }
/* banda que funde con el fondo y desenfoca lo que pasa por debajo */
.wiz-cta::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: linear-gradient(to top, var(--surface-0) 0%, var(--surface-0) 55%, transparent 100%);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  -webkit-mask-image: linear-gradient(to top, black 62%, transparent 100%);
  mask-image: linear-gradient(to top, black 62%, transparent 100%);
  pointer-events: none;
}
@media (prefers-reduced-transparency: reduce) {
  .wiz-cta::before { -webkit-backdrop-filter: none; backdrop-filter: none; -webkit-mask-image: none; mask-image: none; background: linear-gradient(to top, var(--surface-0) 70%, transparent 100%); }
}
#wizNext { margin-top: 0; }
#wizNext:disabled { opacity: 0.4; cursor: not-allowed; box-shadow: none; filter: saturate(0.6); }
#wizNext:disabled:active { transform: none; }
.wiz-hint {
  margin: 0 0 var(--sp-2);
  text-align: center;
  font-size: var(--fs-sm);
  color: var(--text-3);
}
.wiz-hint[hidden] { display: none; }

/* ---- movimiento reducido ---- */
@media (prefers-reduced-motion: reduce) {
  .opt, #moveGrid .movement-card, .opt::before, .opt::after,
  #moveGrid .movement-card::before, #moveGrid .movement-card::after,
  .wiz-progress > i, .mv-ic, .int-meter i, .opt-eq .row-icon { transition: none; }
  .opt:active, #moveGrid .movement-card:active { transform: none; }
  #screen-wizard .wiz-step { animation: none; }
}

/* el foco por teclado no debe quedar oculto bajo la banda del CTA fijo */
#screen-wizard { scroll-padding-bottom: 200px; }

/* zona segura superior: el bloque global de .screen-pad la pierde (padding fijo de 24 px) */
#screen-wizard .screen-pad { padding-top: calc(var(--sp-6) + env(safe-area-inset-top)); }

/* figura del movimiento en cada tarjeta (fotograma fijo del motor RangoFig) */
#moveGrid .movement-card .mv-fig {
  display: flex; align-items: center; justify-content: center;
  width: 100%; height: clamp(104px, 22vw, 140px); margin-bottom: var(--sp-2);
  border-radius: var(--r-sm); background: var(--surface-player); border: 1px solid var(--hairline);
  overflow: hidden;
}
#moveGrid .movement-card .mv-fig .fig { width: 100%; height: 100%; padding: 2px; }
#moveGrid .movement-card .mv-fig .fig-cue { display: none; }
#moveGrid .movement-card[aria-selected="true"] .mv-fig { border-color: color-mix(in srgb, var(--performance-blue) 45%, transparent); }
/* nombres largos (de, pt): partir con guion en vez de cortar la palabra a mitad */
#moveGrid .movement-card .mv-name { hyphens: auto; -webkit-hyphens: auto; overflow-wrap: break-word; }
