/* ============================================
   MARKET
   Market items, earnings, tooltips, buttons
   ============================================ */

.muted {
  opacity: 0.85;
  font-size: 16px;
  font-style: italic;
  padding: 12px;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.6), 0 0 4px rgba(255, 255, 255, 0.2);
}

#earnings {
  font-size: 22px;
  margin: 6px 0 14px;
}

/* Items grid */
.items {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2px;
  padding: 0;
  padding-top: 2px;
}

.items.randomized {
  /* Reserved for future use */
}

/* Individual item card */
.item {
  background: linear-gradient(180deg, var(--blue-primary), var(--blue-secondary));
  border-left: 1px solid var(--blue-accent);
  padding: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 0;
  cursor: pointer;
  transition: transform 0.3s ease, box-shadow 0.3s ease, filter 0.3s ease, border-color 0.3s ease;
  position: relative;
  min-height: 220px;
  box-shadow: inset 0 1px 0 var(--blue-highlight), 0 0 0 1px rgba(0, 0, 0, 0.2);
  border-radius: 16px 0 16px 0;
  will-change: transform, box-shadow;
}

/* Item type variants */
.item.entity-upgrade {
  background: linear-gradient(180deg, var(--green-primary), var(--green-secondary));
  border-left-color: var(--green-accent);
  box-shadow: inset 0 1px 0 var(--green-glow), 0 0 0 1px rgba(0, 0, 0, 0.2);
}

.item.global-upgrade {
  background: linear-gradient(180deg, var(--blue-primary), var(--blue-secondary));
  border-left-color: var(--blue-accent);
  box-shadow: inset 0 1px 0 var(--blue-highlight), 0 0 0 1px rgba(0, 0, 0, 0.2);
}

.item.global-tiered-upgrade {
  background: linear-gradient(180deg, var(--purple-primary), var(--purple-secondary));
  border-left-color: var(--purple-accent);
  box-shadow: inset 0 1px 0 var(--purple-highlight), 0 0 0 1px rgba(0, 0, 0, 0.2);
}

.item.global-effect {
  background: linear-gradient(180deg, var(--red-primary), var(--red-secondary));
  border-left-color: var(--red-accent);
  box-shadow: inset 0 1px 0 var(--red-highlight), 0 0 0 1px rgba(0, 0, 0, 0.2);
}

/* Item hover states */
.item:hover:not(.disabled) {
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35), 0 0 0 1px rgba(255, 255, 255, 0.15) inset, inset 0 1px 0 rgba(255, 255, 255, 0.3);
  filter: brightness(1.15);
}

.item.entity-upgrade:hover:not(.disabled) {
  border-left-color: var(--green-glow);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35), 0 0 12px rgba(0, 255, 0, 0.3), inset 0 1px 0 var(--green-glow);
}

.item.global-upgrade:hover:not(.disabled) {
  border-left-color: var(--blue-highlight);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35), 0 0 12px rgba(0, 100, 255, 0.3), inset 0 1px 0 var(--blue-highlight);
}

.item.global-tiered-upgrade:hover:not(.disabled) {
  border-left-color: var(--purple-highlight);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35), 0 0 12px rgba(180, 0, 255, 0.3), inset 0 1px 0 var(--purple-highlight);
}

.item.global-effect:hover:not(.disabled) {
  border-left-color: var(--red-highlight);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35), 0 0 12px rgba(255, 0, 0, 0.3), inset 0 1px 0 var(--red-highlight);
}

.item:active:not(.disabled) {
  transform: translateY(-1px);
}

.item.disabled {
  opacity: 0.5;
  cursor: not-allowed;
  background: linear-gradient(180deg, rgba(128, 128, 128, 0.3), rgba(64, 64, 64, 0.3));
  border-left-color: rgba(128, 128, 128, 0.3);
  color: white;
  box-shadow: none;
}

.item.disabled:hover {
  transform: none;
  box-shadow: none;
}

/* Purchase animation */
.item.purchasing {
  animation: purchasePulse 0.6s ease-in-out;
}

@keyframes purchasePulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.05); box-shadow: 0 0 20px rgba(255, 255, 255, 0.5); }
  100% { transform: scale(1); }
}

