.family-gallery {
  --gallery-spread: min(34vw, 455px);
  position: relative;
  width: min(1460px, 100%);
  margin: 72px auto 68px;
  isolation: isolate;
  z-index: 2;
}

.family-gallery-stage {
  position: relative;
  height: 690px;
  perspective: 1450px;
  transform-style: preserve-3d;
  touch-action: pan-y;
  outline: 0;
}

.family-gallery-stage:focus-visible {
  outline: 0;
  box-shadow: inset 0 0 0 3px var(--red);
  border-radius: 28px;
}

.family-gallery-slide {
  position: absolute;
  top: 0;
  left: 50%;
  width: clamp(360px, 29vw, 400px);
  margin: 0;
  padding: 10px 10px 16px;
  background: #fffaf0;
  border: 1px solid #fff9;
  border-radius: 27px;
  box-shadow:
    inset 0 1px 0 #fff,
    0 8px 14px #3c2c181f,
    0 28px 58px #3827143d;
  opacity: 0;
  pointer-events: none;
  transform: translate3d(-50%, calc(var(--photo-y, 0px) + 52px), -260px) scale(.68);
  transform-origin: 50% 82%;
  transition:
    transform .9s cubic-bezier(.22, 1, .36, 1),
    opacity .6s ease,
    filter .8s ease,
    box-shadow .8s ease;
  filter: saturate(.75) brightness(.82);
}

.family-gallery-slide::before {
  content: "";
  position: absolute;
  z-index: -1;
  inset: 28px -18px -24px 22px;
  border-radius: 32px;
  background: #1b271f45;
  filter: blur(21px);
  transform: rotate(4deg) translateY(10px);
  opacity: .72;
}

.family-gallery-slide picture {
  display: block;
  overflow: hidden;
  border-radius: 19px;
  background: #d6c7aa;
  box-shadow: inset 0 0 0 1px #2a1c1017;
}

.family-gallery-slide img {
  width: 100%;
  height: clamp(530px, 42.8vw, 590px);
  object-fit: cover;
  opacity: 0;
  transform: scale(1.025);
  transition: opacity .45s ease, transform 1.1s var(--ease);
}

.family-gallery-slide.is-loaded img { opacity: 1; }
.family-gallery-slide.is-active img { animation: gallery-breathe 5.2s ease-in-out infinite; }

.family-gallery-slide figcaption {
  min-height: 66px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 3px;
  padding: 11px 10px 1px;
  color: var(--ink);
  font: italic 17px/1.25 var(--serif);
}

.family-gallery-slide figcaption span {
  color: var(--red);
  font: 700 9px/1.35 var(--body);
  letter-spacing: .14em;
  text-transform: uppercase;
}

.family-gallery-slide.is-active {
  z-index: 4;
  opacity: 1;
  pointer-events: auto;
  filter: none;
  transform: translate3d(-50%, var(--photo-y, 0px), 80px) rotate(-1.2deg) scale(1);
  box-shadow:
    inset 0 1px 0 #fff,
    0 9px 17px #3c2c1824,
    0 36px 72px #38271459;
}

.family-gallery-slide.is-prev {
  z-index: 2;
  opacity: .68;
  transform: translate3d(calc(-50% - var(--gallery-spread)), calc(var(--photo-y, 0px) + 38px), -115px) rotate(-7deg) scale(.83);
}

.family-gallery-slide.is-next {
  z-index: 3;
  opacity: .73;
  transform: translate3d(calc(-50% + var(--gallery-spread)), calc(var(--photo-y, 0px) + 28px), -90px) rotate(7deg) scale(.86);
}

.family.motion-in-view .family-gallery-slide.is-active,
.family.motion-in-view .family-gallery-slide.is-prev,
.family.motion-in-view .family-gallery-slide.is-next {
  will-change: transform;
}

.family-gallery-controls {
  position: relative;
  z-index: 7;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 16px;
  width: min(760px, calc(100% - 44px));
  margin: 9px auto 0;
}

.family-gallery-arrow {
  width: 50px;
  height: 50px;
  flex: 0 0 50px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid #5d49342b;
  border-radius: 50%;
  background: #fffaf0d9;
  color: var(--wine);
  -webkit-backdrop-filter: blur(13px) saturate(1.25);
  backdrop-filter: blur(13px) saturate(1.25);
  box-shadow: inset 0 1px 1px #fff, 0 7px 18px #4b391c21;
  transition: transform .25s var(--ease), box-shadow .25s var(--ease), background .25s;
}

