/* Knight's Tour — chessboard + tour rendering.
   Colours follow the classic chess scheme (chess.com / lichess defaults).
   Single ink colour for all text — keeps numbers legible on both field
   shades. Tour line is drawn on an SVG overlay above the grid. */

:root {
  --board-cell:    60px;
  --color-light:   #f0d9b5;
  --color-dark:    #b58863;
  --color-ink:     #3a2410;
  --color-border:  #3a2410;
  --color-accent:        #c0392b;  /* tour line, stop button, focus ring on cells */
  --color-accent-shadow: #8a2618;  /* darker variant for borders/contrast */
}

body {
  font-family: system-ui, -apple-system, sans-serif;
  color: var(--color-ink);
  margin: 2rem;
}

h1 {
  font-size: 1.4rem;
  margin: 0 0 1rem;
  cursor: pointer;  /* signals 'click to reset' affordance (tooltip explains) */
  user-select: none;
  width: max-content;  /* so the clickable surface matches the visible text */
}

#controls, #controls2, #controls3 {
  margin-bottom: 0.6rem;
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
#controls3 {
  margin-bottom: 1rem;
}

#controls label, #controls2 label, #controls3 label {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.95rem;
}
#controls3 label { cursor: pointer; }

#controls input, #controls2 select {
  padding: 0.2rem 0.4rem;
  font: inherit;
  color: var(--color-ink);
}
#controls input {
  width: 5rem;
}

#controls2 button {
  padding: 0.25rem 0.7rem;
  font: inherit;
  color: var(--color-ink);
  background: var(--color-light);
  border: 1px solid var(--color-border);
  border-radius: 3px;
  cursor: pointer;
}
#controls2 button:hover { filter: brightness(1.05); }

#board {
  position: relative;
  z-index: 0;  /* form a stacking context: tour line above cells, numbers above line */
  display: grid;
  /* grid dimensions and width/height set inline by JS (see buildBoard) */
  border: 2px solid var(--color-border);
}

.cell {
  position: relative;
  cursor: pointer;
  transition: filter 0.1s;
}
.cell:hover { filter: brightness(1.07); }

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

/* Blocked cells: solid dark grey with a diagonal hatch overlay. Comes
   after .light/.dark so its specificity-equal rule wins by source order. */
.cell.blocked {
  background-color: #4a4a4a;
  background-image: repeating-linear-gradient(
    45deg,
    transparent 0,
    transparent 4px,
    rgba(255, 255, 255, 0.18) 4px,
    rgba(255, 255, 255, 0.18) 8px
  );
  cursor: not-allowed;
}

.num {
  position: absolute;
  inset: 0;
  z-index: 2;
  /* display toggled via --num-display; flex for centering when shown */
  display: var(--num-display, flex);
  align-items: center;
  justify-content: center;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: calc(var(--board-cell) * 0.32);
  color: var(--color-ink);
  pointer-events: none;
}

#overlay {
  position: absolute;
  inset: 0;
  z-index: 1;
  /* display toggled via --overlay-display; block when shown */
  display: var(--overlay-display, block);
  width: 100%;
  height: 100%;
  pointer-events: none;
}

#search-controls {
  margin-top: 0.6rem;
  min-height: 1.8rem;  /* reserve space so the layout doesn't jump when buttons toggle */
  display: flex;
  gap: 0.6rem;
}
#stop-btn, #sensitivity-btn {
  padding: 0.25rem 0.9rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.95rem;
  border-radius: 3px;
  cursor: pointer;
}
#stop-btn {
  color: #fff;
  background: var(--color-accent);
  border: 1px solid var(--color-accent-shadow);
}
#sensitivity-btn {
  color: var(--color-ink);
  background: var(--color-light);
  border: 1px solid var(--color-border);
}
#stop-btn:hover, #sensitivity-btn:hover { filter: brightness(1.06); }

.cell .num.sens { font-size: calc(var(--board-cell) * 0.28); }

#status, #status2 {
  margin-top: 0.3rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 1rem;
  color: var(--color-ink);
}

#footer-links {
  margin-top: 1.2rem;
  font-size: 0.9rem;
  color: var(--color-ink);
}
#footer-links a { color: var(--color-accent); }
#footer-links .sep { margin: 0 0.4rem; color: var(--color-border); }

/* a11y: visible focus ring on keyboard navigation. :focus-visible only
   activates for keyboard or otherwise-keyboard-equivalent focus, so mouse
   clicks don't leave a lingering outline. z-index lifts it above numbers. */
.cell:focus-visible {
  outline: 3px solid var(--color-accent);
  outline-offset: -3px;
  z-index: 3;
}
#controls input:focus-visible,
#controls select:focus-visible,
#controls2 select:focus-visible,
#controls2 button:focus-visible,
#controls3 select:focus-visible,
#controls3 input[type="checkbox"]:focus-visible,
#search-controls button:focus-visible {
  outline: 2px solid var(--color-ink);
  outline-offset: 2px;
}
