/* ==========================================================================
   Abracabazza: the gallery (gallery.html)
   Sections by type of event (content/gallery.json, rendered by
   scripts/build.mjs): a heading and count, then an even grid of square
   tiles that grows to fit however many photos and videos there are.
   js/gallery.js adds "Show more" and the full-size viewer.
   Tokens come from :root in styles.css; same 900px breakpoint.
   ========================================================================== */

.gallery-page {
  padding: clamp(3rem, 9vw, 6.5rem) var(--gutter) clamp(4rem, 10vw, 8rem);
}

.gallery-page > * {
  max-width: 1320px;
  margin-inline: auto;
}

.gallery-intro {
  display: grid;
  gap: clamp(1.25rem, 3vw, 2rem);
}

.gallery-intro .section-title {
  font-size: clamp(2.6rem, 9vw, 5.5rem);
}

.gallery-intro__lede {
  max-width: 44ch;
  margin: 0;
  font-size: clamp(1.05rem, 1rem + 0.4vw, 1.3rem);
  line-height: 1.6;
  color: var(--ink-soft);
}

@media (min-width: 900px) {
  .gallery-intro {
    grid-template-columns: minmax(0, 7fr) minmax(0, 5fr);
    align-items: end;
    column-gap: clamp(3rem, 6vw, 6rem);
  }
}

/* Section links: stay in reach under the header while scrolling. */
.gallery-tabs {
  position: sticky;
  top: var(--header-h);
  z-index: 5;
  margin-top: clamp(2rem, 5vw, 3rem);
  background: var(--bg);
  box-shadow: 0 1px 0 var(--line);
}

.gallery-tabs ul {
  display: flex;
  gap: 0.25rem 1.75rem;
  margin: 0;
  padding: 0;
  overflow-x: auto;
  list-style: none;
  scrollbar-width: none;
}

.gallery-tabs a {
  display: inline-flex;
  align-items: center;
  min-height: 48px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  white-space: nowrap;
  color: var(--ink-soft);
  text-decoration: none;
}

.gallery-tabs a:hover,
.gallery-tabs a:focus-visible {
  color: var(--gold-light);
}

.gallery-section {
  padding-top: clamp(2.5rem, 6vw, 4rem);
  /* Land below the header and the section links. */
  scroll-margin-top: calc(var(--header-h) + 48px);
}

.gallery-section__head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem 2rem;
  margin-bottom: clamp(1rem, 3vw, 1.5rem);
}

.gallery-section__title {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(2rem, 1.5rem + 2vw, 3.25rem);
  font-weight: 400;
  line-height: 1;
  text-transform: uppercase;
}

.gallery-section__count {
  margin: 0;
  font-size: 0.875rem;
  color: var(--ink-soft);
}

.gallery-section__empty {
  margin: 0;
  padding: clamp(2rem, 6vw, 3.5rem) 1.5rem;
  text-align: center;
  color: var(--ink-soft);
  background: var(--bg-raised);
  box-shadow: inset 0 0 0 1px var(--line);
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(46%, 15rem), 1fr));
  gap: clamp(0.4rem, 1vw, 0.75rem);
  margin: 0;
  padding: 0;
  list-style: none;
}

.gallery-item {
  position: relative;
  aspect-ratio: 1;
  overflow: hidden;
  border-radius: 2px;
  background: var(--bg-raised);
}

.gallery-item__link {
  position: absolute;
  inset: 0;
  display: block;
}

.gallery-item__link:focus-visible {
  outline: 2px solid var(--gold-light);
  outline-offset: -2px;
}

.gallery-item :is(picture, img) {
  width: 100%;
  height: 100%;
}

.gallery-item img {
  object-fit: cover;
  transition: transform 0.4s var(--ease-out);
}

@media (prefers-reduced-motion: no-preference) {
  .gallery-item__link:hover img {
    transform: scale(1.03);
  }
}

