/* ========================================
   ZLATA LUXE - GALLERY STYLES (ALBUM VERSION)
   Альбомная галерея с превью
   ======================================== */

/* ========== GALLERY SECTION ========== */
.gallery-section {
  padding: 40px 20px 80px;
  position: relative;
  z-index: 5;
  background: transparent;
  min-height: 100vh;
}

/* ========== ЗАГОЛОВОК ГАЛЕРЕИ ========== */
.gallery-header {
  text-align: center;
  margin-bottom: 60px;
  position: relative;
  z-index: 10;
}

.gallery-header h1 {
  font-family: "Playfair Display", serif;
  font-size: clamp(32px, 5vw, 48px);
  background: var(--gold-grad);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 12px;
  animation: fadeInDown 0.8s ease-out;
}

@keyframes fadeInDown {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ========== КНОПКА "НАЗАД К АЛЬБОМАМ" ========== */
.back-to-albums {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 24px;
  margin-bottom: 32px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(143, 94, 37, 0.3);
  border-radius: 12px;
  color: var(--gold-mid);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  backdrop-filter: blur(10px);
  text-decoration: none;
}

.back-to-albums:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: var(--gold-mid);
  transform: translateX(-4px);
  box-shadow: var(--glow-gold);
}

.back-to-albums svg {
  width: 20px;
  height: 20px;
  transition: transform var(--transition);
}

.back-to-albums:hover svg {
  transform: translateX(-4px);
}

/* ========== КОНТЕЙНЕР АЛЬБОМОВ ========== */
#albumsContainer {
  max-width: 1400px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(3, 1fr); /* 4 альбома в ряд */
  gap: 24px;
  animation: fadeIn 0.6s ease-out;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* ========== КАРТОЧКА АЛЬБОМА ========== */
.album-card {
  position: relative;
  cursor: pointer;
  border-radius: 16px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.05);
  transition: all var(--transition);
  aspect-ratio: 16/12; /* Пропорции как у обложки книги */
  display: flex;
  flex-direction: column;
  animation: albumFadeIn 0.8s ease-out backwards;
}

/* Задержки появления альбомов */
.album-card:nth-child(1) {
  animation-delay: 0.1s;
}
.album-card:nth-child(2) {
  animation-delay: 0.2s;
}
.album-card:nth-child(3) {
  animation-delay: 0.3s;
}
.album-card:nth-child(4) {
  animation-delay: 0.4s;
}
.album-card:nth-child(5) {
  animation-delay: 0.5s;
}
.album-card:nth-child(6) {
  animation-delay: 0.6s;
}
.album-card:nth-child(7) {
  animation-delay: 0.7s;
}
.album-card:nth-child(8) {
  animation-delay: 0.8s;
}

@keyframes albumFadeIn {
  from {
    opacity: 0;
    transform: translateY(30px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Превью-изображение альбома */
.album-cover {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform var(--transition-slow);
}

.album-card:hover .album-cover {
  transform: scale(1.08);
}

/* Оверлей с градиентом */
.album-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    180deg,
    transparent 0%,
    rgba(0, 0, 0, 0.3) 40%,
    rgba(0, 0, 0, 0.85) 100%
  );
  transition: opacity var(--transition);
}

.album-card:hover .album-overlay {
  background: linear-gradient(
    180deg,
    rgba(0, 0, 0, 0.1) 0%,
    rgba(0, 0, 0, 0.5) 40%,
    rgba(0, 0, 0, 0.92) 100%
  );
}

/* Информация об альбоме */
.album-info {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 20px;
  z-index: 2;
  transform: translateY(0);
  transition: transform var(--transition);
}

.album-card:hover .album-info {
  transform: translateY(-8px);
}

.album-title {
  font-family: "Playfair Display", serif;
  font-size: clamp(18px, 2.5vw, 24px);
  font-weight: 700;
  background: var(--gold-grad);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 6px;
  line-height: 1.3;
}

/* Бейдж с количеством фото */
.album-badge {
  position: absolute;
  top: 16px;
  right: 16px;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(251, 244, 161, 0.3);
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  color: var(--gold-mid);
  z-index: 3;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
  transition: all var(--transition);
}

.album-card:hover .album-badge {
  transform: scale(1.1);
  box-shadow: 0 0 20px rgba(251, 244, 161, 0.4);
}

/* Рамка при ховере */
.album-card:hover {
  transform: translateY(-8px);
  border-color: rgba(143, 94, 37, 0.8);
  box-shadow: var(--premium-shadow), var(--glow-gold);
}

/* Эффект "шиммер" при ховере */
.album-card::before {
  content: "";
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(251, 244, 161, 0.15),
    transparent
  );
  transform: rotate(45deg);
  transition: opacity var(--transition);
  opacity: 0;
  z-index: 1;
  pointer-events: none;
  animation: shimmer 3s infinite;
}

@keyframes shimmer {
  0% {
    transform: translateX(-100%) rotate(45deg);
  }
  100% {
    transform: translateX(100%) rotate(45deg);
  }
}

.album-card:hover::before {
  opacity: 1;
}

