/* ============================================================
   PantiGame — Gallery Lightbox
   فقط lightbox و cursor — سایز و layout پیش‌فرض وردپرس
   ============================================================ */

/* ── گالری کلاسیک ویرایشگر: بازگرداندن ستون‌بندی صحیح ── */
.pg-article-body .gallery,
.entry-content .gallery {
  display: grid;
  gap: 4px;
  margin-block: 1em;
}
/* ستون‌بندی بر اساس کلاس وردپرس */
.pg-article-body .gallery-columns-1, .entry-content .gallery-columns-1 { grid-template-columns: repeat(1, 1fr); }
.pg-article-body .gallery-columns-2, .entry-content .gallery-columns-2 { grid-template-columns: repeat(2, 1fr); }
.pg-article-body .gallery-columns-3, .entry-content .gallery-columns-3 { grid-template-columns: repeat(3, 1fr); }
.pg-article-body .gallery-columns-4, .entry-content .gallery-columns-4 { grid-template-columns: repeat(4, 1fr); }
.pg-article-body .gallery-columns-5, .entry-content .gallery-columns-5 { grid-template-columns: repeat(5, 1fr); }
.pg-article-body .gallery-columns-6, .entry-content .gallery-columns-6 { grid-template-columns: repeat(6, 1fr); }
.pg-article-body .gallery-columns-7, .entry-content .gallery-columns-7 { grid-template-columns: repeat(7, 1fr); }
.pg-article-body .gallery-columns-8, .entry-content .gallery-columns-8 { grid-template-columns: repeat(8, 1fr); }
.pg-article-body .gallery-columns-9, .entry-content .gallery-columns-9 { grid-template-columns: repeat(9, 1fr); }

.pg-article-body .gallery-item,
.entry-content .gallery-item {
  /* ریست float پیش‌فرض وردپرس */
  float: none !important;
  margin: 0 !important;
  width: 100% !important;
}

.pg-article-body .gallery-item img,
.entry-content .gallery-item img {
  width: 100%;
  height: auto;
  display: block;
}

/* clearfix پیش‌فرض وردپرس دیگه لازم نیست */
.pg-article-body .gallery::after,
.entry-content .gallery::after {
  display: none;
}

/* cursor zoom-in روی تصاویر گالری */
.pg-article-body .gallery img,
.entry-content .gallery img,
.pg-article-body .wp-block-gallery img,
.entry-content .wp-block-gallery img {
  cursor: zoom-in;
}

/* hover: کمی روشن‌تر */
.pg-article-body .gallery img:hover,
.entry-content .gallery img:hover,
.pg-article-body .wp-block-gallery img:hover,
.entry-content .wp-block-gallery img:hover {
  filter: brightness(1.08);
  transition: filter 0.2s ease;
}

/* overlay روی تصویر هنگام hover */
.pg-gallery-item-wrap {
  position: relative;
  display: inline-block;
  cursor: zoom-in;
}
.pg-gallery-item-wrap::after {
  content: '';
  position: absolute;
  inset: 0;
  background:
    rgba(0,0,0,0.28)
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='m21 21-4.35-4.35'/%3E%3Cpath d='M11 8v6M8 11h6'/%3E%3C/svg%3E")
    no-repeat center/32px 32px;
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: none;
  border-radius: inherit;
}
.pg-gallery-item-wrap:hover::after { opacity: 1; }

@media (max-width: 600px) {
  .pg-article-body .gallery-columns-3,
  .pg-article-body .gallery-columns-4,
  .pg-article-body .gallery-columns-5,
  .pg-article-body .gallery-columns-6,
  .pg-article-body .gallery-columns-7,
  .pg-article-body .gallery-columns-8,
  .pg-article-body .gallery-columns-9,
  .entry-content .gallery-columns-3,
  .entry-content .gallery-columns-4,
  .entry-content .gallery-columns-5,
  .entry-content .gallery-columns-6,
  .entry-content .gallery-columns-7,
  .entry-content .gallery-columns-8,
  .entry-content .gallery-columns-9 {
    grid-template-columns: repeat(2, 1fr) !important;
  }
}

