/* ============================================================
   Anagramas — seis filas, una activa.
   Fila en reposo: número + letras desordenadas en pequeño.
   Fila activa: casillas de respuesta (--slot, lo calcula anagram.js)
   + bandeja de fichas grandes (≥ 44px: es el teclado en móvil).
   Fila resuelta: la palabra con tildes, en verde suave.
   ============================================================ */
.an-host { padding: 4px 0 16px; }
.an {
  --slot: 42px;
  width: 100%; max-width: 640px; margin: 0 auto;
  display: flex; flex-direction: column; gap: 14px;
}

.an-head {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 12px;
  padding: 0 4px 12px;
  border-bottom: 1px solid var(--line);
}
.an-theme { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.an-theme-k { font-size: var(--t-xs); letter-spacing: .14em; text-transform: uppercase; color: var(--muted); font-weight: 500; }
.an-theme-v { font-size: var(--t-xl); font-family: var(--font-display); font-weight: 400; color: var(--ink); line-height: 1.1; }
.an-count { font-family: var(--font-num); font-size: var(--t-sm); color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; padding-bottom: 4px; }

.an-rows { display: flex; flex-direction: column; gap: 8px; }
.an-row { border-radius: var(--r-lg); scroll-margin: 16px; }
.an-num {
  flex: none; width: 24px; height: 24px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-family: var(--font-num); font-size: var(--t-xs); color: var(--muted);
  background: var(--surface-2);
}

/* ---------- en reposo ---------- */
.an-row-btn {
  width: 100%; min-height: 52px;
  display: flex; align-items: center; gap: 14px;
  padding: 8px 14px;
  background: transparent; border: 1px solid var(--line); border-radius: var(--r-lg);
  color: var(--ink); font: inherit; text-align: left; cursor: pointer;
  transition: background var(--dur), border-color var(--dur);
}
.an-row-btn:hover { background: var(--surface); border-color: var(--line-2); }
.an-row-btn:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.an-mini { display: flex; flex-wrap: wrap; gap: 3px; min-width: 0; flex: 1; }
.an-mini-l {
  width: 24px; height: 28px; display: inline-flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: .9rem; color: var(--ink-2);
  background: var(--surface-2); border-radius: 6px;
}
.an-len { flex: none; font-size: var(--t-xs); color: var(--muted); }

/* ---------- activa ---------- */
.an-row.is-active {
  background: var(--surface);
  border: 1px solid var(--line-2);
  box-shadow: var(--shadow-md);
  padding: 14px 14px 16px;
}
.an-row-top { display: flex; align-items: center; gap: 10px; position: relative; }
.an-row.is-active .an-row-top { justify-content: center; }

.an-row.is-solved .an-row-top { padding: 6px 14px; min-height: 52px; }
.an-slots { display: flex; gap: var(--slot-gap, 5px); flex-wrap: nowrap; min-width: 0; }
.an-slot {
  width: var(--slot); height: calc(var(--slot) * 1.12);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: calc(var(--slot) * .5); font-weight: 600; color: var(--ink);
  border-radius: 8px;
  background: var(--surface-2);
  box-shadow: inset 0 -2px 0 var(--line-2);
  transition: background var(--dur), box-shadow var(--dur), color var(--dur);
}
.an-slot.is-filled { background: var(--surface); box-shadow: inset 0 0 0 1.5px var(--line-2); }
.an-slot.is-next { box-shadow: inset 0 -2px 0 var(--sel); }
.an-slot.is-locked { color: var(--sel-ink); background: var(--sel-weak); box-shadow: none; }
.an-slot.hint-pulse { animation: an-pop .45s var(--ease); }
.an-slots.is-checking .an-slot { color: var(--muted); }
.an-slots.is-wrong { animation: an-shake .38s var(--ease); }
.an-slots.is-wrong .an-slot.is-filled:not(.is-locked) { color: var(--danger); box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--danger) 55%, transparent); }

.an-row-meta {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  font-size: var(--t-xs); letter-spacing: .12em; text-transform: uppercase;
  color: var(--muted); font-weight: 500; margin: -4px 0 12px 2px;
}
.an-tray-wrap { margin-top: 16px; }
.an-tray {
  --tile: 46px;
  display: flex; flex-wrap: wrap; gap: 6px; justify-content: center;
  margin: 0 auto;
}
.an-tile {
  width: var(--tile); height: calc(var(--tile) * 1.1); min-width: 40px; min-height: 44px;
  display: inline-flex; align-items: center; justify-content: center;
  font: inherit; font-size: calc(var(--tile) * .44); font-weight: 600; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line-2); border-radius: 10px;
  box-shadow: 0 1.5px 0 var(--line-2);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: opacity var(--dur), transform .08s ease, background var(--dur);
}
.an-tile:hover { background: var(--surface-2); }
.an-tile:active { transform: translateY(1px); box-shadow: none; }
.an-tile:focus-visible, .an-back:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.an-tile.is-used { opacity: .28; box-shadow: none; cursor: default; pointer-events: none; }
.an-back {
  flex: none; width: 52px; height: 40px;
  display: inline-flex; align-items: center; justify-content: center;
  background: transparent; border: 1px solid var(--line); border-radius: 10px;
  color: var(--ink-2); cursor: pointer; touch-action: manipulation;
}
.an-back:hover { background: var(--surface-2); color: var(--ink); }
.an-back[disabled] { opacity: .35; cursor: default; }
.an-back svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.an-tray.is-shuffled .an-tile { animation: an-in .22s var(--ease) both; }
.an-tray.is-nope { animation: an-shake .3s var(--ease); }

/* ---------- resuelta ---------- */
.an-row.is-solved { background: color-mix(in srgb, var(--success-weak) 70%, transparent); }
.an-word { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.an-word-t { font-size: 1.15rem; font-weight: 600; color: var(--success); letter-spacing: .01em; }
.an-word-l { font-size: var(--t-xs); color: var(--muted); }
.an-row.is-solved.is-revealed { background: var(--surface-2); }
.an-row.is-solved.is-revealed .an-word-t { color: var(--ink-2); font-style: italic; }
.an-ok { margin-left: auto; flex: none; width: 22px; height: 22px; color: var(--success); }
.an-row.is-revealed .an-ok { color: var(--muted); }
.an-ok svg { width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.an-row.just-solved .an-word-t { animation: an-pop .42s var(--ease) both; display: inline-block; }

@keyframes an-pop { 40% { transform: scale(1.08); } }
@keyframes an-shake { 20%, 60% { transform: translateX(-5px); } 40%, 80% { transform: translateX(5px); } }
@keyframes an-in { from { opacity: 0; transform: scale(.85); } }

.an-help-keys { color: var(--muted); font-size: var(--t-sm); margin: 0 0 var(--s-4); }

@media (max-width: 520px) {
  .an-row.is-active { padding: 12px 10px 14px; }
  .an-len { display: none; }
  .an-mini-l { width: 22px; }
  .an-row-btn { gap: 10px; padding: 8px 10px; }
  .an-row.is-solved .an-row-top { padding: 6px 10px; }
  .an-row-top { gap: 8px; }
}
@media (prefers-reduced-motion: reduce) {
  .an-slots.is-wrong, .an-row.just-solved .an-word-t, .an-tray.is-shuffled .an-tile, .an-slot.hint-pulse, .an-tray.is-nope { animation: none; }
}
