/* Галерея фото и просмотр */

/* Детальная страница изделия — */
/* 50 + 2 = 52 до «Галереи» */
/* 58 от заголовка «Галерея» до плиток */
.inner--product .inner__title + .gallery { margin-top: .5rem; }

/* Галерея */
/* Четыре в ряд по 455 при зазоре 20, высота строки 305 — вся сетка 630 */
.gallery {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  grid-auto-rows: 19.0625rem;
  gap: 1.25rem;
  padding: 0 3.75rem;
}
.gallery__item {
  overflow: hidden;
  border: 1px solid var(--orange);
  border-radius: var(--radius);
  background: #e0e8f2;
}
.gallery__item img { width: 100%; height: 100%; object-fit: cover; }

/* Просмотр фотографий галереи */
.gallery__btn {
  display: block;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
}
.gallery__btn img { transition: transform .3s ease; }
.gallery__btn:hover img,
.gallery__btn:focus-visible img { transform: scale(1.04); }
.gallery__btn:focus-visible { outline: 2px solid var(--orange); outline-offset: -2px; }
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  overflow-y: auto;
}
/* display: flex выше перебивает браузерное [hidden] { display: none } */
.lightbox[hidden] { display: none; }
.lightbox__backdrop { position: fixed; inset: 0; background-color: rgba(10, 18, 38, .9); }
.lightbox__panel {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 2.5rem;                     /* 40 между шапкой, кадром и лентой */
  width: 52.5rem;                  /* 840 */
  max-width: 100%;
  margin: auto 0;
}

/* Шапка: счётчик слева, крестик справа */
.lightbox__head { display: flex; align-items: center; gap: 1.25rem; height: 3.125rem; }
.lightbox__counter {
  flex: 1 1 auto;
  font-size: 1rem;                 /* 16/1.3 */
  line-height: 1.3;
  color: rgba(255, 255, 255, .5);
}
.lightbox__close {
  flex: none;
  width: 3.125rem;                 /* 50 */
  height: 3.125rem;
  padding: 0;
  border: 0;
  background: none;
  color: rgba(253, 255, 254, .5);  /* в макете крестик белый на 50 % */
  cursor: pointer;
  transition: color .2s ease;
}
/* при наведении — оранжевый, как рамка полей формы */
.lightbox__close:hover,
.lightbox__close:focus-visible { color: var(--orange); }
.lightbox__close svg { display: block; width: 100%; height: 100%; }

/* КадÑ */
.lightbox__stage {
  position: relative;
  width: 100%;
  aspect-ratio: 1450 / 966;
  border-radius: var(--radius);
  overflow: hidden;
  background-color: rgba(255, 255, 255, .06);
}
.lightbox__photo { display: block; width: 100%; height: 100%; object-fit: cover; }
.lightbox__arrow {
  position: absolute;
  top: 50%;
  width: 3rem;                     /* 48 */
  height: 3rem;
  margin-top: -1.5rem;
  padding: 0;
  border: 0;
  background: transparent no-repeat center / 100% 100%;
  cursor: pointer;
  transition: transform .15s ease, filter .2s ease;
}
.lightbox__arrow--prev { left: 2.5rem; background-image: url('../../../img/arrow-left.svg'); }
.lightbox__arrow--next { right: 2.5rem; background-image: url('../../../img/arrow-right.svg'); }
.lightbox__arrow:hover,
.lightbox__arrow:focus-visible { transform: scale(1.08); filter: drop-shadow(0 0 .5rem rgba(231, 124, 28, .55)); }
.lightbox__arrow:active { transform: scale(1); }

/* Лента миниатюÑ */
.lightbox__thumbs {
  display: flex;
  gap: 1.25rem;
  overflow-x: auto;
  scrollbar-width: none;
}
.lightbox__thumbs::-webkit-scrollbar { display: none; }
.lightbox__thumb {
  position: relative;
  flex: none;
  width: calc((100% - 6.25rem) / 6);   /* шесть миниатюр и пять зазоров по 20 */
  aspect-ratio: 540 / 304;
  padding: 0;
  border: 0;
  border-radius: var(--radius);
  background: none;
  cursor: pointer;
  overflow: hidden;
}
/* снимок занимает миниатюру целиком — и у неактивных, и у активной, как в макете */
.lightbox__thumb img { display: block; width: 100%; height: 100%; object-fit: cover; border-radius: var(--radius); }
.lightbox__thumb::after {
  content: '';
  position: absolute;
  inset: 0;
  border: 2px solid transparent;
  border-radius: inherit;
  background-color: rgba(10, 18, 38, .5);
  transition: background-color .2s ease, border-color .2s ease;
}
.lightbox__thumb:hover::after,
.lightbox__thumb:focus-visible::after { background-color: rgba(10, 18, 38, .1); }
.lightbox__thumb.is-active::after { border-color: var(--orange); background-color: transparent; }

/* Планшет */
@media (max-width: 1279px) {
  .lightbox__panel { gap: 1.5rem; }
  .lightbox__head { height: 2.5rem; }
  .lightbox__close { width: 2.5rem; height: 2.5rem; }
  .lightbox__arrow { width: 2.5rem; height: 2.5rem; margin-top: -1.25rem; }
  .lightbox__arrow--prev { left: 1.25rem; }
  .lightbox__arrow--next { right: 1.25rem; }
}

