/* Crossword (js/games/crossword.js). Kit styles: css/game.css. Sizes come from the layout
 * in JS: --cw-cell on .cw-board, font sizes on .cw-clue and .cw-lists, --cw-kh on .cw-kb. */

.cw-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;
  --cw-word: color-mix(in srgb, var(--accent) 16%, var(--surface-200));
  --cw-cur: color-mix(in srgb, var(--accent) 42%, var(--surface-200));
  --cw-cross: color-mix(in srgb, var(--accent) 8%, transparent);
}
@supports not (background: color-mix(in srgb, red 10%, white)) {
  .cw-room { --cw-word: var(--surface-300); --cw-cur: var(--fill-strong); --cw-cross: transparent; }
}

/* the current clue */
.cw-clue {
  position: absolute; display: flex; align-items: stretch; gap: 6px;
  border-radius: var(--radius-md); background: var(--surface-200); box-shadow: 0 0 0 1px var(--line);
}
.cw-clue-text {
  flex: 1; min-width: 0; display: block; padding: 8px 4px; border: 0; background: none; color: var(--ink);
  font: 500 1em/1.3 var(--font-sans); text-align: left; cursor: pointer; overflow: hidden;
}
.cw-clue-n { font-weight: 600; color: var(--accent); margin-right: .25em; white-space: nowrap; }
.cw-enum { color: var(--ink-muted); font-weight: 400; white-space: nowrap; }
.cw-clue-nav {
  flex: none; width: max(48px, 2.4em); border: 0; border-radius: var(--radius-md); background: none; color: var(--ink);
  display: grid; place-items: center; cursor: pointer;
}
.cw-clue-nav .icon { width: 1.1em; height: 1.1em; }
.cw-clue-nav:hover { background: var(--fill-subtle); }
.cw-clue-nav:active { background: var(--fill-strong); }

/* the grid: letter squares on the page background, no black squares */
.cw-board { position: absolute; display: grid; grid-auto-rows: var(--cw-cell); touch-action: manipulation; }
.cw-board:focus { outline: none; }
.cw-board:focus-visible { outline: 3px solid var(--focus-ring); outline-offset: 6px; border-radius: 6px; }
.cw-block { pointer-events: none; }
.cw-cell {
  position: relative; display: flex; align-items: center; justify-content: center; cursor: pointer;
  background: var(--surface-200); box-shadow: inset 0 0 0 1px var(--line-strong);
  margin: -.5px; /* shared borders */
}
.cw-n {
  position: absolute; left: 3px; top: 1px; pointer-events: none;
  font: 500 max(10px, calc(var(--cw-cell) * .26))/1.1 var(--font-sans); color: var(--ink-muted);
}
.cw-l { font: 600 calc(var(--cw-cell) * .58)/1 var(--font-sans); color: var(--ink); text-transform: uppercase; padding-top: calc(var(--cw-cell) * .08); pointer-events: none; }
.cw-cell.is-word { background: var(--cw-word); }
.cw-cell.is-cur { background: var(--cw-cur); box-shadow: inset 0 0 0 3px var(--accent); z-index: 1; }
.cw-cell.is-shown .cw-l { color: var(--accent); }
.cw-cell.is-shown::after { /* a little corner mark: this letter was shown by a hint */
  content: ''; position: absolute; right: 0; top: 0; border: calc(var(--cw-cell) * .12) solid transparent;
  border-top-color: var(--accent); border-right-color: var(--accent); pointer-events: none;
}
.cw-cell.is-wrong .cw-l { color: var(--caution); text-decoration: underline; text-decoration-thickness: .08em; text-underline-offset: .12em; }

/* Across and Down lists */
.cw-lists { position: absolute; display: grid; gap: 0 1.2em; align-items: stretch; }
.cw-lists[hidden] { display: none; }
.cw-list { min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding-right: 4px; }
.cw-lists-one { grid-auto-rows: max-content; align-content: start; overflow-y: auto; overscroll-behavior: contain; }
.cw-lists-one .cw-list { overflow: visible; }
.cw-lists-one .cw-list + .cw-list { margin-top: .6em; }
.cw-list-h { position: sticky; top: 0; z-index: 1; margin: 0; padding: .2em .4em .4em; background: var(--surface-100); font: 600 1em/1.2 var(--font-sans); letter-spacing: 0; color: var(--ink-muted); }
.cw-list ul { list-style: none; margin: 0; padding: 0; }
.cw-item {
  display: flex; gap: .55em; width: 100%; min-height: 48px; padding: .4em .5em; border: 0; border-radius: var(--radius-sm);
  background: none; color: var(--ink); font: 400 1em/1.3 var(--font-sans); text-align: left; cursor: pointer;
}
.cw-item:hover { background: var(--fill-subtle); }
.cw-item-n { flex: none; min-width: 1.4em; font-weight: 600; }
.cw-item.is-cross { background: var(--cw-cross); }
.cw-item.is-cur { background: var(--cw-word); box-shadow: inset 3px 0 0 var(--accent); }
.cw-item.is-done .cw-item-t { color: var(--ink-muted); }
.cw-item.is-done .cw-item-n { color: var(--ink-muted); }

/* the on-screen keyboard (touch screens) */
.cw-kb { position: absolute; display: flex; flex-direction: column; gap: 8px; }
.cw-kb[hidden] { display: none; }
.cw-kb-row { display: flex; justify-content: center; gap: 6px; height: var(--cw-kh, 52px); }
.cw-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(--cw-kh, 52px) * .44)/1 var(--font-sans); cursor: pointer;
}
.cw-key:active { background: var(--fill-strong); }
.cw-key-del { flex-basis: calc((100% - 54px) / 10 * 1.6); display: grid; place-items: center; }
.cw-key-del .icon { width: 1.4em; height: 1.4em; font-size: calc(var(--cw-kh, 52px) * .4); }

/* finished: a gentle green edge while the result comes up */
.cw-done .cw-cell { box-shadow: inset 0 0 0 1px var(--positive); transition: box-shadow .6s ease; }
.cw-done .cw-board { pointer-events: none; }

@media (prefers-reduced-motion: reduce) {
  .cw-done .cw-cell { transition: none; }
}
