/* ─────────────────────────────────────────────────────────────
   Галерея: ряды равной высоты.
   Ширина плитки пропорциональна кадру, поэтому строка заполняется
   целиком — ничего не обрезается и не остаётся дыр.
   ───────────────────────────────────────────────────────────── */

.gal-hero {
  padding: 180px 0 44px;   /* шапка сайта лежит поверх */
  text-align: center;
}
.gal-hero__title {
  font-family: var(--font-body);
  font-size: 60px;
  line-height: 60px;
  font-weight: 700;
  color: var(--ink);
}
.gal-hero__lead {
  max-width: 640px;
  margin: 20px auto 0;
  font-family: var(--font-body);
  font-size: 18px;
  line-height: 27px;
  font-weight: 300;
  color: var(--muted);
}
.gal-hero .acrumbs {
  justify-content: center;
  margin-top: 26px;
  font-size: 16px;
  line-height: 24px;
}
.gal-hero .acrumbs a { color: rgba(var(--brand-rgb), 0.82); }
.gal-hero .acrumbs a:hover { color: var(--brand); }

/* ── Сетка ──────────────────────────────────────────────────── */
.gal { padding-bottom: 110px; }

.gal__grid {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
}

/* Высоту строки задаёт --row, ширину — пропорции кадра.
   flex-grow добивает строку до края, flex-basis задаёт ей форму. */
.gal__grid { --row: 250px; }

.gal__item {
  position: relative;
  height: var(--row);
  flex-grow: calc(var(--ar) * 100);
  flex-basis: calc(var(--ar) * var(--row));
  overflow: hidden;
  background: var(--badge-bg);
  border-radius: 14px;
  cursor: zoom-in;
}
.gal__item img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.6s cubic-bezier(0.22, 0.61, 0.36, 1);
}
.gal__item::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(var(--ink-rgb), 0.18);
  opacity: 0;
  transition: opacity 0.3s ease;
}
.gal__item:hover img { transform: scale(1.05); }
.gal__item:hover::after { opacity: 1; }
.gal__item:focus-visible { outline: 2px solid var(--brand); outline-offset: 3px; }

/* Распорки съедают остаток последней строки, чтобы её плитки
   не растягивались во всю ширину. */
.gal__spacer {
  flex-grow: 99999;
  height: 0;
  min-width: 200px;
}

/* ── Просмотрщик ────────────────────────────────────────────── */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 24px;
  background: rgba(13, 20, 28, 0.94);
  opacity: 0;
  transition: opacity 0.25s ease;
}
.lightbox[hidden] { display: none; }
.lightbox.is-open { opacity: 1; }

.lightbox__figure {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  max-width: min(1240px, 100%);
}
.lightbox__img {
  max-width: 100%;
  max-height: calc(100vh - 140px);
  object-fit: contain;
  border-radius: var(--radius-sm);
  /* Смена кадра — короткое проявление, чтобы не мигало */
  animation: lightboxIn 0.28s ease both;
}
@keyframes lightboxIn {
  from { opacity: 0; transform: scale(0.985); }
  to   { opacity: 1; transform: none; }
}

.lightbox__caption {
  display: flex;
  align-items: center;
  gap: 14px;
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 22px;
  color: rgba(255, 255, 255, 0.72);
}
.lightbox__count { color: rgba(255, 255, 255, 0.42); }

.lightbox__nav,
.lightbox__close {
  display: grid;
  place-items: center;
  flex: none;
  width: 48px;
  height: 48px;
  color: var(--white);
  background: rgba(255, 255, 255, 0.1);
  border-radius: 50%;
  transition: background 0.2s, transform 0.2s;
}
.lightbox__nav svg { width: 18px; height: 18px; }
.lightbox__close svg { width: 16px; height: 16px; }
.lightbox__nav:hover,
.lightbox__close:hover { background: rgba(255, 255, 255, 0.22); }
.lightbox__nav:active { transform: scale(0.94); }

.lightbox__close {
  position: absolute;
  top: 20px;
  right: 24px;
}

/* ── Планшет ────────────────────────────────────────────────── */
@media (max-width: 1199px) {
  .gal-hero { padding: 46px 0 30px; }
  .gal-hero__title { font-size: 42px; line-height: 48px; }
  .gal-hero__lead { font-size: 16px; line-height: 25px; }

  .gal { padding-bottom: 70px; }
  .gal__grid { --row: 200px; gap: 12px; }
}

/* ── Телефон ────────────────────────────────────────────────── */
@media (max-width: 767px) {
  .gal-hero { padding: 32px 0 22px; }
  .gal-hero__title { font-size: 32px; line-height: 38px; }

  .gal { padding-bottom: 48px; }
  .gal__grid { --row: 150px; gap: 8px; }
  .gal__item { border-radius: 10px; }
  .gal__spacer { min-width: 120px; }

  /* Стрелки уводим вниз — на узком экране по бокам для них нет места */
  .lightbox { flex-wrap: wrap; padding: 16px; }
  .lightbox__figure { order: 1; width: 100%; }
  .lightbox__nav { order: 2; }
  .lightbox__img { max-height: calc(100vh - 210px); }
  .lightbox__close { top: 12px; right: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  .gal__item img,
  .lightbox,
  .lightbox__img { transition: none; animation: none; }
}

/* ── Узкий телефон ──────────────────────────────────────────────
   При строке в 150px в ряд влезает один кадр и страница растягивается
   на много экранов. Снижаем высоту строки — снимки идут по два. */
@media (max-width: 520px) {
  .gal__grid { --row: 114px; gap: 7px; }
  .gal__spacer { min-width: 90px; }
}
