.tp-gallery__section {
  margin-bottom: 2rem;
}

.tp-gallery__title {
  margin: 1rem 0.5rem;
  padding: 0.25rem;
  background-color: #c1272d;
  text-align: center;
}

.tp-gallery__grid {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 1rem;
}

.tp-gallery__item {
  position: relative;
  display: block;
  flex: 0 0 auto;
  cursor: zoom-in;
}

.tp-gallery__thumb {
  display: block;
  width: auto;
  height: 80px;
  border: 0;
}

.tp-gallery__caption {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 0.45rem);
  z-index: 20;
  width: max-content;
  max-width: min(260px, 78vw);
  padding: 0.4rem 0.55rem;
  border-radius: 0.35rem;
  background: rgba(18, 18, 18, 0.92);
  color: #fff;
  font-size: 0.72rem;
  line-height: 1.3;
  text-align: left;
  white-space: normal;
  opacity: 0;
  visibility: hidden;
  transform: translate(-50%, 0.2rem);
  transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s ease;
  pointer-events: none;
  box-shadow: 0 0.2rem 0.65rem rgba(0, 0, 0, 0.32);
}

@media (hover: hover) and (pointer: fine) {
  .tp-gallery__item:hover .tp-gallery__caption,
  .tp-gallery__item:focus-visible .tp-gallery__caption {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, 0);
  }
}

@media (hover: none), (pointer: coarse) {
  .tp-gallery__caption {
    display: none;
  }
}

.tp-gallery__item:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 3px;
}

.tp-lightbox {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(0, 0, 0, 0.9);
}

.tp-lightbox.is-open {
  display: flex;
}

.tp-lightbox__dialog {
  position: relative;
  display: flex;
  width: min(100%, 1100px);
  max-height: calc(100vh - 2rem);
  flex-direction: column;
  align-items: center;
}

.tp-lightbox__image {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: calc(100vh - 8rem);
  object-fit: contain;
  background: #111;
}

.tp-lightbox__caption {
  box-sizing: border-box;
  width: 100%;
  max-width: 900px;
  margin-top: 0.65rem;
  padding: 0.65rem 0.8rem;
  border-radius: 0.4rem;
  background: rgba(18, 18, 18, 0.96);
  color: #fff;
  font-size: 0.92rem;
  line-height: 1.45;
  text-align: center;
}

.tp-lightbox__close {
  position: absolute;
  top: -0.55rem;
  right: -0.35rem;
  z-index: 2;
  width: 2.5rem;
  height: 2.5rem;
  border: 0;
  border-radius: 50%;
  background: rgba(20, 20, 20, 0.88);
  color: #fff;
  font-size: 1.65rem;
  line-height: 1;
  cursor: pointer;
}

.tp-lightbox__close:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

body.tp-lightbox-open {
  overflow: hidden;
}

@media (max-width: 600px) {
  .tp-gallery__grid {
    gap: 0.65rem;
  }

  .tp-gallery__thumb {
    height: 74px;
  }

  .tp-lightbox {
    padding: 0.5rem;
  }

  .tp-lightbox__dialog {
    width: 100%;
    max-height: calc(100dvh - 1rem);
  }

  .tp-lightbox__image {
    max-height: calc(100dvh - 7.5rem);
  }

  .tp-lightbox__caption {
    max-height: 5.8rem;
    margin-top: 0.45rem;
    padding: 0.55rem 0.65rem;
    overflow-y: auto;
    font-size: 0.84rem;
    line-height: 1.4;
    text-align: left;
  }

  .tp-lightbox__close {
    top: 0.25rem;
    right: 0.25rem;
    width: 2.35rem;
    height: 2.35rem;
    background: rgba(0, 0, 0, 0.72);
  }
}
