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

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

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

.py {
    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;
}

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

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

.py-slot[data-pile="waste"], .py-slot[data-pile="discard"] { border-style: solid; }
/* covered cards: darker and only their corner, so the free ones stand out */
.py-covered .card-front { filter: brightness(.92) saturate(.75); }
:root[data-theme="dark"] .py-covered .card-front { filter: brightness(.74) saturate(.8); }
.py-covered .card-middle { opacity: 0; }
.py-card .card-front { transition: filter .2s; }
.py-card .card-middle { transition: opacity .2s; }
.py-pass {
    position: absolute;
    left: 0;
    top: 0;
    text-align: center;
    font-size: .8rem;
    font-weight: 600;
    color: var(--py-muted);
    pointer-events: none;
}

/* won: the cards taken away hop */
.py-won .py-card .card-flip { animation: py-hop .5s ease-in-out 2 alternate; }
@keyframes py-hop { to { transform: translateY(-14%) rotate(-3deg); } }

.py-bar {
    display: flex;
    align-items: center;
    gap: .75rem;
    width: 100%;
    max-width: 34rem;
    padding: .5rem .25rem .75rem;
    box-sizing: border-box;
}
.py-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(--py-panel);
    color: var(--py-text);
    font-size: .95rem;
    box-shadow: 0 1px 2px rgba(0, 0, 0, .12);
    cursor: pointer;
}
.py-tool i { font-size: 1.15rem; }
.py-tool:disabled { opacity: .4; cursor: default; }
.py-hint { flex: 1 1 auto; margin: 0; font-size: .8rem; line-height: 1.25; color: var(--py-muted); text-align: right; }

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

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