/* ==========================================================================
   LIGHTBOX.CSS - Dorys Janitorial Cleaning Services
   Image Gallery Lightbox with Close Button
   ========================================================================== */

/* --------------------------------------------------------------------------
   Lightbox Container
   -------------------------------------------------------------------------- */
.lightbox {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: var(--z-modal);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--transition-base), visibility var(--transition-base);
}

.lightbox.is-open {
  opacity: 1;
  visibility: visible;
}

/* --------------------------------------------------------------------------
   Lightbox Overlay
   -------------------------------------------------------------------------- */
.lightbox__overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.95);
  cursor: pointer;
}

/* --------------------------------------------------------------------------
   Lightbox Content Container
   -------------------------------------------------------------------------- */
.lightbox__container {
  position: relative;
  max-width: 90vw;
  max-height: 90vh;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* --------------------------------------------------------------------------
   Lightbox Image
   -------------------------------------------------------------------------- */
.lightbox__image-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lightbox__image {
  max-width: 90vw;
  max-height: 80vh;
  object-fit: contain;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-2xl);
  opacity: 0;
  transform: scale(0.9);
  transition: opacity var(--transition-base), transform var(--transition-base);
}

.lightbox.is-open .lightbox__image {
  opacity: 1;
  transform: scale(1);
}

/* Loading spinner */
.lightbox__loader {
  position: absolute;
  width: 50px;
  height: 50px;
  border: 3px solid rgba(255, 255, 255, 0.2);
  border-top-color: var(--color-primary);
  border-radius: var(--radius-full);
  animation: spin 1s linear infinite;
}

.lightbox__image.is-loaded + .lightbox__loader {
  display: none;
}

/* --------------------------------------------------------------------------
   Lightbox Caption
   -------------------------------------------------------------------------- */
.lightbox__caption {
  margin-top: var(--space-lg);
  padding: var(--space-md) var(--space-xl);
  background-color: rgba(0, 0, 0, 0.7);
  border-radius: var(--radius-md);
  color: var(--color-text-white);
  text-align: center;
  max-width: 600px;
}

.lightbox__caption:empty {
  display: none;
}

.lightbox__caption-title {
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-semibold);
  margin-bottom: var(--space-xs);
}

.lightbox__caption-text {
  font-size: var(--font-size-sm);
  opacity: 0.9;
}

/* --------------------------------------------------------------------------
   Lightbox Close Button
   -------------------------------------------------------------------------- */
.lightbox__close {
  position: absolute;
  top: var(--space-lg);
  right: var(--space-lg);
  width: 50px;
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: rgba(255, 255, 255, 0.1);
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: var(--radius-full);
  color: var(--color-text-white);
  font-size: var(--font-size-2xl);
  cursor: pointer;
  transition: all var(--transition-base);
  z-index: 10;
}

.lightbox__close:hover {
  background-color: var(--color-danger);
  border-color: var(--color-danger);
  transform: rotate(90deg);
}

.lightbox__close::before,
.lightbox__close::after {
  content: '';
  position: absolute;
  width: 24px;
  height: 3px;
  background-color: currentColor;
  border-radius: var(--radius-full);
}

.lightbox__close::before {
  transform: rotate(45deg);
}

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

/* --------------------------------------------------------------------------
   Navigation Arrows
   -------------------------------------------------------------------------- */
.lightbox__nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 50px;
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: rgba(255, 255, 255, 0.1);
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: var(--radius-full);
  color: var(--color-text-white);
  cursor: pointer;
  transition: all var(--transition-base);
  z-index: 10;
}

.lightbox__nav:hover {
  background-color: var(--color-primary);
  border-color: var(--color-primary);
}

.lightbox__nav:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.lightbox__nav--prev {
  left: var(--space-lg);
}

.lightbox__nav--next {
  right: var(--space-lg);
}

.lightbox__nav svg {
  width: 24px;
  height: 24px;
}

/* Arrow icons using CSS */
.lightbox__nav--prev::before {
  content: '';
  width: 12px;
  height: 12px;
  border-left: 3px solid currentColor;
  border-bottom: 3px solid currentColor;
  transform: rotate(45deg);
  margin-left: 4px;
}

.lightbox__nav--next::before {
  content: '';
  width: 12px;
  height: 12px;
  border-right: 3px solid currentColor;
  border-top: 3px solid currentColor;
  transform: rotate(45deg);
  margin-right: 4px;
}

/* --------------------------------------------------------------------------
   Image Counter
   -------------------------------------------------------------------------- */
.lightbox__counter {
  position: absolute;
  bottom: var(--space-lg);
  left: 50%;
  transform: translateX(-50%);
  padding: var(--space-sm) var(--space-lg);
  background-color: rgba(0, 0, 0, 0.7);
  border-radius: var(--radius-full);
  color: var(--color-text-white);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  z-index: 10;
}

