/* ==========================================================================
   Gallery (/gallery) and photo albums (/gallery/{slug})
   Album grid, label chips, school moments and an album's photos.
   ========================================================================== */

/* Albums ------------------------------------------------------------------- */
.gallery-albums__body {
  margin-top: clamp(2.25rem, 1.8rem + 1.5vw, 3rem);
}

/* Label filter chips (shown by gallery.js) */
.gallery-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: clamp(2rem, 1.6rem + 1.2vw, 2.5rem);
}
.gallery-chip {
  display: inline-flex;
  align-items: center;
  min-height: 2.5rem;
  padding: 0.35rem 1.1rem;
  border: 1px solid rgb(13 26 54 / 0.12);
  border-radius: 999px;
  background: rgb(255 255 255 / 0.65);
  color: var(--ink-soft);
  font-size: 0.875rem;
  font-weight: 650;
  line-height: 1.2;
  transition:
    background-color 0.3s var(--ease-out),
    border-color 0.3s var(--ease-out),
    color 0.3s var(--ease-out),
    box-shadow 0.3s var(--ease-out);
}
.gallery-chip:hover {
  border-color: rgb(240 180 0 / 0.55);
  background: var(--white);
  color: var(--ink);
}
.gallery-chip[aria-pressed="true"] {
  border-color: var(--navy-900);
  background: var(--navy-900);
  color: var(--white);
  box-shadow: var(--shadow-soft);
}
.gallery-chip:focus-visible {
  border-radius: 999px;
}

.gallery-albums__grid {
  display: grid;
  gap: 1.25rem;
  grid-template-columns: minmax(0, 1fr);
}
@media (min-width: 30rem) {
  .gallery-albums__grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
@media (min-width: 64rem) {
  .gallery-albums__grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}
.gallery-albums__grid > li {
  display: flex;
  min-width: 0;
}

/* Album card: cover on top, title below (the title comes first in the
   markup so a screen reader hears it first; flex order puts the cover on top). */
.gallery-album {
  display: flex;
  flex-direction: column;
  width: 100%;
  padding: 0.7rem;
  border: 1px solid rgb(232 224 207 / 0.9);
  border-radius: var(--radius-xl);
  background: var(--white);
  color: var(--ink);
  text-decoration: none;
  box-shadow: var(--shadow-soft);
  transition:
    transform 0.5s var(--ease-out),
    box-shadow 0.5s var(--ease-out),
    border-color 0.5s var(--ease-out);
}
.gallery-album:hover {
  transform: translateY(-4px);
  border-color: rgb(240 180 0 / 0.45);
  box-shadow: var(--shadow-lift);
}
.gallery-album:focus-visible {
  border-radius: var(--radius-xl);
}
.gallery-album__media {
  position: relative;
  order: -1;
  display: block;
  overflow: hidden;
  aspect-ratio: 4 / 3;
  border-radius: calc(var(--radius-xl) - 0.55rem);
  background: linear-gradient(150deg, var(--navy-700), var(--navy-950));
}
.gallery-album__media img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 1.2s var(--ease-out);
}
.gallery-album:hover .gallery-album__media img {
  transform: scale(1.08);
}
.gallery-album__shade {
  position: absolute;
  inset: 0;
  background: linear-gradient(0deg, rgb(5 15 42 / 0.6), rgb(5 15 42 / 0) 55%);
}

/* An album without photos yet: navy panel with the sunburst and an icon */
.gallery-album__placeholder {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  isolation: isolate;
  overflow: hidden;
}
.gallery-album__rays {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: -1;
  width: 150%;
  height: auto;
  aspect-ratio: 1;
  color: var(--gold-500);
  opacity: 0.16;
  transform: translate(-50%, -50%);
  -webkit-mask-image: radial-gradient(circle closest-side, black 10%, transparent 100%);
  mask-image: radial-gradient(circle closest-side, black 10%, transparent 100%);
}
.gallery-album__placeholder-icon {
  width: 2.4rem;
  height: 2.4rem;
  color: var(--gold-300);
}

.gallery-album__label,
.gallery-album__count {
  position: absolute;
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  line-height: 1.4;
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}
.gallery-album__label {
  top: 0.75rem;
  left: 0.75rem;
  max-width: calc(100% - 1.5rem);
  overflow: hidden;
  padding: 0.18rem 0.7rem;
  background: rgb(255 255 255 / 0.9);
  color: var(--navy-800);
  font-size: 0.66rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}
