/* Nurikabe (/nurikabe): only what is the game's own - the grid of cells, the ocean-blue wall, the sand of the islands
   and the numbers. 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 board's colours are
   custom properties, so Save image and the pencil paint the same ones. */

.nurikabe-landing-app {
    --nk-wall: #1f6fae;
    --nk-sand: #f4e7c5;
    --nk-ink: #3b2a12;
    --nk-dot: #a07a3c;
    --nk-grid: #9aa9bd;
    --nk-empty: #ffffff;
}

.nurikabe-landing-app[data-theme="dark"] {
    --nk-wall: #2f7fc1;
    --nk-sand: #d9c69a;
    --nk-ink: #2a1d0b;
    --nk-dot: #7a5a26;
    --nk-grid: #475569;
    --nk-empty: #1e293b;
}

.nurikabe-board {
    display: grid;
    grid-template-columns: repeat(var(--nk-n, 7), 1fr);
    gap: 2px;
    width: min(100%, calc(100vh - 300px));
    min-width: min(100%, 260px);
    margin-inline: auto;
    padding: 2px;
    border-radius: 8px;
    background: var(--nk-grid);
    box-sizing: border-box;
    /* Dragging paints cells, so the board does not scroll the page under a finger. */
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
}

.nurikabe-board.is-making {
    opacity: 0.55;
}

.nk-cell {
    position: relative;
    aspect-ratio: 1 / 1;
    min-width: 0;
    padding: 0;
    border: 0;
    border-radius: 3px;
    background: var(--nk-empty);
    color: var(--nk-ink);
    font: 700 clamp(12px, calc(46px - var(--nk-n, 7) * 2.6px), 32px) / 1 var(--ak-font, system-ui, sans-serif);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: background-color 0.12s ease;
}

.nk-cell:hover {
    background: color-mix(in srgb, var(--nk-wall) 18%, var(--nk-empty));
}

.nk-cell.is-clue {
    background: var(--nk-sand);
    cursor: default;
}

.nk-cell.is-wall {
    background: var(--nk-wall);
}

.nk-cell.is-dot {
    background: var(--nk-sand);
}

/* A dot: a cell marked as island. */
.nk-cell.is-dot::after {
    content: "";
    position: absolute;
    inset: 39%;
    border-radius: 50%;
    background: var(--nk-dot);
}

/* Solved: every cell that is not wall is island sand. */
.nurikabe-board.is-solved .nk-cell:not(.is-wall) {
    background: var(--nk-sand);
}

.nk-cell.is-selected {
    box-shadow: inset 0 0 0 3px var(--ak-accent);
    outline: none;
}

.nk-cell:focus-visible {
    outline: 3px solid var(--ak-accent);
    outline-offset: -3px;
}

/* A broken rule: a red frame (and red numbers), never a hint at the solution. */
.nk-cell.is-bad {
    box-shadow: inset 0 0 0 3px var(--ak-danger);
}

.nk-cell.is-clue.is-bad {
    color: var(--ak-danger);
}

.nk-cell.is-wall.is-bad {
    background: color-mix(in srgb, var(--ak-danger) 45%, var(--nk-wall));
}

.nk-cell.is-hint {
    animation: nk-pulse 0.8s ease-in-out infinite alternate;
}

@keyframes nk-pulse {
    from { box-shadow: inset 0 0 0 2px var(--ak-info); }
    to { box-shadow: inset 0 0 0 5px var(--ak-info); }
}

.nurikabe-board.is-solving {
    pointer-events: none;
}

.nurikabe-status.is-solved {
    color: var(--ak-success);
    font-weight: 600;
}

@media (prefers-reduced-motion: reduce) {
    .nk-cell { transition: none; }
    .nk-cell.is-hint { animation: none; box-shadow: inset 0 0 0 4px var(--ak-info); }
}
