/* Trading Post — modal panel, market, create offer, history. */

#trade-stage {
  position: fixed; inset: 0; z-index: 95;
  background: radial-gradient(ellipse at center, #1a1538 0%, #06061a 65%, #000 100%);
  overflow-y: auto;
  color: #e9ecff;
  padding: 18px;
}
.trade-header {
  display: flex; align-items: center; gap: 16px;
  margin-bottom: 18px;
  max-width: 1200px;
  margin-left: auto; margin-right: auto;
}
.trade-x {
  background: rgba(255,255,255,0.08);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.18);
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
}
.trade-title {
  font-size: clamp(22px, 3vw, 36px);
  margin: 0;
  background: linear-gradient(120deg, #ffd166, #ef476f, #06d6a0);
  -webkit-background-clip: text; background-clip: text;
  color: transparent;
}
.trade-tabs { display: flex; gap: 8px; margin-left: auto; flex-wrap: wrap; }
.trade-tab {
  background: rgba(255,255,255,0.04);
  color: #d4e0ff;
  border: 1px solid rgba(255,255,255,0.1);
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
  font-weight: 600;
}
.trade-tab.active {
  background: linear-gradient(135deg, #ffd166, #ef476f);
  color: #1a0518;
  border-color: #ffd166;
  box-shadow: 0 0 18px rgba(255,209,102,0.4);
}

.trade-body {
  max-width: 1200px;
  margin: 0 auto;
}

.trade-loading, .trade-empty, .trade-error, .trade-hint {
  text-align: center;
  padding: 30px;
  font-size: 14px;
  opacity: 0.8;
}
.trade-empty a { color: #ffd166; cursor: pointer; text-decoration: underline; }
.trade-error { color: #ff8a8a; background: rgba(239,71,111,0.1); border-radius: 12px; }

.trade-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 16px;
}

.offer-card {
  background: linear-gradient(160deg, rgba(255,255,255,0.04), rgba(0,0,0,0.4));
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 12px;
  padding: 14px;
  display: flex; flex-direction: column; gap: 12px;
}
.offer-card.mine { border-color: rgba(255,209,102,0.4); }
.offer-card.history { opacity: 0.85; }
.offer-card.status-accepted { border-color: rgba(6,214,160,0.4); }
.offer-card.status-cancelled { border-color: rgba(255,150,150,0.3); }
.offer-card.status-expired { border-color: rgba(150,150,150,0.2); }
.offer-champion {
  font-size: 12px;
  opacity: 0.7;
  letter-spacing: 1px;
  text-transform: uppercase;
}
.offer-swap {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 10px;
  align-items: center;
}
.swap-arrow {
  font-size: 26px;
  text-align: center;
  color: #ffd166;
  text-shadow: 0 0 8px #ffd166aa;
}

.card-tile {
  background: linear-gradient(160deg, color-mix(in srgb, var(--type) 30%, transparent), rgba(0,0,0,0.5));
  border: 1px solid var(--type, #888);
  border-radius: 10px;
  padding: 10px;
  text-align: center;
  position: relative;
}
.card-tile[data-rare="legendary"] {
  border-color: #ffd166;
  box-shadow: 0 0 14px rgba(255,209,102,0.25);
}
.card-tile[data-rare="mythical"] {
  border-color: #ffb3ff;
  box-shadow: 0 0 14px rgba(255,179,255,0.3);
}
.tile-label {
  font-size: 10px;
  letter-spacing: 1px;
  text-transform: uppercase;
  opacity: 0.6;
  margin-bottom: 4px;
}
.tile-art {
  width: 60px;
  height: 60px;
  margin: 0 auto;
  display: grid;
  place-items: center;
}
.tile-art img { width: 100%; height: 100%; object-fit: contain; image-rendering: pixelated; }
.tile-empty {
  font-size: 30px;
  opacity: 0.3;
}
.tile-name {
  font-weight: 700;
  font-size: 13px;
  margin: 4px 0 2px;
}
.tile-stats {
  font-size: 10px;
  opacity: 0.8;
}

.offer-card button.primary {
  background: linear-gradient(135deg, #06d6a0, #118ab2);
  color: #06061a;
  font-weight: 700;
  padding: 10px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
}
.offer-card button.primary:hover { filter: brightness(1.1); }
.offer-card button:disabled {
  background: rgba(255,255,255,0.06);
  color: rgba(255,255,255,0.4);
  border: 1px solid rgba(255,255,255,0.1);
  padding: 10px;
  border-radius: 8px;
  cursor: not-allowed;
}
.offer-card button.danger {
  background: rgba(239,71,111,0.18);
  color: #ff8a8a;
  border: 1px solid rgba(239,71,111,0.4);
  padding: 9px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 12px;
}

/* Create-offer flow */
.trade-create {
  background: rgba(0,0,0,0.3);
  border-radius: 14px;
  padding: 18px;
}
.trade-step {
  display: flex;
  gap: 14px;
  margin-bottom: 18px;
}
.trade-step-num {
  width: 36px; height: 36px; border-radius: 50%;
  background: linear-gradient(135deg, #ffd166, #ef476f);
  color: #1a0518;
  display: grid; place-items: center;
  font-weight: 900; font-size: 16px;
  flex-shrink: 0;
}
.trade-step-content { flex: 1; min-width: 0; }
.trade-step-title {
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 10px;
  color: #ffd166;
}
.trade-pick-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 8px;
  max-height: 320px;
  overflow-y: auto;
  padding: 4px;
  background: rgba(0,0,0,0.25);
  border-radius: 8px;
}
.trade-want-search {
  width: 100%;
  background: rgba(0,0,0,0.4);
  border: 1px solid rgba(255,255,255,0.18);
  color: #fff;
  padding: 9px 12px;
  border-radius: 8px;
  font-size: 14px;
  margin-bottom: 10px;
}
.trade-pick-tile {
  background: linear-gradient(160deg, color-mix(in srgb, var(--type) 30%, transparent), rgba(0,0,0,0.5));
  border: 1.5px solid var(--type, #888);
  border-radius: 8px;
  padding: 8px 4px;
  color: #fff;
  cursor: pointer;
  text-align: center;
  font: inherit;
  position: relative;
  transition: transform 0.12s, box-shadow 0.12s;
}
.trade-pick-tile:hover {
  transform: translateY(-3px);
  box-shadow: 0 4px 14px rgba(0,0,0,0.4);
}
.trade-pick-tile.selected {
  outline: 2px solid #ffd166;
  outline-offset: 2px;
  box-shadow: 0 0 18px rgba(255,209,102,0.5);
}
.trade-pick-tile[data-rare="legendary"] { border-color: #ffd166; }
.trade-pick-tile[data-rare="mythical"]  { border-color: #ffb3ff; }
.tile-art-sm {
  width: 50px; height: 50px;
  margin: 0 auto;
  display: grid; place-items: center;
}
.tile-art-sm img { width: 100%; height: 100%; object-fit: contain; image-rendering: pixelated; }
.tile-name-sm {
  font-size: 10px; font-weight: 700;
  margin-top: 2px;
  line-height: 1.2;
}
.tile-qty {
  position: absolute;
  top: 2px; right: 4px;
  font-size: 9px;
  background: rgba(0,0,0,0.7);
  padding: 1px 5px;
  border-radius: 999px;
  color: #ffd166;
}
.trade-submit-row {
  display: flex; align-items: center; gap: 14px;
  padding-top: 14px;
  border-top: 1px solid rgba(255,255,255,0.08);
}
.trade-summary {
  flex: 1;
  font-size: 14px;
  opacity: 0.85;
}
#trade-submit {
  background: linear-gradient(135deg, #06d6a0, #118ab2);
  color: #06061a;
  font-weight: 700;
  padding: 12px 24px;
  border-radius: 10px;
  border: none;
  font-size: 14px;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(6,214,160,0.4);
}
#trade-submit:disabled {
  background: rgba(255,255,255,0.1);
  color: rgba(255,255,255,0.4);
  box-shadow: none;
  cursor: not-allowed;
}

@media (max-width: 720px) {
  .trade-tabs { width: 100%; }
  .trade-tabs .trade-tab { flex: 1 1 0; min-width: 80px; font-size: 11px; padding: 7px 8px; }
  .trade-step { flex-direction: column; gap: 8px; }
  .trade-pick-grid { grid-template-columns: repeat(auto-fill, minmax(80px, 1fr)); max-height: 260px; }
  .offer-swap { grid-template-columns: 1fr; }
  .swap-arrow { transform: rotate(90deg); }
}
