/* ==========================================================================
   Artisan Gambit — Interactive Chessboard & Game Annotation Styles
   ========================================================================== */

.game-meta-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 2rem;
  margin-top: 1.75rem;
  padding-top: 1.4rem;
  border-top: 1px solid rgba(245, 239, 230, 0.14);
  font-size: 0.875rem;
  color: #D5C8B9;
}

.game-meta-item strong {
  color: var(--brass-bright);
  font-weight: 600;
  margin-right: 0.35rem;
}

/* Main Interactive Layout */
.chess-studio {
  display: grid;
  grid-template-columns: minmax(320px, 560px) minmax(0, 1fr);
  gap: 2.5rem;
  align-items: start;
}

/* Left Column: Board Cabinet */
.board-cabinet {
  background: var(--espresso);
  border: 1px solid rgba(197, 155, 39, 0.3);
  border-radius: var(--radius-sm);
  padding: 1.25rem;
  box-shadow: var(--shadow-dark);
}

/* Player Bars (Top & Bottom of Board) */
.player-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.5rem 0.25rem;
  color: var(--cream);
  min-height: 38px;
}

.player-identity {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-width: 0;
}

.player-swatch {
  width: 12px;
  height: 12px;
  border-radius: 2px;
  border: 1px solid rgba(197, 155, 39, 0.55);
  flex-shrink: 0;
}

.player-swatch--white {
  background: var(--parchment);
}

.player-swatch--black {
  background: #2C1E16;
}

.player-name {
  font-family: var(--font-serif);
  font-size: 0.96rem;
  font-weight: 500;
  color: var(--cream);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.captured-tray {
  display: flex;
  align-items: center;
  gap: 0.12rem;
  min-height: 22px;
  flex-shrink: 0;
}

.captured-piece {
  width: 19px;
  height: 19px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  opacity: 0.9;
}

.captured-piece svg {
  width: 100%;
  height: 100%;
}

/* Walnut Frame around the 8x8 Board */
.board-frame {
  position: relative;
  padding: 10px;
  background: linear-gradient(145deg, #3E2A1E 0%, #241710 55%, #342217 100%);
  border: 1px solid rgba(197, 155, 39, 0.45);
  border-radius: 4px;
  box-shadow: inset 0 0 0 1px rgba(26, 18, 14, 0.8), 0 14px 28px rgba(0, 0, 0, 0.45);
}

.chessboard {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  width: 100%;
  aspect-ratio: 1 / 1;
  border: 1px solid rgba(26, 18, 14, 0.85);
  user-select: none;
  overflow: hidden;
}

.square {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.2s ease;
}

.square--light {
  background-color: #E7D9C1;
}

.square--dark {
  background-color: #7D573B;
}

/* Last-move highlights in warm aged brass */
.square--last-from.square--light {
  background-color: #DFC378;
}

.square--last-from.square--dark {
  background-color: #A47B33;
}

.square--last-to.square--light {
  background-color: #E5C158;
}

.square--last-to.square--dark {
  background-color: #B98C2B;
}

/* Check / Checkmate King highlight */
.square--check::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle, rgba(185, 38, 30, 0.72) 25%, rgba(185, 38, 30, 0.15) 75%, transparent 100%);
  pointer-events: none;
}

/* Coordinates */
.coord-rank,
.coord-file {
  position: absolute;
  font-family: var(--font-mono);
  font-size: 0.65rem;
  font-weight: 600;
  line-height: 1;
  pointer-events: none;
  opacity: 0.78;
}

.coord-rank {
  top: 3px;
  left: 4px;
}

.coord-file {
  bottom: 3px;
  right: 4px;
}

.square--light .coord-rank,
.square--light .coord-file {
  color: #5C3D28;
}

.square--dark .coord-rank,
.square--dark .coord-file {
  color: #EADBC4;
}

/* SVG Chess Pieces */
.piece {
  position: relative;
  z-index: 2;
  width: 84%;
  height: 84%;
  display: flex;
  align-items: center;
  justify-content: center;
  filter: drop-shadow(0 2px 2.5px rgba(20, 12, 8, 0.42));
  transition: transform 0.2s var(--ease);
}

.piece svg {
  width: 100%;
  height: 100%;
}

/* Board Controls Bar */
.board-controls {
  display: grid;
  grid-template-columns: 0.96fr 1.12fr 0.92fr 0.92fr 1.28fr;
  gap: 0.45rem;
  margin-top: 1rem;
}

.ctrl-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.34rem;
  padding: 0.66rem 0.45rem;
  background: var(--walnut);
  border: 1px solid rgba(197, 155, 39, 0.28);
  border-radius: var(--radius-xs);
  color: var(--cream);
  font-size: 0.76rem;
  font-weight: 500;
  letter-spacing: 0.03em;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color var(--transition), border-color var(--transition), color var(--transition);
}

.ctrl-btn:hover:not(:disabled) {
  background: var(--walnut-light);
  border-color: var(--brass);
  color: var(--brass-bright);
}

.ctrl-btn:disabled {
  opacity: 0.38;
  cursor: not-allowed;
}

.ctrl-btn--primary {
  background: var(--brass);
  border-color: var(--brass);
  color: var(--espresso);
  font-weight: 600;
}

