/* ══════════════════════════════════════════════════════════
   Shared building-page gallery: Emaar-style carousel + lightbox
   Used on: /pier-residences/, /park-residences/,
            /plaza-residences/, /courtyard/
   Requires assets/js/gallery.js
   ══════════════════════════════════════════════════════════ */

/* ── GALLERY SECTION ── */
.gallery-section {
  background: var(--bg-light, #f4f6fb);
  overflow: hidden;
}

.gallery-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
}

.gallery-header .section-title {
  margin-bottom: 0;
}

.gallery-nav {
  display: flex;
  gap: 12px;
  flex-shrink: 0;
}

.gallery-arrow {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: #f2f2f2;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.3s, opacity 0.3s;
  padding: 0;
}

.gallery-arrow svg {
  width: 20px;
  height: 20px;
  stroke: #1a1a1a;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
}

.gallery-arrow:hover:not(:disabled) {
  background: #e3e3e3;
}

.gallery-arrow:disabled {
  opacity: 0.4;
  cursor: default;
}

/* Full-bleed viewport: negative margins cancel .section padding */
.gallery-viewport {
  overflow: hidden;
  margin: 40px -40px 0;
  cursor: grab;
  /* let the browser own vertical scroll; horizontal is ours */
  touch-action: pan-y;
}

.gallery-viewport.dragging {
  cursor: grabbing;
}

/* Side padding aligns first/last slide with the 1200px content container;
   JS refines the exact value from .section-center position */
.gallery-track {
  display: flex;
  gap: 24px;
  transition: transform 0.5s ease;
  padding: 0 max(40px, calc((100vw - 1200px) / 2));
  touch-action: pan-y;
}

/* live-drag: track follows the finger with no transition lag */
.gallery-viewport.dragging .gallery-track {
  transition: none;
}

.gallery-slide {
  flex: 0 0 58%;
  height: 520px;
  overflow: hidden;
  border-radius: 12px;
  cursor: pointer;
}

.gallery-slide img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
  user-select: none;
}

.gallery-dots {
  display: flex;
  gap: 0;
  justify-content: center;
  margin-top: 20px;
}

/* 24x24 touch target (a11y); the visible 8px dot is drawn by ::before */
.gallery-dots .dot {
  width: 24px;
  height: 24px;
  border: none;
  background: transparent;
  cursor: pointer;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.gallery-dots .dot::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: #8a90a0;
  transition: width 0.3s ease, background 0.3s ease;
}

.gallery-dots .dot.active::before {
  width: 24px;
  background: var(--navy, #0d1b6e);
}

@media (max-width: 1100px) {
  .gallery-slide {
    height: 420px;
  }
}

@media (max-width: 768px) {
  .gallery-viewport {
    margin: 32px -20px 0;
  }

  .gallery-track {
    gap: 16px;
    padding: 0 20px;
  }

  .gallery-slide {
    flex: 0 0 85%;
    height: 280px;
    border-radius: 10px;
  }

  .gallery-nav {
    display: none;
  }
}

/* ── LIGHTBOX ── */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(40, 40, 40, 0.85);
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
  display: flex;
  flex-direction: column;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0s linear 0.3s;
}

.lightbox.open {
  opacity: 1;
  visibility: visible;
  transition: opacity 0.3s ease;
}

.lightbox-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
  flex-shrink: 0;
}

.lightbox-title {
  color: #fff;
  font-family: 'Raleway', sans-serif;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: 0.25em;
  text-transform: uppercase;
}

.lightbox-btn {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.15);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.3s;
  flex-shrink: 0;
  padding: 0;
}

.lightbox-btn:hover {
  background: rgba(255, 255, 255, 0.3);
}

.lightbox-btn svg {
  width: 22px;
  height: 22px;
  stroke: #fff;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
}

.lightbox-stage {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
  padding: 0 24px;
  touch-action: pan-y;
}

.lightbox-image {
  max-width: 80vw;
  max-height: min(78vh, 100%);
  object-fit: contain;
  border-radius: 6px;
  transition: opacity 0.25s ease;
}

.lightbox-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 16px 24px 24px;
  flex-shrink: 0;
}

.lightbox-thumbs {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  max-width: calc(100vw - 220px);
  padding: 4px;
  scrollbar-width: none;
}

.lightbox-thumbs::-webkit-scrollbar {
  display: none;
}

.lightbox-thumb {
  width: 140px;
  height: 90px;
  flex: 0 0 auto;
  border-radius: 4px;
  overflow: hidden;
  cursor: pointer;
  opacity: 0.5;
  border: 2px solid transparent;
  padding: 0;
  background: none;
  transition: opacity 0.3s, border-color 0.3s;
}

.lightbox-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.lightbox-thumb.active {
  opacity: 1;
  border-color: #fff;
}

@media (max-width: 768px) {
  .lightbox-header {
    padding: 14px 16px;
  }

  .lightbox-title {
    font-size: 13px;
  }

  .lightbox-btn {
    width: 40px;
    height: 40px;
  }

  .lightbox-stage {
    padding: 0 12px;
  }

  .lightbox-image {
    max-width: 92vw;
  }

  .lightbox-footer {
    gap: 10px;
    padding: 12px 12px 16px;
  }

  .lightbox-thumbs {
    max-width: calc(100vw - 140px);
  }

  .lightbox-thumb {
    width: 96px;
    height: 60px;
  }
}
