/* ─── THOR Chess — Board Styles ─── */
/* Custom dark theme for chessboard.js */

/* ─── Board Container ─── */
.chess-board-container {
  position: relative;
}

/* ─── Puzzle Tabs ─── */
.puzzle-tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--border-default);
  margin-bottom: 1rem;
}

.puzzle-tab {
  flex: 1;
  padding: 0.6rem 1rem;
  background: transparent;
  border: none;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  color: var(--text-muted);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}

.puzzle-tab:hover {
  color: var(--text-primary);
}

.puzzle-tab-active {
  color: var(--color-cyan, #00E5FF) !important;
  border-bottom-color: var(--color-cyan, #00E5FF) !important;
}

/* ─── Chessboard.js Overrides ─── */
#board .board-b72b1 {
  border: 2px solid var(--border-default) !important;
  border-radius: var(--radius-sm);
  overflow: hidden;
  box-shadow: var(--shadow-card);
}

/* Dark square — clásico madera oscura */
#board .black-3c85d,
#mental-board .black-3c85d,
#puzzle-board .black-3c85d {
  background-color: #b58863 !important;
}

/* Light square — clásico crema */
#board .white-1e1d7,
#mental-board .white-1e1d7,
#puzzle-board .white-1e1d7 {
  background-color: #f0d9b5 !important;
}

/* Highlight: last move (from) */
.highlight-from {
  background: rgba(0, 229, 255, 0.35) !important;
  box-shadow: inset 0 0 0 3px rgba(0, 229, 255, 0.6);
}

/* Highlight: last move (to) */
.highlight-to {
  background: rgba(0, 229, 255, 0.25) !important;
  box-shadow: inset 0 0 0 3px rgba(0, 229, 255, 0.5);
}

/* Highlight: selected piece */
.highlight-selected {
  background: rgba(255, 235, 59, 0.4) !important;
  box-shadow: inset 0 0 0 3px rgba(255, 235, 59, 0.7);
}

/* Highlight: legal move target (dot) */
.highlight-legal {
  position: relative;
}

.highlight-legal::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 30%;
  height: 30%;
  background: rgba(0, 229, 255, 0.5);
  border-radius: 50%;
  pointer-events: none;
}

/* Highlight: legal capture target (ring) */
.highlight-capture::after {
  width: 90%;
  height: 90%;
  background: transparent;
  border: 3px solid rgba(0, 229, 255, 0.5);
  border-radius: 50%;
}

/* Click-to-move (persistent — chessboard.js no las borra) */
.thor-sel {
  background: rgba(255, 235, 59, 0.45) !important;
  box-shadow: inset 0 0 0 3px rgba(255, 235, 59, 0.8);
}
.thor-leg {
  position: relative;
}
.thor-leg::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 30%;
  height: 30%;
  background: rgba(0, 229, 255, 0.55);
  border-radius: 50%;
  pointer-events: none;
  z-index: 2;
}
.thor-cap::after {
  width: 88%;
  height: 88%;
  background: transparent;
  border: 3px solid rgba(0, 229, 255, 0.55);
  border-radius: 50%;
}

/* Hint: from square */
.highlight-hint-from {
  background: rgba(255, 210, 0, 0.55) !important;
  box-shadow: inset 0 0 0 3px rgba(255, 210, 0, 0.85);
}

/* Hint: to square (movimiento sin captura) */
.highlight-hint-to {
  background: rgba(255, 210, 0, 0.28) !important;
  box-shadow: inset 0 0 0 3px rgba(255, 210, 0, 0.55);
}

/* Hint: captura — rojo para dejar claro que se come una pieza enemiga */
.highlight-hint-capture {
  background: rgba(233, 30, 99, 0.40) !important;
  box-shadow: inset 0 0 0 3px rgba(233, 30, 99, 0.80);
}

/* King in check */
.highlight-check {
  background: rgba(233, 30, 99, 0.6) !important;
  box-shadow: inset 0 0 0 3px rgba(233, 30, 99, 0.9);
  animation: check-pulse 0.8s ease-in-out 2;
}

@keyframes check-pulse {
  0%, 100% { background: rgba(233, 30, 99, 0.6) !important; }
  50%       { background: rgba(233, 30, 99, 0.9) !important; }
}

/* ─── Piece sizing — reemplaza chessboard.js CSS que falla al cargar desde CDN ─── */
.board-b72b1 .square-55d63 {
  position: relative;
}

.board-b72b1 img {
  border: none;
  display: block;
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

.board-b72b1 .piece-417db {
  z-index: 1;
}

.board-b72b1 .clearfix-7da63 {
  clear: both;
}

/* ─── Fix: tablero creado con ancho 0 (pantalla oculta al inicializar) ─── */
/* chessboard.js escribe width:0px;height:0px inline (sin !important).    */
/* CSS !important gana sobre inline sin !important — no se necesita JS.   */
#board .board-b72b1,
#mental-board .board-b72b1,
#puzzle-board .board-b72b1 {
  width: 100% !important;
  height: auto !important;
}

#board .square-55d63,
#mental-board .square-55d63,
#puzzle-board .square-55d63 {
  float: left !important;
  position: relative !important;
  overflow: hidden !important;
  padding: 0 !important;
  width: 12.5% !important;
  height: auto !important;
  aspect-ratio: 1 !important;
}

#board img.piece-417db,
#mental-board img.piece-417db,
#puzzle-board img.piece-417db {
  position: absolute !important;
  width: 100% !important;
  height: 100% !important;
  top: 0 !important;
  left: 0 !important;
}

#board .clearfix-7da63,
#mental-board .clearfix-7da63,
#puzzle-board .clearfix-7da63 {
  clear: both !important;
}

/* ─── Coordinate Labels ─── */
.coord-label {
  position: absolute;
  font-family: var(--font-mono);
  font-size: 0.625rem;
  font-weight: 700;
  color: var(--text-muted);
  pointer-events: none;
  user-select: none;
}

/* ─── Promotion Dialog ─── */
.promotion-dialog {
  position: absolute;
  z-index: 200;
  background: var(--bg-surface);
  border: 1px solid var(--border-accent);
  border-radius: var(--radius-md);
  display: flex;
  gap: 0.25rem;
  padding: 0.5rem;
  box-shadow: var(--shadow-glow), var(--shadow-card);
}

.promotion-piece {
  width: 56px;
  height: 56px;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: background var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: center;
}

.promotion-piece:hover {
  background: var(--bg-hover);
}

/* ─── Touch enhancements ─── */
@media (pointer: coarse) {
  /* Larger touch targets for drag feedback */
  #board .board-b72b1 .square-55d63 {
    touch-action: none;
  }

  /* Bigger visual dot for legal moves on touch */
  .highlight-legal::after {
    width: 38%;
    height: 38%;
  }
}