/* Shimmer animation */
@keyframes shimmer {
  0% {
    transform: translateX(-100%) translateY(-100%);
  }
  100% {
    transform: translateX(100%) translateY(100%);
  }
}

.item.shimmer-active {
  overflow: hidden;
}

.item.shimmer-active::before {
  content: '';
  position: absolute;
  inset: 0;
  width: 200%;
  height: 200%;
  background: linear-gradient(
    135deg,
    transparent 25%,
    rgba(255, 255, 255, 0.08) 45%,
    rgba(255, 255, 255, 0.15) 50%,
    rgba(255, 255, 255, 0.08) 55%,
    transparent 75%
  );
  transform: translateX(-100%) translateY(-100%);
  animation: shimmer 1.5s ease-in-out forwards;
  pointer-events: none;
  z-index: 10;
}

/* Badges */
.deal-badge {
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  text-align: center;
  min-width: 60px;
  transition: opacity 0.3s ease, background 0.3s ease, color 0.3s ease;
  transform: translate(30px, -5px) rotate(-10deg);
}

.deal-badge.active {
  background: linear-gradient(180deg, var(--red-primary), var(--red-secondary));
  color: white;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
  box-shadow: 0 2px 8px rgba(25, 10, 10, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.3);
}

.deal-badge.inactive {
  background: transparent;
  color: transparent;
  border: 1px solid transparent;
  text-shadow: none;
}

.free-badge {
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  text-align: center;
  min-width: 60px;
  transition: opacity 0.3s ease, background 0.3s ease;
  transform: translate(0px, 0px) rotate(-10deg);
  background: linear-gradient(180deg, var(--green-primary), var(--green-secondary));
  color: white;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
  box-shadow: 0 2px 8px rgba(10, 25, 10, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.3);
}

/* Item header */
.item h3 {
  margin: 0;
  padding: 16px;
  padding-bottom: 0;
  font-size: 18px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  color: var(--fg);
  text-shadow: 1px 2px 2px rgba(0, 0, 0, 0.8);
  font-weight: 700;
}

.item .tier-badge {
  margin-left: 4px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.15), rgba(255, 255, 255, 0.08));
  padding: 4px 8px;
  border-radius: 0;
  font-size: 11px;
  font-weight: 600;
  color: var(--fg);
  min-width: 40px;
  text-align: center;
  border-left: 1px solid rgba(255, 255, 255, 0.2);
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
  transition: background 0.3s ease, color 0.3s ease;
}

.price {
  color: var(--hud);
  font-weight: 700;
}

/* Button row */
.btnRow {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  padding-top: 20px;
}

/* Buttons */
.btn {
  border: none;
  border-left: 1px solid rgba(255, 255, 255, 0.2);
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0.06));
  color: var(--fg);
  padding: 10px 16px;
  border-radius: 0;
  cursor: pointer;
  font-weight: 700;
  transition: transform 0.3s ease, background 0.3s ease, box-shadow 0.3s ease;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1), 0 0 0 1px rgba(0, 0, 0, 0.2);
}

.btn:hover {
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.18), rgba(255, 255, 255, 0.12));
  transform: translateY(-1px);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.15), 0 2px 8px rgba(0, 0, 0, 0.3), 0 0 0 1px rgba(0, 0, 0, 0.2);
}

.btn.abutt {
  margin-right: -15px;
  text-align: left;
  padding-right: 15px;
}

.btn.red,
.btn.abutt:hover {
  background: linear-gradient(135deg, var(--red-primary), var(--red-secondary));
  color: #ffcccc;
  box-shadow: 0 0 8px rgba(255, 0, 0, 0.3), inset 0 1px 0 var(--red-highlight);
  border-left-color: var(--red-accent);
}

.btn:disabled {
  background: linear-gradient(135deg, rgba(128, 128, 128, 0.3), rgba(64, 64, 64, 0.3));
  opacity: 0.5;
  cursor: not-allowed;
  box-shadow: none;
}

