/* ═══════════════════════════════════════════════════════════════
   BOARD — échiquier, cases, pièces, indicateurs cylindriques
   ═══════════════════════════════════════════════════════════════ */

/* ── Player Bars ──────────────────────────────────────────────── */

.player-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: calc(var(--board-size) + 36px);
  padding: 8px 14px;
  border-radius: var(--radius-md);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  transition: all var(--transition-med);
}

.player-bar.active {
  border-color: var(--color-primary);
  box-shadow: 0 0 20px var(--color-primary-glow);
}

.player-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.player-avatar {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  font-size: 22px;
}

.white-avatar { background: rgba(255,255,255,0.1); }
.black-avatar { background: rgba(255,255,255,0.05); }

.player-name {
  font-weight: 600;
  font-size: 13px;
}

.captured-pieces {
  display: flex;
  flex-wrap: wrap;
  gap: 1px;
  font-size: 14px;
  opacity: 0.7;
  max-width: 200px;
}

.player-timer {
  font-family: 'JetBrains Mono', monospace;
  font-size: 18px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  background: var(--color-surface-2);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.05em;
}

/* ── Board Wrapper ────────────────────────────────────────────── */

.board-wrapper {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
}

.board-container {
  display: flex;
  align-items: center;
  position: relative;
}

.board {
  display: grid;
  grid-template-columns: repeat(8, var(--sq-size));
  grid-template-rows: repeat(8, var(--sq-size));
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-board);
  border: 2px solid rgba(255,255,255,0.08);
  position: relative;
  /* Empêche la sélection de texte pendant le drag */
  user-select: none;
}

/* ── Labels ───────────────────────────────────────────────────── */

.rank-labels {
  display: flex;
  flex-direction: column;
  height: var(--board-size);
}

.rank-labels .label {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
  color: var(--color-text-faint);
  width: 18px;
}

.file-labels {
  display: flex;
  width: var(--board-size);
  margin-left: 18px;
  margin-top: 2px;
}

.file-labels .label {
  flex: 1;
  text-align: center;
  font-size: 11px;
  font-weight: 600;
  color: var(--color-text-faint);
  padding-top: 3px;
}

/* ── Cylinder Indicators ──────────────────────────────────────── */

.cylinder-indicator {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 28px;
  opacity: 0.25;
  transition: opacity var(--transition-med);
  z-index: 2;
}

.cylinder-indicator.left { left: -8px; }
.cylinder-indicator.right { right: -8px; }

.cylinder-indicator:hover { opacity: 0.5; }

.cylinder-arrow {
  font-size: 20px;
  color: var(--color-primary);
  animation: pulse-arrow 2.5s ease-in-out infinite;
}

.cylinder-indicator.left .cylinder-arrow { animation-delay: 0s; }
.cylinder-indicator.right .cylinder-arrow { animation-delay: 1.25s; }

/* ── Squares ──────────────────────────────────────────────────── */

.square {
  width: var(--sq-size);
  height: var(--sq-size);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  /* Curseur grab sur les cases occupées par une pièce jouable */
  cursor: pointer;
  user-select: none;
  transition: none;
}

/* Curseur grab quand une pièce du joueur est sur la case */
.square.has-draggable {
  cursor: grab;
}

/* Pendant un drag actif, tout le plateau passe en grabbing */
.board.is-dragging .square {
  cursor: grabbing !important;
}

.square.light { background: var(--sq-light); }
.square.dark  { background: var(--sq-dark); }

/* Selected */
.square.selected.light { background: var(--sq-light-highlight); }
.square.selected.dark  { background: var(--sq-dark-highlight); }

