/* Gallery & Portfolio — сетка, masonry и лайтбокс. */

.czgal { margin: 1.25em 0; }

/* Сетка: равные ячейки с кропом. */
.czgal-grid {
  display: grid;
  grid-template-columns: repeat(var(--czgal-cols, 3), 1fr);
  gap: var(--czgal-gap, 8px);
}
.czgal-grid .czgal-it {
  position: relative;
  display: block;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  border-radius: 10px;
}
.czgal-grid .czgal-it img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform .25s ease;
}
.czgal-grid a.czgal-it:hover img { transform: scale(1.04); }

/* Masonry: колонки без кропа. */
.czgal-masonry {
  columns: var(--czgal-cols, 3);
  column-gap: var(--czgal-gap, 8px);
}
.czgal-masonry .czgal-it {
  position: relative;
  display: block;
  margin-bottom: var(--czgal-gap, 8px);
  break-inside: avoid;
  overflow: hidden;
  border-radius: 10px;
}
.czgal-masonry .czgal-it img {
  width: 100%;
  height: auto;
  display: block;
}

@media (max-width: 900px) {
  .czgal-grid { grid-template-columns: repeat(min(var(--czgal-cols, 3), 3), 1fr); }
  .czgal-masonry { columns: min(var(--czgal-cols, 3), 3); }
}
@media (max-width: 600px) {
  .czgal-grid { grid-template-columns: repeat(2, 1fr); }
  .czgal-masonry { columns: 2; }
}

/* Подпись поверх снимка. */
.czgal-cap {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  padding: 20px 12px 10px;
  font-size: 13px;
  line-height: 1.35;
  color: #fff;
  background: linear-gradient(transparent, rgba(0, 0, 0, .65));
  pointer-events: none;
}

/* --- «Показать ещё» ------------------------------------------------------ */
.czgal-wrap > .czgal { margin-bottom: 0; }
.czgal-more { display: flex; justify-content: center; margin: 18px 0 1.25em; }
.czgal-more-btn {
  display: inline-flex;
  align-items: center;
  gap: .5em;
  padding: .75em 1.5em;
  border: 1px solid rgba(15, 23, 34, .18);
  border-radius: 999px;
  background: #fff;
  color: #0f1722;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: border-color .2s ease, box-shadow .2s ease, transform .2s ease;
}
.czgal-more-btn:hover { border-color: #0f1722; box-shadow: 0 8px 22px rgba(15, 23, 34, .12); transform: translateY(-1px); }
.czgal-more-btn:disabled { cursor: default; opacity: .65; transform: none; box-shadow: none; }
.czgal-more-btn.is-loading::after {
  content: "";
  width: 1em;
  height: 1em;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: czgal-spin .7s linear infinite;
}
.czgal-more-n {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.7em;
  height: 1.7em;
  padding: 0 .45em;
  border-radius: 999px;
  background: rgba(15, 23, 34, .08);
  font-size: .8em;
  font-weight: 700;
}
@keyframes czgal-spin { to { transform: rotate(360deg); } }

/* --- Карточки-разделы {gallery_albums} ----------------------------------- */
.czgal-albums {
  display: grid;
  grid-template-columns: repeat(var(--czgal-cols, 4), minmax(0, 1fr));
  gap: 22px;
  margin: 1.25em 0;
  padding-top: 12px; /* место под «стопку» над карточкой */
}
.czgal-album {
  position: relative;
  display: block;
  aspect-ratio: 4 / 5;
  border-radius: 18px;
  text-decoration: none;
  isolation: isolate;
  outline-offset: 4px;
  transition: transform .35s ease;
}
/* Стопка снимков за карточкой: сразу видно, что внутри целый альбом, а не одно фото. */
.czgal-album::before,
.czgal-album::after {
  content: "";
  position: absolute;
  left: 7%;
  right: 7%;
  top: -6px;
  bottom: 6px;
  border-radius: 16px;
  background: rgba(15, 23, 34, .16);
  z-index: -1;
  transition: transform .35s ease;
}
.czgal-album::after {
  left: 14%;
  right: 14%;
  top: -12px;
  bottom: 12px;
  background: rgba(15, 23, 34, .08);
  z-index: -2;
}
.czgal-album-media {
  position: absolute;
  inset: 0;
  overflow: hidden;
  border-radius: inherit;
  background: #dfe5ec;
  box-shadow: 0 12px 30px rgba(15, 23, 34, .14);
  transition: box-shadow .35s ease;
}
.czgal-album-media img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform .6s cubic-bezier(.2, .7, .2, 1);
}
.czgal-album-media::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(8, 12, 18, 0) 38%, rgba(8, 12, 18, .8) 100%);
}
.czgal-album-count {
  position: absolute;
  top: 14px;
  left: 14px;
  z-index: 1;
  padding: 5px 11px;
  border-radius: 999px;
  background: rgba(10, 14, 20, .5);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  color: #fff;
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.2;
}
.czgal-album-foot {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 18px 18px 20px;
}
.czgal-album-title {
  color: #fff;
  font-size: 1.15em;
  font-weight: 700;
  line-height: 1.2;
  text-shadow: 0 1px 12px rgba(0, 0, 0, .35);
}
.czgal-album-go {
  flex: none;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #fff;
  color: #0f1722;
  transition: transform .3s ease;
}
.czgal-album:hover,
.czgal-album:focus-visible { transform: translateY(-4px); }
.czgal-album:hover::before,
.czgal-album:focus-visible::before { transform: translateY(-3px); }
.czgal-album:hover::after,
.czgal-album:focus-visible::after { transform: translateY(-6px); }
.czgal-album:hover .czgal-album-media,
.czgal-album:focus-visible .czgal-album-media { box-shadow: 0 22px 46px rgba(15, 23, 34, .24); }
.czgal-album:hover .czgal-album-media img,
.czgal-album:focus-visible .czgal-album-media img { transform: scale(1.06); }
.czgal-album:hover .czgal-album-go,
.czgal-album:focus-visible .czgal-album-go { transform: translateX(3px); }

