/* ========== Gallery Grid ========== */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
}

@media (min-width: 640px) {
  .gallery-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 1.25rem;
  }
}

@media (min-width: 1024px) {
  .gallery-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 1.5rem;
  }
}

.gallery-item {
  position: relative;
  border-radius: 1rem;
  overflow: hidden;
  background: #fff;
  border: 1px solid #f4f4f5;
  cursor: pointer;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  aspect-ratio: 4 / 3;
}

.dark .gallery-item {
  background: #18181b;
  border-color: #27272a;
}

.gallery-item:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.12);
}

.dark .gallery-item:hover {
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.4);
}

.gallery-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.4s ease;
}

.gallery-item:hover img {
  transform: scale(1.05);
}

.gallery-item figcaption {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 0.6rem 0.8rem;
  background: linear-gradient(transparent, rgba(0,0,0,0.65));
  color: #fff;
  font-size: 0.8rem;
  font-weight: 500;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.gallery-item:hover figcaption {
  opacity: 1;
}

/* ========== Lightbox ========== */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0, 0, 0, 0.88);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
  padding: 1rem;
}

.lightbox.active {
  opacity: 1;
  visibility: visible;
}

.lightbox-content {
  position: relative;
  max-width: min(90vw, 1100px);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.lightbox-content img {
  max-width: 100%;
  max-height: 80vh;
  object-fit: contain;
  border-radius: 12px;
  box-shadow: 0 25px 50px rgba(0,0,0,0.5);
}

.lightbox-caption {
  margin-top: 0.75rem;
  color: #e4e4e7;
  font-size: 0.9rem;
  text-align: center;
}

.lightbox-btn {
  position: absolute;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.2);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.2s ease;
  z-index: 10;
}

.lightbox-btn:hover {
  background: rgba(255,255,255,0.22);
  transform: scale(1.08);
}

.lightbox-close {
  top: 1.25rem;
  left: 1.25rem;
}

.lightbox-prev {
  top: 50%;
  right: 1rem;
  transform: translateY(-50%);
}

.lightbox-next {
  top: 50%;
  left: 1rem;
  transform: translateY(-50%);
}

.lightbox-download {
  margin-top: 1rem;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 1.1rem;
  border-radius: 999px;
  font-size: 0.875rem;
  font-weight: 500;
  color: #fff !important;
  text-decoration: none;
  background: rgba(255,255,255,0.12) !important;
  border: 1px solid rgba(255,255,255,0.25);
}

.lightbox-download:hover {
  background: rgba(255,255,255,0.2) !important;
}

/* جلوگیری از اسکرول بدنه هنگام باز بودن لایت‌باکس */
body.lightbox-open {
  overflow: hidden;
}

/* موبایل */
@media (max-width: 640px) {
  .lightbox-prev,
  .lightbox-next {
    width: 38px;
    height: 38px;
  }
  .lightbox-close {
    top: 0.75rem;
    left: 0.75rem;
  }
}