/*
 * Xakrom-Web · demo-cycle · style.css · v5
 * El ciclo en dos cajas, con el anillo de seis tramos, pensado primero para el móvil.
 * Solo lo propio del miniprograma: color, tipografía y geometría en ../_shared/tokens.css,
 * espejo de la app (WEB_Libro_Estilos). Sin colores literales y con pesos hasta 600.
 * Pliego: DEMO_Ciclo.
 * v5: fuera .btn--action, sin elemento desde que la pantalla final perdió el botón de la
 * lista de espera (D-035).
 */

/* ---------- Base del documento ---------- */

*, *::before, *::after { box-sizing: border-box; }

html {
  background: var(--xk-bg);
  color: var(--xk-text);
  font-family: var(--xk-font);
  font-size: 100%;
  line-height: var(--xk-leading);
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

/* La altura que publica frame.js es la del body: nunca se estira a la ventana. */
body { margin: 0; display: flow-root; }

[hidden] { display: none !important; }
h1, h2, h3, p, ol, ul { margin: 0; }
h1, h2, h3 { font-size: inherit; font-weight: inherit; }
ol, ul { padding: 0; list-style: none; }
img, svg { display: block; }
button { font: inherit; color: inherit; margin: 0; }
strong { color: var(--xk-text-strong); font-weight: 600; }

.xk-sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

:focus:not(:focus-visible) { outline: none; }
:focus-visible {
  outline: var(--xk-focus-width) solid var(--xk-focus);
  outline-offset: var(--xk-focus-offset);
}

.i-line { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.i-fill { fill: currentColor; }
.icon { width: 1.25rem; height: 1.25rem; flex: none; }

/* ---------- Composición: dos cajas y un pie ---------- */

.cycle {
  display: grid;
  gap: var(--xk-space-3);
  max-width: 40rem;
  margin: 0 auto;
  padding: var(--xk-space-4) var(--xk-space-4) var(--xk-space-2);
}

@media (min-width: 48rem) {
  .cycle { gap: var(--xk-space-4); padding: var(--xk-space-6) var(--xk-space-6) var(--xk-space-4); }
}

/* Las dos cajas y la pantalla final comparten rejilla. touch-action deja a la página el
   desplazamiento vertical y a la demo el gesto horizontal. */
.stack {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto auto;
  gap: var(--xk-space-4);
  touch-action: pan-y;
}

.head, .box {
  transition: opacity var(--xk-duration) var(--xk-ease), visibility 0s linear 0s;
}
.is-final .head, .is-final .box {
  visibility: hidden;
  opacity: 0;
  transition: opacity var(--xk-duration) var(--xk-ease), visibility 0s linear var(--xk-duration);
}

/* ---------- Caja del paso: sobre el fondo, con el anillo fijo ---------- */

.head {
  grid-row: 1;
  grid-column: 1;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: start;
  column-gap: var(--xk-space-4);
}

/* El anillo: seis tramos que se rellenan en el sentido de las agujas del reloj, y el
   número del paso dentro. No se mueve. */
.ring {
  position: relative;
  display: grid;
  place-items: center;
  width: 3.5rem;
  height: 3.5rem;
}
.ring__svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.ring__track, .ring__fill { fill: none; stroke-width: 4; stroke-linecap: butt; }
.ring__track { stroke: var(--xk-progress-track); transition: stroke var(--xk-duration-fast) var(--xk-ease); }
.ring__seg.is-current .ring__track { stroke: var(--xk-accent-line); }
.ring__fill {
  stroke: var(--xk-progress);
  stroke-dasharray: 1 1;
  stroke-dashoffset: 1;
  opacity: 0;
}
.ring__seg.is-done .ring__fill { stroke-dashoffset: 0; opacity: 1; }
.ring__fill.is-running { opacity: 1; animation: xk-arc var(--stage-ms, 5000ms) linear forwards; }
.is-held .ring__fill.is-running { animation-play-state: paused; }

.ring__num {
  grid-area: 1 / 1;
  color: var(--xk-text-strong);
  font-size: var(--xk-text-l);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  visibility: hidden;
}
.ring__num.is-active, .ring__num.is-leaving { visibility: visible; }

/* El texto del paso: sale por la izquierda y entra el siguiente, sin pasar sobre el anillo. */
.steps { display: grid; min-width: 0; overflow: hidden; }
.step {
  grid-area: 1 / 1;
  display: grid;
  align-content: start;
  gap: var(--xk-space-1);
  visibility: hidden;
}
.step.is-active, .step.is-leaving { visibility: visible; }
.step__name { color: var(--xk-text-strong); font-size: var(--xk-text-xl); font-weight: 400; line-height: 1.3; letter-spacing: -0.01em; }
.step__sentence { font-size: var(--xk-text-m); line-height: 1.5; }

/* ---------- Caja de la escena: resaltada y de tamaño fijo ---------- */

.box {
  grid-row: 2;
  grid-column: 1;
  display: grid;
  overflow: hidden;
  padding: var(--xk-space-5) var(--xk-space-4);
  background: var(--xk-surface);
  border: 1px solid var(--xk-line);
  border-radius: var(--xk-radius-l);
}

/* Las seis escenas ocupan la misma celda: la caja mide lo que la más alta. */
.scene {
  grid-area: 1 / 1;
  display: grid;
  align-content: center;
  gap: var(--xk-space-3);
  font-size: var(--xk-text-s);
  line-height: 1.5;
  visibility: hidden;
  opacity: 0;
  transition: opacity 0.22s var(--xk-ease), visibility 0s linear 0.22s;
}
.scene.is-active { visibility: visible; opacity: 1; transition-delay: 0s; }

.scene__text { font-size: var(--xk-text-m); }
.scene__title { color: var(--xk-text-strong); font-size: var(--xk-text-m); font-weight: 500; }
.icon--tile {
  width: 2.5rem;
  height: 2.5rem;
  padding: 0.5rem;
  border: 1px solid var(--xk-accent-line);
  border-radius: var(--xk-radius-m);
  background: var(--xk-accent-dim);
  color: var(--xk-accent);
}

/* 1 · Conócete: la silueta del perfil, encima de los tres rasgos, que van al tamaño de
   la frase de Comprende al otro */
.scene--style { justify-items: start; gap: var(--xk-space-4); }
.profile { width: 4.5rem; height: 4.5rem; }
.profile__ring { fill: none; stroke: var(--xk-line-strong); stroke-width: 1; }
.profile__shape { fill: var(--xk-raise); stroke: var(--xk-text-strong); stroke-width: 2; stroke-linejoin: round; transform-origin: 60px 60px; }
.traits { justify-self: stretch; display: grid; gap: var(--xk-space-3); font-size: var(--xk-text-m); }

/* 2 · Comprende al otro */
.faces { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--xk-space-3) var(--xk-space-2); }
.face { display: grid; justify-items: center; gap: var(--xk-space-1); }
.face img {
  width: 3.5rem;
  height: 3.5rem;
  border-radius: 50%;
  object-fit: cover;
  box-shadow: 0 0 0 2px var(--xk-surface), 0 0 0 4px var(--c);
  filter: grayscale(0.75) brightness(0.7);
}
.face__name { color: var(--xk-text-muted); font-size: var(--xk-text-s); line-height: 1.3; }
.face.is-match img { filter: none; transform: scale(1.1); }
.face.is-match .face__name { color: var(--xk-text-strong); font-weight: 600; }

/* 3 · Practica */
.call__who { display: flex; align-items: center; gap: var(--xk-space-3); }
.call__who img { width: 2.5rem; height: 2.5rem; border-radius: 50%; box-shadow: 0 0 0 2px var(--xk-surface), 0 0 0 4px var(--c); }
.call__name { color: var(--xk-text-strong); font-size: var(--xk-text-m); font-weight: 500; }
.wave { display: inline-flex; align-items: center; gap: 3px; height: 1.5rem; margin-inline-start: auto; }
.wave i { display: block; width: 4px; height: 100%; border-radius: 2px; background: var(--c); transform: scaleY(var(--h, 0.5)); }
.chat { display: grid; gap: var(--xk-space-2); }
.bubble { max-width: 88%; padding: var(--xk-space-2) var(--xk-space-3); border-radius: var(--xk-radius-m); line-height: 1.45; }
.bubble--them { justify-self: start; background: var(--xk-raise); border-inline-start: 3px solid var(--c); }
.bubble--you { justify-self: end; border: 1px solid var(--xk-line-strong); }

/* 4 · Aplica */
.plan { display: grid; gap: var(--xk-space-3); }
.plan__step { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: var(--xk-space-3); }

/* 5 · Mejora */
.skills { display: grid; gap: var(--xk-space-2); }
.skill { display: grid; grid-template-columns: minmax(6.5rem, 11rem) minmax(0, 1fr); align-items: center; gap: var(--xk-space-3); }
.bar { height: 0.5rem; border-radius: 4px; background: var(--xk-line); overflow: hidden; }
.bar__fill { display: block; height: 100%; border-radius: inherit; background: var(--xk-progress); transform: scaleX(var(--p)); transform-origin: left center; }
.note { display: flex; align-items: flex-start; gap: var(--xk-space-2); padding-top: var(--xk-space-3); border-top: 1px solid var(--xk-line); }
.note .icon { color: var(--xk-accent); margin-top: 0.1rem; }

/* 6 · Evoluciona: los tres movimientos, en orden, cada uno con su frase. Las tres
   insignias miden lo que la más ancha (subgrid); sin subgrid, una columna fija. */
.moves { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: var(--xk-space-3); }
.move { grid-column: 1 / -1; display: grid; grid-template-columns: 6.75rem minmax(0, 1fr); align-items: center; gap: var(--xk-space-3); }
@supports (grid-template-columns: subgrid) {
  .move { grid-template-columns: subgrid; }
}
.move__name {
  justify-self: stretch;
  text-align: center;
  padding: var(--xk-space-1) 0.625rem;
  border: 1px solid var(--xk-accent-line);
  border-radius: var(--xk-radius-pill);
  background: var(--xk-accent-dim);
  color: var(--xk-accent);
  font-weight: 600;
  line-height: 1.3;
}

/* ---------- Pantalla final: ocupa el sitio de las dos cajas ---------- */

.final {
  grid-row: 1 / 3;
  grid-column: 1;
  display: grid;
  justify-items: center;
  align-content: center;
  gap: var(--xk-space-5);
  padding: var(--xk-space-4) 0;
  text-align: center;
  visibility: hidden;
  opacity: 0;
  transition: opacity var(--xk-duration) var(--xk-ease), visibility 0s linear var(--xk-duration);
}
.is-final .final { visibility: visible; opacity: 1; transition-delay: 0s; }

.final__mark { width: 3.5rem; height: 3.5rem; }
.final__mark path { fill: none; stroke: var(--xk-text-strong); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.final__title { max-width: 22ch; color: var(--xk-text-strong); font-size: var(--xk-text-xl); font-weight: 400; line-height: 1.3; letter-spacing: -0.01em; }
.final__actions { display: flex; flex-wrap: wrap; justify-content: center; gap: var(--xk-space-3); }

/* Botones de la app: el principal y el secundario. */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--xk-target);
  padding: 0 var(--xk-space-6);
  border-radius: var(--xk-radius-s);
  font-size: var(--xk-text-btn);
  font-weight: 600;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
  transition: opacity var(--xk-duration-fast) var(--xk-ease), border-color var(--xk-duration-fast) var(--xk-ease), transform 0.1s var(--xk-ease);
}
.btn--quiet { background: transparent; color: var(--xk-text-strong); border: 1px solid var(--xk-line-strong); font-weight: 500; }
.btn:active { transform: scale(0.98); }
@media (hover: hover) {
  .btn--quiet:hover { border-color: var(--xk-text-strong); }
}

