/* ============================================================
   DUEL TACTIQUE — style.css
   ============================================================ */

/* ─────────────────────────────────────────────────────────────
   RESET & BASE
   ───────────────────────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --color-bg:           #1a1a2e;
  --color-surface:      #16213e;
  --color-surface2:     #0f3460;
  --color-accent:       #e94560;
  --color-accent2:      #f5a623;
  --color-p1:           #4fc3f7;
  --color-p1-dark:      #0288d1;
  --color-p2:           #ef9a9a;
  --color-p2-dark:      #c62828;
  --color-text:         #e0e0e0;
  --color-text-muted:   #8899aa;
  --color-border:       #2a4a6a;
  --color-cell-light:   #d4c5a9;
  --color-cell-dark:    #a08060;
  --color-cell-hover:   rgba(255, 255, 100, 0.35);
  --color-cell-select:  rgba(80, 220, 80, 0.55);
  --color-cell-move:    rgba(60, 180, 255, 0.40);
  --color-cell-attack:  rgba(255, 60, 60, 0.50);
  --color-forest:       rgba(30, 120, 30, 0.45);
  --color-swamp:        rgba(80, 60, 20, 0.50);
  --color-trap:         rgba(200, 50, 200, 0.45);
  --board-cell-size:    clamp(44px, 7vw, 72px);
  --panel-width:        300px;
  --radius-sm:          4px;
  --radius-md:          8px;
  --radius-lg:          14px;
  --shadow-card:        0 2px 10px rgba(0,0,0,0.5);
  --shadow-piece:       0 2px 6px rgba(0,0,0,0.7);
  --transition:         0.18s ease;
}

html, body {
  height: 100%;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: 'Segoe UI', system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.4;
  overflow-x: hidden;
}

/* ─────────────────────────────────────────────────────────────
   UTILITY
   ───────────────────────────────────────────────────────────── */
.hidden {
  display: none !important;
}

/* ─────────────────────────────────────────────────────────────
   LAYOUT — #game-board (main container)
   ───────────────────────────────────────────────────────────── */
#game-board {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  gap: 20px;
  padding: 16px 20px;
  min-height: 100vh;
  max-width: 1200px;
  margin: 0 auto;
}

/* ─────────────────────────────────────────────────────────────
   BOARD SECTION
   ───────────────────────────────────────────────────────────── */
#board-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  flex-shrink: 0;
}

#board-wrapper {
  position: relative;
  background: var(--color-surface2) url('assets/board.svg') center/cover no-repeat;
  border: 3px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 6px;
  box-shadow:
    0 0 0 1px rgba(255,255,255,0.06),
    0 8px 32px rgba(0,0,0,0.6);
}

/* Coordonnée labels (optionnel — crée via JS si besoin) */
#board-wrapper::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: var(--radius-md);
  pointer-events: none;
  box-shadow: inset 0 0 24px rgba(0,0,0,0.3);
}

/* ─────────────────────────────────────────────────────────────
   BOARD GRID
   ───────────────────────────────────────────────────────────── */
#board-grid {
  display: grid;
  grid-template-columns: repeat(8, var(--board-cell-size));
  grid-template-rows:    repeat(8, var(--board-cell-size));
  border: 2px solid #2a3a50;
  border-radius: var(--radius-sm);
  overflow: hidden;
  position: relative;
}

/* ─────────────────────────────────────────────────────────────
   CELLS
   ───────────────────────────────────────────────────────────── */
.cell {
  position: relative;
  width:  var(--board-cell-size);
  height: var(--board-cell-size);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: default;
  user-select: none;
  transition:
    background-color var(--transition),
    box-shadow var(--transition);
}

/* Checkerboard pattern */
.cell.light { background-color: var(--color-cell-light); }
.cell.dark  { background-color: var(--color-cell-dark);  }

/* Terrain overlays */
.cell.terrain-forest::after,
.cell.terrain-swamp::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-radius: 1px;
}
.cell.terrain-forest::after { background: var(--color-forest); }
.cell.terrain-swamp::after  { background: var(--color-swamp);  }

