/* ============================================================
   Zallixor — market.css
   Marketplace: browse, product, checkout, orders, seller dashboard.
   Reuses the app's existing tokens and component classes (.btn,
   .field-input, .modal, .pill, .adm-row) so the marketplace looks
   like the rest of Zallixor rather than a bolted-on storefront.
   ============================================================ */

/* ── Browse ──────────────────────────────────────────────── */
.page-market { padding-bottom: 24px; }
.mk-search { margin-bottom: 8px; }
.mk-chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 8px; scrollbar-width: none; }
.mk-chips::-webkit-scrollbar { display: none; }
.mk-quicklinks { display: flex; gap: 8px; padding-bottom: 10px; }

.mk-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.mk-card { display: flex; flex-direction: column; text-align: left; padding: 0; overflow: hidden;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-sm); color: var(--text); }
.mk-card:active { transform: scale(.98); }
.mk-card-img { aspect-ratio: 4 / 5; background: var(--panel-2); display: grid; place-items: center; overflow: hidden; }
.mk-card-img img { width: 100%; height: 100%; object-fit: cover; }
.mk-noimg { color: var(--muted-2); display: grid; place-items: center; }
.mk-noimg .icon { width: 26px; height: 26px; }
.mk-card-body { padding: 8px 10px 10px; display: grid; gap: 3px; }
.mk-card-title { font-size: .86rem; font-weight: 600; line-height: 1.25;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.mk-card-price { font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }
.mk-card-meta { display: flex; align-items: center; gap: 6px; }
.mk-type { font-size: .68rem; color: var(--muted); background: var(--panel-2);
  border: 1px solid var(--line); border-radius: 999px; padding: 2px 8px; }

/* ── Product page ────────────────────────────────────────── */
.mk-hero { border-radius: var(--radius); overflow: hidden; background: var(--panel-2); margin-bottom: 8px; }
.mk-hero-img { width: 100%; max-height: 380px; object-fit: contain; display: block; background: var(--panel-2); }
div.mk-hero-img { aspect-ratio: 4 / 3; }
.mk-thumbs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 10px; }
.mk-thumb { width: 56px; height: 56px; object-fit: cover; border-radius: 10px; flex: 0 0 auto;
  border: 1px solid var(--line); }
.mk-detail { display: grid; gap: 10px; }
.mk-detail h2 { margin: 0; }
.mk-price-row { display: flex; align-items: center; gap: 10px; }
.mk-price { font-family: var(--font-display); font-size: 1.5rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.mk-seller { display: flex; align-items: center; gap: 10px; padding: 10px; cursor: pointer;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-sm); }
.mk-seller-name { font-weight: 600; font-size: .9rem; }
.mk-desc { white-space: pre-wrap; line-height: 1.55; }
.mk-protect { text-align: center; }

/* ── Checkout ────────────────────────────────────────────── */
.mk-checkout-item { display: flex; align-items: center; gap: 10px; padding: 10px;
  background: var(--panel-2); border-radius: var(--radius-sm); margin-bottom: 10px; }
.mk-co-img { width: 48px; height: 48px; object-fit: cover; border-radius: 8px; }
.mk-estimate { padding: 10px; background: var(--panel-2); border-radius: var(--radius-sm); margin: 10px 0; }
.mk-est-row { display: flex; justify-content: space-between; align-items: baseline; }
.mk-est-row strong { font-variant-numeric: tabular-nums; }

/* ── Orders ──────────────────────────────────────────────── */
.mk-order-row, .mk-listing-row, .mk-lib-row, .mk-sale-row {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; width: 100%; text-align: left;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-sm);
  margin-bottom: 6px; color: var(--text); }
.mk-order-img { width: 46px; height: 46px; object-fit: cover; border-radius: 8px; flex: 0 0 auto;
  background: var(--panel-2); }
