/* EstateBrowse public sale listing → Marketplace Items lightbox.
 *
 * Used by app/Views/partials/sale_listing_marketplace_items_section.php and
 * powered by public/js/sale-marketplace-modal.js. Two responsibilities:
 *   1) Truncate the marketplace card title to a single line (no wrap; ellipsis).
 *   2) Render a Facebook-style lightbox with the image on the left and the
 *      item name + condition + description + price on the right.
 *
 * Truncation must work for both bundle (inline-flex h3 with glyph + text)
 * and non-bundle (plain h3 with text) cards. We always wrap the visible
 * text in .sale-mp-card__title-text so a single rule handles both.
 */

/* ---- Title truncation ---------------------------------------------------- */
.sale-mp-card__title {
  display: flex;
  align-items: flex-start;
  gap: 0.4rem;
  min-width: 0;
}
.sale-mp-card__title-text {
  flex: 1 1 auto;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
}

/* ---- Card affordance ----------------------------------------------------- */
/* The whole card is clickable; show the pointer + a subtle lift on hover so
   shoppers know it opens the detail view. */
.sale-mp-card {
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}
/* Card image fallback (no crop_box_1000): cover the whole 4:3 tile so the
   light-gradient background behind .sale-mp-card__media--isolated never
   shows through as a grey letterbox band. */
.sale-mp-card__media--isolated > .sale-mp-card__img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.sale-mp-card:hover,
.sale-mp-card:focus-within {
  transform: translateY(-1px);
  box-shadow: 0 6px 18px color-mix(in srgb, #0f172a 12%, transparent);
}
.sale-mp-card:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--brand, #1d4ed8) 45%, transparent);
  outline-offset: 2px;
}

