/* ============================================================
   Marketplace listing detail — "The Consignment Tag"
   ------------------------------------------------------------
   The book is the displayed object; the commercial terms live
   on a consignment ticket pinned beside it. Each listing
   self-tints to its publisher via --pub-h / the pub-tint system.
   Reuses the app theme tokens (works light + dark).
   ============================================================ */

.listing-page {
  --font-ticket: ui-monospace, SFMono-Regular, "SF Mono", "Roboto Mono", Menlo, Consolas, monospace;
  --pedestal: color-mix(in srgb, var(--text) 22%, transparent);
  max-width: 1080px;
  margin: 0 auto;
  padding: 1.25rem 1.25rem 4rem;
}

/* Breadcrumb / eyebrow — mono, the receipt voice */
.listing-eyebrow {
  font-family: var(--font-ticket);
  font-size: .74rem;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin: 0 0 1.25rem;
  display: flex;
  align-items: center;
  gap: .55rem;
}
.listing-eyebrow a { color: inherit; text-decoration: none; }
.listing-eyebrow a:hover { color: var(--text); text-decoration: underline; }
.listing-eyebrow__sep { opacity: .5; }

.listing-reputation {
  color: var(--text-muted);
  font-size: .9rem;
  margin-top: .35rem;
}

/* ============================================================
   Stage: object (left) + ticket (right)
   ============================================================ */
.listing-stage {
  display: grid;
  grid-template-columns: minmax(280px, 370px) minmax(320px, 372px);
  justify-content: center;
  gap: clamp(1.25rem, 3vw, 2.5rem);
  align-items: start;
}

/* ── The object: a large, proud cover on a soft pedestal ── */
.listing-object {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.listing-object__frame {
  position: relative;
  width: min(100%, 380px);
  display: flex;
  justify-content: center;
  padding: 1.5rem 0 2.25rem;
}

/* Publisher-tinted ambient halo behind the cover */
.listing-object__frame::before {
  content: "";
  position: absolute;
  inset: 6% 8% 14%;
  border-radius: 50%;
  background: radial-gradient(
    62% 58% at 50% 44%,
    hsl(var(--pub-h, 265) 65% 52% / .42),
    transparent 70%);
  filter: blur(20px);
  z-index: 0;
}

.listing-cover-hero {
  position: relative;
  z-index: 1;
  width: min(88%, 300px);
  aspect-ratio: 2 / 3;
  object-fit: cover;
  border-radius: var(--radius-sm);
  box-shadow:
    0 1px 0 color-mix(in srgb, #fff 55%, transparent) inset,
    0 18px 40px -12px var(--pedestal),
    0 6px 14px -8px rgba(0, 0, 0, .4);
  transition: transform var(--motion-med, 220ms) var(--ease-standard, ease);
}
.listing-cover-hero:hover { transform: translateY(-4px) rotate(-.4deg); }

/* Floor shadow under the displayed object */
.listing-object__frame::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 1rem;
  width: 56%;
  height: 18px;
  transform: translateX(-50%);
  background: radial-gradient(50% 100% at 50% 0%, var(--pedestal), transparent 75%);
  z-index: 0;
}

.listing-object__caption { max-width: 34ch; }
.listing-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.4rem, 1rem + 1.6vw, 2rem);
  line-height: 1.08;
  letter-spacing: -.01em;
}
.listing-object__sub {
  margin: .6rem 0 0;
  font-family: var(--font-ticket);
  font-size: .76rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--text-muted);
  display: inline-flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: .5rem;
}
.listing-object__sub b { color: var(--text); font-weight: 700; }
.listing-object__sub .dot { opacity: .45; }

/* ============================================================
   The consignment ticket
   ============================================================ */
