/* ============================================================
   Logan Custom Homes — Portfolio  v3
   Clean editorial grid — uniform 3/2 items + occasional
   full-width banners. No mixed row heights, no dead space.
   ============================================================ */

.portfolio-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  padding: 6px;
}

/* Default: 1 of 3 columns, landscape 3/2 */
.portfolio-item {
  overflow: hidden;
  position: relative;
  cursor: pointer;
  background: var(--charcoal-deep);
  aspect-ratio: 3/2;
}

/* Full-width cinematic strip: items 1, 8, 15, 22, 29 */
.portfolio-item:nth-child(7n+1) {
  grid-column: span 3;
  aspect-ratio: 21/9;
}

.portfolio-item__img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.9s var(--ease-out);
  display: block;
}

.portfolio-item:hover .portfolio-item__img {
  transform: scale(1.04);
}

/* Subtle overlay on hover */
.portfolio-item::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(20, 20, 26, 0.35);
  opacity: 0;
  transition: opacity var(--duration-base) var(--ease-out);
}

.portfolio-item:hover::after {
  opacity: 1;
}

/* ---- Lightbox ---- */

.portfolio-item {
  cursor: zoom-in;
}

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s var(--ease-out);
}

.lightbox.is-open {
  opacity: 1;
  pointer-events: all;
}

.lightbox__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(14, 14, 18, 0.97);
}

.lightbox__figure {
  position: relative;
  z-index: 1;
  transform: scale(0.96);
  transition: transform 0.4s var(--ease-out);
}

.lightbox.is-open .lightbox__figure {
  transform: scale(1);
}

.lightbox__img {
  display: block;
  max-width: 88vw;
  max-height: 86vh;
  width: auto;
  height: auto;
  object-fit: contain;
  opacity: 0;
  transition: opacity 0.25s var(--ease-out);
}

.lightbox__img.is-loaded {
  opacity: 1;
}

/* Close button */
.lightbox__close {
  position: absolute;
  top: var(--space-6);
  right: var(--space-6);
  z-index: 2;
  background: none;
  border: none;
  color: var(--bone);
  opacity: 0.5;
  cursor: pointer;
  padding: var(--space-3);
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity var(--duration-fast);
}

.lightbox__close:hover { opacity: 1; }

/* Prev / Next arrows */
.lightbox__prev,
.lightbox__next {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 2;
  background: none;
  border: none;
  color: var(--bone);
  opacity: 0.4;
  cursor: pointer;
  padding: var(--space-4);
  min-width: 56px;
  min-height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity var(--duration-fast);
}

.lightbox__prev { left: var(--space-6); }
.lightbox__next { right: var(--space-6); }

.lightbox__prev:hover,
.lightbox__next:hover { opacity: 1; }

/* Counter */
.lightbox__counter {
  position: absolute;
  bottom: var(--space-6);
  left: 50%;
  transform: translateX(-50%);
  z-index: 2;
  font-family: var(--font-body);
  font-size: var(--text-xs);
  letter-spacing: var(--tracking-widest);
  color: var(--bone);
  opacity: 0.35;
  white-space: nowrap;
}

body.lightbox-open {
  overflow: hidden;
}

/* ---- Tablet ---- */
@media (max-width: 1024px) {
  .portfolio-grid {
    gap: 4px;
    padding: 4px;
  }
}

/* ---- Mobile ---- */
@media (max-width: 640px) {
  .portfolio-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 3px;
    padding: 3px;
  }

  .portfolio-item {
    aspect-ratio: 1/1;
  }

  .portfolio-item:nth-child(7n+1) {
    grid-column: span 2;
    aspect-ratio: 16/9;
  }
}
