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

/* Higher or lower: one screen, the header, the open card and the deck, the cards
   before, two big buttons. The cards are in cards.css. */
:root {
    --hl-bg: #f3f1ec;
    --hl-bg-glow: #fffdf8;
    --hl-panel: #ffffff;
    --hl-text: #2a2a33;
    --hl-muted: #77737f;
    --hl-accent: #259696;
    --hl-right: #24a36a;
    --hl-wrong: #e0534a;
}
:root[data-theme="dark"] {
    --hl-bg: #161a24;
    --hl-bg-glow: #232a3b;
    --hl-panel: #1f2533;
    --hl-text: #eceef4;
    --hl-muted: #8d93a5;
    --hl-accent: #4fd6d0;
    --hl-right: #4fd68f;
}

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

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

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

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


/* the stage: the open card left, the deck right (placed from higher.js) */
.hl-stage {
    position: relative;
    flex: 1 1 auto;
    min-height: 0;
    width: 100%;
}
.hl-stage .card { cursor: default; }
.hl-card .card-flip { transition: transform .42s ease-out; }
.hl-card { transition: transform .42s cubic-bezier(.3, .7, .4, 1); }
.hl-right .card-front { animation: hl-glow .7s ease-out; }
.hl-wrong .card-front { box-shadow: 0 0 0 calc(var(--cw) * .04) var(--hl-wrong), 0 6px 16px rgba(0, 0, 0, .25); }
@keyframes hl-glow {
    30% { box-shadow: 0 0 0 calc(var(--cw) * .05) var(--hl-right), 0 6px 16px rgba(0, 0, 0, .25); }
}
.hl-count {
    position: absolute;
    left: 0;
    top: 0;
    font-size: .8rem;
    font-weight: 700;
    color: var(--hl-muted);
    font-variant-numeric: tabular-nums;
}
.hl-pop {
    position: absolute;
    z-index: 50;
    font-size: 2.6rem;
    font-weight: 800;
    pointer-events: none;
    text-shadow: 0 2px 8px var(--hl-bg);
    animation: hl-pop .9s ease-out forwards;
}
.hl-pop-right { color: var(--hl-right); }
@keyframes hl-pop {
    0% { opacity: 0; transform: translate(-50%, -20%) scale(.7); }
    25% { opacity: 1; transform: translate(-50%, -50%) scale(1.1); }
    100% { opacity: 0; transform: translate(-50%, -140%) scale(1); }
}

/* the cards before: small, overlapping, the last one right */
.hl-trail {
    --cw: 2.4rem;
    display: flex;
    justify-content: center;
    align-items: flex-end;
    height: calc(var(--cw) * 1.4);
    width: 100%;
    padding: .25rem 0 .5rem;
}
.hl-trail .card {
    position: relative;
    flex: 0 0 auto;
    margin-left: calc(var(--cw) * -.25);
    cursor: default;
    animation: hl-in .3s ease-out;
}
.hl-trail .card:first-child { margin-left: 0; }
.hl-trail .card-middle { display: none; }
@keyframes hl-in { from { opacity: 0; transform: translateY(30%); } }

.hl-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; width: 100%; }
.hl-guess {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    height: 3.6rem;
    border: 0;
    border-radius: 1rem;
    color: #fff;
    font-size: 1.25rem;
    font-weight: 800;
    box-shadow: 0 4px 0 rgba(0, 0, 0, .18);
    cursor: pointer;
    transition: transform .08s, opacity .15s;
}
.hl-guess i { font-size: 1.5rem; }
.hl-guess:active { transform: translateY(2px); box-shadow: 0 2px 0 rgba(0, 0, 0, .18); }
.hl-guess:disabled { opacity: .55; cursor: default; }
.hl-guess-higher { background: linear-gradient(#3cbf8c, #24935a); }
.hl-guess-lower { background: linear-gradient(#ff8a6b, #e0534a); }
.hl-hint { margin: .5rem 0 .75rem; font-size: .8rem; color: var(--hl-muted); text-align: center; }

@media (prefers-reduced-motion: reduce) {
    .hl-card, .hl-card .card-flip { transition: none; }
    .hl-pop, .hl-trail .card, .hl-right .card-front { animation: none; }
    .hl-pop { opacity: 0; }
}
