/* gallery-style.css - СТИЛИ ТОЛЬКО ДЛЯ ГАЛЕРЕИ */

/* Секция галереи */
.gallery-section {
  padding: 60px 20px;
  background-color: #000;
  width: 100%;
  overflow: hidden;
  position: relative;
  z-index: 3;
}

.gallery-section .container {
  max-width: 100%;
  margin: 0 auto;
  width: 100%;
}

.gallery-section h3 {
  font-size: 2.2rem;
  text-align: center;
  margin-bottom: 40px;
  width: 100%;
  color: #fff;
}

/* СЕТКА ГАЛЕРЕИ - МОЗАИКА ВСЕГДА */
.gallery-grid {
  display: grid;
  grid-template-areas:
    "a a b"
    "c d d"
    "c e f";
  gap: 15px;
  width: 100%;
  max-width: 100%;
  margin: 0;
}

.gallery-grid img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.5);
  cursor: pointer;
  transition: transform 0.3s ease;
  backface-visibility: hidden;
  image-rendering: -webkit-optimize-contrast;
  min-height: 200px; /* Базовая минимальная высота */
}

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

/* Позиционирование элементов мозаики */
.gallery-grid > :nth-child(1) { grid-area: a; }
.gallery-grid > :nth-child(2) { grid-area: b; }
.gallery-grid > :nth-child(3) { grid-area: c; }
.gallery-grid > :nth-child(4) { grid-area: d; }
.gallery-grid > :nth-child(5) { grid-area: e; }
.gallery-grid > :nth-child(6) { grid-area: f; }

/* ===========================================
   МОДАЛЬНОЕ ОКНО ГАЛЕРЕИ
   =========================================== */
.gallery-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.95);
  z-index: 9999;
  overflow: hidden;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.gallery-modal.active {
  display: flex;
  opacity: 1;
}

.modal-content {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
}

.modal-image-wrapper {
  position: relative;
  max-width: 90%;
  max-height: 90%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-image-wrapper img {
  max-width: 100%;
  max-height: 80vh;
  object-fit: contain;
  border-radius: 4px;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

/* Кнопки навигации */
.modal-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 60px;
  height: 60px;
  background-color: rgba(255, 255, 255, 0.1);
  border: none;
  border-radius: 50%;
  color: white;
  font-size: 24px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.3s ease;
  z-index: 100;
}

.modal-nav:hover {
  background-color: rgba(255, 255, 255, 0.2);
}

.modal-nav.prev {
  left: 20px;
}

.modal-nav.next {
  right: 20px;
}

/* Закрытие модального окна */
.modal-close {
  position: fixed;
  top: 20px;
  right: 20px;
  width: 40px;
  height: 40px;
  background-color: rgba(255, 255, 255, 0.1);
  border: none;
  border-radius: 50%;
  color: white;
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.3s ease;
  z-index: 10000;
}

.modal-close:hover {
  background-color: rgba(255, 255, 255, 0.2);
}

/* Индикатор текущего фото */
.photo-counter {
  position: fixed;
  bottom: 30px;
  left: 0;
  right: 0;
  text-align: center;
  color: white;
  font-size: 18px;
  z-index: 10000;
  padding: 10px;
  background-color: rgba(0, 0, 0, 0.5);
  border-radius: 20px;
  margin: 0 auto;
  width: fit-content;
  min-width: 120px;
}

/* Лоадер */
.loader {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 50px;
  height: 50px;
  border: 3px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  display: none;
}

@keyframes spin {
  to { transform: translate(-50%, -50%) rotate(360deg); }
}

/* ===========================================
   АДАПТИВНОСТЬ ГАЛЕРЕИ
   =========================================== */

/* Планшеты (до 1024px) */
@media (max-width: 1024px) {
  .gallery-grid {
    gap: 12px;
  }
  
  .gallery-grid img {
    min-height: 180px;
  }
  
  .modal-nav {
    width: 50px;
    height: 50px;
    font-size: 20px;
  }
  
  .modal-nav.prev {
    left: 10px;
  }
  
  .modal-nav.next {
    right: 10px;
  }
}

/* Мобильные (до 768px) */
@media (max-width: 768px) {
  .gallery-section {
    padding: 40px 15px;
  }
  
  .gallery-section h3 {
    font-size: 1.8rem;
    margin-bottom: 30px;
  }
  
  .gallery-grid {
    gap: 10px;
  }
  
  .gallery-grid img {
    min-height: 150px;
  }
  
  .modal-content {
    padding: 20px;
  }
  
  .modal-image-wrapper {
    max-width: 95%;
  }
  
  .modal-nav {
    width: 40px;
    height: 40px;
    font-size: 18px;
    position: fixed;
  }
  
  .modal-close {
    width: 35px;
    height: 35px;
    font-size: 18px;
  }
}

/* Мелкие мобильные (до 480px) */
@media (max-width: 480px) {
  .gallery-section {
    padding: 30px 10px;
  }
  
  .gallery-section h3 {
    font-size: 1.6rem;
    margin-bottom: 25px;
  }
  
  .gallery-grid {
    gap: 8px;
  }
  
  .gallery-grid img {
    min-height: 120px;
  }
  
  .modal-nav {
    width: 35px;
    height: 35px;
    font-size: 16px;
  }
  
  .modal-close {
    top: 10px;
    right: 10px;
  }
  
  .photo-counter {
    bottom: 20px;
    font-size: 16px;
  }
}

/* Оптимизация для touch-устройств */
@media (hover: none) and (pointer: coarse) {
  .gallery-grid img:hover {
    transform: none;
  }
  
  .modal-nav:active,
  .modal-close:active {
    background-color: rgba(255, 255, 255, 0.3);
  }
}