﻿html {
  font-size: 14px;
  min-height: 100%;
}

@media (min-width: 768px) {
  html { font-size: 16px; }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body.site-body {
  position: relative;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  background: #dce8f2;
  color: #252525;
}

/* Непрокручиваемый фон без background-attachment: fixed — так надёжнее на мобильных браузерах. */
body.site-body::before {
  content: "";
  position: fixed;
  z-index: 0;
  inset: 0;
  pointer-events: none;
  background: #dce8f2 url("../images/background.jpg") center center / cover no-repeat;
}

.site-header,
.site-main,
.site-footer {
  position: relative;
  z-index: 1;
}

.site-header {
  width: 100%;
  min-height: 56px;
  background: rgba(18, 56, 109, .98);
  color: #fff;
  box-shadow: 0 1px 8px rgba(0, 31, 67, .16);
}

.site-header__inner {
  min-height: 56px;
  display: flex;
  align-items: center;
}

.site-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  color: #fff;
  text-decoration: none;
  line-height: 1.15;
}

.site-brand:hover,
.site-brand:focus,
.site-brand:active {
  color: #fff;
  text-decoration: none;
}

.site-brand__emblem {
  width: 39px;
  height: 32px;
  flex: 0 0 auto;
  object-fit: contain;
  display: block;
}

.site-brand__title {
  font-size: 18px;
  font-weight: 400;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.site-main {
  flex: 1 0 auto;
}

.site-main > main {
  min-width: 0;
}

.site-footer {
  flex: 0 0 auto;
  width: 100%;
  border-top: 1px solid rgba(210, 218, 226, .95);
  background: rgba(255, 255, 255, .96);
  color: #68717b;
  backdrop-filter: blur(5px);
}

.site-footer__inner {
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  font-size: 14px;
}

/* -------------------- Галерея -------------------- */
.gallery-browser {
  margin: 24px 0 30px;
  padding: 24px;
  border: 1px solid rgba(255, 255, 255, .66);
  border-radius: 18px;
  background: rgba(255, 255, 255, .94);
  box-shadow: 0 10px 34px rgba(16, 49, 82, .14);
  backdrop-filter: blur(7px);
}

.gallery-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 22px;
}

.gallery-heading__main {
  min-width: 0;
}

.gallery-title-row {
  display: flex;
  align-items: center;
  gap: 13px;
  min-width: 0;
}

.gallery-title-logo {
  width: 76px;
  height: auto;
  max-height: 54px;
  flex: 0 0 auto;
  object-fit: contain;
  display: block;
}

.gallery-title {
  min-width: 0;
  margin: 0;
  font-size: clamp(26px, 2.3vw, 34px);
  line-height: 1.1;
  font-weight: 400;
  letter-spacing: .01em;
}

.gallery-breadcrumbs {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 9px;
  color: #737b84;
  font-size: 13px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.gallery-breadcrumbs a {
  color: #315e91;
  text-decoration: none;
  transition: color .22s ease, opacity .22s ease;
}

.gallery-breadcrumbs a:hover {
  color: #12386d;
  text-decoration: underline;
}

.gallery-breadcrumbs__separator {
  color: #a5acb3;
}

.gallery-back {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  flex: 0 0 auto;
  min-height: 39px;
  padding: 7px 14px;
  border: 1px solid #d3dae2;
  border-radius: 9px;
  background: rgba(255, 255, 255, .94);
  color: #303943;
  text-decoration: none;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .02);
  transition: transform .24s cubic-bezier(.2, .7, .2, 1),
              background-color .24s ease,
              border-color .24s ease,
              box-shadow .24s ease;
}

.gallery-back:hover,
.gallery-back:focus-visible {
  color: #1f2d3b;
  background: #fff;
  border-color: #b8c4d1;
  box-shadow: 0 5px 15px rgba(27, 55, 88, .1);
  transform: translateY(-1px);
  outline: none;
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 16px;
}

