/* Free daily Nonogram: board, clues, tools. Loaded after puzzles.css.
   Sizes scale with the board width: --cell is one square (container units),
   --n and --cu (row-clue width in squares) are set by nonogram.js. */

/* Phones: let the card reach closer to the screen edge so a 10x10 board keeps
   squares of about 28 px at 360 px wide. */
@media (max-width: 480px) {
  [data-chalk-game="nonogram"] .play-card { margin-inline: calc(5px - var(--gutter)); padding: 14px 8px 16px; border-radius: 24px; }
  [data-chalk-game="nonogram"] .play-bar { padding-inline: 6px; }
}

.nono {
  --n: 10;
  --cu: 1.7;
  --ink-fill: #262b30;
  --cross: #a2987f;
  --clue-bg: rgba(236, 230, 212, .62);
  --cell: calc(100cqi / (var(--n) + var(--cu)));
  display: grid;
  grid-template-columns: 1.7fr 10fr;
  width: 100%;
  max-width: calc((var(--n) + var(--cu)) * 52px);
  margin: 0 auto;
  container-type: inline-size;
  -webkit-user-select: none;
  user-select: none;
}

/* corner: the picture so far */
.nono-corner { position: relative; min-width: 0; }
.nono-preview { position: absolute; left: 14%; top: 14%; width: 72%; height: 72%; overflow: visible; }
.nono-preview .frame { fill: none; stroke: rgba(23, 27, 30, .2); stroke-width: 1.5px; vector-effect: non-scaling-stroke; }
.nono-preview rect { fill: #fff; }
.nono-preview rect.on { fill: var(--ink-fill); }

/* clues */
.nono-cols { display: grid; grid-template-columns: repeat(var(--n), minmax(0, 1fr)); padding: 0 3px; min-width: 0; }
.nono-rows { display: grid; grid-template-rows: repeat(var(--n), minmax(0, 1fr)); padding: 3px 0; min-width: 0; }
.nono-cols .cc, .nono-rows .rc { font-weight: 800; color: var(--ink); font-variant-numeric: tabular-nums; line-height: 1; font-size: 13px; font-size: min(calc(var(--cell) * .48), 22px); transition: color .2s ease, background-color .2s ease; }
.nono-cols .cc { display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 2px; gap: calc(var(--cell) * .07); padding-bottom: calc(var(--cell) * .18); border-radius: 9px 9px 0 0; }
.nono-rows .rc { display: flex; justify-content: flex-end; align-items: center; gap: 4px; gap: calc(var(--cell) * .15); padding-right: calc(var(--cell) * .16); border-radius: 9px 0 0 9px; }
.nono-cols .cc:nth-child(even), .nono-rows .rc:nth-child(even) { background: var(--clue-bg); }
.nono-cols .cc.on, .nono-rows .rc.on { background: rgba(248, 206, 70, .55); }
.nono-cols .cc.done, .nono-rows .rc.done { color: rgba(23, 27, 30, .26); }
.nono-cols .cc.over, .nono-rows .rc.over { color: var(--danger); }

/* the squares */
.nono-field { display: grid; grid-template-rows: repeat(var(--n), minmax(0, 1fr)); aspect-ratio: 1; border: 3px solid var(--ink); border-radius: 12px; overflow: hidden; background: #fff; touch-action: none; -webkit-touch-callout: none; min-width: 0; }
.nono-row { display: grid; grid-template-columns: repeat(var(--n), minmax(0, 1fr)); min-height: 0; }
.nono-cell { position: relative; display: block; min-width: 0; min-height: 0; margin: 0; padding: 0; border: 0; border-right: 1px solid rgba(23, 27, 30, .15); border-bottom: 1px solid rgba(23, 27, 30, .15); border-radius: 0; background: #fff; cursor: pointer; -webkit-tap-highlight-color: transparent; transition: background-color .08s ease; }
.nono-row:last-child .nono-cell { border-bottom: 0; }
.nono-cell:last-child { border-right: 0; }
.nono-cell.gr { border-right: 2px solid rgba(23, 27, 30, .62); }
.nono-cell.gb { border-bottom: 2px solid rgba(23, 27, 30, .62); }
.nono-cell.ln { background: #fdf3cf; }
.nono-cell.f { background: var(--ink-fill); }
.nono-cell.x::after { content: ""; position: absolute; inset: 24%; background:
  linear-gradient(45deg, transparent calc(50% - 1.5px), var(--cross) calc(50% - 1.5px), var(--cross) calc(50% + 1.5px), transparent calc(50% + 1.5px)),
  linear-gradient(-45deg, transparent calc(50% - 1.5px), var(--cross) calc(50% - 1.5px), var(--cross) calc(50% + 1.5px), transparent calc(50% + 1.5px)); }
.nono-cell.ln.x::after { --cross: #8d836a; }
.nono-cell:focus-visible { outline: 3px solid var(--yellow); outline-offset: -3px; border-radius: 0; box-shadow: inset 0 0 0 4px var(--ink); z-index: 1; }
.nono-cell.hint { animation: nono-hint 1.2s ease; }
@keyframes nono-hint { 0%, 60% { box-shadow: inset 0 0 0 4px var(--yellow); } 100% { box-shadow: inset 0 0 0 0 var(--yellow); } }

/* solved: the picture in colour */
.nono.won .nono-field { border-color: var(--accent); cursor: default; }
.nono.won .nono-cell { cursor: default; border-color: rgba(23, 27, 30, .05); }
.nono.won .nono-cell.gr { border-right-color: rgba(23, 27, 30, .05); }
.nono.won .nono-cell.gb { border-bottom-color: rgba(23, 27, 30, .05); }
.nono.won .nono-cell.f { background: var(--c, var(--accent)); animation: nono-pop .5s cubic-bezier(.3, 1.5, .5, 1) both; animation-delay: var(--d, 0ms); }
.nono.won.still .nono-cell.f { animation: none; }
.nono.won .nono-cols .cc, .nono.won .nono-rows .rc { color: rgba(23, 27, 30, .26); background: transparent; }
@keyframes nono-pop { 0% { background: var(--ink-fill); transform: scale(1); } 45% { background: var(--ink-fill); transform: scale(.62); } 100% { transform: scale(1); } }

/* tools: Fill / Mark toggle, then Undo, Clear, Hint */
[data-chalk-game="nonogram"] .tools { justify-content: center; }
.nono-mode { display: inline-flex; gap: 4px; padding: 4px; border-radius: 16px; background: rgba(255, 255, 255, .7); box-shadow: var(--shadow); }
.nono-mode .tool { box-shadow: none; background: transparent; min-height: 40px; display: inline-flex; align-items: center; gap: 8px; }
.nono-mode .tool[aria-pressed="true"] { background: var(--ink); color: #fff; }
.nono-mode .ico { width: 16px; height: 16px; flex: none; border-radius: 3px; }
.nono-mode .ico-fill { background: currentColor; }
.nono-mode .ico-cross { position: relative; }
.nono-mode .ico-cross::before, .nono-mode .ico-cross::after { content: ""; position: absolute; left: 50%; top: 50%; width: 18px; height: 2.6px; border-radius: 2px; background: currentColor; transform: translate(-50%, -50%) rotate(45deg); }
.nono-mode .ico-cross::after { transform: translate(-50%, -50%) rotate(-45deg); }
.tools .tool:disabled { opacity: .45; cursor: default; }
@media (max-width: 520px) {
  .nono-mode { display: flex; flex: 1 1 100%; }
  .nono-mode .tool { flex: 1; justify-content: center; }
  [data-chalk-game="nonogram"] .tools > .tool { flex: 1; padding: 0 8px; }
}

/* the finished picture on the result sheet */
.result-box .nono-pic { display: block; width: 88px; height: 88px; padding: 7px; border-radius: 16px; background: #fff; box-shadow: var(--shadow); }
.result-box .nono-pic rect { shape-rendering: crispEdges; }
.result-box .nono-pic .frame { display: none; }
