/* Checkers: an eight by eight board played on the dark squares. */

/* A square board that fills the room its stage has (see shell.css). Every size is worked out
   from --board: the squares never take their size from the page's flow or from what stands on
   them. */
.board {
  --board: min(100cqw, 100cqh, 640px);
  --cell: calc((var(--board) - 4px) / 8);   /* 4px is the border on both sides */
  display: grid;
  grid-template-columns: repeat(8, var(--cell));
  grid-template-rows: repeat(8, var(--cell));
  width: var(--board);
  height: var(--board);
  background: var(--panel);
  border: 2px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
}
.lt, .sq { display: block; width: var(--cell); height: var(--cell); }
.lt { background: #333a56; }
.sq {
  appearance: none;
  position: relative;
  border: 0;
  border-radius: 0;
  background: var(--panel);
  color: inherit;
  margin: 0;
  padding: 0;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
}
.sq:focus-visible { outline-offset: -3px; z-index: 1; }
.sq.is-last { background: #20263f; }
.sq.is-sel { background: #2b3560; }
@media (hover: hover) { .sq.is-dest:hover { background: #2b3560; } }

.piece { display: block; position: absolute; left: calc(var(--cell) * .11); top: calc(var(--cell) * .11); width: calc(var(--cell) * .78); height: calc(var(--cell) * .78); }
.piece.chip-1, .piece.chip-2 { position: absolute; }
/* a king wears a crown */
.crown { position: absolute; z-index: 1; left: 24%; top: 24%; width: 52%; height: 52%; display: block; fill: var(--bg); }
.chip-2 .crown { left: 27%; top: 27%; width: 46%; height: 46%; }

/* the piece that was picked up, the squares it can go to, and pieces that have to jump */
.sq.is-sel .piece { outline: 3px solid var(--ink); outline-offset: 1px; }
.sq.is-dest::after { content: ""; position: absolute; left: calc(var(--cell) * .33); top: calc(var(--cell) * .33); width: calc(var(--cell) * .34); height: calc(var(--cell) * .34); border-radius: 50%; background: var(--ink); }
.sq.can-jump .piece { outline: 3px dashed var(--ink); outline-offset: 1px; }

/* a piece that just moved settles into its square */
@media (prefers-reduced-motion: no-preference) {
  .piece.just-moved { animation: settle .18s ease-out; }
  @keyframes settle { from { transform: scale(.6); } }
}
