.community-gallery {
  --gallery-red: #a63236;
  --gallery-line: #ccd5dc;
  --gallery-matte: #eef1f3;
  padding: 0 0 clamp(4rem, 8vw, 6rem);
  background: #fff;
  color: var(--navy);
  scroll-margin-top: 5.5rem;
}

.community-gallery-intro {
  padding: clamp(3rem, 7vw, 5.5rem) 0;
  background: var(--navy);
  color: #fff;
  border-top: 5px solid var(--gallery-red);
}

.community-gallery-heading {
  display: grid;
  grid-template-columns: 1.35fr 1fr;
  gap: clamp(1rem, 5vw, 4rem);
  align-items: end;
}

.community-gallery-kicker {
  display: flex;
  align-items: center;
  gap: .75rem;
  margin: 0;
  color: #dee6ed;
  font-size: .73rem;
  font-weight: 800;
  letter-spacing: .17em;
  text-transform: uppercase;
}

.community-gallery-kicker::before {
  content: '';
  width: 1.75rem;
  height: 2px;
  background: #e48e90;
}

.community-gallery h2 {
  margin: .75rem 0 0;
  font-size: clamp(2.65rem, 6.4vw, 5rem);
  line-height: 1;
  text-wrap: balance;
}

.community-gallery-summary {
  max-width: 30ch;
  margin: 0 0 .2rem;
  color: #dee6ed;
  font-size: clamp(1rem, 1.6vw, 1.15rem);
}

.community-gallery-group {
  margin-top: clamp(2.25rem, 5vw, 3.75rem);
}

.community-gallery-group h3 {
  margin: 0 0 1.1rem;
  padding-bottom: .7rem;
  border-bottom: 1px solid var(--gallery-line);
  font: normal clamp(1.45rem, 3vw, 2rem)/1.2 Georgia, serif;
  letter-spacing: -.02em;
}

.community-gallery-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(1rem, 2vw, 1.5rem);
  margin: 0;
  padding: 0;
  list-style: none;
}

.community-gallery-grid--lead {
  grid-template-columns: minmax(0, 7fr) minmax(0, 5fr);
}

.community-gallery-grid--town {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.community-gallery-photo {
  display: flex;
  flex-direction: column;
  height: 100%;
  color: inherit;
  background: #fff;
  border: 1px solid var(--gallery-line);
  text-decoration: none;
}

.community-gallery-frame {
  display: block;
  position: relative;
  flex: none;
  aspect-ratio: 4 / 3;
  background: var(--gallery-matte);
}

.community-gallery-grid--lead li:nth-child(2) .community-gallery-frame {
  aspect-ratio: 20 / 21;
}

.community-gallery-grid--town .community-gallery-frame {
  aspect-ratio: 4 / 5;
}

.community-gallery-frame img {
  display: block;
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.community-gallery-caption {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: .65rem;
  align-items: center;
  flex: 1;
  min-height: 3.6rem;
  padding: .75rem clamp(.65rem, 1.5vw, 1rem);
  font-size: .89rem;
  font-weight: 700;
  line-height: 1.35;
}

.community-gallery-number {
  color: var(--gallery-red);
  font-size: .7rem;
  font-variant-numeric: tabular-nums;
}

.community-gallery-expand {
  width: 1.75rem;
  height: 1.75rem;
  background:
    linear-gradient(currentColor, currentColor) center / 9px 1px no-repeat,
    linear-gradient(currentColor, currentColor) center / 1px 9px no-repeat;
  border: 1px solid var(--gallery-line);
  border-radius: 50%;
  transition: background-color .15s ease, color .15s ease;
}

.community-gallery-photo:hover,
.community-gallery-photo:focus-visible {
  border-color: var(--navy);
}

.community-gallery-photo:hover .community-gallery-expand,
.community-gallery-photo:focus-visible .community-gallery-expand {
  background-color: var(--navy);
  color: #fff;
  border-color: var(--navy);
}

.community-gallery-jump {
  display: inline-block;
  margin-top: 1.5rem;
  color: #a63236;
  font-weight: 700;
  text-underline-offset: .22em;
}

.community-gallery-photo:focus-visible,
.community-gallery-jump:focus-visible {
  outline: 2px solid #a63236;
  outline-offset: 4px;
}

.community-viewer {
  width: min(94vw, 66rem);
  max-height: 94vh;
  max-height: 94dvh;
  padding: 0;
  color: #fff;
  background: var(--navy);
  border: 1px solid #718597;
  box-shadow: 0 12px 48px #081b2b80;
}

.community-viewer::backdrop {
  background: #081b2be8;
}

.community-viewer:not([open]) {
  display: none;
}

html:has(.community-viewer[open]) {
  overflow: hidden;
}

.community-viewer-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: .65rem;
  padding: .6rem clamp(.65rem, 2vw, 1rem);
  color: #dee6ed;
  font-size: .85rem;
}

.community-viewer button {
  min-height: 44px;
  padding: .4rem .75rem;
  color: #fff;
  background: transparent;
  border: 1px solid #8a9bab;
  font-size: .85rem;
}

.community-viewer button:hover {
  color: var(--navy);
  background: #fff;
}

.community-viewer button:focus-visible,
.community-viewer a:focus-visible {
  outline: 2px solid #f3b1b3;
  outline-offset: 3px;
}

.community-viewer-media {
  display: grid;
  place-items: center;
  height: min(65vh, 44rem);
  height: min(65dvh, 44rem);
  background: var(--deep);
}

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

.community-viewer-media p {
  margin: 1rem;
  text-align: center;
}

.community-viewer-details {
  margin: 0;
  color: #fff;
  font: normal clamp(1.05rem, 2.4vw, 1.4rem)/1.25 Georgia, serif;
}

.community-viewer-controls {
  display: flex;
  gap: .5rem;
}

@media (max-width: 760px) {
  .community-gallery-heading {
    grid-template-columns: 1fr;
  }

  .community-gallery h2 {
    text-wrap: initial;
  }

  .community-gallery-summary {
    max-width: 48ch;
  }

  .community-gallery-grid,
  .community-gallery-grid--town {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .community-gallery-grid--lead {
    grid-template-columns: minmax(0, 7fr) minmax(0, 5fr);
  }
}

@media (max-width: 820px) {
  .community-gallery {
    scroll-margin-top: 10.5rem;
  }
}

@media (max-width: 500px) {
  .community-gallery-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .community-viewer-details {
    flex-basis: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  .community-gallery-expand {
    transition: none;
  }
}
