/* Reversi: an eight by eight board, every square in play. */

/* 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. The thin lines between the squares are the board showing through the gaps. */
.board {
  --board: min(100cqw, 100cqh, 640px);
  --cell: calc((var(--board) - 18px) / 8);   /* 18px: seven 2px gaps and 2px of padding each side */
  display: grid;
  grid-template-columns: repeat(8, var(--cell));
  grid-template-rows: repeat(8, var(--cell));
  gap: 2px;
  width: var(--board);
  height: var(--board);
  padding: 2px;
  background: var(--line);
  border-radius: 14px;
  overflow: hidden;
}
.sq {
  appearance: none;
  display: block;
  position: relative;
  width: var(--cell);
  height: var(--cell);
  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[aria-disabled="true"] { cursor: default; }
.sq:focus-visible { outline-offset: -3px; z-index: 1; }
.sq.is-last { background: #2b3560; }
@media (hover: hover) { .sq.is-open:hover { background: #2b3560; } }

.piece { display: block; position: absolute; left: calc(var(--cell) * .1); top: calc(var(--cell) * .1); width: calc(var(--cell) * .8); height: calc(var(--cell) * .8); }
.piece.chip-1, .piece.chip-2 { position: absolute; }

/* a small ring on every square the player to move can take */
.sq.is-open::after { content: ""; position: absolute; left: calc(var(--cell) * .36); top: calc(var(--cell) * .36); width: calc(var(--cell) * .28); height: calc(var(--cell) * .28); border-radius: 50%; border: 3px solid var(--dim); }

/* a new piece settles in, and the pieces it traps turn over */
@media (prefers-reduced-motion: no-preference) {
  .piece.just-placed { animation: settle .18s ease-out; }
  .piece.just-flipped { animation: turn .3s ease-out; }
  @keyframes settle { from { transform: scale(.6); } }
  @keyframes turn { from { transform: scaleX(0); } }
}