/* Terrain icon */
.cell .terrain-icon {
  position: absolute;
  bottom: 2px;
  right: 2px;
  width: 18px;
  height: 18px;
  opacity: 0.8;
  z-index: 2;
  pointer-events: none;
}

/* Trap marker */
.cell.has-trap::before {
  content: '';
  position: absolute;
  inset: 4px;
  border-radius: 50%;
  background: var(--color-trap);
  border: 2px dashed rgba(200,50,200,0.8);
  pointer-events: none;
  z-index: 3;
  animation: trap-pulse 1.4s ease-in-out infinite;
}

@keyframes trap-pulse {
  0%,100% { opacity: 0.5; transform: scale(0.92); }
  50%      { opacity: 1;   transform: scale(1.06); }
}

/* Interactive states */
.cell.selectable {
  cursor: pointer;
}
.cell.selectable:hover {
  background-color: var(--color-cell-hover) !important;
  box-shadow: inset 0 0 0 2px rgba(255,255,100,0.6);
  z-index: 5;
}

.cell.selected {
  background-color: var(--color-cell-select) !important;
  box-shadow: inset 0 0 0 3px rgba(80,220,80,0.9);
  z-index: 6;
}

.cell.movable {
  cursor: pointer;
  background-color: var(--color-cell-move) !important;
}
.cell.movable:hover {
  background-color: rgba(60, 200, 255, 0.65) !important;
  box-shadow: inset 0 0 0 2px rgba(60,200,255,0.9);
  z-index: 5;
}

/* Movable dot indicator */
.cell.movable::before {
  content: '';
  position: absolute;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: rgba(60,200,255,0.75);
  border: 2px solid rgba(255,255,255,0.5);
  pointer-events: none;
  z-index: 4;
}

.cell.attackable {
  cursor: pointer;
  background-color: var(--color-cell-attack) !important;
}
.cell.attackable:hover {
  background-color: rgba(255,80,80,0.70) !important;
  box-shadow: inset 0 0 0 2px rgba(255,80,80,0.9);
  z-index: 5;
}
.cell.attackable::before {
  content: '⚔';
  position: absolute;
  font-size: 12px;
  top: 2px;
  right: 3px;
  pointer-events: none;
  z-index: 4;
  opacity: 0.9;
}

/* Fog of war */
.cell.fog {
  background-color: #1a2030 !important;
  cursor: not-allowed;
}
.cell.fog::after {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    45deg,
    rgba(20,30,50,0.6) 0px,
    rgba(20,30,50,0.6) 4px,
    rgba(30,40,65,0.6) 4px,
    rgba(30,40,65,0.6) 8px
  );
  z-index: 10;
  pointer-events: none;
}
.cell.fog .piece-wrapper {
  display: none;
}

/* Last-moved highlight */
.cell.last-moved {
  box-shadow: inset 0 0 0 2px rgba(255, 215, 0, 0.7);
}

/* ─────────────────────────────────────────────────────────────
   PIECES
   ───────────────────────────────────────────────────────────── */
.piece-wrapper {
  position: relative;
  width:  calc(var(--board-cell-size) * 0.78);
  height: calc(var(--board-cell-size) * 0.78);
  z-index: 7;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  filter: drop-shadow(var(--shadow-piece));
  transition: transform var(--transition), filter var(--transition);
}

.cell.selectable:hover .piece-wrapper {
  transform: scale(1.12);
  filter: drop-shadow(0 4px 10px rgba(255,255,100,0.6));
}
.cell.selected .piece-wrapper {
  transform: scale(1.15);
  filter: drop-shadow(0 0 10px rgba(80,220,80,0.9));
  animation: piece-selected-bob 0.7s ease-in-out infinite alternate;
}

@keyframes piece-selected-bob {
  from { transform: scale(1.12) translateY(0); }
  to   { transform: scale(1.15) translateY(-3px); }
}

.piece-wrapper img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* Player color tints */
.piece-wrapper.player-1 {
  filter: drop-shadow(0 2px 6px rgba(79,195,247,0.7));
}
.piece-wrapper.player-2 {
  filter: drop-shadow(0 2px 6px rgba(239,154,154,0.7));
}