/* ========== LOADING SPINNER ========== */
.gallery-loading {
  text-align: center;
  padding: 60px 20px;
  color: var(--gray);
}

.loading-spinner {
  width: 50px;
  height: 50px;
  margin: 0 auto 20px;
  border: 4px solid rgba(255, 255, 255, 0.1);
  border-top-color: var(--gold-mid);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ========== КОНТЕЙНЕР ФОТОГАЛЕРЕИ (внутри альбома) ========== */
#galleryContainer {
  max-width: 1400px;
  margin: 0 auto;
  animation: slideUp 0.6s ease-out;
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(40px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Заголовок текущего альбома */
.current-album-title {
  font-family: "Playfair Display", serif;
  font-size: clamp(28px, 4vw, 42px);
  background: var(--gold-grad);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 32px;
  text-align: center;
}

/* ========== GRID ФОТОГРАФИЙ (4 колонки masonry) ========== */
.gallery-grid {
  column-count: 4;
  column-gap: 16px;
  max-width: 1400px;
  margin: 0 auto;
}

.gallery-item {
  break-inside: avoid;
  margin-bottom: 16px;
  position: relative;
  overflow: hidden;
  border-radius: 12px;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.05);
  transition: all var(--transition);
  opacity: 0;
  animation: fadeIn 0.6s ease-out forwards;

  /* ИСПРАВЛЕНИЕ #1 и #2: Ограничение размера и квадратные превью */
  max-width: 100%;
  max-height: 500px; /* Или сколько нужно */
  aspect-ratio: 1;
}

.gallery-item img {
  width: 100%;
  height: 100%;
  object-fit: cover; /* ИСПРАВЛЕНИЕ #2: Делаем все фото квадратными */
  aspect-ratio: 1; /* ИСПРАВЛЕНИЕ #2: Квадратное соотношение сторон */
  display: block;
  transition: transform var(--transition-slow);
}

/* Stagger delays для фото */
.gallery-item:nth-child(1) {
  animation-delay: 0.05s;
}
.gallery-item:nth-child(2) {
  animation-delay: 0.1s;
}
.gallery-item:nth-child(3) {
  animation-delay: 0.15s;
}
.gallery-item:nth-child(4) {
  animation-delay: 0.2s;
}
.gallery-item:nth-child(5) {
  animation-delay: 0.25s;
}
.gallery-item:nth-child(6) {
  animation-delay: 0.3s;
}
.gallery-item:nth-child(7) {
  animation-delay: 0.35s;
}
.gallery-item:nth-child(8) {
  animation-delay: 0.4s;
}

.gallery-item:hover {
  border-color: rgba(143, 94, 37, 0.8);
  box-shadow: var(--premium-shadow), var(--glow-gold);
  transform: translateY(-4px);
}

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

/* Overlay при hover */
.gallery-item::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent 50%, rgba(0, 0, 0, 0.7) 100%);
  opacity: 0;
  transition: opacity var(--transition);
  pointer-events: none;
}

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

/* ========== ЛЕТАЮЩИЕ ЧАСТИЦЫ НА ФОНЕ ГАЛЕРЕИ ========== */
.gallery-particles-bg {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  opacity: 0.35;
  z-index: 1;
}

.gallery-particles-bg .particle {
  position: absolute;
  background: rgba(251, 244, 161, 0.7);
  border-radius: 50%;
  animation: float 25s infinite ease-in-out;
}

@keyframes float {
  0%,
  100% {
    transform: translate(0, 0) scale(1);
    opacity: 0.5;
  }
  25% {
    transform: translate(30px, -40px) scale(1.4);
    opacity: 0.9;
  }
  50% {
    transform: translate(-30px, -80px) scale(0.9);
    opacity: 0.6;
  }
  75% {
    transform: translate(40px, -50px) scale(1.3);
    opacity: 1;
  }
}

/* ИСПРАВЛЕНИЕ #5: Частицы не залезают на фото */
.gallery-section {
  position: relative;
  z-index: 2;
}

#albumsContainer,
#galleryContainer {
  position: relative;
  z-index: 3;
}

/* ========== LIGHTBOX ========== */
.gallery-lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.95);
  backdrop-filter: blur(10px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  opacity: 0;
  transition: opacity var(--transition);
}

.gallery-lightbox.open {
  display: flex;
  opacity: 1;
}

