/* ============================================================
   Lightbox
   ============================================================ */

/* -- Variables ----------------------------------------------- */
:root {
  --lb-z:          9999;
  --lb-bg:         rgba(0, 0, 0, .92);
  --lb-btn-size:   48px;
  --lb-btn-bg:     rgba(255, 255, 255, .12);
  --lb-btn-hover:  rgba(255, 255, 255, .26);
  --lb-radius:     6px;
  --lb-thumb-w:    62px;
  --lb-thumb-h:    46px;
  --lb-bar-h:      68px;
}

/* -- Overlay ------------------------------------------------- */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: var(--lb-z);
  background: var(--lb-bg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  touch-action: none; /* prevent iOS rubber-band scroll */
  z-index: 99999;
}

.lightbox.hide_ {
  display: none;
}

body.lb_open {
  overflow: hidden;
}

/* -- Top bar ------------------------------------------------- */
.lightbox_top-bar {
  position: relative;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px 70px;
  min-height: 52px;
  flex-shrink: 0;
}

.lightbox_top-bar .img_selector-container {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
  justify-content: center;
}

/* -- Slide wrapper & container ------------------------------- */
.lightbox_wrapper {
  flex: 1 1 0;
  overflow: hidden;
  position: relative;
  min-height: 0; /* fix flex overflow on some browsers */
}

.lightbox_container {
  display: flex;
  width: 100%;
  height: calc(100% - 65px);
  cursor: grab;
  will-change: transform;
}

.lightbox_container.grabbing,
.lightbox_container.grabbing * {
  cursor: grabbing !important;
}

/* -- Individual slides --------------------------------------- */
.lightbox_slide {
  flex: 0 0 100vw;
  width: 100vw;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  user-select: none;
}

.lightbox_slide img {
  display: block;
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  pointer-events: none;
  transform-origin: center center;
  will-change: transform;
  transition: transform .12s ease;
  -webkit-touch-callout: none;
  user-select: none;
}

/* -- Close button -------------------------------------------- */
.lightbox_close {
  position: absolute;
  top: 10px;
  right: 12px;
  z-index: 20;
  width: var(--lb-btn-size);
  height: var(--lb-btn-size);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--lb-btn-bg);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border: 1px solid rgba(255, 255, 255, .15);
  border-radius: var(--lb-radius);
  color: #fff;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  appearance: none;
  outline: none;
  transition: background .2s, transform .15s;
}

.lightbox_close:hover  { background: var(--lb-btn-hover); }
.lightbox_close:active { transform: scale(.92); }

/* -- Prev / Next buttons ------------------------------------- */
.lightbox_prev,
.lightbox_next {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 20;
  width: var(--lb-btn-size);
  height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--lb-btn-bg);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border: 1px solid rgba(255, 255, 255, .15);
  border-radius: var(--lb-radius);
  color: #fff;
  cursor: pointer;
  appearance: none;
  outline: none;
  padding: 0;
  transition: background .2s, opacity .2s, transform .15s;
}

.lightbox_prev { left: 12px; }
.lightbox_next { right: 12px; }

.lightbox_prev:hover,
.lightbox_next:hover { background: var(--lb-btn-hover); }

.lightbox_prev:active { transform: translateY(-50%) scale(.92); }
.lightbox_next:active { transform: translateY(-50%) scale(.92); }

/* Chevron arrows rendered via <span> */
.lightbox_prev span,
.lightbox_next span {
  display: block;
  width: 11px;
  height: 11px;
  border-top: 2.5px solid #fff;
  border-right: 2.5px solid #fff;
  border-radius: 1px;
}

.lightbox_prev span { transform: rotate(-135deg) translate(-2px,  2px); }
.lightbox_next span { transform: rotate(  45deg) translate(-2px,  2px); }

/* -- Thumb bar ----------------------------------------------- */
.lb-thumb-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 10;
  display: flex;
  flex-wrap: nowrap;
  gap: 6px;
  align-items: center;
  height: var(--lb-bar-h);
  padding: 0 14px;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-behavior: smooth;
  scrollbar-width: none;
  background: linear-gradient(transparent, rgba(0, 0, 0, .65));
}

.lb-thumb-bar::-webkit-scrollbar { display: none; }

.lb-thumb {
  flex: 0 0 auto;
  width: var(--lb-thumb-w);
  height: var(--lb-thumb-h);
  object-fit: cover;
  border-radius: 4px;
  cursor: pointer;
  opacity: .45;
  border: 2px solid transparent;
  transition: opacity .2s, border-color .2s, transform .2s;
  -webkit-touch-callout: none;
  user-select: none;
  pointer-events: auto;
}

.lb-thumb:hover {
  opacity: .8;
  transform: translateY(-3px);
}

.lb-thumb--active {
  opacity: 1;
  border-color: #fff;
  transform: translateY(-3px);
}

/* -- Mobile -------------------------------------------------- */
@media (max-width: 768px) {
  :root {
    --lb-thumb-w: 52px;
    --lb-thumb-h: 38px;
    --lb-bar-h:   58px;
  }
}

@media (max-width: 600px) {
  :root {
    --lb-btn-size: 38px;
  }

  .lightbox_prev,
  .lightbox_next {
    height: 60px;
  }

  .lightbox_close { font-size: 15px; }
}

@media (max-width: 380px) {
  .lightbox_prev { left:  4px; }
  .lightbox_next { right: 4px; }

  :root {
    --lb-thumb-w: 44px;
    --lb-thumb-h: 32px;
    --lb-bar-h:   50px;
  }
}
