.custom-gallery {
  padding: 72px var(--container-padding);
  font-family: var(--font-body);
}

.custom-gallery__inner {
  width: min(100%, var(--container-max));
  margin: 0 auto;
}

.custom-gallery__heading {
  font-family: var(--font-heading);
  font-weight: 400;
  font-size: clamp(2rem, 3vw, 2.5rem);
  color: var(--color-text-primary);
  margin: 0 0 12px;
  text-align: center;
}

.custom-gallery__description {
  font-size: 1.0625rem;
  line-height: 1.6;
  color: var(--color-text-secondary);
  margin: 0 0 32px;
  text-align: center;
  max-width: 640px;
  margin-left: auto;
  margin-right: auto;
}

.custom-gallery__link {
  display: block;
  border: none;
  padding: 0;
  margin: 0;
  background: none;
  width: 100%;
  cursor: pointer;
}

.custom-gallery__link:hover .custom-gallery__image {
  opacity: 0.92;
}

.custom-gallery__caption {
  margin: 8px 0 0;
  font-size: 0.9375rem;
  color: var(--color-text-secondary);
  text-align: center;
}

.custom-gallery__grid {
  display: grid;
  gap: 16px;
}

.custom-gallery__grid--cols-2 { grid-template-columns: repeat(2, 1fr); }
.custom-gallery__grid--cols-3 { grid-template-columns: repeat(3, 1fr); }
.custom-gallery__grid--cols-4 { grid-template-columns: repeat(4, 1fr); }

.custom-gallery__item {
  margin: 0;
}

.custom-gallery__image {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 12px;
  object-fit: cover;
  transition: opacity 0.2s ease;
}

.custom-gallery__carousel {
  position: relative;
  padding: 0 60px;
}

.custom-gallery__viewport {
  overflow: hidden;
  border-radius: 16px;
}

.custom-gallery__strip {
  display: flex;
  align-items: center;
  transition: transform 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  will-change: transform;
}

.custom-gallery__card {
  flex: 0 0 60%;
  margin: 0 1%;
  transition: transform 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94),
              opacity 0.5s ease,
              filter 0.5s ease;
  transform: scale(0.82);
  opacity: 0.4;
  filter: brightness(0.7);
  border-radius: 16px;
  overflow: hidden;
}

.custom-gallery__card--active {
  transform: scale(1);
  opacity: 1;
  filter: brightness(1);
  z-index: 1;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
}

.custom-gallery__card .custom-gallery__image {
  width: 100%;
  aspect-ratio: 3 / 2;
  object-fit: cover;
  border-radius: 0;
  display: block;
}

.custom-gallery__arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.95);
  color: var(--color-text-primary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
  transition: background 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
  z-index: 3;
}

.custom-gallery__arrow:hover {
  background: #fff;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
  transform: translateY(-50%) scale(1.08);
}

.custom-gallery__arrow--prev { left: 0; }
.custom-gallery__arrow--next { right: 0; }

.custom-gallery__dots {
  display: flex;
  justify-content: center;
  gap: 8px;
  padding: 20px 0 4px;
}

.custom-gallery__dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: none;
  background: var(--color-border-subtle);
  cursor: pointer;
  padding: 0;
  transition: background 0.2s ease, transform 0.2s ease, width 0.2s ease;
}

.custom-gallery__dot--active {
  background: var(--color-brand-green);
  width: 24px;
  border-radius: 5px;
}

.custom-gallery__scroll {
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow: hidden;
  width: 100vw;
  margin-left: calc(50% - 50vw);
}

.custom-gallery__scroll-row {
  overflow: hidden;
}

.custom-gallery__scroll-track {
  display: flex;
  gap: 16px;
  width: max-content;
}

.custom-gallery__scroll-row--left .custom-gallery__scroll-track {
  animation: customGalleryScrollLeft 25s linear infinite;
}

.custom-gallery__scroll-row--right .custom-gallery__scroll-track {
  animation: customGalleryScrollRight 25s linear infinite;
}

@keyframes customGalleryScrollLeft {
  0% { transform: translateX(0); }
  100% { transform: translateX(-33.33%); }
}

@keyframes customGalleryScrollRight {
  0% { transform: translateX(-33.33%); }
  100% { transform: translateX(0); }
}

.custom-gallery__scroll-item {
  flex-shrink: 0;
  margin: 0;
  border-radius: 12px;
  overflow: hidden;
}