.listing-ticket {
  position: sticky;
  top: calc(var(--nav-h, 60px) + 1rem);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  overflow: hidden;
}
/* Publisher accent rail along the top of the ticket */
.listing-ticket::before {
  content: "";
  display: block;
  height: 4px;
  background: linear-gradient(
    90deg,
    hsl(var(--pub-h, 265) 62% 50%),
    hsl(var(--pub-h, 265) 62% 50% / .35));
}

.ticket__body { padding: 1.4rem 1.4rem 1.5rem; }

.ticket__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
}
.ticket__eyebrow {
  font-family: var(--font-ticket);
  font-size: .68rem;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--text-dim);
}
.ticket__avail {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  font-family: var(--font-ticket);
  font-size: .66rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--success);
}
.ticket__avail::before {
  content: "";
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--success) 20%, transparent);
}

.ticket__price {
  margin: .35rem 0 .15rem;
  font-family: var(--font-display);
  font-size: clamp(2.6rem, 2rem + 2.4vw, 3.4rem);
  line-height: 1;
  letter-spacing: -.02em;
  font-variant-numeric: tabular-nums;
}
.ticket__price .cents { font-size: .5em; vertical-align: .55em; margin-left: .04em; }

/* GH-178: what a swap wants back, standing where a sale's price would.
   Deliberately NOT sized like .ticket__price -- a list of book titles at
   3.4rem is unreadable, and the visual weight belongs to the fact that this
   listing wants books rather than to any one of them. */
.ticket__swap {
  margin: .35rem 0 .5rem;
  display: grid;
  gap: .4rem;
}
.ticket__swap-label {
  font-family: var(--font-ticket);
  font-size: .74rem;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.ticket__swap-list {
  margin: 0;
  padding-left: 1.1rem;
  display: grid;
  gap: .25rem;
  font-size: .95rem;
}
.ticket__swap-note {
  color: var(--text-muted);
  font-size: .84rem;
  margin-left: .35rem;
}
.ticket__swap-wishlist {
  font-size: .92rem;
}
.ticket__swap-free {
  margin: 0;
  font-size: .92rem;
}
.ticket__swap-cash {
  margin: 0;
  font-size: .88rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.ticket__terms {
  font-family: var(--font-ticket);
  font-size: .82rem;
  color: var(--text-muted);
  display: flex;
  flex-wrap: wrap;
  gap: .4rem .6rem;
}
.ticket__terms .total { color: var(--text); font-weight: 600; }
.ticket__terms .sep { opacity: .45; }
.ticket__free { color: var(--success); font-weight: 600; }

/* ── Perforation: the one tear-off detail ── */
.ticket__perf {
  position: relative;
  height: 1px;
  margin: 1.25rem -1.4rem;
  border-top: 1px dashed var(--border);
}
.ticket__perf::before,
.ticket__perf::after {
  content: "";
  position: absolute;
  top: 50%;
  width: 18px; height: 18px;
  transform: translateY(-50%);
  border-radius: 50%;
  background: var(--bg);
  border: 1px solid var(--border);
}
.ticket__perf::before { left: -9px; }
.ticket__perf::after { right: -9px; }

/* ── Condition as a stamped grade ── */
.ticket__cond { display: flex; align-items: center; gap: 1rem; }
.ticket__cond-label {
  font-family: var(--font-ticket);
  font-size: .68rem;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--text-dim);
}
.grade-stamp {
  --ink: var(--text);
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  padding: .42rem .9rem;
  font-family: var(--font-display);
  font-size: .92rem;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--ink);
  background: color-mix(in srgb, var(--ink) 9%, var(--surface));
  border: 2px solid color-mix(in srgb, var(--ink) 55%, transparent);
  border-radius: 5px;
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--ink) 6%, transparent);
  transform: rotate(-2.5deg);
}
.grade-stamp[data-grade="new"],
.grade-stamp[data-grade="like-new"] { --ink: var(--success); }
.grade-stamp[data-grade="fair"],
.grade-stamp[data-grade="poor"] { --ink: var(--accent-interest); }
.grade-stamp[data-grade="mixed"] { --ink: var(--text-muted); }

