/* Gallery page. Reuses base.css variables and the .reveal fade-in
   pattern already used on the homepage, just adds the grid and lightbox
   on top. */

.gallery-wrap {
  max-width: 1100px;
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-top: 20px;
}

@media (min-width: 640px) {
  .gallery-grid { grid-template-columns: repeat(3, 1fr); gap: 14px; }
}

@media (min-width: 960px) {
  .gallery-grid { grid-template-columns: repeat(4, 1fr); gap: 16px; }
}

.gallery-item {
  position: relative;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid #3a3530;
  border-bottom: 3px solid var(--yellow);
  background: var(--panel);
  cursor: pointer;
  aspect-ratio: 1 / 1;
  opacity: 0;
  transform: translateY(16px) scale(0.97);
  transition: opacity 0.5s ease, transform 0.5s ease;
  /* Reset: .gallery-item is a <button>, and base.css's global button
     rule (width:100%, padding:14px, background, etc) plus iOS Safari's
     own native button chrome both fight the grid layout otherwise, this
     is what was making the grid not show up correctly on iPhone. */
  padding: 0;
  margin: 0;
  width: 100%;
  font: inherit;
  -webkit-appearance: none;
  appearance: none;
}

.gallery-item.is-visible {
  opacity: 1;
  transform: translateY(0) scale(1);
}

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

.gallery-item:hover img,
.gallery-item:focus-visible img {
  transform: scale(1.06);
}

.gallery-item::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(20,20,20,0.55), transparent 45%);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.gallery-item:hover::after,
.gallery-item:focus-visible::after {
  opacity: 1;
}

.gallery-empty {
  color: var(--bone);
  opacity: 0.7;
  margin-top: 24px;
  text-align: center;
}

/* Lightbox */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(10, 10, 10, 0.94);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  padding: 20px;
}

.lightbox[hidden] { display: none; }

.lightbox img {
  max-width: min(92vw, 900px);
  max-height: 78vh;
  object-fit: contain;
  border-radius: 4px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.5);
  opacity: 0;
  transform: scale(0.97);
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.lightbox img.is-shown {
  opacity: 1;
  transform: scale(1);
}

.lightbox-caption {
  color: var(--bone);
  opacity: 0.75;
  margin-top: 14px;
  font-family: "Barlow", sans-serif;
  text-align: center;
}

.lightbox-close,
.lightbox-nav {
  position: absolute;
  background: var(--panel);
  color: var(--bone);
  border: 1px solid #3a3530;
  border-radius: 50%;
  width: 44px;
  height: 44px;
  padding: 0;
  margin: 0;
  font: inherit;
  -webkit-appearance: none;
  appearance: none;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lightbox-close:hover,
.lightbox-nav:hover {
  border-color: var(--yellow);
  color: var(--yellow);
}

.lightbox-close {
  top: 18px;
  right: 18px;
}

.lightbox-prev { left: 18px; top: 50%; transform: translateY(-50%); }
.lightbox-next { right: 18px; top: 50%; transform: translateY(-50%); }

@media (max-width: 640px) {
  .lightbox-prev { left: 6px; }
  .lightbox-next { right: 6px; }
}
