/* =========================================================
   كبسولة شرعية — gallery.css
   Gallery-specific styles (mobile-first)
   Depends on: style.css (CSS variables & utilities)
   ========================================================= */

/* ─────────────────────────────────────────────────────────
   1. Hero Banner
   ───────────────────────────────────────────────────────── */
.gallery-hero {
  padding: calc(var(--header-h, 84px) + 36px) 0 44px;
  background: var(--bg-features-tint);
  text-align: center;
  position: relative;
  overflow: hidden;
  transition: background-color 0.35s var(--ease);
}

.gallery-hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(
      ellipse 70% 60% at 20% 50%,
      rgba(91, 53, 213, 0.07) 0%,
      transparent 70%
    ),
    radial-gradient(
      ellipse 60% 60% at 80% 50%,
      rgba(244, 92, 58, 0.06) 0%,
      transparent 70%
    );
  pointer-events: none;
}

.gallery-hero .eyebrow {
  margin-bottom: 16px;
}

.gallery-hero h1 {
  font-size: clamp(1.8rem, 5vw, 3.2rem);
  color: var(--text-dark);
  margin-bottom: 12px;
}

.gallery-hero p {
  font-size: clamp(0.95rem, 2.5vw, 1.05rem);
  max-width: 520px;
  margin: 0 auto;
}

/* ─────────────────────────────────────────────────────────
   2. Stats Bar
   ───────────────────────────────────────────────────────── */
.gallery-stats {
  background: var(--bg-features-tint);
  padding: 24px 0;
  border-top: 1px solid var(--border-soft);
  border-bottom: 1px solid var(--border-soft);
  transition:
    background-color 0.35s var(--ease),
    border-color 0.35s var(--ease);
}

.g-stat {
  text-align: center;
  padding: 6px 0;
}

.g-stat-num {
  font-family: var(--font-display);
  font-size: clamp(1.5rem, 3vw, 1.9rem);
  font-weight: 900;
  color: var(--brand-primary);
  display: block;
  line-height: 1;
  margin-bottom: 5px;
}

.g-stat-label {
  font-size: clamp(0.78rem, 2vw, 0.9rem);
  color: var(--text-muted);
  transition: color 0.35s var(--ease);
}

/* ─────────────────────────────────────────────────────────
   3. Gallery Section wrapper
   ───────────────────────────────────────────────────────── */
.gallery-section {
  background: var(--bg-body);
  transition: background-color 0.35s var(--ease);
  padding-bottom: 64px;
}

/* ─────────────────────────────────────────────────────────
   4. Filter Bar  (mobile-first)
   ───────────────────────────────────────────────────────── */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  padding: 28px 0 22px;
}

.filter-btn {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.82rem;
  padding: 7px 16px;
  border-radius: var(--radius-pill);
  border: 1.5px solid var(--border-soft);
  background: var(--card-bg);
  color: var(--text-muted);
  cursor: pointer;
  transition:
    background-color 0.25s var(--ease),
    border-color 0.25s var(--ease),
    color 0.25s var(--ease),
    box-shadow 0.25s var(--ease);
}

.filter-btn:hover {
  border-color: var(--brand-primary);
  color: var(--brand-primary);
}

.filter-btn.active {
  background: var(--brand-primary);
  border-color: var(--brand-primary);
  color: #fff;
  box-shadow: 0 6px 18px rgba(91, 53, 213, 0.28);
}

/* dark mode — cards & filters */
[data-theme="dark"] .filter-btn {
  background: var(--card-bg);
  color: var(--text-muted);
  border-color: var(--border-soft);
}
[data-theme="dark"] .filter-btn:hover {
  border-color: var(--brand-primary-light);
  color: var(--brand-primary-light);
}
[data-theme="dark"] .filter-btn.active {
  background: var(--brand-primary);
  border-color: var(--brand-primary);
  color: #fff;
}

/* ─────────────────────────────────────────────────────────
   5. Masonry Grid  (mobile-first → 1 → 2 → 3 cols)
   ───────────────────────────────────────────────────────── */
.gallery-grid {
  columns: 1;
  column-gap: 16px;
}

@media (min-width: 576px) {
  .gallery-grid {
    columns: 2;
    column-gap: 18px;
  }

  .filter-btn {
    font-size: 0.88rem;
    padding: 8px 22px;
  }
}

@media (min-width: 992px) {
  .gallery-grid {
    columns: 3;
  }

  .filter-bar {
    padding: 36px 0 28px;
    gap: 10px;
  }
}

/* ─────────────────────────────────────────────────────────
   6. Gallery Item Card
   ───────────────────────────────────────────────────────── */
.gallery-item {
  break-inside: avoid;
  margin-bottom: 16px;
  border-radius: var(--radius-md);
  overflow: hidden;
  position: relative;
  cursor: pointer;
  background: var(--card-bg);
  box-shadow: var(--shadow-sm);
  transition:
    box-shadow 0.35s var(--ease),
    transform 0.35s var(--ease),
    background-color 0.35s var(--ease);
}

@media (min-width: 992px) {
  .gallery-item {
    margin-bottom: 18px;
  }
}

.gallery-item:hover {
  transform: translateY(-6px);
  box-shadow: var(--shadow-lg);
}

/* touch devices: always show overlay */
@media (hover: none) {
  .gallery-item:active {
    transform: scale(0.98);
  }
}

.gallery-item img {
  width: 100%;
  height: auto;
  display: block;
  transition:
    transform 0.55s var(--ease),
    filter 0.35s var(--ease);
  filter: brightness(0.95);
}

/* dark mode: images slightly brighter to compensate dark UI */
[data-theme="dark"] .gallery-item img {
  filter: brightness(0.85);
}

.gallery-item:hover img {
  transform: scale(1.05);
  filter: brightness(0.65);
}