/* ── Seller / age line ── */
.ticket__meta {
  margin: 1.25rem 0 0;
  font-family: var(--font-ticket);
  font-size: .78rem;
  color: var(--text-muted);
  line-height: 1.5;
}
.ticket__meta a { color: var(--text); text-decoration: none; font-weight: 600; }
.ticket__meta a:hover { text-decoration: underline; }
.ticket__meta .seller-by { color: var(--text-dim); }

/* ── CTAs ── */
.ticket__ctas { display: grid; gap: .55rem; margin-top: 1.35rem; }
.ticket__cta {
  width: 100%;
  min-height: 50px;
  font-size: 1.02rem;
  font-weight: 700;
  gap: .5rem;
}
.ticket__cta--primary {
  background: var(--brand);
  border-color: var(--brand);
  color: var(--on-brand);
  border-radius: var(--radius);
  box-shadow: 0 8px 20px -10px color-mix(in srgb, var(--brand) 80%, transparent);
  transition: transform var(--motion-fast, 140ms) var(--ease-standard, ease),
              box-shadow var(--motion-fast, 140ms) var(--ease-standard, ease);
}
.ticket__cta--primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 26px -10px color-mix(in srgb, var(--brand) 85%, transparent);
}
.ticket__cta--ghost {
  background: transparent;
  border-radius: var(--radius);
  min-height: 44px;
  color: var(--text-muted);
}
.ticket__cta--ghost:hover { color: var(--text); border-color: var(--text-muted); }

/* ============================================================
   Seller's note
   ============================================================ */
.listing-note-block {
  margin: 3rem auto 0;
  max-width: 760px;
  padding: 1.25rem 1.4rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid hsl(var(--pub-h, 265) 55% 50% / .7);
  border-radius: var(--radius);
}
.listing-note-block__h {
  font-family: var(--font-ticket);
  font-size: .7rem;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin: 0 0 .5rem;
}
.listing-description {
  color: var(--text);
  line-height: 1.6;
  white-space: pre-wrap;
  margin: 0;
}
.listing-note {
  margin: .75rem 0 0;
  color: var(--text-muted);
  white-space: pre-wrap;
  font-size: .92rem;
}

/* ============================================================
   Section heading shared by spec sheet + contents
   ============================================================ */
.listing-section { margin: 3rem auto 0; max-width: 760px; }
.listing-section__h {
  display: flex;
  align-items: baseline;
  gap: .6rem;
  font-family: var(--font-ticket);
  font-size: .74rem;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin: 0 0 1rem;
}
.listing-section__h::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ── Spec sheet (single-book listing) — no duplicate cover ── */
.spec-grid {
  margin: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--border);
}
.spec-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  padding: .7rem .95rem;
  background: var(--surface);
}
.spec-row dt {
  font-family: var(--font-ticket);
  font-size: .7rem;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-dim);
}
.spec-row dd {
  margin: 0;
  font-weight: 600;
  font-size: .92rem;
  text-align: right;
}
.spec-row dd .strike {
  color: var(--text-dim);
  text-decoration: line-through;
  font-weight: 400;
  margin-right: .4rem;
}
.spec-row dd .save { color: var(--success); font-weight: 700; }
.spec-link {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  margin-top: 1rem;
  font-family: var(--font-ticket);
  font-size: .8rem;
  letter-spacing: .04em;
  color: var(--brand);
  text-decoration: none;
}
.spec-link:hover { text-decoration: underline; }

/* ============================================================
   Lot contents (bundle) — cover-forward tiles / compact rows
   ============================================================ */
.listing-items-grid,
.listing-items-list { list-style: none; margin: 0; padding: 0; }

