/* Upgrade Screen - Enhanced Design System */
/* SPACEJAY-148 Phase 4: Upgrade Screen - Ornate stone borders & rich textures */

/* ═══════════════════════════════════════════════════════════════
   UPGRADE SCREEN OVERLAY - Enhanced starfield with nebulae
   ═══════════════════════════════════════════════════════════════ */

#upgrade-screen-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  background: 
    radial-gradient(ellipse at 20% 30%, rgba(139, 0, 0, 0.25) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 70%, rgba(75, 0, 130, 0.25) 0%, transparent 50%),
    radial-gradient(ellipse at 50% 50%, rgba(0, 100, 150, 0.15) 0%, transparent 60%),
    linear-gradient(135deg, #05070A 0%, #0a0a0a 50%, #05070A 100%);
  background-size: cover;
  background-position: center;
  z-index: 1000;
  font-family: 'Press Start 2P', monospace;
  color: white;
  overflow-y: auto;
  overflow-x: hidden;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  position: relative;
  box-sizing: border-box;
}

/* DENSE starfield - matching main menu */
#upgrade-screen-overlay::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: 
    radial-gradient(1px 1px at 10% 20%, white, transparent),
    radial-gradient(1px 1px at 15% 35%, white, transparent),
    radial-gradient(1px 1px at 20% 50%, white, transparent),
    radial-gradient(1px 1px at 25% 65%, white, transparent),
    radial-gradient(1px 1px at 30% 80%, white, transparent),
    radial-gradient(1px 1px at 35% 15%, white, transparent),
    radial-gradient(1px 1px at 40% 30%, white, transparent),
    radial-gradient(1px 1px at 45% 45%, white, transparent),
    radial-gradient(1px 1px at 50% 60%, white, transparent),
    radial-gradient(1px 1px at 55% 75%, white, transparent),
    radial-gradient(1px 1px at 60% 10%, white, transparent),
    radial-gradient(1px 1px at 65% 25%, white, transparent),
    radial-gradient(1px 1px at 70% 40%, white, transparent),
    radial-gradient(1px 1px at 75% 55%, white, transparent),
    radial-gradient(1px 1px at 80% 70%, white, transparent),
    radial-gradient(1px 1px at 85% 85%, white, transparent),
    radial-gradient(1px 1px at 90% 5%, white, transparent),
    radial-gradient(1px 1px at 95% 95%, white, transparent),
    radial-gradient(2px 2px at 12% 42%, rgba(255,255,255,0.8), transparent),
    radial-gradient(2px 2px at 38% 68%, rgba(255,255,255,0.8), transparent),
    radial-gradient(2px 2px at 62% 22%, rgba(255,255,255,0.8), transparent),
    radial-gradient(2px 2px at 88% 78%, rgba(255,255,255,0.8), transparent);
  background-size: 
    200% 200%, 200% 200%, 200% 200%, 200% 200%, 200% 200%,
    200% 200%, 200% 200%, 200% 200%, 200% 200%, 200% 200%,
    200% 200%, 200% 200%, 200% 200%, 200% 200%, 200% 200%,
    200% 200%, 200% 200%, 200% 200%, 250% 250%, 250% 250%,
    250% 250%, 250% 250%;
  animation: stars-drift 180s linear infinite;
  opacity: 0.6;
  pointer-events: none;
  z-index: 0;
}

@keyframes stars-drift {
  from { background-position: 0% 0%; }
  to { background-position: 100% 100%; }
}

/* SPACEJAY-190: Stop animation when closing to prevent FPS drops */
#upgrade-screen-overlay.animation-stopped::before {
  animation: none !important;
}

/* Ensure content is above starfield */
#upgrade-screen-overlay > * {
  position: relative;
  z-index: 1;
}

/* ═══════════════════════════════════════════════════════════════
   UPGRADE CONTAINER
   ═══════════════════════════════════════════════════════════════ */

.upgrade-container {
  max-width: min(900px, 95vw);
  width: 100%;
}

/* ═══════════════════════════════════════════════════════════════
   TITLE
   ═══════════════════════════════════════════════════════════════ */

.upgrade-title {
  font-size: clamp(1.2rem, 2.5vw, 1.8rem);
  letter-spacing: 4px;
  text-transform: uppercase;
  color: #C0C5CC;
  text-shadow: 
    0 0 30px rgba(255, 179, 71, 0.6),
    0 0 60px rgba(255, 179, 71, 0.3),
    0 4px 0 #1A1C20,
    0 8px 0 #05070A,
    2px 2px 4px rgba(0, 0, 0, 0.9);
  text-align: center;
  margin-bottom: 20px;
}

