/* ============================================
   POPUP OVERLAY — promotional announcements
   ============================================ */

#popup-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 300;
  align-items: center;
  justify-content: center;
  padding: 20px 16px;
}

#popup-overlay.popup-open { display: flex; }

/* ── Backdrop ── */
.popup-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(8, 6, 4, 0.6);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  opacity: 0;
  transition: opacity 0.35s ease;
}

#popup-overlay.popup-open    .popup-backdrop { opacity: 1; }
#popup-overlay.popup-closing .popup-backdrop { opacity: 0; transition-duration: 0.28s; }

/* ── Card shell ── */
.popup-card {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 360px;
  max-height: 90dvh;
  background: var(--white);
  border-radius: 28px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow:
    0 32px 80px rgba(0, 0, 0, 0.28),
    0 0 0 1px rgba(255, 255, 255, 0.55) inset;

  opacity: 0;
  transform: scale(0.82) translateY(40px);
  transition:
    opacity  0.42s cubic-bezier(0.22, 1, 0.36, 1),
    transform 0.42s cubic-bezier(0.22, 1, 0.36, 1);
}

#popup-overlay.popup-open    .popup-card { opacity: 1; transform: scale(1) translateY(0); }
#popup-overlay.popup-closing .popup-card {
  opacity: 0;
  transform: scale(0.9) translateY(24px);
  transition-timing-function: cubic-bezier(0.4, 0, 1, 1);
  transition-duration: 0.26s;
}

/* gradient accent strip */
.popup-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 4px;
  background: linear-gradient(to left, var(--blush-dark), var(--sage-light));
  z-index: 5;
  pointer-events: none;
}

/* ── Close button ── */
.popup-close {
  position: absolute;
  top: 14px;
  left: 14px;
  width: 32px; height: 32px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.85rem; line-height: 1;
  cursor: pointer;
  box-shadow: 0 2px 12px rgba(0,0,0,0.18);
  z-index: 10;
  opacity: 0;
  transform: scale(0.6) rotate(-45deg);
  transition: opacity 0.28s 0.28s ease, transform 0.28s 0.28s cubic-bezier(0.34,1.56,0.64,1), background 0.15s;
}

#popup-overlay.popup-open .popup-close { opacity: 1; transform: scale(1) rotate(0deg); }
.popup-close:hover  { background: #fff; }
.popup-close:active { transform: scale(0.84) !important; }

/* ════════════════════════════════════════════
   PRODUCT POPUP (new_item / discount_item)
   ════════════════════════════════════════════ */

/* ── Header: badge + title ── */
.popup-header {
  padding: 22px 20px 14px;
  display: flex;
  flex-direction: column;
  align-items: center;     /* وسط‌چین */
  gap: 8px;
  direction: rtl;

  opacity: 0;
  transform: translateY(-10px);
  transition: opacity 0.35s 0.18s ease, transform 0.35s 0.18s cubic-bezier(0.22,1,0.36,1);
}

#popup-overlay.popup-open .popup-header {
  opacity: 1;
  transform: translateY(0);
}

.popup-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.7rem;
  font-weight: 800;
  padding: 4px 13px;
  border-radius: var(--radius-pill);
  letter-spacing: 0.03em;
}