.ctrl-btn--primary:hover:not(:disabled) {
  background: var(--brass-bright);
  border-color: var(--brass-bright);
  color: var(--espresso);
}

.ctrl-btn--active {
  background: rgba(197, 155, 39, 0.2);
  border-color: var(--brass);
  color: var(--brass-bright);
}

.board-shortcuts {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.8rem;
  padding-top: 0.7rem;
  border-top: 1px solid rgba(245, 239, 230, 0.1);
  font-size: 0.74rem;
  color: #A69888;
}

.board-shortcuts kbd {
  padding: 0.12rem 0.38rem;
  background: rgba(245, 239, 230, 0.08);
  border: 1px solid rgba(245, 239, 230, 0.16);
  border-radius: 3px;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--cream);
}

/* Right Column: Synchronized Commentary & Classical Scoresheet */
.analysis-column {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.commentary-card {
  background: #FAF6F0;
  border: 1px solid rgba(44, 30, 22, 0.16);
  border-top: 3px solid var(--brass);
  border-radius: var(--radius-sm);
  padding: 1.85rem;
  box-shadow: var(--shadow-card);
}

.commentary-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1rem;
  padding-bottom: 0.9rem;
  border-bottom: 1px solid rgba(44, 30, 22, 0.12);
}

.move-badge-group {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.current-move-san {
  font-family: var(--font-mono);
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--espresso);
  background: rgba(197, 155, 39, 0.18);
  border: 1px solid rgba(197, 155, 39, 0.45);
  padding: 0.2rem 0.65rem;
  border-radius: var(--radius-xs);
}

.move-phase-tag {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--brass-deep);
}

.ply-counter {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--slate);
}

.commentary-title {
  font-size: 1.45rem;
  color: var(--ink);
  margin-bottom: 0.75rem;
}

.commentary-text {
  font-family: var(--font-editorial);
  font-size: 1.02rem;
  line-height: 1.78;
  color: #3A322C;
  margin-bottom: 1.15rem;
}

.tactical-motif {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  padding: 0.85rem 1rem;
  background: var(--parchment-warm);
  border-left: 2px solid var(--walnut);
  border-radius: 0 var(--radius-xs) var(--radius-xs) 0;
  font-size: 0.88rem;
  color: var(--walnut);
}

.tactical-motif strong {
  text-transform: uppercase;
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  color: var(--brass-deep);
  display: block;
  margin-bottom: 0.15rem;
}

/* Classical Two-Column Scoresheet */
.scoresheet-card {
  background: #FAF6F0;
  border: 1px solid rgba(44, 30, 22, 0.16);
  border-radius: var(--radius-sm);
  overflow: hidden;
  box-shadow: 0 10px 28px -18px rgba(26, 18, 14, 0.2);
}

.scoresheet-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.9rem 1.35rem;
  background: var(--walnut);
  color: var(--cream);
}

.scoresheet-title {
  font-family: var(--font-serif);
  font-size: 1rem;
  color: var(--cream);
}

.scoresheet-result {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--brass-bright);
  letter-spacing: 0.08em;
}

.scoresheet-body {
  max-height: 310px;
  overflow-y: auto;
  padding: 0.5rem 0.75rem;
}

.move-row {
  display: grid;
  grid-template-columns: 42px 1fr 1fr;
  align-items: center;
  gap: 0.35rem;
  padding: 0.22rem 0.35rem;
  border-bottom: 1px solid rgba(44, 30, 22, 0.07);
}

.move-row:last-child {
  border-bottom: none;
}

.move-num {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: #827569;
  text-align: right;
  padding-right: 0.5rem;
}

.move-btn {
  width: 100%;
  text-align: left;
  padding: 0.36rem 0.65rem;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-xs);
  font-family: var(--font-mono);
  font-size: 0.86rem;
  color: var(--ink);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: background-color 0.16s ease, border-color 0.16s ease;
}

.move-btn:hover {
  background: rgba(197, 155, 39, 0.14);
}

.move-btn.is-active {
  background: var(--walnut);
  color: var(--brass-bright);
  border-color: var(--brass);
  font-weight: 600;
}

.move-nag {
  font-size: 0.72rem;
  color: var(--brass-deep);
  margin-left: 0.25rem;
}

.move-btn.is-active .move-nag {
  color: var(--cream);
}

/* Historical Context Band */
.history-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1.75rem;
}

.history-card {
  padding: 1.75rem;
  background: var(--espresso-elevated);
  border: var(--border-dark);
  border-radius: var(--radius-sm);
}

.history-card-label {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--brass);
  margin-bottom: 0.5rem;
}

.history-card h3 {
  font-size: 1.25rem;
  color: var(--cream);
  margin-bottom: 0.65rem;
}

.history-card p {
  font-size: 0.92rem;
  line-height: 1.68;
  color: var(--cream-muted);
}

/* Responsive Adjustments */
@media (max-width: 980px) {
  .chess-studio {
    grid-template-columns: 1fr;
  }

  .board-cabinet {
    max-width: 560px;
    width: 100%;
    margin: 0 auto;
  }

  .history-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 540px) {
  .board-cabinet {
    padding: 0.85rem;
  }

  .board-controls {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .board-controls .ctrl-btn--wide-mobile {
    grid-column: 1 / -1;
  }

  .commentary-card {
    padding: 1.35rem;
  }
}