/* ═══════════════════════════════════════════════════════════════
   CURRENCY DISPLAY
   ═══════════════════════════════════════════════════════════════ */

#currency-display {
  font-size: 16px;
  text-align: center;
  margin-bottom: 30px;
  color: #FFB347;
  text-shadow: 
    0 0 15px rgba(255, 179, 71, 0.8),
    2px 2px 4px rgba(0, 0, 0, 0.9);
  letter-spacing: 1px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

/* SPACEJAY-168: Currency SVG icon */
.currency-svg-icon {
  width: 20px;
  height: 20px;
  display: inline-block;
  vertical-align: middle;
  filter: drop-shadow(0 0 4px rgba(255, 179, 71, 0.8));
}

/* ═══════════════════════════════════════════════════════════════
   UPGRADES GRID
   ═══════════════════════════════════════════════════════════════ */

.upgrades-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(250px, 100%), 1fr));
  gap: 20px;
  margin-bottom: 30px;
}

/* ═══════════════════════════════════════════════════════════════
   UPGRADE CARD - Ornate Panel Design
   ═══════════════════════════════════════════════════════════════ */

.upgrade-card {
  position: relative;
  padding: 60px 30px 50px 30px;
  box-sizing: border-box;
  transition: all 0.3s ease;
  display: flex;
  flex-direction: column;
  border: none;
  border-radius: 0;
  overflow: visible;
  background: transparent;
}

/* Panel frame background */
.upgrade-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: url('../../assets/menus/panel-frame2-clean.png');
  background-size: 100% 100%;
  background-repeat: no-repeat;
  background-position: center;
  image-rendering: auto;
  z-index: -1;
  transition: filter 0.3s ease;
}

/* Ensure content is above the frame */
.upgrade-card > * {
  position: relative;
  z-index: 1;
}

/* Hover state */
.upgrade-card:hover::before {
  filter: brightness(1.1);
}

.upgrade-card:hover {
  transform: translateY(-3px);
}

/* Special card (AI Companion) */
.upgrade-card.special {
  animation: specialPulse 2s ease-in-out infinite;
}

.upgrade-card.special::before {
  filter: brightness(1.15);
}

@keyframes specialPulse {
  0%, 100% { 
    filter: brightness(1.15);
  }
  50% { 
    filter: brightness(1.25);
  }
}

/* Special badge */
.upgrade-badge {
  position: absolute;
  top: -12px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(68, 136, 255, 0.2);
  color: #4488ff;
  padding: 4px 12px;
  font-size: 8px;
  font-weight: bold;
  border-radius: 10px;
  border: 2px solid #4488ff;
  box-shadow: none;
  letter-spacing: 1px;
  z-index: 10;
  text-shadow: 0 0 10px rgba(68, 136, 255, 0.8);
}

/* ═══════════════════════════════════════════════════════════════
   UPGRADE CARD CONTENT
   ═══════════════════════════════════════════════════════════════ */

.upgrade-header {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  margin-bottom: 10px;
  gap: 0;
}

.upgrade-name {
  font-size: 12px;
  color: #8A8F96;
  text-shadow: 2px 2px 4px #000;
  letter-spacing: 1px;
  flex: 1;
}

.upgrade-name.special {
  font-size: 14px;
  color: #4488ff;
  text-shadow: 
    0 0 20px rgba(68, 136, 255, 0.8),
    2px 2px 4px #000;
  font-weight: bold;
}

.upgrade-name.maxed {
  color: #FFB347;
  text-shadow: 
    0 0 15px rgba(255, 179, 71, 0.8),
    2px 2px 4px #000;
}

.upgrade-level {
  font-size: 11px;
  color: #8A8F96;
  text-shadow: 2px 2px 4px #000;
}

.upgrade-level.special {
  color: #4488ff;
}

.upgrade-level.maxed {
  color: #FFB347;
}

.upgrade-description {
  font-size: 8px;
  margin-bottom: 15px;
  line-height: 1.5;
  color: #8A8F96;
  text-shadow: 2px 2px 4px #000;
}

.upgrade-description.special {
  color: #aaccff;
}

.upgrade-maxed {
  font-size: 9px;
  text-align: center;
  padding: 10px;
  color: #FFB347;
  text-shadow: 
    0 0 15px rgba(255, 179, 71, 0.8),
    2px 2px 4px #000;
  letter-spacing: 1px;
}

/* ═══════════════════════════════════════════════════════════════
   UPGRADE BUTTONS - Unified Button System
   ═══════════════════════════════════════════════════════════════ */

