/**
 * gallery.css — Photo gallery + custom lightbox (photos.php, Phase 6)
 */

/* Narrow sidebar column (photos uses w-col-2 / w-col-10) */
.page-container .w-col-2 {
  width: 16.66666667%;
}

.page-container .w-col-10 {
  width: 83.33333333%;
}

@media screen and (max-width: 991px) {
  .page-container .w-col-2,
  .page-container .w-col-10 {
    width: 100%;
  }
}

.gallery-year-pills {
  margin: 5px 0;
}

.gallery-card__media {
  position: relative;
  overflow: hidden;
  width: 100%;
  padding-top: 100%;
  border-radius: 8px;
  background-color: #1e293b;
}

.gallery-image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.gallery-item {
  background-color: var(--color-slate-gray);
  text-align: center;
}

.gallery-image-error {
  display: none;
}

.gallery-trigger {
  display: block;
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  padding: 0;
  margin: 0;
  border: none;
  background: none;
  cursor: pointer;
  text-align: left;
}

.gallery-trigger:disabled {
  cursor: not-allowed;
}

.gallery-image-error-icon::before,
.gallery-lightbox-image-error-icon::before {
  content: "⚠️";
  display: block;
}

@media screen and (max-width: 991px) {
  .mobileview {
    display: block !important;
  }
}

.mobileview {
  display: none;
}

.view-more {
  padding: 12px;
  border-radius: 6px !important;
  margin-left: 8px;
}

.gallery-item {
  margin-top: 0 !important;
  margin-bottom: 0 !important;
  border-radius: 8px !important;
  transition: all 0.3s ease !important;
}

.gallery-item:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 16px 0 rgba(88, 88, 88, 0.4) !important;
}

.gallery-image {
  border-radius: 8px;
  transition: transform 0.3s ease !important;
}

.gallery-image:hover {
  transform: scale(1.02) !important;
}

/* ── Custom lightbox ───────────────────────────────────────────────────── */

.gallery-lightbox {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
}

.gallery-lightbox[hidden] {
  display: none !important;
}

body.gallery-lightbox-open {
  overflow: hidden;
}

.gallery-lightbox-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.gallery-lightbox-content {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: min(95vw, 1200px);
  max-height: 95vh;
  padding: 48px 56px;
  box-sizing: border-box;
}

.gallery-lightbox-close,
.gallery-lightbox-prev,
.gallery-lightbox-next {
  position: absolute;
  z-index: 2;
  border: none;
  background: rgba(0, 0, 0, 0.5);
  color: #fff;
  cursor: pointer;
  border-radius: 8px;
  line-height: 1;
  transition: background 0.2s ease;
}

.gallery-lightbox-close:hover,
.gallery-lightbox-prev:hover,
.gallery-lightbox-next:hover {
  background: rgba(0, 0, 0, 0.75);
}

.gallery-lightbox-close {
  top: 8px;
  right: 8px;
  font-size: 28px;
  width: 40px;
  height: 40px;
  padding: 0;
}

.gallery-lightbox-prev,
.gallery-lightbox-next {
  top: 50%;
  transform: translateY(-50%);
  font-size: 32px;
  width: 44px;
  height: 56px;
  padding: 0;
}

.gallery-lightbox-prev {
  left: 0;
}

.gallery-lightbox-next {
  right: 0;
}

.gallery-lightbox-figure {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: 0;
  max-width: 100%;
}

.gallery-lightbox-image {
  display: block;
  max-width: 100%;
  max-height: 75vh;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  object-fit: contain;
}

.gallery-lightbox-caption {
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  padding: 16px 20px;
  margin: 12px 0 0;
  border-radius: 12px;
  font-size: 16px;
  line-height: 1.5;
  color: rgba(255, 255, 255, 0.95);
  max-width: 100%;
  text-align: center;
}

.gallery-image-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, #1e293b 25%, #334155 50%, #1e293b 75%);
  background-size: 200% 100%;
  animation: skeleton-pulse 1.5s ease-in-out infinite;
  border-radius: 8px;
}

@keyframes skeleton-pulse {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.gallery-item:not(.image-loaded):not(.has-error) .gallery-image-loading {
  display: flex;
}

.gallery-item.image-loaded .gallery-image-loading,
.gallery-item.has-error .gallery-image-loading {
  display: none;
}

.gallery-item.has-error .gallery-image {
  display: none;
}

.gallery-item.has-error .gallery-image-error {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: absolute;
  inset: 0;
  background-color: #1e293b;
  color: #94a3b8;
  padding: 20px;
  text-align: center;
}

.gallery-lightbox-image-error {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 300px;
  min-height: 300px;
  background-color: rgba(0, 0, 0, 0.3);
  border-radius: 12px;
  color: rgba(255, 255, 255, 0.7);
  padding: 40px;
  text-align: center;
}

.gallery-lightbox-figure.has-error .gallery-lightbox-image {
  display: none;
}

.gallery-lightbox-figure.has-error .gallery-lightbox-image-error {
  display: flex;
}

@media screen and (max-width: 991px) {
  .gallery-lightbox-content {
    padding: 40px 36px;
  }

  .gallery-lightbox-caption {
    font-size: 13px;
    padding: 12px 16px;
  }

  .gallery-lightbox-image {
    max-height: 65vh;
  }

  .card-grid {
    grid-column-gap: 12px !important;
    grid-row-gap: 12px !important;
    padding: 8px !important;
  }

  .tags.view-more {
    padding: 8px 14px !important;
  }
}
