/* Word Search - uses the shared tokens from /css/fd.css. The idea: found words are inked with a soft
   highlighter stroke (round caps, one colour per find) drawn in SVG underneath the letters. */
:root {
  --hl-0: #ffd43b; --hl-1: #8ce99a; --hl-2: #74c0fc; --hl-3: #faa2c1;
  --hl-4: #ffa94d; --hl-5: #b197fc; --hl-6: #63e6be; --hl-7: #ff8787;
  --hl-alpha: .55;
}
@media (prefers-color-scheme: dark) {
  :root { --hl-0: #f59f00; --hl-1: #37b24d; --hl-2: #1c7ed6; --hl-3: #d6336c;
    --hl-4: #e8590c; --hl-5: #7048e8; --hl-6: #0ca678; --hl-7: #e03131; --hl-alpha: .6; }
}

.ws-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.ws-theme { margin: 0; display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.ws-theme .muted { font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; }
.ws-theme strong { font-size: 1.3rem; letter-spacing: -0.01em; overflow-wrap: anywhere; }
.ws-meta { margin: 0; display: flex; gap: 8px; align-items: center; flex-shrink: 0; }
.ws-time { font-variant-numeric: tabular-nums; color: var(--muted); min-width: 3.2em; text-align: right; }

/* Board: a square card; the SVG ink layer sits under a transparent grid of letter buttons. */
.ws-board { position: relative; width: 100%; max-width: 480px; margin: 0 auto; aspect-ratio: 1; background: var(--card);
  border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 6px; }
.ws-ink, .ws-grid { position: absolute; inset: 6px; width: calc(100% - 12px); height: calc(100% - 12px); }
.ws-ink { overflow: visible; pointer-events: none; }
.ws-grid { display: grid; grid-template-columns: repeat(10, 1fr); grid-template-rows: repeat(10, 1fr);
  z-index: 1; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.ws-cell { appearance: none; border: 0; background: transparent; color: var(--ink); padding: 0; margin: 0; border-radius: 50%;
  font: 700 clamp(1rem, 5.2vw, 1.5rem)/1 var(--font); cursor: pointer; display: grid; place-items: center;
  -webkit-tap-highlight-color: transparent; position: relative; }
.ws-cell:focus-visible { outline: 3px solid var(--accent); outline-offset: -3px; }
.ws-cell.start { color: var(--accent-ink); }
.ws-cell.start::before { content: ""; position: absolute; inset: 8%; border-radius: 50%; background: var(--accent); z-index: -1; }
.ws-grid.over .ws-cell { cursor: default; }

/* Strokes: width .78 of a cell, round caps -> a pill that hugs the letters. */
.ws-ink line { stroke-width: .78; stroke-linecap: round; fill: none; }
.ws-ink .sel { stroke: var(--accent); stroke-opacity: .32; }
.ws-ink .sel.miss { stroke: var(--bad); stroke-opacity: .35; animation: ws-shake .4s ease; transform-box: fill-box; }
.ws-ink .hl { stroke-opacity: var(--hl-alpha); }
.ws-ink .pop { animation: ws-draw .35s ease-out; }
.ws-ink .missed { stroke: var(--muted); stroke-opacity: .5; stroke-width: .62; stroke-dasharray: .001 .22; fill: none; }
.ws-ink .hl-0, .ws-words .hl-0 { stroke: var(--hl-0); --sw: var(--hl-0); }
.ws-ink .hl-1, .ws-words .hl-1 { stroke: var(--hl-1); --sw: var(--hl-1); }
.ws-ink .hl-2, .ws-words .hl-2 { stroke: var(--hl-2); --sw: var(--hl-2); }
.ws-ink .hl-3, .ws-words .hl-3 { stroke: var(--hl-3); --sw: var(--hl-3); }
.ws-ink .hl-4, .ws-words .hl-4 { stroke: var(--hl-4); --sw: var(--hl-4); }
.ws-ink .hl-5, .ws-words .hl-5 { stroke: var(--hl-5); --sw: var(--hl-5); }
.ws-ink .hl-6, .ws-words .hl-6 { stroke: var(--hl-6); --sw: var(--hl-6); }
.ws-ink .hl-7, .ws-words .hl-7 { stroke: var(--hl-7); --sw: var(--hl-7); }

@keyframes ws-draw { from { stroke-opacity: 0; stroke-width: .3; } }
@keyframes ws-shake { 25% { transform: translateX(-.12px); } 75% { transform: translateX(.12px); } }

/* Finish: letters of the found words bob once in reading order. */
.ws-cell.cheer { animation: ws-cheer .5s cubic-bezier(.3, 1.6, .5, 1) both; animation-delay: var(--d, 0ms); }
@keyframes ws-cheer { 0% { transform: none; } 45% { transform: translateY(-18%) scale(1.18); } 100% { transform: none; } }
.ws-board.solved { border-color: var(--good); }

.ws-live { min-height: 1.5em; margin: 10px 0 4px; text-align: center; font-weight: 600; }

.ws-words { list-style: none; padding: 0; margin: 6px 0 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 10px; }
@media (min-width: 520px) { .ws-words { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.ws-words li { display: flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--card); font-weight: 700; letter-spacing: .06em; min-height: 36px; }
.ws-words .mark { width: 1.1em; text-align: center; font-size: .9rem; }
.ws-words li.got { background: color-mix(in srgb, var(--sw) 35%, var(--card)); border-color: var(--sw); }
.ws-words li.got .w { text-decoration: line-through; text-decoration-thickness: 2px; color: var(--muted); }
.ws-words li.missed { border-style: dashed; color: var(--muted); }
.ws-words li.missed .mark { color: var(--bad); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.ws-actions { display: flex; justify-content: center; margin: 14px 0 6px; }
.ws-actions .btn.confirm { border-color: var(--accent); color: var(--accent); }

#result { margin-top: 18px; }
#result h2 { margin-top: 4px; }
.ws-pts { font-size: 1rem; font-weight: 600; }
.ws-links { font-size: .95rem; }

/* Archive */
.ws-archive { padding-left: 2.6em; margin: 0; }
.ws-archive li { padding: 4px 0; border-bottom: 1px solid var(--line); }
.ws-archive a { display: flex; justify-content: space-between; gap: 10px; padding: 8px 0; min-height: 44px; align-items: center;
  text-decoration: none; color: var(--ink); }
.ws-archive a:hover .t { color: var(--accent); }
.ws-archive .muted { font-size: .88rem; white-space: nowrap; }
