/* A Sudoku board drawn to the app's own spec (rendered by renderAppBoard in learn.js).

   From the app: GridOverlayView draws 1pt lines between squares and 3pt lines between boxes,
   in Grid/Lines #BABABA, on top of the squares, with no outer border; the board is clipped to a
   30pt radius on a ~540pt board. CellBackground alternates Cell Primary #F9F9F7 and Cell
   Alternate #F7F7F4, givens are Cell Prefilled #F5F3F0. Numbers are Rubik Bold, about half the
   square's height (font size ~0.71 of the square); pencil marks are Rubik 14pt in a 60pt square,
   in Pencil #424242. CellHighlight lays Selection Primary #FAC842 over the selected square at
   60% and over its row, column and box at 20%.

   Sizes are in cqi of the board, so it scales as one piece; a square is 100/9 cqi. */

.app-board {
  --line: #bababa;
  --thin: max(1px, 0.19cqi);
  --thick: max(2px, 0.56cqi);
  --selection: 250 200 66;
  container-type: inline-size;
  display: grid;
  grid-template-columns: repeat(9, minmax(0, 1fr));
  grid-template-rows: repeat(9, minmax(0, 1fr));
  aspect-ratio: 1;
  width: 100%;
  border-radius: 5.6%;
  overflow: hidden;
  background: #f9f9f7;
  box-shadow:
    0 0 0 1px rgb(255 255 255 / 0.8),
    0 1.5rem 3rem -1.5rem rgb(33 33 33 / 0.35);
}

/* --l and --t are the widths of the lines on a square's left and top edges. */
.app-board > span {
  position: relative;
  display: grid;
  place-items: center;
  background-color: #f9f9f7;
  box-shadow:
    inset var(--l, 0) 0 0 0 var(--line),
    inset 0 var(--t, 0) 0 0 var(--line);
  font-size: 7.9cqi;
  font-weight: 700;
  line-height: 1;
  color: #121212;
}

.app-board > span.is-alt {
  background-color: #f7f7f4;
}

.app-board > span.is-given {
  background-color: #f5f3f0;
}

.app-board > span.is-highlighted {
  background-image: linear-gradient(rgb(var(--selection) / 0.2), rgb(var(--selection) / 0.2));
}

.app-board > span.is-selected {
  background-image: linear-gradient(rgb(var(--selection) / 0.6), rgb(var(--selection) / 0.6));
}

/* Pencil marks: digit d sits at position d of a 3×3 grid. Fewer marks read stronger, as in the
   app: full and bold with one or two left, 75% with three or four, 60% with five to eight. */
.app-board .marks {
  grid-area: 1 / 1;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-template-rows: repeat(3, minmax(0, 1fr));
  width: 84%;
  height: 84%;
  font-size: 2.6cqi;
  font-weight: 400;
  color: #424242;
}

.app-board .marks span {
  display: grid;
  place-items: center;
}

.app-board .marks.is-few {
  font-weight: 700;
}

.app-board .marks.is-some {
  opacity: 0.75;
}

.app-board .marks.is-many {
  opacity: 0.6;
}

/* A number the player places, in Pen #5F717F. */
.app-board .pen {
  grid-area: 1 / 1;
  color: #5f717f;
}

/* The selected square's lone candidate becomes the answer, and back again, on a loop. The
   number grows in from 70% as the app's does. */
.app-board .is-selected .marks {
  animation: app-board-marks 5s ease-in-out infinite;
}

.app-board .is-selected .pen {
  animation: app-board-pen 5s ease-in-out infinite;
}

@keyframes app-board-marks {
  0%, 35% { opacity: 1; }
  42%, 92% { opacity: 0; }
  100% { opacity: 1; }
}

@keyframes app-board-pen {
  0%, 35% { opacity: 0; transform: scale(0.7); }
  42%, 92% { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: scale(0.7); }
}

/* Without motion, show the answer in place. */
@media (prefers-reduced-motion: reduce) {
  .app-board .is-selected .pen {
    animation: none;
  }

  .app-board .is-selected .marks {
    animation: none;
    opacity: 0;
  }
}
