/**
 * Petsure Lightbox — Custom Image Lightbox Styles
 *
 * Replaces Elementor's built-in lightbox with a themed overlay
 * matching the video modal's animation quality and the petsure
 * design system (CSS custom properties).
 *
 * @package Petsure_Core
 */

/* ============================================================ */
/*  OVERLAY                                                     */
/* ============================================================ */

.petsure-lightbox-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.88);
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.45s ease, visibility 0.45s ease;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.petsure-lightbox-overlay.petsure-lightbox-open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

/* ── Init hidden (prevents flash) ── */
.petsure-lightbox-init {
  display: none !important;
}

/* ============================================================ */
/*  CONTENT WRAPPER                                             */
/* ============================================================ */

.petsure-lightbox-content {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 90vw;
  max-width: 1200px;
  max-height: 90vh;
  transform: scale(0.88) translateY(30px);
  transition: transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.petsure-lightbox-open .petsure-lightbox-content {
  transform: scale(1) translateY(0);
}

/* Fullscreen: content fills viewport */
.petsure-lightbox-fullscreen-active .petsure-lightbox-content {
  width: 100vw;
  max-width: 100vw;
  max-height: 100vh;
  height: 100vh;
}

/* ============================================================ */
/*  TOOLBAR (top-right buttons)                                 */
/* ============================================================ */

.petsure-lightbox-toolbar {
  position: absolute;
  top: -48px;
  right: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  z-index: 20;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.petsure-lightbox-open .petsure-lightbox-toolbar {
  animation: petsure-lightbox-toolbar-in 0.4s ease 0.25s forwards;
}

@keyframes petsure-lightbox-toolbar-in {
  to {
    opacity: 1;
  }
}

.petsure-lightbox-toolbar-btn {
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: none;
  background: rgba(0, 0, 0, 0.25);
  color: var(--petsure-white);
  cursor: pointer;
  transition: background 0.25s ease, transform 0.25s ease;
  padding: 0;
  opacity: 0;
  transform: scale(0.5) translateY(-8px);
}

.petsure-lightbox-open .petsure-lightbox-toolbar-btn {
  animation: petsure-lightbox-tbtn-in 0.35s ease forwards;
}

.petsure-lightbox-open .petsure-lightbox-toolbar-btn:nth-child(1) {
  animation-delay: 0.12s;
}

.petsure-lightbox-open .petsure-lightbox-toolbar-btn:nth-child(2) {
  animation-delay: 0.18s;
}

@keyframes petsure-lightbox-tbtn-in {
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.petsure-lightbox-toolbar-btn:hover {
  background: rgba(255, 255, 255, 0.25);
  transform: scale(1.15);
}

.petsure-lightbox-toolbar-btn:active {
  transform: scale(0.9);
}

.petsure-lightbox-toolbar-btn svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
}

/*
 * In the default (non-fullscreen) state the dialog is 90vw/90vh, so
 * the toolbar and nav buttons can sit in the surrounding margin using
 * negative offsets. In fullscreen the content fills the entire
 * viewport (100vw/100vh) and that margin no longer exists, so those
 * negative offsets would push the controls off-screen. Bring them
 * back inside the visible area.
 */
.petsure-lightbox-fullscreen-active .petsure-lightbox-toolbar {
  top: 16px;
  right: 16px;
}

/* ============================================================ */
/*  NAVIGATION BUTTONS (prev / next)                            */
/* ============================================================ */

.petsure-lightbox-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.1);
  color: var(--petsure-white);
  cursor: pointer;
  z-index: 10;
  transition: background 0.3s ease, transform 0.3s ease, opacity 0.3s ease;
  padding: 0;
  opacity: 0;
}

.petsure-lightbox-open .petsure-lightbox-nav {
  opacity: 1;
  transition: background 0.3s ease, transform 0.3s ease, opacity 0.4s ease 0.3s;
}

.petsure-lightbox-nav:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: translateY(-50%) scale(1.1);
}

.petsure-lightbox-nav:active {
  transform: translateY(-50%) scale(0.9);
}

.petsure-lightbox-prev {
  left: -56px;
}

.petsure-lightbox-next {
  right: -56px;
}

