/* begin license *
 *
 * Small browser games on swl and swindl
 *
 * All rights reserved.
 *
 * Copyright (C) 2026 moatley moatley@lost-monkeys.net
 *
 * This file is part of "Games"
 *
 * end license */

/* Word search: one screen, the theme and the grid under the header, the words below. */
:root {
    --ws-bg: #f3f1ec;
    --ws-bg-glow: #fffdf8;
    --ws-panel: #ffffff;
    --ws-grid: #fffaf0;
    --ws-grid-line: #e6dcc8;
    --ws-text: #2a2a33;
    --ws-letter: #3a3550;
    --ws-muted: #77737f;
    --ws-accent: #e8505b;
    --ws-select: #3fa7d6;
    --ws-band-opacity: .5;
    --ws-band-0: #ff8a5b;
    --ws-band-1: #ffc62e;
    --ws-band-2: #5cc777;
    --ws-band-3: #3fa7d6;
    --ws-band-4: #b18cff;
    --ws-band-5: #ff6fa8;
    --ws-band-6: #2fc9c0;
    --ws-band-7: #a4d23a;
}
:root[data-theme="dark"] {
    --ws-bg: #161a24;
    --ws-bg-glow: #232a3b;
    --ws-panel: #1f2533;
    --ws-grid: #252c3b;
    --ws-grid-line: #0e1118;
    --ws-text: #eceef4;
    --ws-letter: #e3e6f0;
    --ws-muted: #8d93a5;
    --ws-select: #6fc3ea;
    --ws-band-opacity: .55;
}

body.search-page {
    margin: 0;
    background: radial-gradient(ellipse at 50% 40%, var(--ws-bg-glow), var(--ws-bg) 70%) var(--ws-bg);
    min-height: 100vh;
    color: var(--ws-text);
    overscroll-behavior: none;
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
    touch-action: manipulation;
}

.ws {
    display: flex;
    flex-direction: column;
    align-items: center;
    height: 100vh;
    height: 100dvh;
    max-width: 34rem;
    margin: 0 auto;
    padding: env(safe-area-inset-top) .5rem env(safe-area-inset-bottom);
    box-sizing: border-box;
    overflow: hidden;
}

