/* Word Search game. Uses the colours and buttons from crossword.css. */
.ws-game { --ws: min(30px, calc((100vw - 44px) / var(--n, 14))); }

.ws-time { font-size: 15px; font-weight: 500; color: var(--ink); font-variant-numeric: tabular-nums; }

/* The letter grid. touch-action: none lets you drag across letters without the page scrolling. */
.ws-grid { display: grid; grid-template-columns: repeat(var(--n, 14), var(--ws)); width: max-content; max-width: 100%; margin: 12px auto 8px; padding: 4px; background: var(--card); border: 1px solid var(--border); border-radius: 14px; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent; cursor: pointer; }
.ws-cell { width: var(--ws); height: var(--ws); display: flex; align-items: center; justify-content: center; font-weight: 500; font-size: calc(var(--ws) * .52); color: var(--ink); border-radius: 8px; line-height: 1; }
.ws-cell.sel { background: var(--accent); color: #fff; }
.ws-cell.anchor { background: var(--accent-soft); color: var(--accent); outline: 2px solid var(--accent); outline-offset: -2px; }
.ws-cell.nope { background: var(--red); color: var(--red-ink); }
.ws-cell.hint { background: #fff1d6; outline: 2px solid #e0a100; outline-offset: -2px; animation: ws-pulse .8s infinite; }
.ws-cell.missed { background: var(--grey); color: var(--muted); }
/* Found words: six soft colours, so crossing words stay easy to tell apart */
.ws-cell.f0, .ws-w.f0 { background: #d9f5e3; color: #13693a; }
.ws-cell.f1, .ws-w.f1 { background: #e3efff; color: #0a4fb3; }
.ws-cell.f2, .ws-w.f2 { background: #fff1d6; color: #8a5a00; }
.ws-cell.f3, .ws-w.f3 { background: #fde4e1; color: #b3261e; }
.ws-cell.f4, .ws-w.f4 { background: #eadcff; color: #5b2fa8; }
.ws-cell.f5, .ws-w.f5 { background: #d8f3f3; color: #0b6b6b; }

.ws-msg { min-height: 22px; margin: 4px 0 8px; font-size: 14px; text-align: center; color: var(--muted); }
.ws-msg.good { color: var(--green-ink); font-weight: 500; }
.ws-msg.bad { color: var(--red-ink); font-weight: 500; }

/* The list of words to find, in groups */
.ws-words { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 16px; margin: 4px 0 16px; }
.ws-group h3 { margin: 0 0 6px; font-size: 12px; font-weight: 500; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.ws-group ul { margin: 0; padding: 0; list-style: none; display: flex; flex-wrap: wrap; gap: 6px; }
.ws-w { font-size: 13px; font-weight: 500; letter-spacing: .03em; padding: 4px 9px; border-radius: 999px; background: var(--card); border: 1px solid var(--border); color: var(--ink); }
.ws-w.found { border-color: transparent; text-decoration: line-through; text-decoration-thickness: 2px; }

.ws-game .actions { justify-content: center; }
.ws-game button { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
@keyframes ws-pulse { 50% { background: #ffe3a3; } }

.ws-rules { margin-top: 32px; border-top: 1px solid var(--border); color: var(--muted); font-size: 14px; line-height: 1.55; }
.ws-rules summary { cursor: pointer; padding: 14px 0; font-size: 15px; font-weight: 500; color: var(--ink); list-style: none; display: flex; justify-content: space-between; align-items: center; }
.ws-rules summary::-webkit-details-marker { display: none; }
.ws-rules summary::after { content: "+"; font-size: 20px; font-weight: 350; color: var(--muted); }
.ws-rules[open] summary::after { content: "−"; }
.ws-rules ul { margin: 0 0 8px; padding-left: 18px; }
.ws-rules li { margin-bottom: 4px; }

.ws-modal { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; padding: 20px; background: rgba(17, 24, 39, .55); animation: ws-fade .2s; }
.ws-modal[hidden] { display: none; }
.ws-modal-card { display: flex; flex-direction: column; width: 100%; max-width: 380px; text-align: center; background: var(--card); border-radius: 16px; padding: 28px 22px 22px; box-shadow: 0 20px 60px rgba(0, 0, 0, .25); }
.ws-modal-card h2 { font-size: 26px; font-weight: 500; line-height: 1.2; margin: 0 0 10px; color: var(--head); }
.ws-modal-card p { color: var(--muted); margin: 0 0 14px; }
.ws-modal-card .win-perfect { color: var(--head); background: var(--accent-soft); border-radius: 10px; padding: 8px 10px; font-weight: 500; }
.ws-modal-card button { display: block; width: 100%; margin: 8px 0 0; }
.ws-modal-card button:not(.primary):not(.ws-link) { border-color: var(--line2); color: var(--head); }
.ws-modal-card .share-note { order: 3; margin: 8px 0 0; font-size: 13px; }
.ws-modal-card .ws-link { order: 4; border: 0; background: none; color: var(--accent); text-decoration: none; font-size: 14px; }
@media (min-width: 641px) and (hover: hover){.ws-modal-card .ws-link:hover{ text-decoration: underline; }}
@keyframes ws-fade { from { opacity: 0; } to { opacity: 1; } }

/* Georgian has no capitals: text-transform would turn the letters into Mtavruli, so switch it off */
html:lang(ka) .ws-group h3 { text-transform: none; letter-spacing: 0; }

/* Look from the design: light-green cells, solid green for found words, flat list of word chips, filled + outline buttons */
.ws-grid { border-radius: 16px; padding: 12px; gap: 4px; margin-top: 4px; }
.ws-cell { background: var(--accent-soft); color: var(--head); font-weight: 350; border-radius: 8px; }
.ws-cell.f0, .ws-cell.f1, .ws-cell.f2, .ws-cell.f3, .ws-cell.f4, .ws-cell.f5 { background: var(--main); color: #fff; font-weight: 500; }
.ws-cell.sel { background: var(--accent); color: #fff; font-weight: 500; }
.ws-words { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; }
.ws-group, .ws-group ul { display: contents; }
.ws-group h3 { display: none; }
.ws-w, .ws-w.f0, .ws-w.f1, .ws-w.f2, .ws-w.f3, .ws-w.f4, .ws-w.f5 { font-size: 15px; font-weight: 350; letter-spacing: 0; padding: 6px 14px; border-radius: 14px; background: var(--card); border: 1px solid var(--line2); color: var(--head); }
.ws-w.found { background: var(--accent-soft); border-color: var(--border); color: #4f7f66; text-decoration: line-through; text-decoration-thickness: 1px; }
.ws-game .actions { gap: 10px; }
.ws-game .actions button { padding: 12px 28px; border-radius: 12px; font-size: 15px; font-weight: 400; border: 1px solid var(--line2); color: var(--head); background: var(--card); }
.ws-game .actions #wsHint { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 500; }
.ws-time { color: var(--ph); font-weight: 350; font-size: 13px; }

@media (min-width: 900px) {
  #wordsearch main.narrow { max-width: 1000px; }
  /* The 11 x 11 grid shrinks a little on short screens so the whole grid stays on one screen (about 275px above it is the menu and title) */
  .ws-game { --ws: clamp(24px, calc((100vh - 275px) / 11), 34px); display: grid; grid-template-columns: max-content minmax(0, 1fr); column-gap: 24px; row-gap: 16px; align-items: start; grid-template-rows: auto auto auto auto 1fr; }
  .ws-grid { grid-column: 1; grid-row: 1 / span 5; margin: 0; }
  .ws-game .meta { grid-column: 2; grid-row: 1; margin: 0; }
  .ws-msg { grid-column: 2; grid-row: 2; text-align: left; margin: 0; min-height: 0; }
  .ws-words { grid-column: 2; grid-row: 3; }
  .ws-game .actions { grid-column: 2; grid-row: 4; justify-content: flex-start; padding-top: 4px; }
}
@media (max-width: 640px) {
  .ws-game { --ws: calc((100vw - 60px) / var(--n, 14)); }
  .ws-grid { border-radius: 14px; padding: 6px; gap: 2px; margin: 12px -6px 8px; max-width: none; }
  .ws-cell { border-radius: 6px; font-size: calc(var(--ws) * .64); font-weight: 400; }
  .ws-w, .ws-w.f0, .ws-w.f1, .ws-w.f2, .ws-w.f3, .ws-w.f4, .ws-w.f5 { font-size: 13px; padding: 4px 11px; border-radius: 12px; }
  .ws-words { gap: 6px; margin-bottom: 20px; }
  .ws-game .actions { gap: 10px; }
  .ws-game .actions button { flex: 1 1 0; padding: 12px 8px; }
}
/* Phones: dragging on the letters marks words in every direction (up, down, sideways, diagonal), so the grid itself does not scroll the page. Scroll by touching anywhere outside the grid. Tapping the first and last letter still works. */
@media (pointer: coarse) { .ws-grid { touch-action: none; } }

/* a letter whose words are all found: greyed out and not selectable */
.ws-cell.locked { cursor: not-allowed; }