.upgrade-buy-button {
  position: relative;
  padding: 10px 15px;
  font-size: 9px;
  font-weight: bold;
  letter-spacing: 2px;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.3s ease;
  border: none;
  width: 100%;
  min-height: 50px;
  image-rendering: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  color: #8A8F96;
  text-shadow: 
    0 0 8px rgba(138, 143, 150, 0.4),
    2px 2px 4px rgba(0, 0, 0, 0.8);
  font-family: 'Press Start 2P', monospace;
}

/* Special button (AI Companion) */
.upgrade-buy-button.special {
  font-size: 10px;
  font-weight: bold;
}

/* Disabled state */
.upgrade-buy-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Default state - Neutral button background */
.upgrade-buy-button::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: url('../../assets/menus/button-neutral-clean.png');
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  z-index: -1;
  width: 100%;
  height: 100%;
  transition: opacity 0.3s ease;
}

/* Cyan button overlay (hidden by default) */
.upgrade-buy-button::after {
  content: '';
  position: absolute;
  inset: 0;
  background-image: url('../../assets/menus/button-cyan-clean.png');
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  z-index: -1;
  width: 100%;
  height: 100%;
  opacity: 0;
  transition: opacity 0.3s ease;
}

/* Hover state - Show cyan button and change text color */
.upgrade-buy-button:not(:disabled):hover {
  color: #00D4FF;
  text-shadow: 
    0 0 15px rgba(0, 212, 255, 1),
    0 0 30px rgba(0, 212, 255, 0.6),
    2px 2px 4px rgba(0, 0, 0, 0.8);
  transform: translateY(-2px);
}

.upgrade-buy-button:not(:disabled):hover::after {
  opacity: 1;
}

/* ═══════════════════════════════════════════════════════════════
   CONTINUE BUTTON
   ═══════════════════════════════════════════════════════════════ */

.upgrade-continue-button {
  position: relative;
  padding: 16px 50px;
  font-size: 0.9rem;
  font-weight: bold;
  letter-spacing: 3px;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.3s ease;
  border: none;
  min-width: 300px;
  min-height: 70px;
  image-rendering: auto;
  display: block;
  margin: 0 auto;
  background: transparent;
  color: #8A8F96;
  text-shadow: 
    0 0 8px rgba(138, 143, 150, 0.4),
    2px 2px 4px rgba(0, 0, 0, 0.8);
  font-family: 'Press Start 2P', monospace;
}

/* Default state - Neutral button background */
.upgrade-continue-button::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: url('../../assets/menus/button-neutral-clean.png');
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  z-index: -1;
  width: 100%;
  height: 100%;
  transition: opacity 0.3s ease;
}

/* Cyan button overlay (hidden by default) */
.upgrade-continue-button::after {
  content: '';
  position: absolute;
  inset: 0;
  background-image: url('../../assets/menus/button-cyan-clean.png');
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  z-index: -1;
  width: 100%;
  height: 100%;
  opacity: 0;
  transition: opacity 0.3s ease;
}

/* Hover state - Show cyan button and change text color */
.upgrade-continue-button:hover {
  color: #00D4FF;
  text-shadow: 
    0 0 15px rgba(0, 212, 255, 1),
    0 0 30px rgba(0, 212, 255, 0.6),
    2px 2px 4px rgba(0, 0, 0, 0.8);
  transform: translateY(-2px);
}

.upgrade-continue-button:hover::after {
  opacity: 1;
}

/* ═══════════════════════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════════════════════ */

@media (max-width: 768px) {
  .upgrades-grid {
    grid-template-columns: 1fr;
    gap: 15px;
  }
  
  .upgrade-title {
    font-size: 1rem;
  }
  
  .upgrade-continue-button {
    min-width: 250px;
  }
  
  #upgrade-screen-overlay {
    padding: 30px 15px;
  }
}

@media (max-width: 480px) {
  .upgrade-card {
    padding: 50px 25px 45px 25px;
  }
  
  .upgrade-title {
    font-size: 0.9rem;
    letter-spacing: 2px;
  }
  
  #currency-display {
    font-size: 14px;
    margin-bottom: 20px;
  }
  
  .upgrade-continue-button {
    min-width: 200px;
    min-height: 60px;
    font-size: 0.8rem;
  }
  
  .upgrade-buy-button {
    min-height: 45px;
    font-size: 8px;
  }
}

