/**
 * Photo Set Block Component Styles
 * Supports multiple image layouts with sidebar editor system
 */

.photo-set-block {
  position: relative;
  margin-bottom: 24px;
  width: 90%;
  margin-left: auto !important;
  margin-right: auto !important;
}

.photo-set-container {
  position: relative;
  display: grid;
  width: 100%;
  justify-items: center;
  justify-content: center;
}
.image-column-1 {
  grid-template-columns: repeat(1, auto) !important;
  gap: 5px;
}

.image-column-2 {
  grid-template-columns: repeat(2, auto) !important;
  gap: 5px;
}

.image-column-3 {
  grid-template-columns: repeat(3, auto) !important;
  gap: 5px;
}

.image-column-4 {
  grid-template-columns: repeat(4, auto) !important;
  gap: 5px;
}

.photo-set-item {
  position: relative;
  overflow: hidden;
  border-radius: 0px !important;
  max-height: 400px;
  transition: transform 0.3s ease, box-shadow 0.3s ease, opacity 0.6s ease, translate 0.6s ease;
  /* Initial state for scroll animation */
  opacity: 0;
  translate: 0 30px;
}

.block-wrapper .photo-set-item {
  opacity:1;
  translate: unset;
}

/* Animated state when item enters viewport */
.photo-set-item.animate-in {
  opacity: 1;
  translate: 0 0;
}

.photo-set-item:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.photo-set-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  border-radius: 4px;
  border-radius: 0px !important;
  transition: all 0.3s ease;
  cursor: pointer;
}

.photo-set-image:hover {
  transform: scale(1.02);
  filter: brightness(1.05);
}

/* Grid Layout (Default) */
.photo-set-grid .photo-set-container {
  display: grid;
  grid-template-columns: repeat(2, auto);
  gap: 5px;
  justify-content: center;
}


/* Masonry Layout */
.photo-set-masonry .photo-set-container {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  grid-auto-rows: 10px;
  gap: 10px;
}

.photo-set-masonry .photo-set-item {
  grid-row-end: span 20;
}

.photo-set-masonry .photo-set-item:nth-child(3n) {
  grid-row-end: span 25;
}

.photo-set-masonry .photo-set-item:nth-child(3n+1) {
  grid-row-end: span 30;
}

.photo-set-masonry .photo-set-image {
  height: 100%;
}

/* Carousel Layout */
.photo-set-carousel .photo-set-container {
  display: flex;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  gap: 10px;
  padding-bottom: 10px;
}

.photo-set-carousel .photo-set-item {
  flex: 0 0 80%;
  scroll-snap-align: center;
  max-width: 600px;
}

.photo-set-carousel .photo-set-container::-webkit-scrollbar {
  height: 8px;
}

.photo-set-carousel .photo-set-container::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 4px;
}

.photo-set-carousel .photo-set-container::-webkit-scrollbar-thumb {
  background: #888;
  border-radius: 4px;
}

.photo-set-carousel .photo-set-container::-webkit-scrollbar-thumb:hover {
  background: #555;
}

/* Stacked Layout */
.photo-set-stacked .photo-set-container {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.photo-set-stacked .photo-set-item {
  width: 100%;
}

/* Image placeholder */
.photo-set-block .image-placeholder {
  width: 100%;
  min-height: 200px;
  background: #f8f9fa;
  border: 2px dashed #dee2e6;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #6c757d;
  font-size: 14px;
  text-align: center;
  padding: 20px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.photo-set-block .image-placeholder:hover {
  background: #e9ecef;
  border-color: #adb5bd;
}

/* Caption styling */
.photo-set-caption {
  margin-top: 12px;
  color: #495057;
  font-size: 14px;
  font-style: italic;
  text-align: center;
  line-height: 1.4;
}

/* Image size variations */
.photo-set-block.image-size-small .photo-set-container {
  max-width: 400px;
}

.photo-set-block.image-size-medium .photo-set-container {
  max-width: 800px;
}

.photo-set-block.image-size-large .photo-set-container {
  max-width: 1200px;
}

.photo-set-block.image-size-full-width .photo-set-container {
  max-width: 100%;
}

/* Responsive design */
@media (max-width: 768px) {
  .photo-set-grid .photo-set-container {
    grid-template-columns: 1fr !important;
  }

  .photo-set-masonry .photo-set-container {
    grid-template-columns: 1fr;
  }
  
  .photo-set-carousel .photo-set-item {
    flex: 0 0 90%;
  }
}

.photo-set-image img {
  border-radius: 0px !important;
}

@media (max-width: 480px) {
  .photo-set-carousel .photo-set-item {
    flex: 0 0 95%;
  }
}

/* Editing mode styles */
.sdc-editable-container .photo-set-block {
  border: 2px dashed transparent;
  transition: border-color 0.3s ease;
  padding: 8px;
}

.sdc-editable-container .photo-set-block:hover {
  border-color: #007cba;
  background-color: rgba(0, 124, 186, 0.05);
}

.sdc-editable-container .photo-set-item {
  cursor: pointer;
}

/* Loading state */
.photo-set-block.loading .photo-set-image {
  opacity: 0.5;
  filter: blur(2px);
}

.photo-set-block.loading::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 40px;
  height: 40px;
  border: 4px solid #f3f3f3;
  border-top: 4px solid #007cba;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: translate(-50%, -50%) rotate(0deg); }
  100% { transform: translate(-50%, -50%) rotate(360deg); }
}

/* Accessibility improvements */
.photo-set-image:focus {
  outline: 2px solid #007cba;
  outline-offset: 2px;
}

/* Disable animations when wrapped in block-wrapper */
.block-wrapper .photo-set-item {
  opacity: 1 !important;
  translate: 0 0 !important;
  transition: transform 0.3s ease, box-shadow 0.3s ease !important;
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  .photo-set-item {
    opacity: 1 !important;
    translate: 0 0 !important;
    transition: transform 0.3s ease, box-shadow 0.3s ease !important;
  }
}

/* Print styles */
@media print {
  .photo-set-block {
    break-inside: avoid;
  }
  
  .photo-set-carousel .photo-set-container,
  .photo-set-grid .photo-set-container {
    display: grid !important;
    grid-template-columns: repeat(2, 1fr);
    overflow: visible;
  }
  
  .photo-set-item {
    box-shadow: none;
  }
  
  .photo-set-image {
    max-width: 100%;
  }
}

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

.photo-lightbox {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 10000;
  display: none;
  align-items: center;
  justify-content: center;
}

.photo-lightbox.active {
  display: flex;
}

/* Lightbox overlay */
.lightbox-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.95);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.photo-lightbox.active .lightbox-overlay {
  opacity: 1;
}

