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

/* Solitaire: one screen, the header, the table and a bar with Undo. The cards are
   in cards.css; the table only places them (absolutely, from solitaire.js). */
:root {
    --sl-bg: #f3f1ec;
    --sl-bg-glow: #fffdf8;
    --sl-panel: #ffffff;
    --sl-text: #2a2a33;
    --sl-muted: #77737f;
    --sl-accent: #259696;
}
:root[data-theme="dark"] {
    --sl-bg: #161a24;
    --sl-bg-glow: #232a3b;
    --sl-panel: #1f2533;
    --sl-text: #eceef4;
    --sl-muted: #8d93a5;
    --sl-accent: #4fd6d0;
}

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

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

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

/* the table: as big as there is room; the cards are placed in it in px */
.sl-table {
    position: relative;
    flex: 1 1 auto;
    min-height: 0;
    width: 100%;
    touch-action: none;
}
.sl-slot { cursor: default; }
.sl-slot[data-pile="stock"] { cursor: pointer; }
.sl-slot[data-pile="stock"] i { font-size: calc(var(--cw, 60px) * .42); opacity: 0; transition: opacity .2s; }
.sl-slot.sl-redeal i { opacity: 1; color: var(--sl-accent); }

/* won: the kings on the foundations hop */
.sl-won .card[data-card$="13"] .card-flip { animation: sl-hop .6s ease-in-out 3 alternate; }
.sl-won .card[data-card^="H"][data-card$="13"] .card-flip { animation-delay: .1s; }
.sl-won .card[data-card^="D"][data-card$="13"] .card-flip { animation-delay: .2s; }
.sl-won .card[data-card^="C"][data-card$="13"] .card-flip { animation-delay: .3s; }
@keyframes sl-hop { to { transform: translateY(-18%) rotate(-4deg); } }

.sl-bar {
    display: flex;
    align-items: center;
    gap: .75rem;
    width: 100%;
    max-width: 34rem;
    padding: .5rem .25rem .75rem;
    box-sizing: border-box;
}
.sl-tool {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .4rem;
    flex: 0 0 auto;
    height: 2.6rem;
    padding: 0 1rem;
    border: 0;
    border-radius: .6rem;
    background: var(--sl-panel);
    color: var(--sl-text);
    font-size: .95rem;
    box-shadow: 0 1px 2px rgba(0, 0, 0, .12);
    cursor: pointer;
}
.sl-tool i { font-size: 1.15rem; }
.sl-tool:disabled { opacity: .4; cursor: default; }
.sl-hint { flex: 1 1 auto; margin: 0; font-size: .8rem; color: var(--sl-muted); text-align: right; }

.sl-over {
    position: fixed;
    inset: 0;
    z-index: 3000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, .45);
}
.sl-over[hidden] { display: none; }
.sl-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(--sl-panel);
    color: var(--sl-text);
}
.sl-over-box h2 { margin-top: 0; }
.sl-over-box p { margin: .25rem 0; }
.sl-over-best { color: #e0a100; font-weight: 700; }
.sl-over-mascot { width: 7.5rem; height: auto; }
.sl-over-buttons { grid-column: 1 / -1; display: flex; justify-content: center; gap: .75rem; }
@media (max-width: 24rem) {
    .sl-over-box { padding: 1.25rem; gap: .5rem .75rem; }
    .sl-over-mascot { width: 5.5rem; }
}

@media (prefers-reduced-motion: reduce) {
    .sl-won .card .card-flip { animation: none !important; }
}
