/* ==========================================================================
   1. FILE HEADER & META DOCUMENTATION
   ========================================================================== */

/**
 * page_05_battle_stage1.css - Responsive Battle Stage 1 Preparation Layout
 * 
 * Overview:
 * Stylesheet governing the visual presentation, layout hierarchy, grid systems,
 * player status displays, action controls, overlay modals, and animation keyframes
 * for Battle Stage 1.
 * 
 * Layout Paradigm:
 * Dynamic viewport-relative scaling powered by Container Query units (cqw, cqh, cqmin)
 * calculated relative to the target container (#game-wrapper).
 */

/* ==========================================================================
   2. MAIN CONTAINER & CARD WRAPPER
   ========================================================================== */

.battle-stage1-container {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1.5cqh 2cqw;
  box-sizing: border-box;
  overflow: hidden;
  position: relative;
  z-index: 10;
}

.battle-stage1-container.hidden {
  display: none !important;
}

.battle-stage1-card {
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  background-color: rgba(18, 10, 6, 0.92);
  border: 0.35cqmin solid var(--border-gold, #c89d38);
  border-radius: 1.5cqmin;
  padding: 1.2cqh 1.8cqw;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 0.6cqh;
  box-shadow: 0 1cqh 3cqh rgba(0, 0, 0, 0.9), 0 0 1.5cqh rgba(200, 157, 56, 0.2);
  box-sizing: border-box;
  color: #e2b755;
  font-family: 'Inter', sans-serif;
}

/* ==========================================================================
   3. SECTION LABELS & TEXT TYPOGRAPHY
   ========================================================================== */

.hand-label {
  font-family: 'Cinzel', serif;
  font-size: 1.35cqh;
  font-weight: 700;
  color: #a88238;
  letter-spacing: 0.05em;
  margin-bottom: 0.4cqh;
  text-transform: uppercase;
}

.hand-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1cqw;
  margin-bottom: 0.5cqh;
}

.instruction-label {
  font-family: 'Inter', sans-serif;
  font-size: 1.25cqh;
  font-weight: 600;
  color: #f3d078;
  letter-spacing: 0.02em;
  text-transform: none;
  margin-bottom: 0;
}

.deploy-counter-badge {
  font-family: 'Inter', sans-serif;
  font-size: 1.1cqh;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #f3d078;
  background-color: rgba(42, 25, 16, 0.9);
  border: 0.18cqmin solid #c89d38;
  border-radius: 999px;
  padding: 0.25cqh 0.9cqw;
  white-space: nowrap;
  flex-shrink: 0;
}

.deploy-counter-badge.full {
  color: #2ecc71;
  border-color: #2ecc71;
  background-color: rgba(27, 56, 35, 0.9);
}

/* ==========================================================================
   4. HAND GRIDS & UNIT CARDS
   ========================================================================== */

.hand-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1cqw;
  overflow: visible;
  padding-top: 0.4cqh;
}

