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

/* Flight: the header on top, the sky (a canvas) fills the rest, in a portrait shape;
   the hangar, the pause and the game over over it. */
:root {
    --fl-bg: #d9eefb;
    --fl-panel: #ffffff;
    --fl-text: #1f2a3a;
    --fl-muted: #5f6f84;
    --fl-hangar: #f3ede2;
    --fl-hangar-glow: #ffffff;
    --fl-card: #ffffff;
    --fl-card-line: #e3d8c4;
    --fl-ship: #2c3e57;
    --fl-ship-floor: #3d5576;
    --fl-accent: #ff9f1c;
    --fl-pip: #e7dfcf;
}
:root[data-theme="dark"] {
    --fl-bg: #0b1626;
    --fl-panel: #1f2a3a;
    --fl-text: #eceef4;
    --fl-muted: #93a0b2;
    --fl-hangar: #111a28;
    --fl-hangar-glow: #1d2a3e;
    --fl-card: #1f2a3a;
    --fl-card-line: #2f3d52;
    --fl-ship: #0d1522;
    --fl-ship-floor: #1b2a40;
    --fl-accent: #ffb03b;
    --fl-pip: #34445b;
}

body.flight-page {
    margin: 0;
    background: var(--fl-bg);
    color: var(--fl-text);
    overflow: hidden;
    overscroll-behavior: none;
    touch-action: none;
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
}

.fl {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    /* a portrait play area, also on a wide screen */
    max-width: min(34rem, 62vh);
    max-width: min(34rem, 62dvh);
    margin: 0 auto;
    padding: env(safe-area-inset-top) 0 0;
    box-sizing: border-box;
}

.fl-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .5rem;
    padding: .5rem .75rem;
    flex: 0 0 auto;
}
.fl-round {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    width: 2.5rem;
    height: 2.5rem;
    border: 0;
    border-radius: 50%;
    background: var(--fl-panel);
    color: var(--fl-text);
    font-size: 1.3rem;
    text-decoration: none;
    cursor: pointer;
}
.fl-scores { display: flex; flex: 1 1 auto; justify-content: space-evenly; gap: .5rem; min-width: 0; }
.fl-score { display: flex; flex-direction: column; align-items: center; min-width: 3.2rem; }
.fl-score > span:last-child { font-size: 1.45rem; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.2; white-space: nowrap; }
.fl-label { font-size: .68rem; letter-spacing: .08em; text-transform: uppercase; color: var(--fl-muted); white-space: nowrap; }
.fl-score-coins .fl-coin { margin-right: .25rem; vertical-align: -.05em; }
.fl-bump { animation: fl-bump .35s ease-out; }
@keyframes fl-bump { 40% { transform: scale(1.2); } }

