/* Word chain (js/games/word-chain.js). Kit styles: css/game.css. Sizes come from the layout
 * in JS: --wc-t (square size) on .wc-chain, --wc-kh (key height) on .wc-kb.
 * Puzzle colours: the toy palette (found words in mint, text #111 on it). */

.wc-room {
  position: absolute; inset: 0; overflow: hidden; background: var(--surface-100);
  touch-action: manipulation; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}

/* the chain: one row of squares per word, the phrase between two known words */
.wc-chain {
  position: absolute; left: 0; right: 0; display: flex; flex-direction: column; align-items: center;
  --wc-t: 56px; font-size: var(--wc-t);
}
.wc-row {
  display: flex; gap: calc(var(--wc-t) * .12); padding: 0; margin: 0; border: 0; background: none; font: inherit;
  border-radius: calc(var(--wc-t) * .2); cursor: pointer; color: var(--ink);
  outline-offset: calc(var(--wc-t) * .1);
}
.wc-row.is-given, .wc-row.is-found { cursor: default; }
.wc-tile {
  width: var(--wc-t); height: var(--wc-t); display: grid; place-items: center;
  border-radius: calc(var(--wc-t) * .16); background: var(--surface-200); box-shadow: inset 0 0 0 1.5px var(--line-strong);
  font: 600 .52em/1 var(--font-sans); text-transform: uppercase;
  transition: background-color .25s ease, box-shadow .2s ease, transform .2s ease;
}
.wc-row.is-given .wc-tile { background: var(--surface-300); box-shadow: inset 0 0 0 1.5px var(--line); }
.wc-row.is-found .wc-tile { background: var(--toy-mint, #8FD6A8); color: #111; box-shadow: none; }
.wc-tile.is-fixed { color: var(--ink-muted); }
.wc-tile.is-typed { color: var(--ink); }
.wc-row.is-active .wc-tile { box-shadow: inset 0 0 0 2px var(--accent); }
.wc-row.is-active .wc-tile.is-cursor { box-shadow: inset 0 0 0 3px var(--accent); background: color-mix(in srgb, var(--accent) 14%, var(--surface-200)); }
.wc-row.is-wrong .wc-tile { box-shadow: inset 0 0 0 2px var(--caution); }
.wc-row.is-wrong .wc-tile.is-typed { color: var(--caution); }
.wc-row.is-wrong { animation: wc-shake .35s ease; }
.wc-row:not(.is-given):not(.is-found):not(.is-active):hover .wc-tile { box-shadow: inset 0 0 0 1.5px var(--ink-muted); }

.wc-link {
  height: calc(var(--wc-t) * .62); display: flex; align-items: center; justify-content: center;
  font: 400 max(.85rem, calc(var(--wc-t) * .26))/1 var(--font-sans); color: var(--ink-muted);
  position: relative; white-space: nowrap;
}
.wc-link:not(.is-known)::before {
  content: ''; width: 3px; height: 50%; border-radius: 2px; background: var(--line-strong);
}

/* the deal-in: rows fade up one after another (moves only, never hides for long) */
.wc-chain .wc-row, .wc-chain .wc-link { opacity: .3; transform: translateY(6px); }
.wc-chain.wc-in .wc-row, .wc-chain.wc-in .wc-link { opacity: 1; transform: none; transition: opacity .35s ease, transform .35s ease; }

/* the on-screen keyboard (touch screens) */
.wc-kb { position: absolute; display: flex; flex-direction: column; gap: 8px; }
.wc-kb[hidden] { display: none; }
.wc-kb-row { display: flex; justify-content: center; gap: 6px; height: var(--wc-kh, 52px); }
.wc-key {
  flex: 0 1 calc((100% - 54px) / 10); min-width: 0; padding: 0; border: 1.5px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface-200); color: var(--ink); font: 500 calc(var(--wc-kh, 52px) * .44)/1 var(--font-sans); cursor: pointer;
}
.wc-key:active { background: var(--fill-strong); }
.wc-key-del { flex-basis: calc((100% - 54px) / 10 * 1.6); display: grid; place-items: center; }
.wc-key-del .icon { width: 1.4em; height: 1.4em; font-size: calc(var(--wc-kh, 52px) * .4); }

.wc-done .wc-chain { pointer-events: none; }

@keyframes wc-shake { 0%, 100% { transform: none; } 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }
@media (prefers-reduced-motion: reduce) {
  .wc-row.is-wrong { animation: none; }
  .wc-chain .wc-row, .wc-chain .wc-link { opacity: 1; transform: none; transition: none; }
  .wc-tile { transition: none; }
}
