/* Picture Logic (nonograms). Colours come from ../shared/base.css; the fallbacks keep the page usable without it. */
:root {
  --nono-ink: #2f3a2c;
  --nono-fill: #34402f;
  --nono-paper: var(--card, #fff);
  --nono-line: #d9d3c4;
  --nono-thick: #9a9282;
  --nono-hl: #fff1c7;
  --nono-hl-line: #e8b923;
  --nono-done: #b8b2a3;
  --nono-accent: var(--accent, #a65032);
  --nono-forest: var(--forest, #3d5a3a);
  --nono-muted: var(--muted, #6b6b60);
}

* { box-sizing: border-box; }
body { margin: 0; background: #faf7f1; color: var(--nono-ink); font-family: system-ui, -apple-system, "Segoe UI", sans-serif; -webkit-tap-highlight-color: transparent; }
button { font: inherit; color: inherit; cursor: pointer; }

/* ---------- header (base.css may style these too) ---------- */
.nono-top .header-actions { display: flex; align-items: center; gap: 8px; }
.icon-btn { width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--line, #e6e0d2); background: var(--nono-paper); font-weight: 700; font-size: 17px; }

/* ---------- layout ---------- */
.nono { max-width: 760px; margin: 0 auto 56px; padding: 0 24px; }
.nono-sizes { display: flex; flex-wrap: nowrap; gap: 8px; overflow-x: auto; margin: 0; padding: 8px 2px 14px; scrollbar-width: none; }
.nono-sizes::-webkit-scrollbar { display: none; }
.size-tab { flex: 0 0 auto; display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: 76px; padding: 9px 12px; border-radius: 14px; border: 1px solid var(--line, #e6e0d2); background: var(--nono-paper); }
.size-tab b { font-size: 16px; }
.size-tab span { font-size: 11px; color: var(--nono-muted); font-variant-numeric: tabular-nums; }
.size-tab[aria-current="true"] { background: var(--nono-forest); border-color: var(--nono-forest); color: #fff; }
.size-tab[aria-current="true"] span { color: #ffffffcc; }

.puzzle-head { display: flex; justify-content: space-between; align-items: end; gap: 12px; margin: 4px 0 14px; }
.puzzle-head h1 { font: 400 clamp(26px, 5vw, 34px) Georgia, serif; margin: 4px 0 0; letter-spacing: -.5px; }
.eyebrow { font-size: 11px; font-weight: 700; letter-spacing: 1.4px; color: var(--nono-accent); }
.soft-btn { padding: 10px 14px; border-radius: 12px; border: 1px solid var(--line, #e6e0d2); background: var(--nono-paper); font-weight: 600; font-size: 14px; white-space: nowrap; }
.primary { padding: 12px 18px; border-radius: 14px; border: 0; background: var(--nono-forest); color: #fff; font-weight: 700; }

/* ---------- board ---------- */
.board-wrap { display: flex; justify-content: center; padding: 14px; background: var(--nono-paper); border: 1px solid var(--line, #e6e0d2); border-radius: 22px; box-shadow: 0 10px 35px #3d44350a; }
.board { --cell: 32px; --rowclue: 40px; --colclue: 40px; display: grid; grid-template-columns: var(--rowclue) repeat(var(--n), var(--cell)); grid-template-rows: var(--colclue) repeat(var(--n), var(--cell)); user-select: none; -webkit-user-select: none; touch-action: none; }
.clue { display: flex; color: var(--nono-ink); font-weight: 700; font-variant-numeric: tabular-nums; font-size: calc(var(--cell) * .42); transition: color .2s; }
.clue.col { flex-direction: column; justify-content: flex-end; align-items: center; padding-bottom: 4px; gap: 1px; line-height: 1.05; border-radius: 8px 8px 0 0; }
.clue.row { justify-content: flex-end; align-items: center; padding-right: 7px; gap: calc(var(--cell) * .22); border-radius: 8px 0 0 8px; }
.clue.done { color: var(--nono-done); }
.clue.hl { background: var(--nono-hl); color: var(--nono-ink); }
.clue.hl.done { color: var(--nono-ink); }

.cell { position: relative; background: #fff; border-right: 1px solid var(--nono-line); border-bottom: 1px solid var(--nono-line); }
.cell.c0 { border-left: 2px solid var(--nono-thick); }
.cell.r0 { border-top: 2px solid var(--nono-thick); }
.cell.c5 { border-right: 2px solid var(--nono-thick); }
.cell.r5 { border-bottom: 2px solid var(--nono-thick); }
.cell.lastc { border-right: 2px solid var(--nono-thick); }
.cell.lastr { border-bottom: 2px solid var(--nono-thick); }
.cell.cross-hl { background: #fbf7ea; }
.cell::after { content: ""; position: absolute; inset: 2px; border-radius: 3px; transition: background .12s, transform .12s; }
.cell.v1::after { background: var(--nono-fill); }
.cell.v2::after { inset: 0; background: center / 56% no-repeat url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 10'%3E%3Cpath d='M2 2l6 6M8 2l-6 6' stroke='%23b0a690' stroke-width='1.6' stroke-linecap='round'/%3E%3C/svg%3E"); }
.cell.hl { background: var(--nono-hl); }
.cell.wrong { background: #ffd9d0; box-shadow: inset 0 0 0 3px #e0583a; }
.cell.pop::after { animation: pop .5s ease; }
@keyframes pop { 40% { transform: scale(.7); } }

/* finished: the picture appears in colour */
.board.solved .cell { border-color: transparent; transition: background .4s; }
.board.solved .cell.v1::after { inset: 0; border-radius: 0; background: var(--pic); transition-delay: var(--d, 0s); }
.board.solved .cell.v2::after { background: none; }
.board.solved .clue { color: var(--nono-done); }

/* ---------- hints and tools ---------- */
.hint-box { margin: 14px 0 0; padding: 14px 16px; border-radius: 16px; background: #fff8e1; border: 1px solid #f0dc9a; font-size: 15px; line-height: 1.5; }
.hint-box b { color: var(--nono-accent); }
.hint-box.ok { background: #eef6ea; border-color: #c4dcb8; }

.tools { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px; margin-top: 14px; }
.mode { display: flex; padding: 4px; border-radius: 16px; background: #efe9db; }
.mode-btn { display: flex; align-items: center; gap: 8px; padding: 10px 16px; border: 0; border-radius: 12px; background: none; font-weight: 700; font-size: 15px; color: var(--nono-muted); }
.mode-btn[aria-checked="true"] { background: #fff; color: var(--nono-ink); box-shadow: 0 2px 8px #3d443518; }
.swatch { width: 20px; height: 20px; border-radius: 5px; display: inline-grid; place-items: center; }
.swatch.fill { background: var(--nono-fill); }
.swatch.cross { border: 1.5px solid #c8bfa8; color: #9a907a; font-size: 13px; }
.tool-row { display: flex; gap: 8px; flex-wrap: wrap; }
.tool { padding: 10px 14px; border-radius: 12px; border: 1px solid var(--line, #e6e0d2); background: var(--nono-paper); font-weight: 600; font-size: 14px; }
.tool:disabled { opacity: .45; cursor: default; }
.tool.hint { background: #fff8e1; border-color: #f0dc9a; }
button:focus-visible { outline: 3px solid var(--nono-accent); outline-offset: 2px; }

/* ---------- dialogs (base.css styles dialogs too; these keep this page complete on its own) ---------- */
dialog { border: 0; border-radius: 24px; padding: 28px 26px 24px; max-width: min(440px, calc(100vw - 32px)); width: 100%; box-shadow: 0 30px 80px #2a302633; color: var(--nono-ink); background: #fffdf8; }
dialog.wide { max-width: min(620px, calc(100vw - 32px)); }
dialog::backdrop { background: #2a302655; }
dialog h2 { font: 400 28px Georgia, serif; margin: 6px 0 14px; }
dialog .close { position: absolute; top: 12px; right: 14px; width: 36px; height: 36px; border-radius: 50%; border: 0; background: #f2efe6; font-size: 20px; }
.guide-list { padding-left: 20px; margin: 14px 0 20px; line-height: 1.55; font-size: 15px; }
.guide-list li { margin-bottom: 6px; }
.guide-demo { display: flex; justify-content: center; padding: 8px 0; }
.demo-grid { --cell: 26px; display: grid; grid-template-columns: 34px repeat(5, var(--cell)); grid-template-rows: 30px repeat(5, var(--cell)); }
.demo-grid .clue { font-size: 12px; }
.demo-grid .cell.v1::after { animation: demo-fill 6s infinite; animation-delay: var(--d); opacity: 0; }
@keyframes demo-fill { 0%, 8% { opacity: 0; } 14%, 86% { opacity: 1; } 94%, 100% { opacity: 0; } }

#listBody section { margin-bottom: 18px; }
#listBody h3 { font-size: 14px; margin: 0 0 8px; display: flex; justify-content: space-between; }
#listBody h3 span { font-weight: 400; color: var(--nono-muted); }
.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 8px; }
.thumb { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 8px 4px 6px; border-radius: 12px; border: 1px solid var(--line, #e6e0d2); background: #fff; font-size: 11px; color: var(--nono-muted); }
.thumb svg { width: 48px; height: 48px; border-radius: 4px; background: #f6f3ea; }
.thumb.current { border-color: var(--nono-accent); box-shadow: 0 0 0 2px var(--nono-accent) inset; }
.thumb .q { width: 48px; height: 48px; border-radius: 4px; display: grid; place-items: center; background: #f6f3ea; font: 22px Georgia, serif; color: #b8ae96; }

.win-art { display: flex; justify-content: center; margin: 2px 0 12px; }
.win-art svg { width: 140px; height: 140px; animation: win-in .6s cubic-bezier(.2, 1.4, .4, 1); }
@keyframes win-in { from { transform: scale(.4) rotate(-8deg); opacity: 0; } }
#win { text-align: center; }
.win-points { font-weight: 700; color: var(--nono-forest); min-height: 1.4em; margin: -6px 0 6px; }
.win-note { color: var(--nono-muted); margin: 0 0 18px; font-size: 14px; }
.win-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

@media (max-width: 560px) {
  .nono { padding: 0 16px; }
  .board-wrap { padding: 10px 6px; border-radius: 18px; }
  .tools { flex-direction: column; align-items: stretch; }
  .mode-btn { flex: 1; justify-content: center; }
  .tool-row .tool { flex: 1; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
