/* ============================================================
   TSMS – Gallery Section + Lightbox
   ============================================================ */

.gallery {
  background: var(--white);
  padding: var(--section-padding);
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-auto-rows: 240px;
  gap: 1rem;
  margin-top: 3rem;
}

/* Some cells span 2 columns or 2 rows for visual interest */
.gallery-item {
  overflow: hidden;
  border-radius: var(--radius-md);
  cursor: pointer;
  position: relative;
  background: var(--panel-bg);
}
.gallery-item.wide  { grid-column: span 2; }
.gallery-item.tall  { grid-row:    span 2; }

.gallery-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.4s ease;
  display: block;
}
  transform: scale(1.05);
}

/* Overlay on hover */
.gallery-item::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(26, 26, 26, 0);
  transition: background 0.3s ease;
  pointer-events: none;
}
.gallery-item:hover::after {
  background: rgba(26, 26, 26, 0.25);
}

.gallery-zoom-icon {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%) scale(0.6);
  opacity: 0;
  transition: opacity 0.3s, transform 0.3s;
  z-index: 2;
  width: 48px; height: 48px;
  background: rgba(255,255,255,0.9);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
}
.gallery-item:hover .gallery-zoom-icon {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

/* Placeholder tiles (shown when no real photos are added yet) */
.gallery-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  background: var(--panel-bg);
  color: var(--mid);
  font-size: 0.8rem;
  font-weight: 500;
  text-align: center;
  padding: 1rem;
  user-select: none;
}
.gallery-placeholder svg {
  opacity: 0.35;
  margin-bottom: 0.25rem;
}

/* ── LIGHTBOX ── */
.lightbox {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(10, 10, 10, 0.94);
  backdrop-filter: blur(6px);
  align-items: center;
  justify-content: center;
}
.lightbox.open {
  display: flex;
}

.lightbox-inner {
  position: relative;
  max-width: 90vw;
  max-height: 90vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lightbox img {
  display: block;
  max-width: 88vw;
  max-height: 85vh;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: var(--radius-md);
  box-shadow: 0 40px 80px rgba(0,0,0,0.6);
}

.lightbox-close {
  position: fixed;
  top: 1.5rem; right: 1.5rem;
  width: 44px; height: 44px;
  background: rgba(255,255,255,0.12);
  border: none;
  border-radius: 50%;
  color: var(--white);
  font-size: 1.4rem;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background var(--transition);
  z-index: 201;
}
.lightbox-close:hover { background: rgba(255,255,255,0.22); }

.lightbox-prev,
.lightbox-next {
  position: fixed;
  top: 50%; transform: translateY(-50%);
  width: 48px; height: 48px;
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 50%;
  color: var(--white);
  font-size: 1.2rem;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background var(--transition);
  z-index: 201;
}
.lightbox-prev { left: 1.5rem; }
.lightbox-next { right: 1.5rem; }
.lightbox-prev:hover,
.lightbox-next:hover { background: rgba(255,255,255,0.22); }

.lightbox-caption {
  position: fixed;
  bottom: 1.5rem; left: 50%;
  transform: translateX(-50%);
  color: rgba(255,255,255,0.6);
  font-size: 0.82rem;
  letter-spacing: 0.5px;
}

/* ── RESPONSIVE ── */
@media (max-width: 900px) {
  .gallery-grid {
    grid-template-columns: repeat(2, 1fr);
    grid-auto-rows: 200px;
  }
  .gallery-item.wide { grid-column: span 2; }
}
@media (max-width: 560px) {
  .gallery-grid {
    grid-template-columns: 1fr;
    grid-auto-rows: 220px;
  }
  .gallery-item.wide,
  .gallery-item.tall { grid-column: span 1; grid-row: span 1; }
  .lightbox-prev { left: 0.5rem; }
  .lightbox-next { right: 0.5rem; }
}

/* Ensure real images fill their tile correctly */
.gallery-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.4s ease;
}
.gallery-item:hover img {
  transform: scale(1.05);
}