/* Flag piece — special glow */
.piece-wrapper.piece-flag.player-1 {
  filter: drop-shadow(0 0 8px rgba(79,195,247,1)) drop-shadow(0 2px 4px rgba(0,0,0,0.6));
}
.piece-wrapper.piece-flag.player-2 {
  filter: drop-shadow(0 0 8px rgba(239,154,154,1)) drop-shadow(0 2px 4px rgba(0,0,0,0.6));
  transform: translate(-50%, -50%) scaleX(-1);
}

/* Combat value badge */
.piece-badge {
  position: absolute;
  bottom: -3px;
  right: -3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--color-bg);
  border: 1.5px solid rgba(255,255,255,0.4);
  font-size: 9px;
  font-weight: 700;
  color: var(--color-text);
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  z-index: 9;
}
.player-1 .piece-badge { border-color: var(--color-p1); color: var(--color-p1); }
.player-2 .piece-badge { border-color: var(--color-p2); color: var(--color-p2); }

/* Shield indicator */
.piece-shield {
  position: absolute;
  top: -4px;
  left: -4px;
  width: 16px;
  height: 16px;
  font-size: 11px;
  z-index: 9;
  pointer-events: none;
  animation: shield-spin 2s linear infinite;
}
@keyframes shield-spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

/* ─────────────────────────────────────────────────────────────
   CONTEXT MESSAGE
   ───────────────────────────────────────────────────────────── */
#context-message {
  min-height: 32px;
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 6px 14px;
  font-size: 13px;
  color: var(--color-accent2);
  text-align: center;
  width: calc(8 * var(--board-cell-size) + 12px);
  max-width: 100%;
  transition: color var(--transition);
}
#context-message:empty::before {
  content: ' ';
}

/* ─────────────────────────────────────────────────────────────
   ACTION BUTTONS
   ───────────────────────────────────────────────────────────── */
#action-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  width: calc(8 * var(--board-cell-size) + 12px);
  max-width: 100%;
}

#action-buttons button,
#btn-new-game-over {
  padding: 9px 18px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition:
    background var(--transition),
    transform var(--transition),
    box-shadow var(--transition),
    opacity var(--transition);
  outline: none;
  white-space: nowrap;
}

#btn-draw-card {
  background: linear-gradient(135deg, #1565c0, #1976d2);
  color: #fff;
  box-shadow: 0 2px 8px rgba(21,101,192,0.5);
}
#btn-draw-card:hover:not(:disabled) {
  background: linear-gradient(135deg, #1976d2, #42a5f5);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(21,101,192,0.7);
}
#btn-draw-card:active:not(:disabled) { transform: translateY(0); }

#btn-end-turn {
  background: linear-gradient(135deg, #2e7d32, #388e3c);
  color: #fff;
  box-shadow: 0 2px 8px rgba(46,125,50,0.5);
}
#btn-end-turn:hover:not(:disabled) {
  background: linear-gradient(135deg, #388e3c, #66bb6a);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(46,125,50,0.7);
}
#btn-end-turn:active:not(:disabled) { transform: translateY(0); }

#btn-new-game {
  background: linear-gradient(135deg, #4a148c, #6a1b9a);
  color: #fff;
  box-shadow: 0 2px 8px rgba(74,20,140,0.5);
}
#btn-new-game:hover:not(:disabled) {
  background: linear-gradient(135deg, #6a1b9a, #ab47bc);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(74,20,140,0.7);
}
#btn-new-game:active:not(:disabled) { transform: translateY(0); }

#fog-toggle {
  background: linear-gradient(135deg, #37474f, #546e7a);
  color: #fff;
  box-shadow: 0 2px 8px rgba(55,71,79,0.5);
}
#fog-toggle:hover:not(:disabled) {
  background: linear-gradient(135deg, #546e7a, #78909c);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(55,71,79,0.7);
}
#fog-toggle:active:not(:disabled) { transform: translateY(0); }

#action-buttons button:disabled {
  opacity: 0.38;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
}

/* ─────────────────────────────────────────────────────────────
   INFO PANEL
   ───────────────────────────────────────────────────────────── */
#info-panel {
  width: var(--panel-width);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-bottom: 20px;
}