/* ---- Modal shell --------------------------------------------------------- */
.sale-mp-modal {
  padding: 0;
  border: none;
  border-radius: var(--r-lg, 14px);
  background: #fff;
  width: min(60rem, 96vw);
  max-width: 96vw;
  max-height: min(92dvh, 100% - 2rem);
  overflow: hidden;
  box-shadow: 0 28px 80px rgba(15, 23, 42, 0.28);
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  margin: 0;
}
.sale-mp-modal::backdrop {
  background: rgba(15, 23, 42, 0.65);
}
.sale-mp-modal__inner {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
  max-height: inherit;
  min-height: 0;
}
.sale-mp-modal__close {
  position: absolute;
  top: 0.5rem;
  right: 0.6rem;
  z-index: 2;
  appearance: none;
  border: none;
  background: rgba(15, 23, 42, 0.55);
  color: #fff;
  width: 2rem;
  height: 2rem;
  border-radius: 999px;
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.sale-mp-modal__close:hover,
.sale-mp-modal__close:focus-visible {
  background: rgba(15, 23, 42, 0.85);
  outline: none;
}

/* ---- Media (left column) ------------------------------------------------- */
/*
 * Facebook-style "blurred backdrop": the foreground <img> uses object-fit:
 * contain so nothing is cropped, but the surrounding canvas is filled with a
 * blurred copy of the same image (set as background-image via the
 * --sale-mp-modal-bg CSS variable, populated by sale-marketplace-modal.js).
 * Result: image fills the canvas with no letterbox/grey edges and no crop.
 */
.sale-mp-modal__media {
  background: #0f172a;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
  position: relative;
  overflow: hidden;
  aspect-ratio: 1 / 1;
  isolation: isolate;
}
.sale-mp-modal__media::before {
  content: '';
  position: absolute;
  /* Inflate the backdrop so the blur halo never reveals the dark base. */
  inset: -8%;
  background-image: var(--sale-mp-modal-bg, none);
  background-size: cover;
  background-position: center;
  filter: blur(28px) brightness(0.85) saturate(1.05);
  transform: scale(1.06);
  z-index: 0;
  pointer-events: none;
}
.sale-mp-modal__media img {
  position: relative;
  z-index: 1;
  display: block;
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
}
.sale-mp-modal__media .pro-mp-bundle-rotating {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  border-radius: 0;
  background: transparent;
}
.sale-mp-modal__media-placeholder {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #94a3b8;
}

/* ---- Info (right column) ------------------------------------------------- */
.sale-mp-modal__info {
  padding: var(--sp-5, 1.25rem) var(--sp-5, 1.25rem) var(--sp-4, 1rem);
  display: flex;
  flex-direction: column;
  gap: var(--sp-3, 0.75rem);
  overflow-y: auto;
  min-height: 0;
}
.sale-mp-modal__title {
  margin: 0;
  font-size: 1.35rem;
  line-height: 1.3;
  font-weight: 700;
  color: var(--primary, #0f172a);
  display: flex;
  align-items: center;
  gap: 0.45rem;
  min-width: 0;
}
/* Single-line title in the lightbox; ellipsis when needed (bundle + plain items). */
.sale-mp-modal__title [data-sale-mp-modal-title-text] {
  flex: 1 1 auto;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sale-mp-modal__title .pro-mp-badge--bundle-glyph {
  flex: 0 0 auto;
}
.sale-mp-modal__title .pro-mp-badge--bundle-glyph svg {
  width: 1.1em;
  height: 1.1em;
}
/* Honour [hidden] on the bundle glyph in the modal title — the base
   .pro-mp-badge--bundle-glyph rule sets display: inline-flex, which would
   otherwise win over the browser's default display: none for [hidden]. */
.sale-mp-modal__title .pro-mp-badge--bundle-glyph[hidden] {
  display: none !important;
}
.sale-mp-modal__meta {
  margin: 0;
  font-size: var(--text-sm, 0.875rem);
  color: var(--text-muted, #6b7280);
}
.sale-mp-modal__desc {
  margin: 0;
  font-size: var(--text-base, 1rem);
  line-height: 1.55;
  color: var(--text, #1f2937);
  white-space: pre-wrap;
}
.sale-mp-modal__desc--muted {
  color: var(--text-muted, #6b7280);
  font-style: italic;
}
.sale-mp-modal__price {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--primary, #0f172a);
}

/* ---- Bundle / collection: child item shortcuts --------------------------- */
.sale-mp-modal__included {
  margin-top: var(--sp-2, 0.5rem);
  padding-top: var(--sp-3, 0.75rem);
  border-top: 1px solid color-mix(in srgb, var(--border, #e5e7eb) 90%, transparent);
}
.sale-mp-modal__included-title {
  margin: 0 0 var(--sp-2, 0.5rem);
  font-size: var(--text-sm, 0.875rem);
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--text-muted, #6b7280);
}
.sale-mp-modal__included-grid {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2, 0.5rem);
}
.sale-mp-modal__included-item {
  display: flex;
  align-items: stretch;
  gap: var(--sp-3, 0.75rem);
  width: 100%;
  margin: 0;
  padding: var(--sp-2, 0.5rem) var(--sp-3, 0.75rem);
  text-align: left;
  cursor: pointer;
  border: 1px solid color-mix(in srgb, var(--border, #e5e7eb) 85%, transparent);
  border-radius: var(--r-md, 10px);
  background: color-mix(in srgb, var(--n-50, #f8fafc) 65%, #fff);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.sale-mp-modal__included-item:hover,
.sale-mp-modal__included-item:focus-visible {
  border-color: color-mix(in srgb, var(--brand, #1d4ed8) 35%, var(--border, #e5e7eb));
  box-shadow: 0 2px 10px color-mix(in srgb, #0f172a 8%, transparent);
  outline: none;
}
.sale-mp-modal__included-thumb {
  flex: 0 0 4.25rem;
  width: 4.25rem;
  height: 4.25rem;
  border-radius: var(--r-sm, 8px);
  overflow: hidden;
  background: var(--n-100, #f1f5f9);
  display: flex;
  align-items: center;
  justify-content: center;
}
.sale-mp-modal__included-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.sale-mp-modal__included-thumb-placeholder {
  font-size: 0.75rem;
  color: var(--text-muted, #94a3b8);
}
.sale-mp-modal__included-body {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  justify-content: center;
}
.sale-mp-modal__included-item-title {
  font-size: var(--text-sm, 0.9375rem);
  font-weight: 600;
  color: var(--primary, #0f172a);
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.sale-mp-modal__included-item-meta {
  margin: 0;
  font-size: var(--text-xs, 0.75rem);
}
.sale-mp-modal__included-item-price {
  font-size: var(--text-sm, 0.875rem);
  font-weight: 600;
  color: var(--primary, #0f172a);
}
.sale-mp-modal__included-item-tiers {
  margin: 0;
  font-size: var(--text-xs, 0.75rem);
  line-height: 1.35;
  color: var(--text-muted, #64748b);
}

/* ---- Responsive: stack on narrow screens --------------------------------- */
@media (max-width: 720px) {
  .sale-mp-modal {
    width: min(96vw, 30rem);
  }
  .sale-mp-modal__inner {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
    max-height: 92dvh;
  }
  .sale-mp-modal__media {
    aspect-ratio: 4 / 3;
  }
}
