/* ===== KJW PHOTO GALLERY — Masonry grid + lightbox ===== */

/* ---- Masonry container ---- */
.masonry {
  columns: 3;
  column-gap: 8px;
  /* Padding inside property-card so rounded card corners clip cleanly */
  padding: var(--space-4) var(--space-4) 0;
  /* No bottom margin — property-card__badge follows right below */
}

@media (max-width: 900px) {
  .masonry { columns: 2; }
}
@media (max-width: 480px) {
  .masonry { columns: 1; }
}

/* ---- Each tile ---- */
.masonry__item {
  break-inside: avoid;
  margin-bottom: 8px;
  overflow: hidden;
  border-radius: var(--radius-md);
  position: relative;
  cursor: pointer;
  display: block;
}

.masonry__item img {
  width: 100%;
  height: auto;
  display: block;
  object-fit: cover;
  /* Saturation + contrast boost */
  filter: saturate(1.12) contrast(1.06);
  transition: transform 0.45s cubic-bezier(0.16, 1, 0.3, 1),
              filter 0.35s ease;
  /* Lazy-load fade-in starting state */
  opacity: 0;
  transition: opacity 0.4s ease,
              transform 0.45s cubic-bezier(0.16, 1, 0.3, 1),
              filter 0.35s ease;
}

/* Fade in once loaded */
.masonry__item img.loaded {
  opacity: 1;
}

/* Hover: zoom + vivid */
.masonry__item:hover img {
  transform: scale(1.05);
  filter: saturate(1.22) contrast(1.09) brightness(1.04);
}

/* Dark overlay on hover */
.masonry__item::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0);
  transition: background 0.3s ease;
  pointer-events: none;
  border-radius: var(--radius-md);
}
.masonry__item:hover::after {
  background: rgba(0, 0, 0, 0.08);
}

/* Focus ring for keyboard nav */
.masonry__item:focus-visible {
  outline: 3px solid var(--color-primary);
  outline-offset: 2px;
}

/* Skeleton shimmer while image loads */
.masonry__item::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    var(--color-surface-offset) 25%,
    var(--color-surface-offset-2) 50%,
    var(--color-surface-offset) 75%
  );
  background-size: 400% 100%;
  animation: shimmer 1.6s ease infinite;
  border-radius: var(--radius-md);
  z-index: 0;
}
.masonry__item img.loaded ~ .masonry__item::before,
.masonry__item:has(img.loaded)::before {
  display: none;
}

@keyframes shimmer {
  0%   { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}

/* Photo count badge — pulled out of column flow */
.masonry__count {
  column-span: all;  /* spans across all columns */
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--color-text-muted);
  margin-bottom: var(--space-3);
  letter-spacing: 0.04em;
  break-before: column;
  break-after: column;
}
.masonry__count svg {
  opacity: 0.6;
}


/* ===== LIGHTBOX ===== */
.lightbox {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(10, 8, 6, 0.97);
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: var(--space-4);
  animation: lb-fade-in 0.2s ease;
}

@keyframes lb-fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.lightbox.is-open { display: flex; }

/* Image wrapper */
.lightbox__img-wrap {
  position: relative;
  max-width: 92vw;
  max-height: 76vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Main image */
.lightbox__img {
  max-width: 92vw;
  max-height: 76vh;
  object-fit: contain;
  border-radius: var(--radius-lg);
  box-shadow: 0 32px 96px rgba(0,0,0,0.7);
  filter: saturate(1.1) contrast(1.05);
  transition: opacity 0.18s ease;
}
.lightbox__img.is-fading { opacity: 0; }

/* Prev / Next */
.lightbox__nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.22);
  color: #fff;
  width: 52px;
  height: 52px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.2s ease;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.lightbox__nav:hover {
  background: rgba(255,255,255,0.22);
  transform: translateY(-50%) scale(1.08);
}
.lightbox__prev { left: -66px; }
.lightbox__next { right: -66px; }

/* Close */
.lightbox__close {
  position: fixed;
  top: var(--space-6);
  right: var(--space-6);
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.22);
  color: #fff;
  width: 46px;
  height: 46px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  transition: background 0.2s ease, transform 0.2s ease;
  z-index: 1001;
}
.lightbox__close:hover {
  background: rgba(255,255,255,0.22);
  transform: scale(1.1);
}

/* Counter + caption */
.lightbox__counter {
  color: rgba(255,255,255,0.5);
  font-size: var(--text-xs);
  letter-spacing: 0.1em;
  font-variant-numeric: tabular-nums;
}
.lightbox__caption {
  color: rgba(255,255,255,0.7);
  font-size: var(--text-xs);
  text-align: center;
  max-width: 60ch;
  min-height: 1.4em;
}

/* Thumbnail strip */
.lightbox__thumbs {
  display: flex;
  gap: var(--space-2);
  overflow-x: auto;
  padding: var(--space-2) var(--space-4);
  max-width: 90vw;
  scrollbar-width: none;
}
.lightbox__thumbs::-webkit-scrollbar { display: none; }

.lightbox__thumb-btn {
  width: 64px;
  height: 46px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  flex-shrink: 0;
  border: 2px solid transparent;
  padding: 0;
  cursor: pointer;
  transition: border-color 0.2s ease, opacity 0.2s ease, transform 0.2s ease;
  opacity: 0.42;
}
.lightbox__thumb-btn img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: saturate(1.08);
}
.lightbox__thumb-btn.active,
.lightbox__thumb-btn:hover {
  border-color: var(--color-primary);
  opacity: 1;
  transform: scale(1.06);
}

/* ===== RESPONSIVE lightbox ===== */
@media (max-width: 700px) {
  .lightbox__prev { left: var(--space-2); }
  .lightbox__next { right: var(--space-2); }
  .lightbox__img-wrap { max-height: 62vh; }
  .lightbox__img     { max-height: 62vh; }
}