.unit-card {
  position: relative;
  background: linear-gradient(180deg, #2a1910 0%, #160d08 100%);
  border: 0.2cqmin solid #7d5b22;
  border-radius: 1cqmin;
  padding: 0.7cqh 0.4cqw;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
  min-height: 7.2cqh;
}

.unit-card:hover:not(.disabled) {
  border-color: #f3d078;
  box-shadow: 0 0 1cqmin rgba(243, 208, 120, 0.4);
  transform: translateY(-0.3cqh);
}

.unit-card.selected {
  border: 0.35cqmin solid #2ecc71;
  background: linear-gradient(180deg, #1b3823 0%, #0d1e13 100%);
  box-shadow: 0 0 1.2cqmin rgba(46, 204, 113, 0.6);
}

.unit-card.deployed,
.unit-card.disabled {
  opacity: 0.4;
  cursor: not-allowed;
  filter: grayscale(0.7);
}

.unit-card .unit-icon {
  font-size: 2.8cqh;
  line-height: 1.1;
}

.unit-card .unit-name {
  font-family: 'Cinzel', serif;
  font-size: 1.15cqh;
  font-weight: 700;
  color: #e2b755;
  margin-top: 0.3cqh;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.unit-card .info-btn {
  position: absolute;
  top: -0.6cqh;
  right: -0.35cqw;
  width: 2.2cqh;
  height: 2.2cqh;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #b21f1f 0%, #680808 100%);
  color: #ffffff;
  font-weight: 800;
  font-size: 1.15cqh;
  line-height: 1;
  border: 0.18cqmin solid var(--border-gold, #c89d38);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease-in-out;
  cursor: pointer;
  z-index: 5;
}

/* ==========================================================================
   5. ENEMY HAND INTERACTION RULES
   ========================================================================== */

.enemy-hand .unit-card,
.enemy-unit {
  opacity: 1 !important;
  filter: none !important;
  cursor: default !important;
  pointer-events: none;
}

.enemy-hand .unit-card .info-btn,
.enemy-unit .info-btn {
  pointer-events: auto !important;
  cursor: pointer !important;
  opacity: 1 !important;
}

.unit-card .info-btn:hover,
.enemy-hand .unit-card .info-btn:hover,
.enemy-unit .info-btn:hover {
  background: radial-gradient(circle at 35% 35%, #d32f2f 0%, #8b0000 100%);
  border-color: var(--border-gold-light, #f3d078);
  box-shadow: 0 0 1cqmin rgba(243, 208, 120, 0.6);
  transform: scale(1.1);
  color: #ffffff;
}

.unit-card .info-btn:active,
.enemy-hand .unit-card .info-btn:active,
.enemy-unit .info-btn:active {
  transform: scale(0.95);
  box-shadow: 0 0 0.5cqmin rgba(243, 208, 120, 0.4);
}

/* ==========================================================================
   6. PLAYER STATUS BARS & LIVES INDICATORS
   ========================================================================== */

.player-status-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background-color: #0d0704;
  border: 0.2cqmin solid #4a3418;
  padding: 0.6cqh 1.2cqw;
  border-radius: 0.8cqmin;
  font-family: 'Cinzel', serif;
}

.player-name {
  font-size: 1.45cqh;
  font-weight: 700;
  letter-spacing: 0.05em;
}

.enemy-status .player-name {
  color: #e74c3c;
}

.user-status .player-name {
  color: #0055ff;
}

.lives-container {
  display: flex;
  gap: 0.5cqw;
  font-size: 1.6cqh;
}

.heart-icon.full-enemy {
  color: #e74c3c;
}

.heart-icon.full-user {
  color: #0055ff;
}

.heart-icon.empty {
  color: #4a3418;
}

/* ==========================================================================
   7. TIMER & PROGRESS TRACKER
   ========================================================================== */

.timer-stage-wrapper {
  display: flex;
  flex-direction: column;
  gap: 0.35cqh;
}

.timer-header {
  display: flex;
  justify-content: space-between;
  font-size: 1.3cqh;
  font-weight: 700;
  color: #c89d38;
}

.timer-track {
  width: 100%;
  height: 1cqh;
  min-height: 4px;
  background-color: #0b0604;
  border: 0.18cqmin solid #7d5b22;
  border-radius: 0.5cqh;
  overflow: hidden;
  padding: 0.1cqh;
  box-sizing: border-box;
}

.timer-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #c89d38 0%, #f3d078 100%);
  border-radius: 0.3cqh;
  transition: width 0.3s linear;
}

/* ==========================================================================
   8. ARENA FIELD & GRID SYSTEM
   ========================================================================== */

.arena-wrapper {
  position: relative;
  border: 0.35cqmin solid var(--border-gold, #c89d38);
  border-radius: 1.2cqmin;
  background: 
    radial-gradient(circle at 50% 50%, rgba(35, 20, 12, 0.9) 0%, rgba(10, 5, 3, 0.96) 100%),
    linear-gradient(rgba(200, 157, 56, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(200, 157, 56, 0.04) 1px, transparent 1px);
  background-size: 100% 100%, 2cqw 2cqw, 2cqw 2cqw;
  padding: 1cqh 1.8cqw;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  flex-grow: 1;
  box-shadow: inset 0 0 2cqh rgba(0, 0, 0, 0.8), 0 0 1cqh rgba(200, 157, 56, 0.15);
  box-sizing: border-box;
}

.arena-corner {
  position: absolute;
  width: 0.8cqmin;
  height: 0.8cqmin;
  border-color: #f3d078;
  border-style: solid;
  pointer-events: none;
}

.arena-corner.top-left {
  top: 0.4cqmin;
  left: 0.4cqmin;
  border-width: 0.25cqmin 0 0 0.25cqmin;
}

.arena-corner.top-right {
  top: 0.4cqmin;
  right: 0.4cqmin;
  border-width: 0.25cqmin 0.25cqmin 0 0;
}

.arena-corner.bottom-left {
  bottom: 0.4cqmin;
  left: 0.4cqmin;
  border-width: 0 0 0.25cqmin 0.25cqmin;
}

.arena-corner.bottom-right {
  bottom: 0.4cqmin;
  right: 0.4cqmin;
  border-width: 0 0.25cqmin 0.25cqmin 0;
}

.arena-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2cqh;
  margin-bottom: 0.4cqh;
}

.arena-title {
  font-family: 'Cinzel', serif;
  font-size: 1.45cqh;
  font-weight: 700;
  color: #f3d078;
  letter-spacing: 0.12em;
  text-shadow: 0 0.2cqh 0.4cqh rgba(0, 0, 0, 0.9);
}

.arena-subtitle {
  font-family: 'Inter', sans-serif;
  font-size: 0.9cqh;
  font-weight: 600;
  color: #a88238;
  letter-spacing: 0.08em;
}

.arena-lanes-grid {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 1.5cqw;
  width: 100%;
  align-items: center;
  flex-grow: 1;
}

.arena-divider {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.8cqh;
  opacity: 0.4;
  height: 100%;
}

.divider-line {
  width: 1px;
  flex-grow: 1;
  background: linear-gradient(180deg, transparent, #c89d38, transparent);
}

.divider-icon {
  font-size: 1.2cqh;
  color: #c89d38;
}

/* ==========================================================================
   9. TACTICAL LANES & ARENA SLOTS
   ========================================================================== */

.lane-column {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5cqh;
  width: 100%;
  height: 100%;
  justify-content: space-evenly;
}

.lane-header {
  width: 100%;
  text-align: center;
  border-bottom: 0.15cqmin solid rgba(200, 157, 56, 0.3);
  padding-bottom: 0.3cqh;
}

.lane-badge {
  font-family: 'Cinzel', serif;
  font-size: 1.15cqh;
  font-weight: 700;
  color: #e2b755;
  letter-spacing: 0.08em;
}

.lane-slots {
  display: flex;
  flex-direction: column;
  gap: 0.8cqh;
  width: 100%;
  flex-grow: 1;
  justify-content: space-evenly;
}

.arena-slot {
  height: 11.5cqh;
  border: 0.25cqmin dashed #7d5b22;
  border-radius: 0.8cqmin;
  background: rgba(18, 10, 6, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.25s ease-in-out;
  position: relative;
  box-sizing: border-box;
}

.arena-slot.slot-frontline {
  background: linear-gradient(180deg, rgba(35, 18, 10, 0.7) 0%, rgba(18, 10, 6, 0.65) 100%);
  border-color: #8c6328;
}

.arena-slot.slot-backline {
  background: linear-gradient(180deg, rgba(20, 25, 35, 0.5) 0%, rgba(18, 10, 6, 0.65) 100%);
  border-color: #4a5a6a;
}

.arena-slot:hover {
  border-style: solid;
  border-color: #f3d078;
  background-color: rgba(50, 30, 15, 0.85);
  box-shadow: 0 0 1cqmin rgba(243, 208, 120, 0.3);
  transform: scale(1.01);
}

.arena-slot.occupied {
  border: 0.28cqmin solid #2ecc71;
  background: linear-gradient(180deg, #1d3324 0%, #112217 100%);
  box-shadow: inset 0 0 1cqh rgba(46, 204, 113, 0.2);
}

.arena-slot.target-highlight:not(.occupied) {
  border-style: solid;
  border-color: #f3d078;
  animation: slotPulse 1.2s infinite ease-in-out;
}

/* ==========================================================================
   10. SLOT PLACEHOLDERS & DEPLOYED UNITS
   ========================================================================== */

.slot-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.3cqh;
  color: #a88238;
  pointer-events: none;
}

.slot-label {
  font-family: 'Cinzel', serif;
  font-size: 1.50cqh;
  font-weight: 600;
  letter-spacing: 0.05em;
  color: #7d5b22;
}

.slot-sublabel {
  font-family: 'Cinzel', serif;
  font-size: 1.25cqh;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: #5e4419;
}

.deployed-unit {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.deployed-unit .unit-icon {
  font-size: 3.2cqh;
}

.deployed-unit .unit-name {
  font-family: 'Cinzel', serif;
  font-size: 1.15cqh;
  font-weight: 700;
  color: #ffffff;
  margin-top: 0.2cqh;
}

/* ==========================================================================
   11. CONTROLS & ACTION BUTTONS
   ========================================================================== */

.stage1-controls-bar {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 1.5cqw;
  margin-top: 0.4cqh;
}

.btn-stage1 {
  font-family: 'Cinzel', serif;
  font-size: 1.4cqh;
  font-weight: 700;
  padding: 1cqh 0.5cqw;
  border-radius: 0.8cqmin;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: center;
}

.btn-gold {
  background: linear-gradient(180deg, #f3d078 0%, #c89d38 100%);
  border: 0.2cqmin solid #7d5b22;
  color: #1a0f0a;
}

.btn-gold:hover {
  filter: brightness(1.1);
}

.btn-ready {
  background: linear-gradient(180deg, #2ecc71 0%, #27ae60 100%);
  border: 0.2cqmin solid #1e824c;
  color: #ffffff;
  box-shadow: 0 0 1.2cqmin rgba(46, 204, 113, 0.5);
}

.btn-ready:disabled {
  background: #2c3e50;
  border-color: #1a252f;
  color: #7f8c8d;
  box-shadow: none;
  cursor: not-allowed;
  opacity: 0.6;
}

/* ==========================================================================
   12. OVERLAY, MODAL & SPINNER FX
   ========================================================================== */

.wait-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: rgba(5, 3, 2, 0.95);
  backdrop-filter: blur(6px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.5s ease-in-out;
}

.wait-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.wait-overlay.hidden {
  display: none !important;
}

.wait-modal-card {
  width: 80cqw;
  max-width: 85cqw;
  padding: 4cqh 3cqw;
  background-color: #120a06;
  border: 0.35cqmin solid var(--border-gold, #c89d38);
  border-radius: 2cqmin;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2.5cqh;
  box-shadow: 0 1.5cqh 4cqh rgba(0, 0, 0, 0.9), 0 0 2cqh rgba(200, 157, 56, 0.2);
}

.spinner-ring {
  width: 6cqh;
  height: 6cqh;
  border: 0.5cqh solid rgba(200, 157, 56, 0.2);
  border-top-color: #f3d078;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

.wait-modal-text {
  font-family: 'Cinzel', serif;
  font-size: 1.8cqh;
  font-weight: 700;
  letter-spacing: 0.15em;
  color: #e2b755;
  text-shadow: 0 0.3cqh 0.6cqh rgba(0, 0, 0, 0.8);
}

.screen-shake {
  animation: screenShake 0.15s infinite;
}

/* ==========================================================================
   13. KEYFRAME ANIMATIONS
   ========================================================================== */

@keyframes slotPulse {
  0%, 100% { box-shadow: 0 0 0.4cqmin rgba(243, 208, 120, 0.3); }
  50% { box-shadow: 0 0 1.2cqmin rgba(243, 208, 120, 0.7); }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes screenShake {
  0%   { transform: translate(0, 0); }
  25%  { transform: translate(-0.224cqw, 0.141cqw); }
  50%  { transform: translate(0.141cqw, -0.224cqw); }
  75%  { transform: translate(-0.141cqw, 0.224cqw); }
  100% { transform: translate(0.224cqw, -0.141cqw); }
}