/* ==========================================================================
   06-gallery.css
   Everything specific to gallery.html: the solid navbar variant, the page
   header band, the filter chips, the masonry grid, and the lightbox.

   Loaded only by gallery.html, so nothing here affects the home page.
   ========================================================================== */


/* ---- Solid navbar ---------------------------------------------------------
   The home page navbar starts transparent over the hero and js/nav.js adds
   .nav--scrolled once you scroll. This page has no hero, so white-on-white
   would be invisible for the first 50px. .nav--solid pins the scrolled look on
   from the start; the rules below mirror the .nav--scrolled ones in
   04-components.css and must be kept in step with them.                    */

.nav--solid {
  background-color: rgb(255 255 255 / 0.95);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow-nav);
}

.nav--solid .nav__brand-text  { color: var(--purple); }
.nav--solid .nav__link        { color: var(--charcoal); }
.nav--solid .nav__link:hover  { color: var(--purple); }
.nav--solid .nav__toggle      { color: var(--charcoal); }

.nav--solid .nav__cta {
  background-color: var(--purple);
  color: var(--white);
  box-shadow: var(--shadow-button);
}
.nav--solid .nav__cta:hover { background-color: rgb(107 44 145 / 0.9); }

/* The page you are already on, marked in the navbar. */
.nav__link--current {
  color: var(--purple);
  font-weight: 600;
}


/* ---- Page header ----------------------------------------------------------
   A short purple band standing in for the home page's full-height hero. The
   top padding clears the fixed navbar.                                     */

.page-head {
  background-color: var(--deep-purple);
  padding-top: calc(var(--nav-height) + 3rem);
  padding-bottom: 3rem;
  text-align: center;
}

.page-head__label { color: var(--light-purple); }

.page-head__title {
  margin-top: 0.75rem;
  font-family: var(--font-display);
  font-size: var(--text-4xl);
  line-height: var(--lh-4xl);
  font-weight: 700;
  color: var(--white);
}

.page-head__lede {
  margin: 1.25rem auto 0;
  max-width: 640px;
  font-size: var(--text-base);
  line-height: var(--leading-relaxed);
  color: rgb(255 255 255 / 0.85);
}

@media (min-width: 768px) {
  .page-head       { padding-top: calc(var(--nav-height) + 4.5rem); padding-bottom: 4.5rem; }
  .page-head__title { font-size: var(--text-5xl); line-height: var(--lh-5xl); }
  .page-head__lede  { font-size: var(--text-lg); }
}


/* ---- Filter chips ---------------------------------------------------------
   Plain buttons, so they work without JavaScript as well — gallery.js only
   adds the filtering behaviour on top.                                     */

.gallery-section { padding-block: 3rem; }

@media (min-width: 768px) {
  .gallery-section { padding-block: 4rem; }
}

.filters {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.625rem;
}

.filter {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1.125rem;
  border: 1px solid var(--border-gray);
  border-radius: var(--radius-full);
  background-color: var(--white);
  font-size: var(--text-sm);
  line-height: var(--lh-sm);
  font-weight: 500;
  color: var(--charcoal);
  cursor: pointer;
  transition: background-color 200ms ease, color 200ms ease, border-color 200ms ease;
}

.filter:hover {
  border-color: var(--purple);
  color: var(--purple);
}

.filter--active {
  background-color: var(--purple);
  border-color: var(--purple);
  color: var(--white);
}
.filter--active:hover { color: var(--white); }

.filter__count {
  font-size: var(--text-xs);
  line-height: var(--lh-xs);
  font-weight: 600;
  color: var(--soft-gray);
}
.filter--active .filter__count { color: rgb(255 255 255 / 0.75); }

.gallery-status {
  margin-top: 1.25rem;
  text-align: center;
  font-size: var(--text-sm);
  line-height: var(--lh-sm);
  color: var(--soft-gray);
}


/* ---- Masonry grid ---------------------------------------------------------
   CSS columns rather than a row grid: the photographs are a mix of portrait
   and landscape, and columns let every one keep its own aspect ratio instead
   of being cropped to a common tile shape. Filtering just sets display:none
   on the tiles that do not match, and the columns reflow themselves.

   The trade-off is reading order — columns run top-to-bottom, so tiles fill
   down the first column before the second. That is fine for a gallery, where
   there is no sequence to follow.                                          */

.grid-masonry {
  margin-top: 2rem;
  column-count: 1;
  column-gap: 1rem;
}

@media (min-width: 640px)  { .grid-masonry { column-count: 2; } }
@media (min-width: 1024px) { .grid-masonry { column-count: 3; column-gap: 1.25rem; } }
@media (min-width: 1280px) { .grid-masonry { column-count: 4; } }

/* Subtitle dividers within the Education category (Book Donations, School
   Visits & Classrooms, Annex Construction). column-span: all breaks the
   masonry columns so the label reads across the full width instead of
   landing wherever the shortest column happens to be.

   They only make sense when a single category is on screen, so they stay
   hidden except while the Education filter is active — see gallery.js,
   which toggles .grid-masonry--education on the grid. */