/* Lightbox content */
.lightbox-content {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 60px 80px;
  box-sizing: border-box;
}

/* Lightbox image container */
.lightbox-image-container {
  position: relative;
  max-width: 100%;
  max-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  transform: scale(0.9);
  opacity: 0;
  transition: transform 0.3s ease, opacity 0.3s ease;
}

.photo-lightbox.active .lightbox-image-container {
  transform: scale(1);
  opacity: 1;
}

/* Lightbox image */
.lightbox-image {
  max-width: 100%;
  max-height: calc(100vh - 180px);
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 4px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  transition: opacity 0.2s ease;
}

.lightbox-image.loading {
  opacity: 0.5;
}

/* Lightbox counter */
.lightbox-counter {
  margin-top: 20px;
  color: #ffffff;
  font-size: 16px;
  font-weight: 500;
  text-align: center;
  padding: 8px 16px;
  background: rgba(0, 0, 0, 0.6);
  border-radius: 20px;
  backdrop-filter: blur(10px);
}

/* Lightbox buttons - shared styles */
.lightbox-close,
.lightbox-prev,
.lightbox-next {
  position: absolute;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: #ffffff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  backdrop-filter: blur(10px);
  z-index: 10;
  padding: 0;
}

.lightbox-close:hover,
.lightbox-prev:hover,
.lightbox-next:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: scale(1.1);
}

.lightbox-close:focus,
.lightbox-prev:focus,
.lightbox-next:focus {
  outline: 2px solid #ffffff;
  outline-offset: 2px;
}

.lightbox-close:active,
.lightbox-prev:active,
.lightbox-next:active {
  transform: scale(0.95);
}

/* Close button */
.lightbox-close {
  top: 20px;
  right: 20px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
}

/* Navigation buttons */
.lightbox-prev,
.lightbox-next {
  top: 50%;
  transform: translateY(-50%);
  width: 56px;
  height: 56px;
  border-radius: 50%;
}

.lightbox-prev:hover,
.lightbox-next:hover {
  transform: translateY(-50%) scale(1.1);
}

.lightbox-prev:active,
.lightbox-next:active {
  transform: translateY(-50%) scale(0.95);
}

.lightbox-prev {
  left: 20px;
}

.lightbox-next {
  right: 20px;
}

/* Button SVG icons */
.lightbox-close svg,
.lightbox-prev svg,
.lightbox-next svg {
  width: 24px;
  height: 24px;
  stroke-width: 2.5;
}

/* Responsive lightbox */
@media (max-width: 768px) {
  .lightbox-content {
    padding: 80px 20px 40px;
  }
  
  .lightbox-image {
    max-height: calc(100vh - 200px);
  }
  
  .lightbox-close {
    top: 15px;
    right: 15px;
    width: 44px;
    height: 44px;
  }
  
  .lightbox-prev,
  .lightbox-next {
    width: 44px;
    height: 44px;
  }
  
  .lightbox-prev {
    left: 10px;
  }
  
  .lightbox-next {
    right: 10px;
  }
  
  .lightbox-counter {
    font-size: 14px;
    padding: 6px 12px;
    margin-top: 15px;
  }
}

@media (max-width: 480px) {
  .lightbox-content {
    padding: 70px 10px 30px;
  }
  
  .lightbox-image {
    max-height: calc(100vh - 160px);
  }
  
  .lightbox-close {
    width: 40px;
    height: 40px;
  }
  
  .lightbox-prev,
  .lightbox-next {
    width: 40px;
    height: 40px;
  }
  
  .lightbox-close svg,
  .lightbox-prev svg,
  .lightbox-next svg {
    width: 20px;
    height: 20px;
  }
}

/* Hide lightbox when printing */
@media print {
  .photo-lightbox {
    display: none !important;
  }
}

/* Accessibility - respect reduced motion preference */
@media (prefers-reduced-motion: reduce) {
  .lightbox-overlay,
  .lightbox-image-container,
  .lightbox-image,
  .lightbox-close,
  .lightbox-prev,
  .lightbox-next {
    transition: none !important;
  }
}

