.tpg-gallery,
.tpg-gallery * {
  box-sizing: border-box;
}

.tpg-gallery {
  --tpg-blue: #075bd8;
  --tpg-light-blue: #00a9ff;
  --tpg-dark-blue: #031c4c;
  --tpg-white: #fff;
  --tpg-columns: 3;
  width: 100%;
  font-family: "Poppins", Arial, sans-serif;
}

.tpg-gallery__filters {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
  margin: 0 0 32px;
}

.tpg-gallery__filter {
  min-height: 42px;
  padding: 9px 18px;
  color: var(--tpg-dark-blue);
  border: 1px solid #d5e4f6;
  border-radius: 999px;
  background: var(--tpg-white);
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: .25s ease;
}

.tpg-gallery__filter:hover,
.tpg-gallery__filter.is-active {
  color: var(--tpg-white);
  border-color: var(--tpg-blue);
  background: linear-gradient(135deg, var(--tpg-blue), var(--tpg-light-blue));
  box-shadow: 0 9px 22px rgba(7, 91, 216, .2);
  transform: translateY(-2px);
}

.tpg-gallery__grid {
  display: grid;
  grid-template-columns: repeat(var(--tpg-columns), minmax(0, 1fr));
  gap: 22px;
}

.tpg-gallery__item {
  overflow: hidden;
  margin: 0;
  border: 1px solid #dce8f5;
  border-radius: 12px;
  background: var(--tpg-white);
  box-shadow: 0 14px 36px rgba(3, 28, 76, .09);
  animation: tpgFadeIn .35s ease both;
}

.tpg-gallery__item[hidden] {
  display: none !important;
}

.tpg-gallery__open {
  position: relative;
  overflow: hidden;
  width: 100%;
  height: 280px;
  display: block;
  padding: 0;
  border: 0;
  background: #dceaff;
  cursor: zoom-in;
}

.tpg-gallery__image {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  transition: transform .5s ease;
}

.tpg-gallery__video-preview {
  background: #07172d;
}

.tpg-gallery__overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--tpg-white);
  background: linear-gradient(180deg, rgba(3, 28, 76, .06), rgba(3, 28, 76, .72));
  opacity: 0;
  transition: opacity .3s ease;
}

.tpg-gallery__overlay svg {
  width: 52px;
  height: 52px;
  padding: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  border: 1px solid rgba(255, 255, 255, .7);
  border-radius: 50%;
  background: rgba(7, 91, 216, .75);
  transform: scale(.75);
  transition: transform .3s ease;
}

.tpg-gallery__open:hover .tpg-gallery__image,
.tpg-gallery__open:focus-visible .tpg-gallery__image {
  transform: scale(1.07);
}

.tpg-gallery__open:hover .tpg-gallery__overlay,
.tpg-gallery__open:focus-visible .tpg-gallery__overlay {
  opacity: 1;
}

.tpg-gallery__open:hover .tpg-gallery__overlay svg,
.tpg-gallery__open:focus-visible .tpg-gallery__overlay svg {
  transform: scale(1);
}

.tpg-gallery figcaption {
  padding: 15px 18px;
  color: #46566c;
  font-size: 13px;
  line-height: 1.5;
  font-weight: 600;
}

.tpg-lightbox[hidden] {
  display: none !important;
}

.tpg-lightbox {
  position: fixed;
  z-index: 999999;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 28px;
}

.tpg-lightbox__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(1, 12, 34, .94);
  backdrop-filter: blur(8px);
}

.tpg-lightbox__content {
  position: relative;
  z-index: 2;
  width: min(1180px, 100%);
  height: min(86vh, 820px);
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr) 58px;
  align-items: center;
  gap: 12px;
}

.tpg-lightbox__stage {
  min-width: 0;
  max-height: 86vh;
  display: grid;
  justify-items: center;
  gap: 13px;
}

.tpg-lightbox__image,
.tpg-lightbox__video {
  max-width: 100%;
  max-height: calc(86vh - 55px);
  display: block;
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, .42);
}

.tpg-lightbox__video {
  width: auto;
  min-width: min(760px, 100%);
  background: #000;
}

.tpg-lightbox__image[hidden],
.tpg-lightbox__video[hidden] {
  display: none !important;
}

.tpg-lightbox__caption {
  margin: 0;
  color: rgba(255, 255, 255, .82);
  font-size: 13px;
  line-height: 1.5;
  text-align: center;
}

.tpg-lightbox__close,
.tpg-lightbox__nav {
  display: grid;
  place-items: center;
  color: var(--tpg-white);
  border: 1px solid rgba(255, 255, 255, .28);
  background: rgba(255, 255, 255, .08);
  cursor: pointer;
  transition: .2s ease;
}

.tpg-lightbox__close:hover,
.tpg-lightbox__nav:hover {
  border-color: var(--tpg-light-blue);
  background: var(--tpg-blue);
}

.tpg-lightbox__close {
  position: absolute;
  z-index: 4;
  top: -8px;
  right: 0;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  font-size: 30px;
  line-height: 1;
}

.tpg-lightbox__nav {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  font-size: 38px;
}

.tpg-lightbox-open {
  overflow: hidden;
}

.tpg-empty {
  padding: 20px;
  color: #536074;
  border: 1px dashed #c5d6ea;
  border-radius: 8px;
  background: #f5f9ff;
}

@keyframes tpgFadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 1024px) {
  .tpg-gallery__grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 767px) {
  .tpg-gallery__filters {
    justify-content: flex-start;
    overflow-x: auto;
    flex-wrap: nowrap;
    padding: 0 0 8px;
  }

  .tpg-gallery__filter {
    flex: 0 0 auto;
  }

  .tpg-gallery__grid {
    grid-template-columns: 1fr;
    gap: 17px;
  }

  .tpg-gallery__open {
    height: 245px;
  }

  .tpg-lightbox {
    padding: 14px;
  }

  .tpg-lightbox__content {
    height: 90vh;
    grid-template-columns: 44px minmax(0, 1fr) 44px;
    gap: 5px;
  }

  .tpg-lightbox__nav {
    width: 40px;
    height: 40px;
    font-size: 30px;
  }

  .tpg-lightbox__close {
    top: 8px;
    width: 40px;
    height: 40px;
  }
}

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