.gallery-album__count {
  right: 0.75rem;
  bottom: 0.75rem;
  gap: 0.4rem;
  padding: 0.28rem 0.7rem;
  background: rgb(5 15 42 / 0.6);
  color: var(--white);
  font-size: 0.75rem;
  font-weight: 700;
}
.gallery-album__count .icon {
  width: 0.85rem;
  height: 0.85rem;
}

.gallery-album__body {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 0.65rem 0.45rem;
}
.gallery-album__title {
  font-size: 1.25rem;
  font-weight: 540;
  line-height: 1.25;
  transition: color 0.3s;
}
.gallery-album:hover .gallery-album__title {
  color: var(--navy-700);
}
.gallery-album__arrow {
  width: 1.1rem;
  height: 1.1rem;
  margin-top: 0.2rem;
  color: var(--gold-600);
  transition: transform 0.3s var(--ease-out);
}
.gallery-album:hover .gallery-album__arrow {
  transform: translate(2px, -2px);
}

/* School moments (navy band) -------------------------------------------- */
.gallery-moments {
  overflow: hidden;
  isolation: isolate;
}
.gallery-moments__rays {
  position: absolute;
  top: -28rem;
  left: 50%;
  z-index: -1;
  width: 56rem;
  height: 56rem;
  color: var(--gold-500);
  opacity: 0.1;
  transform: translateX(-50%);
  -webkit-mask-image: radial-gradient(circle closest-side, black 0%, rgb(0 0 0 / 0.5) 55%, transparent 100%);
  mask-image: radial-gradient(circle closest-side, black 0%, rgb(0 0 0 / 0.5) 55%, transparent 100%);
  animation: turn 160s linear infinite;
}

/* Justified rows: each photo keeps its own shape (--r = width / height, so
   the collages are never cropped) and grows in proportion to it, so every
   photo in a row has the same height and the row fills the width. The view
   puts a zero-height break item where a row ends: --sm breaks on phones,
   --lg breaks from 48rem. */
.gallery-moments__grid {
  --gap: 0.7rem;
  display: flex;
  flex-wrap: wrap;
  column-gap: var(--gap);
  margin: clamp(2.5rem, 2rem + 2vw, 3.5rem) 0 calc(var(--gap) * -1);
}
@media (min-width: 48rem) {
  .gallery-moments__grid {
    --gap: 1rem;
  }
}
.gallery-moment {
  flex: var(--r, 1.5) 1 0%;
  min-width: 0;
  margin-bottom: var(--gap);
  aspect-ratio: var(--r, 1.5);
}
.gallery-moments__break {
  flex: 0 0 100%;
  height: 0;
}
@media (max-width: 47.99rem) {
  .gallery-moments__break:not(.gallery-moments__break--sm) {
    display: none;
  }
}
@media (min-width: 48rem) {
  .gallery-moments__break:not(.gallery-moments__break--lg) {
    display: none;
  }
}

.gallery-moment__link,
.gallery-moment__link:focus-visible {
  border-radius: var(--radius);
}
.gallery-moment__link {
  position: relative;
  isolation: isolate;
  display: block;
  height: 100%;
  overflow: hidden;
  background: var(--navy-900);
  box-shadow:
    0 0 0 1px rgb(255 255 255 / 0.07),
    0 22px 44px -28px rgb(0 0 0 / 0.7);
}
@media (min-width: 48rem) {
  .gallery-moment__link,
  .gallery-moment__link:focus-visible {
    border-radius: var(--radius-lg);
  }
}
.gallery-moment__link img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 1.2s var(--ease-out);
}

/* Shared hover details of a photo tile (moments and album photos) */
.gallery-moment__caption,
.gallery-photo__caption {
  position: absolute;
  inset: auto 0 0;
  padding: 2.75rem 1rem 0.95rem;
  background: linear-gradient(0deg, rgb(5 15 42 / 0.82), rgb(5 15 42 / 0));
  color: var(--white);
  font-size: 0.88rem;
  font-weight: 700;
  line-height: 1.35;
  text-align: left;
  opacity: 0;
  transform: translateY(0.5rem);
  transition:
    opacity 0.5s var(--ease-out),
    transform 0.5s var(--ease-out);
}
/* A moment's caption comes before its photo in the HTML (it starts the
   link's name), so it is lifted above the photo, which scales on hover. */