.gallery-lightbox img {
  max-width: 90%;
  max-height: 85vh;
  object-fit: contain;
  border-radius: 8px;
  box-shadow: var(--premium-shadow);
  animation: lightboxZoom 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes lightboxZoom {
  from {
    transform: scale(0.85);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

/* Кнопка закрытия lightbox */
.lightbox-close {
  position: absolute;
  top: 20px;
  right: 20px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 2px solid rgba(251, 244, 161, 0.3);
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(10px);
  color: var(--gold-mid);
  cursor: pointer;
  transition: all var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10001;
}

.lightbox-close:hover {
  background: rgba(0, 0, 0, 0.95);
  transform: rotate(90deg) scale(1.1);
  box-shadow: 0 0 20px rgba(251, 244, 161, 0.4);
  border-color: var(--gold-mid);
}

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

/* Навигация в lightbox */
.lightbox-nav {
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  transform: translateY(-50%);
  display: flex;
  justify-content: space-between;
  padding: 0 30px;
  pointer-events: none;
}

.lightbox-prev,
.lightbox-next {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  border: 2px solid rgba(251, 244, 161, 0.3);
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(10px);
  color: var(--gold-mid);
  cursor: pointer;
  transition: all var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: all;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

.lightbox-prev:hover:not(:disabled),
.lightbox-next:hover:not(:disabled) {
  background: rgba(0, 0, 0, 0.95);
  transform: scale(1.2);
  box-shadow: 0 0 30px rgba(251, 244, 161, 0.6);
  border-color: var(--gold-mid);
}

.lightbox-prev:disabled,
.lightbox-next:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.lightbox-prev svg,
.lightbox-next svg {
  width: 40px;
  height: 40px;
  stroke-width: 3;
}

/* RTL: правильное направление стрелок */
[dir="rtl"] .lightbox-prev svg {
  transform: rotate(180deg);
}

[dir="rtl"] .lightbox-next svg {
  transform: rotate(180deg);
}

/* Счетчик фото в lightbox */
.lightbox-counter {
  position: absolute;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%);
  padding: 10px 20px;
  border-radius: 24px;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(251, 244, 161, 0.2);
  color: var(--gray);
  font-size: 15px;
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.6);
}

/* ========== КНОПКА "ЗАГРУЗИТЬ ЕЩЕ" ========== */
.load-more-wrapper {
  text-align: center;
  margin-top: 48px;
  padding: 20px;
  display: none;
}

.load-more-btn {
  min-width: 220px;
  padding: 14px 32px;
  font-size: 16px;
  font-weight: 600;
}

/* ========== NO IMAGES ========== */
.no-images {
  text-align: center;
  padding: 80px 20px;
  color: var(--gray);
  font-size: 18px;
  opacity: 0.7;
  display: none;
}

/* ========== КНОПКА "НАВЕРХ" ========== */
.scroll-to-top {
  position: fixed;
  bottom: 30px;
  right: 30px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(10px);
  border: 2px solid rgba(251, 244, 161, 0.3);
  color: var(--gold-mid);
  cursor: pointer;
  transition: all var(--transition);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

.scroll-to-top.visible {
  display: flex;
}

.scroll-to-top:hover {
  background: rgba(0, 0, 0, 0.95);
  transform: translateY(-4px) scale(1.1);
  box-shadow: 0 0 30px rgba(251, 244, 161, 0.6);
  border-color: var(--gold-mid);
}

.scroll-to-top svg {
  width: 24px;
  height: 24px;
}

/* ========== LOADING MORE INDICATOR ========== */
.loading-more {
  text-align: center;
  padding: 40px 20px;
  color: var(--gray);
  opacity: 0;
  transition: opacity var(--transition);
}

.loading-more.visible {
  opacity: 1;
}

.loading-more .loading-spinner {
  width: 40px;
  height: 40px;
  margin: 0 auto 16px;
}

/* ========== RESPONSIVE ========== */

/* Планшеты (3 альбома в ряд) */
@media (max-width: 1200px) {
  #albumsContainer {
    grid-template-columns: repeat(3, 1fr);
  }

  .gallery-grid {
    column-count: 3;
  }
}

/* Средние экраны (2 альбома в ряд) */
@media (max-width: 900px) {
  #albumsContainer {
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
  }

  .gallery-grid {
    column-count: 2;
    column-gap: 12px;
  }

  .gallery-item {
    margin-bottom: 12px;
  }

  .lightbox-nav {
    padding: 0 10px;
  }

  .lightbox-prev,
  .lightbox-next {
    width: 64px;
    height: 64px;
  }

  .lightbox-prev svg,
  .lightbox-next svg {
    width: 32px;
    height: 32px;
  }
}

/* Мобильные (1 альбом в ряд) */
@media (max-width: 600px) {
  #albumsContainer {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .gallery-grid {
    column-count: 2; /* ИСПРАВЛЕНИЕ: 2 фото в ширину на мобильных */
  }

  .album-card {
    aspect-ratio: 4/3; /* На мобильных делаем более широкими */
  }

  .gallery-header h1 {
    font-size: 28px;
  }

  .current-album-title {
    font-size: 24px;
  }

  .back-to-albums {
    font-size: 14px;
    padding: 10px 18px;
  }

  .scroll-to-top {
    bottom: 20px;
    right: 20px;
    width: 48px;
    height: 48px;
  }

  .scroll-to-top svg {
    width: 20px;
    height: 20px;
  }
}

/* Очень маленькие экраны */
@media (max-width: 400px) {
  .gallery-grid {
    column-count: 2; /* ИСПРАВЛЕНИЕ: Оставляем 2 даже на малых экранах */
    column-gap: 10px;
  }

  .gallery-item {
    margin-bottom: 10px;
  }

  .album-badge {
    font-size: 11px;
    padding: 4px 10px;
  }
}
