/* 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 */

/* Letters: one screen; the slots of the words under the header, the letter wheel below. */
:root {
    --lt-bg: #f3f1ec;
    --lt-bg-glow: #fffdf8;
    --lt-panel: #ffffff;
    --lt-wheel: #fff6e6;
    --lt-wheel-line: #f1dfbf;
    --lt-text: #2a2a33;
    --lt-muted: #77737f;
    --lt-box: #ebe6db;
    --lt-box-got: #6cc27e;
    --lt-box-missed: #f6d3cf;
    --lt-missed-text: #b8323b;
    --lt-tile-top: #ffb457;
    --lt-tile: #f39c2b;
    --lt-tile-bottom: #d47218;
    --lt-used: #d9d3c7;
    --lt-good: #1f8a3b;
    --lt-bad: #c8323d;
    --lt-great: #e0a100;
    --lt-enter: #3fa7d6;
}
:root[data-theme="dark"] {
    --lt-bg: #161a24;
    --lt-bg-glow: #232a3b;
    --lt-panel: #1f2533;
    --lt-wheel: #252c3b;
    --lt-wheel-line: #0e1118;
    --lt-text: #eceef4;
    --lt-muted: #8d93a5;
    --lt-box: #2f3748;
    --lt-box-got: #3f9a57;
    --lt-box-missed: #4a2329;
    --lt-missed-text: #ff8a85;
    --lt-used: #3a4252;
    --lt-good: #63d47f;
    --lt-bad: #ff6f6a;
    --lt-great: #ffd23f;
    --lt-enter: #3593c0;
}

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

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

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

