/* Word Search. */

/* The grid is as wide as its column, but never so wide (it is square) that the word list and
   the buttons under it are pushed off a laptop screen. On a phone it keeps its full width: the
   letters are the thing to protect there. */
.ws-grid {
  position: relative; border: 1px solid var(--ink); border-radius: 3px; background: var(--sheet);
  max-width: min(100%, max(20rem, calc(100vh - 20rem)));
  max-width: min(100%, max(20rem, calc(100svh - 20rem)));
  margin-inline: auto;
  container-type: inline-size;
  touch-action: pinch-zoom;          /* a drag selects instead of scrolling; a pinch still zooms */
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
.ws-row, .ws-static { display: grid; grid-template-columns: repeat(var(--n), 1fr); }
.ws-gc { display: block; }
.ws-cell {
  position: relative; z-index: 1; width: 100%; aspect-ratio: 1; padding: 0; border: 0; background: none; border-radius: 50%;
  font: 600 min(calc(58cqw / var(--n)), 1.75rem)/1 var(--sans); color: var(--ink); text-transform: uppercase;
  display: grid; place-items: center; cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.ws-cell:focus-visible { outline: 3px solid var(--ink); outline-offset: -3px; }

/* a letter in a word already found: darker than the game's colour, as on the printed answer */
.ws-cell.in { color: var(--c); color: color-mix(in srgb, var(--c) 62%, #000); }

/* the first letter chosen, waiting for the last: a solid disc, unlike anything else on the grid */
.ws-cell.first { background: var(--ink); color: var(--paper); }
.ws-cell.first:focus-visible { outline-color: var(--paper); outline-offset: -6px; }

/* a letter marked by a hint: a ring in the game's colour */
.ws-cell.hinted { box-shadow: inset 0 0 0 2px var(--c); }
.ws-cell.first.hinted { box-shadow: none; }
.ws-cell.pulse { animation: ws-pulse 0.9s ease-out 2; }
@keyframes ws-pulse {
  from { box-shadow: inset 0 0 0 2px var(--c), 0 0 0 0 color-mix(in srgb, var(--c) 55%, transparent); }
  to { box-shadow: inset 0 0 0 2px var(--c), 0 0 0 0.75rem transparent; }
}

/* the outline round each found word, and round the word being dragged */
.ws-marks { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.ws-marks .cap { fill: var(--c); fill-opacity: 0.16; stroke: var(--c); stroke-opacity: 0.85; stroke-width: 0.045; }
.ws-marks .cap.live { fill: var(--ink); fill-opacity: 0.08; stroke: var(--ink); }

.words {
  list-style: none; margin: 0; padding: 0.8125rem 0 0;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(6.5rem, 1fr)); gap: 0.4375rem 0.5rem;
  font: 600 0.9375rem/1.35 var(--sans); letter-spacing: 0.025em; text-transform: uppercase; overflow-wrap: anywhere;
}
.words .hit { color: #6F6C65; text-decoration: line-through; text-decoration-color: var(--c); text-decoration-thickness: 1.5px; }

/* the solved grid on the answers page: letters only, nothing to press */
.ws-static .ws-cell { cursor: default; }

/* Where the system sets the colours (Windows high contrast), fills and shadows are dropped:
   the chosen letter and a hinted letter are shown with the system's own highlight instead. */
@media (forced-colors: active) {
  .ws-cell.first { forced-color-adjust: none; background: Highlight; color: HighlightText; }
  .ws-cell.hinted { outline: 2px dashed Highlight; outline-offset: -4px; }
  .ws-marks .cap { stroke: Highlight; stroke-opacity: 1; fill: none; }
}


/* While the board loads, about the room it will take (game.css): the drawn board measured 455 to 495px on a phone and
   628 to 641 from 600 wide (the grid and its word list vary by day). */
#board { --board-wait: 480px; }
@media (min-width: 37.5rem) { #board { --board-wait: 632px; } }