#info-panel h3 {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--color-text-muted);
  margin-bottom: 6px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--color-border);
}

/* ─────────────────────────────────────────────────────────────
   ACTIVE PLAYER SECTION
   ───────────────────────────────────────────────────────────── */
#active-player-section {
  background: var(--color-surface);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  box-shadow: var(--shadow-card);
  position: relative;
  overflow: hidden;
}

#active-player-section::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--player-color, var(--color-p1));
  transition: background var(--transition);
}

#active-player-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 3px solid var(--player-color, var(--color-p1));
  background: var(--color-surface2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  transition: border-color var(--transition);
  box-shadow: 0 0 12px var(--player-color, rgba(79,195,247,0.4));
}

#active-player-name {
  font-size: 16px;
  font-weight: 700;
  color: var(--player-color, var(--color-p1));
  transition: color var(--transition);
}

#phase-label {
  font-size: 12px;
  color: var(--color-text-muted);
  background: rgba(255,255,255,0.05);
  border-radius: var(--radius-sm);
  padding: 3px 10px;
}

/* Player 1 active */
body.player-1-active #active-player-section {
  --player-color: var(--color-p1);
}
/* Player 2 active */
body.player-2-active #active-player-section {
  --player-color: var(--color-p2);
}

/* ─────────────────────────────────────────────────────────────
   PLAYERS LIST
   ───────────────────────────────────────────────────────────── */
#players-section {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 12px;
  box-shadow: var(--shadow-card);
}

#players-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

#players-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: rgba(255,255,255,0.04);
  border: 1px solid transparent;
  transition: border-color var(--transition), background var(--transition);
}

#players-list li.active-player {
  border-color: var(--color-accent2);
  background: rgba(245,166,35,0.08);
}

.player-list-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
}
.player-list-avatar.p1 { background: rgba(79,195,247,0.2);  border: 2px solid var(--color-p1); }
.player-list-avatar.p2 { background: rgba(239,154,154,0.2); border: 2px solid var(--color-p2); }

.player-list-name {
  flex: 1;
  font-size: 13px;
  font-weight: 600;
}
.player-list-name.p1 { color: var(--color-p1); }
.player-list-name.p2 { color: var(--color-p2); }

.player-list-pieces {
  font-size: 11px;
  color: var(--color-text-muted);
}

/* First player marker in list */
.player-first-marker {
  width: 18px;
  height: 18px;
  object-fit: contain;
  opacity: 0.85;
}

/* ─────────────────────────────────────────────────────────────
   TURN BAR
   ───────────────────────────────────────────────────────────── */
#turn-section {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 12px;
  box-shadow: var(--shadow-card);
}

#turn-bar {
  height: 10px;
  background: rgba(255,255,255,0.08);
  border-radius: 10px;
  overflow: hidden;
  margin-bottom: 6px;
  border: 1px solid var(--color-border);
}

#turn-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--color-p1), var(--color-accent2));
  border-radius: 10px;
  width: 0%;
  transition: width 0.5s ease;
}

#turn-count {
  font-size: 12px;
  color: var(--color-text-muted);
  text-align: center;
}

/* ─────────────────────────────────────────────────────────────
   LAST EVENT BOX
   ───────────────────────────────────────────────────────────── */
#last-event-section {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 12px;
  box-shadow: var(--shadow-card);
}

#last-event-box {
  font-size: 12px;
  color: var(--color-accent2);
  padding: 8px;
  background: rgba(245,166,35,0.07);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--color-accent2);
  min-height: 36px;
  line-height: 1.5;
  word-break: break-word;
}

/* ─────────────────────────────────────────────────────────────
   HAND CARDS
   ───────────────────────────────────────────────────────────── */
#hand-section {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 12px;
  box-shadow: var(--shadow-card);
}

#hand-cards {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 72px;
  align-items: flex-start;
}

.hand-card {
  position: relative;
  width: 68px;
  height: 88px;
  border-radius: var(--radius-sm);
  background: var(--color-surface2);
  border: 2px solid var(--color-border);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  cursor: pointer;
  transition:
    transform var(--transition),
    border-color var(--transition),
    box-shadow var(--transition);
  box-shadow: var(--shadow-card);
  overflow: hidden;
  user-select: none;
}

