/* ============================================================
   style.css — Šachová hra
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500;700&family=Roboto+Mono:wght@400;500&display=swap');

/* --- CSS proměnné (přepisuje JS) --- */
:root {
  --sq-light:     #f0d9b5;
  --sq-dark:      #b58863;
  --sq-highlight: rgba(20, 85, 30, 0.5);
  --sq-lastmove:  rgba(155, 199, 0, 0.41);
  --bg-main:      #1a1a2e;
  --bg-panel:     #16213e;
  --bg-card:      #0f3460;
  --accent:       #e94560;
  --text-primary: #eaeaea;
  --text-muted:   #8a8a9a;
  --border:       rgba(255,255,255,0.08);
  --navbar-h:     56px;
}

/* --- Reset & base --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; height: 100%; }
body {
  font-family: 'Roboto', sans-serif;
  background: var(--bg-main);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ============================================================
   NAVBAR
   ============================================================ */
.navbar {
  height: var(--navbar-h);
  background: #0a0a1a;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
  gap: 1rem;
  flex-shrink: 0;
  z-index: 100;
  position: sticky;
  top: 0;
}

.navbar-brand {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text-primary);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: .5rem;
}

.navbar-brand .icon { font-size: 1.6rem; }
.navbar-spacer { flex: 1; }
.navbar-actions { display: flex; align-items: center; gap: .5rem; }

/* ============================================================
   LAYOUT
   ============================================================ */
.main-container {
  flex: 1;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 1.5rem;
  gap: 1.5rem;
}

.board-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .75rem;
  flex-shrink: 0;
}

.side-panel {
  display: flex;
  flex-direction: column;
  gap: .75rem;
  width: 280px;
  flex-shrink: 0;
}

/* ============================================================
   HRÁČSKÝ PANEL
   ============================================================ */
.player-panel {
  background: var(--bg-panel);
  border: 2px solid var(--border);
  border-radius: 10px;
  padding: .6rem .9rem;
  display: flex;
  align-items: center;
  gap: .7rem;
  transition: border-color .2s, box-shadow .2s;
}

.player-panel.active-player {
  border-color: #4caf50;
  box-shadow: 0 0 12px rgba(76,175,80,.4);
}

.player-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
}
.player-icon.white-icon { background: #f0d9b5; }
.player-icon.black-icon { background: #333; }

.player-info { flex: 1; }
.player-name  { font-size: .95rem; font-weight: 500; }
.player-color { font-size: .75rem; color: var(--text-muted); }

.player-timer {
  font-family: 'Roboto Mono', monospace;
  font-size: 1.35rem;
  font-weight: 500;
  min-width: 60px;
  text-align: right;
}

.timer-low { color: #f44336 !important; animation: blink .7s infinite; }
@keyframes blink { 0%,100% { opacity: 1; } 50% { opacity: .3; } }

.captured-pieces {
  display: flex;
  flex-wrap: wrap;
  gap: 1px;
  min-height: 20px;
  margin-top: .3rem;
}

.captured-piece {
  width: 20px;
  height: 20px;
  display: inline-block;
}
.captured-piece svg { width: 100%; height: 100%; }

/* ============================================================
   ŠACHOVNICE
   ============================================================ */
.board-wrap {
  position: relative;
  user-select: none;
}

#board {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  width: min(80vmin, 560px);
  height: min(80vmin, 560px);
  border: 3px solid #2c2c2c;
  border-radius: 4px;
  overflow: hidden;
  box-shadow: 0 8px 32px rgba(0,0,0,.6);
}

/* ============================================================
   POLE ŠACHOVNICE
   ============================================================ */
.square {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

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

.sq-selected::after {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--sq-highlight);
  pointer-events: none;
  z-index: 1;
}

.sq-last-move { background-image: linear-gradient(var(--sq-lastmove), var(--sq-lastmove)); }
.sq-selected.sq-last-move::after { background: var(--sq-highlight); }

.sq-check::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at center, rgba(255,0,0,.85) 0%, rgba(255,0,0,.2) 55%, transparent 100%);
  pointer-events: none;
  z-index: 1;
}

/* ============================================================
   FIGURKY
   ============================================================ */
.piece {
  width: 88%;
  height: 88%;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  z-index: 2;
  pointer-events: none;
  transition: transform .1s ease;
}

.piece svg {
  width: 100%;
  height: 100%;
  filter: drop-shadow(0px 2px 3px rgba(0,0,0,.55));
}

.square:active .piece { transform: scale(1.1); }

/* ============================================================
   LEGÁLNÍ TAHY
   ============================================================ */
.legal-dot {
  width: 30%;
  height: 30%;
  border-radius: 50%;
  background: rgba(0,0,0,.22);
  position: absolute;
  z-index: 3;
  pointer-events: none;
  animation: dotPop .13s ease-out;
}

.legal-capture {
  position: absolute;
  inset: 3px;
  border-radius: 50%;
  border: 5px solid rgba(0,0,0,.22);
  z-index: 3;
  pointer-events: none;
  animation: dotPop .13s ease-out;
}