/* a coin */
.fl-coin {
    display: inline-block;
    width: .85em;
    height: .85em;
    border-radius: 50%;
    background: radial-gradient(circle at 38% 35%, #fff3b0 0 22%, #ffd23f 45%, #e8a400 100%);
    box-shadow: inset 0 0 0 .09em #a86a00;
    flex: 0 0 auto;
}

.fl-stage {
    position: relative;
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
    touch-action: none;
    cursor: pointer;
}
@media (min-width: 34rem) {
    .fl-stage { border-radius: 1rem 1rem 0 0; }
}
.fl-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.fl-pilots { display: none; }

.fl-hint {
    position: absolute;
    left: 50%;
    bottom: calc(1rem + env(safe-area-inset-bottom));
    transform: translateX(-50%);
    width: max-content;
    max-width: calc(100% - 2rem);
    margin: 0;
    padding: .4rem .9rem;
    border-radius: 1rem;
    background: var(--fl-panel);
    color: var(--fl-text);
    font-size: .9rem;
    text-align: center;
    pointer-events: none;
    transition: opacity .6s;
}
.fl-hint.fl-gone { opacity: 0; }

/* "Wave 3", "Boss!": big in the middle for a moment */
.fl-banner {
    position: absolute;
    left: 50%;
    top: 30%;
    display: flex;
    flex-direction: column;
    align-items: center;
    width: max-content;
    max-width: calc(100% - 2rem);
    margin: 0;
    transform: translate(-50%, -50%);
    color: #fff;
    text-align: center;
    pointer-events: none;
    text-shadow: 0 2px 0 #1b3a6b, 0 0 12px rgba(10, 30, 60, .55);
}
.fl-banner[hidden] { display: none; }
.fl-banner > span { font-size: 2.2rem; font-weight: 900; letter-spacing: .02em; line-height: 1.1; }
.fl-banner > small { font-size: 1.05rem; font-weight: 800; color: #ffe066; }
.fl-banner > small:empty { display: none; }
.fl-banner-on { animation: fl-banner 1.8s ease-out forwards; }
@keyframes fl-banner {
    0% { opacity: 0; transform: translate(-50%, -50%) scale(.6); }
    12% { opacity: 1; transform: translate(-50%, -50%) scale(1.08); }
    20% { transform: translate(-50%, -50%) scale(1); }
    80% { opacity: 1; }
    100% { opacity: 0; transform: translate(-50%, -60%); }
}

/* "Shield!" over the plane */
.fl-pop {
    position: absolute;
    transform: translateX(-50%);
    white-space: nowrap;
    font-weight: 900;
    font-size: 1.25rem;
    color: #fff;
    -webkit-text-stroke: .35rem #2b1610;
    paint-order: stroke fill;
    pointer-events: none;
    animation: fl-pop 1.1s ease-out forwards;
}
.fl-pop-spread { color: #ffb347; }
.fl-pop-rapid { color: #ffe066; }
.fl-pop-shield { color: #7fe6ff; }
.fl-pop-magnet { color: #ff8a9a; }
.fl-pop-bomb { color: #c4b2ff; }
@keyframes fl-pop {
    0% { opacity: 0; translate: 0 .5rem; scale: .6; }
    15% { opacity: 1; translate: 0 0; scale: 1.15; }
    25% { scale: 1; }
    100% { opacity: 0; translate: 0 -3rem; }
}
@media (prefers-reduced-motion: reduce) {
    .fl-pop { animation: fl-fade 1.1s forwards; }
    .fl-banner-on { animation: fl-fade 1.8s forwards; }
    .fl-bump, .fl-up.fl-bought, .fl-up.fl-no { animation: none; }
    @keyframes fl-fade { 0%, 70% { opacity: 1; } 100% { opacity: 0; } }
}

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

/* the hangar */
.fl-hangar {
    align-items: stretch;
    background: radial-gradient(ellipse at 50% 0, var(--fl-hangar-glow), var(--fl-hangar) 70%);
    color: var(--fl-text);
}
.fl-hangar-box {
    display: flex;
    flex-direction: column;
    gap: .55rem;
    width: 100%;
    max-width: 30rem;
    height: 100%;
    margin: 0 auto;
    padding: calc(.65rem + env(safe-area-inset-top)) .75rem calc(.75rem + env(safe-area-inset-bottom));
    box-sizing: border-box;
    overflow-y: auto;
    justify-content: safe center;
}
.fl-hangar-top { display: flex; align-items: center; justify-content: space-between; gap: .75rem; flex: 0 0 auto; }
.fl-hangar-top h2 { margin: 0; font-size: 1.5rem; font-weight: 900; line-height: 1.1; }
.fl-hangar-top p { margin: 0; color: var(--fl-muted); font-size: .9rem; }
.fl-pill {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    padding: .35rem .8rem;
    border-radius: 2rem;
    background: var(--fl-card);
    box-shadow: inset 0 0 0 2px var(--fl-card-line);
    font-size: 1.3rem;
    font-variant-numeric: tabular-nums;
}
.fl-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

.fl-ship-box {
    flex: 1 1 7rem;
    min-height: 4.5rem;
    max-height: 14rem;
    border-radius: 1rem;
    background:
        repeating-linear-gradient(-45deg, rgba(255, 210, 63, .5) 0 10px, rgba(0, 0, 0, 0) 10px 20px) bottom / 100% 8px no-repeat,
        linear-gradient(var(--fl-ship) 0 55%, var(--fl-ship-floor) 55% 100%);
    overflow: hidden;
}
.fl-ship { display: block; width: 100%; height: 100%; }

.fl-ups { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; flex: 0 0 auto; }
.fl-up {
    position: relative;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    grid-template-areas: "icon name name" "text text text" "pips pips price";
    align-items: center;
    gap: .15rem .4rem;
    min-height: 3rem;
    padding: .45rem .55rem .5rem;
    border: 0;
    border-radius: .8rem;
    background: var(--fl-card);
    box-shadow: inset 0 0 0 2px var(--fl-card-line), 0 2px 0 var(--fl-card-line);
    color: var(--fl-text);
    font: inherit;
    text-align: left;
    white-space: normal;
    cursor: pointer;
    touch-action: manipulation;
}
.fl-up:active { transform: translateY(1px); box-shadow: inset 0 0 0 2px var(--fl-card-line); }
.fl-up:focus-visible { outline: 3px solid var(--fl-accent); outline-offset: 2px; }
.fl-up-icon {
    grid-area: icon;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.75rem;
    height: 1.75rem;
    border-radius: 50%;
    background: var(--fl-accent);
    color: #fff;
    font-size: .95rem;
}
.fl-up-name { grid-area: name; font-weight: 800; font-size: .95rem; line-height: 1.15; min-width: 0; overflow-wrap: anywhere; }
.fl-up-text { grid-area: text; min-width: 0; font-size: .72rem; line-height: 1.2; color: var(--fl-muted); overflow-wrap: anywhere; }
.fl-up-pips { grid-area: pips; display: flex; gap: .2rem; }
.fl-pip { display: block; flex: 0 1 1.1rem; height: .32rem; border-radius: .2rem; background: var(--fl-pip); }
.fl-pip.fl-on { background: var(--fl-accent); }
.fl-pip-heart { flex: 0 0 .6rem; height: .6rem; border-radius: 50%; }
.fl-pip-heart.fl-on { background: #ff4d6d; }
.fl-up-price {
    grid-area: price;
    display: inline-flex;
    align-items: center;
    gap: .2rem;
    padding: .1rem .45rem;
    border-radius: 1rem;
    background: #fff4cf;
    color: #6b4a00;
    font-weight: 800;
    font-size: .9rem;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
.fl-up.fl-cant .fl-up-price { background: var(--fl-pip); color: var(--fl-muted); }
.fl-up.fl-cant .fl-up-icon { filter: grayscale(.7); opacity: .7; }
.fl-up.fl-full .fl-up-price { background: #d9f5dc; color: #1d6b2c; }
.fl-up.fl-full .fl-up-price .fl-coin { display: none; }
.fl-up[data-up="repair"].fl-full .fl-up-price { visibility: hidden; }
.fl-up.fl-bought { animation: fl-bought .45s ease-out; }
.fl-up.fl-no { animation: fl-no .35s ease-out; }
@keyframes fl-bought { 35% { transform: scale(1.05); box-shadow: inset 0 0 0 3px var(--fl-accent); } }
@keyframes fl-no { 20% { transform: translateX(-5px); } 45% { transform: translateX(5px); } 70% { transform: translateX(-3px); } }
/* repair: the whole width, on one line */
.fl-up[data-up="repair"] {
    grid-column: 1 / -1;
    grid-template-columns: auto auto minmax(0, 1fr) auto auto;
    grid-template-areas: "icon name text pips price";
    gap: .5rem;
}
.fl-up[data-up="repair"] .fl-up-icon { background: #3fb36b; }
.fl-up[data-up="repair"] .fl-up-pips { justify-content: flex-end; }

.fl-note { margin: 0; min-height: 1.1rem; text-align: center; font-size: .85rem; font-weight: 700; color: #d6455a; flex: 0 0 auto; }
.fl-next { flex: 0 0 auto; width: 100%; min-height: 3rem; font-size: 1.15rem; font-weight: 800; }

@media (max-height: 600px) {
    .fl-up-text { display: none; }
    .fl-up { grid-template-areas: "icon name name" "pips pips price"; }
}