.custom-gallery__scroll-item .custom-gallery__image {
  height: 240px;
  width: auto;
  aspect-ratio: 3 / 2;
  object-fit: cover;
  border-radius: 0;
  display: block;
}

.custom-gallery__lightbox {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: rgba(0, 0, 0, 0.9);
  z-index: 9999;
  padding: 24px;
}

.custom-gallery__lightbox[hidden] {
  display: none;
}

.custom-gallery__lightbox-stage {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  max-width: 1100px;
}

.custom-gallery__lightbox-figure {
  position: relative;
  margin: 0;
  width: fit-content;
  max-width: 90vw;
  max-height: 78vh;
  border: 2px solid rgba(255, 255, 255, 0.85);
  border-radius: 6px;
  background: #000;
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.55);
  line-height: 0;
}

.custom-gallery__lightbox-image {
  width: auto;
  max-width: 90vw;
  max-height: 78vh;
  object-fit: contain;
  border-radius: 4px;
  display: block;
  margin: 0 auto;
}

.custom-gallery__lightbox-caption {
  position: absolute;
  left: 2px;
  bottom: 2px;
  padding: 8px 14px;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 0.9rem;
  line-height: normal;
  letter-spacing: 0.02em;
  border-bottom-left-radius: 4px;
}

.custom-gallery__lightbox-caption:empty {
  display: none;
}

.custom-gallery__lightbox-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  cursor: pointer;
  z-index: 2;
  transition: background 0.2s ease;
}

.custom-gallery__lightbox-arrow:hover {
  background: rgba(0, 0, 0, 0.8);
}

.custom-gallery__lightbox-arrow--prev { left: 12px; }
.custom-gallery__lightbox-arrow--next { right: 12px; }

.custom-gallery__lightbox--single .custom-gallery__lightbox-arrow,
.custom-gallery__lightbox--single .custom-gallery__lightbox-thumbs {
  display: none;
}

.custom-gallery__lightbox-thumbs {
  display: flex;
  gap: 6px;
  max-width: 90vw;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.3) transparent;
}

.custom-gallery__lightbox-thumbs::-webkit-scrollbar {
  height: 6px;
}

.custom-gallery__lightbox-thumbs::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.3);
  border-radius: 4px;
}

.custom-gallery__lightbox-thumb {
  flex: 0 0 auto;
  width: 72px;
  height: 48px;
  padding: 0;
  border: 2px solid transparent;
  border-radius: 3px;
  background: none;
  cursor: pointer;
  opacity: 0.6;
  transition: opacity 0.2s ease, border-color 0.2s ease;
}

.custom-gallery__lightbox-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  border-radius: 1px;
}

.custom-gallery__lightbox-thumb:hover {
  opacity: 1;
}

.custom-gallery__lightbox-thumb--active {
  opacity: 1;
  border-color: var(--color-brand-green);
}

.custom-gallery__lightbox-close {
  position: absolute;
  top: 0;
  right: 0;
  transform: translate(50%, -50%);
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.75);
  color: #fff;
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  z-index: 4;
  transition: background 0.2s ease;
}

.custom-gallery__lightbox-close:hover {
  background: rgba(0, 0, 0, 0.9);
}

@media (max-width: 767px) {
  .custom-gallery__lightbox-thumb {
    width: 56px;
    height: 38px;
  }
}

@media (max-width: 767px) {
  .custom-gallery {
    padding: 56px var(--container-padding);
  }

  .custom-gallery__grid--cols-3,
  .custom-gallery__grid--cols-4 {
    grid-template-columns: repeat(2, 1fr);
  }

  .custom-gallery__scroll-item .custom-gallery__image {
    height: 200px;
  }

  .custom-gallery__carousel {
    padding: 0 40px;
  }

  .custom-gallery__card {
    flex: 0 0 70%;
    margin: 0 1%;
  }
}

@media (max-width: 479px) {
  .custom-gallery__grid--cols-2,
  .custom-gallery__grid--cols-3,
  .custom-gallery__grid--cols-4 {
    grid-template-columns: 1fr;
  }

  .custom-gallery__scroll-item .custom-gallery__image {
    height: 160px;
  }

  .custom-gallery__carousel {
    padding: 0 32px;
  }

  .custom-gallery__card {
    flex: 0 0 80%;
  }

  .custom-gallery__arrow {
    width: 36px;
    height: 36px;
  }
}
