/* Bingo (/bingo): only what is the game's own - the caller with its balls, the BINGO! button, the cards with their
   daubs, the board of called numbers and the computers' small cards. Tiles, panels, buttons, the games accent and the
   colours come from the app kit (css/app-kit, css/app-kit/games.css, docs/app-kit.md). Loaded only on this page. */

/* The shared app layout gives the stage a fixed height with overflow hidden: the stage scrolls on its own. */
body .filter-landing-app.bingo-landing-app > .filter-landing-stage.ak-stage {
    justify-content: flex-start;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    overscroll-behavior: contain;
}

.bingo-landing-app > .filter-landing-stage.ak-stage > * {
    flex-shrink: 0;
    align-self: stretch;
    min-width: 0;
    max-width: 100%;
}

/* The column colours of the balls and the card heads: B blue, I red, N white, G green, O yellow. */
.bingo-landing-app {
    --bingo-b: #2563eb;
    --bingo-i: #dc2626;
    --bingo-n: #f8fafc;
    --bingo-g: #16a34a;
    --bingo-o: #f59e0b;
    --bingo-daub: rgba(225, 29, 72, 0.78);
}

.bingo-landing-app .bingo-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.9rem;
}

/* --- The caller ---------------------------------------------------------------------------------------------------- */

.bingo-landing-app .bingo-caller {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    gap: 1rem;
    width: 100%;
    max-width: 44rem;
}

.bingo-landing-app .bingo-ball {
    --ball: var(--ak-border);
    --ball-text: #1f2937;
    position: relative;
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 30%, rgba(255, 255, 255, 0.9) 0, rgba(255, 255, 255, 0) 38%), var(--ball);
    box-shadow: inset 0 -0.35em 0.6em rgba(0, 0, 0, 0.22), 0 0.15em 0.4em rgba(0, 0, 0, 0.2);
    color: var(--ball-text);
    font-weight: 800;
    line-height: 1;
}

/* The white disc in the middle of every ball, where the number is printed. */
.bingo-landing-app .bingo-ball::before {
    content: "";
    position: absolute;
    inset: 20%;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.06);
}

.bingo-landing-app .bingo-ball > * {
    position: relative;
}

.bingo-landing-app .bingo-ball[data-col="0"] { --ball: var(--bingo-b); }
.bingo-landing-app .bingo-ball[data-col="1"] { --ball: var(--bingo-i); }
.bingo-landing-app .bingo-ball[data-col="2"] { --ball: var(--bingo-n); }
.bingo-landing-app .bingo-ball[data-col="3"] { --ball: var(--bingo-g); }
.bingo-landing-app .bingo-ball[data-col="4"] { --ball: var(--bingo-o); }

.bingo-landing-app .bingo-ball--big {
    width: clamp(6.5rem, 26vw, 9rem);
    aspect-ratio: 1 / 1;
    font-size: clamp(1.9rem, 8vw, 2.9rem);
}

.bingo-landing-app .bingo-ball-letter {
    font-size: 0.42em;
    letter-spacing: 0.04em;
    opacity: 0.75;
}

.bingo-landing-app .bingo-ball--big.is-rolling {
    animation: bingo-roll 0.55s cubic-bezier(0.2, 0.8, 0.3, 1.2);
}

@keyframes bingo-roll {
    0% { transform: translateX(-60%) rotate(-200deg) scale(0.6); opacity: 0; }
    100% { transform: none; opacity: 1; }
}

.bingo-landing-app .bingo-caller-side {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    min-width: 0;
}

