/* ============================================================
   gallery.css — Masonry photo grid + lightbox overlay
   Depends on: variables.css, layout.css
   ============================================================ */

.gallery {
  padding: var(--section-padding);
  background-color: var(--color-surface);
}

/* ── Uniform grid ───────────────────────────────────────── */
.gallery__grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-3);
}

@media (min-width: 768px) {
  .gallery__grid {
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-4);
  }
}

/* 9-я карточка показывается только на десктопе (3×3 grid).
   На мобилке скрыта, чтобы сетка 2×4 оставалась ровной (8 картинок). */
@media (max-width: 767px) {
  .gallery__item--desktop-only {
    display: none;
  }
}

/* ── Gallery item ───────────────────────────────────────── */
.gallery__item {
  position: relative;
  border-radius: var(--radius-lg);
  overflow: hidden;
  cursor: pointer;
  background-color: var(--color-border);
  aspect-ratio: 4 / 3;          /* все ячейки одинаковой высоты */
}

.gallery__item img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  object-position: center;
  transition: transform 0.4s ease;
}

/* Hover overlay */
.gallery__item::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(15, 31, 61, 0);
  transition: background 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.gallery__item:hover::after {
  background: rgba(15, 31, 61, 0.4);
}

.gallery__item:hover img {
  transform: scale(1.04);
}

/* Zoom icon on hover */
.gallery__item__zoom {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.3s ease;
  z-index: 1;
  color: white;
}

.gallery__item__zoom svg {
  width: 36px;
  height: 36px;
  filter: drop-shadow(0 2px 8px rgba(0,0,0,0.4));
}

.gallery__item:hover .gallery__item__zoom {
  opacity: 1;
}

/* Caption */
.gallery__item__caption {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: var(--space-3) var(--space-4);
  background: linear-gradient(to top, rgba(15,31,61,0.8) 0%, transparent 100%);
  color: rgba(255,255,255,0.9);
  font-size: var(--text-caption);
  font-weight: var(--font-weight-semibold);
  transform: translateY(100%);
  transition: transform 0.3s ease;
}

.gallery__item:hover .gallery__item__caption {
  transform: translateY(0);
}

/* ── Lightbox overlay ───────────────────────────────────── */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  background-color: rgba(15, 31, 61, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  /* Shown/hidden via `hidden` attribute */
}

.lightbox[hidden] {
  display: none;
}

/* Close button */
.lightbox__close {
  position: absolute;
  top: var(--space-4);
  right: var(--space-4);
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-full);
  background: rgba(255,255,255,0.15);
  color: white;
  border: 1px solid rgba(255,255,255,0.2);
  transition: var(--transition-fast);
  z-index: 1;
}

.lightbox__close:hover {
  background: rgba(255,255,255,0.28);
}

.lightbox__close svg {
  width: 22px;
  height: 22px;
}

/* Image */
.lightbox__img {
  max-width: min(90vw, 1000px);
  max-height: 85vh;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lightbox);
  display: block;
}

/* Caption */
.lightbox__caption {
  position: absolute;
  bottom: var(--space-8);
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
  color: rgba(255,255,255,0.75);
  font-size: var(--text-caption);
  font-weight: var(--font-weight-semibold);
  white-space: nowrap;
}

/* Prev / Next buttons */
.lightbox__prev,
.lightbox__next {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-full);
  background: rgba(255,255,255,0.15);
  color: white;
  border: 1px solid rgba(255,255,255,0.2);
  transition: var(--transition-fast);
  z-index: 1;
}

.lightbox__prev { left: var(--space-4); }
.lightbox__next { right: var(--space-4); }

.lightbox__prev:hover,
.lightbox__next:hover {
  background: rgba(255,255,255,0.28);
}

.lightbox__prev svg,
.lightbox__next svg {
  width: 24px;
  height: 24px;
}

@media (max-width: 479px) {
  .lightbox__prev { left: var(--space-2); }
  .lightbox__next { right: var(--space-2); }
}

/* ── Telegram CTA ───────────────────────────────────────── */
.gallery__more {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-4);
  margin-top: var(--space-10);
  padding-top: var(--space-8);
  border-top: 1px solid var(--color-border);
  text-align: center;
}

.gallery__more-text {
  font-size: var(--text-body-m);
  color: var(--color-text-secondary);
  margin: 0;
}

.gallery__more-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
}

/* ── Telegram-канал кнопка под галереей ──────────────────── */
.gallery__telegram-wrap {
  text-align: center;
  margin-top: var(--space-8);
}

.gallery__telegram-link {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--color-primary);
  font-weight: 700;
  font-size: var(--text-body-m);
  text-decoration: none;
  border: 2px solid var(--color-primary);
  border-radius: var(--radius-full);
  padding: 10px 24px;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.gallery__telegram-link:hover {
  background-color: var(--color-primary);
  color: #fff;
}