.gallery-card {
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  padding: 9px 9px 11px;
  overflow: hidden;
  border: 1px solid #d7dce2;
  border-radius: 13px;
  background: rgba(255, 255, 255, .97);
  color: #2c333a;
  text-decoration: none;
  box-shadow: 0 2px 7px rgba(20, 45, 72, .04);
  transform: translateZ(0);
  transition: transform .25s cubic-bezier(.2, .72, .22, 1),
              border-color .25s ease,
              box-shadow .25s ease,
              background-color .25s ease;
}

.gallery-card:hover,
.gallery-card:focus-visible {
  color: #202b36;
  border-color: #aebdcc;
  background: #fff;
  box-shadow: 0 10px 24px rgba(19, 56, 91, .14);
  transform: translateY(-4px);
  outline: none;
}

.gallery-card__preview {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border-radius: 8px;
  background: #f3f5f7;
}

.gallery-card__preview::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .025);
  border-radius: inherit;
}

.gallery-card__preview--image img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  object-position: center;
  border-radius: inherit;
  transition: transform .32s cubic-bezier(.2, .72, .22, 1), opacity .2s ease;
}

.gallery-card--image:hover .gallery-card__preview--image img,
.gallery-card--image:focus-visible .gallery-card__preview--image img {
  transform: scale(1.045);
}

.gallery-card__preview--folder {
  background: #f7f8fa;
}

.folder-mosaic {
  width: 100%;
  height: 100%;
  display: grid;
  gap: 2px;
  background: #e7ebef;
  transition: transform .28s cubic-bezier(.2, .72, .22, 1);
}

.gallery-card--folder:hover .folder-mosaic,
.gallery-card--folder:focus-visible .folder-mosaic {
  transform: scale(1.018);
}

.folder-mosaic--1 {
  grid-template-columns: 1fr;
  grid-template-rows: 1fr;
  background: #f7f8fa;
}

.folder-mosaic--1 img {
  width: 100%;
  height: 100%;
  place-self: stretch;
  object-fit: cover;
  object-position: center;
}
.folder-mosaic--2 { grid-template-columns: repeat(2, 1fr); grid-template-rows: repeat(2, 1fr); }
.folder-mosaic--3 { grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr); }
.folder-mosaic--4 { grid-template-columns: repeat(4, 1fr); grid-template-rows: repeat(4, 1fr); }

