/* only gallery styles */

.is-hidden {
  display: none !important;
}

.gallery .gallery-shell {
  width: min(1480px, calc(100% - 20px));
  margin: 0 auto;
  padding: 8px 0 28px;
}

.gallery .gallery-loader {
  min-height: 22vh;
  display: grid;
  place-items: center;
  gap: 12px;
  padding-top: 20px;
}

.gallery .gallery-loader__dot {
  width: 30px;
  height: 30px;
  border-radius: 999px;
  border: 2px solid rgba(0, 0, 0, 0.12);
  border-top-color: rgba(0, 0, 0, 0.58);
  animation: gallerySpin 0.9s linear infinite;
}

.gallery .gallery-loader__text {
  font-size: 12px;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  color: rgba(0, 0, 0, 0.55);
  white-space: nowrap;
}

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

.gallery .masonry {
  display: grid;
  align-items: start;
  gap: 8px;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  position: relative;
}

.gallery .masonry-column {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.gallery .masonry-item {
  position: relative;
  display: block;
  overflow: hidden;
  text-decoration: none;
  background: #ecece7;
  opacity: 0;
  transform: translateY(38px);
  transition:
    opacity 1.05s ease,
    transform 1.05s cubic-bezier(0.16, 1, 0.3, 1);
  will-change: transform, opacity;
  backface-visibility: hidden;
  transform-origin: top left;
}

.gallery .masonry-item.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.gallery .masonry-item img {
  display: block;
  width: 100%;
  height: auto;
  min-height: 120px;
}

.gallery .masonry-item.is-flipping {
  z-index: 2;
}

.gallery .more-wrap {
  text-align: center;
  margin-top: 22px;
}

.gallery .more-btn {
  background: transparent;
  border: none;
  border-bottom: 1px solid rgba(0, 0, 0, 0.72);
  color: inherit;
  font-size: 13px;
  letter-spacing: 2px;
  text-transform: uppercase;
  padding: 8px 0;
  cursor: pointer;
  transition: opacity 0.25s ease;
}

.gallery .more-btn:hover {
  opacity: 0.55;
}

.gallery .more-btn[disabled] {
  opacity: 0.34;
  cursor: default;
}

.gallery .sentinel {
  width: 100%;
  height: 1px;
  margin-top: 4px;
}

.back-to-top {
  position: fixed;
  right: 18px;
  bottom: 18px;
  width: 52px;
  height: 52px;
  border: none;
  background: rgba(255, 255, 255, 0.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  color: rgba(0, 0, 0, 0.65);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  z-index: 3000;
  border-radius: 50%;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.08);
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px) scale(0.95);
  transition:
    opacity 0.25s ease,
    transform 0.25s ease,
    background 0.25s ease,
    box-shadow 0.25s ease;
}

.back-to-top:hover {
  background: rgba(255, 255, 255, 0.75);
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.12);
}

.back-to-top.is-visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

@media (max-width: 1800px) {
  .gallery .masonry {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }
}

@media (max-width: 1550px) {
  .gallery .masonry {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (max-width: 1280px) {
  .gallery .masonry {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 7px;
  }

  .gallery .masonry-column {
    gap: 7px;
  }
}

@media (max-width: 980px) {
  .gallery .masonry {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 7px;
  }

  .gallery .masonry-column {
    gap: 7px;
  }
}

@media (max-width: 760px) {
  .gallery .gallery-shell {
    width: calc(100% - 12px);
    padding-top: 6px;
  }

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

  .gallery .masonry-column {
    gap: 6px;
  }

  .back-to-top {
    width: 44px;
    height: 44px;
    font-size: 20px;
    right: 10px;
    bottom: 10px;
  }
}

@media (max-width: 520px) {
  .gallery .gallery-shell {
    width: calc(100% - 10px);
    padding-top: 4px;
  }

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

  .gallery .masonry-column {
    gap: 5px;
  }

  .back-to-top {
    right: 10px;
    bottom: 10px;
    width: 44px;
    height: 44px;
    font-size: 20px;
  }
}

/* ===== make gallery use almost full width ===== */

/* safer width override for gallery */
.gallery {
  padding-left: 0 !important;
  padding-right: 0 !important;
}

.gallery .gallery-shell {
  width: min(1700px, calc(100% - 10px)) !important;
  margin-left: auto !important;
  margin-right: auto !important;
}

@media (max-width: 760px) {
  .gallery .gallery-shell {
    width: calc(100% - 4px) !important;
  }
}

@media (max-width: 520px) {
  .gallery .gallery-shell {
    width: calc(100% - 4px) !important;
  }
}

/* ===== gallery-only width override ===== */
main:has(.gallery) {
  max-width: none !important;
  width: 100% !important;
  padding-left: 0 !important;
  padding-right: 0 !important;
}

main:has(.gallery) .gallery {
  padding-left: 0 !important;
  padding-right: 0 !important;
}

main:has(.gallery) .gallery .gallery-shell {
  width: min(1680px, calc(100% - 24px)) !important;
  margin-left: auto !important;
  margin-right: auto !important;
}

@media (max-width: 760px) {
  main:has(.gallery) .gallery .gallery-shell {
    width: calc(100% - 10px) !important;
  }
}

@media (max-width: 520px) {
  main:has(.gallery) .gallery .gallery-shell {
    width: calc(100% - 10px) !important;
  }
}