.listing-items-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 14px;
}
.listing-item-tile {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
  transition: transform var(--motion-fast, 140ms) var(--ease-standard, ease),
              box-shadow var(--motion-fast, 140ms) var(--ease-standard, ease);
}
.listing-item-tile:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.listing-item-tile__cover { display: block; width: 100%; aspect-ratio: 2 / 3; object-fit: cover; }
.listing-item-tile__cover--placeholder { background: var(--surface-2); }
.listing-item-tile__info {
  padding: .55rem .6rem .65rem;
  display: flex;
  flex-direction: column;
  gap: .3rem;
  flex: 1;
}

.listing-items-list { display: grid; gap: 8px; }
.listing-item-row {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto auto;
  gap: 12px;
  align-items: center;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}
.listing-item-row__thumb { display: block; width: 44px; aspect-ratio: 2 / 3; object-fit: cover; border-radius: var(--radius-sm); }
.listing-item-row__thumb--placeholder { background: var(--surface-2); border-radius: var(--radius-sm); }

.listing-item-title { font-weight: 600; font-size: .9rem; line-height: 1.25; }
.listing-item-condition {
  display: inline-block;
  align-self: flex-start;
  padding: .12rem .5rem;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  font-family: var(--font-ticket);
  font-size: .68rem;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.listing-item-price {
  font-family: var(--font-ticket);
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  white-space: nowrap;
}

/* ============================================================
   Tombstone (gone listing)
   ============================================================ */
.listing-tombstone { text-align: center; padding: 4rem 1rem; max-width: 460px; margin: 0 auto; }
.listing-tombstone .listing-title { margin-bottom: .5rem; }
.listing-tombstone__sub { color: var(--text-muted); margin: .5rem 0 1.75rem; }

/* ============================================================
   Shared marketplace card aliases (browse grid / order-book)
   kept intact so other surfaces are unaffected
   ============================================================ */
.listing-card {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}
.listing-link { color: inherit; text-decoration: none; }
.listing-link:hover { text-decoration: underline; }
.listing-main { min-width: 0; }

/* ============================================================
   Bundle cover stack — fanned covers, larger on the pedestal
   ============================================================ */
.listing-object .mkt-cover-stack {
  position: relative;
  z-index: 1;
  width: 240px;
  height: 300px;
}
.listing-object .mkt-cover-stack__img {
  position: absolute;
  width: 175px;
  aspect-ratio: 2 / 3;
  object-fit: cover;
  border-radius: var(--radius-sm);
  box-shadow: 0 14px 30px -12px var(--pedestal), 0 4px 10px -6px rgba(0, 0, 0, .35);
  transform-origin: bottom center;
}
.listing-object .mkt-cover-stack__img--1 { left: 0; bottom: 0; z-index: 1; transform: rotate(-7deg); }
.listing-object .mkt-cover-stack__img--2 { left: 30px; bottom: 0; z-index: 2; transform: rotate(-2deg); }
.listing-object .mkt-cover-stack__img--3 { left: 60px; bottom: 0; z-index: 3; transform: rotate(3deg); }
.listing-object .mkt-cover-stack__img:only-child { left: 32px; transform: none; }

/* ============================================================
   Page-load reveal (one orchestrated moment)
   ============================================================ */
@media (prefers-reduced-motion: no-preference) {
  .listing-object { animation: listing-rise var(--motion-slow, 360ms) var(--ease-enter, ease) both; }
  .listing-ticket { animation: listing-rise var(--motion-slow, 360ms) var(--ease-enter, ease) both; animation-delay: 80ms; }
  @keyframes listing-rise {
    from { opacity: 0; transform: translateY(14px); }
    to { opacity: 1; transform: none; }
  }
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 900px) {
  .listing-stage { grid-template-columns: 1fr; gap: 1.5rem; }
  .listing-ticket { position: static; max-width: 480px; width: 100%; margin: 0 auto; }
  .listing-object__frame { padding-top: .5rem; }
}

@media (max-width: 460px) {
  .listing-page { padding: 1rem 1rem 3rem; }
  .listing-cover-hero { width: min(64%, 240px); }
  .spec-grid { grid-template-columns: 1fr; }
}