@media (max-height: 700px) {
  #upgrade-screen-overlay {
    padding: 20px 15px;
  }
  
  .upgrade-title {
    font-size: 1rem;
    margin-bottom: 15px;
  }
  
  #currency-display {
    margin-bottom: 20px;
  }
  
  .upgrades-grid {
    gap: 15px;
    margin-bottom: 20px;
  }
  
  .upgrade-card {
    padding: 50px 25px 45px 25px;
  }
  
  .upgrade-continue-button {
    min-height: 60px;
  }
}


/* ═══════════════════════════════════════════════════════════════
   SPACEJAY-168: PROGRESS PIPS - Cyan filled indicators
   ═══════════════════════════════════════════════════════════════ */

.upgrade-pips {
  display: flex;
  gap: 6px;
  justify-content: center;
  align-items: center;
  margin-bottom: 15px;
  padding: 8px 0;
}

.upgrade-pip {
  width: 10px;
  height: 10px;
  border: 2px solid #3A3F46;
  background: rgba(10, 10, 10, 0.6);
  border-radius: 2px;
  transition: all 0.3s ease;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.5);
}

.upgrade-pip.filled {
  background: #00D4FF;
  border-color: #00D4FF;
  box-shadow: 
    0 0 6px rgba(0, 212, 255, 0.8),
    0 0 12px rgba(0, 212, 255, 0.4),
    inset 0 1px 2px rgba(255, 255, 255, 0.3);
}

/* ═══════════════════════════════════════════════════════════════
   SPACEJAY-168: SVG ICONS - Monochrome sci-fi style
   ═══════════════════════════════════════════════════════════════ */

.upgrade-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  color: #8A8F96;
  flex-shrink: 0;
  margin-right: 8px;
  filter: drop-shadow(0 0 3px currentColor);
  transition: color 0.3s ease, filter 0.3s ease;
}

.upgrade-icon.special {
  color: #4488ff;
  filter: drop-shadow(0 0 6px rgba(68, 136, 255, 0.8));
}

.upgrade-icon.maxed {
  color: #FFB347;
  filter: drop-shadow(0 0 6px rgba(255, 179, 71, 0.8));
}

.upgrade-svg-icon {
  width: 100%;
  height: 100%;
}

/* ═══════════════════════════════════════════════════════════════
   SPACEJAY-168: TIER CARD GLOW
   None → Bronze → Silver → Gold → Platinum → Rainbow
   Applied as outer box-shadow on the card
   ═══════════════════════════════════════════════════════════════ */

/* Bronze tier - warm subtle glow */
.upgrade-card.tier-bronze {
  box-shadow: 0 0 12px rgba(205, 127, 50, 0.4), 0 0 4px rgba(205, 127, 50, 0.2);
}

.upgrade-card.tier-bronze .upgrade-icon {
  color: #CD7F32;
}

.upgrade-card.tier-bronze .upgrade-name {
  color: #CD7F32;
  text-shadow: 0 0 8px rgba(205, 127, 50, 0.5), 2px 2px 4px #000;
}

/* Silver tier */
.upgrade-card.tier-silver {
  box-shadow: 0 0 15px rgba(192, 192, 192, 0.45), 0 0 5px rgba(192, 192, 192, 0.25);
}

.upgrade-card.tier-silver .upgrade-icon {
  color: #C0C0C0;
}

.upgrade-card.tier-silver .upgrade-name {
  color: #C0C0C0;
  text-shadow: 0 0 8px rgba(192, 192, 192, 0.5), 2px 2px 4px #000;
}

/* Gold tier */
.upgrade-card.tier-gold {
  box-shadow: 0 0 18px rgba(255, 215, 0, 0.5), 0 0 6px rgba(255, 215, 0, 0.3);
}

.upgrade-card.tier-gold .upgrade-icon {
  color: #FFD700;
  filter: drop-shadow(0 0 6px rgba(255, 215, 0, 0.6));
}

.upgrade-card.tier-gold .upgrade-name {
  color: #FFD700;
  text-shadow: 0 0 10px rgba(255, 215, 0, 0.6), 2px 2px 4px #000;
}

/* Platinum tier */
.upgrade-card.tier-platinum {
  box-shadow: 0 0 22px rgba(229, 228, 226, 0.5), 0 0 8px rgba(229, 228, 226, 0.3);
}

.upgrade-card.tier-platinum .upgrade-icon {
  color: #E5E4E2;
  filter: drop-shadow(0 0 8px rgba(229, 228, 226, 0.7));
}

.upgrade-card.tier-platinum .upgrade-name {
  color: #E5E4E2;
  text-shadow: 0 0 12px rgba(229, 228, 226, 0.6), 2px 2px 4px #000;
}

