/* Shop window (shop.js): picture cards by rarity, or a table. */
html body #shopDialog {
  width: min(1180px, calc(100vw / var(--site-zoom, 1) - 32px));
  max-width: none;
  height: min(860px, calc(100dvh / var(--site-zoom, 1) - 32px));
  max-height: none;
  padding: 0;
  overflow: hidden;
}
#shopDialog[open] { display: flex; flex-direction: column; }
.shop-head { display: flex; align-items: center; gap: 16px; padding: 18px 22px 12px; border-bottom: 1px solid var(--m-border); }
.shop-head > div:first-child { flex: 1; min-width: 0; }
.shop-head h2 { margin: 0; font-size: 22px; }
.shop-head p { margin: 2px 0 0; font-size: 13px; }
.shop-balance { display: grid; justify-items: end; line-height: 1.1; }
.shop-balance span { color: var(--m-muted); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; }
.shop-balance b { font-size: 22px; font-variant-numeric: tabular-nums; }
.shop-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 22px; }
.shop-cats, .shop-view { display: flex; gap: 6px; flex-wrap: wrap; }
html body #shopDialog .shop-cats button { min-height: 36px; padding: 6px 14px; border-radius: 999px !important; font-size: 13px; }
html body #shopDialog :is(.shop-cats, .shop-view) button[aria-pressed="true"] { border-color: transparent; background: var(--m-text); color: var(--m-panel); }
.shop-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
html body #shopDialog .shop-controls :is(input[type="search"], select) { width: auto; min-height: 36px; padding: 6px 10px; font-size: 13px; }
html body #shopDialog #shopSearch { width: 170px; }
.shop-afford { display: flex; align-items: center; gap: 6px; margin: 0; font-size: 13px; font-weight: 700; white-space: nowrap; }
.shop-afford input { width: auto; }
html body #shopDialog .shop-view button { width: 38px; min-height: 36px; padding: 0; font-size: 17px; }
.shop-status { min-height: 0; margin: 0 22px; color: var(--m-accent) !important; font-weight: 700; }
.shop-status:empty { display: none; }
.shop-body { flex: 1; min-height: 0; overflow-y: auto; padding: 8px 22px 24px; scrollbar-width: thin; }
.shop-empty { padding: 40px; text-align: center; }