.ws-top {
    display: flex;
    align-items: center;
    gap: .5rem;
    width: 100%;
    padding: .75rem 0 .25rem;
}
.ws-back, .ws-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    flex: 0 0 auto;
    border: 0;
    border-radius: 50%;
    background: var(--ws-panel);
    color: var(--ws-text);
    font-size: 1.2rem;
    text-decoration: none;
    cursor: pointer;
}
.ws-scores { display: flex; justify-content: space-around; flex: 1 1 auto; min-width: 0; }
.ws-score { display: flex; flex-direction: column; align-items: center; min-width: 2.75rem; }
.ws-score > span:last-child { font-size: 1.4rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.ws-score-best > span:last-child { font-size: 1rem; line-height: 1.4rem; color: var(--ws-muted); }
.ws-label { font-size: .7rem; letter-spacing: .08em; text-transform: uppercase; color: var(--ws-muted); }
.ws-mascot {
    width: 3.2rem;
    height: 3.2rem;
    border-radius: 50%;
    overflow: hidden;
    background: var(--ws-panel);
    flex: 0 0 auto;
}

.ws-theme {
    flex: 0 0 auto;
    margin: .1rem 0 .3rem;
    font-size: 1.15rem;
    font-weight: 800;
    letter-spacing: .02em;
    color: var(--ws-text);
}
.ws-theme::before, .ws-theme::after { content: "✦"; margin: 0 .45rem; color: var(--ws-band-1); font-size: .8em; }
.ws-loading .ws-theme { color: var(--ws-muted); font-weight: 600; }
.ws-loading .ws-theme::before, .ws-loading .ws-theme::after { content: none; }

/* the grid: a square as big as the room under the header allows */
.ws-board {
    flex: 1 1 0;
    min-height: 0;
    width: 100%;
    container-type: size;
    display: flex;
    align-items: center;
    justify-content: center;
}
.ws-grid {
    display: block;
    width: min(100cqw, 100cqh);
    height: min(100cqw, 100cqh);
    touch-action: none;
    -webkit-tap-highlight-color: transparent;
    cursor: pointer;
    filter: drop-shadow(0 3px 6px rgba(0, 0, 0, .12));
}
.ws-loading .ws-grid { visibility: hidden; }
.ws-board.ws-miss .ws-grid { animation: ws-shake .3s; }
@keyframes ws-shake { 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }
.ws-panel { fill: var(--ws-grid); stroke: var(--ws-grid-line); stroke-width: .05; }
.ws-letter {
    font-size: .58px;
    font-weight: 800;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    fill: var(--ws-letter);
    pointer-events: none;
}
.ws-band, .ws-selection { stroke-width: .78; stroke-linecap: round; pointer-events: none; }
.ws-band { stroke-opacity: var(--ws-band-opacity); animation: ws-band-in .25s ease-out; }
@keyframes ws-band-in { from { stroke-width: .3; } }
.ws-selection { stroke: var(--ws-select); stroke-opacity: .35; }
.ws-band.ws-band-0 { stroke: var(--ws-band-0); }
.ws-band.ws-band-1 { stroke: var(--ws-band-1); }
.ws-band.ws-band-2 { stroke: var(--ws-band-2); }
.ws-band.ws-band-3 { stroke: var(--ws-band-3); }
.ws-band.ws-band-4 { stroke: var(--ws-band-4); }
.ws-band.ws-band-5 { stroke: var(--ws-band-5); }
.ws-band.ws-band-6 { stroke: var(--ws-band-6); }
.ws-band.ws-band-7 { stroke: var(--ws-band-7); }

/* the words to find */
.ws-words {
    flex: 0 0 auto;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: .25rem .35rem;
    margin: .5rem 0 0;
    padding: 0;
    list-style: none;
    max-width: 30rem;
}
.ws-word {
    --ws-chip: transparent;
    padding: .1rem .55rem;
    border-radius: 1rem;
    background: var(--ws-panel);
    box-shadow: inset 0 0 0 2px var(--ws-chip);
    font-size: .9rem;
    font-weight: 700;
    letter-spacing: .03em;
    text-transform: uppercase;
    color: var(--ws-text);
    transition: opacity .2s;
}
.ws-word.ws-found { text-decoration: line-through 2px; color: var(--ws-muted); }
.ws-word.ws-band-0 { --ws-chip: var(--ws-band-0); }
.ws-word.ws-band-1 { --ws-chip: var(--ws-band-1); }
.ws-word.ws-band-2 { --ws-chip: var(--ws-band-2); }
.ws-word.ws-band-3 { --ws-chip: var(--ws-band-3); }
.ws-word.ws-band-4 { --ws-chip: var(--ws-band-4); }
.ws-word.ws-band-5 { --ws-chip: var(--ws-band-5); }
.ws-word.ws-band-6 { --ws-chip: var(--ws-band-6); }
.ws-word.ws-band-7 { --ws-chip: var(--ws-band-7); }
.ws-words[data-count="12"] .ws-word { font-size: .8rem; padding: .05rem .45rem; }

.ws-hint { flex: 0 0 auto; margin: .35rem 0 .6rem; font-size: .8rem; text-align: center; color: var(--ws-muted); }

.ws-over {
    position: fixed;
    inset: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, .45);
}
.ws-over[hidden] { display: none; }
.ws-over-box {
    display: grid;
    grid-template-columns: auto 1fr;
    align-items: center;
    gap: .5rem 1rem;
    margin: 0 1rem;
    padding: 1.5rem 2rem;
    border-radius: 1rem;
    background: var(--ws-panel);
    color: var(--ws-text);
    text-align: left;
}
.ws-over-box h2 { margin-top: 0; }
.ws-over-best { color: #e0a100; font-weight: 700; }
.ws-over-mascot { width: 7.5rem; height: auto; }
.ws-over-buttons { grid-column: 1 / -1; display: flex; justify-content: center; gap: .75rem; }

@media (max-width: 22rem) {
    .ws-score-best { display: none; }
}
@media (max-height: 36rem) {
    .ws-hint { display: none; }
}
@media (max-height: 34rem) {
    .ws-theme { font-size: 1rem; margin: 0 0 .15rem; }
}