.bingo-landing-app .bingo-recent {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    min-height: 2.2rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

.bingo-landing-app .bingo-ball--small {
    width: 2.2rem;
    height: 2.2rem;
    font-size: 0.8rem;
}

.bingo-landing-app .bingo-status {
    min-height: 1.3em;
    margin: 0;
    color: var(--ak-muted);
    font-size: var(--ak-fs-md);
    font-weight: 600;
}

.bingo-landing-app .bingo-status[data-outcome="win"] { color: var(--ak-success); font-weight: 800; }
.bingo-landing-app .bingo-status[data-outcome="lose"] { color: var(--ak-danger); font-weight: 800; }
.bingo-landing-app .bingo-status[data-outcome="warn"] { color: var(--ak-warning); }

/* BINGO!: the big call button, in the games accent. */
.bingo-landing-app .bingo-call {
    align-self: flex-start;
    min-width: 11rem;
    padding: 0.6rem 1.4rem;
    border: 0;
    border-radius: 999px;
    background: var(--ak-accent);
    box-shadow: 0 0.25rem 0 color-mix(in srgb, var(--ak-accent) 60%, #000);
    color: var(--ak-on-accent);
    font: inherit;
    font-size: var(--ak-fs-xl);
    font-weight: 900;
    letter-spacing: 0.06em;
    cursor: pointer;
    transition: transform 0.1s, box-shadow 0.1s, opacity 0.15s;
}

.bingo-landing-app .bingo-call:hover:not(:disabled) { transform: translateY(-1px); }

.bingo-landing-app .bingo-call:active:not(:disabled) {
    transform: translateY(0.2rem);
    box-shadow: 0 0.05rem 0 color-mix(in srgb, var(--ak-accent) 60%, #000);
}

.bingo-landing-app .bingo-call:focus-visible {
    outline: 3px solid var(--ak-text);
    outline-offset: 3px;
}

.bingo-landing-app .bingo-call:disabled {
    cursor: default;
    opacity: 0.45;
}

.bingo-landing-app .bingo-call.is-won {
    background: var(--ak-success);
    box-shadow: 0 0.25rem 0 color-mix(in srgb, var(--ak-success) 60%, #000);
    opacity: 1;
}

/* --- Your cards ---------------------------------------------------------------------------------------------------- */

.bingo-landing-app .bingo-cards {
    display: grid;
    grid-template-columns: minmax(0, 22rem);
    justify-content: center;
    gap: 1rem;
    width: 100%;
}

.bingo-landing-app .bingo-cards[data-count="2"] {
    grid-template-columns: repeat(2, minmax(0, 20rem));
}

@media (max-width: 640px) {
    .bingo-landing-app .bingo-cards[data-count="2"] {
        grid-template-columns: minmax(0, 22rem);
    }

    .bingo-landing-app .bingo-caller {
        gap: 0.7rem;
    }

    .bingo-landing-app .bingo-call {
        min-width: 0;
        width: 100%;
    }
}

.bingo-landing-app .bingo-card {
    padding: 0.5rem;
    border: 2px solid var(--ak-border);
    border-radius: var(--ak-radius-lg);
    background: var(--ak-field);
}

.bingo-landing-app .bingo-card-head,
.bingo-landing-app .bingo-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 0.3rem;
}

.bingo-landing-app .bingo-card-head {
    margin-bottom: 0.3rem;
}

.bingo-landing-app .bingo-letter {
    padding: 0.2rem 0;
    border-radius: 0.4rem;
    color: #fff;
    font-size: var(--ak-fs-lg);
    font-weight: 900;
    text-align: center;
}

.bingo-landing-app .bingo-letter[data-col="0"] { background: var(--bingo-b); }
.bingo-landing-app .bingo-letter[data-col="1"] { background: var(--bingo-i); }
.bingo-landing-app .bingo-letter[data-col="2"] { background: #64748b; }
.bingo-landing-app .bingo-letter[data-col="3"] { background: var(--bingo-g); }
.bingo-landing-app .bingo-letter[data-col="4"] { background: #d97706; }

.bingo-landing-app .bingo-cell {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    aspect-ratio: 1 / 1;
    min-width: 0;
    padding: 0;
    border: 1px solid var(--ak-border);
    border-radius: 0.45rem;
    background: var(--ak-panel);
    color: var(--ak-text);
    font: inherit;
    font-size: clamp(0.95rem, 4.2vw, 1.3rem);
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.bingo-landing-app button.bingo-cell {
    cursor: pointer;
    transition: transform 0.08s, border-color 0.15s;
}

.bingo-landing-app button.bingo-cell:hover:not(:disabled) {
    border-color: var(--ak-accent);
}

.bingo-landing-app button.bingo-cell:active:not(:disabled) {
    transform: scale(0.94);
}

.bingo-landing-app button.bingo-cell:focus-visible {
    z-index: 1;
    outline: 3px solid var(--ak-accent);
    outline-offset: 1px;
}

.bingo-landing-app .bingo-cell--free {
    color: var(--ak-muted);
    font-size: clamp(0.6rem, 2.6vw, 0.8rem);
    text-transform: uppercase;
}

button.bingo-cell--free:disabled {
    cursor: default;
}

/* A daub: a round, translucent dot of ink over the number. */
.bingo-landing-app .bingo-cell.is-marked::before {
    content: "";
    position: absolute;
    inset: 12%;
    border-radius: 50%;
    background: var(--bingo-daub);
    animation: bingo-daub 0.18s ease-out;
}

.bingo-landing-app .bingo-cell.is-marked {
    color: #fff;
}

.bingo-landing-app .bingo-cell.is-marked {
    text-shadow: 0 1px 1px rgba(0, 0, 0, 0.35);
}

.bingo-landing-app .bingo-cell {
    isolation: isolate;
}

.bingo-landing-app .bingo-cell::before {
    z-index: -1;
}

@keyframes bingo-daub {
    from { transform: scale(0.3); opacity: 0.4; }
    to { transform: scale(1); opacity: 1; }
}

/* The winning line. */
.bingo-landing-app .bingo-cell.is-win {
    border-color: var(--ak-success);
    box-shadow: 0 0 0 2px var(--ak-success);
}

.bingo-landing-app .bingo-cell.is-win::before {
    background: var(--ak-success);
}

/* A number that has not been called yet: a short shake. */
.bingo-landing-app .bingo-cell.is-shaking {
    animation: bingo-shake 0.3s ease-in-out;
}

@keyframes bingo-shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-4px); }
    75% { transform: translateX(4px); }
}

/* --- The called numbers -------------------------------------------------------------------------------------------- */

.bingo-landing-app .bingo-board {
    display: grid;
    gap: 0.2rem;
    width: 100%;
    max-width: 44rem;
}

.bingo-landing-app .bingo-board-row {
    display: grid;
    grid-template-columns: repeat(16, minmax(0, 1fr));
    gap: 0.2rem;
}

.bingo-landing-app .bingo-board-letter,
.bingo-landing-app .bingo-board-cell {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 0;
    height: clamp(1.25rem, 4.5vw, 1.7rem);
    border-radius: 0.3rem;
    font-size: clamp(0.55rem, 2.3vw, 0.8rem);
    font-variant-numeric: tabular-nums;
}

.bingo-landing-app .bingo-board-letter {
    color: #fff;
    font-weight: 900;
}

.bingo-landing-app .bingo-board-row[data-col="0"] { --col: var(--bingo-b); }
.bingo-landing-app .bingo-board-row[data-col="1"] { --col: var(--bingo-i); }
.bingo-landing-app .bingo-board-row[data-col="2"] { --col: #64748b; }
.bingo-landing-app .bingo-board-row[data-col="3"] { --col: var(--bingo-g); }
.bingo-landing-app .bingo-board-row[data-col="4"] { --col: #d97706; }

.bingo-landing-app .bingo-board-letter {
    background: var(--col);
}

.bingo-landing-app .bingo-board-cell {
    background: var(--ak-field);
    color: var(--ak-muted);
    opacity: 0.75;
}

.bingo-landing-app .bingo-board-cell.is-called {
    background: color-mix(in srgb, var(--col) 22%, var(--ak-panel));
    color: var(--ak-text);
    font-weight: 800;
    opacity: 1;
}

.bingo-landing-app .bingo-board-cell.is-last {
    background: var(--col);
    color: #fff;
}

/* --- The computers' cards ------------------------------------------------------------------------------------------ */

.bingo-landing-app .bingo-cpus {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.75rem;
    width: 100%;
}

.bingo-landing-app .bingo-cpu {
    width: min(9.5rem, calc(50% - 0.4rem));
    margin: 0;
    padding: 0.4rem;
    border: 2px solid var(--ak-border);
    border-radius: var(--ak-radius);
    background: var(--ak-field);
}

.bingo-landing-app .bingo-cpu.is-winner {
    border-color: var(--ak-danger);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--ak-danger) 22%, transparent);
}

.bingo-landing-app .bingo-cpu-name {
    display: flex;
    justify-content: space-between;
    gap: 0.3rem;
    margin-bottom: 0.3rem;
    color: var(--ak-muted);
    font-size: var(--ak-fs-xs);
    font-weight: 700;
}

.bingo-landing-app .bingo-grid--mini {
    gap: 0.15rem;
}

.bingo-landing-app .bingo-grid--mini .bingo-cell {
    border-radius: 0.2rem;
    font-size: 0.62rem;
    font-weight: 600;
}

.bingo-landing-app .bingo-grid--mini .bingo-cell.is-win {
    border-color: var(--ak-danger);
    box-shadow: none;
}

.bingo-landing-app .bingo-grid--mini .bingo-cell.is-win::before {
    background: var(--ak-danger);
}

/* --- Wide screens ------------------------------------------------------------------------------------------------- */

/* On a wide stage everything fits side by side instead of in one long column: the caller, the board of called numbers
   and the computers on the left, your cards beside them on the right. It follows the stage's width, not the window's,
   so it also applies when the controls are hidden. Phones keep the single column above. */
.bingo-landing-app > .filter-landing-stage.bingo-stage {
    container: bingo-stage / inline-size;
}

@container bingo-stage (min-width: 820px) {
    /* The panel fills the stage, with the game in the middle of it. */
    .bingo-landing-app .bingo-panel {
        flex: 1 0 auto;
        display: grid;
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
        grid-template-rows: auto auto auto;
        grid-template-areas:
            "caller cards"
            "board  cards"
            "cpus   cards";
        align-content: center;
        align-items: start;
        column-gap: clamp(1.25rem, 3cqi, 2.5rem);
        row-gap: 1rem;
    }

    /* Two cards of your own need more room: the right column grows, and the computers get a row of their own under
       everything (the two cards are less tall than one). */
    .bingo-landing-app .bingo-panel:has(.bingo-cards[data-count="2"]) {
        grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr);
        grid-template-areas:
            "caller cards"
            "board  cards"
            "cpus   cpus";
    }

    .bingo-landing-app .bingo-caller {
        grid-area: caller;
        max-width: none;
    }

    .bingo-landing-app .bingo-board {
        grid-area: board;
        max-width: none;
    }

    .bingo-landing-app .bingo-cpus {
        grid-area: cpus;
        gap: 0.6rem;
    }

    /* Three in a row while their names fit on one line, else two. */
    .bingo-landing-app .bingo-cpu {
        width: clamp(8.75rem, calc((100% - 1.2rem) / 3), 10.5rem);
    }

    .bingo-landing-app .bingo-cpu-name > * {
        white-space: nowrap;
    }

    /* A card about as tall as it is wide: as big as the column and the height of the screen allow. */
    .bingo-landing-app .bingo-cards {
        grid-area: cards;
        align-self: center;
        grid-template-columns: minmax(0, min(36rem, calc(100vh - 16rem)));
    }

    .bingo-landing-app .bingo-cards[data-count="2"] {
        grid-template-columns: repeat(2, minmax(0, min(28rem, calc(100vh - 16rem))));
    }

    .bingo-landing-app .bingo-cards .bingo-cell:not(.bingo-cell--free) {
        font-size: clamp(1.1rem, 2.4cqi, 1.9rem);
    }

    .bingo-landing-app .bingo-ball--big {
        width: clamp(6.5rem, 12cqi, 9rem);
    }

    .bingo-landing-app .bingo-board-letter,
    .bingo-landing-app .bingo-board-cell {
        height: clamp(1.3rem, 2.6cqi, 1.9rem);
        font-size: clamp(0.62rem, 1.2cqi, 0.85rem);
    }
}

@media (prefers-reduced-motion: reduce) {
    .bingo-landing-app .bingo-ball--big.is-rolling,
    .bingo-landing-app .bingo-cell.is-marked::before,
    .bingo-landing-app .bingo-cell.is-shaking {
        animation: none;
    }
}
