/* ============================================================
   ООО «Альянс» — просмотр фотографий и документов.

   Отдельный файл со стилями полноэкранной галереи объекта,
   миниатюр на странице проекта и встроенного просмотрщика
   документов. Подключается на всех страницах рядом с основной
   темой site-steel.css.
   ============================================================ */

/* --- Миниатюры в галерее на странице проекта ----------------- */
.gallery__item {
  display: block; position: relative; overflow: hidden; padding: 0; border: 0;
  background: none; cursor: zoom-in; border-radius: var(--radius-sm, 9px);
  text-decoration: none;
}
.gallery__item img { display: block; transition: transform .3s ease; }
.gallery__item:hover img,
.gallery__item:focus-visible img { transform: scale(1.045); }
.gallery__item::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  border-radius: var(--radius-sm, 9px);
  box-shadow: inset 0 0 0 1px rgba(14, 23, 38, .08);
}
.gallery__item:focus-visible {
  outline: 2px solid var(--blue-500, #0a55c0); outline-offset: 2px;
}
.gallery__zoom {
  position: absolute; right: .6rem; bottom: .6rem; width: 38px; height: 38px;
  display: grid; place-items: center; border-radius: 10px; color: #fff;
  background: rgba(11, 15, 22, .62); backdrop-filter: blur(2px);
  opacity: 0; transform: translateY(6px); pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
}
.gallery__zoom svg { width: 20px; height: 20px; }
.gallery__item:hover .gallery__zoom,
.gallery__item:focus-visible .gallery__zoom { opacity: 1; transform: none; }
@media (hover: none) {
  .gallery__zoom { opacity: 1; transform: none; }
}

/* Кнопка под галереей длинная, а у .btn стоит white-space: nowrap —
   на узком экране разрешаем ей переноситься по словам. */
.btn--wrap { white-space: normal; max-width: 100%; text-align: center; }

/* ============================================================
   Отдельная страница-галерея объекта
   ============================================================ */
.galpage {
  margin: 0; overflow: hidden; background: #0b0f16; color: #e7edf6;
  font-family: "Golos Text", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
.galpage * { box-sizing: border-box; }

.gal {
  display: grid;
  /* minmax(0, 1fr) обязателен: иначе полоса миниатюр растягивает
     колонку по своему max-content и страница уезжает по горизонтали */
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  width: 100%; height: 100vh; height: 100dvh;
}
.gal > * { min-width: 0; }

/* --- Верхняя панель ----------------------------------------- */
.gal__bar {
  display: flex; align-items: center; gap: 1rem;
  padding: .8rem clamp(.8rem, 2.5vw, 1.6rem);
  border-bottom: 1px solid rgba(255, 255, 255, .1);
  background: rgba(255, 255, 255, .02);
}
.gal__back {
  display: inline-flex; align-items: center; gap: .5rem; flex: none;
  height: 48px; padding: 0 1.15rem 0 .9rem; border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, .28); background: rgba(255, 255, 255, .07);
  color: #fff; text-decoration: none; font-weight: 700; font-size: .95rem;
  font-family: "Manrope", "Golos Text", system-ui, sans-serif;
  transition: background .15s ease, transform .15s ease, border-color .15s ease;
}
.gal__back svg { width: 22px; height: 22px; flex: none; }
.gal__back:hover {
  background: rgba(255, 255, 255, .17); border-color: rgba(255, 255, 255, .45);
  transform: translateY(-1px);
}
.gal__titles {
  flex: 1; min-width: 0; display: flex; flex-direction: column; gap: .1rem; text-align: center;
}
.gal__title {
  font-family: "Manrope", "Golos Text", system-ui, sans-serif; font-weight: 700;
  font-size: 1.02rem; color: #fff;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.gal__loc {
  font-size: .82rem; color: #93a3ba;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.gal__counter {
  flex: none; font-family: "JetBrains Mono", ui-monospace, Menlo, monospace;
  font-size: .9rem; color: #93a3ba; letter-spacing: .04em;
  padding: .45rem .8rem; border-radius: 999px; background: rgba(255, 255, 255, .06);
}
.gal__counter b { color: #fff; font-weight: 500; }

/* --- Основное фото ------------------------------------------ */
.gal__stage {
  position: relative; min-height: 0; display: flex;
  align-items: center; justify-content: center;
  padding: clamp(1rem, 2.5vw, 2rem) clamp(4.75rem, 10vw, 7rem);
}
.gal__figure {
  margin: 0; min-height: 0; max-width: 100%; max-height: 100%;
  display: flex; flex-direction: column; align-items: center; gap: .9rem;
}
.gal__img {
  min-height: 0; max-width: 100%; max-height: 100%;
  width: auto; height: auto; object-fit: contain;
  border-radius: 12px; background: #10151f;
  box-shadow: 0 30px 70px -30px rgba(0, 0, 0, .85);
}
.gal__caption {
  flex: none; font-size: .9rem; color: #93a3ba; text-align: center; max-width: 70ch;
}
.gal__caption:empty { display: none; }

/* --- Крупные кнопки перелистывания -------------------------- */
.gal__nav {
  position: absolute; top: 50%; transform: translateY(-50%); z-index: 2;
  width: 64px; height: 64px; border-radius: 50%;
  display: grid; place-items: center; cursor: pointer; color: #fff;
  border: 1px solid rgba(255, 255, 255, .3); background: rgba(255, 255, 255, .1);
  backdrop-filter: blur(4px); text-decoration: none;
  transition: background .15s ease, border-color .15s ease, transform .15s ease;
}
.gal__nav svg { width: 32px; height: 32px; }
.gal__nav:hover {
  background: rgba(255, 255, 255, .22); border-color: rgba(255, 255, 255, .5);
  transform: translateY(-50%) scale(1.06);
}
.gal__nav:active { transform: translateY(-50%) scale(.97); }
.gal__nav:focus-visible { outline: 2px solid #fff; outline-offset: 3px; }
.gal__nav--prev { left: clamp(.6rem, 2.5vw, 1.75rem); }
.gal__nav--next { right: clamp(.6rem, 2.5vw, 1.75rem); }

/* --- Полоса миниатюр ---------------------------------------- */
.gal__thumbs {
  display: flex; gap: .55rem; overflow-x: auto; overflow-y: hidden;
  padding: .85rem clamp(.8rem, 2.5vw, 1.6rem);
  border-top: 1px solid rgba(255, 255, 255, .1);
  scrollbar-width: thin; scrollbar-color: rgba(255, 255, 255, .25) transparent;
}
.gal__thumbs::-webkit-scrollbar { height: 8px; }
.gal__thumbs::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, .22); border-radius: 999px;
}
.gal__thumb {
  display: block; flex: none; width: 104px; height: 72px; border-radius: 9px; overflow: hidden;
  border: 2px solid transparent; opacity: .5; cursor: pointer; padding: 0;
  background: #10151f; transition: opacity .18s ease, border-color .18s ease, transform .18s ease;
}
.gal__thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.gal__thumb:hover { opacity: .85; transform: translateY(-2px); }
.gal__thumb.is-active { opacity: 1; border-color: #fff; }
.gal__thumb:focus-visible { outline: 2px solid #fff; outline-offset: 2px; opacity: 1; }

/* --- Подсказка по клавишам ---------------------------------- */
.gal__hint {
  padding: .5rem 1rem .8rem; text-align: center;
  font-family: "JetBrains Mono", ui-monospace, Menlo, monospace;
  font-size: .72rem; letter-spacing: .04em; color: #64748b;
}

@media (max-width: 780px) {
  .gal__back span { display: none; }
  .gal__back { padding: 0; width: 48px; justify-content: center; }
  /* На узком экране фото занимает всю ширину, а кнопки лежат поверх
     его краёв — так снимок остаётся крупным. Плюс работает свайп. */
  .gal__stage { padding: .9rem .6rem; }
  .gal__nav { width: 52px; height: 52px; }
  .gal__nav svg { width: 26px; height: 26px; }
  .gal__thumb { width: 76px; height: 54px; }
  .gal__hint { display: none; }
}

/* ============================================================
   Просмотр документа (справки, допуски) прямо на сайте
   ============================================================ */
.docview { position: fixed; inset: 0; z-index: 300; display: none; }
.docview.is-open { display: block; }
.docview__overlay {
  position: absolute; inset: 0;
  background: rgba(11, 15, 22, .74); backdrop-filter: blur(3px);
}
.docview__inner {
  position: relative; z-index: 1; height: 100%;
  display: flex; align-items: center; justify-content: center;
  padding: clamp(.75rem, 3vw, 2rem);
}
.docview__dialog {
  display: flex; flex-direction: column; overflow: hidden;
  width: min(1040px, 100%); height: min(90vh, 1200px);
  background: #fff; border-radius: 14px;
  box-shadow: 0 30px 70px -25px rgba(0, 0, 0, .6);
  animation: docview-pop .22s ease;
}
@keyframes docview-pop {
  from { opacity: 0; transform: translateY(14px) scale(.985); }
  to { opacity: 1; transform: none; }
}
.docview__head {
  flex: none; display: flex; align-items: center; gap: .9rem;
  padding: .8rem .9rem .8rem 1.2rem; border-bottom: 1px solid #e0e3e9;
}
.docview__title {
  flex: 1; min-width: 0; margin: 0; font-size: 1.02rem; color: #131313;
  font-family: "Manrope", "Golos Text", system-ui, sans-serif; font-weight: 700;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.docview__actions { flex: none; display: flex; align-items: center; gap: .5rem; }
.docview__btn,
.docview__close {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  height: 44px; border-radius: 10px; border: 1px solid #e0e3e9;
  background: #fff; color: #131313; cursor: pointer; text-decoration: none;
  font-family: "Manrope", "Golos Text", system-ui, sans-serif;
  font-weight: 700; font-size: .92rem;
  transition: background .15s ease, border-color .15s ease;
}
.docview__btn { padding: 0 1rem; }
.docview__close { width: 44px; flex: none; }
.docview__btn svg,
.docview__close svg { width: 20px; height: 20px; flex: none; }
.docview__btn:hover,
.docview__close:hover { background: #f4f6fa; border-color: #c9d2e0; }
.docview__btn:focus-visible,
.docview__close:focus-visible { outline: 2px solid #0a55c0; outline-offset: 2px; }
.docview__body { flex: 1; min-height: 0; background: #f4f6fa; }
.docview__body iframe { width: 100%; height: 100%; border: 0; display: block; }
body.docview-open { overflow: hidden; }

@media (max-width: 640px) {
  .docview__dialog { height: 94vh; border-radius: 12px; }
  .docview__head { padding-left: .9rem; }
  .docview__btn span { display: none; }
  .docview__btn { width: 44px; padding: 0; }
}
