/* Kakuro (/kakuro): only what is the game's own - the grid of clue cells and white cells, and the number pad. 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 clue cells' colours are custom
   properties, so Save image and the pencil paint the same ones. */

.kakuro-landing-app {
    --kk-block: #334155;
    --kk-clue: #ffffff;
}

.kakuro-landing-app[data-theme="dark"] {
    --kk-block: #0b1220;
    --kk-clue: #e2e8f0;
}

.kakuro-board {
    display: grid;
    grid-template-columns: repeat(var(--kk-n, 8), 1fr);
    gap: 2px;
    width: min(100%, calc(100vh - 330px));
    min-width: min(100%, 260px);
    margin-inline: auto;
    padding: 2px;
    border-radius: 8px;
    background: var(--kk-block);
    box-sizing: border-box;
}

.kakuro-board.is-making {
    opacity: 0.55;
}

.kk-block,
.kk-cell {
    position: relative;
    aspect-ratio: 1 / 1;
    min-width: 0;
    border-radius: 3px;
}

.kk-block {
    background: var(--kk-block);
}

/* A clue cell: a diagonal, the across sum top right and the down sum bottom left. */
.kk-block.has-clue {
    background: linear-gradient(to bottom left, transparent calc(50% - 1px), rgba(255, 255, 255, 0.4) 50%, transparent calc(50% + 1px)) var(--kk-block);
}

.kk-clue {
    position: absolute;
    color: var(--kk-clue);
    font: 700 clamp(8px, calc(22px - var(--kk-n, 8) * 0.9px), 17px) / 1 var(--ak-font, system-ui, sans-serif);
}

.kk-clue--across {
    top: 10%;
    right: 9%;
}

.kk-clue--down {
    bottom: 10%;
    left: 9%;
}

.kk-clue.is-bad {
    color: #fca5a5;
    text-decoration: underline wavy;
}

.kk-cell {
    padding: 0;
    border: 0;
    background: var(--ak-field);
    color: var(--ak-text);
    font: 600 clamp(12px, calc(40px - var(--kk-n, 8) * 1.8px), 30px) / 1 var(--ak-font, system-ui, sans-serif);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.kk-cell:hover {
    background: var(--ak-hover);
}

/* The cells of the chosen cell's two runs, and the chosen cell itself. */
.kk-cell.is-run {
    background: color-mix(in srgb, var(--ak-accent) 12%, var(--ak-field));
}

.kk-cell.is-selected {
    background: color-mix(in srgb, var(--ak-accent) 30%, var(--ak-field));
    outline: none;
}

.kk-cell:focus-visible {
    outline: 3px solid var(--ak-accent);
    outline-offset: -3px;
}

.kk-cell.is-bad {
    color: var(--ak-danger);
    box-shadow: inset 0 0 0 2px var(--ak-danger);
}

.kk-cell.is-hint {
    animation: kk-pulse 0.8s ease-in-out infinite alternate;
}

@keyframes kk-pulse {
    from { box-shadow: inset 0 0 0 2px var(--ak-info); }
    to { box-shadow: inset 0 0 0 5px var(--ak-info); }
}

.kakuro-board.is-solving {
    pointer-events: none;
}

.kakuro-combos {
    min-height: 1.4em;
    margin: 6px 0 0;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

/* The number pad: one row of ten keys, two rows on a narrow screen. */
.kakuro-pad {
    display: grid;
    grid-template-columns: repeat(10, 1fr);
    gap: 6px;
    width: min(100%, 600px);
    margin: 8px auto 0;
}

.kk-pad-btn {
    min-height: 40px;
    padding: 0;
    border: 1px solid var(--ak-border);
    border-radius: 10px;
    background: var(--ak-field);
    color: var(--ak-text);
    font: 600 18px / 1 var(--ak-font, system-ui, sans-serif);
    cursor: pointer;
}

.kk-pad-btn:hover:not(:disabled) {
    border-color: var(--ak-accent);
}

.kk-pad-btn:disabled {
    opacity: 0.45;
    cursor: default;
}

@media (max-width: 520px) {
    .kakuro-pad { grid-template-columns: repeat(5, 1fr); }
}

.kakuro-status.is-solved {
    color: var(--ak-success);
    font-weight: 600;
}

@media (prefers-reduced-motion: reduce) {
    .kk-cell.is-hint { animation: none; box-shadow: inset 0 0 0 4px var(--ak-info); }
}