/* Last move */
.square.last-move.light { background: color-mix(in srgb, var(--sq-light) 60%, #b8cc3a 40%); }
.square.last-move.dark  { background: color-mix(in srgb, var(--sq-dark) 60%, #8a9a2a 40%); }

/* Check highlight */
.square.in-check.light {
  background: radial-gradient(ellipse at center, rgba(255,0,0,0.7) 0%, rgba(255,0,0,0.3) 40%, var(--sq-light) 70%);
}
.square.in-check.dark {
  background: radial-gradient(ellipse at center, rgba(255,0,0,0.7) 0%, rgba(255,0,0,0.3) 40%, var(--sq-dark) 70%);
}

/* Move dots */
.square.legal-move::after {
  content: '';
  position: absolute;
  width: 26%;
  height: 26%;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.2);
  pointer-events: none;
}

.square.legal-capture::after {
  content: '';
  position: absolute;
  width: 85%;
  height: 85%;
  border-radius: 50%;
  border: 5px solid rgba(0, 0, 0, 0.2);
  background: transparent;
  pointer-events: none;
}

/* ── Pièces SVG ───────────────────────────────────────────────── */

.piece {
  width:  calc(var(--sq-size) * 0.84);
  height: calc(var(--sq-size) * 0.84);
  object-fit: contain;
  filter: drop-shadow(1px 2px 3px rgba(0, 0, 0, 0.55));
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
  transition: transform 0.08s ease, filter 0.08s ease, opacity 0.06s ease;
  z-index: 1;
}

.square:hover .piece {
  transform: scale(1.07);
  filter: drop-shadow(1px 3px 6px rgba(0, 0, 0, 0.65));
}

/* La pièce source devient semi-transparente pendant le drag
   pour indiquer qu'elle est "en l'air" */
.square.drag-source .piece {
  opacity: 0.25;
  transform: none !important;  /* pas d'agrandissement au hover */
}

/* ── Ghost de drag (pièce qui suit le curseur) ────────────────── */

.piece-dragging {
  position: fixed;
  width:  calc(var(--sq-size) * 1.0);   /* légèrement plus grande que sur le plateau */
  height: calc(var(--sq-size) * 1.0);
  object-fit: contain;
  pointer-events: none;                  /* ne bloque pas elementFromPoint */
  z-index: 1000;
  filter: drop-shadow(2px 5px 12px rgba(0, 0, 0, 0.7));
  transform: translate(-50%, -50%);      /* centré sur le curseur */
  /* Pas de transition : suit le curseur en temps réel */
}

/* ── Case survolée pendant un drag ───────────────────────────── */

.square.drag-over.light {
  background: color-mix(in srgb, var(--sq-light) 50%, rgba(74,168,124,0.5) 50%);
}
.square.drag-over.dark {
  background: color-mix(in srgb, var(--sq-dark) 50%, rgba(74,168,124,0.5) 50%);
}

/* Wrap-around edge glow */
.square.wrap-edge-left::before {
  content: '';
  position: absolute;
  left: 0; top: 0;
  width: 4px; height: 100%;
  background: linear-gradient(to right, rgba(74, 168, 124, 0.3), transparent);
  pointer-events: none;
  z-index: 1;
}
.square.wrap-edge-right::before {
  content: '';
  position: absolute;
  right: 0; top: 0;
  width: 4px; height: 100%;
  background: linear-gradient(to left, rgba(74, 168, 124, 0.3), transparent);
  pointer-events: none;
  z-index: 1;
}

/* ── Arrow Overlay (Beginner Mode) ────────────────────────────── */

.arrow-overlay {
  position: absolute;
  inset: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  z-index: 5;
  overflow: visible;
}

.arrow-overlay .arrow-path {
  fill: none;
  stroke: rgba(74, 168, 124, 0.6);
  stroke-width: 5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.arrow-overlay .arrow-path.capture-arrow {
  stroke: rgba(224, 85, 85, 0.6);
}

.arrow-overlay .arrow-head {
  fill: rgba(74, 168, 124, 0.75);
  stroke: none;
}

.arrow-overlay .arrow-head.capture-head {
  fill: rgba(224, 85, 85, 0.75);
}

.arrow-overlay .arrow-wrap-portal {
  fill: none;
  stroke: rgba(74, 168, 124, 0.35);
  stroke-width: 3;
  stroke-dasharray: 6 4;
}

/* ── Check Threat Path (Beginner Mode) ──────────────────────── */

.square.check-threat.light {
  background: color-mix(in srgb, var(--sq-light) 55%, rgba(200, 60, 60, 0.5) 45%);
}
.square.check-threat.dark {
  background: color-mix(in srgb, var(--sq-dark) 55%, rgba(200, 60, 60, 0.5) 45%);
}
