/* Marketplace page (catalog.html): categories on the left, search and sorting on top,
   a grid of model cards with photo, name, green price and likes. */

.market {
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  gap: 32px;
  align-items: start;
}
main.container.market { padding-top: calc(var(--header-h) + 24px); }

.market-side, .market-main { min-width: 0; }

/* ---------- left column ---------- */
.market-side {
  position: sticky;
  top: calc(var(--header-h) + 16px);
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: calc(100vh - var(--header-h) - 32px);
  overflow: auto;
  scrollbar-width: none;
}
.market-custom {
  width: 100%;
  background: var(--color-accent);
  color: var(--color-accent-text);
  box-shadow: 0 12px 28px -12px rgba(255, 107, 44, 0.8);
}
.market-side-title { margin: 14px 12px 2px; }
.market-cats { display: flex; flex-direction: column; gap: 2px; }
.market-cat {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  border: 0;
  border-radius: 14px;
  padding: 10px 12px;
  background: transparent;
  color: var(--color-text);
  font: inherit;
  font-weight: 700;
  font-size: 15px;
  text-align: left;
  cursor: pointer;
  transition: background-color 0.2s ease, transform 0.18s var(--ease-out, ease);
}
.market-cat svg {
  width: 20px; height: 20px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
  color: var(--color-muted);
  transition: color 0.2s ease;
}
.market-cat-name { flex: 1; min-width: 0; }
.market-cat-count { color: var(--color-muted); font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums; }
.market-cat:hover { background: var(--pill-bg-hover); }
.market-cat:hover svg { color: var(--color-accent); }
.market-cat[aria-current="true"] { background: var(--color-surface); box-shadow: var(--shadow); }
.market-cat[aria-current="true"] svg { color: var(--color-accent); }

.market-side::-webkit-scrollbar { display: none; }

/* ---------- top: search, title, sorting ---------- */
.market-search {
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 560px;
  padding: 0 18px;
  border-radius: 999px;
  background: var(--color-surface);
  box-shadow: var(--shadow);
  color: var(--color-muted);
  border: 1.5px solid transparent;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.market-search:focus-within { border-color: var(--color-accent); box-shadow: var(--shadow), 0 0 0 4px rgba(255, 107, 44, 0.16); }
.market-search input {
  flex: 1;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--color-text);
  font: inherit;
  font-weight: 600;
  font-size: 16px;
  padding: 14px 0;
  min-width: 0;
}
.market-search input:focus { box-shadow: none; }
.market-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin: 26px 0 18px; }
.market-head h1 { margin: 0; font-size: clamp(26px, 3vw, 36px); }
.market-tools { display: flex; align-items: center; gap: 14px; }
.market-tools .meta { white-space: nowrap; }
.market-tools select { width: auto; padding: 10px 40px 10px 16px; font-weight: 700; cursor: pointer; }

/* ---------- cards ---------- */
.market-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 18px;
}
.market-card {
  position: relative;
  isolation: isolate;
  display: flex;
  flex-direction: column;
  border-radius: 22px;
  background: var(--color-surface);
  box-shadow: 0 1px 0 var(--color-border);
  text-decoration: none;
  color: inherit;
  overflow: hidden;
  animation: fx-rise 0.5s var(--ease-out, ease) backwards;
  transition: transform 0.25s var(--ease-out, ease), box-shadow 0.25s ease;
}
.market-card:hover { transform: translateY(-4px); box-shadow: var(--shadow); }
.market-card:focus-visible { outline: 3px solid var(--color-accent); outline-offset: 3px; }
.market-grid > :nth-child(4n+2) { animation-delay: 0.04s; }
.market-grid > :nth-child(4n+3) { animation-delay: 0.08s; }
.market-grid > :nth-child(4n+4) { animation-delay: 0.12s; }

.market-pic {
  position: relative;
  aspect-ratio: 1 / 1;
  background: var(--color-surface-2);
  display: grid;
  place-items: center;
  overflow: hidden;
}
.market-pic img {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover;
  opacity: 0; transition: opacity 0.35s ease, transform 0.6s var(--ease-out, ease);
}
.market-pic.loaded img { opacity: 1; }
.market-pic.loaded .loader, .market-pic.broken img { display: none; }
.market-card:hover .market-pic img { transform: scale(1.05); }
.market-tag {
  position: absolute; left: 10px; top: 10px;
  padding: 4px 10px; border-radius: 999px;
  background: rgba(20, 12, 8, 0.62); color: #fff;
  font-size: 12px; font-weight: 800;
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
}

.market-body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.market-name {
  font-weight: 700; font-size: 15px; line-height: 1.3;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  min-height: 2.6em;
}
.market-row { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 2px 8px; margin-top: auto; }
.market-price { font-size: 20px; font-weight: 800; letter-spacing: -0.01em; white-space: nowrap; }
.market-price small { font-size: 13px; font-weight: 700; opacity: 0.85; }
.market-price-later { font-size: 13px; font-weight: 700; color: var(--color-muted); }
.market-likes { font-size: 13px; font-weight: 700; color: var(--color-muted); white-space: nowrap; }

/* Light under the pointer, as on the other cards (js/fx.js) */
.market-card::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit; padding: 1.5px; pointer-events: none;
  opacity: 0; transition: opacity 0.35s ease;
  background: radial-gradient(220px circle at var(--gx, 50%) var(--gy, 50%), var(--glow-edge), transparent 65%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0);
}
.market-card.fx-lit::after { opacity: 1; }

/* Placeholders while the list loads */
.market-card.skeleton { pointer-events: none; }
.market-card.skeleton .market-pic, .sk-line {
  background: linear-gradient(90deg, var(--color-surface-2) 0%, var(--color-border) 50%, var(--color-surface-2) 100%);
  background-size: 200% 100%;
  animation: sk-shine 1.2s linear infinite;
}
.sk-line { height: 14px; border-radius: 8px; }
.sk-line.short { width: 45%; height: 18px; margin-top: 6px; }
@keyframes sk-shine { from { background-position: 200% 0; } to { background-position: -200% 0; } }

.market-more { display: flex; justify-content: center; margin: 28px 0 8px; }
.market-note { margin-top: 18px; max-width: 760px; }
.market-grid .empty { grid-column: 1 / -1; }

/* ---------- phone: categories become a row of chips above the grid ---------- */
@media (max-width: 860px) {
  .market { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .market-side { position: static; max-height: none; overflow: visible; }
  .market-side-title { display: none; }
  .market-cats { flex-direction: row; overflow-x: auto; gap: 8px; padding-bottom: 6px; scrollbar-width: none; }
  .market-cats::-webkit-scrollbar { display: none; }
  .market-cat { width: auto; flex: none; padding: 8px 14px; background: var(--color-surface); white-space: nowrap; }
  .market-cat[aria-current="true"] { background: var(--color-cta); color: var(--color-cta-text); box-shadow: none; }
  .market-cat[aria-current="true"] svg { color: inherit; }
  .market-cat-count { color: inherit; opacity: 0.7; }
  .market-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .market-price { font-size: 17px; }
  .market-head { margin: 18px 0 12px; }
}
@media (prefers-reduced-motion: reduce) {
  .market-card, .market-pic img, .sk-line, .market-card.skeleton .market-pic { animation: none !important; transition: none !important; }
}
