/*
 * Xakrom-Web · demo-relations · style.css · v1
 * El mapa de 18 combinaciones, pensado primero para el móvil. Solo lo propio de la vista:
 * 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, y solo pinta el aro de su cara. Pesos hasta 600. Cada estado tiene forma
 * propia además de color, y su nombre en la leyenda y en el texto accesible de la celda.
 * Pliego: DEMO_Relaciones.
 */

*, *::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%;
}

body { margin: 0; display: flow-root; }

[hidden] { display: none !important; }
h1, h2, h3, p, ul { margin: 0; }
h1, h2, h3 { font-size: inherit; font-weight: inherit; }
ul { padding: 0; list-style: none; }
img { display: block; }

.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;
}

/* ---------- Composición ---------- */

.rel {
  display: grid;
  gap: var(--xk-space-5);
  max-width: 46rem;
  margin: 0 auto;
  padding: var(--xk-space-5) var(--xk-space-4);
}

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

/* La cifra grande y su rótulo, como el 70 % del deck. */
.rel__head {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  column-gap: var(--xk-space-4);
}
.rel__big {
  color: var(--xk-blue-300);
  font-size: 3.5rem;
  font-weight: 600;
  line-height: 1;
  letter-spacing: -0.03em;
}
.rel__label {
  color: var(--xk-text-strong);
  font-size: var(--xk-text-xl);
  font-weight: 400;
  line-height: 1.25;
  letter-spacing: -0.01em;
}
.rel__sub {
  margin-top: var(--xk-space-1);
  color: var(--xk-text-muted);
  font-size: var(--xk-text-s);
  line-height: 1.5;
}

/* ---------- El mapa ---------- */

.map-wrap {
  border: 1px solid var(--xk-line);
  border-radius: var(--xk-radius-l);
  background: var(--xk-surface);
  padding: var(--xk-space-3) var(--xk-space-2);
}

@media (min-width: 34rem) {
  .map-wrap { padding: var(--xk-space-4); }
}

.map {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  table-layout: fixed;
}

.map__corner { width: 28%; }

@media (min-width: 34rem) {
  .map__corner { width: 34%; }
}

/* Las cabeceras de columna: nombre de la posición y, desde 34rem, su frase. */
.col {
  padding: var(--xk-space-1) var(--xk-space-1) var(--xk-space-3);
  text-align: center;
  vertical-align: bottom;
}
.col__name {
  display: block;
  color: var(--xk-text-strong);
  font-size: var(--xk-text-s);
  font-weight: 600;
  line-height: 1.3;
}
.col__sub {
  display: none;
  margin-top: 0.125rem;
  color: var(--xk-text-muted);
  font-size: var(--xk-text-s);
  font-weight: 400;
  line-height: 1.35;
}

/* En móvil la columna lleva el nombre corto, que cabe sin partir palabras; desde 34rem, el
   nombre entero y su frase. */
.col__name--full {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

@media (min-width: 34rem) {
  .col__sub { display: block; }
  .col__name--short { display: none; }
  .col__name--full { position: static; width: auto; height: auto; overflow: visible; clip-path: none; white-space: normal; }
}

/* La columna hacia arriba va destacada: es la que lleva la llamada del bloque. */
.col.is-focus,
.cell.is-focus {
  background: var(--xk-accent-subtle);
  box-shadow: inset 1px 0 0 var(--xk-accent-line), inset -1px 0 0 var(--xk-accent-line);
}
.col.is-focus {
  border-radius: var(--xk-radius-m) var(--xk-radius-m) 0 0;
  box-shadow: inset 1px 0 0 var(--xk-accent-line), inset -1px 0 0 var(--xk-accent-line), inset 0 1px 0 var(--xk-accent-line);
}
.col.is-focus .col__name { color: var(--xk-blue-300); }
.row:last-child .cell.is-focus {
  border-radius: 0 0 var(--xk-radius-m) var(--xk-radius-m);
  box-shadow: inset 1px 0 0 var(--xk-accent-line), inset -1px 0 0 var(--xk-accent-line), inset 0 -1px 0 var(--xk-accent-line);
}

/* La persona: cara con su aro y su filete, nombre y tipo. */
/* En móvil, la cara encima del nombre, para que el nombre quepa entero: el color de cada
   personaje va siempre con su nombre. Desde 34rem, al lado, con el tipo debajo. */
.who {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--xk-space-2);
  padding: var(--xk-space-2) var(--xk-space-1);
  text-align: center;
  font-weight: 400;
}
.row + .row .who,
.row + .row .cell { border-top: 1px solid var(--xk-line); }

