/* Souci Mall — live order notifications (social proof bubble).
 *
 * Fixed-position bubble that slides in from the configured edge, stays a
 * few seconds, then slides out. Bourbon palette: dark surface, gold accent
 * on the verified-order tick + product link. Avoids overlapping the
 * floating WhatsApp / cart-FAB row by keeping the offset configurable
 * (Customizer → Live order notifications) and slimming on mobile.
 */

.sm-sp {
  position: fixed;
  z-index: 90;             /* below mobile tabbar (95) + sticky cart (100) */
  pointer-events: none;
  width: min(340px, calc(100vw - 32px));
}
.sm-sp__bubble {
  pointer-events: auto;
  display: grid;
  grid-template-columns: 56px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(21, 21, 30, 0.92);
  border: 1px solid rgba(190, 149, 93, 0.28);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.32), 0 2px 6px rgba(0, 0, 0, 0.18);
  backdrop-filter: blur(14px) saturate(1.05);
  -webkit-backdrop-filter: blur(14px) saturate(1.05);
  color: var(--sm-ink, #F5F0E8);
  margin-top: 10px;        /* spacing between successive bubbles if they overlap briefly */
  opacity: 0;
  will-change: transform, opacity;
  transition: transform .42s cubic-bezier(0.22, 1, 0.36, 1), opacity .35s ease;
}

/* Slide-in direction depends on which edge we're anchored to.
 * IMPORTANT: chain `.is-in` / `.is-out` under the same `[data-sm-sp-align]`
 * selector so the active-state rules match the initial-state rule's
 * specificity (0,2,1). Otherwise the initial off-screen transform wins
 * and the bubble never enters. */
.sm-sp[data-sm-sp-align="left"]  .sm-sp__bubble        { transform: translate3d(-110%, 0, 0); }
.sm-sp[data-sm-sp-align="right"] .sm-sp__bubble        { transform: translate3d(110%, 0, 0); }
.sm-sp[data-sm-sp-align="left"]  .sm-sp__bubble.is-in  { transform: translate3d(0, 0, 0); opacity: 1; }
.sm-sp[data-sm-sp-align="right"] .sm-sp__bubble.is-in  { transform: translate3d(0, 0, 0); opacity: 1; }
.sm-sp[data-sm-sp-align="left"]  .sm-sp__bubble.is-out { transform: translate3d(-110%, 0, 0); opacity: 0; }
.sm-sp[data-sm-sp-align="right"] .sm-sp__bubble.is-out { transform: translate3d(110%, 0, 0);  opacity: 0; }
/* Reduced motion → fade only */
.sm-sp__bubble.is-reduced              { transform: none; transition: opacity .25s ease; }
.sm-sp__bubble.is-reduced.is-in        { transform: none; opacity: 1; }
.sm-sp__bubble.is-reduced.is-out       { transform: none; opacity: 0; }

.sm-sp__thumb {
  display: block;
  width: 56px;
  height: 56px;
  border-radius: 10px;
  overflow: hidden;
  background: rgba(190, 149, 93, 0.10);
  border: 1px solid rgba(190, 149, 93, 0.18);
  flex-shrink: 0;
}
.sm-sp__thumb img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
}

