/* 2025-10-31 17:40, working version, updates from previous versions: */

/* mobile thumb transition from inactive to active is smooth */
/* teaked thumbbar animation, smooth without flash on mobile */
/* added swiping down to exit for mobile */
/* prev, next & close icons for cursor are now png with baked in shadow effect */
/* added animation to caption */

:root {
  --lb-gap: 16px;
  --lb-gap-mobile: 5px;
  --lb-gap-top: 20px;
  --lb-fit: 90vh;
  --lb-fitw: 90vw;
  --lb-anim: 200ms;
  --lb-ease: cubic-bezier(.4,.22,.35,1);
  --lb-thumb-h: 72px;
  --lb-space-stage-thumbs: 20px;
  --lb-caption-h: 20px;
  --lb-thumb-delay-start: 50ms;
  /* first thumb delay */
  --lb-thumb-delay-gap: 55ms;
  /* gap per thumb */
  --lb-thumb-dur: 200ms;
  --lb-thumb-ease: var(--lb-ease, ease);
}

/* Overlay & fade */
.lb-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .95);
  z-index: 9999;
  display: none;
  opacity: 0;
  transform: scale(.76);
  transition: opacity var(--lb-anim) var(--lb-ease), transform var(--lb-anim) var(--lb-ease);
}

.lb-overlay.lb-open {
  display: block;
  opacity: 1;
  transform: scale(1);
}

.lb-overlay.lb-no-fade {
  transition: none !important;
}

/* Stage area (reserves space for thumbs) */
.lb-stage {
  position: absolute;
  left: var(--lb-gap);
  right: var(--lb-gap);
  top: var(--lb-gap-top);
  bottom: calc(var(--lb-gap) + var(--lb-thumb-h) + var(--lb-space-stage-thumbs) + var(--lb-caption-h));
  display: grid;
  place-items: center;
  overflow: hidden;
}

.lb-stage-inner {
  position: relative;
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  overflow: hidden;
  contain: layout paint;
}

/* Image */
.lb-img {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(.97);
  opacity: 0;
  max-width: min(100%, var(--lb-fitw));
  max-height: 100%;
  object-fit: contain;
  transition: opacity var(--lb-anim) var(--lb-ease), transform var(--lb-anim) var(--lb-ease);
  user-select: none;
  -webkit-user-drag: none;
  -webkit-touch-callout: none;
  will-change: transform, opacity;
  backface-visibility: hidden;
}

.lb-img.lb-active {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

/* Close */
.lb-close {
  position: absolute;
  right: 12px;
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  z-index: 2;
  cursor: pointer;
  text-decoration: none;
}

.lb-close::before,
.lb-close::after {
  content: "";
  position: absolute;
  width: 20px;
  height: 2px;
  background: #fff;
  border-radius: 1px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .6);
}

.lb-close::before {
  transform: rotate(45deg);
}

.lb-close::after {
  transform: rotate(-45deg);
}

/* Counter & caption */
.lb-counter {
  position: absolute;
  left: 12px;
  top: 10px;
  color: var(--text-lightGrey-color);
  font-size: .9rem;
  z-index: 3;
  text-shadow: 0 0 5px rgba(0,0,0,0.6);
}

.lb-caption {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(var(--lb-thumb-h) + var(--lb-space-stage-thumbs));
  color: var(--text-lightGrey-color);
  background: rgba(0, 0, 0, .5);
  text-align: center;
  padding: 6px 12px;
  font-size: .95rem;
  transform-origin: center bottom;
  will-change: transform, opacity;
}

/* Thumbs */
.lb-thumbbar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: var(--lb-gap);
  z-index: 1;
  background: linear-gradient(to top, rgba(0, 0, 0, .45), transparent);
  transform-origin: center top; 
  will-change: transform, opacity;
}

.lb-thumbs {
  display: flex;
  gap: 8px;
  list-style: none;
  margin: 0;
  padding: 8px 12px;
  overflow-x: auto;
  scroll-behavior: smooth;
  justify-content: center;
}

.lb-thumbs::-webkit-scrollbar {
  height: 8px;
}

.lb-thumbs::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, .25);
  border-radius: 4px;
}

