/* Public photo gallery: justified rows that keep every photo's shape, names always visible. */

.gallery-album-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1.5rem;
  flex-wrap: wrap;
  margin-bottom: 2rem;
}
.gallery-album-head h2 { margin: 0.35rem 0 0; }

.gallery-filters { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.gallery-filter {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.6rem 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  background: var(--white);
  color: var(--navy);
  font: 700 0.86rem/1 var(--font-sans);
  cursor: pointer;
  transition: background 0.2s var(--ease), color 0.2s var(--ease), border-color 0.2s var(--ease);
}
.gallery-filter span { color: var(--muted); font-weight: 600; }
.gallery-filter:hover { border-color: var(--gold); }
.gallery-filter.is-active { border-color: var(--navy); background: var(--navy); color: var(--white); }
.gallery-filter.is-active span { color: var(--gold-bright); }
.gallery-filter:focus-visible { outline: 3px solid var(--gold-bright); outline-offset: 2px; }

.gallery-section + .gallery-section { margin-top: 2.75rem; }
.gallery-section[hidden] { display: none; }
.gallery-section-title {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  margin: 0 0 1rem;
  color: var(--navy);
  font-size: 1.15rem;
}
.gallery-section-title::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.gallery-album.is-filtered .gallery-section-title { display: none; }

/* Justified layout: each item grows in proportion to its aspect ratio, so rows line up. */
.gallery-grid {
  --row-height: 250px;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}
.gallery-grid::after { content: ""; flex-grow: 999999; }
.gallery-item {
  position: relative;
  flex-grow: calc(var(--ratio) * 100);
  flex-basis: calc(var(--ratio) * var(--row-height));
  /* Never let a photo grow past ~1.8x the row height, even alone on a row. */
  max-width: calc(var(--ratio) * var(--row-height) * 1.8);
  min-width: 0;
  aspect-ratio: var(--ratio);
  margin: 0;
  overflow: hidden;
  border-radius: var(--radius);
  background: var(--gold-soft);
  box-shadow: var(--shadow-sm);
}
.gallery-item.is-featured {
  flex-grow: calc(var(--ratio) * 170);
  flex-basis: calc(var(--ratio) * var(--row-height) * 1.7);
  max-width: calc(var(--ratio) * var(--row-height) * 2.2);
}
.gallery-open {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  background: none;
  cursor: zoom-in;
}
.gallery-open img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.6s var(--ease);
}
.gallery-item:hover .gallery-open img { transform: scale(1.04); }
.gallery-open:focus-visible { outline: 3px solid var(--gold-bright); outline-offset: -3px; }

.gallery-item figcaption {
  position: absolute;
  inset: auto 0 0;
  display: grid;
  gap: 0.15rem;
  padding: 2.4rem 1rem 0.85rem;
  background: linear-gradient(to top, rgba(16, 28, 51, 0.9), rgba(16, 28, 51, 0.55) 55%, transparent);
  color: var(--white);
  pointer-events: none;
}
.gallery-item figcaption strong {
  color: var(--white);
  font-size: 0.92rem;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.gallery-item figcaption span {
  color: rgba(255, 255, 255, 0.75);
  font-size: 0.78rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.gallery-item.is-featured figcaption strong { font-size: 1.05rem; }

.gallery-empty { text-align: center; }
.gallery-empty h2 { margin-top: 0.5rem; }

/* Lightbox */
.gallery-lightbox {
  width: 100vw;
  max-width: 100vw;
  height: 100vh;
  max-height: 100vh;
  margin: 0;
  padding: 0;
  border: 0;
  background: rgba(10, 17, 31, 0.96);
  color: var(--white);
}
.gallery-lightbox[open] {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
}
.gallery-lightbox::backdrop { background: rgba(10, 17, 31, 0.9); }
.lightbox-figure {
  display: grid;
  grid-template-rows: 1fr auto;
  height: 100vh;
  margin: 0;
  padding: 3.5rem 0 1.25rem;
  min-width: 0;
}
.lightbox-figure img {
  justify-self: center;
  align-self: center;
  max-width: 100%;
  max-height: calc(100vh - 13rem);
  object-fit: contain;
  border-radius: var(--radius-sm);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.45);
}
.lightbox-figure figcaption {
  display: grid;
  gap: 0.3rem;
  justify-items: center;
  padding-top: 1.1rem;
  text-align: center;
}
.lightbox-figure figcaption strong { color: var(--white); font-family: var(--font-display); font-size: clamp(1.15rem, 2.4vw, 1.6rem); font-weight: 600; }
.lightbox-figure figcaption span { color: rgba(255, 255, 255, 0.72); }
.lightbox-count { color: var(--gold-bright) !important; font-size: 0.72rem; font-weight: 800; letter-spacing: 0.16em; text-transform: uppercase; }
.lightbox-close,
.lightbox-nav {
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.06);
  color: var(--white);
  cursor: pointer;
  transition: background 0.2s var(--ease), border-color 0.2s var(--ease);
}
.lightbox-close:hover,
.lightbox-nav:hover { border-color: var(--gold-bright); background: rgba(230, 188, 92, 0.16); }
.lightbox-close:focus-visible,
.lightbox-nav:focus-visible { outline: 3px solid var(--gold-bright); outline-offset: 2px; }
.lightbox-close { position: absolute; top: 1rem; right: 1rem; z-index: 2; width: 2.75rem; height: 2.75rem; font-size: 1.6rem; line-height: 1; }
.lightbox-nav { width: 3.25rem; height: 3.25rem; margin: 0 clamp(0.5rem, 2vw, 1.5rem); font-size: 1.3rem; }
.lightbox-nav[hidden] { visibility: hidden; display: grid; }

@media (max-width: 760px) {
  .gallery-grid { --row-height: 165px; gap: 0.5rem; }
  .gallery-item { border-radius: var(--radius-sm); }
  .gallery-item figcaption { padding: 1.8rem 0.65rem 0.6rem; }
  .gallery-item figcaption strong { font-size: 0.8rem; }
  .gallery-item figcaption span { display: none; }
  .gallery-filters { width: 100%; }
  .gallery-lightbox[open] { grid-template-columns: 1fr; }
  .lightbox-figure { padding: 3.5rem 0.75rem 5.5rem; }
  .lightbox-nav { position: absolute; bottom: 1.25rem; margin: 0; }
  .lightbox-prev { left: 1.25rem; }
  .lightbox-next { right: 1.25rem; }
}

@media (prefers-reduced-motion: reduce) {
  .gallery-open img { transition: none; }
  .gallery-item:hover .gallery-open img { transform: none; }
}
