/* Home sticky product popup — sits above .bottom-bar */

body.home {
  --bj-bottom-bar-h: 72px;
  --bj-home-popup-ink: #1a1a1a;
  --bj-home-popup-muted: #6b7280;
  --bj-home-popup-muted-2: #9ca3af;
  --bj-home-popup-border: rgba(26, 26, 26, 0.06);
  --bj-home-popup-brand-soft: #eef4fc;
  --bj-home-popup-font: "Noto Sans Thai", "Sarabun", "Helvetica Neue", Arial, sans-serif;
}

#bj-home-product-popup.wp__product-popup {
  --ink: var(--bj-home-popup-ink);
  --muted: var(--bj-home-popup-muted);
  --muted-2: var(--bj-home-popup-muted-2);
  --border: var(--bj-home-popup-border);
  --brand-soft: var(--bj-home-popup-brand-soft);
  --wp-font-title: var(--bj-home-popup-font);

  position: fixed;
  left: 0;
  right: 0;
  bottom: calc(var(--bj-bottom-bar-h) + env(safe-area-inset-bottom, 0px));
  z-index: 1000;
  max-width: 480px;
  margin: 0 auto;
  padding: 0 12px;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(14px);
  transition:
    opacity 0.28s ease,
    transform 0.28s ease,
    visibility 0.28s;
  font-family: var(--bj-home-popup-font);
  box-sizing: border-box;
}

#bj-home-product-popup.wp__product-popup.is-visible {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0);
}

#bj-home-product-popup[hidden],
#bj-home-product-popup-pill[hidden] {
  display: none !important;
}

#bj-home-product-popup .wp__product-popup-track {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding-bottom: 2px;
  border-radius: 14px;
}

#bj-home-product-popup .wp__product-popup-track::-webkit-scrollbar {
  display: none;
}

#bj-home-product-popup .wp__product-popup-slide {
  flex: 0 0 85%;
  min-width: 0;
  scroll-snap-align: start;
}

#bj-home-product-popup .wp__product-popup-inner {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 8px 28px rgba(15, 23, 42, 0.14);
  height: 100%;
  box-sizing: border-box;
}

#bj-home-product-popup .wp__product-popup-close {
  position: absolute;
  top: 8px;
  right: 16px;
  z-index: 3;
  appearance: none;
  border: 0;
  background: rgba(255, 255, 255, 0.92);
  width: 26px;
  height: 26px;
  padding: 0;
  margin: 0;
  border-radius: 8px;
  color: var(--muted-2);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  display: grid;
  place-items: center;
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.12);
}

#bj-home-product-popup .wp__product-popup-close:hover,
#bj-home-product-popup .wp__product-popup-close:focus-visible {
  color: var(--ink);
  background: var(--brand-soft);
}

#bj-home-product-popup .wp__product-popup-thumb {
  position: relative;
  flex: 0 0 72px !important;
  width: 72px !important;
  height: 72px !important;
  min-width: 72px !important;
  max-width: 72px !important;
  min-height: 72px !important;
  max-height: 72px !important;
  aspect-ratio: 1 / 1 !important;
  align-self: center !important;
  border-radius: 10px;
  overflow: hidden;
  background: #fff;
  border: 1px solid var(--border);
  box-sizing: border-box;
}

#bj-home-product-popup .wp__product-popup-thumb img {
  display: block !important;
  width: 72px !important;
  height: 72px !important;
  min-width: 72px !important;
  min-height: 72px !important;
  max-width: 72px !important;
  max-height: 72px !important;
  margin: 0 !important;
  padding: 0 !important;
  border: 0 !important;
  border-radius: 0 !important;
  object-fit: cover !important;
  object-position: center !important;
  transform: none !important;
  aspect-ratio: 1 / 1 !important;
}

#bj-home-product-popup .wp__product-popup-badge {
  position: absolute;
  left: 4px;
  top: 4px;
  z-index: 1;
  padding: 2px 6px;
  border-radius: 6px;
  background: rgba(26, 26, 26, 0.78);
  color: #fff;
  font-size: 10px;
  font-weight: 600;
  line-height: 1.2;
}

#bj-home-product-popup .wp__product-popup-body {
  flex: 1;
  min-width: 0;
  padding-right: 4px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
}

#bj-home-product-popup .wp__product-popup-name {
  margin: 0;
  padding-right: 18px;
  font-family: var(--wp-font-title);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.35;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  -webkit-mask-image: linear-gradient(90deg, #000 87%, transparent);
  mask-image: linear-gradient(90deg, #000 87%, transparent);
}

#bj-home-product-popup .wp__product-popup-prices {
  margin: 2px 0 0;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px;
}

#bj-home-product-popup .wp__product-popup-price {
  font-family: var(--wp-font-title);
  font-size: 16px;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.2;
}

#bj-home-product-popup .wp__product-popup-normal {
  font-size: 12px;
  color: var(--muted-2);
  text-decoration: line-through;
}

#bj-home-product-popup .wp__product-popup-discount {
  font-size: 12px;
  font-weight: 600;
  color: #ee4d2d;
}

#bj-home-product-popup .wp__product-popup-coupon {
  margin: 4px 0 0;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.3;
  color: #c2410c;
}

#bj-home-product-popup .wp__product-popup-buy {
  flex-shrink: 0;
  align-self: center;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  padding: 7px 12px;
  border-radius: 8px;
  text-decoration: none !important;
  font-family: var(--wp-font-title);
  font-weight: 700;
  font-size: 13px;
  line-height: 1.2;
  background: #ee4d2d;
  color: #fff !important;
  box-shadow: 0 2px 8px rgba(238, 77, 45, 0.28);
}

#bj-home-product-popup .wp__product-popup-buy:hover,
#bj-home-product-popup .wp__product-popup-buy:focus-visible {
  filter: brightness(1.05);
}

/* Collapsed reopen pill */
.bj-home-product-popup-pill {
  position: fixed;
  left: 12px;
  bottom: calc(var(--bj-bottom-bar-h) + env(safe-area-inset-bottom, 0px) + 8px);
  z-index: 1000;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: calc(100vw - 24px);
  padding: 6px 12px 6px 6px;
  border: 1px solid var(--bj-home-popup-border);
  border-radius: 999px;
  background: #fff;
  box-shadow: 0 6px 20px rgba(15, 23, 42, 0.16);
  color: var(--bj-home-popup-ink);
  font-family: var(--bj-home-popup-font);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.2;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
}

.bj-home-product-popup-pill__thumb {
  flex: 0 0 36px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  overflow: hidden;
  border: 1px solid var(--bj-home-popup-border);
  background: #fff;
}

.bj-home-product-popup-pill__thumb img {
  display: block;
  width: 36px;
  height: 36px;
  object-fit: cover;
}

.bj-home-product-popup-pill__label {
  white-space: nowrap;
  padding-right: 4px;
}

/* Yield to checkout summary / resume float */
body.home.benjaruk-summary-open #bj-home-product-popup,
body.home.benjaruk-summary-open #bj-home-product-popup-pill,
body.benjaruk-home-checkout.benjaruk-summary-open #bj-home-product-popup,
body.benjaruk-home-checkout.benjaruk-summary-open #bj-home-product-popup-pill,
body.home.bj-home-product-popup-yield #bj-home-product-popup,
body.home.bj-home-product-popup-yield #bj-home-product-popup-pill {
  visibility: hidden !important;
  pointer-events: none !important;
  opacity: 0 !important;
}
