/* Reveal the long photo album without stretching the initial page. */
.hm-school-gallery-reveal { position: relative; scroll-margin-top: 90px; }
.hm-school-gallery-reveal__viewport { position: relative; }
.hm-school-gallery-reveal.is-collapsed .hm-school-gallery-reveal__viewport { max-height: 900px; overflow: hidden; }
.hm-school-gallery-reveal.is-collapsed .hm-school-gallery-reveal__viewport::after { content: ''; position: absolute; inset: auto 0 0; height: 140px; background: linear-gradient(transparent, var(--school-gallery-fade, #f2ece1)); pointer-events: none; }
.hm-school-gallery-reveal.is-expanded .hm-school-gallery-reveal__viewport { max-height: none; overflow: visible; }
.hm-school-gallery-reveal__toggle { display: flex; align-items: center; justify-content: center; gap: 24px; min-width: 210px; min-height: 52px; margin: 20px auto 0; padding: 12px 26px; border: 1px solid #b5a783; background: transparent; color: #152b22; font: inherit; font-weight: 600; cursor: pointer; }
.hm-school-gallery-reveal__toggle[hidden] { display: none; }
.hm-school-gallery-reveal__toggle:hover { background: #e8dfce; }
.hm-school-gallery-reveal__toggle:focus-visible { outline: 2px solid #152b22; outline-offset: 4px; }
@media (max-width: 760px) {
  .hm-school-gallery-reveal.is-collapsed .hm-school-gallery-reveal__viewport { max-height: calc(85vh + 200px); max-height: calc(85svh + 200px); }
  .hm-school-gallery-reveal.is-expanded .hm-school-gallery-reveal__viewport { max-height: none; overflow: visible; }
}

.hm-school-photo-open { display: block; width: 100%; padding: 0; border: 0; background: transparent; cursor: zoom-in; }
.hm-school-photo-open:focus-visible { outline: 3px solid #9f793b; outline-offset: -3px; }
.hm-school-field__gallery figcaption { pointer-events: none; }
.hm-school-lightbox { width: min(2000px, calc(100vw - 48px)); max-width: 2000px; max-height: 92vh; padding: 0; border: 0; background: transparent; overflow: visible; }
.hm-school-lightbox::backdrop { background: rgba(8, 20, 15, .88); }
.hm-school-lightbox img { display: block; width: auto; max-width: 100%; max-height: 86vh; height: auto; margin: auto; object-fit: contain; }
.hm-school-lightbox__close { position: absolute; z-index: 1; right: 0; top: -42px; width: 36px; height: 36px; border: 1px solid #fff; border-radius: 50%; background: #152b22; color: #fff; font-size: 26px; cursor: pointer; }
body.hm-photo-modal-open { overflow: hidden; }
@media (max-width: 760px) { .hm-school-lightbox { width: calc(100vw - 24px); } }

.hm-school-lightbox__prev, .hm-school-lightbox__next { position: absolute; z-index: 1; top: 50%; transform: translateY(-50%); width: 48px; height: 48px; border: 1px solid rgba(255,255,255,.7); border-radius: 50%; background: rgba(15,35,26,.85); color: #fff; font-size: 26px; cursor: pointer; }
.hm-school-lightbox__prev { left: 8px; }
.hm-school-lightbox__next { right: 8px; }
.hm-school-lightbox__count { position: absolute; bottom: -36px; left: 0; right: 0; margin: 0; color: #fff; text-align: center; font-size: 13px; }
@media (max-width: 760px) { .hm-school-lightbox__prev, .hm-school-lightbox__next { width: 42px; height: 42px; } }

.hm-school-field__gallery .lyl-bs-photo-journal__video { background: #12271f; }
.hm-school-field__gallery .lyl-bs-photo-journal__video video { display: block; width: 100%; height: auto; aspect-ratio: 16 / 9; }
.hm-school-field__gallery .lyl-bs-photo-journal__video figcaption { position: static; display: flex; justify-content: space-between; gap: 12px; padding: 12px 16px; color: #fff; font-size: 12px; line-height: 1.5; font-family: inherit; text-shadow: none; }
@media (max-width: 760px) { .hm-school-field__gallery .lyl-bs-photo-journal__video figcaption { flex-direction: column; gap: 2px; padding: 8px 10px; font-size: 10px; } }

.school-gallery-video { max-width: 780px; margin: 0 auto 32px; overflow: hidden; background: #12271f; }
.school-gallery-video :is(video, iframe) { display: block; width: 100%; height: auto; aspect-ratio: 16 / 9; border: 0; }
.school-gallery-video figcaption { display: flex; justify-content: space-between; gap: 12px; padding: 12px 16px; color: #fff; font-size: 12px; line-height: 1.5; }
.school-gallery-video figcaption span { white-space: nowrap; color: #d5c8a8; }

.lyl-shared-photo-masonry { columns: 3; column-gap: 14px; }
.lyl-shared-photo-masonry figure { margin: 0 0 14px; break-inside: avoid; }
.lyl-shared-photo-masonry img { display: block; width: 100%; height: auto; }
@media (max-width:760px) { .lyl-shared-photo-masonry { columns:2; column-gap:8px; } .lyl-shared-photo-masonry figure { margin-bottom:8px; } }
#student-connections [data-school-gallery] { margin:32px 0; }

/* Let desktop albums use the viewport while keeping readable photo widths. */
@media (min-width: 761px) {
  [data-school-gallery] {
    width: var(--gallery-wide-width, 100%);
    max-width: none;
    margin-left: var(--gallery-wide-offset, 0px) !important;
    margin-right: 0 !important;
  }
  [data-school-gallery] :is(.lyl-shared-photo-masonry, .lyl-bs-photo-journal__masonry, .hm-school-field__gallery) {
    column-width: 300px !important;
    column-count: auto !important;
    column-gap: 16px;
  }
}

/* Photo captions belong to the enlarged view. */
[data-school-gallery] figcaption { display: none; }
.hm-school-lightbox__caption { margin: 10px 0 0; color: #fff; text-align: center; font-size: 14px; line-height: 1.6; }
.hm-school-lightbox__caption[hidden] { display: none; }
.hm-school-lightbox img { max-height: 78vh; }

/* Site-wide: six photos or fewer stay fully visible within the content. */
[data-school-gallery].is-small-collection {
  width: 100%;
  max-width: 100%;
  margin-left: 0 !important;
}
[data-school-gallery].is-small-collection :is(.lyl-shared-photo-masonry, .lyl-bs-photo-journal__masonry, .hm-school-field__gallery) {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
  columns: auto !important;
}
[data-school-gallery].is-small-collection figure { margin: 0; }
[data-school-gallery].is-small-collection figcaption { display: block; margin-top: 10px; font-size: 13px; line-height: 1.8; }
[data-school-gallery].is-small-collection .hm-school-gallery-reveal__toggle { display: none; }
@media (max-width: 760px) {
  [data-school-gallery].is-small-collection :is(.lyl-shared-photo-masonry, .lyl-bs-photo-journal__masonry, .hm-school-field__gallery) { grid-template-columns: minmax(0, 1fr); }
}

.school-gallery-video figcaption a { color: #d5c8a8; text-decoration: underline; text-underline-offset: 3px; white-space: nowrap; }
