/* ==========================================================
   Photo gallery page (gallery.html)
   Loaded after styles.css; uses the same design tokens.
   ========================================================== */

/* ---------- Grid view ---------- */
.photo-grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.photo-tile {
  display: block;
  position: relative;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  background: var(--cream);
  cursor: zoom-in;
}

.photo-tile img {
  height: 100%;
  transition: transform .45s ease;
}

.photo-tile:after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(18, 27, 21, 0);
  transition: background .25s;
}

.photo-tile:hover img,
.photo-tile:focus-visible img {
  transform: scale(1.05);
}

.photo-tile:hover:after,
.photo-tile:focus-visible:after {
  background: rgba(18, 27, 21, .18);
}

.photo-tile:focus-visible {
  outline: 3px solid var(--rust);
  outline-offset: 3px;
}

/* ---------- Lightbox view ---------- */
body.lightbox-open {
  overflow: hidden;
}

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(16, 22, 18, .96);
  color: #f7f5ee;
  padding: 64px 88px;
}

.lightbox[hidden] {
  display: none;
}

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

/* Override the site-wide img rules (width:100%; object-fit:cover) */
.lightbox-img {
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: calc(100vh - 160px);
  max-height: calc(100dvh - 160px);
  object-fit: contain;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .45);
  user-select: none;
}

.lightbox-caption {
  margin-top: 16px;
  display: flex;
  gap: 18px;
  align-items: baseline;
  justify-content: center;
  flex-wrap: wrap;
  font-size: .92rem;
  color: #d9e0d8;
  text-align: center;
}

.lightbox-count {
  font-size: .75rem;
  letter-spacing: .15em;
  font-weight: 700;
  color: #e7a78e;
}

.lightbox-btn {
  position: absolute;
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, .35);
  background: rgba(255, 255, 255, .06);
  color: #fff;
  font-size: 2rem;
  line-height: 1;
  cursor: pointer;
  transition: background .2s, border-color .2s;
}

.lightbox-btn:hover {
  background: var(--rust);
  border-color: var(--rust);
}

.lightbox-btn:focus-visible {
  outline: 2px solid #e7a78e;
  outline-offset: 3px;
}

.lightbox-close {
  top: 16px;
  right: 16px;
  width: 46px;
  height: 46px;
}

.lightbox-prev,
.lightbox-next {
  top: 50%;
  transform: translateY(-50%);
  font-size: 2.4rem;
  padding-bottom: 4px;
}

.lightbox-prev {
  left: 18px;
}

.lightbox-next {
  right: 18px;
}

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .photo-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .photo-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  /* Image uses the full width; prev/next move to the bottom */
  .lightbox {
    padding: 70px 12px 96px;
  }

  .lightbox-img {
    max-height: calc(100vh - 220px);
    max-height: calc(100dvh - 220px);
  }

  .lightbox-prev,
  .lightbox-next {
    top: auto;
    bottom: 22px;
    transform: none;
  }

  .lightbox-prev {
    left: calc(50% - 64px);
  }

  .lightbox-next {
    right: calc(50% - 64px);
  }
}
