/* hud.css — in-game HUD overlay.
 *
 * Phase 1 Milestone 1.3: top-right block queue panel (Available + upcoming).
 * Phase 1 Milestone 1.6: top-center blueprint selection row.
 * Later milestones add the left player status panel per GDD §11.
 */

/* --- Menu button + modal (top left) ----------------------------------- */

#hud-menu-btn {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 20;
  width: 40px;
  height: 40px;
  border: 1px solid rgba(200, 200, 220, 0.4);
  background: rgba(0, 0, 0, 0.45);
  color: #ddd;
  font-size: 20px;
  font-family: monospace;
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, border-color 0.15s;
}
#hud-menu-btn:hover {
  background: rgba(40, 40, 60, 0.65);
  border-color: rgba(200, 200, 220, 0.8);
}

#hud-menu-modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(10, 10, 20, 0.7);
  align-items: center;
  justify-content: center;
  font-family: monospace;
}
#hud-menu-modal.visible {
  display: flex;
}

#hud-menu-modal .menu-modal-body {
  min-width: 280px;
  max-width: 380px;
  padding: 24px;
  background: rgba(30, 30, 50, 0.95);
  border: 1px solid rgba(200, 200, 220, 0.6);
  text-align: center;
  color: #ddd;
}
#hud-menu-modal h2 {
  margin: 0 0 16px 0;
  font-size: 18px;
  color: #fff;
  letter-spacing: 1px;
}

.menu-buttons {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
}
.menu-btn {
  padding: 10px 14px;
  border: 1px solid rgba(200, 200, 220, 0.4);
  background: rgba(0, 0, 0, 0.35);
  color: #ddd;
  font-family: monospace;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.menu-btn:hover {
  background: rgba(60, 60, 90, 0.6);
  border-color: rgba(200, 200, 220, 0.8);
}
.menu-btn-primary {
  border-color: rgba(255, 220, 120, 0.7);
  background: rgba(80, 70, 30, 0.45);
}
.menu-btn-primary:hover {
  background: rgba(120, 100, 40, 0.6);
}

#menu-modal-hint {
  font-size: 11px;
  color: #888;
  margin-top: 6px;
}

/* --- Blueprint row (top center) ---------------------------------------- */

#hud-blueprint-row {
  position: fixed;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  display: none; /* shown by JS after welcome */
  flex-direction: row;
  gap: 6px;
  font-family: monospace;
}

.bp-btn {
  width: 72px;
  height: 48px;
  border: none;
  border-image: url('../Assets/UI/Windows/PanelElement03a.png') 6 6 6 6 fill / 6px 6px 6px 6px / 0 stretch;
  background: transparent;
  color: #ccc;
  font-size: 10px;
  font-family: monospace;
  text-align: center;
  line-height: 1.2;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative; /* for .placed checkmark pseudo */
  cursor: pointer;
  transition: filter 0.15s, opacity 0.15s, box-shadow 0.15s;
  user-select: none;
}

.bp-btn canvas {
  display: block;
  pointer-events: none; /* clicks hit the button, not the canvas */
}

.bp-btn:hover {
  filter: brightness(1.3);
}

.bp-btn.active {
  box-shadow: 0 0 0 2px rgba(255, 220, 120, 0.95), 0 0 10px rgba(255, 200, 80, 0.6);
  filter: brightness(1.15);
}

/* Player has already placed ≥1 of this building. Stays clickable — you
 * can still build more — but the dimmed tint plus corner check reads as
 * "you have this." */
.bp-btn.placed {
  opacity: 0.55;
}

.bp-btn.placed::after {
  content: '\2713'; /* ✓ */
  position: absolute;
  top: 6px;
  left: 8px;
  font-size: 12px;
  font-weight: bold;
  color: rgba(150, 255, 150, 0.95);
  text-shadow: 0 0 3px rgba(0, 0, 0, 0.8);
  pointer-events: none;
}

/* Override dim when the button is the active selection — don't want
 * "I'm placing right now" and "I already have one" to conflict visually. */
.bp-btn.active.placed {
  opacity: 1;
}

/* --- Block queue (top right) ------------------------------------------- */

#hud-block-queue {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 10;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  pointer-events: none;
  font-family: monospace;
  color: #ccc;
}

/* All three slots (Wood build, Stone, Delete) share the same frame
 * styling; JS renders a different block preview inside each. */
#block-available,
#block-stone,
#block-delete {
  width: 96px;
  height: 96px;
  border: none;
  border-image: url('../Assets/UI/Windows/PanelElement03a.png') 6 6 6 6 fill / 6px 6px 6px 6px / 0 stretch;
  background: transparent;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
  pointer-events: auto;
  cursor: pointer;
  position: relative;
  transition: transform 0.1s ease-out, box-shadow 0.15s ease-out, filter 0.15s ease-out;
}

