.gallery-home[hidden],
.gallery-collection[hidden],
.gallery-controls[hidden],
.gallery-caption[hidden],
.gallery-lightbox [hidden] {
  display: none !important;
}

.gallery-home {
  padding: 72px 0;
  background: var(--paper);
}

.gallery-container {
  margin-inline: calc(34 * var(--u));
}

.gallery-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  margin-bottom: 28px;
}

.gallery-title {
  font-family: "Times New Roman", Times, serif;
  font-size: 44px;
  font-weight: 400;
  line-height: 1.1;
  letter-spacing: -.5px;
}

.gallery-link {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  flex-shrink: 0;
  border-bottom: 1px solid #9ca393;
  font-size: 16px;
}

.gallery-icon {
  display: block;
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}

.gallery-link .gallery-icon {
  transition: transform 180ms;
}

.gallery-link:hover .gallery-icon {
  transform: translateX(3px);
}

.gallery-track,
.gallery-grid {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 24px;
  align-items: start;
}

.gallery-track {
  grid-auto-flow: column;
  grid-auto-columns: calc((100% - 48px) / 3);
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
}

.gallery-track::-webkit-scrollbar {
  display: none;
}

.gallery-track:focus-visible {
  outline: 3px solid #a98b42;
  outline-offset: 5px;
}

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

.gallery-item {
  min-width: 0;
  scroll-snap-align: start;
}

.gallery-card {
  display: block;
  width: 100%;
  min-width: 0;
  border: 0;
  padding: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: zoom-in;
}

.gallery-card:focus-visible {
  outline-offset: -3px;
}

.gallery-frame {
  display: block;
  position: relative;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border-radius: 12px 12px 32px 0;
  background: #e5e8dd;
}

.gallery-photo {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.gallery-zoom {
  position: absolute;
  right: 12px;
  bottom: 12px;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  color: #f7f7f2;
  background: #263f2fe6;
  opacity: 0;
  transition: opacity 180ms;
}

.gallery-card:hover .gallery-zoom,
.gallery-card:focus-visible .gallery-zoom {
  opacity: 1;
}

.gallery-caption {
  display: block;
  padding-top: 12px;
  font-size: 16px;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.gallery-controls {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 24px;
}

.gallery-control {
  display: inline-grid;
  place-items: center;
  width: 48px;
  height: 48px;
  padding: 0;
  border: 1px solid #84937d;
  border-radius: 50%;
  background: transparent;
  color: var(--forest);
  cursor: pointer;
  transition: background-color 180ms, color 180ms;
}

.gallery-control:hover:not(:disabled) {
  background: var(--forest);
  color: var(--paper);
}

.gallery-control:disabled {
  opacity: .35;
  cursor: default;
}

.gallery-control--previous .gallery-icon {
  transform: rotate(180deg);
}

.gallery-page {
  display: flex;
  flex-direction: column;
  min-height: 100svh;
}

.gallery-page > .site-header,
.gallery-page > .site-footer {
  flex-shrink: 0;
}

.gallery-main {
  flex: 1;
  padding: 32px 0 72px;
}

.gallery-intro {
  margin-bottom: 40px;
}

.gallery-description {
  margin-top: 16px;
  font-size: 19px;
  line-height: 1.5;
  color: var(--muted);
}

.gallery-contact {
  margin-top: 40px;
}

.gallery-contact-link {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 12px 24px;
  border: 1px solid #54674e;
  border-radius: 999px;
  background: var(--forest);
  color: var(--paper);
  font-size: 16px;
  transition: background-color 180ms;
}

.gallery-contact-link:hover {
  background: #36533c;
}

.gallery-lightbox {
  position: fixed;
  inset: 0;
  margin: 0;
  width: 100%;
  max-width: none;
  height: 100dvh;
  max-height: none;
  border: 0;
  padding: 24px;
  background: transparent;
  color: #f7f7f2;
  overflow: hidden;
}

.gallery-lightbox::backdrop {
  background: rgb(16 29 21 / 95%);
}

.gallery-lightbox__panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: 100%;
  max-width: 1200px;
  height: 100%;
  margin-inline: auto;
}

.gallery-lightbox__toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-shrink: 0;
}

.gallery-lightbox__counter {
  font: 16px/1.5 Arial, sans-serif;
}

.gallery-lightbox .gallery-control {
  color: #f7f7f2;
  border-color: #a8b39b;
}

.gallery-lightbox .gallery-control:hover:not(:disabled) {
  background: #f7f7f21a;
}

.gallery-lightbox__stage {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1;
  min-height: 0;
  touch-action: pan-y pinch-zoom;
}

.gallery-lightbox__image {
  max-width: 100%;
  max-height: 100%;
  width: 100%;
  height: 100%;
  object-fit: contain;
  user-select: none;
  -webkit-user-drag: none;
}

.gallery-lightbox__bottom {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.gallery-lightbox__caption {
  max-width: 70ch;
  max-height: 20vh;
  overflow: auto;
  overflow-wrap: anywhere;
  text-align: center;
  font-size: 17px;
  line-height: 1.4;
}

.gallery-lightbox .gallery-controls {
  margin: 0;
}

@media (min-width: 768px) and (max-width: 1023px) {
  .gallery-home {
    padding-block: 48px;
  }
  .gallery-title {
    font-size: 36px;
  }
  .gallery-track, .gallery-grid {
    gap: 20px;
  }
  .gallery-track {
    grid-auto-columns: calc((100% - 20px) / 2);
  }
  .gallery-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .gallery-main {
    padding-bottom: 48px;
  }
}

@media (max-width: 767px) {
  .gallery-home {
    padding-block: 36px;
  }
  .gallery-container {
    margin-inline: 24px;
  }
  .gallery-heading {
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 24px;
  }
  .gallery-title {
    font-size: 32px;
  }
  .gallery-link {
    font-size: 15px;
  }
  .gallery-track, .gallery-grid {
    gap: 16px;
  }
  .gallery-track {
    grid-auto-columns: 86%;
  }
  .gallery-grid {
    grid-template-columns: minmax(0, 1fr);
  }
  .gallery-main {
    padding-block: 24px 48px;
  }
  .gallery-intro {
    margin-bottom: 28px;
  }
  .gallery-description {
    font-size: 17px;
  }
  .gallery-lightbox {
    padding: 12px;
  }
  .gallery-lightbox__caption {
    font-size: 15px;
  }
}

@media (hover: none) {
  .gallery-zoom {
    opacity: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  .gallery-home *, .gallery-main *, .gallery-lightbox * {
    transition: none !important;
    scroll-behavior: auto !important;
  }
}
