/* Dots and boxes: a square of dots, the lines between them and the boxes they close. */

/* A square board that fills the room its stage has (see shell.css). Everything inside is placed
   by the script in percentages of the board, so nothing moves or changes size when a line is
   drawn. */
.board {
  --board: min(100cqw, 100cqh, 640px);
  --bar: clamp(5px, var(--board) / 60, 9px);    /* how thick a line is */
  position: relative;
  width: var(--board);
  height: var(--board);
  background: var(--panel);
  border: 2px solid var(--line);
  border-radius: 20px;
}

.dot {
  position: absolute;
  width: calc(var(--bar) * 2.2);
  height: calc(var(--bar) * 2.2);
  margin: calc(var(--bar) * -1.1) 0 0 calc(var(--bar) * -1.1);
  border-radius: 50%;
  background: var(--ink);
  pointer-events: none;
}

/* A line's button is fatter than the line you see, so it is easy to hit. Its ends are cut to a
   point so the buttons that meet at a dot share the space without overlapping. */
.ln {
  appearance: none;
  position: absolute;
  border: 0;
  background: transparent;
  color: inherit;
  margin: 0;
  padding: 0;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
}
.ln-h { clip-path: polygon(0 50%, 30% 0, 70% 0, 100% 50%, 70% 100%, 30% 100%); }
.ln-v { clip-path: polygon(50% 0, 100% 30%, 100% 70%, 50% 100%, 0 70%, 0 30%); }
.ln.on { cursor: default; }
.board.is-over .ln { cursor: pointer; }

.bar { position: absolute; border-radius: 99px; background: var(--line); }
.ln-h .bar { left: calc(var(--bar) * 1.6); right: calc(var(--bar) * 1.6); top: 50%; height: var(--bar); margin-top: calc(var(--bar) / -2); }
.ln-v .bar { top: calc(var(--bar) * 1.6); bottom: calc(var(--bar) * 1.6); left: 50%; width: var(--bar); margin-left: calc(var(--bar) / -2); }
.ln.on .bar { background: var(--ink); }
/* the line or lines of the last turn are in the color of whoever drew them */
.ln.last-1 .bar { background: var(--p1); }
.ln.last-2 .bar { background: var(--p2); }
@media (hover: hover) { .ln:not(.on):hover .bar { background: var(--dim); } }
/* the button is clipped, so the focus ring goes on the line inside it */
.ln:focus-visible { outline: none; }
.ln:focus-visible .bar { outline: 3px solid var(--focus); outline-offset: 2px; }

/* a claimed box is tinted and carries its owner's piece: solid for player 1, ringed for player 2 */
.box { position: absolute; }
.box.own-1 { background: rgba(172, 248, 180, .16); }
.box.own-2 { background: rgba(255, 164, 112, .16); }
.claim { position: absolute; inset: 27%; display: block; }
.claim.chip-1, .claim.chip-2 { position: absolute; }

@media (prefers-reduced-motion: no-preference) {
  .box.just-claimed .claim { animation: settle .2s ease-out; }
  @keyframes settle { from { transform: scale(.5); } }
}