.sm-sp__copy {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.sm-sp__line {
  margin: 0;
  font-size: 11px;
  line-height: 1.3;
  letter-spacing: 0.02em;
  color: var(--sm-ink-muted, #9C9587);
}
.sm-sp__who   { color: var(--sm-ink, #F5F0E8); font-weight: 600; }
.sm-sp__verb  { color: var(--sm-ink-muted, #9C9587); }
.sm-sp__product {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 13px;
  font-weight: 600;
  color: var(--sm-ink, #F5F0E8);
  text-decoration: none;
  letter-spacing: 0.005em;
  line-height: 1.3;
  transition: color .2s ease;
}
.sm-sp__product:hover { color: var(--sm-accent, #BE955D); }
.sm-sp__meta {
  margin: 2px 0 0;
  font-size: 10px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--sm-ink-muted, #9C9587);
  display: flex;
  align-items: center;
  gap: 4px;
}
.sm-sp__verified {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  color: var(--sm-accent, #BE955D);
  font-weight: 700;
}
.sm-sp__verified svg { display: block; }
.sm-sp__dot { color: var(--sm-line, #2a2a35); margin: 0 1px; }
.sm-sp__time { color: var(--sm-ink-muted, #9C9587); font-weight: 500; }

.sm-sp__close {
  align-self: flex-start;
  width: 22px; height: 22px;
  border: 0;
  background: transparent;
  color: var(--sm-ink-muted, #9C9587);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  border-radius: 6px;
  margin-top: -2px;
  margin-right: -4px;
  transition: color .15s ease, background .15s ease;
}
.sm-sp__close:hover {
  color: var(--sm-ink, #F5F0E8);
  background: rgba(190, 149, 93, 0.10);
}

/* Mobile — slim down + lift above the bottom tabbar so it doesn't collide */
@media (max-width: 600px) {
  .sm-sp {
    width: calc(100vw - 24px);
    /* Force the horizontal offset to a thin gutter; preserve top/bottom from
     * the inline style. The `bottom-*` variants get a baseline lift so the
     * bubble sits above the mobile tabbar when present. */
  }
  body.has-mobile-tabbar .sm-sp.sm-sp--bottom-left,
  body.has-mobile-tabbar .sm-sp.sm-sp--bottom-right {
    bottom: calc(68px + 12px + env(safe-area-inset-bottom, 0px)) !important;
  }
  .sm-sp__bubble {
    padding: 10px 12px;
    grid-template-columns: 44px 1fr auto;
    gap: 10px;
  }
  .sm-sp__thumb { width: 44px; height: 44px; border-radius: 8px; }
  .sm-sp__product { font-size: 12.5px; }
  .sm-sp__line, .sm-sp__meta { font-size: 10px; }
}

/* ============================================================
 * Inline mode — Pinduoduo-style "recently ordered" panel.
 *
 * Two slots on the single-product page (controlled by separate
 * Customizer toggles):
 *   .sm-sp--inline-summary   inside product summary,  1 row
 *   .sm-sp--inline-tabs      full-width above tabs,   3 rows
 *
 * Server-rendered static content — no JS rotation, no close button.
 * Reads as social proof + a quick path back to the product, not a
 * roving advert. Bourbon dark surface + thin gold hairline + dashed
 * accent quoting Pinduoduo's "group-buy" boxed framing without the
 * red/orange palette.
 * ============================================================ */
.sm-sp--inline {
  position: relative;
  width: 100%;
  display: block;
  pointer-events: auto;
  /* Reset the z-index inherited from the base `.sm-sp` rule (z 90 — meant
   * only for the FIXED floating bubble). An inline, in-flow panel with
   * z-index 90 paints above the sticky header (z 60) and covers it as the
   * page scrolls. `auto` keeps the panel in normal stacking order so it
   * scrolls behind the header like any other content. */
  z-index: auto;
}
.sm-sp--inline-summary { margin: 14px 0 18px; min-width: 0; max-width: 100%; }
/* Tabs slot fills the surrounding `.sm-wrap` (1440 px max) — drop the
 * earlier max-width: 760 cap so the right side doesn't read as hollow.
 * Inner row content still self-limits via `min-width: 0` truncation. */
.sm-sp--inline-tabs    { margin: 28px 0 24px; }
/* `.sm-sp--inline-tabs` is rendered (via woocommerce_after_single_product_summary)
 * as a direct child of `.woocommerce div.product`, which is a 2-column
 * CSS grid on desktop. Without a column span it auto-places into a
 * single column, leaving the other half blank (the "右边太空了" report).
 * Span the full grid width so it always stretches edge-to-edge. */
.woocommerce div.product > .sm-sp--inline-tabs { grid-column: 1 / -1; }

/* Outer panel — dashed gold border riffs the Pinduoduo box; subdued
 * surface keeps it from competing with the product hero. */
.sm-sp-panel {
  position: relative;
  background: linear-gradient(180deg,
    color-mix(in srgb, var(--sm-surface) 92%, var(--sm-accent) 8%),
    var(--sm-surface));
  border: 1px dashed color-mix(in srgb, var(--sm-accent) 50%, transparent);
  border-radius: 14px;
  padding: 14px 16px 12px;
}

/* Heading row — fire icon + "Recently ordered" + count badge */
.sm-sp-panel__head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  font-family: var(--sm-mono-font);
  font-size: 11px;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--sm-accent);
}
.sm-sp-panel__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px; height: 22px;
  border-radius: 11px;
  background: color-mix(in srgb, var(--sm-accent) 14%, transparent);
  border: 1px solid color-mix(in srgb, var(--sm-accent) 30%, transparent);
  color: var(--sm-accent);
}
.sm-sp-panel__title { font-weight: 700; }
.sm-sp-panel__count {
  color: var(--sm-ink-muted);
  font-weight: 500;
  letter-spacing: 0.6px;
  margin-left: auto;
  text-transform: none;
}

/* Row list */
.sm-sp-panel__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
}
.sm-sp-panel__row + .sm-sp-panel__row {
  border-top: 1px dashed color-mix(in srgb, var(--sm-line) 70%, transparent);
}
.sm-sp-panel__link {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;   /* `minmax(0, 1fr)` forces the body cell to shrink so the cta column always fits */
  align-items: center;
  gap: 12px;
  padding: 10px 4px;
  text-decoration: none;
  color: inherit;
  transition: transform .2s ease;
}
.sm-sp-panel__link:hover {
  transform: translateX(2px);
}
.sm-sp-panel__link:hover .sm-sp-panel__product { color: var(--sm-accent); }
.sm-sp-panel__link:hover .sm-sp-panel__arrow   { transform: translateX(3px); }

/* Avatar pair — two stacked initial-circles. Hue-rotate per row makes
 * each pair feel distinct without breaking the gold theme. */
.sm-sp-panel__avatars {
  position: relative;
  width: 44px;
  height: 28px;
  flex-shrink: 0;
}
.sm-sp-panel__avatar {
  position: absolute;
  top: 0;
  width: 28px;
  height: 28px;
  border-radius: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--sm-display-font);
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0;
  color: var(--sm-accent-ink, #08080C);
  background: linear-gradient(135deg, var(--sm-accent), color-mix(in srgb, var(--sm-accent) 70%, var(--sm-accent-ink, #000)));
  border: 2px solid var(--sm-surface);
  text-transform: uppercase;
}
.sm-sp-panel__avatar:nth-child(1) { left: 0;  z-index: 2; }
.sm-sp-panel__avatar:nth-child(2) { left: 16px; z-index: 1; }

/* Body — name + product, then verified + city below */
.sm-sp-panel__body { min-width: 0; max-width: 100%; }
.sm-sp-panel__line {
  display: -webkit-box;            /* allow up to 2 lines, then ellipsify */
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  font-size: 13px;
  letter-spacing: 0.005em;
  color: var(--sm-ink-soft);
  line-height: 1.35;
  word-break: break-word;          /* break long product names rather than overflow */
  overflow-wrap: anywhere;
}
.sm-sp-panel__who { color: var(--sm-ink); font-weight: 600; }
.sm-sp-panel__sep { color: var(--sm-ink-muted); margin: 0 4px; }
.sm-sp-panel__product { color: var(--sm-ink); font-weight: 500; transition: color .15s ease; }
.sm-sp-panel__sub {
  display: block;
  margin-top: 2px;
  font-family: var(--sm-mono-font);
  font-size: 10px;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  color: var(--sm-ink-muted);
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
}
.sm-sp-panel__verified {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  color: var(--sm-accent);
  font-weight: 700;
}
.sm-sp-panel__verified svg { display: block; }
.sm-sp-panel__dot { color: var(--sm-line); }

/* Right CTA — time + → arrow */
.sm-sp-panel__cta {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--sm-mono-font);
  font-size: 10.5px;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  color: var(--sm-ink-muted);
  flex-shrink: 0;
}
.sm-sp-panel__time { color: var(--sm-ink-muted); }
.sm-sp-panel__arrow {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px; height: 24px;
  border-radius: 12px;
  background: color-mix(in srgb, var(--sm-accent) 14%, transparent);
  color: var(--sm-accent);
  font-weight: 700;
  transition: transform .2s ease, background .2s ease;
}

/* Compact variant (summary column is narrow) — stack the right CTA
 * BELOW the body so the row uses two lines vertically and stops
 * leaving a hollow right gutter. Same behaviour as the mobile rule
 * applied unconditionally because the summary column is always narrow. */
.sm-sp--inline-summary .sm-sp-panel {
  padding: 12px 14px 10px;
}
.sm-sp--inline-summary .sm-sp-panel__head { font-size: 10px; margin-bottom: 8px; }
.sm-sp--inline-summary .sm-sp-panel__line { font-size: 12px; -webkit-line-clamp: 2; }
.sm-sp--inline-summary .sm-sp-panel__sub  { font-size: 9.5px; }
.sm-sp--inline-summary .sm-sp-panel__count { display: none; }    /* save space */
.sm-sp--inline-summary .sm-sp-panel__avatars { width: 38px; height: 24px; }
.sm-sp--inline-summary .sm-sp-panel__avatar  { width: 24px; height: 24px; font-size: 11px; }
.sm-sp--inline-summary .sm-sp-panel__avatar:nth-child(2) { left: 14px; }
.sm-sp--inline-summary .sm-sp-panel__link {
  grid-template-columns: auto minmax(0, 1fr);  /* drop the cta column */
  row-gap: 6px;
}
.sm-sp--inline-summary .sm-sp-panel__cta {
  grid-column: 1 / -1;
  justify-self: end;
  font-size: 9.5px;
  margin-top: 2px;
}

/* Mobile — pretzel the right CTA below to stop the row collapsing. */
@media (max-width: 600px) {
  .sm-sp-panel__link { grid-template-columns: auto 1fr; }
  .sm-sp-panel__cta {
    grid-column: 2;
    justify-self: end;
    margin-top: -4px;
  }
  .sm-sp-panel__sub { font-size: 9.5px; }
}
