.fh-gallery-feature,
.fh-gallery-page {
  --gallery-ink: #241e1a;
  --gallery-accent: #aa390d;
  --gallery-line: #d9cec5;
  background: #faf8f5;
  color: var(--gallery-ink);
}

.fh-gallery-feature {
  position: relative;
  display: grid;
  justify-items: center;
  align-content: center;
  min-height: 100svh;
  padding: clamp(44px, 6svh, 80px) 0 clamp(35px, 5svh, 64px);
  scroll-margin-top: 70px;
  overflow: clip;
}

.fh-gallery-page {
  min-height: 76svh;
  padding: clamp(50px, 8vw, 110px) 0;
}

.fh-gallery-heading {
  width: min(760px, calc(100% - 36px));
  margin: 0 auto clamp(16px, 2.3vh, 26px);
  text-align: center;
}

.fh-gallery-heading :is(h1, h2) {
  font-size: clamp(3rem, 6vw, 6.7rem);
  margin: 0 0 .12em;
  letter-spacing: -.055em;
}

.fh-gallery-heading p {
  color: #514642;
  line-height: 1.5;
  margin: 0;
}

.fh-gallery {
  width: 100%;
  min-width: 0;
}

.fh-gallery [hidden] {
  display: none !important;
}

.fh-gallery-filters {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 16px;
  margin: 0 auto 14px;
}

.fh-gallery-filters button,
.fh-gallery-arrow,
.fh-gallery-cycle {
  min-height: 44px;
  border: 1px solid var(--gallery-line);
  border-radius: 100px;
  background: transparent;
  color: var(--gallery-ink);
  font-weight: 650;
  transition: color .2s ease, background-color .2s ease, border-color .2s ease;
}

.fh-gallery-filters button {
  padding: 0 17px;
  font-size: .9rem;
}

.fh-gallery-filters button[aria-pressed="true"] {
  background: var(--gallery-ink);
  border-color: var(--gallery-ink);
  color: #fff;
}

.fh-gallery :is(button, a):focus-visible,
.fh-gallery-page-link:focus-visible {
  outline: 2px solid #b64315;
  outline-offset: 4px;
}

.fh-gallery-stage {
  --gallery-card-width: clamp(330px, 40vw, 660px);
  --gallery-card-height: clamp(390px, 60svh, 705px);
  --gallery-step: clamp(161px, 18vw, 335px);
  height: calc(var(--gallery-card-height) + 44px);
  position: relative;
  isolation: isolate;
  perspective: 1450px;
  overflow: clip;
  touch-action: pan-y;
}

.fh-gallery-card {
  --position: 0;
  --card-scale: 1;
  --card-angle: 0deg;
  --card-roll: 0deg;
  --card-drop: 0px;
  --card-opacity: 1;
  --card-saturation: 1;
  position: absolute;
  inset: 50% auto auto 50%;
  width: var(--gallery-card-width);
  height: var(--gallery-card-height);
  overflow: hidden;
  border-radius: clamp(18px, 2vw, 31px);
  background: #e8e0d8;
  box-shadow: 0 18px 34px #24161029;
  z-index: 3;
  opacity: var(--card-opacity);
  filter: saturate(var(--card-saturation));
  transform: translate(-50%, -50%) translateX(calc(var(--gallery-step) * var(--position)))
    translateY(var(--card-drop)) scale(var(--card-scale)) rotateY(var(--card-angle)) rotate(var(--card-roll));
  transition: transform .65s cubic-bezier(.22, .68, .24, 1), opacity .46s ease, filter .55s ease, box-shadow .3s ease;
}

.fh-gallery-card[data-position="0"] {
  z-index: 6;
  box-shadow: 0 25px 46px #24161036;
}

.fh-gallery-card[data-position="-1"],
.fh-gallery-card[data-position="1"] {
  --card-scale: .83;
  --card-drop: 14px;
  --card-opacity: .94;
  --card-saturation: .91;
  z-index: 5;
}

.fh-gallery-card[data-position="-2"],
.fh-gallery-card[data-position="2"] {
  --card-scale: .67;
  --card-drop: 28px;
  --card-opacity: .64;
  --card-saturation: .79;
  z-index: 4;
}

.fh-gallery-card[data-position="-3"],
.fh-gallery-card[data-position="3"] {
  --card-scale: .56;
  --card-drop: 38px;
  --card-opacity: 0;
  pointer-events: none;
}

.fh-gallery-card[data-position="-1"] { --position: -1; --card-angle: 16deg; --card-roll: -2deg; }
.fh-gallery-card[data-position="1"] { --position: 1; --card-angle: -16deg; --card-roll: 2deg; }
.fh-gallery-card[data-position="-2"] { --position: -2; --card-angle: 24deg; --card-roll: -3deg; }
.fh-gallery-card[data-position="2"] { --position: 2; --card-angle: -24deg; --card-roll: 3deg; }
.fh-gallery-card[data-position="-3"] { --position: -3; --card-angle: 28deg; }
.fh-gallery-card[data-position="3"] { --position: 3; --card-angle: -28deg; }

.fh-gallery-card[data-fh-wrap] {
  transition: none;
  animation: fh-gallery-card-return .46s ease both;
}

@keyframes fh-gallery-card-return {
  from { opacity: 0; }
  to { opacity: var(--card-opacity); }
}

.fh-gallery-card img,
.fh-gallery-tile img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.fh-gallery-image-crop img {
  scale: 1.25;
  transform-origin: 54% 54%;
}

.fh-gallery-card[data-position="0"]:focus-visible,
.fh-gallery-tile:focus-visible {
  outline-offset: -6px;
}