.mk-order-img.lg { width: 68px; height: 68px; border-radius: 12px; }
.mk-order-mid, .mk-listing-mid, .mk-lib-mid, .mk-sale-main { flex: 1; min-width: 0; }
.mk-order-mid strong, .mk-listing-mid strong, .mk-lib-mid strong { display: block; font-size: .88rem; }

/* ── Order detail ────────────────────────────────────────── */
.mk-order-detail { display: grid; gap: 12px; }
.mk-order-head { display: flex; gap: 12px; align-items: flex-start; }
.mk-order-head h3 { margin: 0 0 4px; }

.mk-money { padding: 12px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-sm); }
.mk-money-row { display: flex; justify-content: space-between; align-items: baseline; padding: 3px 0; }
.mk-money-row strong { font-variant-numeric: tabular-nums; font-size: 1.05rem; }

/* Progress rail. Completed steps fill in; the connecting line is drawn
   with a pseudo-element so there's no extra markup per step. */
.mk-track { display: flex; justify-content: space-between; position: relative; padding: 4px 0 2px; }
.mk-track::before { content: ""; position: absolute; left: 8%; right: 8%; top: 11px;
  height: 2px; background: var(--line-2); }
.mk-track-step { position: relative; display: grid; justify-items: center; gap: 4px; flex: 1; }
.mk-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--panel-3);
  border: 2px solid var(--line-2); position: relative; z-index: 1; }
.mk-track-step.done .mk-dot { background: var(--ok); border-color: var(--ok); }
.mk-track-label { font-size: .62rem; color: var(--muted); text-align: center; }
.mk-track-step.done .mk-track-label { color: var(--text); }

.mk-note { padding: 10px 12px; border-radius: var(--radius-sm); font-size: .82rem;
  background: var(--panel-2); border: 1px solid var(--line); }
.mk-note.ok { border-color: rgba(47,216,164,.35); background: rgba(47,216,164,.08); }
.mk-note.danger { border-color: rgba(255,93,115,.35); background: rgba(255,93,115,.08); }

/* ── Disputes ────────────────────────────────────────────── */
.mk-reasons { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.mk-reason { background: var(--panel-2); border: 1px solid var(--line); color: var(--muted);
  border-radius: 999px; padding: 7px 13px; font-size: .78rem; }
.mk-reason.on { background: var(--accent-soft); border-color: var(--accent-a); color: var(--text); }

/* ── Library ─────────────────────────────────────────────── */
.mk-lib-ico { color: var(--accent-a); display: grid; place-items: center; width: 40px; height: 40px;
  background: var(--panel-2); border-radius: 10px; flex: 0 0 auto; }

/* ── Seller dashboard ────────────────────────────────────── */
.mk-balance { margin: 8px 0 4px; }
.mk-bal-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.mk-bal-stat { display: grid; gap: 2px; padding: 12px 8px; text-align: center;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-sm); }
.mk-bal-stat strong { font-variant-numeric: tabular-nums; font-size: 1rem; }
/* Held vs available are visually distinct on purpose — a seller should
   never mistake escrowed money for money they can withdraw. */
.mk-bal-stat.held { border-color: rgba(246,181,69,.4); }
.mk-bal-stat.held strong { color: var(--amber); }
.mk-bal-stat.avail { border-color: rgba(47,216,164,.4); }
.mk-bal-stat.avail strong { color: var(--ok); }
.mk-bal-actions { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 2px 4px; }

.mk-sale-row { align-items: flex-start; }
.mk-sale-main { display: grid; gap: 3px; }
.mk-sale-actions { display: flex; flex-direction: column; gap: 6px; flex: 0 0 auto; }

/* ── Product editor ──────────────────────────────────────── */
.mk-type-row { display: flex; gap: 6px; margin-bottom: 10px; }
.mk-img-strip { display: flex; gap: 6px; flex-wrap: wrap; }
.mk-img-cell { position: relative; width: 62px; height: 62px; border-radius: 10px; overflow: hidden;
  border: 1px solid var(--line); }
