/* Chess Studio Styling - Apple Craftsmanship */

.chess-stage {
  width: 100%;
  height: 100%;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
  padding: 20px;
  background: radial-gradient(circle at 50% 50%, #101622 0%, #080b12 100%);
  overflow: hidden;
}

/* Main Chess Board Frame */
.chess-arena-container {
  display: flex;
  align-items: center;
  gap: 16px;
  position: relative;
}

/* Advantage Bar (Eval Gauge) */
.chess-eval-bar-wrapper {
  width: 22px;
  height: 520px;
  background: #1c1c1e;
  border-radius: var(--radius-pill);
  border: 1px solid var(--glass-border);
  overflow: hidden;
  position: relative;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column-reverse; /* White is at the bottom */
}

.chess-eval-fill {
  width: 100%;
  background: #f5f5f7;
  height: 50%; /* 50% is equal */
  transition: height 360ms var(--spring-ease);
}

.chess-eval-label {
  position: absolute;
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 9px;
  font-family: var(--font-mono);
  font-weight: 700;
  color: #a1a1a6;
  pointer-events: none;
}

/* The Chess Board */
.chess-board-frame {
  width: 520px;
  height: 520px;
  padding: 12px;
  border-radius: var(--radius-xl);
  background: linear-gradient(135deg, #2c2523 0%, #151110 100%);
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 
    0 32px 70px rgba(0, 0, 0, 0.8),
    inset 0 1px 2px rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.chess-grid {
  width: 100%;
  height: 100%;
  border-radius: var(--radius-md);
  overflow: hidden;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  position: relative;
  box-shadow: inset 0 0 12px rgba(0, 0, 0, 0.6);
}

.chess-square {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background-color 150ms ease;
}

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

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

.chess-square.selected {
  background-color: rgba(10, 132, 255, 0.45) !important;
}

.chess-square.last-move {
  background-color: var(--chess-last-move) !important;
}

.chess-square.in-check {
  background-color: rgba(255, 69, 58, 0.6) !important;
  animation: pulse-check 1s infinite alternate;
}

@keyframes pulse-check {
  from { box-shadow: inset 0 0 10px rgba(255, 69, 58, 0.5); }
  to { box-shadow: inset 0 0 25px rgba(255, 69, 58, 0.9); }
}

/* Move Destination Dots */
.chess-square.valid-dest::after {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  border-radius: var(--radius-pill);
  background: rgba(10, 132, 255, 0.65);
  box-shadow: 0 0 8px rgba(10, 132, 255, 0.4);
  pointer-events: none;
}

.chess-square.valid-capture::after {
  content: "";
  position: absolute;
  inset: 4px;
  border-radius: var(--radius-sm);
  border: 3px solid rgba(255, 69, 58, 0.7);
  box-shadow: 0 0 12px rgba(255, 69, 58, 0.5);
  pointer-events: none;
}

/* Chess Pieces */
.chess-piece {
  width: 82%;
  height: 82%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: grab;
  z-index: 10;
  transition: transform 120ms var(--spring-ease);
  filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.45));
}

.chess-piece:hover {
  transform: scale(1.08);
}

.chess-piece:active, .chess-piece.dragging {
  cursor: grabbing;
  transform: scale(1.18);
  filter: drop-shadow(0 14px 22px rgba(0, 0, 0, 0.65));
  z-index: 100;
}

.chess-piece svg {
  width: 100%;
  height: 100%;
  pointer-events: none;
}

/* Square Coordinates */
.square-coord {
  position: absolute;
  font-size: 10px;
  font-weight: 700;
  font-family: var(--font-mono);
  opacity: 0.6;
  pointer-events: none;
}

.coord-file { bottom: 2px; right: 3px; }
.coord-rank { top: 2px; left: 3px; }

/* Chess Side Panel (Player cards, Clocks, Move History, Evaluation) */
.chess-side-panel {
  width: 320px;
  height: 520px;
  background: var(--glass-bg);
  backdrop-filter: blur(24px) saturate(180%);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-xl);
  padding: 18px;
  box-shadow: var(--glass-shadow);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 12px;
}

/* Player Clocks */
.chess-player-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
}

.chess-player-strip.active {
  border-color: var(--apple-blue);
  background: rgba(10, 132, 255, 0.1);
}

.chess-clock {
  font-size: 20px;
  font-weight: 700;
  font-family: var(--font-mono);
  color: #fff;
  padding: 2px 10px;
  border-radius: var(--radius-sm);
  background: rgba(0, 0, 0, 0.4);
}

.chess-clock.low-time {
  color: var(--apple-red);
  animation: pulse-clock 0.6s infinite alternate;
}

@keyframes pulse-clock {
  from { opacity: 0.7; }
  to { opacity: 1; }
}

/* Move History Timeline */
.chess-history-box {
  flex: 1;
  background: rgba(0, 0, 0, 0.3);
  border-radius: var(--radius-md);
  border: 1px solid var(--glass-border);
  padding: 10px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-family: var(--font-mono);
  font-size: 13px;
}

.history-row {
  display: grid;
  grid-template-columns: 32px 1fr 1fr;
  align-items: center;
  padding: 3px 6px;
  border-radius: 4px;
}

.history-row:hover {
  background: rgba(255, 255, 255, 0.05);
}

.move-num {
  color: #636366;
  font-size: 11px;
}

.move-item {
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.move-item:hover {
  background: rgba(255, 255, 255, 0.12);
}

.move-item.current {
  background: rgba(10, 132, 255, 0.3);
  color: #fff;
}

/* Move Quality Badges */
.badge-brilliant { color: #30d158; font-weight: 800; }
.badge-blunder { color: #ff453a; font-weight: 800; }
.badge-best { color: #0a84ff; font-weight: 800; }

/* Timeline Controls */
.history-controls {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: 6px;
}

/* Opening Name Banner */
.opening-banner {
  padding: 6px 10px;
  background: rgba(255, 214, 10, 0.1);
  border: 1px solid rgba(255, 214, 10, 0.25);
  border-radius: var(--radius-sm);
  color: #ffd60a;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
