/*!
 * Blitzboard styles. Theme with the custom properties on .bb-board.
 * Copyright (c) 2026 Hugo Angelmar. All rights reserved.
 */

.bb-board {
  --bb-light: #f0d9b5;
  --bb-dark: #b58863;
  --bb-last: rgba(255, 214, 10, 0.32);
  --bb-selected: rgba(20, 110, 50, 0.45);
  --bb-dest: rgba(20, 110, 50, 0.5);
  --bb-anim-ms: 180ms;

  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  container-type: inline-size;   /* coordinates scale with the board (cqw units) */
  /* 8x8 squares: each 25% tile holds 2x2 squares, light at top-left (a8 from White's side) */
  background: repeating-conic-gradient(var(--bb-dark) 0 25%, var(--bb-light) 0 50%) 0 0 / 25% 25%;
  /* Taps don't double-tap-zoom; swipes outside pieces still scroll the page */
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

.bb-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

/* Pieces: positioned by transform (translate in multiples of 100% = one square) */
.bb-piece {
  position: absolute;
  left: 0;
  top: 0;
  width: 12.5%;
  height: 12.5%;
  background-size: cover;
  background-repeat: no-repeat;
  will-change: transform;
  pointer-events: auto;
  touch-action: none;   /* a touch that starts on a piece is for the board, not for scrolling */
  cursor: pointer;
}

.bb-piece.bb-animate {
  transition: transform var(--bb-anim-ms) ease;
}

.bb-piece.bb-dragging {
  z-index: 10;
  transition: none;
  cursor: grabbing;
}

.bb-piece.bb-fading {
  opacity: 0;
  transition: opacity var(--bb-anim-ms) ease;
  pointer-events: none;
}

/* Square marks: last move, selection, destinations, and app-defined flashes */
.bb-mark {
  position: absolute;
  left: 0;
  top: 0;
  width: 12.5%;
  height: 12.5%;
}

.bb-mark.bb-last {
  background: var(--bb-last);
}

.bb-mark.bb-selected {
  background: var(--bb-selected);
}

.bb-mark.bb-dest::after,
.bb-mark.bb-capture::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  box-sizing: border-box;
}

.bb-mark.bb-dest::after {
  width: 30%;
  height: 30%;
  background: var(--bb-dest);
}

.bb-mark.bb-capture::after {
  width: 92%;
  height: 92%;
  border: 0.6cqw solid var(--bb-dest);
}

/* Coordinates: file letters along the bottom, rank numbers along the left */
.bb-coord {
  position: absolute;
  width: 12.5%;
  height: 12.5%;
  box-sizing: border-box;
  padding: 0.6cqw 0.8cqw;
  font: 600 2.6cqw/1 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  pointer-events: none;
}

.bb-coord.bb-file {
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
}

.bb-coord.bb-on-light { color: var(--bb-dark); }
.bb-coord.bb-on-dark { color: var(--bb-light); }