.mk-img-cell img { width: 100%; height: 100%; object-fit: cover; }
.mk-img-x { position: absolute; top: 2px; right: 2px; width: 22px; height: 22px;
  background: rgba(0,0,0,.6); border-radius: 50%; color: #fff; }
.mk-img-x .icon { width: 14px; height: 14px; }
.mk-img-add { width: 62px; height: 62px; border-radius: 10px; background: var(--panel-2);
  border: 1px dashed var(--line-2); color: var(--muted); display: grid; place-items: center; }

/* ── Shared pill tones used by order statuses ────────────── */
.pill-ok { background: rgba(47,216,164,.16); color: var(--ok); }
.pill-danger { background: rgba(255,93,115,.16); color: var(--danger); }
.pill-muted { background: var(--panel-2); color: var(--muted); }

/* ── Admin: marketplace settings ─────────────────────────── */
.adm-toggle { display: flex; align-items: center; gap: 8px; }
.adm-toggle input { width: 18px; height: 18px; }

/* ── Bookshelf ────────────────────────────────────────────────
   Books get a 2:3 portrait cover instead of the square product tile.
   A cover is a portrait image with the title set on it — cropping it
   square removes the one thing a browsing reader is reading. */
.mk-shelf { display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 14px 10px; }
.mk-shelf-strip { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 12px; scrollbar-width: none; }
.mk-shelf-strip::-webkit-scrollbar { display: none; }
.mk-shelf-strip .bk-card { flex: 0 0 116px; }
.mk-mixed { display: block; }
.mk-strip-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 2px 8px; }
.mk-strip-head h3 { margin: 0; font-size: .95rem; font-family: var(--font-display); }

.bk-card { display: grid; gap: 2px; text-align: left; background: none; border: 0; padding: 0; color: var(--text); }
.bk-card:active { transform: scale(.97); }
.bk-cover { position: relative; aspect-ratio: 2 / 3; border-radius: 4px 8px 8px 4px; overflow: hidden;
  background: linear-gradient(135deg, var(--panel-2), var(--panel-3));
  /* Offset shadow + a lighter left edge reads as a physical spine. */
  box-shadow: 0 6px 16px rgba(0,0,0,.42), 0 1px 2px rgba(0,0,0,.5);
  display: grid; place-items: center; margin-bottom: 6px; }
.bk-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.bk-spine { position: absolute; inset: 0 auto 0 0; width: 7px;
  background: linear-gradient(90deg, rgba(0,0,0,.34), rgba(255,255,255,.13) 62%, rgba(0,0,0,.16)); }
.bk-nocover { padding: 12px 10px; font-family: var(--font-display); font-size: .82rem; font-weight: 600;
  text-align: center; line-height: 1.3; color: var(--text);
  display: -webkit-box; -webkit-line-clamp: 5; -webkit-box-orient: vertical; overflow: hidden; }
.bk-title { font-size: .8rem; font-weight: 600; line-height: 1.25;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.bk-author { line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bk-price { font-size: .82rem; font-weight: 700; font-variant-numeric: tabular-nums; margin-top: 2px; }
.mk-author-field { margin-top: 6px; }

/* ── Book product page ───────────────────────────────────── */
.bk-hero { display: flex; gap: 14px; align-items: flex-start; padding: 4px 0 12px; }
.bk-hero-cover { position: relative; flex: 0 0 128px; aspect-ratio: 2 / 3; border-radius: 4px 10px 10px 4px;
  overflow: hidden; background: linear-gradient(135deg, var(--panel-2), var(--panel-3));
  box-shadow: 0 10px 26px rgba(0,0,0,.48), 0 1px 2px rgba(0,0,0,.5); display: grid; place-items: center; }
.bk-hero-cover img { width: 100%; height: 100%; object-fit: cover; }
.bk-hero-meta { flex: 1; min-width: 0; display: grid; gap: 6px; align-content: start; }
.bk-hero-meta h2 { margin: 0; font-size: 1.2rem; line-height: 1.25; }
.bk-hero-author { color: var(--muted); font-size: .88rem; }
.page-book .mk-detail { gap: 12px; }
