/* ============================================================
   Sopa de letras — rejilla + lista de palabras.
   Tamaño: --cell (lo calcula wordsearch.js). Las palabras
   encontradas son "cápsulas" SVG detrás de las letras, en tonos
   apagados derivados de los tokens (no un arcoíris): se distinguen
   entre sí sin competir con las letras.
   Escritorio (.is-wide): lista a la derecha. Móvil: debajo, en columnas.
   ============================================================ */
.ws-host { padding: 4px 0 12px; }
.ws {
  --cell: 32px;
  --ws-mix: 24%;
  --ws-dot: 70%;
  display: flex; flex-direction: column; align-items: center; gap: 18px;
  width: 100%;
}
:root[data-theme="dark"] .ws { --ws-mix: 30%; }
@media (prefers-color-scheme: dark) { :root[data-theme="auto"] .ws { --ws-mix: 30%; } }

.ws.is-wide { flex-direction: row; justify-content: center; align-items: flex-start; gap: 32px; }

/* ---------- tablero ---------- */
.ws-stage {
  padding: calc(var(--cell) * .22);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  flex: none;
}
.ws-board {
  position: relative;
  width: calc(var(--cell) * var(--w));
  height: calc(var(--cell) * var(--h));
  touch-action: none;
  user-select: none; -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  cursor: pointer;
  outline: none;
  border-radius: var(--r-sm);
}
.ws-board.is-kbd:focus { box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 40%, transparent); }
.ws-marks { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; }
.ws-letters {
  position: absolute; inset: 0;
  display: grid;
  grid-template-columns: repeat(var(--w), 1fr);
  grid-template-rows: repeat(var(--h), 1fr);
  pointer-events: none;
}
.ws-cell {
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-ui);
  font-size: calc(var(--cell) * .5 + 1px);
  font-weight: 500;
  line-height: 1;
  color: var(--ink);
  border-radius: 50%;
  transition: color var(--dur);
}
.ws-cell.is-anchor { color: var(--sel-ink); font-weight: 650; }
.ws-cell.is-cursor { box-shadow: inset 0 0 0 2px var(--focus); }
.ws-cell.is-hint { box-shadow: inset 0 0 0 2px var(--sel); color: var(--sel-ink); font-weight: 650; }
.ws-cell.is-hint.is-cursor { box-shadow: inset 0 0 0 2px var(--sel), 0 0 0 2px var(--focus); }
.ws-cell.hint-pulse { animation: ws-pulse 1.1s var(--ease) 2; }
@keyframes ws-pulse {
  0%, 100% { background: transparent; }
  45% { background: color-mix(in srgb, var(--sel) 22%, transparent); }
}

/* cápsulas */
.ws-marks line { stroke-linecap: round; stroke-width: .74; fill: none; }
.ws-found { stroke: color-mix(in srgb, var(--ws-hue) var(--ws-mix), transparent); }
.ws-found.is-shown { stroke: color-mix(in srgb, var(--muted) 16%, transparent); }
.ws-sel { stroke: none; }
.ws-sel[data-on] { stroke: color-mix(in srgb, var(--sel) 30%, transparent); }
.ws-sel[data-on="miss"] { stroke: color-mix(in srgb, var(--danger) 22%, transparent); animation: ws-fade .38s ease forwards; }
.ws-sel[data-on="again"] { stroke: color-mix(in srgb, var(--muted) 22%, transparent); animation: ws-fade .38s ease forwards; }
@keyframes ws-fade { to { opacity: 0; } }

/* seis tonos apagados sacados de la paleta */
.ws-hue-0 { --ws-hue: var(--sel); }
.ws-hue-1 { --ws-hue: var(--present); }
.ws-hue-2 { --ws-hue: var(--success); }
.ws-hue-3 { --ws-hue: var(--danger); }
.ws-hue-4 { --ws-hue: color-mix(in srgb, var(--sel) 55%, var(--ink-2)); }
.ws-hue-5 { --ws-hue: color-mix(in srgb, var(--present) 50%, var(--danger)); }

/* ---------- lista ---------- */
.ws-side { width: calc(var(--cell) * var(--w) + var(--cell) * .44 + 2px); max-width: 100%; }
.ws.is-wide .ws-side { width: clamp(190px, 22vw, 250px); padding-top: 6px; }
.ws-side-head {
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
  padding: 0 2px 10px; margin-bottom: 6px;
  border-bottom: 1px solid var(--line);
}
.ws-theme { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.ws-theme-k { font-size: var(--t-xs); letter-spacing: .14em; text-transform: uppercase; color: var(--muted); font-weight: 500; }
.ws-theme-v { font-size: var(--t-lg); font-weight: 600; color: var(--ink); letter-spacing: -.01em; line-height: 1.2; }
.ws-count { font-family: var(--font-num); font-size: var(--t-sm); color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }

.ws-words {
  list-style: none; margin: 0; padding: 0;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(106px, 1fr)); column-gap: 10px;
}
.ws-words.is-long { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.ws.is-wide .ws-words { grid-template-columns: 1fr; }
.ws-word {
  display: flex; align-items: center; gap: 9px;
  padding: 5px 2px; min-height: 30px;
  font-size: var(--t-base); color: var(--ink);
  transition: color var(--dur);
}
.ws.is-wide .ws-word { padding: 6px 2px; }
.ws-word-dot {
  width: 9px; height: 9px; border-radius: 50%; flex: none;
  box-shadow: inset 0 0 0 1.5px var(--line-2);
  transition: background var(--dur), box-shadow var(--dur);
}
.ws-word-t { min-width: 0; white-space: nowrap; }
@media (max-width: 759px) { .ws-word { font-size: .95rem; gap: 7px; } }
.ws-word.is-found { color: var(--muted); }
.ws-word.is-found .ws-word-t {
  text-decoration: line-through;
  text-decoration-color: color-mix(in srgb, var(--muted) 70%, transparent);
  text-decoration-thickness: 1.5px;
}
.ws-word.is-found .ws-word-dot { box-shadow: none; background: color-mix(in srgb, var(--ws-hue) var(--ws-dot), transparent); }
.ws-word.is-shown .ws-word-dot { background: transparent; box-shadow: inset 0 0 0 1.5px var(--line-2); }
.ws-word.is-shown .ws-word-t { font-style: italic; }
.ws-word.is-hinted { color: var(--sel-ink); }
.ws-word.is-hinted .ws-word-dot { box-shadow: inset 0 0 0 2px var(--sel); }
.ws-word.just-found .ws-word-t { animation: ws-found .5s var(--ease); }
@keyframes ws-found { 40% { transform: translateX(3px); color: var(--ink); } }

.ws.is-done .ws-board { cursor: default; }
.ws-help-keys { color: var(--muted); font-size: var(--t-sm); margin: 0 0 var(--s-4); }

@media (prefers-reduced-motion: reduce) {
  .ws-cell.hint-pulse, .ws-word.just-found .ws-word-t { animation: none; }
}