.popup-badge--new      { background: linear-gradient(135deg,#d1fae5,#a7f3d0); color: #065f46; }
.popup-badge--discount { background: linear-gradient(135deg,#fee2e2,#fecaca); color: #991b1b; }

.popup-headline {
  font-size: clamp(1rem, 4.5vw, 1.2rem);
  font-weight: 900;
  line-height: 1.3;
  color: var(--black);
  letter-spacing: -0.02em;
  text-align: center;
}

/* ── Card wrapper: the item-card lives here ── */
.popup-card-wrap {
  padding: 0 16px 20px;
  overflow-y: auto;
  overscroll-behavior: contain;

  opacity: 0;
  transform: translateY(18px) scale(0.96);
  transition: opacity 0.4s 0.24s cubic-bezier(0.22,1,0.36,1),
              transform 0.4s 0.24s cubic-bezier(0.22,1,0.36,1);
}

#popup-overlay.popup-open .popup-card-wrap {
  opacity: 1;
  transform: translateY(0) scale(1);
}

/* Override: کارت داخل popup کلیک‌پذیر نیست، hover هم نمی‌خواد */
.popup-item-card {
  cursor: default !important;
  animation: none !important;
  pointer-events: none;
}

.popup-item-card:hover {
  transform: none !important;
  box-shadow:
    0 4px 24px rgba(0,0,0,0.07),
    inset 0 1px 0 rgba(255,255,255,0.8) !important;
}

/* ════════════════════════════════════════════
   CUSTOM POPUP
   ════════════════════════════════════════════ */

.popup-content {
  padding: 22px 22px 32px;
  overflow-y: auto;
  overscroll-behavior: contain;
  flex: 1;
  direction: rtl;

  opacity: 0;
  transform: translateY(14px);
  transition: opacity 0.38s 0.22s ease, transform 0.38s 0.22s cubic-bezier(0.22,1,0.36,1);
}

#popup-overlay.popup-open .popup-content { opacity: 1; transform: translateY(0); }

.popup-content--custom {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.popup-custom-icon { font-size: 2.8rem; margin-bottom: 14px; line-height: 1; }

.popup-title {
  font-size: clamp(1.1rem, 5vw, 1.35rem);
  font-weight: 900;
  line-height: 1.3;
  color: var(--black);
  margin-bottom: 10px;
  letter-spacing: -0.02em;
  text-align: center;
}

.popup-divider {
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--blush-dark), transparent);
  margin-bottom: 18px;
  width: 100%;
}

.popup-custom-body {
  font-size: clamp(0.82rem, 2.4vw, 0.92rem);
  color: #4a4a4a;
  line-height: 1.85;
  text-align: right;
  width: 100%;
}

.popup-custom-body p,
.popup-custom-body ul,
.popup-custom-body ol { margin-bottom: 10px; }

.popup-custom-body strong { font-weight: 800; }
.popup-custom-body em     { font-style: italic; }

/* ════════════════════════════════════════════
   BANNER POPUP — lightbox, no card wrapper
   ════════════════════════════════════════════ */

.popup-banner-lightbox {
  position: relative;
  z-index: 1;
  width: 75%;
  max-width: 600px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;

  opacity: 0;
  transform: scale(0.88);
  transition:
    opacity  0.4s cubic-bezier(0.22, 1, 0.36, 1),
    transform 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}

#popup-overlay.popup-open    .popup-banner-lightbox { opacity: 1; transform: scale(1); }
#popup-overlay.popup-closing .popup-banner-lightbox {
  opacity: 0;
  transform: scale(0.92);
  transition-timing-function: cubic-bezier(0.4, 0, 1, 1);
  transition-duration: 0.26s;
}

/* تصویر بنر — کامل بدون crop */
.popup-banner-img {
  width: 100%;
  line-height: 0;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 24px 60px rgba(0,0,0,0.4);
}

.popup-banner-img img {
  display: block;
  width: 100%;
  height: auto;
  max-height: 80dvh;
  object-fit: contain;
}

.popup-banner-img a { display: block; line-height: 0; }

/* عنوان زیر تصویر */
.popup-banner-title {
  font-size: clamp(0.85rem, 2.5vw, 1rem);
  font-weight: 700;
  color: #fff;
  text-shadow: 0 1px 6px rgba(0,0,0,0.5);
  text-align: center;

  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.3s 0.28s ease, transform 0.3s 0.28s ease;
}

#popup-overlay.popup-open .popup-banner-title { opacity: 1; transform: translateY(0); }

/* دکمه بستن برای banner — بالای تصویر */
.popup-close--banner {
  position: absolute;
  top: -14px;
  left: -14px;
  background: rgba(255,255,255,0.95) !important;
}