.btn.primary {
  background: linear-gradient(135deg, var(--accent), var(--green-primary));
  color: #052815;
  box-shadow: 0 0 12px rgba(39, 240, 156, 0.45), inset 0 1px 0 var(--green-glow);
  border-left-color: var(--green-accent);
}

.btn.danger {
  background: linear-gradient(135deg, var(--warning), var(--red-primary));
  color: #fff;
  box-shadow: 0 0 12px rgba(255, 107, 107, 0.45), inset 0 1px 0 var(--red-highlight);
  border-left-color: var(--red-accent);
}

.btn.danger:hover {
  background: linear-gradient(135deg, var(--red-highlight), var(--warning));
  box-shadow: 0 0 16px rgba(255, 107, 107, 0.6), inset 0 1px 0 var(--red-highlight);
  transform: translateY(-1px);
}

/* Bar (used for purchase buttons) */
.bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  width: 100%;
  border: none;
  border-left: 1px solid rgba(255, 255, 255, 0.2);
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0.06));
  color: var(--fg);
  padding: 10px 16px;
  border-radius: 0;
  cursor: pointer;
  font-weight: 700;
  transition: background 0.3s ease, box-shadow 0.3s ease;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1), 0 0 0 1px rgba(0, 0, 0, 0.2);
}

.buy-btn {
  /* Reserved for future use */
}

/* Panel header */
.panelHeader {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  border-left: 1px solid rgba(255, 255, 255, 0.05);
}

.panelCredits {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.panelCredits .label {
  opacity: 0.85;
  font-weight: 700;
  letter-spacing: 0.3px;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.6);
}

.panelCredits .value {
  font-size: 26px;
  font-weight: 900;
  color: var(--accent);
  text-shadow: 0 0 12px rgba(39, 240, 156, 0.5), 0 0 20px rgba(39, 240, 156, 0.35), 1px 1px 2px rgba(0, 0, 0, 0.8);
}

.panelCredits .value.negative {
  color: var(--warning);
  text-shadow: 0 0 12px rgba(255, 107, 107, 0.5), 0 0 20px rgba(255, 107, 107, 0.35), 1px 1px 2px rgba(0, 0, 0, 0.8);
}

/* Earnings counter */
.earningsCounter {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
}

.earningsCounter .creditsValue {
  font-size: 40px;
  font-weight: 900;
  color: var(--accent);
  letter-spacing: 0.5px;
  text-shadow: 0 0 14px rgba(39, 240, 156, 0.55), 0 0 26px rgba(39, 240, 156, 0.35);
}

/* Earnings lines */
.earningsLine {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  gap: 16px;
  padding: 10px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  opacity: 1;
  transition: opacity 0.3s ease, background 0.3s ease, border-color 0.3s ease, padding-left 0.2s ease;
  background: transparent;
  border-left: 2px solid transparent;
  position: relative;
  /* Note: DO NOT use transform here - it causes compositing bugs with child tooltip opacity */
}

.earningsLine:hover {
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.04), transparent);
  border-left-color: var(--accent);
  padding-left: 18px; /* 16px base + 2px shift */
}

.earningsLine:hover .earningsLabel {
  color: white;
}

.earningsLine.negative:hover {
  border-left-color: var(--warning);
}

.earningsLine.active {
  background: linear-gradient(90deg, rgba(39, 240, 156, 0.06), transparent);
  border-left-color: rgba(39, 240, 156, 0.4);
}

.earningsLine.active .earningsLabel {
  color: rgba(255, 255, 255, 0.75);
}

.earningsLine.completed .earningsLabel {
  color: rgba(255, 255, 255, 0.5);
}

.earningsLine.completed:hover .earningsLabel {
  color: white;
}

.earningsLine.completed .earningsValue {
  color: rgba(39, 240, 156, 0.7);
}

.earningsLine.negative.active {
  background: linear-gradient(90deg, rgba(255, 107, 107, 0.06), transparent);
  border-left-color: rgba(255, 107, 107, 0.4);
}

.earningsLabel {
  font-size: 15px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.55);
  text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.8);
  flex: 2;
}

.earningsValue {
  font-size: 17px;
  font-weight: 700;
  color: var(--accent);
  text-shadow: 0 0 8px rgba(39, 240, 156, 0.4), 1px 1px 2px rgba(0, 0, 0, 0.8);
  flex: 1;
  text-align: right;
}

