/*
 * Xakrom-Web · demo-skills · style.css · v4
 * Las habilidades de comunicación, 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: el de cada personaje llega como --c desde su
 * custom property de tokens.css, y solo pinta el perfilado de su cara. Pesos hasta 600.
 * El pie es el de demo-cycle y la cabecera sigue el patrón de su círculo numerado.
 * Pliego: DEMO_Habilidades.
 */

/* ---------- 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; }

/* ---------- Composición: cabecera, caja y pie ---------- */

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

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

/* touch-action deja a la página el desplazamiento vertical y a la demo el gesto horizontal. */
.deck {
  display: grid;
  gap: var(--xk-space-4);
  touch-action: pan-y;
}

/* ---------- Fuera de la caja: la escalera, el rótulo y la etapa ---------- */

/* Misma retícula que la cabecera del ciclo: marca a la izquierda, texto a la derecha y
   alineación por arriba. */
.head {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: start;
  column-gap: var(--xk-space-4);
}

/* Cuatro líneas cortas en escalera, en el sitio del círculo numerado del ciclo y con su
   mismo tamaño y grosor: una por pantalla, la suya, y las cuatro a la vez en el resumen. */
.steps { width: 3.5rem; height: 3.5rem; overflow: visible; }
.step {
  fill: none;
  stroke: var(--xk-progress-track);
  stroke-width: 4;
  stroke-linecap: round;
  transition: stroke var(--xk-duration) var(--xk-ease);
}
.step.is-on { stroke: var(--xk-progress); }

/* El rótulo y la frase llevan la tipografía del ciclo: `.step__name` y `.step__sentence`. */
.head__label {
  color: var(--xk-text-strong);
  font-size: var(--xk-text-xl);
  font-weight: 400;
  line-height: 1.3;
  letter-spacing: -0.01em;
}

/* Líneas reservadas, tres en móvil y dos a partir de 544 px: el alto de la cabecera no
   cambia de una pantalla a otra ni entre los dos idiomas. */
.head__stage {
  min-height: calc(3 * 1.5 * var(--xk-text-m));
  margin-top: var(--xk-space-1);
  color: var(--xk-text-muted);
  font-size: var(--xk-text-m);
  line-height: 1.5;
}

@media (min-width: 34rem) {
  .head__stage { min-height: calc(2 * 1.5 * var(--xk-text-m)); }
}

/* La última pantalla no lleva palabra en negrita: su frase va sola y en el color fuerte. */
.head__stage.is-plain { color: var(--xk-text-strong); }
.head__stage.is-plain .head__sep { display: none; }

/* ---------- La caja ---------- */

/* La caja y el resumen ocupan la misma celda: el bloque mide lo que el más alto, y el paso
   de la cuarta pantalla a la quinta no mueve la maqueta (DEMO_Habilidades §3.1). */
.stage { display: grid; grid-template-columns: minmax(0, 1fr); }
.card, .summary { grid-area: 1 / 1; visibility: hidden; }
.card.is-active, .summary.is-active { visibility: visible; }

/* El contenido se reparte por todo el alto de la caja en vez de apelotonarse en el centro:
   nombre, descripción, caras y cierre, con el mismo aire entre ellos y en los bordes. */
.card {
  display: grid;
  justify-items: center;
  align-content: space-evenly;
  text-align: center;
  padding: var(--xk-space-6) var(--xk-space-4);
  border: 1px solid var(--xk-line);
  border-radius: var(--xk-radius-l);
  background: var(--xk-surface);
}

.card__skill {
  color: var(--xk-text-strong);
  font-size: var(--xk-text-xl);
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: -0.01em;
}

/* La caja mide siempre lo mismo, porque comparte celda con el resumen, que es más alto, y
   el reparto del contenido no necesita reservar líneas (criterio 6 del pliego). */
.card__desc {
  max-width: 24rem;
  color: var(--xk-text-muted);
  font-size: var(--xk-text-m);
  line-height: 1.5;
}

/* La frase de cierre es la que se queda: va un escalón por encima de la descripción. */
.card__close {
  max-width: 24rem;
  color: var(--xk-text-strong);
  font-size: var(--xk-text-l);
  line-height: 1.4;
}

/* ---------- Las seis caras: aquí llevan información ---------- */

/* Dos filas de tres en móvil y una fila de seis a partir de 544 px: así las caras son
   grandes en el sitio donde menos ancho hay, y el perfilado se ve. */
.faces {
  display: grid;
  grid-template-columns: repeat(3, auto);
  justify-content: center;
  gap: var(--xk-space-3);
}

@media (min-width: 34rem) {
  .faces { grid-template-columns: repeat(6, auto); }
}

.face {
  position: relative;
  width: 4rem;
  height: 4rem;
}

/* La cara va metida hacia dentro y lleva un filete del color de la caja: entre la foto y
   el perfilado siempre queda un anillo de fondo, para que el color se distinga aunque la
   foto tenga tonos parecidos. */
.face img {
  position: absolute;
  inset: 0.5rem;
  width: calc(100% - 1rem);
  height: calc(100% - 1rem);
  border-radius: 50%;
  background: var(--xk-raise);
  box-shadow: 0 0 0 3px var(--xk-surface);
  opacity: 0.35;
  filter: grayscale(1);
  transition: opacity var(--xk-duration) var(--xk-ease), filter var(--xk-duration) var(--xk-ease);
}
.face.is-on img { opacity: 1; filter: none; }