.lb-thumbs li {
  flex: 0 0 auto;
}

.lb-thumbs img {
  height: calc(var(--lb-thumb-h) - 8px);
  width: auto;
  display: block;
  border-radius: 4px;
  opacity: .78;
  transition: opacity 180ms var(--lb-ease), box-shadow 180ms var(--lb-ease);
  box-shadow: 0 0 0 2px rgba(255,255,255,0); /* start with transparent ring */
  will-change: opacity, box-shadow;
  transform: translateZ(0);
  backface-visibility: hidden;
}

.lb-thumbs li.lb-active img {
  opacity: 1;
  box-shadow: 0 0 0 2px #fff;
}

/* Keep hover only for real pointers (desktop) */
@media (hover: hover) and (pointer: fine) {
  .lb-thumbs img:hover {
    opacity: 1;
    box-shadow: 0 0 0 2px #fff;
  }
}

/* Remove iOS/Android tap highlight flash */
.lb-thumbs a { -webkit-tap-highlight-color: transparent; }

/* Stagger keyframes */
@keyframes lbThumbIn {
  from {
    opacity: 0;
    transform: translateX(10px) scale(.96);
  }

  to {
    opacity: 1;
    transform: none;
  }
}

.lb-thumbs.lb-anim>li {
  animation: lbThumbIn var(--lb-thumb-dur) var(--lb-thumb-ease) both;
  animation-delay: calc(var(--lb-thumb-delay-start) + var(--lb-thumb-delay-gap) * var(--i, 0));
}

@media (prefers-reduced-motion: reduce) {
  :root {
    --lb-anim: 0ms;
  }

  .lb-overlay,
  .lb-img,
  .lb-thumbs>li {
    transition-duration: 50ms !important;
  }
}

/* Cursor hints */
.lb-overlay {
  cursor: default;
}

.lb-overlay .lb-stage-inner,
.lb-overlay .lb-stage,
.lb-overlay .lb-caption,
.lb-overlay .lb-thumbbar,
.lb-overlay .lb-thumbs,
.lb-overlay .lb-thumbs * {
  cursor: inherit;
}

.lb-close,
.lb-thumbs a {
  cursor: pointer;
}

.lb-cursor-prev {
  cursor: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='28' height='28' viewBox='0 0 14 24'><path d='M9.5 3.5L2.5 12l7 8.5' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/></svg>") 6 14, w-resize;
}

.lb-cursor-next {
  cursor: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='28' height='28' viewBox='0 0 14 24'><path d='M4.5 3.5L11.5 12l-7 8.5' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/></svg>") 22 14, e-resize;
}

.lb-cursor-close {
  cursor: url("../img/icons/cls.png") 16 16, w-resize;
}

/* 1× default */
.lb-overlay.lb-cursor-prev {
  cursor: url("../img/icons/prv.png") 10 16, w-resize;
}

.lb-overlay.lb-cursor-next {
  cursor: url("../img/icons/nxt.png") 22 16, e-resize;
}

.lb-overlay.lb-cursor-close {
  cursor: url("../img/icons/cls.png") 16 16, pointer;
}

/* Keep default cursor on caption/thumbbar */
.lb-thumbbar,
.lb-thumbbar *,
.lb-caption {
  cursor: auto !important;
}

/* drag-to-dismiss state */
.lb-overlay.lb-dragging { transition: none !important; }
.lb-overlay.lb-dragging .lb-img { transition: none !important; }
.lb-overlay.lb-dragging .lb-thumbbar { transition: none !important; }
.lb-overlay.lb-dragging .lb-caption { transition: none !important; }

/* Mobile tweaks */
@media (max-width: 640px) {
  .lb-thumbs {
    justify-content: flex-start;
  }
}

/* Scope mobile variable overrides to the overlay so they beat :root and inline */
@media (max-width: 480px) {
  .lb-overlay {
    --lb-thumb-h: 60px;
    /* smaller thumbs on phones */
    --lb-fit: 95vh;
    --lb-fitw: 95vw;
  }

  .lb-stage {
    left: var(--lb-gap-mobile);
    right: var(--lb-gap-mobile);
  }
}