/* ============================================
   TANGLE-ME PHOTO LIGHTBOX
   Standalone modal viewer with swipe + arrows
   ============================================ */

/* Overlay */
.tl-overlay {
  position: fixed;
  inset: 0;
  z-index: 99999;
  background: rgba(0, 0, 0, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0.25s ease;
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.tl-overlay.tl-active {
  opacity: 1;
  visibility: visible;
}

/* Top bar: counter + close */
.tl-topbar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  z-index: 3;
  background: linear-gradient(to bottom, rgba(0,0,0,0.5) 0%, transparent 100%);
}

.tl-counter {
  color: #fff;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-shadow: 0 1px 3px rgba(0,0,0,0.6);
}

.tl-close {
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  background: rgba(255,255,255,0.15);
  color: #fff;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
  -webkit-tap-highlight-color: transparent;
}

.tl-close:hover {
  background: rgba(255,255,255,0.3);
}

/* Image container */
.tl-track {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  overflow: hidden;
}

.tl-slider {
  display: flex;
  transition: transform 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  will-change: transform;
  height: 100%;
  align-items: center;
  /* Ensure slider starts at left edge — translateX controls position */
  margin: 0;
  padding: 0;
  position: relative;
  left: 0;
}

.tl-slider.tl-dragging {
  transition: none;
}

.tl-slide {
  flex: 0 0 100vw;
  width: 100vw;
  min-width: 100vw;
  max-width: 100vw;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 60px 16px 80px;
  box-sizing: border-box;
}

.tl-slide img {
  max-width: calc(100vw - 32px);
  max-height: calc(100vh - 160px);
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 4px;
  display: block;
  margin: 0 auto;
  /* Quality rendering hints */
  image-rendering: -webkit-optimize-contrast;
  image-rendering: high-quality;
  /* Smooth scaling */
  transform: translateZ(0);
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
}

/* Loading spinner per slide */
.tl-slide .tl-loader {
  position: absolute;
  width: 32px;
  height: 32px;
  border: 3px solid rgba(255,255,255,0.15);
  border-top-color: #fff;
  border-radius: 50%;
  animation: tl-spin 0.7s linear infinite;
}

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

/* Desktop arrow buttons */
.tl-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 3;
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 50%;
  background: rgba(255,255,255,0.12);
  color: #fff;
  font-size: 20px;
  cursor: pointer;
  display: none; /* hidden on mobile */
  align-items: center;
  justify-content: center;
  transition: background 0.2s, transform 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.tl-arrow:hover {
  background: rgba(255,255,255,0.25);
  transform: translateY(-50%) scale(1.08);
}

.tl-arrow:active {
  transform: translateY(-50%) scale(0.95);
}

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

.tl-arrow svg {
  width: 20px;
  height: 20px;
  stroke: #fff;
  stroke-width: 2.5;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Dot indicators */
.tl-dots {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 8px;
  z-index: 3;
}

.tl-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: rgba(255,255,255,0.35);
  transition: background 0.25s, transform 0.25s;
  cursor: pointer;
}

.tl-dot.tl-dot-active {
  background: #fff;
  transform: scale(1.3);
}

/* When there are many dots (>8), use a pill style for active */
.tl-dots.tl-dots-many .tl-dot {
  width: 5px;
  height: 5px;
}
.tl-dots.tl-dots-many .tl-dot.tl-dot-active {
  width: 16px;
  border-radius: 4px;
  transform: scale(1);
}

/* Desktop: show arrows, wider padding */
@media (min-width: 769px) {
  .tl-arrow {
    display: flex;
  }
  .tl-slide {
    padding: 60px 60px 80px;
  }
  .tl-slide img {
    max-width: calc(100vw - 120px);
    max-height: calc(100vh - 160px);
  }
}

/* Prevent body scroll when lightbox open */
body.tl-noscroll {
  overflow: hidden !important;
  position: fixed;
  width: 100%;
}
