/* Four in a row: a rack of seven columns and six rows, and the two kinds of pieces. */

/* player 1 is a solid mint piece; player 2 is orange with a ring in it, so the two can be told
   apart without relying on color */
.mark-1, .disc-1 { background: var(--p1); border-radius: 50%; }
.mark-2, .disc-2 { background: var(--p2); border-radius: 50%; box-shadow: inset 0 0 0 4px var(--p2), inset 0 0 0 7px #8a4a22; }

/* The rack is seven holes wide and six tall and fills the room its stage has (see shell.css):
   as wide as the stage, unless that would make it taller than the stage. Every size is worked
   out from --board. */
.board {
  --hole: clamp(4px, 1.4cqw, 10px);   /* the space between holes */
  --board: min(100cqw, (100cqh - 4px - var(--hole)) * 7 / 6 + 4px + var(--hole), 700px);
  display: grid;
  --cell: calc((var(--board) - 4px - var(--hole)) / 7);   /* 4px is the border on both sides */
  grid-template-columns: repeat(7, var(--cell));
  grid-template-rows: calc(var(--cell) * 6);
  width: var(--board);
  height: calc(var(--cell) * 6 + 4px + var(--hole));
  padding: calc(var(--hole) / 2);
  background: var(--panel);
  border: 2px solid var(--line);
  border-radius: 20px;
  overflow: hidden;
}
.col {
  appearance: none;
  display: block;
  width: var(--cell);
  height: calc(var(--cell) * 6);
  line-height: 0;
  font-size: 0;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: inherit;
  margin: 0;
  padding: 0;
  min-width: 0;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
}
/* only where there is a real pointer: on a touch screen a hover would stick to the last column tapped */
@media (hover: hover) { .col:hover:not([aria-disabled="true"]) { background: #1f2540; } }
.col[aria-disabled="true"] { cursor: default; }
.col:focus-visible { outline-offset: -3px; }

.slot { display: block; position: relative; width: var(--cell); height: var(--cell); }
.slot::before { content: ""; position: absolute; inset: calc(var(--hole) / 2); border-radius: 50%; background: var(--bg); }
.disc { display: block; position: absolute; inset: calc(var(--hole) / 2); }
.disc-2 { box-shadow: inset 0 0 0 calc(var(--board) / 60) var(--p2), inset 0 0 0 calc(var(--board) / 34) #8a4a22; }
.disc.is-win { outline: 3px solid var(--ink); outline-offset: -3px; }
.board.is-over .disc:not(.is-win) { opacity: .4; }

/* a new piece falls into place from the top of its column */
@media (prefers-reduced-motion: no-preference) {
  .disc.just-placed { animation: fall .3s cubic-bezier(.3, 0, .7, 1); }
  .disc.fall-1 { --rows: 1; animation-duration: .12s; }
  .disc.fall-2 { --rows: 2; animation-duration: .17s; }
  .disc.fall-3 { --rows: 3; animation-duration: .21s; }
  .disc.fall-4 { --rows: 4; animation-duration: .25s; }
  .disc.fall-5 { --rows: 5; animation-duration: .28s; }
  .disc.fall-6 { --rows: 6; animation-duration: .31s; }
  @keyframes fall { from { transform: translateY(calc((-100% - var(--hole)) * var(--rows))); } }
}
