/* Star Battle (/star-battle): only what is the game's own - the grid of coloured regions with its walls, the stars and
   the dots. 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 region, wall, star and dot colours
   are custom properties, so Save image and the pencil paint the same ones. Ten soft region colours (the 10 x 10 board
   has ten regions), each one different, so two neighbouring regions never share a colour. */

.star-battle-landing-app {
    --sb-r0: #fbcfd6;
    --sb-r1: #c7ecd0;
    --sb-r2: #c9defb;
    --sb-r3: #fbe8a6;
    --sb-r4: #ddd3fb;
    --sb-r5: #fdd9b5;
    --sb-r6: #b9efe6;
    --sb-r7: #f3cdf5;
    --sb-r8: #dcefb0;
    --sb-r9: #e6d5c3;
    --sb-grid: rgba(15, 23, 42, 0.22);
    --sb-wall: #1e293b;
    --sb-star: #b45309;
    --sb-dot: #334155;
}

.star-battle-landing-app[data-theme="dark"] {
    --sb-r0: #6b2f45;
    --sb-r1: #22533f;
    --sb-r2: #1f4470;
    --sb-r3: #64561c;
    --sb-r4: #4b3a7a;
    --sb-r5: #6d4020;
    --sb-r6: #1c5a5a;
    --sb-r7: #63305f;
    --sb-r8: #44581f;
    --sb-r9: #4d4d58;
    --sb-grid: rgba(226, 232, 240, 0.2);
    --sb-wall: #cbd5e1;
    --sb-star: #fbbf24;
    --sb-dot: #cbd5e1;
}

.star-battle-board {
    display: grid;
    grid-template-columns: repeat(var(--sb-n, 8), 1fr);
    width: min(100%, calc(100vh - 300px));
    min-width: min(100%, 260px);
    margin-inline: auto;
    border: 4px solid var(--sb-wall);
    border-radius: 6px;
    overflow: hidden;
    background: var(--sb-wall);
    box-sizing: border-box;
}

.star-battle-board.is-making {
    opacity: 0.55;
}

/* A cell draws its top and left line as inset shadows (they take no room, so every mark stays centred): thin inside a
   region, thick where the region changes. The board's frame is the outer line. */
.sb-cell {
    --sb-top: 1px;
    --sb-left: 1px;
    --sb-top-color: var(--sb-grid);
    --sb-left-color: var(--sb-grid);
    position: relative;
    aspect-ratio: 1 / 1;
    min-width: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: var(--sb-fill, var(--ak-field));
    box-shadow: inset 0 var(--sb-top) 0 var(--sb-top-color), inset var(--sb-left) 0 0 var(--sb-left-color);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.sb-cell.sb-edge-top { --sb-top: 0px; }
.sb-cell.sb-edge-left { --sb-left: 0px; }
.sb-cell.sb-wall-top { --sb-top: 3px; --sb-top-color: var(--sb-wall); }
.sb-cell.sb-wall-left { --sb-left: 3px; --sb-left-color: var(--sb-wall); }

.sb-cell:hover {
    background: color-mix(in srgb, var(--sb-fill, var(--ak-field)) 82%, var(--ak-text));
}

/* The chosen cell keeps its region's colour, a little towards the accent. */
.sb-cell.is-selected {
    background: color-mix(in srgb, var(--sb-fill, var(--ak-field)) 82%, var(--ak-accent));
    outline: none;
}

.sb-cell:focus-visible {
    outline: 3px solid var(--ak-accent);
    outline-offset: -3px;
}

/* The mark: a star or a dot. */
.sb-cell::after {
    content: "";
    position: absolute;
    pointer-events: none;
}

.sb-cell.is-star::after {
    inset: 14%;
    background: var(--sb-star);
    clip-path: polygon(50% 2%, 61.8% 36.4%, 98% 36.4%, 68.7% 57.6%, 79.4% 92%, 50% 70.8%, 20.6% 92%, 31.3% 57.6%, 2% 36.4%, 38.2% 36.4%);
}

.sb-cell.is-dot::after {
    top: 50%;
    left: 50%;
    width: 16%;
    height: 16%;
    min-width: 5px;
    min-height: 5px;
    border-radius: 50%;
    background: var(--sb-dot);
    transform: translate(-50%, -50%);
}

/* A star that breaks a rule (it touches another star, or its row, column or region has too many). */
.sb-cell.is-bad::after {
    background: var(--ak-danger);
}

.sb-cell.is-bad {
    background: color-mix(in srgb, var(--sb-fill, var(--ak-field)) 75%, var(--ak-danger));
}

/* The ring of the Hint and of the cell Solve just filled. */
.sb-cell::before {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.sb-cell.is-hint::before {
    animation: sb-pulse 0.8s ease-in-out infinite alternate;
}

@keyframes sb-pulse {
    from { box-shadow: inset 0 0 0 2px var(--ak-info); }
    to { box-shadow: inset 0 0 0 5px var(--ak-info); }
}

.star-battle-board.is-solving {
    pointer-events: none;
}

.star-battle-status.is-solved {
    color: var(--ak-success);
    font-weight: 600;
}

@media (prefers-reduced-motion: reduce) {
    .sb-cell.is-hint::before { animation: none; box-shadow: inset 0 0 0 4px var(--ak-info); }
}
