.manfred-gallery-heading {
  max-width: 58rem;
}

.manfred-gallery-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  column-gap: 44px;
  row-gap: 74px;
  align-items: start;
}

.manfred-gallery-card {
  min-width: 0;
  background: transparent;
}

.manfred-gallery-image-button {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  border-radius: var(--_spacing---very-small);
  background: transparent;
  color: inherit;
  cursor: zoom-in;
  appearance: none;
}

.manfred-gallery-image-button img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: inherit;
  object-fit: contain;
  box-shadow:
    0 31px 42px rgba(18, 22, 27, 0.42),
    0 13px 19px rgba(18, 22, 27, 0.28),
    0 3px 7px rgba(18, 22, 27, 0.18);
  transition:
    box-shadow 260ms ease,
    filter 260ms ease,
    transform 260ms ease;
}

.manfred-gallery-image-button:hover img,
.manfred-gallery-image-button:focus-visible img {
  transform: translateY(-2px);
  filter: saturate(1.02);
  box-shadow:
    0 35px 48px rgba(18, 22, 27, 0.46),
    0 16px 23px rgba(18, 22, 27, 0.3),
    0 4px 9px rgba(18, 22, 27, 0.2);
}

.manfred-gallery-image-button:focus-visible {
  outline: 2px solid var(--brown);
  outline-offset: 5px;
}

.manfred-gallery-details {
  padding-top: 16px;
}

.manfred-gallery-details :is(h2, h3) {
  margin: 0;
  font-family: var(--_typography---font-family--heading);
  color: var(--black);
  font-size: 21px;
  line-height: 1.15;
  font-weight: var(--_typography---font-weight--regular);
}

.manfred-gallery-details p {
  margin: 8px 0 0;
  font-family: var(--_typography---font-family--body);
  color: var(--grey);
  font-size: 12px;
  line-height: 1.35;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

body.manfred-gallery-open {
  overflow: hidden;
}

.manfred-gallery-lightbox {
  position: fixed;
  z-index: 9999;
  inset: 0;
  display: grid;
  place-items: center;
  padding: clamp(16px, 3vw, 48px);
}

.manfred-gallery-lightbox[hidden] {
  display: none;
}

.manfred-gallery-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(242, 239, 235, 0.9);
  opacity: 0;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: opacity 260ms ease;
}

.manfred-gallery-dialog {
  position: relative;
  z-index: 1;
  width: min(100%, 1480px);
  max-height: calc(100vh - clamp(32px, 6vw, 96px));
  padding: clamp(44px, 5vw, 76px) clamp(12px, 2.5vw, 36px) clamp(18px, 2.5vw, 36px);
  border-radius: var(--_spacing---very-small);
  background: rgba(250, 248, 245, 0.96);
  box-shadow: 0 24px 70px rgba(18, 22, 27, 0.2);
  opacity: 0;
  transform: translateY(10px) scale(0.975);
  transition:
    opacity 260ms cubic-bezier(0.22, 1, 0.36, 1),
    transform 260ms cubic-bezier(0.22, 1, 0.36, 1);
}

.manfred-gallery-lightbox.is-open .manfred-gallery-backdrop,
.manfred-gallery-lightbox.is-open .manfred-gallery-dialog {
  opacity: 1;
}

.manfred-gallery-lightbox.is-open .manfred-gallery-dialog {
  transform: translateY(0) scale(1);
}

.manfred-gallery-close,
.manfred-gallery-control {
  display: inline-grid;
  place-items: center;
  padding: 0;
  border: 1px solid rgba(105, 68, 37, 0.24);
  border-radius: 999px;
  background: rgba(250, 248, 245, 0.92);
  color: var(--black);
  cursor: pointer;
  appearance: none;
  transition:
    background-color 180ms ease,
    border-color 180ms ease,
    color 180ms ease,
    transform 180ms ease;
}

.manfred-gallery-close:hover,
.manfred-gallery-control:hover {
  border-color: var(--brown);
  background: var(--brown);
  color: var(--white);
}

.manfred-gallery-close:focus-visible,
.manfred-gallery-control:focus-visible {
  outline: 2px solid var(--brown);
  outline-offset: 3px;
}

.manfred-gallery-close {
  position: absolute;
  z-index: 2;
  top: 14px;
  right: 14px;
  width: 42px;
  height: 42px;
}

.manfred-gallery-close svg,
.manfred-gallery-control svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.manfred-gallery-stage {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr) 52px;
  gap: clamp(12px, 2vw, 28px);
  align-items: center;
}

.manfred-gallery-control {
  width: 52px;
  height: 52px;
}

.manfred-gallery-figure {
  display: grid;
  min-width: 0;
  max-height: calc(100vh - clamp(112px, 12vw, 180px));
  margin: 0;
  justify-items: center;
}

.manfred-gallery-figure img {
  display: block;
  width: auto;
  max-width: 100%;
  height: auto;
  max-height: calc(100vh - clamp(172px, 17vw, 240px));
  border-radius: var(--_spacing---very-small);
  object-fit: contain;
  box-shadow: 0 18px 46px rgba(18, 22, 27, 0.24);
}

.manfred-gallery-figure figcaption {
  display: flex;
  width: 100%;
  padding-top: 14px;
  justify-content: space-between;
  align-items: baseline;
  gap: 18px;
}

.manfred-gallery-figure figcaption span:first-child {
  font-family: var(--_typography---font-family--heading);
  color: var(--black);
  font-size: 21px;
  line-height: 1.15;
}

.manfred-gallery-figure figcaption span:last-child {
  font-family: var(--_typography---font-family--body);
  color: var(--grey);
  font-size: 12px;
  line-height: 1.35;
  letter-spacing: 0.05em;
  text-align: right;
  text-transform: uppercase;
}

@media screen and (max-width: 900px) {
  .manfred-gallery-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    column-gap: 18px;
    row-gap: 42px;
  }
}

@media screen and (max-width: 520px) {
  .manfred-gallery-grid {
    grid-template-columns: minmax(0, 1fr);
    row-gap: 42px;
  }

  .manfred-gallery-lightbox {
    padding: 12px;
  }

  .manfred-gallery-dialog {
    max-height: calc(100dvh - 24px);
    padding: 54px 12px 14px;
  }

  .manfred-gallery-stage {
    grid-template-columns: 1fr 1fr;
    grid-template-areas:
      "figure figure"
      "previous next";
    gap: 14px;
  }

  .manfred-gallery-figure {
    grid-area: figure;
    max-height: calc(100dvh - 146px);
  }

  .manfred-gallery-figure img {
    max-height: calc(100dvh - 222px);
  }

  .manfred-gallery-previous {
    grid-area: previous;
    justify-self: end;
  }

  .manfred-gallery-next {
    grid-area: next;
    justify-self: start;
  }

  .manfred-gallery-figure figcaption {
    align-items: flex-start;
    flex-direction: column;
    gap: 5px;
  }

  .manfred-gallery-figure figcaption span:last-child {
    text-align: left;
  }
}

@media (prefers-reduced-motion: reduce) {
  .manfred-gallery-image-button img,
  .manfred-gallery-backdrop,
  .manfred-gallery-dialog,
  .manfred-gallery-close,
  .manfred-gallery-control {
    transition: none;
  }
}
