/* Market page */

body.site-page--market {
  overflow-x: hidden;
}

.market-main {
  max-width: 1200px;
  width: 100%;
  box-sizing: border-box;
}

.market-hero {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
  width: 100%;
}

.market-hero__aside {
  display: flex;
  align-items: stretch;
  gap: 12px;
  flex-wrap: wrap;
  margin-left: auto;
}

.market-npc-card {
  display: flex;
  align-items: stretch;
  max-width: 280px;
  min-width: 200px;
}

.market-npc-btn {
  width: 100%;
  justify-content: center;
  text-align: center;
  white-space: normal;
  line-height: 1.3;
  min-height: 52px;
  padding: 0.65rem 0.9rem !important;
  font-size: 0.92rem !important;
  font-weight: 700 !important;
  text-decoration: none;
  pointer-events: auto;
}

.market-npc-btn.is-waiting {
  background: linear-gradient(180deg, #3d9b78, #2a7a5c) !important;
  border-color: rgba(90, 190, 150, 0.55) !important;
  color: #f0fff8 !important;
  cursor: default;
  pointer-events: none;
}

.market-npc-btn.is-selling {
  background: linear-gradient(180deg, #2ecc71, #1f9e55) !important;
  border-color: rgba(80, 220, 140, 0.7) !important;
  color: #fff !important;
  box-shadow: 0 0 0 2px rgba(46, 204, 113, 0.25), 0 10px 24px rgba(20, 90, 50, 0.35) !important;
  cursor: default;
  pointer-events: none;
  animation: market-npc-glow 2.4s ease-in-out infinite alternate;
}

@keyframes market-npc-glow {
  from {
    filter: brightness(1);
  }
  to {
    filter: brightness(1.08);
  }
}

.market-balance-card {
  min-width: 160px;
  padding: 14px 18px;
  border-radius: 14px;
  background: linear-gradient(145deg, rgba(252, 212, 138, 0.16), rgba(49, 67, 84, 0.9));
  border: 1px solid rgba(252, 212, 138, 0.35);
  box-shadow: 0 12px 30px rgba(5, 31, 69, 0.35);
  transition: opacity 0.2s ease;
}

.market-balance-card.is-guest {
  opacity: 0.55;
}

.market-balance-card__label {
  display: block;
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--site-muted);
  margin-bottom: 4px;
}

.market-balance-card__value {
  font-size: 28px;
  font-weight: 750;
  color: var(--site-sand);
  letter-spacing: 0.02em;
}

.market-gate {
  margin: 0 0 16px;
  padding: 16px 18px;
  border: 1px dashed rgba(212, 62, 20, 0.45);
  border-radius: 14px;
  text-align: center;
  background: rgba(212, 62, 20, 0.08);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.market-gate[hidden] {
  display: none !important;
}

.market-gate p {
  margin: 0;
  color: var(--site-muted);
}

.market-trade-locked {
  padding: 28px 12px;
  text-align: center;
  color: var(--site-muted);
  border: 1px dashed rgba(208, 208, 180, 0.2);
  border-radius: 12px;
}

.market-trade-locked[hidden],
#market-trade-content[hidden] {
  display: none !important;
}

.market-layout {
  display: grid;
  grid-template-columns: minmax(0, 380px) minmax(0, 1fr);
  gap: 22px;
  align-items: start;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

.market-panel {
  background: rgba(49, 67, 84, 0.55);
  border: 1px solid rgba(252, 212, 138, 0.16);
  border-radius: 18px;
  padding: 18px;
  backdrop-filter: blur(6px);
  transition: border-color 0.2s ease, background 0.2s ease;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
  overflow: hidden;
}

.market-panel__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.market-panel__head h2 {
  margin: 0;
  font-size: 18px;
}

.market-hint {
  margin: 0 0 14px;
  font-size: 13px;
  color: var(--site-muted);
}

.market-section-title {
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(232, 240, 228, 0.5);
  margin: 12px 0 8px;
}

.market-grid {
  display: grid;
  grid-template-columns: repeat(9, minmax(0, 1fr));
  gap: 4px;
}

.market-grid--hotbar {
  margin-bottom: 4px;
}

.market-slot {
  aspect-ratio: 1;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid rgba(232, 240, 228, 0.1);
  position: relative;
  display: grid;
  place-items: center;
  cursor: default;
  overflow: hidden;
}

.market-slot.is-filled {
  cursor: pointer;
  transition: border-color 0.15s ease, transform 0.1s ease;
}

.market-slot.is-filled:hover {
  border-color: rgba(252, 212, 138, 0.55);
  transform: translateY(-1px);
}

.market-slot img {
  width: 70%;
  height: 70%;
  object-fit: contain;
  image-rendering: pixelated;
}

.market-slot__label {
  font-size: 8px;
  text-align: center;
  padding: 2px;
  color: var(--site-muted);
  display: none;
  line-height: 1.1;
}

.market-slot__label.is-visible {
  display: block;
}

.market-slot__amt {
  position: absolute;
  right: 3px;
  bottom: 2px;
  font-size: 10px;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 0 3px #000, 0 1px 2px #000, 1px 0 2px #000;
}

.market-tabs {
  display: flex;
  flex-wrap: nowrap;
  gap: 6px;
  margin: 0 0 14px;
  max-width: 100%;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scrollbar-width: thin;
  padding-bottom: 4px;
  -webkit-overflow-scrolling: touch;
}

.market-tabs::-webkit-scrollbar {
  height: 4px;
}

.market-tabs::-webkit-scrollbar-thumb {
  background: rgba(212, 62, 20, 0.45);
  border-radius: 4px;
}

.market-tab {
  appearance: none;
  flex: 0 0 auto;
  border: 1px solid rgba(208, 208, 180, 0.14);
  background: rgba(0, 0, 0, 0.22);
  color: var(--site-muted);
  font: inherit;
  font-size: 12px;
  font-weight: 650;
  padding: 7px 12px;
  min-height: 36px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}

.market-tab:hover {
  color: var(--site-cream);
  border-color: rgba(212, 62, 20, 0.4);
}

.market-tab.is-active {
  color: #051f45;
  background: linear-gradient(180deg, #fcd48a, #e8b86a);
  border-color: rgba(252, 212, 138, 0.85);
}

.market-tab[data-cat="ore"].is-active {
  background: linear-gradient(180deg, #c9a06a, #8b6914);
  color: #fff8e8;
}

.market-tab[data-cat="building"].is-active {
  background: linear-gradient(180deg, #8eb894, #3d6b45);
  color: #f2faf2;
}

.market-tab[data-cat="redstone"].is-active {
  background: linear-gradient(180deg, #e07070, #a02828);
  color: #fff5f5;
}

.market-tab[data-cat="food"].is-active {
  background: linear-gradient(180deg, #e8a878, #c45c2a);
  color: #fff8f0;
}

.market-tab[data-cat="weapons"].is-active {
  background: linear-gradient(180deg, #9aa7b8, #4a5568);
  color: #f5f7fa;
}

.market-tab[data-cat="potions"].is-active {
  background: linear-gradient(180deg, #c49ae8, #6b3d9a);
  color: #faf5ff;
}

.market-tab[data-cat="other"].is-active {
  background: linear-gradient(180deg, #8a9a8e, #3d4a40);
  color: #f0f4f0;
}

.market-lots {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(190px, 100%), 1fr));
  gap: 12px;
  align-items: stretch;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

.market-lot {
  border-radius: 14px;
  border: 1px solid rgba(232, 240, 228, 0.12);
  background: rgba(0, 0, 0, 0.22);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: border-color 0.15s ease, background 0.15s ease;
  position: relative;
  min-height: 292px;
  height: 100%;
  box-sizing: border-box;
}

.market-lot__admin {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  border: 1px solid rgba(255, 120, 120, 0.45);
  background: rgba(80, 20, 20, 0.85);
  color: #ffb4b4;
  font-size: 16px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  display: grid;
  place-items: center;
  padding: 0;
}

.market-lot__admin:hover {
  background: rgba(140, 30, 30, 0.95);
  color: #fff;
}

.market-lot__ttl {
  font-size: 11px;
  text-align: center;
  color: rgba(232, 240, 228, 0.55);
}

.market-grid--rewards {
  margin-top: 4px;
}

.market-history-panel {
  margin-top: 22px;
}

.market-history {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.market-sale {
  display: grid;
  grid-template-columns: 48px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 14px 4px;
  border-top: 1px solid rgba(232, 240, 228, 0.08);
}

.market-sale:first-child {
  border-top: none;
  padding-top: 4px;
}

.market-sale__icon {
  width: 48px;
  height: 48px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.35);
  display: grid;
  place-items: center;
  position: relative;
}

.market-sale__icon img {
  width: 70%;
  height: 70%;
  object-fit: contain;
  image-rendering: pixelated;
}

.market-sale__amt {
  position: absolute;
  right: 3px;
  bottom: 2px;
  font-size: 10px;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 0 3px #000, 0 1px 2px #000;
}

.market-sale__body {
  min-width: 0;
}

.market-sale__title {
  font-weight: 650;
  font-size: 14px;
  margin-bottom: 4px;
  word-break: break-word;
}

.market-sale__flow {
  font-size: 13px;
  color: var(--site-muted);
  word-break: break-word;
}

.market-sale__flow strong {
  color: var(--site-cream);
  font-weight: 650;
}

.market-sale__side {
  text-align: right;
}

.market-sale__price {
  font-size: 16px;
  font-weight: 750;
  color: var(--site-sand);
}

.market-sale__time {
  font-size: 11px;
  color: rgba(232, 240, 228, 0.45);
  margin-top: 2px;
}

.market-lot:hover {
  border-color: rgba(212, 62, 20, 0.4);
  background: rgba(0, 0, 0, 0.3);
}

.market-lot__icon {
  width: 56px;
  height: 56px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.35);
  display: grid;
  place-items: center;
  margin: 0 auto;
  position: relative;
}

.market-lot__icon img {
  width: 70%;
  height: 70%;
  object-fit: contain;
  image-rendering: pixelated;
}

.market-lot__amt {
  position: absolute;
  right: 4px;
  bottom: 3px;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 0 3px #000, 0 1px 2px #000, 1px 0 2px #000;
}

.market-lot__name {
  font-size: 14px;
  font-weight: 650;
  text-align: center;
  line-height: 1.25;
  min-height: 2.5em;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}

.market-lot__base {
  font-size: 11px;
  text-align: center;
  color: rgba(232, 240, 228, 0.45);
  min-height: 1.2em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.market-lot__details {
  font-size: 11px;
  line-height: 1.35;
  color: #b8d4c0;
  text-align: center;
  min-height: 3.9em;
  max-height: 3.9em;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  flex: 1 1 auto;
}

.market-lot__details:empty {
  visibility: hidden;
}

.market-lot__ench {
  color: #c9a0ff;
}

.market-lot__meta {
  font-size: 12px;
  color: var(--site-muted);
  text-align: center;
  margin-top: auto;
}

.market-lot__price {
  text-align: center;
  font-size: 18px;
  font-weight: 750;
  color: var(--site-sand);
}

.market-lot__actions {
  display: flex;
  gap: 6px;
}

.market-lot__actions .site-btn {
  flex: 1;
  justify-content: center;
  padding: 8px 10px;
}

.market-pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin-top: 16px;
}

.market-pager[hidden] {
  display: none !important;
}

.market-pager__info {
  font-size: 13px;
  color: var(--site-muted);
  min-width: 4.5em;
  text-align: center;
}

.market-pager .site-btn:disabled {
  opacity: 0.4;
  cursor: default;
}

.market-count {
  font-size: 12px;
  color: var(--site-muted);
}

.market-empty {
  color: var(--site-muted);
  text-align: center;
  padding: 28px 12px;
}

.market-error {
  color: #ff8f8f;
  min-height: 1.2em;
  font-size: 13px;
  margin: 8px 0 0;
}

.market-modal-backdrop,
.market-sell-backdrop {
  position: fixed;
  inset: 0;
  z-index: 10100;
  background: rgba(5, 31, 69, 0.78);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.market-modal-backdrop[hidden],
.market-sell-backdrop[hidden] {
  display: none !important;
}

.market-modal {
  width: min(400px, 100%);
  background: linear-gradient(180deg, #314354, #051f45);
  border: 1px solid rgba(252, 212, 138, 0.28);
  border-radius: 16px;
  padding: 22px;
  box-shadow: 0 24px 60px rgba(5, 31, 69, 0.55);
}

.market-modal h3 {
  margin: 0 0 14px;
}

.market-modal__item {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
  padding: 10px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.25);
}

.market-modal__item img {
  width: 40px;
  height: 40px;
  image-rendering: pixelated;
}

.market-history-panel {
  margin-top: 22px;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  min-width: 0;
}

.market-history,
.market-sale {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

@media (max-width: 900px) {
  body.site-page--market .site-main.market-main {
    max-width: 100%;
    width: 100%;
    padding-left: 12px;
    padding-right: 12px;
    margin: 0;
  }

  .market-main {
    max-width: 100%;
  }

  .market-layout {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .market-panel,
  .market-panel--listings,
  .market-history-panel,
  .market-lots,
  .market-history,
  .market-gate,
  .market-hero {
    width: 100%;
    max-width: 100%;
    min-width: 0;
  }

  .market-panel {
    padding: 14px;
    border-radius: 14px;
  }

  .market-grid {
    grid-template-columns: repeat(9, minmax(0, 1fr));
    width: 100%;
    max-width: 100%;
  }

  .market-lots {
    grid-template-columns: 1fr;
    width: 100%;
  }

  .market-lot {
    min-height: 0;
    width: 100%;
    max-width: 100%;
  }

  .market-tabs {
    margin-left: 0;
    margin-right: 0;
    width: 100%;
  }

  .market-tab {
    flex: 0 0 auto;
  }

  .market-sale {
    grid-template-columns: 48px minmax(0, 1fr);
    gap: 10px;
  }

  .market-sale__side {
    grid-column: 2;
    text-align: left;
  }

  .market-sale__body {
    min-width: 0;
  }

  .market-hero {
    flex-direction: column;
    align-items: stretch;
  }

  .market-balance-card {
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
  }
}