@media (max-width: 1024px) {
  .czgal-albums { grid-template-columns: repeat(min(var(--czgal-cols, 4), 3), minmax(0, 1fr)); }
}
@media (max-width: 720px) {
  .czgal-albums { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 12px; }
  .czgal-album { border-radius: 14px; }
  .czgal-album::before, .czgal-album::after { border-radius: 12px; }
  .czgal-album-count { top: 10px; left: 10px; padding: 4px 9px; font-size: 11.5px; }
  .czgal-album-foot { padding: 12px; gap: 8px; }
  .czgal-album-title { font-size: 1em; }
  .czgal-album-go { width: 30px; height: 30px; }
  .czgal-album-go svg { width: 15px; height: 15px; }
}

/* --- Окно альбома ------------------------------------------------------- */
html.czgal-lock { overflow: hidden; }
.czgal-viewer {
  position: fixed;
  inset: 0;
  z-index: 99990; /* ниже лайтбокса GLightbox — он открывается поверх окна */
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 3vh 3vw;
  color: #0f1722;
  visibility: hidden;
  opacity: 0;
  transition: opacity .25s ease, visibility 0s linear .25s;
}
.czgal-viewer.is-open { visibility: visible; opacity: 1; transition: opacity .25s ease; }
.czgal-v-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(8, 12, 18, .72);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}
.czgal-v-panel {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 1180px;
  height: 100%;
  overflow: hidden;
  border-radius: 22px;
  background: #fff;
  box-shadow: 0 40px 100px rgba(0, 0, 0, .35);
  transform: translateY(24px) scale(.985);
  transition: transform .35s cubic-bezier(.2, .8, .2, 1);
}
.czgal-viewer.is-open .czgal-v-panel { transform: none; }
.czgal-v-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 22px 12px 28px;
}
.czgal-v-heading { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 12px; min-width: 0; }
.czgal-v-title { margin: 0; color: #0f1722; font-size: 1.5em; font-weight: 700; line-height: 1.2; }
.czgal-v-count { color: #64748b; font-size: .9em; white-space: nowrap; }
.czgal-v-close {
  flex: none;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: #f1f4f8;
  color: #0f1722;
  cursor: pointer;
  transition: background .2s ease, transform .2s ease;
}
.czgal-v-close:hover { background: #e2e8f0; transform: rotate(90deg); }
.czgal-v-chips {
  display: flex;
  gap: 8px;
  padding: 2px 28px 14px;
  overflow-x: auto;
  border-bottom: 1px solid #eef1f5;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.czgal-v-chips::-webkit-scrollbar { display: none; }
.czgal-v-chip {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 14px;
  border: 1px solid #e2e8f0;
  border-radius: 999px;
  background: #fff;
  color: #334155;
  font-size: .9em;
  font-weight: 600;
  line-height: 1.2;
  text-decoration: none;
  white-space: nowrap;
  transition: border-color .2s ease, background .2s ease, color .2s ease;
}
.czgal-v-chip:hover { border-color: #94a3b8; color: #0f1722; }
.czgal-v-chip.is-active { border-color: #0f1722; background: #0f1722; color: #fff; }
.czgal-v-chip-n { font-size: .8em; font-weight: 700; opacity: .6; }
.czgal-v-body {
  flex: 1 1 auto;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 22px 28px 28px;
}
.czgal-v-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.czgal-v-tile {
  position: relative;
  display: block;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  border-radius: 14px;
  background: #eef2f6;
}
.czgal-v-tile img { display: block; width: 100%; height: 100%; object-fit: cover; transition: transform .45s ease; }
a.czgal-v-tile:hover img { transform: scale(1.05); }
.czgal-v-tile .czgal-cap { opacity: 0; transform: translateY(6px); transition: opacity .25s ease, transform .25s ease; }
a.czgal-v-tile:hover .czgal-cap,
a.czgal-v-tile:focus-visible .czgal-cap { opacity: 1; transform: none; }
@media (hover: none) {
  .czgal-v-tile .czgal-cap { opacity: 1; transform: none; }
}
.czgal-v-sk {
  background: linear-gradient(100deg, #eef2f6 30%, #f8fafc 50%, #eef2f6 70%);
  background-size: 300% 100%;
  animation: czgal-shimmer 1.2s ease-in-out infinite;
}
@keyframes czgal-shimmer { from { background-position: 100% 0; } to { background-position: 0 0; } }
.czgal-v-foot { display: flex; flex-direction: column; align-items: center; gap: 14px; padding-top: 22px; }
.czgal-v-msg { margin: 0; color: #64748b; font-size: .95em; text-align: center; }
.czgal-v-msg:empty { display: none; }
.czgal-v-cta {
  display: inline-flex;
  align-items: center;
  padding: .85em 1.6em;
  border-radius: 999px;
  background: #0f1722;
  color: #fff;
  font-weight: 600;
  text-decoration: none;
  transition: transform .2s ease, box-shadow .2s ease;
}
.czgal-v-cta:hover { color: #fff; transform: translateY(-2px); box-shadow: 0 12px 26px rgba(15, 23, 34, .25); }
/* Темы часто задают ссылкам свой цвет (.x a { color: inherit }) — у кнопок окна он свой. */
.czgal-viewer a.czgal-v-chip { color: #334155; }
.czgal-viewer a.czgal-v-chip:hover { color: #0f1722; }
.czgal-viewer a.czgal-v-chip.is-active { color: #fff; }
.czgal-viewer a.czgal-v-cta,
.czgal-viewer a.czgal-v-cta:hover { color: #fff; }

@media (max-width: 720px) {
  .czgal-viewer { padding: 0; }
  .czgal-v-panel { max-width: none; border-radius: 0; }
  .czgal-v-head { padding: 14px 14px 10px 18px; }
  .czgal-v-title { font-size: 1.2em; }
  .czgal-v-chips { padding: 2px 18px 12px; }
  .czgal-v-body { padding: 14px 14px 22px; }
  .czgal-v-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .czgal-v-tile { border-radius: 10px; }
}
@media (prefers-reduced-motion: reduce) {
  .czgal-album, .czgal-album::before, .czgal-album::after, .czgal-album-media img, .czgal-album-go,
  .czgal-viewer, .czgal-v-panel, .czgal-v-tile img { transition: none; }
  .czgal-v-sk, .czgal-more-btn.is-loading::after { animation: none; }
}

/* Лайтбокс — GLightbox (MIT); стили библиотеки грузятся отдельным файлом.
   Здесь только подгонка под тёмный оверлей и подписи. */
.goverlay { background: rgba(10, 12, 16, .94); }
.glightbox-container .gslide-description { background: rgba(17, 20, 26, .92); }
.glightbox-container .gslide-title { color: #fff; font-size: 15px; margin: 0; }
.glightbox-container .gdesc-inner { padding: 14px 18px; }
