/* Binary Puzzle (/binary-puzzle): only what is the game's own - the grid of 0s and 1s. 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 two digit colours are custom properties, so Save image and the
   pencil paint the same ones. */

.binary-puzzle-landing-app {
    --bp-zero: #0284c7;
    --bp-one: #d97706;
}

.binary-puzzle-board {
    display: grid;
    grid-template-columns: repeat(var(--bp-n, 8), 1fr);
    gap: clamp(2px, 0.5vw, 5px);
    width: min(100%, calc(100vh - 260px));
    min-width: min(100%, 260px);
    margin-inline: auto;
    padding: clamp(6px, 1.4vw, 14px);
    border-radius: 16px;
    background: var(--ak-panel);
    box-shadow: inset 0 0 0 1px var(--ak-border);
    box-sizing: border-box;
}

.bp-cell {
    aspect-ratio: 1 / 1;
    min-width: 0;
    padding: 0;
    border: 0;
    border-radius: 16%;
    background: var(--ak-field);
    box-shadow: inset 0 0 0 1px var(--ak-border);
    color: #ffffff;
    font: 600 clamp(11px, calc(32px - var(--bp-n, 8) * 1.2px), 26px) / 1 var(--ak-font, system-ui, sans-serif);
    cursor: pointer;
    transition: background 100ms ease, transform 80ms ease;
    -webkit-tap-highlight-color: transparent;
}

.bp-cell:hover {
    box-shadow: inset 0 0 0 2px var(--ak-accent);
}

/* Your digits: a lighter tint of the digit's colour. */
.bp-cell.is-zero {
    background: color-mix(in srgb, var(--bp-zero) 70%, #ffffff);
    box-shadow: none;
}

.bp-cell.is-one {
    background: color-mix(in srgb, var(--bp-one) 70%, #ffffff);
    box-shadow: none;
}

/* A given digit: the full colour, bolder, and it cannot be changed. */
.bp-cell.is-given {
    font-weight: 800;
    cursor: default;
}

.bp-cell.is-given.is-zero {
    background: var(--bp-zero);
}

.bp-cell.is-given.is-one {
    background: var(--bp-one);
}

.bp-cell:active:not(.is-given) {
    transform: scale(0.94);
}

.bp-cell:focus-visible {
    outline: 3px solid var(--ak-accent);
    outline-offset: 1px;
    position: relative;
    z-index: 1;
}

/* A rule broken: three equal digits (red ring), or a line with too many of one digit or a twin (soft red). */
.bp-cell.is-bad-line:not(.is-zero):not(.is-one) {
    background: color-mix(in srgb, var(--ak-danger) 14%, var(--ak-field));
}

.bp-cell.is-bad-line.is-zero,
.bp-cell.is-bad-line.is-one {
    box-shadow: inset 0 0 0 3px color-mix(in srgb, var(--ak-danger) 60%, transparent);
}

.bp-cell.is-bad {
    position: relative;
    z-index: 1;
    box-shadow: 0 0 0 3px var(--ak-danger), inset 0 0 0 2px #ffffff;
}

.bp-cell.is-hint {
    animation: bp-pulse 0.8s ease-in-out infinite alternate;
}

@keyframes bp-pulse {
    from { box-shadow: 0 0 0 2px var(--ak-info); }
    to { box-shadow: 0 0 0 5px var(--ak-info), 0 0 14px var(--ak-info); }
}

.binary-puzzle-board.is-solving {
    pointer-events: none;
}

.binary-puzzle-status.is-solved {
    color: var(--ak-success);
    font-weight: 600;
}

@media (prefers-reduced-motion: reduce) {
    .bp-cell.is-hint { animation: none; box-shadow: 0 0 0 4px var(--ak-info); }
}