[data-theme="dark"] .gallery-item:hover img {
  filter: brightness(0.5);
}

/* Gradient overlay */
.gallery-item-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  padding: 20px 14px 16px;
  background: linear-gradient(0deg, rgba(18, 13, 40, 0.82) 0%, transparent 55%);
  opacity: 0;
  transition: opacity 0.35s var(--ease);
}

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

/* always show on touch */
@media (hover: none) {
  .gallery-item-overlay {
    opacity: 1;
    background: linear-gradient(
      0deg,
      rgba(18, 13, 40, 0.72) 0%,
      transparent 45%
    );
  }
  .gallery-zoom-icon {
    display: none;
  }
}

.gallery-item-overlay .item-tag {
  font-family: var(--font-display);
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--brand-orange);
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

.gallery-item-overlay h3 {
  font-size: 0.92rem;
  color: #fff;
  margin: 0;
  line-height: 1.4;
  text-align: center;
}

/* Zoom icon badge */
.gallery-zoom-icon {
  position: absolute;
  top: 12px;
  left: 12px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.18);
  backdrop-filter: blur(6px);
  color: #fff;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transform: scale(0.7);
  transition: all 0.3s var(--ease);
}

.gallery-item:hover .gallery-zoom-icon {
  opacity: 1;
  transform: scale(1);
}

/* ─────────────────────────────────────────────────────────
   7. Filter — hidden state & empty message
   ───────────────────────────────────────────────────────── */
.gallery-item.hidden {
  display: none;
}

.gallery-empty {
  display: none;
  text-align: center;
  padding: 56px 20px;
  color: var(--text-muted);
  transition: color 0.35s var(--ease);
}

.gallery-empty i {
  font-size: 3rem;
  opacity: 0.3;
  margin-bottom: 14px;
  display: block;
  color: var(--brand-primary);
}

.gallery-empty p {
  font-size: 1rem;
}

.gallery-empty.show {
  display: block;
}

/* ─────────────────────────────────────────────────────────
   8. Lightbox
   ───────────────────────────────────────────────────────── */
#lightbox {
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: rgba(8, 5, 20, 0.95);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  opacity: 0;
  visibility: hidden;
  transition:
    opacity 0.3s var(--ease),
    visibility 0.3s var(--ease);
}

#lightbox.open {
  opacity: 1;
  visibility: visible;
}

/* dark mode lightbox is already very dark — add subtle brand tint */
[data-theme="dark"] #lightbox {
  background: rgba(5, 3, 14, 0.97);
}

.lightbox-inner {
  position: relative;
  max-width: 940px;
  width: 100%;
  max-height: 90svh;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

#lbImage {
  max-width: 100%;
  max-height: 76svh;
  border-radius: var(--radius-md);
  object-fit: contain;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.65);
  transform: scale(0.92);
  transition: transform 0.35s var(--ease);
  display: block;
}

#lightbox.open #lbImage {
  transform: scale(1);
}

/* Caption */
.lightbox-caption {
  text-align: center;
  color: rgba(255, 255, 255, 0.78);
  font-family: var(--font-display);
  font-size: 0.9rem;
  padding: 0 40px;
}

.lightbox-caption .lb-tag {
  color: var(--brand-orange);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  display: block;
  margin-bottom: 3px;
}

/* Navigation arrows */
.lb-arrow {
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(8px);
  color: #fff;
  font-size: 1.15rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition:
    background 0.25s var(--ease),
    transform 0.25s var(--ease);
  z-index: 2001;
}

.lb-arrow:hover {
  background: var(--brand-primary);
  transform: translateY(-50%) scale(1.1);
}

.lb-arrow.prev {
  right: 12px;
}
.lb-arrow.next {
  left: 12px;
}

/* Close button */
.lb-close {
  position: fixed;
  top: 16px;
  left: 16px;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition:
    background 0.25s var(--ease),
    transform 0.25s var(--ease);
  z-index: 2002;
}

.lb-close:hover {
  background: var(--brand-coral);
  transform: scale(1.1);
}

/* Image counter */
.lb-counter {
  position: fixed;
  top: 22px;
  right: 20px;
  font-family: var(--font-display);
  font-size: 0.83rem;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.5);
  z-index: 2002;
  letter-spacing: 0.5px;
}

/* ── Lightbox responsive ─────────────────────────────── */
@media (min-width: 576px) {
  .lb-arrow {
    width: 50px;
    height: 50px;
    font-size: 1.3rem;
  }
  .lb-arrow.prev {
    right: 20px;
  }
  .lb-arrow.next {
    left: 20px;
  }
  .lb-close {
    top: 20px;
    left: 20px;
    width: 46px;
    height: 46px;
  }
}

@media (min-width: 992px) {
  .lb-arrow.prev {
    right: 28px;
  }
  .lb-arrow.next {
    left: 28px;
  }
  #lbImage {
    max-height: 80svh;
  }
}

/* ─────────────────────────────────────────────────────────
   9. Hero responsive extras
   ───────────────────────────────────────────────────────── */
@media (min-width: 576px) {
  .gallery-hero {
    padding: calc(var(--header-h, 84px) + 44px) 0 50px;
  }
}

@media (min-width: 992px) {
  .gallery-hero {
    padding: calc(var(--header-h, 84px) + 56px) 0 60px;
  }
}

/* ─────────────────────────────────────────────────────────
   10. Stats responsive extras
   ───────────────────────────────────────────────────────── */
@media (max-width: 575.98px) {
  .gallery-stats {
    padding: 20px 0;
  }
  .g-stat {
    border-bottom: 1px solid var(--border-soft);
    padding: 14px 0;
  }
  .g-stat:last-child {
    border-bottom: none;
  }
}