.gallery-subtitle {
  display: none;
  column-span: all;
  margin: 0 0 1rem;
  font-family: var(--font-display);
  font-size: var(--text-xl);
  line-height: var(--lh-xl);
  font-weight: 600;
  color: var(--charcoal);
}

.gallery-subtitle:not(:first-child) {
  margin-top: 0.5rem;
}

.grid-masonry--education .gallery-subtitle {
  display: block;
}

.tile {
  break-inside: avoid;
  /* `break-inside` alone still lets Chrome split a tile across columns when the
     tile is the last thing in one; the inline-block belt-and-braces stops it. */
  display: inline-block;
  width: 100%;
  margin-bottom: 1rem;
}

@media (min-width: 1024px) {
  .tile { margin-bottom: 1.25rem; }
}

.tile__btn {
  display: block;
  position: relative;
  width: 100%;
  padding: 0;
  border: 0;
  border-radius: var(--radius-card);
  overflow: hidden;
  background-color: var(--lavender-cream);
  cursor: zoom-in;
}

.tile__btn img {
  display: block;
  width: 100%;
  height: auto;
  transition: transform 400ms var(--ease-out-quart);
}

.tile__btn:hover img,
.tile__btn:focus-visible img {
  transform: scale(1.04);
}

.tile__btn:focus-visible {
  outline: 3px solid var(--purple);
  outline-offset: 3px;
}

/* The caption rides in on hover or keyboard focus. On touch there is no hover
   state, but tapping opens the lightbox, which shows the same caption. */
.tile__overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: flex-end;
  padding: 1rem;
  background-image: linear-gradient(
    to top,
    rgb(43 45 66 / 0.85),
    rgb(43 45 66 / 0.25) 45%,
    rgb(43 45 66 / 0)
  );
  opacity: 0;
  transition: opacity 250ms ease;
}

.tile__btn:hover .tile__overlay,
.tile__btn:focus-visible .tile__overlay {
  opacity: 1;
}

.tile__caption {
  font-size: var(--text-sm);
  line-height: var(--lh-sm);
  font-weight: 500;
  color: var(--white);
  text-align: left;
}

/* Hidden by a filter. */
.tile--hidden { display: none; }


/* ---- Lightbox -------------------------------------------------------------
   A single reusable overlay; gallery.js swaps the image and caption rather
   than building one per photograph.                                        */

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.lightbox[hidden] { display: none; }

/* Near-opaque rather than translucent: at 0.94 the fixed navbar and the tile
   captions underneath stayed legible through the overlay. */
.lightbox__backdrop {
  position: absolute;
  inset: 0;
  background-color: rgb(20 12 28 / 0.985);
}

.lightbox__figure {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  max-width: 100%;
}

.lightbox__img {
  display: block;
  max-width: 92vw;
  max-height: 74vh;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: var(--radius-button);
  background-color: rgb(255 255 255 / 0.04);
}

.lightbox__caption {
  max-width: 46rem;
  text-align: center;
  font-size: var(--text-sm);
  line-height: var(--leading-relaxed);
  color: rgb(255 255 255 / 0.9);
}

.lightbox__counter {
  display: block;
  margin-top: 0.375rem;
  font-size: var(--text-xs);
  line-height: var(--lh-xs);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgb(255 255 255 / 0.55);
}

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

.lightbox__close,
.lightbox__nav {
  position: absolute;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.75rem;
  height: 2.75rem;
  border: 0;
  border-radius: var(--radius-full);
  background-color: rgb(255 255 255 / 0.12);
  color: var(--white);
  cursor: pointer;
  transition: background-color 200ms ease;
}

.lightbox__close:hover,
.lightbox__nav:hover {
  background-color: rgb(255 255 255 / 0.25);
}

.lightbox__close:focus-visible,
.lightbox__nav:focus-visible {
  outline: 2px solid var(--white);
  outline-offset: 2px;
}

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

.lightbox__nav--prev { left: 0.75rem;  top: 50%; transform: translateY(-50%); }
.lightbox__nav--next { right: 0.75rem; top: 50%; transform: translateY(-50%); }

@media (min-width: 768px) {
  .lightbox__close      { top: 1.5rem; right: 1.5rem; }
  .lightbox__nav        { width: 3.25rem; height: 3.25rem; }
  .lightbox__nav--prev  { left: 2rem; }
  .lightbox__nav--next  { right: 2rem; }
  .lightbox__img        { max-height: 78vh; }
}

/* While the lightbox is open the page behind it must not scroll. */
.no-scroll { overflow: hidden; }


@media (prefers-reduced-motion: reduce) {
  .tile__btn img,
  .tile__overlay {
    transition: none;
  }
  .tile__btn:hover img,
  .tile__btn:focus-visible img {
    transform: none;
  }
}