/* ---------- Pie: controles discretos ---------- */

.foot { display: grid; justify-items: center; }

.controls { display: flex; align-items: center; justify-content: center; gap: var(--xk-space-1); }

.ctl {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-width: 2.5rem;
  min-height: 2.5rem;
  padding: 0 var(--xk-space-3);
  border: 0;
  border-radius: var(--xk-radius-s);
  background: transparent;
  color: var(--xk-text-muted);
  font-size: var(--xk-text-s);
  font-weight: 500;
  cursor: pointer;
  transition: color var(--xk-duration-fast) var(--xk-ease), background var(--xk-duration-fast) var(--xk-ease);
}
.ctl svg { width: 1.1rem; height: 1.1rem; }
.ctl--icon { width: 2.5rem; padding: 0; }
.ctl--play { min-width: 7.5rem; }
.ctl[aria-disabled="true"] { color: var(--xk-text-disabled); cursor: default; }
@media (hover: hover) {
  .ctl:not([aria-disabled="true"]):hover { color: var(--xk-text-strong); background: var(--xk-raise); }
}

.ctl--play .i-pause, .is-playing .ctl--play .i-play { display: none; }
.is-playing .ctl--play .i-pause { display: block; }

/* ---------- Alternativa textual (sin JavaScript o sin copy) ---------- */