/* Cards */
.shop-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 14px; }
.shop-card {
  --frame: var(--m-border);
  --glow: transparent;
  position: relative;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--frame);
  border-radius: 16px;
  background: var(--m-panel-2);
  box-shadow: 0 0 0 0 var(--glow);
  transition: transform .18s, box-shadow .18s;
}
.shop-card:hover { transform: translateY(-3px); box-shadow: 0 10px 26px -10px var(--glow), var(--m-shadow); }
.shop-pic {
  position: relative;
  display: grid;
  place-items: end center;
  height: 190px;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 40%, color-mix(in srgb, var(--item) 55%, #fff) 0, transparent 62%),
    linear-gradient(180deg, color-mix(in srgb, var(--item) 35%, var(--m-panel)) 0%, color-mix(in srgb, var(--trim) 30%, var(--m-panel-2)) 100%);
}
.shop-pic .pixel-avatar { width: 110px; height: 165px; image-rendering: pixelated; filter: drop-shadow(0 8px 10px #0005); transition: transform .25s; }
.shop-card:hover .shop-pic .pixel-avatar { transform: translateY(-4px) scale(1.04); }
.shop-rarity {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  background: #0006;
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .6px;
  text-transform: uppercase;
}
.shop-pic .shop-rarity { position: absolute; top: 10px; left: 10px; backdrop-filter: blur(4px); }
.shop-owned { position: absolute; top: 10px; right: 10px; display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: #1fbf5b; color: #fff; font-size: 14px; font-weight: 800; }
.shop-info { padding: 10px 12px 4px; }
.shop-info h3 { margin: 0; font-size: 15px; line-height: 1.25; }
.shop-info small { color: var(--m-muted); font-size: 12px; }
html body #shopDialog :is(.shop-buy, .shop-wear) {
  display: block;
  margin: 8px 12px 12px;
  min-height: 38px;
  padding: 8px 10px;
  border: 0 !important;
  border-radius: 10px !important;
  background: linear-gradient(180deg, var(--m-accent), var(--m-accent-2)) !important;
  color: #fff !important;
  box-shadow: var(--m-glow) !important;
  font-size: 13px;
  font-weight: 800;
  text-align: center;
}
html body #shopDialog .shop-buy:disabled { background: var(--m-hover) !important; color: var(--m-muted) !important; box-shadow: none !important; opacity: 1; }
html body #shopDialog .shop-wear { background: var(--m-hover) !important; color: var(--m-text) !important; box-shadow: none !important; }

/* Different card for each rarity */
.shop-card.rarity-rare { --frame: #4f9dff; --glow: #4f9dff88; }
.shop-card.rarity-rare .shop-rarity { background: #2f7ff0; }
.shop-card.rarity-epic { --frame: #b26bff; --glow: #b26bffaa; border-width: 2px; }
.shop-card.rarity-epic .shop-rarity { background: linear-gradient(90deg, #8f52ff, #d05cff); }
.shop-card.rarity-epic .shop-pic::after { content: ""; position: absolute; inset: 0; background: radial-gradient(circle at 50% 100%, #b26bff55, transparent 60%); pointer-events: none; }
.shop-card.rarity-legend { --frame: transparent; --glow: #ffc23dcc; border: 2px solid transparent; background: linear-gradient(var(--m-panel-2), var(--m-panel-2)) padding-box, linear-gradient(135deg, #ffe17a, #ff9a3d, #ffd34d, #fff1b8) border-box; }
.shop-card.rarity-legend .shop-rarity { background: linear-gradient(90deg, #f7b500, #ff7a2f); color: #2a1a00; }
.shop-card.rarity-legend .shop-pic::before {
  content: "";
  position: absolute;
  inset: -40%;
  background: conic-gradient(from 0deg, transparent 0 20%, #fff3 25%, transparent 30% 70%, #fff3 75%, transparent 80%);
  animation: shop-shine 6s linear infinite;
  pointer-events: none;
}
@keyframes shop-shine { to { transform: rotate(1turn); } }
@media (prefers-reduced-motion: reduce) { .shop-card.rarity-legend .shop-pic::before { animation: none; } }
.shop-card.is-owned .shop-pic { filter: saturate(.9); }

/* Table */
.shop-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 14px; }
.shop-table thead th {
  position: sticky;
  top: -8px;
  z-index: 1;
  padding: 10px 12px;
  border-bottom: 1px solid var(--m-border);
  background: var(--m-panel);
  color: var(--m-muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .5px;
  text-align: left;
  text-transform: uppercase;
}
.shop-table td, .shop-table tbody th { padding: 8px 12px; border-bottom: 1px solid var(--m-border); text-align: left; vertical-align: middle; }
.shop-table tbody th { font-weight: 800; }
.shop-table tbody tr:hover { background: var(--m-hover); }
.shop-thumb { display: block; width: 46px; height: 46px; overflow: hidden; border-radius: 10px; background: color-mix(in srgb, var(--item) 45%, var(--m-panel-2)); }
.shop-thumb .pixel-avatar { display: block; width: 100%; height: 100%; image-rendering: pixelated; }
.shop-price { font-weight: 800; white-space: nowrap; font-variant-numeric: tabular-nums; }
.shop-table .shop-rarity { background: var(--m-hover); color: var(--m-text); }
.shop-table .rarity-rare .shop-rarity { background: #2f7ff0; color: #fff; }
.shop-table .rarity-epic .shop-rarity { background: linear-gradient(90deg, #8f52ff, #d05cff); color: #fff; }
.shop-table .rarity-legend .shop-rarity { background: linear-gradient(90deg, #f7b500, #ff7a2f); color: #2a1a00; }
html body #shopDialog .shop-table :is(.shop-buy, .shop-wear) { display: inline-block; margin: 0; white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

@media (max-width: 700px) {
  .shop-head, .shop-bar { padding-inline: 14px; }
  .shop-body { padding-inline: 14px; }
  .shop-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .shop-pic { height: 150px; }
  .shop-pic .pixel-avatar { width: 86px; height: 129px; }
  html body #shopDialog #shopSearch { width: 100%; flex: 1 0 100%; }
  .shop-table { font-size: 12px; }
  .shop-table :is(th, td):nth-child(3), .shop-table :is(th, td):nth-child(5) { display: none; }
}

/* What the shop shows: outfits, card designs, table designs. */
.shop-kinds { display: flex; gap: 6px; flex-wrap: wrap; padding: 12px 22px 0; }
html body #shopDialog .shop-kinds button { min-height: 40px; padding: 7px 16px; border-radius: 12px !important; font-size: 14px; font-weight: 800; }
html body #shopDialog .shop-kinds button[aria-pressed="true"] { border-color: transparent; background: linear-gradient(180deg, var(--m-accent, #ff3d71), var(--m-accent-2, #ff2a55)); color: #fff; }
.shop-cats[hidden] { display: none; }
.shop-card.is-decor .shop-pic { display: grid; place-items: center; }
.shop-thumb.is-decor .decor-preview { padding: 2px; }
.shop-thumb.is-decor .decor-preview .table-felt { border-width: 4px; padding: 2px; gap: 1px; }
.shop-thumb.is-decor .decor-preview .playing-card { width: 11px; border-radius: 2px; font-size: 0; }