.who__face {
  flex: none;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 50%;
  box-shadow: 0 0 0 2px var(--xk-surface), 0 0 0 4px var(--c);
}
.who__face img { width: 100%; height: 100%; border-radius: 50%; }
.who__text { display: grid; min-width: 0; }
.who__name {
  color: var(--xk-text-strong);
  font-size: var(--xk-text-s);
  font-weight: 600;
  line-height: 1.3;
}
/* El tipo se lee desde 34rem; por debajo no cabe y se queda en el nombre del personaje. */
.who__type {
  display: none;
  color: var(--xk-text-muted);
  font-size: var(--xk-text-s);
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (min-width: 34rem) {
  .who { flex-direction: row; gap: var(--xk-space-3); text-align: left; }
  .who__type { display: block; }
  .who__face { width: 2.5rem; height: 2.5rem; }
}

.cell {
  padding: var(--xk-space-2) var(--xk-space-1);
  text-align: center;
  vertical-align: middle;
}
.cell .mk { margin: 0 auto; }

/* El nombre del estado se lee en la celda desde 40rem; por debajo, la forma y la leyenda. */
.cell__text {
  display: none;
  margin-top: 0.25rem;
  color: var(--xk-text-muted);
  font-size: var(--xk-text-s);
  line-height: 1.3;
}
@media (min-width: 40rem) {
  .cell__text { display: block; }
}
.cell--next .cell__text { color: var(--xk-blue-300); font-weight: 600; }

/* ---------- Las cuatro formas ---------- */

.mk {
  display: block;
  width: 1.25rem;
  height: 1.25rem;
  border-radius: 50%;
  flex: none;
}
.mk--done { background: var(--xk-accent); }
.mk--hard {
  border: 2px solid var(--xk-blue-300);
  background: linear-gradient(to right, var(--xk-blue-300) 50%, transparent 50%);
}
/* El aro vacío va en el texto atenuado: con el color de las líneas no llegaría a 3:1. */
.mk--todo { border: 2px solid var(--xk-text-muted); }

/* La siguiente práctica: el acento, más grande y con su flecha hacia arriba. */
.mk--next {
  position: relative;
  width: 1.75rem;
  height: 1.75rem;
  background: var(--xk-accent);
  box-shadow: 0 0 0 4px var(--xk-accent-subtle);
}
.mk--next::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 28%;
  width: 0.5rem;
  height: 0.5rem;
  border-top: 2px solid var(--xk-action-text);
  border-left: 2px solid var(--xk-action-text);
  transform: translateX(-50%) rotate(45deg);
}
.mk--next::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 34%;
  width: 2px;
  height: 0.6rem;
  background: var(--xk-action-text);
  transform: translateX(-50%);
}

/* ---------- Leyenda y pie ---------- */

.legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--xk-space-2) var(--xk-space-5);
}
.legend li {
  display: flex;
  align-items: center;
  gap: var(--xk-space-2);
  color: var(--xk-text-muted);
  font-size: var(--xk-text-s);
  line-height: 1.4;
}
.legend .mk--next { width: 1.25rem; height: 1.25rem; box-shadow: none; }
.legend .mk--next::before { width: 0.375rem; height: 0.375rem; top: 26%; }
.legend .mk--next::after { height: 0.45rem; }

.rel__foot {
  max-width: 34rem;
  margin: 0 auto;
  color: var(--xk-text-strong);
  font-size: var(--xk-text-m);
  line-height: 1.5;
  text-align: center;
}

/* ---------- Alternativa textual ---------- */

.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); }
.fallback strong { color: var(--xk-text-strong); font-weight: 600; }

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

@keyframes xk-rise { from { opacity: 0; transform: translateY(0.4rem); } }

.rel.is-waiting .row, .rel.is-waiting .legend, .rel.is-waiting .rel__foot { opacity: 0; }
.rel.is-in .row { animation: xk-rise 0.4s var(--xk-ease-progress) both; }
.rel.is-in .row:nth-child(2) { animation-delay: 0.07s; }
.rel.is-in .row:nth-child(3) { animation-delay: 0.14s; }
.rel.is-in .row:nth-child(4) { animation-delay: 0.21s; }
.rel.is-in .row:nth-child(5) { animation-delay: 0.28s; }
.rel.is-in .row:nth-child(6) { animation-delay: 0.35s; }
.rel.is-in .legend { animation: xk-rise 0.4s 0.5s var(--xk-ease-progress) both; }
.rel.is-in .rel__foot { animation: xk-rise 0.4s 0.6s var(--xk-ease-progress) both; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

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

@media (forced-colors: active) {
  .mk--done, .mk--next { background: CanvasText; forced-color-adjust: none; }
  .mk--hard { border-color: CanvasText; background: linear-gradient(to right, CanvasText 50%, Canvas 50%); forced-color-adjust: none; }
  .mk--todo { border-color: CanvasText; }
  .mk--next::before { border-color: Canvas; }
  .mk--next::after { background: Canvas; }
  .who__face { box-shadow: none; outline: 2px solid CanvasText; outline-offset: 2px; }
  .map-wrap { border-color: CanvasText; }
  .col.is-focus, .cell.is-focus { outline: 1px solid CanvasText; }
}