.fallback { padding: var(--xk-space-6) var(--xk-space-4); display: grid; gap: var(--xk-space-6); }
.fallback section { display: grid; gap: var(--xk-space-3); }
.fallback h1 { color: var(--xk-text-strong); font-size: var(--xk-text-l); font-weight: 500; }
.fallback ol { list-style: decimal; padding-inline-start: 1.5rem; display: grid; gap: var(--xk-space-2); }

/* ---------- Movimiento ---------- */

@keyframes xk-arc { from { stroke-dashoffset: 1; } to { stroke-dashoffset: 0; } }
@keyframes xk-out-left { to { opacity: 0; transform: translateX(-100%); } }
@keyframes xk-out { to { opacity: 0; transform: scale(0.6); } }
@keyframes xk-pop { from { opacity: 0; transform: scale(0.4); } }
@keyframes xk-in-right { from { opacity: 0; transform: translateX(30%); } }
@keyframes xk-rise { from { opacity: 0; transform: translateY(0.5rem); } }
@keyframes xk-grow { from { opacity: 0; transform: scale(0.4); } }
@keyframes xk-dim { from { filter: none; } }
@keyframes xk-match { from { transform: scale(1); } }
@keyframes xk-bar { from { transform: scaleX(0); } }
@keyframes xk-wave { 0%, 100% { transform: scaleY(var(--h, 0.5)); } 50% { transform: scaleY(1); } }
@keyframes xk-turn { from { transform: rotate(-120deg); opacity: 0; } }

