/* ===================================================================
   Liuren Magic Sanctuary - Photo Gallery Styles
   =================================================================== */

/* Gallery Filters */
.gallery-filters {
  margin: 2rem 0 3rem 0;
  padding: 1.5rem;
  background-color: var(--bg-cream);
  border-radius: var(--border-radius);
  border: 1px solid var(--border-color);
}

.filter-section {
  margin-bottom: 1.5rem;
}

.filter-section:last-child {
  margin-bottom: 0;
}

.filter-section h4 {
  margin: 0 0 0.75rem 0;
  color: var(--primary-red);
  font-size: 1rem;
}

.filter-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.filter-btn,
.year-btn {
  padding: 0.5rem 1rem;
  background-color: var(--bg-white);
  border: 2px solid var(--border-color);
  border-radius: var(--border-radius);
  color: var(--text-dark);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s ease;
}

.filter-btn:hover,
.year-btn:hover {
  background-color: var(--bg-cream);
  border-color: var(--accent-gold);
  transform: translateY(-2px);
}

.filter-btn.active,
.year-btn.active {
  background-color: var(--primary-red);
  border-color: var(--primary-red);
  color: var(--bg-white);
}

.filter-btn.active:hover,
.year-btn.active:hover {
  transform: none;
}

/* Gallery Grid */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.5rem;
  margin: 2rem 0;
}

/* Gallery Item */
.gallery-item {
  position: relative;
  background-color: var(--bg-white);
  border-radius: var(--border-radius);
  overflow: hidden;
  box-shadow: 0 2px 8px var(--shadow);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  cursor: pointer;
}

.gallery-item:hover {
  transform: translateY(-5px);
  box-shadow: 0 4px 16px var(--shadow);
}

.gallery-item-image {
  position: relative;
  width: 100%;
  padding-top: 75%; /* 4:3 aspect ratio */
  overflow: hidden;
  background-color: var(--bg-cream);
}

.gallery-item-image img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;

  /* Image protection */
  user-select: none;
  -webkit-user-drag: none;
  -webkit-touch-callout: none;
  pointer-events: none;
}

.gallery-item:hover .gallery-item-image img {
  transform: scale(1.05);
}

/* Image protection overlay */
.gallery-item-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: transparent;
  z-index: 2;
  pointer-events: auto;
}

.gallery-item-caption {
  padding: 1rem;
  background-color: var(--bg-white);
}

.gallery-item-caption h4 {
  margin: 0 0 0.5rem 0;
  color: var(--primary-red);
  font-size: 0.95rem;
  line-height: 1.4;
}

.gallery-item-caption .caption-zh {
  margin: 0 0 0.5rem 0;
  color: var(--text-medium);
  font-size: 0.85rem;
  line-height: 1.4;
}

.gallery-item-caption .caption-meta {
  margin: 0;
  color: var(--text-light);
  font-size: 0.75rem;
}

.gallery-item-caption .caption-meta .category-badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  margin-left: 0.5rem;
  background-color: var(--accent-gold);
  color: var(--text-dark);
  border-radius: 3px;
  font-size: 0.7rem;
  font-weight: 600;
}

/* Loading and No Results Messages */
.loading-message,
.no-results {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-medium);
  font-size: 1.1rem;
}

.no-results {
  background-color: var(--bg-cream);
  border-radius: var(--border-radius);
  margin: 2rem 0;
}

/* Lightbox */
.lightbox {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lightbox-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.9);
  z-index: 1;
}

.lightbox-content {
  position: relative;
  z-index: 2;
  max-width: 90%;
  max-height: 90%;
  display: flex;
  flex-direction: column;
}

.lightbox-image-container {
  position: relative;
  max-width: 100%;
  max-height: calc(90vh - 150px);
  display: flex;
  align-items: center;
  justify-content: center;
}

#lightbox-image {
  max-width: 100%;
  max-height: calc(90vh - 150px);
  height: auto;
  border-radius: var(--border-radius);

  /* Image protection */
  user-select: none;
  -webkit-user-drag: none;
  -webkit-touch-callout: none;
  pointer-events: none;
}

/* Lightbox image protection overlay */
.lightbox-image-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: transparent;
  z-index: 10;
  pointer-events: auto;
}

.lightbox-caption {
  background-color: rgba(255, 255, 255, 0.95);
  padding: 1rem 1.5rem;
  border-radius: 0 0 var(--border-radius) var(--border-radius);
  margin-top: 1rem;
  max-width: 800px;
}

.lightbox-caption p {
  margin: 0.5rem 0;
  color: var(--text-dark);
}

.lightbox-caption .caption-zh {
  color: var(--text-medium);
  font-size: 0.9rem;
}

.lightbox-caption .caption-meta {
  color: var(--text-light);
  font-size: 0.85rem;
  font-style: italic;
}

/* Lightbox Controls */
.lightbox-close,
.lightbox-prev,
.lightbox-next {
  position: absolute;
  background-color: rgba(255, 255, 255, 0.9);
  border: none;
  font-size: 2rem;
  color: var(--text-dark);
  cursor: pointer;
  z-index: 11;
  width: 50px;
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all 0.3s ease;
}

.lightbox-close:hover,
.lightbox-prev:hover,
.lightbox-next:hover {
  background-color: var(--primary-red);
  color: var(--bg-white);
  transform: scale(1.1);
}

.lightbox-close {
  top: 20px;
  right: 20px;
  font-size: 2.5rem;
  line-height: 1;
}

.lightbox-prev {
  left: 20px;
  top: 50%;
  transform: translateY(-50%);
}

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

.lightbox-next {
  right: 20px;
  top: 50%;
  transform: translateY(-50%);
}

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

/* Hidden state */
.gallery-item.hidden {
  display: none;
}

/* Responsive Design */
@media (max-width: 1024px) {
  .gallery-grid {
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 1.25rem;
  }
}

@media (max-width: 768px) {
  .gallery-filters {
    padding: 1rem;
  }

  .filter-buttons {
    gap: 0.5rem;
  }

  .filter-btn,
  .year-btn {
    padding: 0.4rem 0.75rem;
    font-size: 0.85rem;
  }

  .gallery-grid {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
  }

  .gallery-item-caption {
    padding: 0.75rem;
  }

  .gallery-item-caption h4 {
    font-size: 0.85rem;
  }

  .gallery-item-caption .caption-zh {
    font-size: 0.8rem;
  }

  .lightbox-content {
    max-width: 95%;
    max-height: 95%;
  }

  .lightbox-caption {
    padding: 0.75rem 1rem;
    font-size: 0.9rem;
  }

  .lightbox-close,
  .lightbox-prev,
  .lightbox-next {
    width: 40px;
    height: 40px;
    font-size: 1.5rem;
  }

  .lightbox-close {
    top: 10px;
    right: 10px;
  }

  .lightbox-prev {
    left: 10px;
  }

  .lightbox-next {
    right: 10px;
  }
}

@media (max-width: 480px) {
  .filter-section h4 {
    font-size: 0.9rem;
  }

  .filter-buttons {
    flex-direction: column;
  }

  .filter-btn,
  .year-btn {
    width: 100%;
    text-align: left;
  }

  .gallery-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .lightbox-caption {
    font-size: 0.85rem;
  }

  #lightbox-image {
    max-height: calc(90vh - 200px);
  }
}

/* Print Styles */
@media print {
  .gallery-filters,
  .lightbox {
    display: none !important;
  }

  .gallery-item {
    break-inside: avoid;
  }
}