@keyframes dotPop { from { transform: scale(0); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* ============================================================
   KOORDINÁTY
   ============================================================ */
.coord-rank {
  position: absolute;
  top: 2px;
  left: 3px;
  font-size: .6rem;
  font-weight: 700;
  color: rgba(0,0,0,.45);
  line-height: 1;
  pointer-events: none;
  z-index: 4;
}
.sq-dark .coord-rank { color: rgba(255,255,255,.4); }

.coord-file {
  position: absolute;
  bottom: 2px;
  right: 3px;
  font-size: .6rem;
  font-weight: 700;
  color: rgba(0,0,0,.45);
  line-height: 1;
  pointer-events: none;
  z-index: 4;
}
.sq-dark .coord-file { color: rgba(255,255,255,.4); }

/* ============================================================
   SIDE PANEL — KARTY
   ============================================================ */
.panel-card {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: .75rem 1rem;
}

.panel-card h3 {
  font-size: .75rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--text-muted);
  margin-bottom: .5rem;
}

/* ============================================================
   STATUS BAR
   ============================================================ */
.status-bar {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: .6rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  width: 100%;
}

#game-status { font-size: .95rem; font-weight: 500; }
.status-check    { color: #ff9800; }
.status-playing  { color: var(--text-primary); }
.status-gameover { color: var(--accent); }
.status-draw     { color: #64b5f6; }

#check-indicator {
  display: none;
  background: var(--accent);
  color: #fff;
  font-size: .7rem;
  font-weight: 700;
  padding: .2rem .5rem;
  border-radius: 4px;
  letter-spacing: .05em;
  animation: pulse .6s infinite alternate;
}

@keyframes pulse { from { opacity: .75; } to { opacity: 1; } }

/* ============================================================
   HISTORIA TAHŮ
   ============================================================ */
.history-scroll {
  max-height: 260px;
  overflow-y: auto;
  font-family: 'Roboto Mono', monospace;
  font-size: .82rem;
}

.history-scroll::-webkit-scrollbar { width: 4px; }
.history-scroll::-webkit-scrollbar-track { background: transparent; }
.history-scroll::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.history-row {
  display: grid;
  grid-template-columns: 2rem 1fr 1fr;
  gap: .2rem;
  padding: .18rem .25rem;
  border-radius: 4px;
}

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

.move-num  { color: var(--text-muted); text-align: right; padding-right: .3rem; }
.move-san  { padding: 0 .3rem; border-radius: 3px; cursor: default; }
.move-current { background: rgba(76,175,80,.25); color: #81c784; }

/* ============================================================
   TLAČÍTKA
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .3rem;
  padding: .45rem .85rem;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--bg-card);
  color: var(--text-primary);
  font-family: 'Roboto', sans-serif;
  font-size: .82rem;
  font-weight: 500;
  cursor: pointer;
  transition: background .15s, border-color .15s, transform .1s;
  white-space: nowrap;
}

.btn:hover { background: rgba(255,255,255,.1); border-color: rgba(255,255,255,.2); }
.btn:active { transform: scale(.96); }

.btn-primary { background: var(--accent); border-color: var(--accent); }
.btn-primary:hover { background: #c73652; }
.btn-muted { opacity: .5; }

.btn-group { display: flex; flex-wrap: wrap; gap: .35rem; }
.btn-group .btn.active {
  border-color: #4caf50;
  color: #81c784;
  background: rgba(76,175,80,.15);
}

/* Styl figurek — tlačítka */
.piece-style-btn {
  width: 38px;
  height: 38px;
  padding: 6px;
  overflow: hidden;
  border-radius: 7px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Témata — barevné políčka */
.theme-btn {
  width: 34px;
  height: 34px;
  padding: 0;
  overflow: hidden;
  border-radius: 7px;
  flex-shrink: 0;
}
.theme-btn-inner {
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
}
.theme-btn-inner span { display: block; }

/* ============================================================
   PROMOCE MODAL
   ============================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.78);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(4px);
}

.modal-overlay.hidden { display: none !important; }

.modal-box {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1.5rem 2rem;
  text-align: center;
  box-shadow: 0 16px 64px rgba(0,0,0,.6);
}

.modal-box h2 { font-size: 1rem; margin-bottom: 1rem; color: var(--text-muted); }

#promo-pieces {
  display: flex;
  gap: .6rem;
  justify-content: center;
}

.promo-piece {
  width: 70px;
  height: 70px;
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
  transition: border-color .15s, transform .1s, background .15s;
}

.promo-piece:hover { border-color: #4caf50; background: rgba(76,175,80,.15); transform: scale(1.06); }
.promo-piece svg   { width: 100%; height: 100%; }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 860px) {
  .side-panel { width: 240px; }
}

@media (max-width: 700px) {
  .main-container {
    flex-direction: column;
    align-items: center;
    padding: .6rem;
    gap: .75rem;
  }

  .side-panel {
    width: 100%;
    max-width: min(90vmin, 540px);
  }

  .history-scroll { max-height: 140px; }

  #board {
    width: min(92vmin, 480px);
    height: min(92vmin, 480px);
  }

  .status-bar { max-width: min(92vmin, 480px); }
  .board-section { width: 100%; align-items: center; }
}

@media (max-height: 520px) and (orientation: landscape) {
  .main-container {
    flex-direction: row;
    align-items: flex-start;
    padding: .4rem .75rem;
    gap: 1rem;
  }

  #board {
    width: min(84vh, 360px);
    height: min(84vh, 360px);
  }

  .side-panel {
    width: 210px;
    max-height: calc(100vh - 48px);
    overflow-y: auto;
  }

  .history-scroll { max-height: 100px; }
  .navbar { height: 44px; }
  :root { --navbar-h: 44px; }
}

/* ============================================================
   UTILITY
   ============================================================ */
.hidden { display: none !important; }
.text-muted { color: var(--text-muted); font-size: .8rem; }

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,.15); border-radius: 3px; }