/* Caja del paso: el texto sale por la izquierda; el número cambia dentro del anillo y el
   nombre y la frase nuevos entran deslizándose. */
.step.is-leaving { animation: xk-out-left 0.42s var(--xk-ease-progress) both; }
.step.is-active { animation: xk-in-right 0.5s 0.2s var(--xk-ease-progress) both; }
.ring__num.is-leaving { animation: xk-out 0.15s var(--xk-ease) both; }
.ring__num.is-active { animation: xk-pop 0.34s 0.15s var(--xk-ease-progress) both; }

/* Caja de la escena: se construye en menos de tres segundos. Los estados finales son los
   estáticos, así que con movimiento reducido las escenas se ven completas. */
.scene.is-active .scene__text { animation: xk-rise 0.45s 0.2s var(--xk-ease-progress) both; }
.scene--style.is-active .profile__shape { animation: xk-grow 0.8s 0.3s var(--xk-ease-progress) both; }
.scene--style.is-active .trait { animation: xk-rise 0.4s var(--xk-ease-progress) both; }
.scene--style.is-active .trait:nth-child(1) { animation-delay: 0.5s; }
.scene--style.is-active .trait:nth-child(2) { animation-delay: 0.9s; }
.scene--style.is-active .trait:nth-child(3) { animation-delay: 1.3s; }
.scene--match.is-active .face { animation: xk-rise 0.35s var(--xk-ease-progress) both; }
.scene--match.is-active .face:nth-child(1) { animation-delay: 0.3s; }
.scene--match.is-active .face:nth-child(2) { animation-delay: 0.38s; }
.scene--match.is-active .face:nth-child(3) { animation-delay: 0.46s; }
.scene--match.is-active .face:nth-child(4) { animation-delay: 0.54s; }
.scene--match.is-active .face:nth-child(5) { animation-delay: 0.62s; }
.scene--match.is-active .face:nth-child(6) { animation-delay: 0.7s; }
.scene--match.is-active .face:not(.is-match) img { animation: xk-dim 0.5s 1.2s var(--xk-ease-progress) both; }
.scene--match.is-active .face.is-match img { animation: xk-match 0.5s 1.2s var(--xk-ease-progress) both; }
.scene--match.is-active .match-name { animation: xk-rise 0.4s 1.5s var(--xk-ease-progress) both; }
.scene--call.is-active .call__who { animation: xk-rise 0.35s 0.15s var(--xk-ease-progress) both; }
.scene--call.is-active .wave i { animation: xk-wave 0.8s 0.3s ease-in-out 3 backwards; }
.scene--call.is-active .wave i:nth-child(2) { animation-delay: 0.42s; }
.scene--call.is-active .wave i:nth-child(3) { animation-delay: 0.54s; }
.scene--call.is-active .wave i:nth-child(4) { animation-delay: 0.38s; }
.scene--call.is-active .wave i:nth-child(5) { animation-delay: 0.48s; }
.scene--call.is-active .bubble { animation: xk-rise 0.4s var(--xk-ease-progress) both; }
.scene--call.is-active .bubble:nth-child(1) { animation-delay: 0.45s; }
.scene--call.is-active .bubble:nth-child(2) { animation-delay: 1.05s; }
.scene--call.is-active .bubble:nth-child(3) { animation-delay: 1.65s; }
.scene--call.is-active .bubble:nth-child(4) { animation-delay: 2.25s; }
.scene--apply.is-active .plan__step { animation: xk-rise 0.4s var(--xk-ease-progress) both; }
.scene--apply.is-active .plan__step:nth-child(1) { animation-delay: 0.2s; }
.scene--apply.is-active .plan__step:nth-child(2) { animation-delay: 0.7s; }
.scene--apply.is-active .plan__step:nth-child(3) { animation-delay: 1.2s; }
.scene--improve.is-active .scene__title { animation: xk-rise 0.35s 0.15s var(--xk-ease-progress) both; }
.scene--improve.is-active .skill { animation: xk-rise 0.35s 0.3s var(--xk-ease-progress) both; }
.scene--improve.is-active .bar__fill { animation: xk-bar 0.9s 0.5s var(--xk-ease-progress) both; }
.scene--improve.is-active .note { animation: xk-rise 0.4s 1.4s var(--xk-ease-progress) both; }
.scene--evolve.is-active .move { animation: xk-rise 0.4s var(--xk-ease-progress) both; }
.scene--evolve.is-active .move:nth-child(1) { animation-delay: 0.15s; }
.scene--evolve.is-active .move:nth-child(2) { animation-delay: 0.55s; }
.scene--evolve.is-active .move:nth-child(3) { animation-delay: 0.95s; }
.is-final .final .final__mark { animation: xk-turn 0.7s var(--xk-ease-progress) both; }
.is-final .final .final__title { animation: xk-rise 0.45s 0.15s var(--xk-ease-progress) both; }
.is-final .final .final__actions { animation: xk-rise 0.45s 0.35s var(--xk-ease-progress) both; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
  .ring__seg.is-current .ring__fill { stroke-dashoffset: 0; opacity: 1; }
}

/* ---------- Colores forzados ---------- */

@media (forced-colors: active) {
  .ring__track { stroke: GrayText; }
  .ring__seg.is-current .ring__track { stroke: CanvasText; }
  .ring__fill { stroke: Highlight; }
  .profile__shape { fill: Canvas; stroke: CanvasText; }
  .icon--tile, .move__name { border-color: CanvasText; }
  .bar { border: 1px solid CanvasText; }
  .bar__fill, .wave i { background: CanvasText; }
}