/* Rainbow tier (max level) - animated color-cycling glow */
.upgrade-card.tier-rainbow {
  animation: rainbowGlow 4s linear infinite;
}

.upgrade-card.tier-rainbow .upgrade-icon {
  animation: rainbowColor 4s linear infinite;
  filter: drop-shadow(0 0 10px currentColor);
}

.upgrade-card.tier-rainbow .upgrade-name {
  animation: rainbowColor 4s linear infinite;
  text-shadow: 0 0 15px currentColor, 2px 2px 4px #000;
}

@keyframes rainbowGlow {
  0%   { box-shadow: 0 0 20px rgba(255, 0, 0, 0.5),   0 0 8px rgba(255, 0, 0, 0.3); }
  16%  { box-shadow: 0 0 20px rgba(255, 165, 0, 0.5), 0 0 8px rgba(255, 165, 0, 0.3); }
  33%  { box-shadow: 0 0 20px rgba(255, 255, 0, 0.5), 0 0 8px rgba(255, 255, 0, 0.3); }
  50%  { box-shadow: 0 0 20px rgba(0, 255, 0, 0.5),   0 0 8px rgba(0, 255, 0, 0.3); }
  66%  { box-shadow: 0 0 20px rgba(0, 150, 255, 0.5), 0 0 8px rgba(0, 150, 255, 0.3); }
  83%  { box-shadow: 0 0 20px rgba(180, 0, 255, 0.5), 0 0 8px rgba(180, 0, 255, 0.3); }
  100% { box-shadow: 0 0 20px rgba(255, 0, 0, 0.5),   0 0 8px rgba(255, 0, 0, 0.3); }
}

@keyframes rainbowColor {
  0%   { color: #ff4444; }
  16%  { color: #ffa500; }
  33%  { color: #ffff44; }
  50%  { color: #44ff44; }
  66%  { color: #4499ff; }
  83%  { color: #b844ff; }
  100% { color: #ff4444; }
}

/* Tier-based icon coloring in header */
.upgrade-icon.tier-bronze { color: #CD7F32; }
.upgrade-icon.tier-silver { color: #C0C0C0; }
.upgrade-icon.tier-gold { color: #FFD700; filter: drop-shadow(0 0 6px rgba(255, 215, 0, 0.6)); }
.upgrade-icon.tier-platinum { color: #E5E4E2; filter: drop-shadow(0 0 8px rgba(229, 228, 226, 0.7)); }
.upgrade-icon.tier-rainbow { animation: rainbowColor 4s linear infinite; filter: drop-shadow(0 0 10px currentColor); }

/* ═══════════════════════════════════════════════════════════════
   SPACEJAY-168: BURGUNDY CURRENCY - Can't afford indicator
   ═══════════════════════════════════════════════════════════════ */

/* Total currency turns burgundy when player can't afford any upgrade */
#currency-display.currency-unaffordable {
  color: #8B0000;
  text-shadow: 
    0 0 10px rgba(139, 0, 0, 0.6),
    2px 2px 4px rgba(0, 0, 0, 0.9);
}

#currency-display.currency-unaffordable .currency-svg-icon {
  color: #8B0000;
  filter: drop-shadow(0 0 4px rgba(139, 0, 0, 0.6));
}

/* Individual card cost turns burgundy when can't afford */
.upgrade-buy-button.unaffordable {
  color: #8B0000;
  text-shadow: 
    0 0 6px rgba(139, 0, 0, 0.5),
    2px 2px 4px rgba(0, 0, 0, 0.8);
}

.btn-coin-icon.unaffordable .btn-coin-svg {
  color: #8B0000;
  filter: drop-shadow(0 0 3px rgba(139, 0, 0, 0.5));
}


/* SPACEJAY-168: Button coin icon */
.btn-coin-icon {
  display: inline-flex;
  align-items: center;
  margin-left: 6px;
  vertical-align: middle;
}

.btn-coin-svg {
  width: 14px;
  height: 14px;
  color: #FFB347;
  filter: drop-shadow(0 0 3px rgba(255, 179, 71, 0.6));
}


/* ═══════════════════════════════════════════════════════════════
   SPACEJAY-252: GAMEPAD FOCUS - D-pad navigation highlight
   Replicates the hover state when focused via controller
   ═══════════════════════════════════════════════════════════════ */

.upgrade-buy-button.gamepad-focus:not(:disabled)::after {
  opacity: 1;
}

.upgrade-continue-button.gamepad-focus::after {
  opacity: 1;
}
