/* Create By Asking: the nonogram game. Loaded after puzzles.css, which gives the board-and-side-panel layout. */

.ng { grid-template-columns: minmax(0, 1fr) 300px; }
.ng .pz-board { position: relative; justify-items: center; }
.ng .pz-head, .ng .pz-msg { width: 100%; }
.ng-nav { display: flex; align-items: center; gap: 8px; }
.ng-nav .icon-step { width: 32px; height: 32px; border-radius: 50%; border: 0; background: rgba(255, 255, 255, 0.1); color: #fff; cursor: pointer; font: 700 1rem/1 var(--body); }
.ng-nav .icon-step:hover { background: rgba(255, 255, 255, 0.2); }

/* the board: clues on the top and left, squares in the middle */
.ng-scroll { width: 100%; overflow-x: auto; overscroll-behavior-x: contain; padding-bottom: 4px; }
.ng-board {
  --cs: 28px; --chip: 22px;
  display: grid; width: max-content; margin: 0 auto;
  grid-template-columns: var(--rcw, 160px) calc(var(--w) * var(--cs));
  grid-template-rows: var(--cch, 160px) calc(var(--h) * var(--cs));
  user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent; outline: none;
}
.ng-board:focus-visible .ng-grid { box-shadow: 0 0 0 3px #FFC93C; }
.ng-corner { display: grid; place-items: center; padding: 4px; }
.ng-mini { max-width: 100%; max-height: 100%; image-rendering: pixelated; border-radius: 4px; background: rgba(255, 255, 255, 0.06); }
.ng-cols { display: grid; grid-template-columns: repeat(var(--w), var(--cs)); align-items: end; }
.ng-rows { display: grid; grid-template-rows: repeat(var(--h), var(--cs)); justify-items: end; }
.ng-clue { display: flex; gap: 2px; border-radius: 6px; transition: opacity 0.25s, background 0.15s; }
.ng-cclue { flex-direction: column; align-items: center; justify-content: flex-end; padding: 3px 0 4px; height: 100%; }
.ng-rclue { align-items: center; justify-content: flex-end; padding: 0 5px 0 3px; width: 100%; }
.ng-clue b {
  display: grid; place-items: center; width: var(--chip); height: var(--chip); border-radius: calc(var(--chip) * 0.28);
  font: 700 calc(var(--chip) * 0.6)/1 var(--body); letter-spacing: -0.02em; font-variant-numeric: tabular-nums;
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.18);
}
.ng-clue b.pale { box-shadow: inset 0 0 0 1px rgba(28, 15, 63, 0.25), inset 0 -2px 0 rgba(0, 0, 0, 0.12); }
.ng-clue b.dark { box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.4), inset 0 -2px 0 rgba(0, 0, 0, 0.18); }
.ng-clue b.zero { background: transparent; color: #A597CC; box-shadow: none; }
.ng-clue.hl { background: rgba(255, 201, 60, 0.18); }
.ng-clue.done { opacity: 0.32; }
.ng-cclue.b5 { box-shadow: inset -1px 0 0 rgba(255, 255, 255, 0.12); }
.ng-rclue.b5 { box-shadow: inset 0 -1px 0 rgba(255, 255, 255, 0.12); }

.ng-grid {
  display: grid; grid-template-columns: repeat(var(--w), var(--cs)); grid-template-rows: repeat(var(--h), var(--cs));
  background: #B9AFD3; border-radius: 6px; overflow: hidden; box-shadow: 0 0 0 2px #1C0F3F, 0 10px 30px rgba(0, 0, 0, 0.35);
  touch-action: none; cursor: crosshair;
}
.ng-cell { position: relative; display: block; margin: 0 1px 1px 0; background-color: #E3DCF0; transition: background-color 0.08s; }
.ng-cell.br { margin-right: 2px; }
.ng-cell.bb { margin-bottom: 2px; }
.ng-cell.hl:not(.f) { background-color: #D3C8EC; }
.ng-cell.f { box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.22), inset 0 -2px 0 rgba(0, 0, 0, 0.1); }
.ng-cell.x::before, .ng-cell.x::after { content: ""; position: absolute; left: 20%; right: 20%; top: 50%; height: 2px; margin-top: -1px; background: #8C7FB0; border-radius: 2px; transform: rotate(45deg); }
.ng-cell.x::after { transform: rotate(-45deg); }
.ng-cell.dot::before { content: ""; position: absolute; left: 50%; top: 50%; width: 4px; height: 4px; margin: -2px; border-radius: 50%; background: #B9AFD3; }
.ng-cell.cur { outline: 2px solid #FF6FA8; outline-offset: -2px; z-index: 1; }
.ng-cell.bad { animation: ng-bad 0.45s ease-in-out 4; }
.ng-cell.hinted { animation: ng-hint 0.6s ease-in-out 3; z-index: 1; }
@keyframes ng-bad { 50% { background-color: #FF4D6D; box-shadow: inset 0 0 0 3px #fff; } }
@keyframes ng-hint { 50% { transform: scale(1.25); box-shadow: 0 0 0 3px #FFC93C; } }

/* solved: the grid lines melt away and the picture pops in */
.ng.won .ng-grid { background: linear-gradient(160deg, #DCEBFF, #EFE3FA 55%, #FBE3EE); cursor: default; }
.ng.won .ng-cell { margin: 0; background-color: transparent; }
.ng.won .ng-cell.f { box-shadow: none; }
.ng.won .ng-cell.dot::before, .ng.won .ng-cell.x::before, .ng.won .ng-cell.x::after { display: none; }
.ng.won .ng-cell.f { animation: ng-pop 0.5s cubic-bezier(.3, 1.6, .5, 1) both; animation-delay: var(--d); }
.ng.won .ng-clue { opacity: 0.22; }
@keyframes ng-pop { 0% { transform: scale(0.4); } 60% { transform: scale(1.18); } 100% { transform: scale(1); } }

/* the win and peek cards */
.ng-over { display: grid; place-items: center; z-index: 5; }
.ng-over[hidden] { display: none; }
.ng-over.win { width: 100%; }
.ng.won .ng-pal, .ng.won .ng-tools { display: none; }
.ng-over.peek { position: absolute; inset: 0; background: rgba(28, 15, 63, 0.82); border-radius: 14px; backdrop-filter: blur(3px); }
.ng-card-over { display: grid; gap: 6px; justify-items: center; text-align: center; padding: 14px 20px; border-radius: 16px; background: #fff; color: #1C0F3F; box-shadow: 0 20px 50px rgba(0, 0, 0, 0.45); max-width: 360px; animation: ng-rise 0.5s cubic-bezier(.2, 1.4, .4, 1) both; }
.ng-over.win:not(.calm) .ng-card-over { animation-delay: 0.9s; }
.ng-card-over h3 { color: #1C0F3F; font-size: var(--step-1); margin: 0; }
.ng-over.peek .ng-card-over h3 { font-size: var(--step-2); }
.ng-card-over p { margin: 0; color: #5A4E80; }
.ng-card-over .eyebrow { color: #D6337F; }
.ng-over-btns { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 4px; }
.ng-card-over .btn-ghost { background: #EEE8FB; color: #1C0F3F; }
.ng-peek { width: min(240px, 60vw); height: auto; image-rendering: pixelated; border-radius: 8px; background: linear-gradient(160deg, #DCEBFF, #EFE3FA 55%, #FBE3EE); padding: 8px; }
@keyframes ng-rise { from { opacity: 0; transform: translateY(16px) scale(0.96); } }

/* colours and tools under the board */
.ng-pal { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.ng-sw { display: grid; justify-items: center; gap: 3px; padding: 0; border: 0; background: none; color: #A597CC; cursor: pointer; font: inherit; }
.ng-sw span { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 12px; background: var(--c); box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.2), 0 0 0 2px rgba(255, 255, 255, 0.12); transition: transform 0.12s, box-shadow 0.12s; }
.ng-sw.dark span { box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.2), 0 0 0 2px rgba(255, 255, 255, 0.45); }
.ng-sw small { font: 600 0.65rem/1 var(--mono); }
.ng-swx span { background: #E9E3F5; color: #6A5E8C; font: 800 1.2rem/1 var(--body); }
.ng-sw.on span { transform: translateY(-3px) scale(1.06); box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.2), 0 0 0 3px #1C0F3F, 0 0 0 6px #FFC93C; }
.ng-sw.on small { color: #FFC93C; }
.ng-tools { width: min(100%, 560px); display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; }
.ng-tools .btn { justify-content: center; padding-inline: 4px; white-space: nowrap; }
.ng-tools .btn:disabled { opacity: 0.4; cursor: default; }
.tool-shell .ng-tools .ng-rev { background: rgba(255, 111, 168, 0.18); }
.tool-shell .ng-tools .ng-rev:hover { background: rgba(255, 111, 168, 0.3); }

/* the picture picker */
.ng-tabs { display: flex; flex-wrap: wrap; gap: 6px; }
.ng-tabs .chip-dark { flex: 1 1 0; padding: 7px 4px; text-align: center; font-size: 0.8rem; }
.tool-shell .ng-tabs .chip-dark.on { background: #FFC93C; color: #1C0F3F; }
.ng-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(78px, 1fr)); gap: 8px; }
.ng-pick { position: relative; display: grid; justify-items: center; align-content: start; gap: 4px; padding: 8px 4px 7px; border: 0; border-radius: 12px; background: rgba(255, 255, 255, 0.06); color: #CBBFE8; cursor: pointer; font: 600 0.72rem/1.15 var(--body); text-align: center; }
.ng-pick:hover { background: rgba(255, 255, 255, 0.12); }
.ng-pick.on { box-shadow: 0 0 0 2px #FFC93C; }
.ng-pick canvas { width: 48px; height: 48px; object-fit: contain; image-rendering: pixelated; border-radius: 6px; background: linear-gradient(160deg, #DCEBFF, #EFE3FA 55%, #FBE3EE); }
.ng-pick.fresh canvas { background: repeating-linear-gradient(45deg, #3A2A6E 0 6px, #33255F 6px 12px); }
.ng-pick.fresh::after { content: "?"; position: absolute; top: 8px; left: 50%; width: 48px; height: 48px; margin-left: -24px; display: grid; place-items: center; font: 800 1.4rem/1 var(--display, var(--body)); color: #8C7FB0; }
.ng-pick.started canvas { background: #E9E3F5; }
.ng-pick.solved span { color: #fff; }
.ng-pick small { font: 600 0.65rem/1 var(--mono); color: #5BD48F; }
.ng-tally { margin: 0; font: 600 0.8rem/1.2 var(--mono); color: #FFC93C; }
.ng .pz-side .ng-keys { margin: 0; }
@media (hover: none) and (pointer: coarse) { .ng .pz-side .ng-keys { display: none; } }

@media (max-width: 860px) {
  .ng { grid-template-columns: 1fr; }
}
@media (max-width: 480px) {
  .ng.tool-shell { padding: 10px; }
  .ng .pz-board { padding: 10px 4px; }
  .ng-sw span { width: 36px; height: 36px; }
  .ng-tools { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 4px; }
  .ng-tools .btn { font-size: 0.74rem; padding-inline: 2px; }
}
@media (prefers-reduced-motion: reduce) {
  .ng.won .ng-cell.f { animation-duration: 0.01s; }
}

@media print {
  .ng-print .ng-pline { display: flex; justify-content: space-between; gap: 8mm; margin: 0 0 6mm; font-size: 10.5pt; text-align: left; }
  .ng-sheet svg { display: block; width: 100%; max-width: 175mm; max-height: 230mm; height: auto; margin: 0 auto; }
  .ng-ans svg { max-width: 110mm; }
  .ng-print svg rect { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .ng-print .ng-from { margin-top: 8mm; font-size: 9pt; color: #555; }
}
.ng.won .ng-cell.cur { outline: 0; }
.ng.won .ng-cell.hl:not(.f) { background-color: transparent; }
.ng-grid { grid-column: 2; grid-row: 2; }
.ng-board.compact .ng-cols, .ng-board.compact .ng-rows, .ng-board.compact .ng-corner { display: none; }
