/* ==========================================================
   SLAPY ŽDÁŇ
   gallery.css
   Galerie nemovitosti + fullscreen lightbox
   Verze 1.0
========================================================== */

/* ----------------------------------------------------------
   GALERIE
---------------------------------------------------------- */

.property-gallery {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  grid-auto-rows: 230px;
  gap: 16px;
  margin-top: 48px;
}

.gallery-item {
  position: relative;
  min-width: 0;
  overflow: hidden;
  border: 0;
  border-radius: 18px;
  padding: 0;
  background: #e8e8e4;
  cursor: zoom-in;
  box-shadow: none;
}

.gallery-item:first-child {
  grid-row: span 2;
}

.gallery-item:nth-child(6n + 4) {
  grid-column: span 2;
}

.gallery-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition:
    transform .5s ease,
    filter .35s ease;
}

.gallery-item::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    180deg,
    transparent 55%,
    rgba(0, 0, 0, .22)
  );
  opacity: 0;
  transition: opacity .35s ease;
  pointer-events: none;
}

.gallery-item:hover img {
  transform: scale(1.035);
}

.gallery-item:hover::after {
  opacity: 1;
}

.gallery-more {
  position: absolute;
  right: 18px;
  bottom: 18px;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 16px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .94);
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
  box-shadow: var(--shadow);
  pointer-events: none;
}


/* ----------------------------------------------------------
   LIGHTBOX
---------------------------------------------------------- */

.gallery-lightbox {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: none;
  background: rgba(10, 16, 13, .97);
  color: #fff;
}

.gallery-lightbox.is-open {
  display: grid;
  grid-template-rows: auto 1fr auto;
}

.gallery-lightbox[aria-hidden="false"] {
  animation: galleryFadeIn .25s ease;
}

@keyframes galleryFadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

.gallery-lightbox-header {
  position: relative;
  z-index: 4;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 72px;
  padding:
    max(14px, env(safe-area-inset-top))
    max(22px, env(safe-area-inset-right))
    14px
    max(22px, env(safe-area-inset-left));
}

.gallery-counter {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: .04em;
  opacity: .9;
}

.gallery-close {
  width: 48px;
  height: 48px;
  border: 0;
  border-radius: 50%;
  padding: 0;
  background: rgba(255, 255, 255, .1);
  color: #fff;
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
}

.gallery-lightbox-stage {
  position: relative;
  min-width: 0;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  touch-action: pan-y;
}

.gallery-lightbox-image {
  max-width: min(88vw, 1500px);
  max-height: calc(100vh - 180px);
  width: auto;
  height: auto;
  object-fit: contain;
  user-select: none;
  -webkit-user-drag: none;
  opacity: 0;
  transform: scale(.985);
  transition:
    opacity .25s ease,
    transform .25s ease;
}

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

.gallery-lightbox-image.is-changing {
  opacity: 0;
  transform: scale(.985);
}

.gallery-arrow {
  position: absolute;
  top: 50%;
  z-index: 3;
  width: 56px;
  height: 56px;
  border: 0;
  border-radius: 50%;
  padding: 0;
  background: rgba(255, 255, 255, .11);
  color: #fff;
  font-size: 34px;
  line-height: 1;
  transform: translateY(-50%);
  cursor: pointer;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.gallery-arrow:hover {
  background: rgba(255, 255, 255, .2);
}

.gallery-prev {
  left: 24px;
}

.gallery-next {
  right: 24px;
}

.gallery-lightbox-footer {
  position: relative;
  z-index: 4;
  min-height: 74px;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding:
    12px
    max(22px, env(safe-area-inset-right))
    max(18px, env(safe-area-inset-bottom))
    max(22px, env(safe-area-inset-left));
}

.gallery-caption {
  max-width: 900px;
  margin: 0;
  color: rgba(255, 255, 255, .82);
  font-size: 15px;
  line-height: 1.5;
  text-align: center;
}

body.gallery-open {
  overflow: hidden;
}


/* ----------------------------------------------------------
   LOADING
---------------------------------------------------------- */

.gallery-loader {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 42px;
  height: 42px;
  margin: -21px 0 0 -21px;
  border: 3px solid rgba(255, 255, 255, .18);
  border-top-color: rgba(255, 255, 255, .85);
  border-radius: 50%;
  animation: gallerySpin .8s linear infinite;
}

.gallery-loader[hidden] {
  display: none;
}

@keyframes gallerySpin {
  to {
    transform: rotate(360deg);
  }
}


/* ----------------------------------------------------------
   TABLETY
---------------------------------------------------------- */

@media (max-width: 992px) {

  .property-gallery {
    grid-template-columns: repeat(2, 1fr);
    grid-auto-rows: 220px;
  }

  .gallery-item:first-child {
    grid-column: span 2;
    grid-row: span 2;
  }

  .gallery-item:nth-child(6n + 4) {
    grid-column: auto;
  }

}


/* ----------------------------------------------------------
   MOBILY
---------------------------------------------------------- */

@media (max-width: 768px) {

  .property-gallery {
    grid-template-columns: 1fr 1fr;
    grid-auto-rows: 150px;
    gap: 9px;
    margin-top: 32px;
  }

  .gallery-item {
    border-radius: 12px;
  }

  .gallery-item:first-child {
    grid-column: span 2;
    grid-row: span 2;
  }

  .gallery-item:hover img {
    transform: none;
  }

  .gallery-more {
    right: 12px;
    bottom: 12px;
    padding: 9px 13px;
    font-size: 13px;
  }

  .gallery-lightbox-header {
    min-height: 64px;
  }

  .gallery-close {
    width: 44px;
    height: 44px;
  }

  .gallery-arrow {
    width: 46px;
    height: 46px;
    font-size: 28px;
  }

  .gallery-prev {
    left: 10px;
  }

  .gallery-next {
    right: 10px;
  }

  .gallery-lightbox-image {
    max-width: 100vw;
    max-height: calc(100dvh - 150px);
  }

  .gallery-lightbox-footer {
    min-height: 70px;
  }

  .gallery-caption {
    font-size: 14px;
  }

}


/* ----------------------------------------------------------
   MALÉ MOBILY
---------------------------------------------------------- */

@media (max-width: 480px) {

  .property-gallery {
    grid-auto-rows: 125px;
  }

  .gallery-counter {
    font-size: 14px;
  }

  .gallery-arrow {
    background: rgba(0, 0, 0, .28);
  }

}


/* ----------------------------------------------------------
   PREFERENCES
---------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {

  .gallery-lightbox[aria-hidden="false"] {
    animation: none;
  }

  .gallery-item img,
  .gallery-lightbox-image {
    transition: none;
  }

  .gallery-loader {
    animation-duration: 1.5s;
  }

}

@media (hover: none) {

  .gallery-item:hover img {
    transform: none;
  }

  .gallery-item:hover::after {
    opacity: 0;
  }

}