/* Мобильная */
@media (max-width: 767px) {
  .lightbox { padding: 20px; }
  .lightbox__panel { gap: 40px; }
  .lightbox__head { height: 50px; gap: 20px; }
  .lightbox__counter { font-size: 16px; }
  .lightbox__close { width: 50px; height: 50px; }
  .lightbox__arrow { width: 48px; height: 48px; margin-top: -24px; }
  .lightbox__arrow--prev { left: 20px; }
  .lightbox__arrow--next { right: 20px; }
  /* в мобильном макете четыре миниатюры по 45 в высоту и зазор 10 */
  .lightbox__thumbs { gap: 10px; }
  .lightbox__thumb { width: calc((100% - 30px) / 4); height: 45px; aspect-ratio: auto; }
}

/* Планшет: своего макета нет, сделан в логике */
@media (max-width: 1279px) {
  .inner--product .inner__title + .gallery { margin-top: 0; }
  /* восемь фотографий в две колонки дают слишком крупные плитки — берём три */
  .gallery { grid-template-columns: repeat(3, minmax(0, 1fr)); grid-auto-rows: 12rem; gap: 1rem; padding: 0 1rem; }
}

/* Мобильный */
@media (max-width: 767px) {
  /* Галерея — 2 × 4, зазор 10, строка 112: вся сетка 478, как в макете */
  .gallery { grid-template-columns: 1fr 1fr; grid-auto-rows: 112px; gap: 10px; padding: 0 20px; }
}

/* «ЦПОИ «Самара» / Заказ снимков» (cpoi-samara.html) */
@media (min-width: 1280px) {
  /* −3,1 */
  .inner--cpoi .inner__title + .gallery { margin-top: .27rem; }
}

/* Страница «Музей АО «РКЦ «Прогресс»» (museum.html) */
.gallery__item--empty { border-style: dashed; background-color: transparent; }
.gallery__note {
  padding: 0 3.75rem;
  font-size: 1.25rem;
  line-height: 1.3;
  color: #0a1226;
  opacity: .7;
}

/* Планшет (< 1280) */
@media (max-width: 1279px) {
  .gallery__note { padding: 0 1rem; font-size: 1rem; }
}

/* Мобильная (< 768) */
@media (max-width: 767px) {
  .gallery__note { padding: 0 20px; font-size: 14px; }
}

/* Страница альбома (photo-album.html, макет 392-3202 / */
/* 24 */
/* Сетка альбома: четыре колонки, зазор 20, снимки 540 × 304 без рамки */
.gallery--album { grid-auto-rows: auto; }
.gallery--album .gallery__item { aspect-ratio: 540 / 304; border: 0; }
.gallery--album .gallery__btn { position: relative; }
.gallery__hover {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1.875rem;
  background: rgba(10, 18, 38, .5);
  color: #fff;
  text-align: left;
  opacity: 0;
  transition: opacity .2s ease;
  pointer-events: none;
}
.gallery__btn:hover .gallery__hover,
.gallery__btn:focus-visible .gallery__hover { opacity: 1; }
.gallery__hover-text {
  display: -webkit-box;
  align-self: stretch;
  overflow: hidden;
  font-size: 1.25rem;
  line-height: 1.3;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  line-clamp: 3;
}
.lightbox__desc { font-size: 1.25rem; line-height: 1.3; color: rgba(255, 255, 255, .5); }
.lightbox__desc[hidden] { display: none; }
/* заголовок снимка в многострочной подписи («Галерея снимков») */
.lightbox__desc-title { color: #fff; font-weight: 600; }

/* Планшет (< 1280) */
@media (max-width: 1279px) {
  .gallery__hover { padding: 1.25rem; }
  .gallery__hover-text { font-size: 1rem; }
  .lightbox__desc { font-size: 1rem; }
}

/* Мобильная (< 768, макет 591-7974): поля 20, дата и */
@media (max-width: 767px) {
  .gallery--album .gallery__item { aspect-ratio: auto; height: 100px; }
  /* на телефоне наведения нет — затемнение не показываем */
  .gallery__hover { display: none; }
  .lightbox__desc { font-size: 14px; }
}

/* Страница «Видеогалерея» (video-gallery.html): плитки роликов и плеер в просмотрщике */
/* Оранжевый «play» по центру плитки, над затемнением */
.gallery__play {
  position: absolute;
  z-index: 1;
  top: 50%;
  left: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 4rem;                     /* 64 */
  height: 4rem;
  border-radius: 50%;
  background: var(--orange);
  transform: translate(-50%, -50%);
  transition: transform .2s;
  pointer-events: none;
}
.gallery__play svg { display: block; width: 1.5rem; height: 1.5rem; margin-left: .1875rem; }
.gallery__btn:hover .gallery__play,
.gallery__btn:focus-visible .gallery__play { transform: translate(-50%, -50%) scale(1.06); }
/* Кадр с плеером: высота по плееру (сцена 16 : 9 и панель) */
.lightbox__stage--video { aspect-ratio: auto; background-color: #050a1b; }
.lightbox .lightbox__player { margin: 0; border-radius: 0; }
/* Одна плитка: счётчик, стрелки и миниатюры не нужны */
.lightbox--single .lightbox__counter { visibility: hidden; }
.lightbox--single .lightbox__arrow,
.lightbox--single .lightbox__thumbs { display: none; }

/* Мобильная (< 768) */
@media (max-width: 767px) {
  .gallery__play { width: 40px; height: 40px; }
  .gallery__play svg { width: 18px; height: 18px; margin-left: 2px; }
}