/* --------------------------------------------------------------------------
   Thumbnails Strip
   -------------------------------------------------------------------------- */
.lightbox__thumbnails {
  position: absolute;
  bottom: var(--space-xl);
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: var(--space-sm);
  padding: var(--space-sm);
  background-color: rgba(0, 0, 0, 0.7);
  border-radius: var(--radius-lg);
  max-width: 90vw;
  overflow-x: auto;
  z-index: 10;
}

.lightbox__thumbnail {
  width: 60px;
  height: 60px;
  flex-shrink: 0;
  border-radius: var(--radius-sm);
  overflow: hidden;
  cursor: pointer;
  opacity: 0.5;
  transition: opacity var(--transition-fast), transform var(--transition-fast);
  border: 2px solid transparent;
}

.lightbox__thumbnail:hover {
  opacity: 0.8;
}

.lightbox__thumbnail.is-active {
  opacity: 1;
  border-color: var(--color-primary);
  transform: scale(1.1);
}

.lightbox__thumbnail img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* --------------------------------------------------------------------------
   Gallery Grid (Trigger Images)
   -------------------------------------------------------------------------- */
.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--space-lg);
}

.gallery__item {
  position: relative;
  border-radius: var(--radius-lg);
  overflow: hidden;
  cursor: pointer;
  aspect-ratio: 4 / 3;
}

.gallery__item::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    to bottom,
    transparent 0%,
    rgba(0, 0, 0, 0.5) 100%
  );
  opacity: 0;
  transition: opacity var(--transition-base);
  z-index: 1;
}

.gallery__item:hover::before {
  opacity: 1;
}

.gallery__item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform var(--transition-slow);
}

.gallery__item:hover img {
  transform: scale(1.1);
}

/* Zoom icon overlay */
.gallery__item::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0);
  width: 60px;
  height: 60px;
  background-color: var(--color-primary);
  border-radius: var(--radius-full);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='white'%3E%3Cpath d='M15.5 14h-.79l-.28-.27A6.471 6.471 0 0016 9.5 6.5 6.5 0 109.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z'/%3E%3Cpath d='M12 10h-2v2H9v-2H7V9h2V7h1v2h2v1z'/%3E%3C/svg%3E");
  background-size: 30px;
  background-repeat: no-repeat;
  background-position: center;
  transition: transform var(--transition-base);
  z-index: 2;
}

.gallery__item:hover::after {
  transform: translate(-50%, -50%) scale(1);
}

/* Gallery caption */
.gallery__caption {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: var(--space-md);
  color: var(--color-text-white);
  transform: translateY(100%);
  transition: transform var(--transition-base);
  z-index: 2;
}

.gallery__item:hover .gallery__caption {
  transform: translateY(0);
}

.gallery__caption-title {
  font-weight: var(--font-weight-semibold);
  margin-bottom: var(--space-xs);
}

.gallery__caption-text {
  font-size: var(--font-size-sm);
  opacity: 0.9;
}

/* --------------------------------------------------------------------------
   Masonry Gallery Layout (Optional)
   -------------------------------------------------------------------------- */
.gallery--masonry {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  grid-auto-rows: 10px;
  gap: var(--space-md);
}

.gallery--masonry .gallery__item {
  grid-row-end: span 20; /* Default height */
}

.gallery--masonry .gallery__item--tall {
  grid-row-end: span 30;
}

.gallery--masonry .gallery__item--short {
  grid-row-end: span 15;
}

/* --------------------------------------------------------------------------
   Responsive Adjustments
   -------------------------------------------------------------------------- */
@media (max-width: 767px) {
  .lightbox__close {
    top: var(--space-md);
    right: var(--space-md);
    width: 44px;
    height: 44px;
  }

  .lightbox__nav {
    width: 44px;
    height: 44px;
  }

  .lightbox__nav--prev {
    left: var(--space-sm);
  }

  .lightbox__nav--next {
    right: var(--space-sm);
  }

  .lightbox__image {
    max-width: 95vw;
    max-height: 70vh;
  }

  .lightbox__thumbnails {
    bottom: var(--space-md);
    padding: var(--space-xs);
  }

  .lightbox__thumbnail {
    width: 50px;
    height: 50px;
  }

  .gallery {
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-sm);
  }

  .gallery__item::after {
    width: 44px;
    height: 44px;
    background-size: 22px;
  }
}

@media (max-width: 480px) {
  .gallery {
    grid-template-columns: 1fr;
  }
}

/* --------------------------------------------------------------------------
   Keyboard Focus States
   -------------------------------------------------------------------------- */
.lightbox__close:focus-visible,
.lightbox__nav:focus-visible,
.lightbox__thumbnail:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

.gallery__item:focus-visible {
  outline: 3px solid var(--color-primary);
  outline-offset: 3px;
}