.gallery-moment__caption {
  z-index: 1;
}
.gallery-moment__zoom,
.gallery-photo__zoom {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  display: grid;
  place-items: center;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 999px;
  background: rgb(255 255 255 / 0.92);
  color: var(--navy-800);
  box-shadow: var(--shadow-soft);
  opacity: 0;
  transform: scale(0.85);
  transition:
    opacity 0.4s var(--ease-out),
    transform 0.4s var(--ease-out);
}
.gallery-moment__link:hover img,
.gallery-photo:hover img {
  transform: scale(1.05);
}
.gallery-moment__link:hover .gallery-moment__caption,
.gallery-moment__link:focus-visible .gallery-moment__caption,
.gallery-photo:hover .gallery-photo__caption,
.gallery-photo:focus-visible .gallery-photo__caption,
.gallery-moment__link:hover .gallery-moment__zoom,
.gallery-moment__link:focus-visible .gallery-moment__zoom,
.gallery-photo:hover .gallery-photo__zoom,
.gallery-photo:focus-visible .gallery-photo__zoom {
  opacity: 1;
  transform: none;
}
/* Phones: no hover, and the tiles are small — the viewer shows captions. */
@media (hover: none) {
  .gallery-moment__caption,
  .gallery-photo__caption,
  .gallery-moment__zoom,
  .gallery-photo__zoom {
    display: none;
  }
}

/* One album (/gallery/{slug}) -------------------------------------------- */
.gallery-photos {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-auto-rows: 10rem;
  gap: 0.75rem;
}
@media (min-width: 30rem) {
  .gallery-photos {
    grid-auto-rows: 12rem;
  }
}
@media (min-width: 48rem) {
  .gallery-photos {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    grid-auto-rows: 14rem;
    gap: 1rem;
  }
}
@media (min-width: 64rem) {
  .gallery-photos {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}
/* Tile sizes per column count come from the view (--c2/--r2 on phones,
   --c3/--r3 from 48rem, --c4/--r4 from 64rem; 1 when unset). */
.gallery-photos__item {
  min-width: 0;
  grid-column: span var(--c2, 1);
  grid-row: span var(--r2, 1);
}
@media (min-width: 48rem) {
  .gallery-photos__item {
    grid-column: span var(--c3, 1);
    grid-row: span var(--r3, 1);
  }
}
@media (min-width: 64rem) {
  .gallery-photos__item {
    grid-column: span var(--c4, 1);
    grid-row: span var(--r4, 1);
  }
}

/* An album of one photo: shown large and centred. */
.gallery-photos--single {
  grid-template-columns: minmax(0, 52rem);
  grid-auto-rows: auto;
  justify-content: center;
}
.gallery-photos--single .gallery-photos__item {
  grid-column: auto;
  grid-row: auto;
  aspect-ratio: 3 / 2;
}
/* Shown whole (no crop), on a quiet backdrop. */
.gallery-photos--single .gallery-photo {
  background: var(--paper-2);
}
.gallery-photos--single .gallery-photo img {
  object-fit: contain;
}
@media (min-width: 48rem) {
  .gallery-photos--single {
    grid-template-columns: minmax(0, 52rem);
  }
  .gallery-photos--single .gallery-photos__item {
    grid-column: auto;
    grid-row: auto;
  }
}

.gallery-photo,
.gallery-photo:focus-visible {
  border-radius: var(--radius);
}
.gallery-photo {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--sand);
  box-shadow: var(--shadow-soft);
}
@media (min-width: 48rem) {
  .gallery-photo,
  .gallery-photo:focus-visible {
    border-radius: var(--radius-lg);
  }
}
.gallery-photo img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 1.2s var(--ease-out);
}

.gallery-detail__back {
  display: flex;
  justify-content: center;
  margin-top: clamp(2.5rem, 2rem + 2vw, 3.5rem);
}

/* Photo viewer (built by site.js) ----------------------------------------- */
/* Keeps every photo inside the screen with its caption visible. The stage's
   only row is auto-sized, so the image's max-height: 100% does not limit it
   and a tall photo spills off the bottom on desktop; a definite track does.
   Scoped to the gallery pages; drop it once site.css's .lightbox__stage has
   this rule (requested from the lead). */
.page-gallery .lightbox__stage {
  grid-template: minmax(0, 1fr) / minmax(0, 1fr);
}
