/* ==========================================================================
   Галереи проектов, автопрокрутка баннеров и увеличенный просмотр.
   Каркас страницы и типографика — responsive.css.
   ========================================================================== */

/* --- Запасной вид без скриптов: активные изображения списком --------------- */

.project-gallery {
  /* Одна высота для всех проектов; короткие экраны ограничиваются ниже. */
  --gallery-height: clamp(260px, 50vw, 560px);
  margin-block: clamp(16px, 1.6vw, 26px);
}

.project-gallery figure { margin: 0; }

/* Браузерное выделение не должно окрашивать фотографии глобальным ::selection. */
.gallery-open,
.project-gallery img,
.viewer-stage img {
  -webkit-user-select: none;
  user-select: none;
}
.project-gallery img,
.viewer-stage img { -webkit-user-drag: none; }
.project-gallery img::selection,
.viewer-stage img::selection { background: transparent; }

.project-gallery:not([data-gallery-ready="true"]) img {
  width: 100%;
  height: min(var(--gallery-height), 65vh);
  height: min(var(--gallery-height), 65svh);
  object-fit: contain;
  background: #fff;
  border: 1px solid var(--border, #e6e5e3);
  border-radius: 8px;
}
.project-gallery:not([data-gallery-ready="true"]) figcaption {
  margin-top: 6px;
  font-size: 0.84rem;
  color: var(--muted, #66635f);
  text-align: left;
}
.project-gallery:not([data-gallery-ready="true"]) figure + figure { margin-top: 18px; }
/* Слайды без src (data-src) до переключения не должны занимать место. */
.project-gallery:not([data-gallery-ready="true"]) figure:has(img:not([src])) { display: none; }

/* --- Рамка галереи --------------------------------------------------------- */

.gallery-frame {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) 48px;
  grid-template-rows: minmax(0, 1fr);
  height: min(var(--gallery-height), 65vh);
  height: min(var(--gallery-height), 65svh);
  min-height: 0;
  background: #383a3c;
  border-radius: 8px;
}

.gallery-open {
  display: block;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  padding: 0;
  border: 0;
  background: #fff;
  cursor: zoom-in;
}

.case .gallery-open img {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 0;
  max-height: 100%;
  aspect-ratio: auto;
  object-fit: contain;
  object-position: center;
  margin: 0;
  border: 0;
  border-radius: 0;
}

.gallery-arrow {
  display: grid;
  place-items: center;
  min-width: 44px;
  min-height: 48px;
  padding: 0;
  border: 0;
  background: transparent;
  color: #fff;
  cursor: pointer;
}
.gallery-arrow--prev { border-radius: 8px 0 0 8px; }
.gallery-arrow--next { border-radius: 0 8px 8px 0; }

/* Стрелки по умолчанию малозаметны (30%), при наведении и фокусе — полностью. */
.gallery-arrow svg { width: 22px; height: 22px; opacity: 0.3; transition: opacity 0.2s ease; }
.gallery-arrow:hover svg,
.gallery-arrow:focus-visible svg,
.gallery-arrow:active svg { opacity: 1; }
.gallery-arrow:disabled { visibility: hidden; cursor: default; }

/* Обводка фокуса внутри кнопки: её нигде не обрезает. */
.gallery-arrow:focus-visible,
.gallery-open:focus-visible {
  outline: 3px solid var(--accent, #2783de);
  outline-offset: -3px;
}

.gallery-info {
  display: flex;
  align-items: center;
  min-height: 44px;
  gap: 10px 16px;
  margin-top: 10px;
  font-size: 0.85rem;
  color: var(--muted, #66635f);
  text-align: left;
}

.gallery-status {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  flex: 1 1 auto;
  min-width: 0;
}

.gallery-caption { min-width: 0; }
.gallery-count { white-space: nowrap; font-variant-numeric: tabular-nums; }

/* --- Автопрокрутка баннеров ----------------------------------------------- */

.banner-gallery .gallery-open { position: relative; overflow: hidden; }
.case .banner-gallery .gallery-open .banner-outgoing { position: absolute; inset: 0; height: 100%; }

.banner-pause {
  flex: none;
  min-height: 40px;
  padding: 6px 14px;
  border: 1px solid var(--border, #e6e5e3);
  border-radius: 6px;
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: 0.84rem;
  cursor: pointer;
}
.banner-pause:hover { border-color: var(--accent, #2783de); }

/* --- Увеличенный просмотр -------------------------------------------------- */

.image-viewer {
  padding: 16px;
  border: 0;
  margin: auto;
  width: 100vw;
  height: 100dvh;
  max-width: 100vw;
  max-height: 100dvh;
  background: #202224;
  color: #fff;
}
.image-viewer::backdrop { background: rgba(0, 0, 0, 0.9); }
.image-viewer[open] {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 12px;
}

.viewer-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.viewer-title { font-size: 1rem; font-weight: 500; }

.viewer-close {
  flex: none;
  min-width: 44px;
  min-height: 44px;
  border: 1px solid #777;
  border-radius: 50%;
  background: transparent;
  color: #fff;
  font: 28px/1 Arial, sans-serif;
  cursor: pointer;
}
.viewer-close:hover { border-color: #fff; }
.viewer-close:focus-visible { outline: 3px solid var(--accent, #2783de); outline-offset: 2px; }

.viewer-stage {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr) 56px;
  align-items: stretch;
  min-height: 0;
}
.viewer-stage img { width: 100%; height: 100%; min-height: 0; object-fit: contain; }
.viewer-stage .gallery-arrow svg { width: 26px; height: 26px; }

.viewer-caption {
  padding-bottom: env(safe-area-inset-bottom);
  color: #eee;
  font-size: 0.88rem;
  text-align: center;
}

body.viewer-active { overflow: hidden; }

/* --- Заголовки секций ------------------------------------------------------ */

.portfolio-section-heading {
  margin-top: clamp(24px, 2vw + 12px, 48px);
  padding-block: clamp(14px, 1.4vw, 28px);
  border-top: 2px solid var(--text, #2c2c2b);
  font-size: clamp(1.75rem, 1.25rem + 2.3vw, 3rem);
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: -0.03em;
}
.section-group > .portfolio-section-heading:first-child { margin-top: 0; }
.portfolio-section-heading.visually-hidden { border-top: 0; padding: 0; margin: 0; }

/* --- Адаптив --------------------------------------------------------------- */

@media (max-width: 600px) {
  .gallery-frame { grid-template-columns: 44px minmax(0, 1fr) 44px; }
  .image-viewer { padding: 12px 0; }
  .viewer-toolbar { padding: calc(env(safe-area-inset-top) + 4px) 12px 0; }
  .viewer-stage { grid-template-columns: 44px minmax(0, 1fr) 44px; }
  .viewer-caption { padding-inline: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  .gallery-arrow svg { transition: none; }
}
