/*
 * Xakrom-Web · demo-characters · style.css · v1
 * Los seis personajes, uno detrás de otro, 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 su aro. Pesos hasta 600.
 * El pie es el de demo-cycle. Pliego: DEMO_Personajes.
 */

/* ---------- 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: tarjeta, fila de caras y pie ---------- */

.chars {
  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) {
  .chars { 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-5);
  touch-action: pan-y;
}

/* ---------- Tarjeta del personaje ---------- */

/* Las seis tarjetas ocupan la misma celda: el bloque mide lo que la más alta. */
.cards { display: grid; grid-template-columns: minmax(0, 1fr); }

.card {
  grid-area: 1 / 1;
  display: grid;
  justify-items: center;
  align-content: start;
  text-align: center;
  visibility: hidden;
}
.card.is-active, .card.is-leaving { visibility: visible; }

/* La cara, en un círculo, con el aro de su color: 160 px de imagen y 6 px de aro. */
.avatar {
  position: relative;
  display: grid;
  place-items: center;
  width: 10.75rem;
  height: 10.75rem;
  margin-bottom: var(--xk-space-4);
}
.avatar img {
  width: 10rem;
  height: 10rem;
  border-radius: 50%;
  object-fit: cover;
  background: var(--xk-surface);
}

/* El aro: el tramo de fondo es el color del personaje atenuado; el trazo lleno se dibuja
   durante el tiempo del personaje, en el sentido de las agujas del reloj, desde arriba. */
.aro {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  transform: rotate(-90deg);
}
.aro__track, .aro__fill { fill: none; stroke-width: 6; }
.aro__track { stroke: var(--c); opacity: 0.3; }
.aro__fill { stroke: var(--c); }
.card.is-drawing .aro__fill { stroke-dasharray: 1 1; stroke-dashoffset: 1; }
.card.is-drawing .aro__fill.is-running { animation: xk-draw var(--char-ms, 6000ms) linear forwards; }
.is-held .card.is-drawing .aro__fill.is-running { animation-play-state: paused; }

.card__type {
  color: var(--xk-text-strong);
  font-size: var(--xk-text-xl);
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: -0.01em;
}
.card__name {
  margin-top: var(--xk-space-1);
  color: var(--xk-blue-300);
  font-size: var(--xk-text-l);
  font-weight: 500;
  line-height: 1.4;
}
.card__text {
  max-width: 24rem;
  margin-top: var(--xk-space-3);
  font-size: var(--xk-text-m);
  line-height: 1.5;
}

/* ---------- Fila de las seis caras: decorativa ---------- */

.row {
  display: flex;
  justify-content: center;
  gap: var(--xk-space-2);
}
.dot {
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  opacity: 0.4;
  box-shadow: 0 0 0 2px transparent;
  transition: opacity var(--xk-duration) var(--xk-ease), box-shadow var(--xk-duration) var(--xk-ease);
}
.dot img { width: 100%; height: 100%; border-radius: 50%; }
.dot.is-active { opacity: 1; box-shadow: 0 0 0 2px var(--c); }

/* ---------- 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 ol { list-style: decimal; padding-inline-start: 1.5rem; display: grid; gap: var(--xk-space-2); }

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

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

/* Sale la tarjeta anterior y entra la nueva: primero la cara, después los textos. */
.card.is-leaving { animation: xk-fade-out 0.3s var(--xk-ease) both; }
.card.is-active .avatar { animation: xk-pop 0.5s 0.1s var(--xk-ease-progress) both; }
.card.is-active .card__type { animation: xk-rise 0.4s 0.35s var(--xk-ease-progress) both; }
.card.is-active .card__name { animation: xk-rise 0.4s 0.5s var(--xk-ease-progress) both; }
.card.is-active .card__text { animation: xk-rise 0.45s 0.7s var(--xk-ease-progress) both; }

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

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

@media (forced-colors: active) {
  .aro__track { stroke: GrayText; opacity: 1; }
  .aro__fill { stroke: CanvasText; }
  .avatar img { border: 1px solid CanvasText; }
  .dot.is-active { outline: 2px solid CanvasText; }
  .card__name { color: CanvasText; }
}