.earningsLine.negative .earningsValue {
  color: var(--warning);
  text-shadow: 0 0 8px rgba(255, 107, 107, 0.4), 1px 1px 2px rgba(0, 0, 0, 0.8);
}

.earningsLine.negative.completed .earningsValue {
  color: rgba(255, 107, 107, 0.7);
}

/* Earnings total */
.earningsTotal,
.earningsTotal:hover {
  margin-top: 12px;
  padding: 14px 16px;
  background: linear-gradient(90deg, rgba(39, 240, 156, 0.12), rgba(39, 240, 156, 0.04));
  border-left: 3px solid var(--accent);
  border-bottom: none;
  box-shadow: inset 0 1px 0 rgba(39, 240, 156, 0.15);
}

.earningsTotal .earningsLabel {
  font-size: 16px;
  font-weight: 700;
  color: white;
  text-shadow: 0 0 8px rgba(255, 255, 255, 0.3), 1px 1px 2px rgba(0, 0, 0, 0.8);
}

.earningsTotal .earningsValue {
  font-size: 20px;
  font-weight: 800;
  text-shadow: 0 0 12px rgba(39, 240, 156, 0.6), 0 0 24px rgba(39, 240, 156, 0.3), 1px 1px 2px rgba(0, 0, 0, 0.8);
}

.earningsTotal.negative {
  background: linear-gradient(90deg, rgba(255, 107, 107, 0.12), rgba(255, 107, 107, 0.04));
  border-left-color: var(--warning);
}

.earningsTotal.negative .earningsValue {
  color: var(--warning);
  text-shadow: 0 0 12px rgba(255, 107, 107, 0.6), 0 0 24px rgba(255, 107, 107, 0.3), 1px 1px 2px rgba(0, 0, 0, 0.8);
}

/* Tooltips */
.tooltip-indicator {
  color: rgb(39, 240, 156);
  font-size: 14px;
  margin-left: 8px;
  cursor: help;
  transition: opacity 0.2s ease;
}

.war-bond-tooltip {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translateY(-50%) translateZ(0);
  background: rgb(8, 12, 28);
  border: 1px solid rgb(40, 60, 100);
  border-radius: 16px 0 16px 0;
  padding: 16px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.8);
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  margin-left: 12px;
  backface-visibility: hidden;
}

.tooltip-title {
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 8px;
  font-size: 14px;
  text-align: center;
  border-bottom: 1px solid rgba(39, 240, 156, 0.3);
  padding-bottom: 8px;
}

.bond-item {
  font-size: 13px;
  color: white;
  padding: 2px 0;
  text-align: right;
}

.earningsLine:hover .war-bond-tooltip {
  opacity: 1;
  pointer-events: auto;
}

/* Emergency War Bond Widget */
.emergency-war-bond-widget {
  position: absolute;
  animation: slideInFromRight 0.5s ease-out;
  pointer-events: auto;
  width: 300px;
}

.emergency-war-bond-header {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 8px;
}

.dismiss-button {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: rgba(255, 255, 255, 0.8);
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 18px;
  font-weight: bold;
  transition: transform 0.2s ease, background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.dismiss-button:hover {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.5);
  color: rgba(255, 255, 255, 1);
  transform: scale(1.1);
}

.dismiss-button:active {
  transform: scale(0.95);
}

@keyframes slideInFromRight {
  0% {
    transform: translateX(100%);
    opacity: 0;
  }
  100% {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes emergencyPulse {
  0%, 100% {
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6), inset 0 1px 0 var(--red-highlight);
  }
  50% {
    box-shadow: 0 8px 32px rgba(255, 0, 0, 0.3), inset 0 1px 0 var(--red-highlight), 0 0 20px rgba(255, 0, 0, 0.4);
  }
}

@keyframes emergencyBadgePulse {
  0%, 100% {
    transform: translate(30px, -5px) rotate(-10deg) scale(1);
  }
  50% {
    transform: translate(30px, -5px) rotate(-10deg) scale(1.1);
  }
}
