/* ============================================
   صفحة معرض الصور - Gallery Page
   ============================================ */

/* ===== شبكة المعرض ===== */
.gallery-masonry {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: var(--space-6);
}

.gallery-item {
  position: relative;
  border-radius: var(--radius-lg);
  overflow: hidden;
  cursor: pointer;
  background: var(--color-bg-secondary);
  aspect-ratio: 4/5;
}

.gallery-item img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  transition: transform 0.6s var(--ease-out);
}

.gallery-item:hover img {
  transform: scale(1.06);
}

.gallery-item-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(11,13,15,0.85) 0%, transparent 55%);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: var(--space-5);
  opacity: 0;
  transition: opacity var(--duration-base) var(--ease-out);
}

.gallery-item:hover .gallery-item-overlay {
  opacity: 1;
}

.gallery-item-overlay span {
  color: #fff;
  font-size: var(--text-sm);
  font-weight: 700;
}

.gallery-item-expand {
  position: absolute;
  top: var(--space-4);
  left: var(--space-4);
  width: 38px;
  height: 38px;
  border-radius: var(--radius-full);
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-border);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity var(--duration-base) var(--ease-out);
}

.gallery-item:hover .gallery-item-expand {
  opacity: 1;
}

.gallery-item-expand svg {
  width: 16px;
  height: 16px;
  color: #fff;
}

/* ===== نافذة العرض الكبير (Lightbox) ===== */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(11,13,15,0.94);
  z-index: var(--z-modal);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: all var(--duration-base) var(--ease-out);
  padding: var(--space-8);
}

.lightbox.is-open {
  opacity: 1;
  visibility: visible;
}

.lightbox-image-wrap {
  max-width: 900px;
  max-height: 80vh;
  position: relative;
}

.lightbox img {
  max-width: 100%;
  max-height: 80vh;
  border-radius: var(--radius-md);
  object-fit: contain;
  transform: scale(0.94);
  transition: transform var(--duration-base) var(--ease-out);
}

.lightbox.is-open img {
  transform: scale(1);
}

.lightbox-caption {
  text-align: center;
  color: rgba(247,245,241,0.8);
  font-size: var(--text-sm);
  margin-top: var(--space-4);
}

.lightbox-close {
  position: absolute;
  top: var(--space-6);
  left: var(--space-6);
  width: 48px;
  height: 48px;
  border-radius: var(--radius-full);
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
}

.lightbox-close svg { width: 20px; height: 20px; }

.lightbox-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 52px;
  height: 52px;
  border-radius: var(--radius-full);
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  transition: background var(--duration-fast) var(--ease-out);
}

.lightbox-nav:hover {
  background: var(--color-accent-primary);
  color: #14171A;
}

.lightbox-nav svg { width: 22px; height: 22px; }
.lightbox-prev { right: var(--space-6); }
.lightbox-next { left: var(--space-6); }

/* ===== قبل / بعد - Slider تفاعلي ===== */
.before-after-section {
  background: var(--color-bg-secondary);
}

.before-after-widget {
  position: relative;
  max-width: 900px;
  margin-inline: auto;
  aspect-ratio: 16/9;
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  cursor: ew-resize;
  user-select: none;
}

.ba-image-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.ba-image-layer img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  user-select: none;
  pointer-events: none;
}

.ba-image-layer.ba-after {
  clip-path: inset(0 0 0 50%);
}

.ba-label {
  position: absolute;
  top: var(--space-5);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: 700;
  background: rgba(11,13,15,0.7);
  color: #fff;
  backdrop-filter: blur(8px);
}

.ba-label.ba-label-before { left: var(--space-5); }
.ba-label.ba-label-after { right: var(--space-5); }

.ba-handle {
  position: absolute;
  top: 0;
  bottom: 0;
  right: 50%;
  width: 3px;
  background: #fff;
  transform: translateX(50%);
  box-shadow: 0 0 12px rgba(0,0,0,0.4);
}

.ba-handle-grip {
  position: absolute;
  top: 50%;
  right: 50%;
  transform: translate(50%, -50%);
  width: 44px;
  height: 44px;
  border-radius: var(--radius-full);
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  box-shadow: var(--shadow-md);
}

.ba-handle-grip svg {
  width: 14px;
  height: 14px;
  color: var(--color-text-primary);
}

.before-after-tabs {
  display: flex;
  justify-content: center;
  gap: var(--space-3);
  margin-bottom: var(--space-8);
  flex-wrap: wrap;
}

@media (max-width: 640px) {
  .gallery-masonry { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: var(--space-4); }
  .lightbox-nav { width: 42px; height: 42px; }
  .lightbox-prev { right: var(--space-2); }
  .lightbox-next { left: var(--space-2); }
}
