/* Color by Numbers (/color-by-numbers): only what is the game's own - the canvas board, the row of numbered
   swatches and the little celebration when a picture is done. Tiles, buttons, fields and the accent come from the
   app kit (css/app-kit, docs/app-kit.md), the button row from css/app-kit/games.css (every game). Loaded only on
   this page (StylePaths). */

/* The shared app layout gives the stage a fixed height with overflow hidden: the stage scrolls on its own. */
body .filter-landing-app.color-by-numbers-landing-app > .filter-landing-stage.ak-stage {
    justify-content: flex-start;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    overscroll-behavior: contain;
}

.color-by-numbers-landing-app > .filter-landing-stage.ak-stage > * {
    flex-shrink: 0;
    align-self: stretch;
    min-width: 0;
    max-width: 100%;
}

.color-by-numbers-landing-app .cbn-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
}

/* --- The board ------------------------------------------------------------------------------------------------------ */

.color-by-numbers-landing-app .cbn-board-wrap {
    display: flex;
    justify-content: center;
    width: 100%;
}

.color-by-numbers-landing-app .cbn-board {
    display: block;
    max-width: 100%;
    border-radius: 6px;
    cursor: crosshair;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.color-by-numbers-landing-app .cbn-board:focus-visible {
    outline: 3px solid var(--ak-accent);
    outline-offset: 4px;
}

/* A finished picture: a short pop and a warm glow. */
.color-by-numbers-landing-app .cbn-panel.is-complete .cbn-board {
    cursor: default;
    animation: cbn-done 0.9s ease-out;
    filter: drop-shadow(0 0 18px color-mix(in srgb, var(--ak-accent) 45%, transparent));
}

@keyframes cbn-done {
    0% { transform: scale(1); }
    30% { transform: scale(1.05) rotate(-1deg); }
    60% { transform: scale(0.98) rotate(0.6deg); }
    100% { transform: scale(1); }
}

@media (prefers-reduced-motion: reduce) {
    .color-by-numbers-landing-app .cbn-panel.is-complete .cbn-board {
        animation: none;
    }
}

/* --- The palette: numbered swatches ---------------------------------------------------------------------------- */

.color-by-numbers-landing-app .cbn-palette {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.45rem;
    width: 100%;
    max-width: 40rem;
}

.color-by-numbers-landing-app .cbn-swatch {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.75rem;
    height: 2.75rem;
    padding: 0;
    border: 2px solid var(--ak-border);
    border-radius: 50%;
    background: var(--cbn-swatch, #ccc);
    color: var(--cbn-ink, #fff);
    font: 800 var(--ak-fs-md) / 1 var(--ak-font, system-ui, sans-serif);
    cursor: pointer;
    box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.18);
    transition: transform 0.12s, box-shadow 0.12s, border-color 0.12s;
}

.color-by-numbers-landing-app .cbn-swatch:hover {
    transform: translateY(-2px);
}

.color-by-numbers-landing-app .cbn-swatch[aria-pressed="true"] {
    border-color: var(--ak-text);
    box-shadow: 0 0 0 3px var(--ak-accent), inset 0 -3px 0 rgba(0, 0, 0, 0.18);
    transform: scale(1.08);
}

.color-by-numbers-landing-app .cbn-swatch:focus-visible {
    outline: 3px solid var(--ak-accent);
    outline-offset: 3px;
}

/* A colour with every square painted: its number gives way to a tick. */
.color-by-numbers-landing-app .cbn-swatch.is-done .cbn-swatch-num {
    opacity: 0;
}

.color-by-numbers-landing-app .cbn-swatch.is-done::after {
    content: "";
    position: absolute;
    inset: 0;
    background: var(--cbn-ink, #fff);
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5' fill='none' stroke='black' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 60% no-repeat;
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5' fill='none' stroke='black' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 60% no-repeat;
}

.color-by-numbers-landing-app .cbn-status {
    min-height: 1.4em;
    margin: 0;
    text-align: center;
    font-weight: 600;
}

.color-by-numbers-landing-app .cbn-status.is-done {
    color: var(--ak-success);
    font-size: var(--ak-fs-lg);
}

@media (max-width: 480px) {
    .color-by-numbers-landing-app .cbn-swatch {
        width: 2.4rem;
        height: 2.4rem;
    }
}
