/* ============================================================
   board.css — Chess board layout and highlights
   ============================================================ */

.board-column {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  align-items: flex-start;
  flex-shrink: 0;
}

/* Eval bar + board sit side by side inside this inner row */
.board-inner {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
}

.chess-board {
  width: min(500px, calc(100vw - 400px));
  min-width: 280px;
  position: relative; /* required for SVG arrow overlay */
}

/* Material count rows (above and below board) */
.material-count {
  font-size: 1rem;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  min-height: 1.4em;
  padding: 0 2px;
  /* align with the board, not the eval bar */
  padding-left: calc(20px + 0.75rem); /* eval-bar width + gap */
}

/* --- Eval bar --- */
.eval-bar-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
}

.eval-bar-track {
  width: 20px;
  height: min(500px, calc(100vw - 400px));
  min-height: 280px;
  background: #0d2030;
  border-radius: 4px;
  position: relative;
  overflow: hidden;
}

.eval-bar-fill {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: #f5f5f5;
  height: 50%;  /* starts at equal */
  transition: height 0.4s ease;
}

.eval-label {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.02em;
  writing-mode: horizontal-tb;
}

.eval-label.white-ahead { color: #f5f5f5; }
.eval-label.black-ahead { color: #7a94a8; }

/* --- Square highlights --- */

/* Last move - subtle yellow tint */
.highlight-last-move {
  box-shadow: inset 0 0 0 3px rgba(255, 215, 0, 0.6) !important;
}

/* Engine / Stockfish move - blue */
.highlight-engine-move {
  box-shadow: inset 0 0 0 3px rgba(33, 150, 243, 0.7) !important;
}

/* Best move (review mode) - green */
.highlight-best-move {
  box-shadow: inset 0 0 0 3px rgba(76, 175, 80, 0.8) !important;
}

/* Quiz position highlight - purple */
.highlight-quiz {
  box-shadow: inset 0 0 0 3px rgba(156, 39, 176, 0.7) !important;
}

/* Variation exploration highlight - teal */
.highlight-variation {
  box-shadow: inset 0 0 0 3px rgba(0, 188, 212, 0.75) !important;
}

/* ============================================================
   Mobile board sizing
   ============================================================ */
@media (max-width: 768px) {
  .board-column {
    width: 100%;
    align-items: stretch;
  }

  .board-inner {
    gap: 0.5rem;
  }

  /* Board fills viewport width minus eval bar (20px) + gaps (1.5rem + padding) */
  .chess-board {
    width: calc(100vw - 20px - 1rem - 3rem);
    min-width: unset;
  }

  .eval-bar-track {
    height: calc(100vw - 20px - 1rem - 3rem);
    min-height: unset;
  }

  /* Material count: remove the left offset since it's inside a flex column anyway */
  .material-count {
    padding-left: calc(20px + 0.5rem);
  }
}

/* Override chessboard.js defaults to fit dark theme */
#board .square-55d63 {
  transition: box-shadow 0.15s;
  position: relative;  /* needed for ::after pseudo-elements */
}

/* Dragging piece cursor */
#board .piece-417db {
  cursor: grab;
}

/* Selected piece square — yellow tint */
.highlight-selected {
  background-color: rgba(246, 246, 105, 0.5) !important;
}

/* Legal move — dot on empty squares */
.highlight-legal-move::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 34%;
  height: 34%;
  background: rgba(0, 0, 0, 0.45);
  border-radius: 50%;
  pointer-events: none;
  z-index: 10;
}

/* Legal capture — ring around occupied squares */
.highlight-legal-capture::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 90%;
  height: 90%;
  background: transparent;
  border: 6px solid rgba(0, 0, 0, 0.45);
  border-radius: 50%;
  pointer-events: none;
  z-index: 10;
}

/* --- Coach highlights (I'm Stuck panel) --- */

/* Checking moves we can give — bright cyan */
.highlight-coach-check {
  box-shadow: inset 0 0 0 3px rgba(0, 229, 255, 0.85) !important;
}

/* Our available captures — bright green */
.highlight-coach-capture {
  box-shadow: inset 0 0 0 3px rgba(0, 230, 118, 0.85) !important;
}

/* Our hanging pieces (opponent can take) — orange */
.highlight-coach-hanging {
  box-shadow: inset 0 0 0 3px rgba(255, 152, 0, 0.9) !important;
}

/* Opponent threats (they can take our pieces) — red */
.highlight-coach-threat {
  box-shadow: inset 0 0 0 3px rgba(244, 67, 54, 0.85) !important;
}
