/* EwrekaGames — Nonogram board (assets/js/solo/nonogram.js). Shell styles: assets/css/solo.css.
 * Sizes come from the module as custom properties set once per mount: --s (cell), --q (cell when not zoomed),
 * --rw / --ch (row-clue strip width, column-clue strip height), --mw / --mh (grid window), --f (clue font), --bw. */
:root { --nn-ink: #1E2636; --nn-line: #cfd6e2; --nn-thick: #6b778c; --nn-clue: #f3f5f9; --nn-clue-2: #e9edf4; --nn-soft: #e5eaf2; --nn-x: #8792a6; }
:root[data-theme="dark"] { --nn-ink: #e9edf5; --nn-line: #303a4b; --nn-thick: #7c879b; --nn-clue: #1d2431; --nn-clue-2: #232b3a; --nn-soft: #2b3444; --nn-x: #7e8aa0; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --nn-ink: #e9edf5; --nn-line: #303a4b; --nn-thick: #7c879b; --nn-clue: #1d2431; --nn-clue-2: #232b3a; --nn-soft: #2b3444; --nn-x: #7e8aa0; } }

/* the wrap is never narrower than the stage allows (up to 340 px, 440 px on wider screens), so the tools keep usable
   widths under a narrow board */
.nn-wrap { display: flex; flex-direction: column; align-items: center; gap: 10px; width: max(var(--bw, 100%), min(100%, 340px)); max-width: 100%; margin: 0 auto; }
@media (min-width: 641px) { .nn-wrap { width: max(var(--bw, 100%), min(100%, 440px)); } }
.nn-wrap.side { flex-direction: row; align-items: flex-start; width: auto; }
.nn-board {
  position: relative; flex: none; display: grid;
  grid-template-columns: var(--rw) var(--mw); grid-template-rows: var(--ch) var(--mh); gap: 2px;
  touch-action: none; -webkit-tap-highlight-color: transparent; -webkit-user-select: none; user-select: none;
  --t1: #FF6B4A; --t2: #F5B524;
}
.nn-board.nn-t1 { --t1: #3D7BF7; --t2: #14A874; }
.nn-board.nn-t2 { --t1: #8B5CF6; --t2: #FF6B4A; }
.nn-board.nn-t3 { --t1: #14A874; --t2: #3D7BF7; }

/* corner: live preview of the picture (and the zoom window) */
.nn-corner { position: relative; background: var(--surface-2); border-radius: 10px 4px 4px 4px; overflow: hidden; display: grid; place-items: center; }
.nn-prev { width: calc(100% - 4px); height: calc(100% - 4px); display: block; }
.nn-board.zoomed .nn-corner { cursor: crosshair; touch-action: none; }

/* clue strips */
.nn-top, .nn-left { position: relative; overflow: hidden; background: var(--nn-clue); }
.nn-top { border-radius: 4px 10px 0 0; }
.nn-left { border-radius: 4px 0 0 10px; }
.nn-cc { display: flex; height: 100%; will-change: transform; }
.nn-rc { display: flex; flex-direction: column; width: 100%; will-change: transform; }
.nn-cl { flex: none; width: var(--s); display: flex; flex-direction: column; justify-content: flex-end; align-items: center; padding-bottom: 3px; box-sizing: border-box; border-right: 1px solid transparent; }
.nn-cl:nth-child(even) { background: var(--nn-clue-2); }
.nn-cl.b5 { border-right-color: var(--nn-thick); }
.nn-rl { flex: none; height: var(--s); display: flex; justify-content: flex-end; align-items: center; padding-right: 4px; box-sizing: border-box; border-bottom: 1px solid transparent; }
.nn-rl:nth-child(even) { background: var(--nn-clue-2); }
.nn-rl.b5 { border-bottom-color: var(--nn-thick); }
.nn-cl span, .nn-rl span {
  display: grid; place-items: center; font-size: var(--f); font-weight: 700; color: var(--ink); line-height: 1;
  font-variant-numeric: tabular-nums; transition: color .2s, opacity .2s;
}
.nn-cl span { height: calc(var(--q) * .6); width: 100%; }
.nn-rl span { width: calc(var(--q) * .66); height: 100%; }
.nn-board.two .nn-rl span { width: calc(var(--q) * .82); }
.nn-cl span.ok, .nn-rl span.ok { color: var(--ink-3); opacity: .45; }
.nn-cl.hl, .nn-rl.hl { background: color-mix(in srgb, var(--blue) 16%, var(--nn-clue)); }
.nn-cl.hl span:not(.ok), .nn-rl.hl span:not(.ok) { color: var(--blue); }
.nn-cl.flash, .nn-rl.flash { animation: nn-flash .7s var(--ease); }
@keyframes nn-flash { 0% { background: color-mix(in srgb, var(--good) 40%, var(--nn-clue)); } 100% { } }

/* the grid window */
.nn-main { position: relative; overflow: hidden; background: var(--surface); outline: 2px solid var(--nn-thick); outline-offset: 0; border-radius: 2px 2px 10px 2px; cursor: pointer; }
.nn-main:focus { outline: 2px solid var(--nn-thick); }
.nn-board.kbd .nn-main:focus-visible { outline: 3px solid var(--blue); }
.nn-cells { display: grid; grid-template-columns: repeat(var(--n), var(--s)); grid-auto-rows: var(--s); width: max-content; will-change: transform; }
.nn-row { display: contents; }
.nn-c { position: relative; box-sizing: border-box; border-right: 1px solid var(--nn-line); border-bottom: 1px solid var(--nn-line); background: var(--surface); }
.nn-c.br { border-right: 2px solid var(--nn-thick); }
.nn-c.bb { border-bottom: 2px solid var(--nn-thick); }
@media (hover: hover) { .nn-board:not(.solved) .nn-c:hover { background: color-mix(in srgb, var(--blue) 12%, var(--surface)); } }
.nn-c.f { background: var(--nn-ink); box-shadow: inset 0 0 0 max(1px, calc(var(--s) * .05)) var(--surface); }
@media (hover: hover) { .nn-board:not(.solved) .nn-c.f:hover { background: color-mix(in srgb, var(--nn-ink) 82%, var(--blue)); } }
.nn-c.x::before, .nn-c.x::after { content: ""; position: absolute; left: 50%; top: 50%; width: 62%; height: max(1.5px, calc(var(--s) * .09)); border-radius: 2px; background: var(--nn-x); transform: translate(-50%, -50%) rotate(45deg); }
.nn-c.x::after { transform: translate(-50%, -50%) rotate(-45deg); }
.nn-c.a::before { content: ""; position: absolute; left: 50%; top: 50%; width: max(3px, calc(var(--s) * .16)); height: max(3px, calc(var(--s) * .16)); border-radius: 50%; background: var(--nn-x); opacity: .7; transform: translate(-50%, -50%); }
.nn-c.h { background-image: linear-gradient(225deg, var(--brand) 0 calc(var(--s) * .22), transparent calc(var(--s) * .22 + .5px)); }   /* hinted: coral corner */
.nn-c.bad.f { background: var(--bad); background-image: repeating-linear-gradient(45deg, rgba(255, 255, 255, .25) 0 3px, transparent 3px 7px); }
.nn-c.bad.x::before, .nn-c.bad.x::after, .nn-c.bad.a::before { background: var(--bad); opacity: 1; }
.nn-c.bad.a::before { width: max(5px, calc(var(--s) * .26)); height: max(5px, calc(var(--s) * .26)); }
.nn-board.kbd .nn-c.cur { z-index: 2; box-shadow: inset 0 0 0 max(2px, calc(var(--s) * .1)) var(--blue); }
.nn-board.kbd .nn-c.cur.f { box-shadow: inset 0 0 0 max(2px, calc(var(--s) * .1)) var(--blue), inset 0 0 0 max(3px, calc(var(--s) * .16)) var(--surface); }
.nn-c.pop { animation: nn-pop .18s var(--ease); }
.nn-c.hint { animation: nn-hint 1s var(--ease); z-index: 3; }
@keyframes nn-pop { 0% { transform: scale(.7); } 100% { transform: none; } }
@keyframes nn-hint { 0%, 100% { box-shadow: inset 0 0 0 0 var(--brand); } 30% { box-shadow: inset 0 0 0 max(3px, calc(var(--s) * .16)) var(--brand); } }

/* solved: the picture appears in colour, crosses fade away */
.nn-board.solved .nn-main { cursor: default; }
.nn-board.solved .nn-c { transition: background-color .5s ease var(--d, 0ms); }
.nn-board.solved .nn-c { background-image: none; }
.nn-board.solved .nn-c.f { background: var(--t1); background: color-mix(in srgb, var(--t2) calc(var(--k, 0) * 100%), var(--t1)); box-shadow: none; }
.nn-board.solved .nn-c.x::before, .nn-board.solved .nn-c.x::after, .nn-board.solved .nn-c.a::before { opacity: 0; transition: opacity .4s ease; }
.nn-board.solved .nn-c { border-color: transparent; }
.nn-board.solved .nn-c.win { animation: nn-win .6s var(--ease) var(--d, 0ms) backwards; }
@keyframes nn-win { 0% { transform: scale(.4); border-radius: 50%; } 60% { transform: scale(1.12); } 100% { transform: none; } }
.nn-board.solved .nn-cl span, .nn-board.solved .nn-rl span { opacity: .35; }

/* messages over the grid (never move anything) */
.nn-toast {
  position: absolute; left: calc(var(--rw) + 8px); right: 6px; top: calc(var(--ch) + 8px); z-index: 6;
  justify-self: center; margin: 0 auto; width: max-content; max-width: calc(100% - var(--rw) - 14px);
  padding: 7px 12px; border-radius: 12px; background: var(--ink); color: var(--surface); font-size: 13px; font-weight: 600; line-height: 1.3;
  text-align: center; pointer-events: none; opacity: 0; transform: translateY(-4px); transition: opacity .18s, transform .18s;
  box-shadow: 0 6px 18px rgba(0, 0, 0, .18);
}
.nn-toast.show { opacity: 1; transform: none; }
.nn-toast.low { top: auto; bottom: 8px; }
.nn-toast.count { font-size: 18px; font-weight: 800; padding: 4px 14px; background: var(--blue); color: #fff; font-variant-numeric: tabular-nums; }
.nn-toast.hint { background: var(--brand); color: var(--on-brand); }
/* the picture's name sits over the (faded) column clues, never over the picture itself */
.nn-toast.win { top: max(2px, calc(var(--ch) / 2 - 17px)); bottom: auto; font-size: 15px; font-weight: 800; background: var(--surface); color: var(--ink); border: 1px solid var(--line-2); }

/* tools under (or beside) the board */
.nn-tools { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr); gap: 8px; width: 100%; flex: none; }
.nn-tools.three { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) minmax(0, 1fr); }   /* no Zoom: Fill/Cross, Undo, Hint */
.nn-clock { display: none; }
.nn-seg { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 3px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--line); }
.nn-b {
  height: 52px; min-width: 0; display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 0 10px;
  border-radius: 12px; border: 1px solid var(--line-2); background: var(--surface); color: var(--ink-2); font: inherit; font-size: 14px; font-weight: 700;
  box-shadow: var(--press); cursor: pointer; touch-action: manipulation; transition: transform .08s, box-shadow .08s, background .15s, color .15s, border-color .15s;
}
.nn-b span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nn-b svg { width: 20px; height: 20px; flex: none; }
.nn-b:active:not(:disabled) { transform: translateY(3px); box-shadow: none; }
.nn-b:disabled { opacity: .45; cursor: default; }
.nn-b.hidden { display: none; }
.nn-seg .nn-b { height: 44px; box-shadow: none; border-color: transparent; background: transparent; }
.nn-seg .nn-b.on { background: var(--surface); color: var(--ink); border-color: var(--line-2); box-shadow: 0 2px 0 var(--line-2); }
.nn-seg .nn-b[data-m="f"].on svg { color: var(--ink); }
.nn-seg .nn-b[data-m="x"].on { color: var(--brand); }
.nn-zoom[aria-pressed="true"] { background: var(--brand-soft); border-color: var(--brand); color: var(--brand); }
.nn-b:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.nn-tools.done { opacity: .55; }
.nn-wrap.side .nn-tools { width: 76px; grid-template-columns: 1fr; grid-auto-rows: auto; gap: 6px; }
.nn-wrap.side .nn-seg { grid-template-columns: 1fr; }
.nn-wrap.side .nn-b { flex-direction: column; gap: 2px; height: 46px; padding: 0 4px; font-size: 11px; }
.nn-wrap.side .nn-seg .nn-b { height: 44px; }
.nn-wrap.side .nn-b svg { width: 18px; height: 18px; }
/* side layout (short landscape screens): the page header with the clock is scrolled away, so the clock sits here */
.nn-wrap.side .nn-clock {
  display: block; height: 22px; line-height: 22px; text-align: center; font-size: 14px; font-weight: 800; color: var(--ink-2);
  font-variant-numeric: tabular-nums; overflow: hidden; white-space: nowrap;
}

@media (max-width: 640px) {
  .nn-b { font-size: 13px; padding: 0 6px; gap: 5px; }
  .nn-b svg { width: 17px; height: 17px; }
  .nn-tools { grid-template-columns: minmax(0, 1fr) repeat(3, 46px); gap: 6px; }
  .nn-tools.three { grid-template-columns: minmax(0, 1fr) repeat(2, 54px); }
}
/* phones: Undo / Zoom become icon buttons (their text stays as the accessible name) */
@media (max-width: 480px) {
  .nn-undo span, .nn-zoom span:last-child, .nn-hint span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .nn-undo svg, .nn-zoom svg, .nn-hint svg { width: 22px; height: 22px; }
}
@media (max-width: 340px) {
  .nn-seg .nn-b svg { display: none; }
}
/* set by the module when a label does not fit (see fitLabels): icon buttons, the text stays as the accessible name */
.nn-tools.icons .nn-undo span, .nn-tools.icons .nn-zoom span:last-child, .nn-tools.icons .nn-hint span,
.nn-tools.tight .nn-seg .nn-b span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.nn-tools.icons .nn-undo svg, .nn-tools.icons .nn-zoom svg, .nn-tools.icons .nn-hint svg { width: 22px; height: 22px; }
.nn-tools.icons { grid-template-columns: minmax(0, 1fr) repeat(3, 56px); }
.nn-tools.icons.three { grid-template-columns: minmax(0, 1fr) repeat(2, 60px); }
.nn-wrap.side .nn-tools.icons { grid-template-columns: 1fr; }
.nn-tools.tight .nn-seg .nn-b svg { display: block; width: 22px; height: 22px; }
@media (prefers-reduced-motion: reduce) {
  .nn-c.pop, .nn-c.hint, .nn-board.solved .nn-c.win, .nn-cl.flash, .nn-rl.flash { animation: none; }
  .nn-board.solved .nn-c { transition: none; }
  .nn-toast { transition: none; }
}
/* wave18: tablets and desktop without Zoom: Undo and Hint take the width of their own label (static texts, so the row
   never changes during play) and Fill / Cross share the rest, so "Rückgängig" / "Rellenar" are no longer cut on a
   440 px row (a 5x5 board is narrow); labels that still do not fit fall back to icons (nonogram.js fitLabels) */
@media (min-width: 641px) {
  .nn-wrap:not(.side) .nn-tools.three { grid-template-columns: minmax(0, 1fr) auto auto; }
  .nn-wrap:not(.side) .nn-tools.three .nn-seg .nn-b { padding: 0 6px; gap: 6px; }
}