.gallery-item__play {
  position: absolute;
  left: 50%;
  top: 50%;
  display: grid;
  place-items: center;
  width: 3.25rem;
  height: 3.25rem;
  padding-left: 3px;
  border-radius: 50%;
  background: rgba(5, 4, 4, 0.7);
  color: var(--ink);
  box-shadow: inset 0 0 0 1px rgba(214, 173, 98, 0.65);
  transform: translate(-50%, -50%);
}

.gallery-section__more {
  display: flex;
  margin: clamp(1.25rem, 3vw, 2rem) auto 0;
}

.gallery-copyright {
  margin-top: clamp(2rem, 5vw, 3rem);
  font-size: 0.8125rem;
  color: var(--ink-soft);
}

.gallery-cta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem 2rem;
  margin-top: clamp(2.5rem, 6vw, 4rem);
  padding-top: clamp(1.75rem, 4vw, 2.5rem);
  border-top: 1px solid var(--line);
}

.gallery-cta__text {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.5rem, 1.2rem + 1.2vw, 2.25rem);
  line-height: 1.1;
  text-transform: uppercase;
}

@media (max-width: 479.98px) {
  .gallery-cta .btn,
  .gallery-section__more {
    width: 100%;
    letter-spacing: 0.14em;
  }
}

/* --------------------------------------------------------------------------
   Viewer: one photo or video at a time, full screen
   -------------------------------------------------------------------------- */

.lightbox {
  width: 100%;
  max-width: 100%;
  height: 100%;
  max-height: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  background: rgba(5, 4, 4, 0.96);
  color: var(--ink);
}

.lightbox::backdrop {
  background: rgba(0, 0, 0, 0.8);
}

/* Flex, not grid: the stage's height is definite (absolute insets), so the
   photo's max-height: 100% resolves and a tall photo never runs off screen. */
.lightbox__stage {
  position: absolute;
  inset: 3.5rem clamp(0.5rem, 6vw, 5rem) 3rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lightbox__stage :is(picture, img, video) {
  max-width: 100%;
  max-height: 100%;
}

.lightbox__stage picture {
  display: contents;
}

.lightbox__stage img,
.lightbox__stage video {
  width: auto;
  height: auto;
  object-fit: contain;
  background: #000;
}

.lightbox__caption {
  position: absolute;
  inset: auto 0 0.9rem;
  margin: 0;
  font-size: 0.8125rem;
  text-align: center;
  color: var(--ink-soft);
}

.lightbox__btn {
  position: absolute;
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border: 0;
  border-radius: 50%;
  background: rgba(20, 17, 19, 0.75);
  color: var(--ink);
  cursor: pointer;
}

.lightbox__btn:hover {
  color: var(--gold-light);
}

.lightbox__close {
  top: 0.5rem;
  right: 0.5rem;
}

.lightbox__prev,
.lightbox__next {
  top: 50%;
  transform: translateY(-50%);
}

.lightbox__prev {
  left: 0.5rem;
}

.lightbox__next {
  right: 0.5rem;
}

/* Phones: the arrows move below the photo, either side of the count, so they
   never cover a video's controls. */
@media (max-width: 599.98px) {
  .lightbox__stage {
    inset: 4rem 0.5rem 4.5rem;
  }

  .lightbox__prev,
  .lightbox__next {
    top: auto;
    bottom: 0.75rem;
    transform: none;
  }

  .lightbox__caption {
    bottom: 1.6rem;
  }
}

/* Small screens: the three section links fit on one line without scrolling. */
@media (max-width: 479.98px) {
  .gallery-tabs ul {
    gap: 0.25rem 1.25rem;
  }

  .gallery-tabs a {
    font-size: 0.6875rem;
    letter-spacing: 0.12em;
  }
}

/* Current page in the footer nav, matching the header's gold. */
.site-footer__nav a[aria-current="page"] {
  color: var(--gold-light);
}
