/* ── KenKen (Calcudoku) ───────────────────────────────────────────────────────
   A Latin square carved into heavy-outlined cages. The play chrome
   (.q-chrome / .q-stage / .q-foot) is the shared shell from queens.css; the
   number palette (.ng-pal) is the shared dock from numgrid.css. Below is
   KenKen's own — the board, the cage rules, the cage tags, and the digits.

   Sizing tokens (--kk-n, --kk-cell) are set on .kk-hold by the JS to fit the
   stage; colours are theme-aware via app tokens, with a math accent for the
   player's own digits. */

.kk-play { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.kk-play .q-stage { padding: var(--space-5); overflow: auto; display: flex; align-items: center; justify-content: center; }
.kk-hold { display: inline-block; }

/* ── the board: a grid of cells, each drawing its own thin + heavy rules ────── */
.kk-board {
  /* colours (--kk-heavy/thin/math/bad) + geometry (--kk-n/cell) live in tokens.css */
  display: grid;
  grid-template-columns: repeat(var(--kk-n), var(--kk-cell));
  background: var(--surface);
  border-radius: var(--radius-sm);
  touch-action: none; user-select: none; -webkit-user-select: none;
}

.kk-cell {
  position: relative; box-sizing: border-box;
  width: var(--kk-cell); height: var(--kk-cell);
  display: flex; align-items: center; justify-content: center;
  margin: 0; padding: 0;
  border: 1px solid var(--kk-thin);
  background: transparent;
  font-family: var(--font-mono);
  cursor: pointer;
}
/* heavy edges: a cage boundary, or the board's own rim */
.kk-cell.kk-tb { border-top: 3px solid var(--kk-heavy); }
.kk-cell.kk-bb { border-bottom: 3px solid var(--kk-heavy); }
.kk-cell.kk-lb { border-left: 3px solid var(--kk-heavy); }
.kk-cell.kk-rb { border-right: 3px solid var(--kk-heavy); }

.kk-given { background: var(--surface-2); cursor: default; }

/* the small cage target + operator, in the cage's top-left cell */
.kk-tag {
  position: absolute; top: 2px; left: 4px;
  font-size: calc(var(--kk-cell) * 0.22); line-height: 1;
  color: var(--mute); letter-spacing: 0; pointer-events: none;
}
/* the digit */
.kk-val {
  font-size: calc(var(--kk-cell) * 0.46); font-weight: 600;
  color: var(--text); line-height: 1; pointer-events: none;
}
.kk-user .kk-val { color: var(--kk-math); font-weight: 700; }
.kk-given .kk-val { color: var(--text); font-weight: 700; }

/* a value repeated in its row/column — a soft warning while you play */
.kk-dupe { background: color-mix(in srgb, var(--kk-bad) 15%, transparent); }
/* Check flagged this cell */
.kk-bad { outline: 2px solid var(--kk-bad); outline-offset: -3px; z-index: 3; }

/* the finished square: a soft settle on the digits */
.kk-board.kk-solved .kk-user .kk-val,
.kk-board.kk-solved .kk-given .kk-val { animation: kk-pop var(--duration-3, 0.28s) var(--ease, ease) both; }
@keyframes kk-pop { from { transform: scale(0.72); opacity: 0.4; } to { transform: none; opacity: 1; } }

/* ── footer: Check / Solve tools above the number palette ──────────────────── */
.kk-foot { flex-direction: column; gap: var(--space-4); }
.kk-tools { display: inline-flex; gap: var(--space-4); justify-content: center; }
.kk-tool {
  display: inline-flex; align-items: center; gap: var(--space-3);
  padding: var(--space-3) var(--space-5);
  background: var(--surface); color: var(--mute);
  border: var(--hairline) solid var(--line); border-radius: var(--radius);
  font-family: var(--font-mono); font-size: var(--text-sm); cursor: pointer;
  transition: var(--t, transform 0.08s ease, background 0.12s ease);
}
.kk-tool svg { width: var(--icon-sm, 16px); height: var(--icon-sm, 16px); flex: none; }
.kk-tool:active { transform: scale(0.96); }
.kk-tool:hover { color: var(--text); border-color: var(--line-2); }

/* ── level-card thumbnail: the caged grid, digits once solved ──────────────── */
.kk-mini {
  display: grid;
  grid-template-columns: repeat(var(--kk-mn), 1fr);
  width: 44px; height: 44px; margin: 0 auto;
  border-radius: 2px; overflow: hidden;
}
.kk-mini i {
  position: relative; box-sizing: border-box;
  display: flex; align-items: center; justify-content: center;
  border: 0.5px solid var(--line-2);
  aspect-ratio: 1;
}
.kk-mini i.kk-tb { border-top: 1.5px solid var(--text); }
.kk-mini i.kk-bb { border-bottom: 1.5px solid var(--text); }
.kk-mini i.kk-lb { border-left: 1.5px solid var(--text); }
.kk-mini i.kk-rb { border-right: 1.5px solid var(--text); }
.kk-mini b {
  font-family: var(--font-mono); font-weight: 700;
  font-size: 8px; line-height: 1; color: var(--mute);
}
.kk-mini.done b { color: var(--text); }

@media (prefers-reduced-motion: reduce) {
  .kk-board.kk-solved .kk-user .kk-val,
  .kk-board.kk-solved .kk-given .kk-val { animation: none; }
  .kk-tool { transition: none; }
}