.hand-card img {
  width: 36px;
  height: 36px;
  object-fit: contain;
  pointer-events: none;
}

.hand-card-label {
  font-size: 9px;
  font-weight: 700;
  text-align: center;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  pointer-events: none;
}

.hand-card:hover:not(.disabled) {
  transform: translateY(-6px) scale(1.04);
  border-color: var(--color-accent2);
  box-shadow: 0 8px 20px rgba(245,166,35,0.35);
  z-index: 10;
}

.hand-card.selected-card {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px rgba(233,69,96,0.5);
  transform: translateY(-8px) scale(1.06);
}

.hand-card.disabled,
.hand-card.card-played {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none !important;
}

/* Card type colors */
.hand-card.card-shield { border-color: #1565c0; }
.hand-card.card-shield:hover:not(.disabled) { border-color: #42a5f5; box-shadow: 0 8px 20px rgba(21,101,192,0.4); }

.hand-card.card-sprint { border-color: #2e7d32; }
.hand-card.card-sprint:hover:not(.disabled) { border-color: #66bb6a; box-shadow: 0 8px 20px rgba(46,125,50,0.4); }

.hand-card.card-trap   { border-color: #6a1b9a; }
.hand-card.card-trap:hover:not(.disabled)   { border-color: #ab47bc; box-shadow: 0 8px 20px rgba(106,27,154,0.4); }

/* Empty hand placeholder */
.hand-empty {
  font-size: 12px;
  color: var(--color-text-muted);
  font-style: italic;
  padding: 8px;
}

/* ─────────────────────────────────────────────────────────────
   INVENTORY
   ───────────────────────────────────────────────────────────── */
#inventory-section {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 12px;
  box-shadow: var(--shadow-card);
}

#inventory-slots {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 5px;
}

.inventory-slot {
  min-width: 0;
  height: auto;
  min-height: 56px;
  border-radius: var(--radius-sm);
  background: rgba(255,255,255,0.04);
  border: 1px dashed var(--color-border);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 4px 2px;
  transition: border-color var(--transition), background var(--transition);
  cursor: default;
  overflow: hidden;
}

.inventory-slot:hover {
  border-color: var(--color-text-muted);
  background: rgba(255,255,255,0.07);
}

.inventory-slot img {
  width: 22px;
  height: 22px;
  object-fit: contain;
  flex-shrink: 0;
}

.inventory-value {
  font-size: 11px;
  font-weight: 700;
  color: var(--color-text);
  line-height: 1;
}

.inventory-label {
  font-size: 8px;
  color: var(--color-text-muted);
  text-align: center;
  line-height: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}

/* ─────────────────────────────────────────────────────────────
   LOG LIST
   ───────────────────────────────────────────────────────────── */
/* Marqueur joueur actif dans le panneau */
.active-marker {
  width: 28px;
  height: 28px;
  max-width: 28px;
  max-height: 28px;
  object-fit: contain;
  display: inline-block;
  vertical-align: middle;
}

/* Cellule du plateau — s'assurer que piece-wrapper remplit la cellule */
.cell {
  position: relative;
}
.piece-wrapper {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

/* Couleurs des joueurs (utilisées dans les spans de nom, titre fin de partie…) */
.player-1-color { color: var(--color-p1) !important; }
.player-2-color { color: var(--color-p2) !important; }
.player-1-avatar { border-color: var(--color-p1) !important; box-shadow: 0 0 12px rgba(79,195,247,0.4) !important; }
.player-2-avatar { border-color: var(--color-p2) !important; box-shadow: 0 0 12px rgba(239,154,154,0.4) !important; }
.player-name { font-size: 16px; font-weight: 700; }

/* Message contextuel — couleurs selon le type */
.context-info  { color: var(--color-accent2) !important; }
.context-error { color: var(--color-accent)  !important; }

/* Info panel — empêche tout overflow horizontal */
#info-panel,
#info-panel > * {
  max-width: 100%;
  min-width: 0;
}

/* Turn count text */
#turn-count {
  font-size: 12px;
  color: var(--color-text-muted);
  text-align: center;
  margin-top: 4px;
}