.folder-mosaic img,
.folder-mosaic__empty {
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  display: block;
  object-fit: cover;
  background: linear-gradient(135deg, #f2f4f6, #e8edf1);
}

.gallery-card__name {
  min-width: 0;
  min-height: 39px;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: 6px;
  padding: 10px 4px 0;
  text-align: center;
  font-size: 13px;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.folder-icon-small {
  position: relative;
  width: 15px;
  height: 11px;
  flex: 0 0 auto;
  margin-top: 2px;
  border: 1px solid #9d6700;
  border-radius: 1px;
  background: #ffd65b;
}

.folder-icon-small::before {
  content: "";
  position: absolute;
  left: 1px;
  top: -4px;
  width: 7px;
  height: 4px;
  border: 1px solid #9d6700;
  border-bottom: 0;
  border-radius: 2px 2px 0 0;
  background: #ffd65b;
}

.folder-icon-large,
.gallery-empty-folder {
  position: relative;
  width: 62px;
  height: 43px;
  border: 3px solid #1c2530;
  border-radius: 3px;
  background: #ffd15a;
  transform: skew(-4deg);
}

.folder-icon-large::before,
.gallery-empty-folder::before {
  content: "";
  position: absolute;
  left: 5px;
  top: -12px;
  width: 29px;
  height: 12px;
  border: 3px solid #1c2530;
  border-bottom: 0;
  border-radius: 4px 4px 0 0;
  background: #ffd15a;
}

.gallery-message {
  min-height: 260px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 22px;
  padding: 28px;
  color: #727b84;
  text-align: center;
}

.gallery-message--error {
  min-height: 140px;
  border: 1px solid #e4c7c7;
  border-radius: 10px;
  background: #fff8f8;
  color: #8f3030;
}

.gallery-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 24px;
}

.gallery-pagination__button {
  min-width: 92px;
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 7px 12px;
  border: 1px solid #d1d9e1;
  border-radius: 9px;
  background: #fff;
  color: #2d527f;
  text-decoration: none;
  transition: transform .22s ease, box-shadow .22s ease, border-color .22s ease;
}

.gallery-pagination__button:not(.is-disabled):hover {
  border-color: #aebdcc;
  box-shadow: 0 5px 14px rgba(20, 54, 87, .1);
  transform: translateY(-1px);
}

.gallery-pagination__button.is-disabled {
  opacity: .42;
}

.gallery-pagination__status {
  min-width: 62px;
  color: #707983;
  text-align: center;
  font-size: 13px;
}

/* -------------------- Скачать каталог -------------------- */
.gallery-download-all {
  display: flex;
  justify-content: center;
  margin-top: 28px;
  padding-top: 22px;
  border-top: 1px solid rgba(116, 130, 145, .18);
}

.gallery-download-all__button {
  min-width: 235px;
  min-height: 54px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 11px;
  padding: 9px 18px;
  border: 1px solid #b9c8d7;
  border-radius: 11px;
  background: linear-gradient(180deg, #ffffff 0%, #f4f8fc 100%);
  color: #214f80;
  text-decoration: none;
  box-shadow: 0 2px 7px rgba(21, 58, 94, .06);
  transition: transform .25s cubic-bezier(.2, .72, .22, 1),
              border-color .25s ease,
              box-shadow .25s ease,
              background-color .25s ease,
              color .25s ease;
}

.gallery-download-all__button:hover,
.gallery-download-all__button:focus-visible {
  color: #133d6d;
  border-color: #8fa9c2;
  background: #fff;
  box-shadow: 0 8px 22px rgba(21, 58, 94, .14);
  transform: translateY(-2px);
  outline: none;
}

.gallery-download-all__button:active {
  transform: translateY(0) scale(.985);
}

.gallery-download-all__icon {
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: #e8f1fa;
  color: #1e568e;
  font-size: 23px;
  line-height: 1;
  font-weight: 600;
  transition: transform .25s cubic-bezier(.2, .72, .22, 1), background-color .25s ease;
}

.gallery-download-all__button:hover .gallery-download-all__icon,
.gallery-download-all__button:focus-visible .gallery-download-all__icon {
  background: #dfeefc;
  transform: translateY(2px);
}

.gallery-download-all__text {
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  line-height: 1.15;
}

.gallery-download-all__text strong {
  font-size: 14px;
  font-weight: 600;
}

.gallery-download-all__text small {
  margin-top: 4px;
  color: #7a8591;
  font-size: 11px;
  font-weight: 400;
}

/* -------------------- Просмотр изображения -------------------- */
.gallery-viewer[hidden] {
  display: none !important;
}

.gallery-viewer {
  position: fixed;
  z-index: 5000;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  opacity: 0;
  visibility: hidden;
  transition: opacity .24s ease, visibility .24s ease;
}

.gallery-viewer.is-open {
  opacity: 1;
  visibility: visible;
}

.gallery-viewer__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(5, 12, 21, .82);
  backdrop-filter: blur(5px);
}

.gallery-viewer__dialog {
  position: relative;
  z-index: 1;
  width: min(1120px, 94vw);
  height: min(860px, 92dvh);
  min-height: 360px;
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr) 54px;
  align-items: stretch;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, .18);
  border-radius: 16px;
  background: #101820;
  box-shadow: 0 24px 80px rgba(0, 0, 0, .48);
  transform: translateY(14px) scale(.975);
  transition: transform .26s cubic-bezier(.2, .72, .22, 1), box-shadow .26s ease;
}