/* El perfilado: completo en las caras de esa habilidad, y dibujándose sobre su carril en
   la que marca el tiempo de la pantalla. En las apagadas no se pinta. */
.aro {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  transform: rotate(-90deg);
}
.aro__track, .aro__fill { fill: none; stroke: transparent; stroke-width: 4; }
.face.is-on .aro__track { stroke: var(--xk-progress-track); }
.face.is-on .aro__fill { stroke: var(--c); }
.face.is-drawing .aro__fill { stroke-dasharray: 1 1; stroke-dashoffset: 1; }
.face.is-drawing .aro__fill.is-running { animation: xk-draw var(--scene-ms, 6000ms) linear forwards; }
.is-held .face.is-drawing .aro__fill.is-running { animation-play-state: paused; }

/* ---------- La última pantalla: las cuatro habilidades ---------- */

.summary { display: grid; gap: var(--xk-space-2); align-content: center; }

.srow {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--xk-space-2) var(--xk-space-3);
  padding: var(--xk-space-3) var(--xk-space-4);
  border: 1px solid var(--xk-line);
  border-radius: var(--xk-radius-m);
  background: var(--xk-surface);
}
.srow__skill {
  color: var(--xk-text-strong);
  font-size: var(--xk-text-m);
  font-weight: 500;
  line-height: 1.4;
}

/* La etapa de cada habilidad, con las palabras de las cabeceras. Siempre con su texto:
   nunca depende del color. */
.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--xk-space-2);
  justify-self: end;
  padding: 0.25rem var(--xk-space-3);
  border: 1px solid var(--xk-line-strong);
  border-radius: var(--xk-radius-pill);
  color: var(--xk-text-muted);
  font-size: var(--xk-text-s);
  font-weight: 500;
  line-height: 1.6;
}
.chip__dot {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  border: 1px solid currentColor;
}
.srow[data-state="2"] .chip { border-color: var(--xk-accent-line); color: var(--xk-text-strong); }
.srow[data-state="2"] .chip__dot { background: linear-gradient(to right, currentColor 50%, transparent 50%); }
.srow[data-state="3"] .chip {
  border-color: var(--xk-accent-line);
  background: var(--xk-accent-subtle);
  color: var(--xk-blue-300);
}
.srow[data-state="3"] .chip__dot { background: currentColor; }

.sfaces {
  grid-column: 1 / -1;
  display: flex;
  gap: var(--xk-space-2);
}
/* Mismo filete que en la caja: el anillo de color nunca toca la foto. */
.sface {
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 50%;
  opacity: 0.3;
}
.sface img { width: 100%; height: 100%; border-radius: 50%; filter: grayscale(1); }
.sface.is-on {
  opacity: 1;
  box-shadow: 0 0 0 2px var(--xk-surface), 0 0 0 4px var(--c);
}
.sface.is-on img { filter: none; }

/* ---------- Pie: el de demo-cycle ---------- */

.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; }
@media (hover: hover) {
  .ctl: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 ul { display: grid; gap: var(--xk-space-2); }

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

@keyframes xk-draw { from { stroke-dashoffset: 1; } to { stroke-dashoffset: 0; } }
@keyframes xk-pop { from { opacity: 0; transform: scale(0.6); } }
@keyframes xk-rise { from { opacity: 0; transform: translateY(0.4rem); } }

/* Entra la etapa, después la habilidad y sus caras, y al final la frase de cierre. */
.head.is-step .head__stage { animation: xk-rise 0.4s var(--xk-ease-progress) both; }
.card.is-step .card__skill { animation: xk-rise 0.4s 0.1s var(--xk-ease-progress) both; }
.card.is-step .card__desc { animation: xk-rise 0.4s 0.2s var(--xk-ease-progress) both; }
.card.is-step .faces { animation: xk-rise 0.4s 0.3s var(--xk-ease-progress) both; }
.card.is-step .card__close { animation: xk-rise 0.4s 0.5s var(--xk-ease-progress) both; }
.face.is-drawing img { animation: xk-pop 0.45s 0.3s var(--xk-ease-progress) both; }
.summary.is-step .srow { animation: xk-rise 0.4s var(--xk-ease-progress) both; }
.summary.is-step .srow:nth-child(2) { animation-delay: 0.08s; }
.summary.is-step .srow:nth-child(3) { animation-delay: 0.16s; }
.summary.is-step .srow:nth-child(4) { animation-delay: 0.24s; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
  .face.is-drawing .aro__fill { stroke-dasharray: none; stroke-dashoffset: 0; }
}

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

@media (forced-colors: active) {
  .step { stroke: GrayText; }
  .step.is-on { stroke: CanvasText; }
  .face img, .sface img { filter: none; opacity: 1; box-shadow: none; }
  /* El perfilado pintado sobre la cara no se distingue cuando el sistema fija los colores:
     la marca de encendida pasa a un contorno por fuera, sobre el fondo. */
  .face .aro { display: none; }
  .face.is-on img { outline: 3px solid CanvasText; outline-offset: 3px; }
  .sface { opacity: 1; }
  .sface.is-on { outline: 2px solid CanvasText; outline-offset: 2px; }
  .chip { border-color: CanvasText; color: CanvasText; background: Canvas; }
  .chip__dot { border-color: CanvasText; }
  .srow[data-state="2"] .chip__dot, .srow[data-state="3"] .chip__dot { background: CanvasText; }
  .card, .srow { border-color: CanvasText; }
}
