/* begin license *
 *
 * Small browser games on swl and swindl
 *
 * All rights reserved.
 *
 * Copyright (C) 2026 moatley moatley@lost-monkeys.net
 *
 * This file is part of "Games"
 *
 * end license */

/* Pictures: one screen, the list of puzzles or one puzzle with its tools below. */
:root {
    --pic-bg: #f3f1ec;
    --pic-bg-glow: #fffdf8;
    --pic-panel: #ffffff;
    --pic-text: #2a2a33;
    --pic-muted: #77737f;
    --pic-cell-bg: #fbfaf7;
    --pic-line: #d6d0c4;
    --pic-line-thick: #8f887b;
    --pic-fill: #2f3446;
    --pic-cross: #a39d92;
    --pic-clue: #2a2a33;
    --pic-clue-done: #bdb7ac;
    --pic-clue-bg: #ebe7df;
    --pic-accent: #259696;
}
:root[data-theme="dark"] {
    --pic-bg: #161a24;
    --pic-bg-glow: #232a3b;
    --pic-panel: #1f2533;
    --pic-text: #eceef4;
    --pic-muted: #8d93a5;
    --pic-cell-bg: #262d3d;
    --pic-line: #384056;
    --pic-line-thick: #7d869e;
    --pic-fill: #dfe3ee;
    --pic-cross: #6d758a;
    --pic-clue: #eceef4;
    --pic-clue-done: #4e566b;
    --pic-clue-bg: #1c2230;
    --pic-accent: #38c9c9;
}

body.pictures-page {
    margin: 0;
    background: radial-gradient(ellipse at 50% 40%, var(--pic-bg-glow), var(--pic-bg) 70%) var(--pic-bg);
    background-attachment: fixed;
    min-height: 100vh;
    color: var(--pic-text);
    overscroll-behavior: none;
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
}

.pic {
    display: flex;
    flex-direction: column;
    align-items: center;
    height: 100vh;
    height: 100dvh;
    max-width: 40rem;
    margin: 0 auto;
    padding: env(safe-area-inset-top) .75rem env(safe-area-inset-bottom);
    box-sizing: border-box;
}

.pic-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .5rem;
    width: 100%;
    padding: .75rem 0 .25rem;
    flex: 0 0 auto;
}
.pic-back, .pic-restart {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    border: 0;
    border-radius: 50%;
    background: var(--pic-panel);
    color: var(--pic-text);
    font-size: 1.2rem;
    text-decoration: none;
    cursor: pointer;
    flex: 0 0 auto;
}
.pic-restart[hidden] { display: none; }
/* a placeholder for the restart button in the list, so the header stays balanced */
.pic-top:has(.pic-restart[hidden])::after { content: ""; width: 2.5rem; flex: 0 0 auto; }
.pic-score { display: flex; flex-direction: column; align-items: center; flex: 1 1 auto; min-width: 0; }
.pic-score[hidden] { display: none; }
.pic-score > span:last-child {
    font-size: 1.5rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}
.pic-label { font-size: .7rem; letter-spacing: .08em; text-transform: uppercase; color: var(--pic-muted); }

.pic-mascot {
    width: 3.4rem;
    height: 3.4rem;
    border-radius: 50%;
    overflow: hidden;
    background: var(--pic-panel);
    flex: 0 0 auto;
}

/* ---------- the list ---------- */

.pic-list {
    flex: 1 1 auto;
    min-height: 0;
    width: 100%;
    overflow-y: auto;
    padding-bottom: 1rem;
}
.pic-list[hidden], .pic-play[hidden] { display: none; }
.pic-size h2 {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin: 1rem 0 .5rem;
    font-size: 1.15rem;
}
.pic-size-count { font-size: .85rem; font-weight: 400; color: var(--pic-muted); font-variant-numeric: tabular-nums; }
.pic-tiles {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(4rem, 1fr));
    gap: .5rem;
}
.pic-tile {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    aspect-ratio: 1;
    border-radius: .75rem;
    background: var(--pic-panel);
    color: var(--pic-text);
    text-decoration: none;
    box-shadow: 0 1px 3px rgba(0, 0, 0, .12);
}
.pic-tile:hover, .pic-tile:focus-visible { outline: 2px solid var(--pic-accent); outline-offset: 1px; }
.pic-tile-q { font-size: 1.6rem; font-weight: 800; line-height: 1; color: var(--pic-muted); }
.pic-tile-size { font-size: .7rem; color: var(--pic-muted); margin-top: .2rem; }
/* begun but not solved: a small dot */
.pic-tile-started::after {
    content: "";
    position: absolute;
    top: .4rem;
    right: .4rem;
    width: .45rem;
    height: .45rem;
    border-radius: 50%;
    background: var(--pic-accent);
}
.pic-thumb { width: 72%; height: 72%; }