/* the slots of the words to find: a line per length */
.lt-targets {
    --lt-box-size: 1.15rem;
    flex: 1 1 0;
    min-height: 0;
    width: 100%;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: .35rem;
    padding: .25rem 0;
    box-sizing: border-box;
}
.lt-targets[data-count="many"] { --lt-box-size: 1rem; gap: .25rem; }
.lt-wait { margin: 0; text-align: center; color: var(--lt-muted); }
.lt-group { display: flex; flex-wrap: wrap; justify-content: center; gap: .3rem .5rem; }
.lt-slot { display: inline-flex; gap: 2px; }
.lt-box {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: var(--lt-box-size);
    height: calc(var(--lt-box-size) * 1.15);
    border-radius: 4px;
    background: var(--lt-box);
    font-size: calc(var(--lt-box-size) * .7);
    font-weight: 800;
    line-height: 1;
}
.lt-slot.lt-got .lt-box { background: var(--lt-box-got); color: #fff; }
.lt-slot.lt-missed .lt-box { background: var(--lt-box-missed); color: var(--lt-missed-text); }
.lt-slot.lt-pop { animation: lt-pop .35s ease-out; }
@keyframes lt-pop { 0% { transform: scale(1); } 40% { transform: scale(1.2); } 100% { transform: scale(1); } }

.lt-bonus {
    flex: 0 0 auto;
    max-width: 100%;
    margin: .15rem 0 0;
    font-size: .75rem;
    text-align: center;
    color: var(--lt-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.lt-bonus[hidden] { display: none; }
.lt-bonus-label { font-weight: 700; text-transform: uppercase; letter-spacing: .06em; font-size: .65rem; }

/* the word being made, the wheel and the buttons */
.lt-play { flex: 0 0 auto; display: flex; flex-direction: column; align-items: center; width: 100%; }
.lt-word-row { position: relative; display: flex; align-items: center; justify-content: center; width: 100%; height: 3rem; margin-top: .25rem; }
.lt-word {
    display: flex;
    gap: 3px;
    min-width: 6rem;
    height: 2.4rem;
    padding: 0 .5rem;
    align-items: center;
    justify-content: center;
    border-radius: 1.2rem;
    background: var(--lt-panel);
    box-shadow: 0 1px 3px rgba(0, 0, 0, .1);
}
.lt-word.lt-empty { opacity: .6; }
.lt-typed { font-size: 1.5rem; font-weight: 800; letter-spacing: .04em; animation: lt-in .12s ease-out; }
@keyframes lt-in { from { transform: translateY(4px); opacity: 0; } }
.lt-word.lt-shake { animation: lt-shake .3s; }
@keyframes lt-shake { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
.lt-clear {
    width: 2rem;
    height: 2rem;
    margin-left: .35rem;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--lt-muted);
    cursor: pointer;
}
.lt-word.lt-empty + .lt-clear { visibility: hidden; }
.lt-message {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -30%);
    padding: .4rem .9rem;
    border-radius: 1.2rem;
    background: var(--lt-panel);
    box-shadow: 0 2px 6px rgba(0, 0, 0, .15);
    font-size: .9rem;
    font-weight: 700;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s, transform .2s;
}
.lt-message.lt-show { opacity: 1; transform: translate(-50%, -50%); }
.lt-message.lt-good { color: var(--lt-good); }
.lt-message.lt-bad { color: var(--lt-bad); }
.lt-message.lt-great { color: var(--lt-great); }

.lt-wheel {
    position: relative;
    width: min(16rem, 72vw, 38dvh);
    aspect-ratio: 1;
    margin: .35rem 0;
    border-radius: 50%;
    background: var(--lt-wheel);
    box-shadow: inset 0 0 0 3px var(--lt-wheel-line), 0 3px 8px rgba(0, 0, 0, .08);
}
.lt-tile {
    position: absolute;
    width: 25%;
    height: 25%;
    transform: translate(-50%, -50%);
    padding: 0;
    border: 1px solid rgba(255, 255, 255, .5);
    border-radius: 50%;
    background: linear-gradient(180deg, var(--lt-tile-top), var(--lt-tile) 55%, var(--lt-tile-bottom));
    box-shadow: 0 3px 4px rgba(0, 0, 0, .25), inset 0 -3px 0 rgba(0, 0, 0, .12);
    color: #fff;
    text-shadow: 0 1px 1px rgba(0, 0, 0, .35);
    font-size: min(1.7rem, 9vw, 4.6dvh);
    font-weight: 800;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: transform .12s, background .15s, opacity .15s;
}
.lt-tile:active { transform: translate(-50%, -50%) scale(.92); }
.lt-tile.lt-used {
    background: var(--lt-used);
    box-shadow: none;
    color: rgba(255, 255, 255, .7);
    text-shadow: none;
    transform: translate(-50%, -50%) scale(.85);
    cursor: default;
}
.lt-shuffle {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 22%;
    height: 22%;
    transform: translate(-50%, -50%);
    border: 0;
    border-radius: 50%;
    background: var(--lt-panel);
    color: var(--lt-muted);
    font-size: 1.2rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, .15);
    cursor: pointer;
}
.lt-loading .lt-wheel, .lt-loading .lt-actions, .lt-loading .lt-word-row { visibility: hidden; }

.lt-actions { display: flex; gap: .5rem; justify-content: center; align-items: center; width: 100%; margin: .2rem 0 .75rem; }
.lt-action {
    height: 2.6rem;
    padding: 0 1rem;
    border: 0;
    border-radius: 1.3rem;
    background: var(--lt-panel);
    color: var(--lt-text);
    font-size: .95rem;
    font-weight: 700;
    box-shadow: 0 1px 3px rgba(0, 0, 0, .12);
    cursor: pointer;
}
.lt-giveup { font-size: .8rem; font-weight: 600; color: var(--lt-muted); }
.lt-delete { width: 3rem; padding: 0; font-size: 1.2rem; }
.lt-enter { min-width: 6rem; background: var(--lt-enter); color: #fff; }
.lt-done .lt-actions button, .lt-done .lt-shuffle, .lt-done .lt-tile { opacity: .5; pointer-events: none; }

/* the end: at the bottom, so the slots with the words stay in sight */
.lt-over {
    position: fixed;
    inset: 0;
    z-index: 20;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding-bottom: calc(1rem + env(safe-area-inset-bottom));
    background: linear-gradient(to bottom, transparent 30%, rgba(0, 0, 0, .45));
}
.lt-over[hidden] { display: none; }
.lt-over-box {
    display: grid;
    grid-template-columns: auto 1fr;
    align-items: center;
    gap: .25rem 1rem;
    margin: 0 1rem;
    padding: 1.25rem 1.5rem;
    border-radius: 1rem;
    background: var(--lt-panel);
    color: var(--lt-text);
    text-align: left;
    box-shadow: 0 8px 24px rgba(0, 0, 0, .3);
}
.lt-over-box h2 { margin-top: 0; margin-bottom: .25rem; }
.lt-over-box p { margin: 0 0 .25rem; }
.lt-over-best { color: #e0a100; font-weight: 700; }
.lt-over-mascot { width: 6.5rem; height: auto; }
.lt-over-buttons { grid-column: 1 / -1; display: flex; justify-content: center; gap: .75rem; margin-top: .25rem; }

@media (max-width: 22rem) {
    .lt-score-best { display: none; }
}
@media (min-width: 40rem) and (min-height: 44rem) {
    .lt-targets { --lt-box-size: 1.5rem; }
    .lt-targets[data-count="many"] { --lt-box-size: 1.3rem; }
}
