.gallery-hero {
  position: relative;
  isolation: isolate;
  display: flex;
  min-height: clamp(28rem, 43vw, 35rem);
  align-items: end;
  margin-top: clamp(1.25rem, 3.75vw, 3.5rem);
  overflow: hidden;
  border-radius: .75rem clamp(3rem, 7vw, 6rem) .75rem .75rem;
  background: var(--ink);
  color: var(--paper);
}

.gallery-cover, .gallery-hero::after {
  position: absolute;
  z-index: -1;
  inset: 0;
  width: 100%;
  height: 100%;
}

.gallery-cover {
  object-fit: cover;
  object-position: 50% 52%;
  animation: gallery-cover-in 880ms cubic-bezier(.18, .73, .31, 1) both;
}

.gallery-hero::after {
  background:
    linear-gradient(90deg, #112719eb, #11271982 44%, transparent 86%),
    linear-gradient(0deg, #11271995, transparent 59%);
  content: "";
}

.gallery-intro {
  width: 100%;
  padding: clamp(1.35rem, 5.1vw, 4.6rem);
  animation: gallery-rise 560ms 140ms cubic-bezier(.18, .73, .31, 1) both;
}

.gallery-intro h1 {
  max-width: 11ch;
  margin-bottom: .95rem;
  font-size: clamp(3.4rem, 7.2vw, 6.5rem);
  line-height: .98;
  letter-spacing: -.055em;
}

.gallery-intro em { display: block; color: var(--sprout); font-weight: 500; }
.gallery-intro p { max-width: 27rem; color: #f0f4e9; font-size: clamp(1rem, 1.6vw, 1.15rem); }
.gallery-intro-actions { display: flex; flex-wrap: wrap; gap: .65rem; margin-top: 1.25rem; }
.gallery-hero :focus-visible, .photo-viewer :focus-visible { outline-color: var(--sprout); }
.gallery-button-outline { border-color: #eff7e0a8; background: #15332365; color: var(--paper); }
.gallery-button-outline:hover { background: #274c35; }

.gallery-collection { padding-block: clamp(2.65rem, 6vw, 5.5rem) clamp(2.5rem, 5vw, 4.5rem); }

.gallery-section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: .95rem 1.5rem;
  margin-bottom: clamp(1.25rem, 2.65vw, 2rem);
}

.gallery-section-heading h2 {
  font-size: clamp(2.35rem, 5.1vw, 4rem);
}

.gallery-filters { margin: 0; }

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  column-gap: clamp(.65rem, 1.6vw, 1.3rem);
  row-gap: clamp(1.15rem, 2.7vw, 2.15rem);
}

.gallery-photo { min-width: 0; }
.gallery-photo--wide { grid-column: span 2; }
.gallery-collection[data-filtered] .gallery-photo { grid-column: auto; }
.gallery-photo.is-revealing { animation: gallery-rise 550ms cubic-bezier(.18, .73, .31, 1) both; }

.photo-link {
  position: relative;
  display: block;
  height: clamp(14rem, 25vw, 22rem);
  overflow: hidden;
  border-radius: .48rem;
  background: #dce5d3;
}

.photo-link img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 360ms cubic-bezier(.18, .73, .31, 1);
}

.photo-link::after {
  position: absolute;
  right: .65rem;
  bottom: .65rem;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  background:
    linear-gradient(var(--ink), var(--ink)) center / .65rem 1px no-repeat,
    linear-gradient(var(--ink), var(--ink)) center / 1px .65rem no-repeat,
    var(--paper);
  box-shadow: 0 2px 12px #12271935;
  content: "";
}

.photo-link:focus-visible img { transform: scale(1.035); }

@media (hover: hover) {
  .photo-link:hover img { transform: scale(1.045); }
}

.gallery-photo figcaption { margin-top: .55rem; font-size: .9rem; font-weight: 600; }

.gallery-film { padding-bottom: clamp(2.8rem, 6vw, 5.5rem); }

.gallery-film-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 2rem clamp(1.25rem, 5vw, 5rem);
  padding: clamp(1.45rem, 5vw, 4.2rem);
  border-radius: .75rem clamp(2.5rem, 6vw, 5rem) .75rem .75rem;
  background: var(--ink);
  color: var(--paper);
}

.gallery-film-copy h2 { max-width: 12ch; }
.gallery-film-copy p { margin-top: .8rem; color: #dce6d9; font-size: 1.0625rem; }

.gallery-film video {
  display: block;
  width: min(18rem, 100%);
  height: auto;
  max-width: 100%;
  aspect-ratio: 478 / 850;
  margin-inline: auto;
  border-radius: .5rem;
  background: #102419;
  object-fit: cover;
}

body:has(.photo-viewer[open]) { overflow: hidden; }

.photo-viewer {
  width: min(65rem, calc(100% - 1.25rem));
  max-width: none;
  max-height: calc(100% - 1.25rem);
  padding: 0;
  overflow: hidden;
  border: 1px solid #6a8370;
  border-radius: .8rem;
  background: #14271c;
  color: var(--paper);
}

.photo-viewer[open] { animation: gallery-dialog-in 230ms cubic-bezier(.18, .73, .31, 1) both; }
.photo-viewer::backdrop { background: #102217dc; }

.viewer-panel {
  display: grid;
  height: min(52rem, calc(100dvh - 1.5rem));
  grid-template-rows: auto minmax(0, 1fr) auto;
}

.viewer-toolbar, .viewer-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: clamp(.4rem, 2vw, 1.2rem);
  padding: .7rem clamp(.65rem, 2vw, 1.25rem);
}

.viewer-position { color: #d7e0d3; font-size: .9rem; }
.viewer-caption { text-align: center; line-height: 1.28; }

.viewer-button {
  min-height: 2.75rem;
  padding-inline: .76rem;
  border-color: #92a8939c;
  background: transparent;
  color: var(--paper);
}

.viewer-button:hover { background: #2c4b37; }
.viewer-button:disabled { cursor: default; opacity: .55; }

.viewer-stage {
  display: grid;
  min-height: 0;
  place-items: center;
  padding-inline: .55rem;
  overflow: hidden;
  background: #0f2117;
}

.viewer-stage img {
  width: 100%;
  height: 100%;
  min-height: 0;
  object-fit: contain;
}

@keyframes gallery-cover-in {
  from { opacity: .65; transform: scale(1.035); }
  to { opacity: 1; transform: scale(1); }
}

@keyframes gallery-rise {
  from { opacity: .45; transform: translateY(.85rem); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes gallery-dialog-in {
  from { opacity: .55; transform: translateY(.35rem) scale(.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@media (max-width: 62rem) {
  .gallery-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .gallery-photo--wide { grid-column: auto; }
}

@media (max-width: 46rem) {
  .gallery-hero { min-height: clamp(26rem, 75vw, 30rem); }
  .gallery-cover { object-position: 53% 50%; }
  .gallery-hero::after {
    background: linear-gradient(0deg, #112719fa, #112719ad 48%, #11271912 88%);
  }
  .gallery-intro h1 { font-size: clamp(3.45rem, 12vw, 5.3rem); }
  .gallery-intro p { max-width: 22rem; }
  .gallery-intro-actions .button { padding-inline: .75rem; }
  .gallery-collection:not([data-filtered]) .gallery-photo:first-child,
  .gallery-collection:not([data-filtered]) .gallery-photo:last-child { grid-column: 1 / -1; }
  .photo-link { height: clamp(9rem, 36vw, 16rem); }
  .gallery-collection:not([data-filtered]) .gallery-photo:first-child .photo-link,
  .gallery-collection:not([data-filtered]) .gallery-photo:last-child .photo-link {
    height: clamp(12rem, 49vw, 20rem);
  }
  .photo-link::after { right: .42rem; bottom: .42rem; width: 1.6rem; height: 1.6rem; }
  .gallery-film-panel { grid-template-columns: 1fr; }
  .gallery-film video { width: min(16rem, 100%); }
  .viewer-caption { font-size: .9rem; }
}

@media (prefers-reduced-motion: reduce) {
  .gallery-cover, .gallery-intro, .gallery-photo.is-revealing, .photo-viewer[open] {
    animation: none;
  }
  .photo-link:hover img, .photo-link:focus-visible img { transform: none; }
}