/* ---------- one puzzle ---------- */

.pic-play {
    flex: 1 1 auto;
    min-height: 0;
    width: 100%;
    display: flex;
    flex-direction: column;
}
.pic-board {
    flex: 1 1 auto;
    min-height: 0;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}
.pic-grid {
    display: grid;
    touch-action: none;
    font-size: var(--pic-font);
    line-height: 1;
}
.pic-corner { background: transparent; }

.pic-clue {
    display: flex;
    color: var(--pic-clue);
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    transition: color .2s;
}
.pic-col-clue {
    flex-direction: column;
    justify-content: flex-end;
    align-items: center;
    gap: .1em;
    padding-bottom: .3em;
}
.pic-row-clue {
    justify-content: flex-end;
    align-items: center;
    gap: .35em;
    padding-right: .35em;
}
.pic-col-clue:nth-child(odd), .pic-row-clue:nth-child(odd of .pic-row-clue) { background: var(--pic-clue-bg); }
.pic-col-clue { border-radius: .3em .3em 0 0; }
.pic-row-clue { border-radius: .3em 0 0 .3em; }
.pic-clue-done { color: var(--pic-clue-done); }

.pic-cell {
    position: relative;
    box-sizing: border-box;
    background: var(--pic-cell-bg);
    border-right: 1px solid var(--pic-line);
    border-bottom: 1px solid var(--pic-line);
    cursor: pointer;
    transition: background-color .25s, border-color .4s;
}
.pic-cell.pic-first-c { border-left: 2px solid var(--pic-line-thick); }
.pic-cell.pic-first-r { border-top: 2px solid var(--pic-line-thick); }
.pic-cell.pic-five-c, .pic-cell.pic-last-c { border-right: 2px solid var(--pic-line-thick); }
.pic-cell.pic-five-r, .pic-cell.pic-last-r { border-bottom: 2px solid var(--pic-line-thick); }
.pic-cell.pic-filled { background: var(--pic-fill); }
/* a cross: two thin lines */
.pic-cell.pic-crossed::before, .pic-cell.pic-crossed::after {
    content: "";
    position: absolute;
    left: 22%;
    right: 22%;
    top: 50%;
    height: max(1.5px, calc(var(--pic-cell) * .08));
    margin-top: calc(max(1.5px, calc(var(--pic-cell) * .08)) / -2);
    border-radius: 1px;
    background: var(--pic-cross);
    transform: rotate(45deg);
}
.pic-cell.pic-crossed::after { transform: rotate(-45deg); }

/* solved: the picture in its colour, the lines fade away */
.pic-grid.pic-done .pic-cell { border-color: transparent; cursor: default; }
.pic-grid.pic-done .pic-cell.pic-filled { background: var(--pic-color); }
.pic-grid.pic-done .pic-clue { color: var(--pic-clue-done); }

.pic-tools {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
    padding: .75rem 0 1rem;
}
.pic-modes {
    display: inline-flex;
    padding: .25rem;
    border-radius: 2rem;
    background: var(--pic-panel);
    box-shadow: 0 1px 3px rgba(0, 0, 0, .12);
}
.pic-mode, .pic-undo {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 3.25rem;
    height: 2.75rem;
    border: 0;
    border-radius: 1.5rem;
    background: transparent;
    color: var(--pic-muted);
    font-size: 1.3rem;
    cursor: pointer;
}
.pic-mode[aria-pressed="true"] { background: var(--pic-accent); color: #fff; }
.pic-mode-fill-icon {
    display: block;
    width: 1.05rem;
    height: 1.05rem;
    border-radius: 2px;
    background: currentColor;
}
.pic-undo {
    width: 2.75rem;
    border-radius: 50%;
    background: var(--pic-panel);
    color: var(--pic-text);
    box-shadow: 0 1px 3px rgba(0, 0, 0, .12);
}
.pic-undo:disabled { opacity: .4; cursor: default; }

/* ---------- solved ---------- */

.pic-over {
    position: fixed;
    inset: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, .45);
}
.pic-over[hidden] { display: none; }
.pic-over-box {
    display: grid;
    grid-template-columns: auto 1fr;
    align-items: center;
    gap: .5rem 1rem;
    margin: 0 1rem;
    padding: 1.5rem 1.5rem;
    border-radius: 1rem;
    background: var(--pic-panel);
    color: var(--pic-text);
}
.pic-over-box h2 { margin: 0 0 .5rem; }
.pic-over-mascot { width: 7rem; height: auto; }
.pic-over-picture { width: 5rem; height: 5rem; }
.pic-over-svg { display: block; width: 100%; height: 100%; }
.pic-over-buttons { grid-column: 1 / -1; display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; }
.pic-over-buttons > :first-child { grid-column: 1 / -1; }
