/* ═══════════════════════════════════════════════════
   Тамада — Галерея с фильтрами
   v1.0.0
   ═══════════════════════════════════════════════════ */

:root {
  --tg-accent: #8B6B4A;
  --tg-accent-hover: #A07D58;
  --tg-text: #333;
  --tg-text-muted: #777;
  --tg-bg: transparent;
  --tg-border: rgba(0,0,0,0.1);
  --tg-border-hover: rgba(0,0,0,0.25);
  --tg-overlay-bg: rgba(0,0,0,0.6);
}

/* ── SECTION ── */
.tg-gallery {
  padding: 80px 24px;
  max-width: 1400px;
  margin: 0 auto;
  background: var(--tg-bg);
}

.tg-gallery__label {
  font-size: 12px;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--tg-accent);
  margin-bottom: 8px;
  font-weight: 600;
}

.tg-gallery__title {
  font-size: 32px;
  font-weight: 700;
  color: var(--tg-text);
  margin: 0 0 12px;
  line-height: 1.2;
}

.tg-gallery__subtitle {
  font-size: 16px;
  color: var(--tg-text-muted);
  margin-bottom: 8px;
  max-width: 600px;
  line-height: 1.6;
}

/* ── FILTERS ── */
.tg-gallery__filters {
  display: flex;
  gap: 8px;
  margin: 32px 0 40px;
  flex-wrap: wrap;
}

.tg-gallery__filter {
  background: transparent;
  border: 1px solid var(--tg-border);
  color: var(--tg-text-muted);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.5px;
  padding: 10px 24px;
  cursor: pointer;
  transition: all 0.3s ease;
  border-radius: 0;
  font-family: inherit;
  line-height: 1;
}

.tg-gallery__filter:hover {
  border-color: var(--tg-accent);
  color: var(--tg-accent);
}

.tg-gallery__filter.is-active {
  background: var(--tg-accent);
  border-color: var(--tg-accent);
  color: #fff;
}

/* ── MASONRY GRID ── */
.tg-gallery__masonry {
  column-gap: 16px;
}

.tg-cols-2 .tg-gallery__masonry { columns: 2; }
.tg-cols-3 .tg-gallery__masonry { columns: 3; }
.tg-cols-4 .tg-gallery__masonry { columns: 4; }

.tg-gallery__item {
  break-inside: avoid;
  margin-bottom: 16px;
  position: relative;
  overflow: hidden;
  cursor: pointer;
  border-radius: 4px;
  transition: opacity 0.4s ease, transform 0.4s ease;
}

.tg-gallery__item.is-hidden {
  opacity: 0;
  transform: scale(0.95);
  position: absolute;
  pointer-events: none;
  height: 0;
  margin: 0;
  overflow: hidden;
}

.tg-gallery__item-inner {
  display: block;
  overflow: hidden;
  background: #f0ebe5;
}

.tg-gallery__item-inner img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.6s ease;
}

.tg-gallery__item:hover .tg-gallery__item-inner img {
  transform: scale(1.05);
}

/* ── CAPTION OVERLAY ── */
.tg-gallery__overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(0,0,0,0.65) 0%, transparent 50%);
  display: flex;
  align-items: flex-end;
  padding: 20px;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.tg-gallery__item:hover .tg-gallery__overlay {
  opacity: 1;
}

.tg-gallery__overlay span {
  font-size: 14px;
  color: #fff;
  font-weight: 500;
  letter-spacing: 0.5px;
}

/* ── SCROLL ANIMATION ── */
.tg-animate {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.7s ease, transform 0.7s ease;
}

.tg-animate.is-visible {
  opacity: 1;
  transform: translateY(0);
}

/* Stagger children */
.tg-animate.is-visible .tg-animate { opacity: 1; transform: translateY(0); }
.tg-animate.is-visible .tg-gallery__item:nth-child(1) { transition-delay: 0.03s; }
.tg-animate.is-visible .tg-gallery__item:nth-child(2) { transition-delay: 0.06s; }
.tg-animate.is-visible .tg-gallery__item:nth-child(3) { transition-delay: 0.09s; }
.tg-animate.is-visible .tg-gallery__item:nth-child(4) { transition-delay: 0.12s; }
.tg-animate.is-visible .tg-gallery__item:nth-child(5) { transition-delay: 0.15s; }
.tg-animate.is-visible .tg-gallery__item:nth-child(6) { transition-delay: 0.18s; }
.tg-animate.is-visible .tg-gallery__item:nth-child(7) { transition-delay: 0.21s; }
.tg-animate.is-visible .tg-gallery__item:nth-child(8) { transition-delay: 0.24s; }
.tg-animate.is-visible .tg-gallery__item:nth-child(9) { transition-delay: 0.27s; }

/* ── LIGHTBOX ── */
.tg-lightbox {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 100000;
  background: rgba(0,0,0,0.92);
  align-items: center;
  justify-content: center;
  flex-direction: column;
}

.tg-lightbox.is-open {
  display: flex;
}

.tg-lightbox__content {
  max-width: 90vw;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.tg-lightbox__content img {
  max-width: 90vw;
  max-height: 80vh;
  object-fit: contain;
  border-radius: 2px;
}

.tg-lightbox__caption {
  color: #fff;
  font-size: 15px;
  margin-top: 16px;
  text-align: center;
  opacity: 0.85;
  font-weight: 400;
}

.tg-lightbox__close,
.tg-lightbox__prev,
.tg-lightbox__next {
  position: absolute;
  background: none;
  border: none;
  color: #fff;
  cursor: pointer;
  font-size: 36px;
  line-height: 1;
  padding: 16px;
  z-index: 10;
  opacity: 0.7;
  transition: opacity 0.3s;
}

.tg-lightbox__close:hover,
.tg-lightbox__prev:hover,
.tg-lightbox__next:hover {
  opacity: 1;
}

.tg-lightbox__close {
  top: 16px;
  right: 24px;
  font-size: 48px;
}

.tg-lightbox__prev {
  left: 24px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 56px;
}

.tg-lightbox__next {
  right: 24px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 56px;
}

/* ── RESPONSIVE ── */
@media (max-width: 1024px) {
  .tg-gallery { padding: 60px 20px; }
  .tg-gallery__title { font-size: 28px; }
  .tg-cols-4 .tg-gallery__masonry { columns: 3; }
}

@media (max-width: 768px) {
  .tg-gallery { padding: 48px 16px; }
  .tg-gallery__title { font-size: 24px; }
  .tg-cols-3 .tg-gallery__masonry,
  .tg-cols-4 .tg-gallery__masonry { columns: 2; }
  .tg-gallery__masonry { column-gap: 12px; }
  .tg-gallery__item { margin-bottom: 12px; }
  .tg-gallery__filters { gap: 6px; }
  .tg-gallery__filter { padding: 8px 16px; font-size: 12px; }
  .tg-lightbox__prev { left: 8px; }
  .tg-lightbox__next { right: 8px; }
}

@media (max-width: 480px) {
  .tg-cols-2 .tg-gallery__masonry,
  .tg-cols-3 .tg-gallery__masonry,
  .tg-cols-4 .tg-gallery__masonry { columns: 1; }
  .tg-gallery__filter { padding: 8px 14px; font-size: 11px; }
}
