/* The sudoku page. Tokens come from site.css. */

.board-area {
  display: grid;
  gap: 1.25rem;
  justify-items: center;
}

/* --- the grid ------------------------------------------------------------ */

.board {
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  width: min(100%, 30rem);
  aspect-ratio: 1;
  border: 3px solid var(--line-strong);
  border-radius: 4px;
  background: var(--card);
  overflow: hidden;
  touch-action: manipulation;
}

.cell {
  position: relative;
  margin: 0;
  padding: 0;
  border: 0;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  font-family: inherit;
  font-size: clamp(1.1rem, 5.2vw, 1.75rem);
  font-variant-numeric: tabular-nums;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* The 3x3 box seams, drawn on the cells that sit at a box edge. */
.cell:nth-child(9n) { border-right: 0; }
.cell:nth-child(3n):not(:nth-child(9n)) { border-right: 2px solid var(--line-strong); }
.cell.row-edge { border-bottom: 2px solid var(--line-strong); }
.board > .cell:nth-last-child(-n+9) { border-bottom: 0; }

.cell.given  { font-weight: 650; }
.cell.placed { color: var(--accent); font-weight: 650; }

.cell.peer      { background: color-mix(in srgb, var(--line) 22%, transparent); }
.cell.selected  { background: var(--accent-soft); box-shadow: inset 0 0 0 2px var(--accent); }
.cell.conflict  { background: var(--warn-soft); color: var(--warn); }

/* Cells the current explanation is talking about. */
.cell.hl-unit    { background: color-mix(in srgb, var(--focus-soft) 55%, transparent); }
.cell.hl-support { background: var(--focus-soft); }
.cell.hl-primary {
  background: var(--focus);
  color: var(--paper);
  box-shadow: inset 0 0 0 2px var(--focus);
}
.cell.hl-primary.placed { color: var(--paper); }

.cell:focus-visible { outline: 3px solid var(--focus); outline-offset: -3px; z-index: 1; }

/* Pencil marks: the digits still possible in an empty square. */
.marks {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  width: 100%;
  height: 100%;
  padding: 8%;
  font-size: min(.42em, 3vw);
  font-weight: 500;
  line-height: 1;
  color: var(--ink-faint);
}
.marks span { display: flex; align-items: center; justify-content: center; }
.cell.hl-primary .marks { color: color-mix(in srgb, var(--paper) 80%, transparent); }

/* --- number pad ---------------------------------------------------------- */

.pad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: .5rem;
  width: min(100%, 22rem);
}

.pad button {
  padding: .85rem .2rem;
  font-family: inherit;
  font-size: 1.35rem;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
}

.pad button:hover { border-color: var(--accent); }
.pad button.erase { grid-column: span 3; font-size: 1rem; }

/* --- actions ------------------------------------------------------------- */

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  width: min(100%, 30rem);
}

.actions button {
  flex: 1 1 8rem;
  padding: .8rem 1rem;
  font-family: inherit;
  font-size: 1rem;
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
}

.actions button:hover:not(:disabled) { border-color: var(--accent); }
.actions button:disabled { opacity: .45; cursor: default; }

.actions button.primary {
  flex-basis: 100%;
  background: var(--accent);
  border-color: var(--accent);
  color: var(--paper);
  font-size: 1.1rem;
  font-weight: 600;
}

@media (prefers-color-scheme: dark) {
  .actions button.primary { color: #10201b; }
}

/* --- explanation --------------------------------------------------------- */

.explain {
  width: min(100%, 30rem);
  padding: 1.1rem 1.2rem;
  background: var(--card);
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius);
}

.explain.is-warning { border-left-color: var(--warn); }
.explain.is-guess   { border-left-color: var(--focus); }

.explain h2 { margin: 0 0 .4rem; font-size: 1.1rem; }
.explain p  { margin: 0 0 .6rem; }
.explain p:last-child { margin-bottom: 0; }

.explain .square {
  display: inline-block;
  padding: .05em .45em;
  background: var(--focus);
  color: var(--paper);
  border-radius: 4px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}

.chain { margin: .9rem 0 0; padding: 0; list-style: none; }

.chain > li { margin-top: .45rem; }

.chain button {
  display: block;
  width: 100%;
  padding: .55rem .7rem;
  text-align: left;
  font-family: inherit;
  font-size: .92rem;
  line-height: 1.45;
  color: var(--ink-soft);
  background: transparent;
  border: 1px dashed var(--line);
  border-radius: 8px;
  cursor: pointer;
}

.chain button:hover,
.chain button[aria-current="true"] {
  color: var(--ink);
  border-style: solid;
  border-color: var(--focus);
  background: color-mix(in srgb, var(--focus-soft) 60%, transparent);
}

.chain-heading {
  margin: 1rem 0 0;
  font-size: .82rem;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.toggle {
  display: flex;
  align-items: center;
  gap: .5rem;
  width: min(100%, 30rem);
  color: var(--ink-soft);
  font-size: .95rem;
  cursor: pointer;
}

.toggle input { width: 1.15rem; height: 1.15rem; accent-color: var(--accent); }

.help { width: min(100%, 30rem); color: var(--ink-soft); font-size: .93rem; }
.help summary { cursor: pointer; color: var(--ink); }
.help ol { padding-left: 1.2rem; }
