/* ============================================================
   BT Gallery — Lightbox & Grid Library
   Version: 2.0.0
   ============================================================ */

/* ---- Grid Layout ---- */
.bt-gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 8px;
  width: 100%;
}

.bt-gallery-grid.cols-2 {
  grid-template-columns: repeat(2, 1fr);
}
.bt-gallery-grid.cols-3 {
  grid-template-columns: repeat(3, 1fr);
}
.bt-gallery-grid.cols-4 {
  grid-template-columns: repeat(4, 1fr);
}
.bt-gallery-grid.cols-5 {
  grid-template-columns: repeat(5, 1fr);
}

@media (max-width: 992px) {
  .bt-gallery-grid.cols-4,
  .bt-gallery-grid.cols-5 {
    grid-template-columns: repeat(3, 1fr);
  }
}
@media (max-width: 640px) {
  .bt-gallery-grid,
  .bt-gallery-grid.cols-3,
  .bt-gallery-grid.cols-4,
  .bt-gallery-grid.cols-5 {
    grid-template-columns: repeat(2, 1fr);
  }
}
@media (max-width: 380px) {
  .bt-gallery-grid {
    grid-template-columns: 1fr 1fr;
  }
}

/* ---- Grid Item ---- */
.bt-gallery-item {
  position: relative;
  overflow: hidden;
  border-radius: 6px;
  cursor: pointer;
  aspect-ratio: 4 / 3;
  background: #f0f0f0;
}

.bt-gallery-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  will-change: transform;
}

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

/* ---- Hover Overlay ---- */
.bt-gallery-item .bt-gallery-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    135deg,
    rgba(0, 0, 0, 0.55) 0%,
    rgba(0, 0, 0, 0.2) 100%
  );
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.bt-gallery-item:hover .bt-gallery-overlay {
  opacity: 1;
}