.gallery-viewer.is-open .gallery-viewer__dialog {
  transform: translateY(0) scale(1);
}

.gallery-viewer__figure {
  min-width: 0;
  min-height: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: stretch;
}

.gallery-viewer__stage {
  position: relative;
  min-width: 0;
  min-height: 0;
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 18px 8px 8px;
}

.gallery-viewer__image {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  display: block;
  object-fit: contain;
  opacity: 0;
  transform: scale(.992);
  transition: opacity .22s ease, transform .28s cubic-bezier(.2, .72, .22, 1);
  user-select: none;
  -webkit-user-drag: none;
}

.gallery-viewer__image.is-loaded {
  opacity: 1;
  transform: scale(1);
}

.gallery-viewer__footer {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 66px;
  padding: 11px 8px 13px;
  border-top: 1px solid rgba(255, 255, 255, .08);
}

.gallery-viewer__caption {
  min-width: 0;
  overflow: hidden;
  color: #e9edf1;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
}

.gallery-viewer__download {
  flex: 0 0 auto;
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 13px;
  border: 1px solid rgba(255, 255, 255, .2);
  border-radius: 9px;
  background: rgba(255, 255, 255, .1);
  color: #fff;
  text-decoration: none;
  font-size: 13px;
  transition: background-color .22s ease, border-color .22s ease, transform .22s ease;
}

.gallery-viewer__download:hover,
.gallery-viewer__download:focus-visible {
  color: #fff;
  background: rgba(255, 255, 255, .17);
  border-color: rgba(255, 255, 255, .34);
  transform: translateY(-1px);
  outline: none;
}

.gallery-viewer__close,
.gallery-viewer__nav {
  border: 0;
  background: transparent;
  color: rgba(255, 255, 255, .82);
  cursor: pointer;
  transition: color .2s ease, background-color .2s ease, transform .2s ease;
}

.gallery-viewer__close:hover,
.gallery-viewer__nav:hover {
  color: #fff;
}

.gallery-viewer__close {
  position: absolute;
  z-index: 3;
  top: 6px;
  right: 7px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  font-size: 36px;
  font-weight: 200;
  line-height: 38px;
}

.gallery-viewer__close:hover {
  background: rgba(255, 255, 255, .08);
  transform: rotate(4deg);
}

.gallery-viewer__nav {
  align-self: stretch;
  font-size: 52px;
  font-weight: 200;
  line-height: 1;
}

.gallery-viewer__nav:hover {
  background: rgba(255, 255, 255, .045);
}

.gallery-viewer__loader {
  position: absolute;
  width: 34px;
  height: 34px;
  border: 3px solid rgba(255, 255, 255, .22);
  border-top-color: #fff;
  border-radius: 50%;
  animation: gallery-spin .7s linear infinite;
}

.gallery-viewer__loader[hidden],
.gallery-viewer__nav[hidden] {
  display: none;
}

@keyframes gallery-spin {
  to { transform: rotate(360deg); }
}

