/**
 * Chess Master Stylesheet - Popyca Games
 *
 * Warm cream, slate, and terracotta visual aesthetic.
 * 8x8 responsive board, piece glyphs, legal destination dots, captured pieces tray.
 */

:root {
  --chess-sq-light: #faf6ee;
  --chess-sq-dark: #bba68d;
  --chess-sq-selected: #f6d899;
  --chess-sq-lastmove: #e9e0b8;
  --chess-sq-check: #fed7d7;

  --chess-board-size: min(92vw, 440px);
}

@media (min-width: 600px) {
  :root {
    --chess-board-size: 440px;
  }
}

/* Chess Top Bar: Mode Selector & Status */
.chess-meta-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  max-width: var(--chess-board-size);
  margin-bottom: 10px;
  font-size: 13px;
  font-weight: 700;
  color: var(--color-slate);
}

.chess-mode-tabs {
  display: flex;
  gap: 4px;
  background: #e2dbcd;
  padding: 3px;
  border-radius: 8px;
}

.chess-tab-btn {
  background: transparent;
  border: none;
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 700;
  color: var(--color-slate);
  cursor: pointer;
  transition: all 0.15s ease;
}

.chess-tab-btn.active {
  background: #ffffff;
  color: var(--color-primary);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.turn-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 700;
  background: #ffffff;
  border: 1px solid var(--color-border);
}

.turn-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 1px solid #718096;
}

.turn-dot.white {
  background: #ffffff;
}

.turn-dot.black {
  background: #2d3748;
}

/* Captured Pieces Trays */
.captured-tray {
  width: 100%;
  max-width: var(--chess-board-size);
  min-height: 24px;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 2px 4px;
  font-size: 16px;
  color: var(--color-charcoal);
  user-select: none;
}

/* 8x8 Chess Board Container */
.chess-board-wrapper {
  width: var(--chess-board-size);
  height: var(--chess-board-size);
  border: 4px solid #5a4b3d;
  border-radius: 8px;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.1);
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  user-select: none;
  touch-action: manipulation;
  position: relative;
  overflow: hidden;
}

/* Board Squares */
.chess-square {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background-color 0.1s ease;
}

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

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

.chess-square.selected {
  background: var(--chess-sq-selected) !important;
}

.chess-square.last-move {
  background: var(--chess-sq-lastmove);
}

.chess-square.in-check {
  background: var(--chess-sq-check) !important;
  box-shadow: inset 0 0 0 3px #e53e3e;
}

/* Legal Move Indicator Dot */
.move-dest-dot {
  position: absolute;
  width: 28%;
  height: 28%;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.18);
  pointer-events: none;
}

/* Legal Move Capture Ring */
.move-capture-ring {
  position: absolute;
  width: 82%;
  height: 82%;
  border-radius: 50%;
  border: 4px solid rgba(226, 105, 56, 0.55);
  pointer-events: none;
}

/* Chess Pieces */
.chess-piece {
  font-size: calc(var(--chess-board-size) / 10.5);
  line-height: 1;
  pointer-events: none;
  filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.25));
}

.chess-piece.white {
  color: #fffefb;
  text-shadow: 0 1px 2px #4a3d31, 0 0 1px #222;
}

.chess-piece.black {
  color: #24201c;
  text-shadow: 0 1px 1px rgba(255, 255, 255, 0.3);
}

/* Chess Bottom Controls */
.chess-controls-bar {
  display: flex;
  justify-content: space-between;
  width: 100%;
  max-width: var(--chess-board-size);
  margin-top: 12px;
}

.chess-action-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background: #ffffff;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 700;
  color: var(--color-charcoal);
  cursor: pointer;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.04);
  transition: all 0.15s ease;
}

.chess-action-btn:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
}

/* Move Log Box */
.chess-moves-log {
  width: 100%;
  max-width: var(--chess-board-size);
  height: 38px;
  background: #f7f3eb;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  margin-top: 10px;
  padding: 8px 12px;
  font-size: 12px;
  font-family: monospace;
  color: var(--color-slate);
  overflow-x: auto;
  white-space: nowrap;
}
