/*
 * Xakrom-Web · demo-score · style.css · v1
 * El método SCORE sobre una conversación recreada, 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 Khalid llega como --c desde
 * su custom property, y solo pinta el filo de su burbuja y el aro de su cara. Pesos hasta
 * 600. El pie es el de demo-cycle y la cabecera sigue la retícula de su círculo numerado.
 * Pliego: DEMO_SCORE.
 */

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

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

html {
  background: var(--xk-bg);
  color: var(--xk-text);
  font-family: var(--xk-font);
  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 ---------- */

.score {
  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) {
  .score { 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 flecha y el rótulo ---------- */

/* 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: center;
  column-gap: var(--xk-space-4);
}

/* La flecha bidireccional, en el sitio del círculo numerado del ciclo y con su mismo tamaño
   y grosor. Cinco tramos por lado, que se iluminan a pares de abajo a arriba; las dos
   puntas, al completar el quinto. No lleva nada dentro. */
.mark { width: 3.5rem; height: 3.5rem; overflow: visible; }

.arc {
  fill: none;
  stroke: var(--xk-progress-track);
  stroke-width: 4;
  stroke-linecap: butt;
  transition: stroke var(--xk-duration) var(--xk-ease);
}
.arc.is-done { stroke: var(--xk-progress); }

/* El par en curso se dibuja durante el tiempo de su pantalla y se detiene con la pausa. */
.arc.is-drawing { stroke: var(--xk-progress); stroke-dasharray: 1 1; stroke-dashoffset: 1; }
.arc.is-drawing.is-running { animation: xk-draw var(--scene-ms, 6000ms) linear forwards; }
.is-held .arc.is-drawing.is-running { animation-play-state: paused; }

.tip {
  fill: var(--xk-progress-track);
  transition: fill var(--xk-duration) var(--xk-ease);
}
.tip.is-done { fill: var(--xk-progress); }

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

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

/* La conversación y la pantalla final ocupan la misma celda: el bloque mide lo que el más
   alto, y pasar de la quinta a la final no mueve la maqueta (DEMO_SCORE §3.1). */
.stage { display: grid; grid-template-columns: minmax(0, 1fr); }
.talk, .final { grid-area: 1 / 1; visibility: hidden; }
.talk.is-active, .final.is-active { visibility: visible; }

.talk, .final {
  display: grid;
  gap: var(--xk-space-3);
  padding: var(--xk-space-5) var(--xk-space-4);
  border: 1px solid var(--xk-line);
  border-radius: var(--xk-radius-l);
  background: var(--xk-surface);
}

/* El contenido se reparte por el alto de la caja en vez de apelotonarse arriba: la caja
   mide lo que la pantalla final, que es la más alta (DEMO_SCORE §3.1). */
.talk { align-content: space-evenly; }

/* La letra y el nombre del paso, como antetítulo: la marca no lleva nada dentro. */
.talk__key {
  color: var(--xk-text-muted);
  font-size: var(--xk-text-label);
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.talk__letter { color: var(--xk-accent); }

/* La frase que activa el paso: es la cabecera de la pantalla. */
.talk__phrase {
  color: var(--xk-text-strong);
  font-size: var(--xk-text-l);
  font-weight: 500;
  line-height: 1.35;
  letter-spacing: -0.01em;
}

/* ---------- Los dos turnos ---------- */

.turn { display: grid; gap: var(--xk-space-2); }
.turn--you { justify-items: end; }
.turn--them { justify-items: start; }

.bubble {
  max-width: 30ch;
  padding: var(--xk-space-3) var(--xk-space-4);
  border: 1px solid var(--xk-line);
  border-radius: var(--xk-radius-l);
  background: var(--xk-raise);
  color: var(--xk-text);
  font-size: var(--xk-text-s);
  line-height: 1.55;
}

/* La del visitante, a la derecha y con el acento de la app en el filo. */
.bubble--you {
  border-color: var(--xk-accent-line);
  border-bottom-right-radius: var(--xk-radius-s);
}

/* La de Khalid, a la izquierda y con el filo de su color, que nunca va sin su nombre. */
.bubble--them {
  border-left: 3px solid var(--c);
  border-bottom-left-radius: var(--xk-radius-s);
}

/* Quién habla: la cara redonda con el aro de su color y el nombre al lado
   (DEMO_Personajes §3.1). */
.who {
  display: inline-flex;
  align-items: center;
  gap: var(--xk-space-2);
  color: var(--xk-text-muted);
  font-size: var(--xk-text-s);
  font-weight: 500;
}
.who__face {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  background: var(--xk-raise);
  box-shadow: 0 0 0 2px var(--xk-surface), 0 0 0 4px var(--c);
}

/* ---------- La pantalla final: los cinco pasos juntos ---------- */

.final { align-content: center; justify-items: center; text-align: center; }

.final__title {
  color: var(--xk-text-strong);
  font-size: var(--xk-text-l);
  font-weight: 500;
  line-height: 1.35;
}

.final__list {
  display: grid;
  gap: var(--xk-space-2);
  justify-items: center;
  width: 100%;
}
.final__list li {
  display: grid;
  gap: 0.1rem;
  padding: var(--xk-space-2) var(--xk-space-3);
  border-radius: var(--xk-radius-m);
  background: var(--xk-raise);
  width: 100%;
  max-width: 26rem;
}
.final__key {
  color: var(--xk-accent);
  font-size: var(--xk-text-label);
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.final__phrase {
  color: var(--xk-text);
  font-size: var(--xk-text-s);
  line-height: 1.45;
}

/* ---------- Botón de la pantalla final ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.5rem;
  padding: 0.55rem 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: 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-rise { from { opacity: 0; transform: translateY(0.4rem); } }

/* Entra el paso con su frase, después el turno del visitante y, tras el descanso que hace
   que se lea como conversación, el de Khalid. */
.talk.is-step .talk__key { animation: xk-rise 0.4s var(--xk-ease-progress) both; }
.talk.is-step .talk__phrase { animation: xk-rise 0.4s 0.08s var(--xk-ease-progress) both; }
.talk.is-step .turn--you { animation: xk-rise 0.4s 0.25s var(--xk-ease-progress) both; }
.talk.is-step .turn--them { animation: xk-rise 0.4s var(--xk-reply-ms, 900ms) var(--xk-ease-progress) both; }
.final.is-step .final__title { animation: xk-rise 0.4s var(--xk-ease-progress) both; }
.final.is-step .final__list li { animation: xk-rise 0.4s var(--xk-ease-progress) both; }
.final.is-step .final__list li:nth-child(2) { animation-delay: 0.08s; }
.final.is-step .final__list li:nth-child(3) { animation-delay: 0.16s; }
.final.is-step .final__list li:nth-child(4) { animation-delay: 0.24s; }
.final.is-step .final__list li:nth-child(5) { animation-delay: 0.32s; }
.final.is-step .btn { animation: xk-rise 0.4s 0.4s var(--xk-ease-progress) both; }

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

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

@media (forced-colors: active) {
  .arc { stroke: GrayText; }
  .arc.is-done, .arc.is-drawing { stroke: CanvasText; }
  .tip { fill: GrayText; }
  .tip.is-done { fill: CanvasText; }
  .talk, .final { border: 1px solid CanvasText; }
  .bubble { border-color: CanvasText; }
  .bubble--them { border-left-color: CanvasText; }
  .who__face { box-shadow: none; outline: 2px solid CanvasText; outline-offset: 2px; }
  .final__list li { border: 1px solid CanvasText; }
  .talk__letter, .final__key { color: CanvasText; }
  .btn--quiet { border-color: ButtonText; }
}