#block-available:hover,
#block-stone:hover,
#block-delete:hover {
  filter: brightness(1.2);
}

/* Current selection highlight — the Block frame by default, swapped out
 * while a blueprint button is active. Same golden glow the blueprint
 * buttons use when picked so the two modes read consistently. */
#block-available.active,
#block-stone.active,
#block-delete.active {
  box-shadow: 0 0 0 2px rgba(255, 220, 120, 0.95), 0 4px 16px rgba(255, 200, 80, 0.55);
  filter: brightness(1.15);
}

/* Stone-credit counter badge — small numeric in the bottom-right of
 * the stone slot. Dark puck + light digit reads over any preview. */
.block-slot-badge {
  position: absolute;
  right: 6px;
  bottom: 6px;
  min-width: 18px;
  padding: 1px 5px;
  background: rgba(0, 0, 0, 0.7);
  color: #eee;
  font-family: monospace;
  font-size: 12px;
  line-height: 1.2;
  text-align: center;
  border-radius: 3px;
  pointer-events: none;
  z-index: 2; /* above both progress fill and 3D preview canvas */
}

/* Progress fill — muted dark blue rises from the bottom of the frame.
 * Sits inside the 6px border inset so it doesn't cover the border-image.
 * Width animated via JS (`height` CSS) — opacity swap hides it cleanly
 * when idle instead of leaving an empty stub. */
.block-slot-progress {
  position: absolute;
  left: 6px;
  right: 6px;
  bottom: 6px;
  height: 0%;
  background: rgba(40, 55, 80, 0.55);
  pointer-events: none;
  z-index: 0;
  opacity: 0;
  transition: opacity 0.15s ease-out;
}

/* Queue advance feedback — scale bump + shadow flash. Animation
 * keyframes run forward once; JS removes the class on animationend so
 * a second placement can re-trigger it. */
@keyframes queue-pulse {
  0%   {
    transform: scale(1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
  }
  25%  {
    transform: scale(1.15);
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.85), 0 6px 24px rgba(120, 200, 255, 0.9);
  }
  100% {
    transform: scale(1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
  }
}

#block-available.pulse,
#block-stone.pulse {
  animation: queue-pulse 400ms ease-out;
}

/* Upcoming slot shift — the inline-style transform + transition is
 * applied in blockQueue.js advance(); this rule exists only to share
 * the easing timing with the queue-pulse keyframe. */

#block-available canvas,
#block-stone canvas,
#block-delete canvas {
  display: block;
  width: 100%;
  height: 100%;
  position: relative; /* lets z-index lift canvas over the progress fill */
  z-index: 1;
}

/* Cursor signal when a slot is capped / unavailable — click does
 * nothing, so the pointer shouldn't tease the player into thinking
 * it'll work. Wood slot freezes at block cap; stone slot freezes at
 * zero credits or block cap. */
#block-available.at-cap,
#block-stone.at-cap,
#block-delete.at-cap {
  cursor: not-allowed;
  opacity: 0.75;
}

/* --- Player Status Panel (left) --------------------------------------- */

#hud-player-panel {
  position: fixed;
  top: 72px;
  left: 12px;
  z-index: 10;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-family: monospace;
  color: #ddd;
  pointer-events: none;
  min-width: 180px;
}

.player-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(200, 200, 220, 0.25);
  border-radius: 3px;
  font-size: 12px;
}

.player-row.local {
  border-color: rgba(255, 255, 120, 0.7);
  background: rgba(40, 40, 20, 0.55);
}

/* Counters row — sibling to the main local row. Displays Blocks left
 * and Pop right with the influence row's width. Slightly smaller text
 * so it reads as secondary info rather than a new roster entry. */
.player-row.local-pop {
  padding: 4px 10px;
  font-size: 11px;
  color: rgba(255, 255, 255, 0.82);
  justify-content: space-between;
  background: rgba(40, 40, 20, 0.4);
  border-color: rgba(255, 255, 120, 0.4);
  border-top: none;
  margin-top: -3px;
}
.player-row.local-pop span:empty {
  display: none;
}

.player-row.kingmaker {
  opacity: 0.6;
  border-color: rgba(180, 60, 60, 0.6);
}

.player-color-swatch {
  width: 14px;
  height: 14px;
  border: 1px solid rgba(255, 255, 255, 0.4);
  flex-shrink: 0;
}

.player-shape-icon {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #eebb33;
  font-size: 14px;
  line-height: 1;
}

.player-name {
  flex-grow: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.player-influence {
  font-weight: bold;
  min-width: 40px;
  text-align: right;
  color: #bbdd88;
}

.player-kingmaker-indicator {
  color: #cc4444;
  font-weight: bold;
  min-width: 40px;
  text-align: right;
}