.petsure-lightbox-nav svg {
  width: 22px;
  height: 22px;
  stroke: currentColor;
}

/* Same reasoning as the toolbar above: no exterior margin in fullscreen. */
.petsure-lightbox-fullscreen-active .petsure-lightbox-prev {
  left: 16px;
}

.petsure-lightbox-fullscreen-active .petsure-lightbox-next {
  right: 16px;
}

/* ============================================================ */
/*  IMAGE STAGE (stage around wrap for slide transitions)       */
/* ============================================================ */

.petsure-lightbox-image-stage {
  position: relative;
  width: 100%;
  height: 80vh;
  overflow: hidden;
  border-radius: 12px;
}

/* ============================================================ */
/*  IMAGE WRAPPER & IMG                                         */
/* ============================================================ */

.petsure-lightbox-image-wrap {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  overflow: hidden;
  border-radius: 12px;
  transition: transform 0.35s cubic-bezier(0.55, 0, 0.1, 1), opacity 0.35s ease;
}

.petsure-lightbox-fullscreen-active .petsure-lightbox-image-stage,
.petsure-lightbox-fullscreen-active .petsure-lightbox-image-wrap {
  height: calc(100vh - 100px);
  border-radius: 0;
}

/*
 * `max-width`/`max-height: 100%` combined with `width`/`height: auto`
 * is the robust way to scale an image down to fit both axes of its
 * container without distortion. It only works because the stage and
 * wrap above now have a real `height` (not just `max-height`), which
 * gives these percentages something concrete to resolve against.
 */
.petsure-lightbox-img {
  display: block;
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 12px;
  transition: opacity 0.35s ease, transform 0.25s ease;
  opacity: 1;
  transform-origin: center center;
  background: rgba(0, 0, 0, 0.3);
}

/* Loading state (blur placeholder until full image loads) */
.petsure-lightbox-loading {
  opacity: 0.3;
  filter: blur(20px);
}

/* ============================================================ */
/*  SLIDE TRANSITIONS                                           */
/* ============================================================ */

/* Hidden state used during swap (no inline styles, no transition) */
.petsure-lightbox-slide-hidden {
  opacity: 0 !important;
  transform: none !important;
  transition: none !important;
}

/* Slide out to the left (going to next image) */
.petsure-lightbox-slide-out.petsure-lightbox-slide-left {
  transform: translateX(-60px);
  opacity: 0;
}

/* Slide out to the right (going to previous image) */
.petsure-lightbox-slide-out.petsure-lightbox-slide-right {
  transform: translateX(60px);
  opacity: 0;
}

/* Slide in from the right (new image when going next) */
.petsure-lightbox-slide-in {
  animation: petsure-lightbox-slide-in-from-right 0.35s cubic-bezier(0.55, 0, 0.1, 1) forwards;
}

@keyframes petsure-lightbox-slide-in-from-right {
  from {
    transform: translateX(60px);
    opacity: 0;
  }

  to {
    transform: translateX(0);
    opacity: 1;
  }
}

/* ============================================================ */
/*  FOOTER: CAPTION + COUNTER                                   */
/* ============================================================ */

.petsure-lightbox-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 14px 50px;
  gap: 16px;
}

.petsure-lightbox-caption {
  font-size: 14px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.85);
  line-height: 1.4;
  text-align: left;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.petsure-lightbox-counter {
  font-size: 13px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.5);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  letter-spacing: 0.5px;
}

/* ============================================================ */
/*  RESPONSIVE                                                  */
/* ============================================================ */

@media (max-width: 767px) {
  .petsure-lightbox-content {
    width: 94vw;
  }

  .petsure-lightbox-toolbar {
    top: -44px;
    gap: 4px;
  }

  .petsure-lightbox-toolbar-btn {
    width: 34px;
    height: 34px;
  }

  .petsure-lightbox-toolbar-btn svg {
    width: 16px;
    height: 16px;
  }

  .petsure-lightbox-nav {
    width: 36px;
    height: 36px;
  }

  .petsure-lightbox-prev {
    left: 6px;
  }

  .petsure-lightbox-next {
    right: 6px;
  }

  .petsure-lightbox-caption {
    font-size: 12px;
  }

  .petsure-lightbox-counter {
    font-size: 11px;
  }
}