.fh-gallery-control {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 13px;
  margin: 0 auto;
}

.fh-gallery-arrow {
  width: 46px;
  padding: 0;
  font-size: 1.34rem;
  font-weight: 450;
  line-height: 1;
}

.fh-gallery-arrow:hover,
.fh-gallery-cycle:hover,
.fh-gallery-filters button:not([aria-pressed="true"]):hover {
  border-color: var(--gallery-ink);
  background: #efe7de;
}

.fh-gallery-cycle {
  display: none;
  padding: 0 12px;
  font-size: .78rem;
}

.fh-gallery-meter {
  display: grid;
  justify-items: center;
  gap: 3px;
  min-width: 84px;
  color: #625651;
}

.fh-gallery-meter output {
  font-size: .8rem;
  font-variant-numeric: tabular-nums;
}

.fh-gallery-progress {
  overflow: hidden;
  width: 70px;
  height: 2px;
  border-radius: 9px;
  background: #ddcec4;
}

.fh-gallery-progress::before {
  content: '';
  display: block;
  width: 100%;
  height: 100%;
  background: var(--gallery-accent);
  transform: scaleX(var(--gallery-progress, 0));
  transform-origin: left;
  transition: transform .45s ease;
}

.fh-gallery-caption {
  min-height: 1.5em;
  margin: 9px auto 0;
  padding: 0 20px;
  font-size: .87rem;
  color: #625651;
  text-align: center;
}

.fh-gallery-page-link {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-height: 44px;
  margin: 9px auto 0;
  color: var(--gallery-accent);
  font-weight: 720;
}

.fh-gallery-page-link:hover {
  text-decoration: underline;
  text-underline-offset: 4px;
}

.fh-gallery-page .fh-gallery-filters {
  margin-bottom: 27px;
}

.fh-gallery-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  width: min(1440px, calc(100% - 64px));
  gap: clamp(11px, 2vw, 27px);
  margin-inline: auto;
}

.fh-gallery-tile {
  position: relative;
  display: block;
  overflow: hidden;
  aspect-ratio: 4 / 4.5;
  border-radius: clamp(12px, 1.55vw, 23px);
  background: #e8e0d8;
}

.fh-gallery-tile img {
  transition: transform .55s cubic-bezier(.22, .68, .24, 1);
}

.fh-gallery-tile:hover img {
  transform: scale(1.035);
}

.fh-gallery-tile-label {
  position: absolute;
  inset: auto 0 0;
  padding: clamp(15px, 3vw, 31px) 12px 9px;
  color: #fff;
  background: linear-gradient(transparent, #140f0ce6);
  font-size: .8rem;
}

.fh-gallery-empty {
  margin: 30px auto 0;
  text-align: center;
  padding-inline: 18px;
}

.fh-gallery-viewer {
  --gallery-ink: #fff;
  --gallery-line: #ffffff54;
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  padding: 16px;
  margin: 0;
  border: 0;
  background: #14100ef5;
  color: #fff;
}

.fh-gallery-viewer[open] {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: clamp(4px, 2vw, 24px);
}

.fh-gallery-viewer::backdrop {
  background: #14100e;
}

.fh-gallery-viewer figure {
  display: grid;
  justify-items: center;
  gap: 8px;
  min-width: 0;
  margin: 0;
}

.fh-gallery-viewer img {
  display: block;
  width: 100%;
  height: min(80svh, 900px);
  object-fit: contain;
}

.fh-gallery-viewer figcaption {
  text-align: center;
  font-size: .88rem;
}

.fh-gallery-viewer-close {
  position: absolute;
  top: max(12px, env(safe-area-inset-top));
  right: max(12px, env(safe-area-inset-right));
  z-index: 1;
  width: 44px;
  height: 44px;
  border: 1px solid var(--gallery-line);
  border-radius: 100px;
  color: #fff;
  background: #14100e;
  font-size: 1.6rem;
  line-height: 1;
}

.fh-gallery-viewer .fh-gallery-arrow:hover,
.fh-gallery-viewer-close:hover {
  background: #fff;
  color: #241e1a;
}

@media (max-width: 760px) {
  .fh-gallery-feature {
    min-height: 0;
    padding: 42px 0 30px;
  }

  .fh-gallery-heading :is(h1, h2) {
    font-size: clamp(2.75rem, 11vw, 5rem);
  }

  .fh-gallery-filters {
    gap: 6px;
    margin-bottom: 9px;
  }

  .fh-gallery-filters button {
    padding-inline: 12px;
    font-size: .83rem;
  }

  .fh-gallery-stage {
    --gallery-card-width: 83%;
    --gallery-card-height: clamp(320px, 101vw, 535px);
    --gallery-step: 81vw;
    height: calc(var(--gallery-card-height) + 30px);
    perspective: 1000px;
  }

  .fh-gallery-card[data-position="-2"],
  .fh-gallery-card[data-position="2"] {
    --card-opacity: 0;
    pointer-events: none;
  }

  .fh-gallery-control {
    gap: 9px;
  }

  .fh-gallery-cycle {
    display: inline-block;
  }

  .fh-gallery-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: calc(100% - 28px);
  }

  .fh-gallery-viewer {
    padding: 8px;
  }

  .fh-gallery-viewer .fh-gallery-arrow {
    width: 44px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .fh-gallery-card,
  .fh-gallery-card[data-fh-wrap],
  .fh-gallery-progress::before,
  .fh-gallery-tile img {
    animation: none;
    transition: none;
  }
}

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