/* Slitherlink (/slitherlink): only what is the game's own - the SVG board of dots, numbers, lines and crosses, with its
   hit areas and keyboard cursor. 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. */

.slitherlink-landing-app {
    --sl-face: #ffffff;
    --sl-dot: #1e293b;
    --sl-line: #1d4ed8;
    --sl-cross: #94a3b8;
    --sl-clue: #0f172a;
    --sl-guide: #e2e8f0;
    --sl-bad: #dc2626;
}

.slitherlink-landing-app[data-theme="dark"] {
    --sl-face: #0f172a;
    --sl-dot: #cbd5e1;
    --sl-line: #60a5fa;
    --sl-cross: #64748b;
    --sl-clue: #e2e8f0;
    --sl-guide: #1e293b;
    --sl-bad: #f87171;
}

.slitherlink-board {
    width: min(100%, calc(100vh - 330px));
    min-width: min(100%, 260px);
    margin-inline: auto;
    border-radius: 12px;
    outline: none;
}

/* The ring and the keyboard cursor only for someone using the keyboard: a tap focuses the board too (its keys work at
   once), and a script's focus counts as :focus-visible (data-input, js/seo/landing-input-mode.js). */
html:not([data-input="pointer"]) .slitherlink-board:focus-visible {
    box-shadow: 0 0 0 3px var(--ak-accent);
}

.slitherlink-board.is-making {
    opacity: 0.55;
}

.sl-svg {
    display: block;
    width: 100%;
    height: auto;
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
}

.sl-face {
    fill: var(--sl-face);
}

/* Every edge: a faint guide while empty, a thick line when drawn, red when it closes a loop that cannot be the answer. */
.sl-edge {
    stroke: var(--sl-guide);
    stroke-width: 1.5;
    stroke-linecap: round;
}

.sl-edge.is-line {
    stroke: var(--sl-line);
    stroke-width: 5;
}

.sl-edge.is-line.is-bad {
    stroke: var(--sl-bad);
}

.sl-cross {
    display: none;
    fill: none;
    stroke: var(--sl-cross);
    stroke-width: 2;
    stroke-linecap: round;
}

.sl-cross.is-on {
    display: inline;
}

.sl-dot {
    fill: var(--sl-dot);
}

/* A dot with three lines, or a line that cannot go on: a red ring. */
.sl-dot.is-bad {
    fill: var(--sl-bad);
    stroke: var(--sl-bad);
    stroke-width: 6;
    stroke-opacity: 0.35;
}

.sl-clue {
    fill: var(--sl-clue);
    font: 600 20px var(--ak-font, system-ui, sans-serif);
}

/* A number with its count is done: it steps back. One with too many lines or crosses turns red. */
.sl-clue.is-met {
    opacity: 0.45;
}

.sl-clue.is-bad {
    fill: var(--sl-bad);
    font-weight: 800;
}

/* The hit areas: invisible, but they take the pointer. */
.sl-hit {
    fill: transparent;
    cursor: pointer;
}

@media (hover: hover) {
    .sl-hit:hover {
        fill: color-mix(in srgb, var(--ak-accent) 10%, transparent);
    }
}

/* The keyboard cursor shows only while the board has the keyboard focus. */
.sl-cursor {
    display: none;
    fill: color-mix(in srgb, var(--ak-accent) 18%, transparent);
    stroke: var(--ak-accent);
    stroke-width: 2;
    pointer-events: none;
}

html:not([data-input="pointer"]) .slitherlink-board:focus-visible .sl-cursor {
    display: inline;
}

.sl-hint {
    display: none;
    stroke: var(--ak-info);
    stroke-width: 10;
    stroke-linecap: round;
    stroke-opacity: 0.45;
    pointer-events: none;
}

.sl-hint.is-on {
    display: inline;
    animation: sl-pulse 0.8s ease-in-out infinite alternate;
}

@keyframes sl-pulse {
    from { stroke-opacity: 0.25; }
    to { stroke-opacity: 0.7; }
}

.slitherlink-board.is-solving {
    pointer-events: none;
}

.slitherlink-status.is-solved {
    color: var(--ak-success);
    font-weight: 600;
}

@media (prefers-reduced-motion: reduce) {
    .sl-hint.is-on { animation: none; stroke-opacity: 0.55; }
}