/* ══════════════════════════════════════════
   Lightbox — پس‌زمینه
══════════════════════════════════════════ */
.pg-lightbox {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0);
  backdrop-filter: blur(0px);
  -webkit-backdrop-filter: blur(0px);
  transition:
    background 0.35s ease,
    backdrop-filter 0.35s ease;
  padding: var(--space-6);
  box-sizing: border-box;
  cursor: zoom-out;
}
.pg-lightbox.pg-lb-open {
  background: rgba(0, 0, 0, 0.88);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

/* ── کارت تصویر ── */
.pg-lb-card {
  position: relative;
  max-width: min(92vw, 1100px);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: default;

  /* انیمیشن ورود */
  opacity: 0;
  transform: scale(0.88) translateY(20px);
  transition:
    opacity 0.35s cubic-bezier(0.34, 1.56, 0.64, 1),
    transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.pg-lightbox.pg-lb-open .pg-lb-card {
  opacity: 1;
  transform: scale(1) translateY(0);
}

/* انیمیشن خروج */
.pg-lightbox.pg-lb-closing .pg-lb-card {
  opacity: 0;
  transform: scale(0.88) translateY(30px);
  transition:
    opacity 0.25s ease,
    transform 0.25s ease;
}
.pg-lightbox.pg-lb-closing {
  background: rgba(0,0,0,0);
  backdrop-filter: blur(0px);
  -webkit-backdrop-filter: blur(0px);
  transition:
    background 0.25s ease,
    backdrop-filter 0.25s ease;
}

/* ── تصویر اصلی ── */
.pg-lb-img {
  max-width: 100%;
  max-height: calc(90vh - 80px);
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: var(--radius-xl);
  box-shadow: 0 24px 80px rgba(0,0,0,0.6), 0 0 0 1px rgba(255,255,255,0.06);
  display: block;
  user-select: none;
  -webkit-user-drag: none;

  /* انیمیشن تغییر تصویر */
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.pg-lb-img.pg-lb-changing {
  opacity: 0;
  transform: scale(0.95);
}

/* ── caption ── */
.pg-lb-caption {
  color: rgba(255,255,255,0.7);
  font-size: var(--font-size-sm);
  text-align: center;
  margin-top: var(--space-3);
  max-width: 600px;
  line-height: 1.5;
  min-height: 20px;
}

/* ── شمارنده ── */
.pg-lb-counter {
  position: absolute;
  top: -38px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(255,255,255,0.1);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: var(--radius-full);
  padding: 4px 14px;
  font-size: var(--font-size-xs);
  color: rgba(255,255,255,0.8);
  white-space: nowrap;
  font-weight: var(--font-weight-semibold);
}

/* ── دکمه بستن ── */
.pg-lb-close {
  position: absolute;
  top: -44px;
  right: 0;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.2);
  color: #fff;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition-fast), transform var(--transition-bounce);
  z-index: 10;
  flex-shrink: 0;
  line-height: 1;
}
.pg-lb-close:hover {
  background: rgba(244, 63, 94, 0.6);
  transform: scale(1.12) rotate(90deg);
}

/* ── دکمه‌های ناوبری (قبلی / بعدی) ── */
.pg-lb-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.18);
  color: #fff;
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition:
    background var(--transition-fast),
    transform var(--transition-bounce),
    opacity var(--transition-fast);
  z-index: 10;
  flex-shrink: 0;
}
.pg-lb-nav:hover {
  background: rgba(56,189,248,0.35);
  border-color: rgba(56,189,248,0.5);
  transform: translateY(-50%) scale(1.1);
}
.pg-lb-nav:active { transform: translateY(-50%) scale(0.96); }
.pg-lb-nav.pg-lb-prev { right: calc(100% + 16px); }
.pg-lb-nav.pg-lb-next { left:  calc(100% + 16px); }
.pg-lb-nav[disabled] { opacity: 0.2; pointer-events: none; cursor: default; }

/* موبایل: دکمه‌های nav داخل کارت */
@media (max-width: 700px) {
  .pg-lb-nav.pg-lb-prev { right: unset; left: 8px;  }
  .pg-lb-nav.pg-lb-next { left:  unset; right: 8px; }
  .pg-lb-nav {
    top: auto;
    bottom: 50px;
    transform: none;
    width: 38px;
    height: 38px;
  }
  .pg-lb-nav:hover { transform: scale(1.08); }
  .pg-lb-nav:active { transform: scale(0.95); }
  .pg-lb-close { top: -40px; }
}

/* ── نوار dots پایین ── */
.pg-lb-dots {
  display: flex;
  gap: 6px;
  margin-top: var(--space-4);
  flex-wrap: wrap;
  justify-content: center;
  max-width: 300px;
}
.pg-lb-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: rgba(255,255,255,0.25);
  cursor: pointer;
  transition: background var(--transition-fast), transform var(--transition-fast);
  flex-shrink: 0;
}
.pg-lb-dot:hover { background: rgba(255,255,255,0.55); }
.pg-lb-dot.pg-lb-dot-active {
  background: var(--color-primary);
  transform: scale(1.35);
}

/* ── نوار لود (swipe progress) ── */
.pg-lb-progress {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: rgba(255,255,255,0.12);
  border-radius: 2px;
  overflow: hidden;
  opacity: 0;
  transition: opacity 0.2s;
}
.pg-lb-progress.pg-lb-prog-show { opacity: 1; }
.pg-lb-progress-fill {
  height: 100%;
  background: var(--gradient-primary);
  width: 0;
  border-radius: 2px;
  transition: width 0.15s ease;
}

/* ── swipe hint روی موبایل ── */
@media (max-width: 700px) {
  .pg-lb-img { border-radius: var(--radius-lg); }
}

/* reduced motion */
@media (prefers-reduced-motion: reduce) {
  .pg-lb-card,
  .pg-lb-img,
  .pg-lightbox { transition: none !important; }
}
