/* Donut Checkers. Colours come from the shared :root variables in style.css. */

.ck {
  --light: #e9d5f2;
  --dark: #5b2a7a;
  --edge: #3d1a55;
  --turn: #ff9a3c; /* whoever's turn it is, and the donut they've picked up */
}

/* the round sits in the middle of the page, whatever the widths of the names either side */
.ck-players {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  max-width: 640px;
  margin: 0 auto;
}

.ck-players > :first-child {
  justify-self: start;
}

.ck-players > :last-child {
  justify-self: end;
}

.ck-tag {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 2px solid var(--line);
  border-radius: 999px;
  padding: 4px 14px 4px 4px;
  font-weight: 600;
  transition: border-color 0.2s;
}

.ck-tag img {
  width: 32px;
  height: 32px;
  image-rendering: pixelated;
}

.ck-tag.active {
  border-color: var(--turn);
  box-shadow: 0 0 0 1px var(--turn);
}

.ck-status {
  text-align: center;
  font-size: 1.5rem;
  font-weight: 700;
  margin: 16px 0 12px;
  min-height: 2.1rem;
}

/* End turn, for stopping part way through a multi-jump when jumps aren't forced */
.ck-stop {
  display: flex;
  justify-content: center;
  margin: -4px 0 12px;
}

.ck-board {
  --cell: min(64px, calc((100vw - 56px) / 8), calc((100dvh - 280px) / 8));
  display: grid;
  grid-template-columns: repeat(8, var(--cell));
  width: fit-content;
  margin: 0 auto;
  border: 8px solid var(--edge);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 16px 40px rgb(0 0 0 / 0.4);
}

.ck-cell {
  position: relative;
  width: var(--cell);
  height: var(--cell);
  display: grid;
  place-items: center;
  padding: 0;
  margin: 0;
  border: 0;
  background: var(--light);
  cursor: default;
  font: inherit;
}

.ck-cell.dark {
  background: var(--dark);
}

/* the squares the last move went through */
.ck-cell.dark.trail {
  background: color-mix(in srgb, var(--dark) 70%, var(--turn));
}

.ck-cell:focus-visible {
  outline: 3px solid var(--pink);
  outline-offset: -3px;
}

.ck-cell img {
  width: 88%;
  height: 88%;
  image-rendering: pixelated;
  pointer-events: none;
}

.ck-cell img.pop {
  animation: ck-pop 0.25s ease-out;
}

@keyframes ck-pop {
  from {
    transform: scale(0.6);
  }
}

.ck-board.my-turn .ck-cell.can-move,
.ck-board.my-turn .ck-cell.selected,
.ck-board.my-turn .ck-cell.target {
  cursor: pointer;
}

/* donuts that can move glow a little until one is picked up */
.ck-board.my-turn .ck-cell.can-move img {
  filter: drop-shadow(0 0 4px var(--turn));
}

.ck-board.my-turn .ck-cell.can-move:hover img {
  filter: drop-shadow(0 0 7px var(--turn));
}

.ck-cell.selected {
  box-shadow: inset 0 0 0 4px var(--turn);
}

/* a faded donut on each square the picked up one can go to */
.ck-cell.target::after {
  content: "";
  width: 88%;
  height: 88%;
  background: var(--ghost) center / contain no-repeat;
  image-rendering: pixelated;
  opacity: 0.35;
}

.ck-cell.target:hover::after {
  opacity: 0.6;
}

.ck-board.busy .ck-cell {
  cursor: progress;
}

/* the small board on the create screen */

.ck-preview {
  --cell: min(22px, calc((100vw - 100px) / 8));
  display: grid;
  grid-template-columns: repeat(8, var(--cell));
  width: fit-content;
  margin: 8px auto 0;
  border: 4px solid #3d1a55;
  border-radius: 8px;
  overflow: hidden;
}

.ck-preview i {
  width: var(--cell);
  height: var(--cell);
  background: #e9d5f2 center / 85% no-repeat;
  image-rendering: pixelated;
}

.ck-preview i.dark {
  background-color: #5b2a7a;
}

/* url()s here are relative to this stylesheet */
.ck-preview i[data-piece="1"] {
  background-image: url("../../sprites/blue.png");
}

.ck-preview i[data-piece="2"] {
  background-image: url("../../sprites/pink.png");
}