.bt-gallery-overlay .bt-gallery-icon {
  width: 44px;
  height: 44px;
  border: 2px solid rgba(255, 255, 255, 0.9);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 18px;
  transform: scale(0.7);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.bt-gallery-item:hover .bt-gallery-overlay .bt-gallery-icon {
  transform: scale(1);
}

/* ---- Count Badge (last item) ---- */
.bt-gallery-item.bt-gallery-has-more .bt-gallery-more-badge {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.03em;
  gap: 4px;
  transition: background 0.3s;
}

.bt-gallery-item.bt-gallery-has-more:hover .bt-gallery-more-badge {
  background: rgba(0, 0, 0, 0.72);
}

.bt-gallery-more-badge .bt-more-count {
  font-size: 28px;
  line-height: 1;
}
.bt-gallery-more-badge .bt-more-label {
  font-size: 12px;
  font-weight: 400;
  opacity: 0.85;
  letter-spacing: 0.08em;
}

/* ============================================================
   LIGHTBOX
   ============================================================ */
.bt-lightbox-backdrop {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(8, 8, 12, 0.96);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.28s ease;
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}

.bt-lightbox-backdrop.is-open {
  opacity: 1;
  pointer-events: all;
}

/* ---- Main Stage ---- */
.bt-lightbox-stage {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

/* ---- Close Button ---- */
.bt-lightbox-close {
  position: fixed;
  top: 18px;
  right: 22px;
  z-index: 10010;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: #fff;
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition:
    background 0.2s,
    transform 0.2s;
  line-height: 1;
}
.bt-lightbox-close:hover {
  background: rgba(255, 255, 255, 0.22);
  transform: rotate(90deg);
}

/* ---- Counter ---- */
.bt-lightbox-counter {
  position: fixed;
  top: 22px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10010;
  color: rgba(255, 255, 255, 0.75);
  font-size: 13px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0.12em;
  background: rgba(0, 0, 0, 0.35);
  padding: 4px 14px;
  border-radius: 20px;
  pointer-events: none;
}

/* ---- Image Wrapper ---- */
.bt-lightbox-img-wrap {
  position: relative;
  max-width: calc(100vw - 120px);
  max-height: calc(100vh - 160px);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

@media (max-width: 640px) {
  .bt-lightbox-img-wrap {
    max-width: calc(100vw - 20px);
    max-height: calc(100vh - 140px);
  }
}

.bt-lightbox-img-wrap img {
  max-width: 100%;
  max-height: calc(100vh - 160px);
  object-fit: contain;
  border-radius: 4px;
  box-shadow: 0 20px 80px rgba(0, 0, 0, 0.8);
  transition:
    opacity 0.22s ease,
    transform 0.22s ease;
  display: block;
  user-select: none;
}

.bt-lightbox-img-wrap img.bt-img-entering {
  opacity: 0;
  transform: scale(0.96);
}
/* Slide in from right (going forward) */
.bt-lightbox-img-wrap img.bt-img-entering-right {
  opacity: 0;
  transform: translateX(60px) scale(0.97);
}
/* Slide in from left (going backward) */
.bt-lightbox-img-wrap img.bt-img-entering-left {
  opacity: 0;
  transform: translateX(-60px) scale(0.97);
}
.bt-lightbox-img-wrap img.bt-img-visible {
  opacity: 1;
  transform: translateX(0) scale(1);
}
.bt-lightbox-img-wrap img.bt-img-leaving-left {
  opacity: 0;
  transform: translateX(-60px) scale(0.97);
}
.bt-lightbox-img-wrap img.bt-img-leaving-right {
  opacity: 0;
  transform: translateX(60px) scale(0.97);
}

/* ---- Loading Spinner ---- */
.bt-lightbox-spinner {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}
.bt-lightbox-spinner::after {
  content: "";
  width: 36px;
  height: 36px;
  border: 3px solid rgba(255, 255, 255, 0.15);
  border-top-color: rgba(255, 255, 255, 0.8);
  border-radius: 50%;
  animation: bt-spin 0.7s linear infinite;
}
.bt-lightbox-spinner.bt-hidden {
  display: none;
}

@keyframes bt-spin {
  to {
    transform: rotate(360deg);
  }
}

/* ---- Caption ---- */
.bt-lightbox-caption {
  position: fixed;
  bottom: 90px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10010;
  color: rgba(255, 255, 255, 0.8);
  font-size: 13px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  text-align: center;
  max-width: 600px;
  padding: 6px 20px;
  background: rgba(0, 0, 0, 0.4);
  border-radius: 20px;
  pointer-events: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: opacity 0.3s;
}
.bt-lightbox-caption:empty {
  opacity: 0;
}

/* ---- Navigation Arrows ---- */
.bt-lightbox-arrow {
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  z-index: 10010;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #fff;
  font-size: 22px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition:
    background 0.2s,
    transform 0.2s;
  user-select: none;
}
.bt-lightbox-arrow:hover {
  background: rgba(255, 255, 255, 0.22);
}
.bt-lightbox-arrow.bt-arrow-prev {
  left: 16px;
}
.bt-lightbox-arrow.bt-arrow-prev:hover {
  transform: translateY(-50%) translateX(-3px);
}
.bt-lightbox-arrow.bt-arrow-next {
  right: 16px;
}
.bt-lightbox-arrow.bt-arrow-next:hover {
  transform: translateY(-50%) translateX(3px);
}
.bt-lightbox-arrow.bt-hidden {
  display: none;
}

@media (max-width: 640px) {
  .bt-lightbox-arrow {
    width: 38px;
    height: 38px;
    font-size: 16px;
  }
  .bt-lightbox-arrow.bt-arrow-prev {
    left: 6px;
  }
  .bt-lightbox-arrow.bt-arrow-next {
    right: 6px;
  }
}

/* ---- Thumbnail Strip ---- */
.bt-lightbox-thumbs {
  position: fixed;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10010;
  display: flex;
  gap: 6px;
  max-width: calc(100vw - 40px);
  overflow-x: auto;
  padding: 6px 10px;
  background: rgba(0, 0, 0, 0.45);
  border-radius: 30px;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.bt-lightbox-thumbs::-webkit-scrollbar {
  display: none;
}

.bt-lightbox-thumb {
  flex: 0 0 auto;
  width: 46px;
  height: 34px;
  border-radius: 4px;
  overflow: hidden;
  cursor: pointer;
  opacity: 0.5;
  transition:
    opacity 0.2s,
    transform 0.2s,
    box-shadow 0.2s;
  border: 2px solid transparent;
}
.bt-lightbox-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  pointer-events: none;
}
.bt-lightbox-thumb:hover {
  opacity: 0.85;
  transform: scale(1.08);
}
.bt-lightbox-thumb.is-active {
  opacity: 1;
  border-color: rgba(255, 255, 255, 0.85);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.6);
  transform: scale(1.1);
}

/* Hide thumbs if only 1 image */
.bt-lightbox-thumbs.bt-single {
  display: none;
}

/* ---- Keyboard hint ---- */
.bt-lightbox-hint {
  position: fixed;
  bottom: 70px;
  right: 20px;
  color: rgba(255, 255, 255, 0.3);
  font-size: 11px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0.05em;
  pointer-events: none;
}
@media (max-width: 640px) {
  .bt-lightbox-hint {
    display: none;
  }
}

/* ---- Swipe indicator (mobile) ---- */
.bt-lightbox-swipe-hint {
  display: none;
  position: fixed;
  bottom: 70px;
  left: 50%;
  transform: translateX(-50%);
  color: rgba(255, 255, 255, 0.35);
  font-size: 11px;
  letter-spacing: 0.06em;
  pointer-events: none;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
@media (max-width: 640px) {
  .bt-lightbox-swipe-hint {
    display: block;
  }
}