/* -------------------- Планшеты / телефоны -------------------- */
@media (max-width: 767.98px) {
  .site-header,
  .site-header__inner {
    min-height: 52px;
  }

  .site-header__inner,
  .site-footer__inner {
    padding-left: max(12px, env(safe-area-inset-left));
    padding-right: max(12px, env(safe-area-inset-right));
  }

  .site-brand {
    width: 100%;
    gap: 8px;
  }

  .site-brand__emblem {
    width: 34px;
    height: 29px;
  }

  .site-brand__title {
    min-width: 0;
    font-size: 15px;
  }

  .site-footer__inner {
    min-height: 52px;
    justify-content: center;
    padding-top: 10px;
    padding-bottom: 10px;
    text-align: center;
    font-size: 12px;
    line-height: 1.35;
  }

  .site-main {
    width: 100%;
    max-width: none;
    padding-left: 10px;
    padding-right: 10px;
  }

  .gallery-browser {
    margin: 12px 0 18px;
    padding: 15px 12px 18px;
    border-radius: 14px;
  }

  .gallery-heading {
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 15px;
  }

  .gallery-title-row {
    gap: 8px;
  }

  .gallery-title-logo {
    width: 54px;
    max-height: 40px;
  }

  .gallery-title {
    font-size: clamp(22px, 7vw, 27px);
  }

  .gallery-breadcrumbs {
    margin-top: 7px;
    font-size: 12px;
  }

  .gallery-back {
    min-height: 36px;
    padding: 6px 10px;
  }

  .gallery-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 9px;
  }

  .gallery-card {
    padding: 6px 6px 8px;
    border-radius: 10px;
  }

  .gallery-card__preview {
    border-radius: 7px;
  }

  .gallery-card__preview--image img {
    width: 100%;
    height: 100%;
  }

  .gallery-card__name {
    min-height: 39px;
    padding: 8px 2px 0;
    font-size: 11.5px;
  }

  .folder-mosaic {
    gap: 1px;
  }

  .gallery-pagination {
    gap: 7px;
    margin-top: 18px;
  }

  .gallery-pagination__button {
    min-width: 78px;
    padding-left: 9px;
    padding-right: 9px;
    font-size: 12px;
  }

  .gallery-download-all {
    margin-top: 20px;
    padding-top: 17px;
  }

  .gallery-download-all__button {
    width: 100%;
    min-width: 0;
    min-height: 52px;
    padding: 8px 14px;
  }

  .gallery-download-all__text {
    align-items: center;
  }

  .gallery-viewer {
    padding: 0;
  }

  .gallery-viewer__dialog {
    width: 100%;
    height: 100dvh;
    min-height: 0;
    grid-template-columns: 0 minmax(0, 1fr) 0;
    border: 0;
    border-radius: 0;
  }

  .gallery-viewer__stage {
    padding: max(55px, calc(env(safe-area-inset-top) + 45px)) 8px 8px;
  }

  .gallery-viewer__footer {
    flex-direction: column;
    align-items: stretch;
    gap: 9px;
    padding: 10px max(12px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
  }

  .gallery-viewer__caption {
    text-align: center;
    font-size: 12px;
  }

  .gallery-viewer__download {
    width: 100%;
    min-height: 43px;
    font-size: 13px;
  }

  .gallery-viewer__close {
    top: max(5px, env(safe-area-inset-top));
    right: max(6px, env(safe-area-inset-right));
  }

  .gallery-viewer__nav {
    position: absolute;
    z-index: 2;
    top: 50%;
    width: 42px;
    height: 72px;
    transform: translateY(-50%);
    border-radius: 8px;
    background: rgba(0, 0, 0, .14);
    font-size: 48px;
    text-shadow: 0 1px 5px rgba(0, 0, 0, .65);
  }

  .gallery-viewer__nav--prev { left: 2px; }
  .gallery-viewer__nav--next { right: 2px; }
}

@media (max-width: 390px) {
  .gallery-browser {
    padding-left: 9px;
    padding-right: 9px;
  }

  .gallery-heading {
    gap: 7px;
  }

  .gallery-title-logo {
    width: 46px;
  }

  .gallery-title {
    font-size: 21px;
  }

  .gallery-back span:last-child {
    display: none;
  }

  .gallery-back {
    width: 36px;
    min-width: 36px;
    padding-left: 0;
    padding-right: 0;
  }

  .gallery-grid {
    gap: 7px;
  }

  .gallery-card {
    padding: 5px 5px 7px;
  }

  .gallery-card__name {
    font-size: 11px;
  }
}

@media (max-width: 315px) {
  .gallery-grid {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: .01ms !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
  }
}
