/* ═══════════════════════════════════════════════════
   Sopa de Letras — styles
   ═══════════════════════════════════════════════════ */

/* ── Layout shell ──────────────────────────────────── */
.ww-ws {
  display: flex;
  flex-direction: column;
  height: 100%;
  gap: .5rem;
  container-type: size;
  /* LA FRANJA DE LOS CHIPS SE RESERVA (ronda 2026-08-17: «tapa las letras, se
     cruza con el puntaje»). El HUD flota adrede —no crea franja—, pero esta
     rejilla es contenido LEGIBLE de borde a borde: si crece hasta arriba, las
     letras quedan debajo de las pastillas. El alto reservado es el de un chip
     (fuente 2.6cqmin × 1.8 de caja + el relleno del HUD), con su piso en px. */
  padding-top: max(30px, 6.5cqmin);
}

/* Body: grid + word list side by side */
.ww-ws-body {
  display: flex;
  gap: .75rem;
  flex: 1 1 0;
  min-height: 0;
}

/* ── Grid wrapper ──────────────────────────────────── */
.ww-ws-grid-wrap {
  position: relative;
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Square CSS-grid of letter cells */
.ww-ws-grid {
  display: grid;
  grid-template-columns: repeat(var(--ws-cols, 15), 1fr);
  gap: 1.5px;
  background: var(--ww-card-border, #ced4da);
  border: 2px solid var(--ww-card-border, #ced4da);
  border-radius: 10px;
  overflow: hidden;
  width: min(100%, 100cqb, 580px);
  aspect-ratio: 1;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  position: relative;
  box-shadow: 0 4px 20px rgba(0,0,0,.10);
}

/* Individual cells */
.ws-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: clamp(.45rem, 2cqmin, 1.05rem);
  line-height: 1;
  background: var(--ww-card-bg, #fff);
  color: var(--ww-card-fg, var(--ww-fg, #212529));
  cursor: default;
  transition: background .07s, color .07s;
  aspect-ratio: 1;
}

/* Selecting state (current drag) */
.ws-cell.ws-sel {
  background: rgba(99, 102, 241, .22);
  color: #4f46e5;
}

/* Wrong selection flash */
.ws-cell.ws-wrong {
  background: rgba(239, 68, 68, .30) !important;
  color: #b91c1c !important;
}

/* Found cells — one class per player color */
.ws-cell.ws-found-0 { background: rgba(59,  130, 246, .20); }
.ws-cell.ws-found-1 { background: rgba(239,  68,  68, .20); }
.ws-cell.ws-found-2 { background: rgba(16,  185, 129, .20); }
.ws-cell.ws-found-3 { background: rgba(245, 158,  11, .20); }
.ws-cell.ws-found-4 { background: rgba(168,  85, 247, .20); }
.ws-cell.ws-found-5 { background: rgba(236,  72, 153, .20); }

/* SVG overlay (found-word lines) */
.ww-ws-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  border-radius: 8px;
  overflow: visible;
}

/* ── Word list sidebar ─────────────────────────────── */
.ww-ws-words {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 100px;
  max-width: 150px;
  overflow-y: auto;
  flex-shrink: 0;
}
.ww-ws-words-title {
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: #6c757d;
  margin-bottom: 2px;
}

.ws-word {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: clamp(.72rem, 1.4cqw, .88rem);
  font-weight: 700;
  background: var(--ww-bg-soft, #f1f3f5);
  color: var(--ww-card-fg, var(--ww-fg, #495057));
  letter-spacing: .02em;
  transition: background .15s, color .15s;
  line-height: 1.2;
}
.ws-word-dot { font-size: .85em; opacity: .55; flex-shrink: 0; }

/* La palabra ENCONTRADA. El verde de estado (#10b981) sobre su propio fondo
   verde claro daba 2,4:1 — medido por §29. Aquí el color no es la única señal
   (hay tachado y punto), pero 2,4:1 no se lee a 3 m: se usa un verde OSCURO
   para el texto (≈5:1) manteniendo el mismo lenguaje de color. */
.ws-word.ws-word-found {
  background: rgba(16,185,129,.18);
  color: var(--ww-success-ink, #047857);
  text-decoration: line-through;
}
.ws-word.ws-word-found .ws-word-dot { opacity: 1; }

/* ── VS round target banner ────────────────────────── */
.ww-ws-round-target {
  text-align: center;
  font-size: clamp(1rem, 3cqmin, 1.4rem);
  font-weight: 600;
  color: #6c757d;
  padding: .25rem 0;
}
.ww-ws-target-word {
  color: #4f46e5;
  font-size: clamp(1.2rem, 4cqmin, 2rem);
  font-weight: 900;
  letter-spacing: .06em;
  background: rgba(99,102,241,.10);
  border-radius: 8px;
  padding: .1em .4em;
}

/* ── Reflujo: DOS condiciones (D8, 2026-08-17) ───────────────────────────────
   «rejilla» (cuadrada, manda) y «banco de palabras». El banco es carril lateral
   solo si sobra ANCHO; si el hueco es estrecho O más alto que ancho, baja a
   filas envueltas y le devuelve la anchura a la rejilla.
   Igual que en el crucigrama: la forma SOLA no llegaba, porque el marco está
   fijado a la proporción de la plantilla y fuera de pantalla completa nunca es
   vertical (medido en un móvil de 390). */
@container (aspect-ratio < 1/1) {
  .ww-ws-body { flex-direction: column; }
  .ww-ws-words {
    flex-direction: row;
    flex-wrap: wrap;
    max-width: none;
    min-width: 0;
    gap: 4px;
  }
  .ws-word { font-size: max(.7rem, 1.8cqmin); padding: 3px 8px; }
}

/* ════════════════════════════════════════════════════
   Editor preview grid (inside the editor tab)
   ════════════════════════════════════════════════════ */
.ws-ed-preview {
  border: 1px solid #dee2e6;
  border-radius: 8px;
  overflow: hidden;
  background: #f8f9fa;
  padding: 6px;
  max-height: 380px;
  overflow-y: auto;
}

.ws-ed-grid {
  display: grid;
  grid-template-columns: repeat(var(--ws-cols, 15), 1fr);
  gap: 1px;
  font-family: monospace;
}

.ws-ed-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 1;
  font-size: clamp(.45rem, 1.5vw, .85rem);
  font-weight: 700;
  color: #adb5bd;
  border-radius: 2px;
}

.ws-ed-dot { font-size: 1rem; min-width: 1rem; text-align: center; }