.family-gallery-arrow span { font-size: 22px; line-height: 1; }
.family-gallery-arrow:hover { transform: translateY(-3px); background: #fffaf0; box-shadow: inset 0 1px 1px #fff, 0 12px 25px #4b391c30; }
.family-gallery-arrow:active { transform: translateY(1px) scale(.97); }

.family-gallery-dots {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  padding: 4px 14px;
  border: 1px solid #5d49341c;
  border-radius: 999px;
  background: #fffaf09c;
  box-shadow: inset 0 1px 0 #fff, 0 6px 16px #48371917;
}

.family-gallery-dots button {
  position: relative;
  width: 24px;
  height: 42px;
  padding: 0;
  border: 0;
  background: transparent;
}

.family-gallery-dots button::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: #705f4870;
  transform: translate(-50%, -50%);
  transition: width .35s var(--ease), background .25s, transform .25s;
}

.family-gallery-dots button:hover::before { transform: translate(-50%, -50%) scale(1.25); background: var(--red); }
.family-gallery-dots button[aria-current="true"]::before { width: 22px; background: var(--red); }

.family-gallery-count {
  min-width: 59px;
  color: #665b4b;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .12em;
}

.family-gallery-count b {
  color: var(--red);
  font: 25px/1 var(--display);
  letter-spacing: 0;
}

@keyframes gallery-breathe {
  0%, 100% { transform: scale(1.025) translateY(0); }
  50% { transform: scale(1.04) translateY(-3px); }
}

.gallery-status {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

@media (min-width: 761px) {
  .family .scene-leaf {
    left: clamp(22px, 4vw, 64px);
    top: 51%;
    width: 120px;
  }
}

.motion-ready .family:not(.motion-in-view) .family-gallery-slide.is-active img,
.page-hidden .family-gallery-slide.is-active img {
  animation-play-state: paused;
}

@media (max-width: 1050px) {
  .family-gallery { --gallery-spread: min(35vw, 340px); }
  .family-gallery-stage { height: 630px; }
  .family-gallery-slide { width: clamp(340px, 34vw, 360px); }
  .family-gallery-slide img { height: clamp(505px, 51vw, 530px); }
}

@media (max-width: 760px) {
  .family .scene-leaf { z-index: 1; }

  .family-gallery {
    --gallery-spread: min(72vw, 330px);
    margin: 50px auto 52px;
  }

  .family-gallery-stage {
    height: min(150vw, 590px);
    min-height: 530px;
  }

  .family-gallery-slide {
    width: min(calc(100vw - 68px), 350px);
    padding: 8px 8px 13px;
    border-radius: 24px;
    filter: none;
  }

  .family-gallery-slide::before {
    inset: 25px -10px -18px 16px;
    filter: none;
    opacity: .28;
  }

  .family-gallery-slide picture { border-radius: 17px; }
  .family-gallery-slide img { height: min(128vw, 505px); }
  .family-gallery-slide figcaption { min-height: 60px; padding: 9px 8px 0; font-size: 15px; }
  .family-gallery-slide:not(.is-active) figcaption { opacity: 0; }

  .family-gallery-slide.is-prev {
    opacity: .5;
    transform: translate3d(calc(-50% - var(--gallery-spread)), calc(var(--photo-y, 0px) + 28px), -120px) rotate(-7deg) scale(.8);
  }

  .family-gallery-slide.is-next {
    opacity: .57;
    transform: translate3d(calc(-50% + var(--gallery-spread)), calc(var(--photo-y, 0px) + 24px), -100px) rotate(7deg) scale(.82);
  }

  .family-gallery-controls { width: calc(100% - 12px); gap: 4px; }
  .family-gallery-arrow { width: 44px; height: 44px; flex-basis: 44px; }
  .family-gallery-dots { gap: 0; padding: 2px 4px; }
  .family-gallery-dots button { width: 24px; height: 44px; }
  .family-gallery-dots button[aria-current="true"]::before { width: 18px; }
  .family-gallery-count { display: none; }
}

@media (max-width: 370px) {
  .family-gallery-stage { min-height: 510px; }
  .family-gallery-dots { padding-inline: 2px; }
}
