.gallery-page {
  background: var(--paper);
}

.gallery-hero {
  padding: 92px max(24px, calc((100vw - var(--max)) / 2)) 64px;
  color: #fff;
  background: var(--ink);
}

.gallery-hero > div {
  max-width: 820px;
}

.gallery-hero h1 {
  margin: 0;
  font-size: clamp(3rem, 6vw, 6.4rem);
  line-height: .96;
  letter-spacing: -.05em;
}

.gallery-hero > div > p:last-child {
  max-width: 680px;
  margin: 26px 0 0;
  color: #d1dbe1;
  font-size: 1.08rem;
}

.gallery-categories {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 42px;
}

.gallery-categories a {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-height: 46px;
  padding: 10px 14px;
  border: 1px solid rgba(255, 255, 255, .28);
  border-radius: 999px;
  color: #fff;
  font-size: .9rem;
  font-weight: 700;
  transition: background .2s, border-color .2s;
}

.gallery-categories a:hover,
.gallery-categories a:focus {
  border-color: var(--orange);
  background: rgba(239, 91, 35, .16);
}

.gallery-categories span {
  display: inline-grid;
  min-width: 26px;
  height: 26px;
  place-items: center;
  border-radius: 50%;
  color: var(--ink);
  background: #fff;
  font-size: .78rem;
}

.gallery-group {
  scroll-margin-top: 82px;
  background: #fff;
}

.gallery-group:nth-of-type(even) {
  background: var(--paper);
}

.gallery-group-head {
  display: grid;
  grid-template-columns: 1fr minmax(260px, .55fr);
  gap: 64px;
  align-items: end;
  margin-bottom: 38px;
}

.gallery-group-head h2 {
  margin: 0;
  font-size: clamp(2.15rem, 4vw, 4rem);
  line-height: 1;
  letter-spacing: -.04em;
}

.gallery-group-head > p {
  margin: 0;
  color: var(--muted);
}

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

.gallery-card {
  position: relative;
  aspect-ratio: 4 / 3;
  margin: 0;
  overflow: hidden;
  background: var(--ink);
}

.gallery-card a {
  display: block;
  width: 100%;
  height: 100%;
}

.gallery-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform .25s ease, opacity .25s ease;
}

.gallery-card figcaption {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  padding: 42px 17px 14px;
  color: #fff;
  background: linear-gradient(transparent, rgba(7, 18, 29, .84));
  font-size: .9rem;
  font-weight: 700;
}

.gallery-card a:hover img,
.gallery-card a:focus img {
  transform: scale(1.025);
  opacity: .94;
}

.gallery-card a:focus-visible {
  outline: 4px solid var(--orange);
  outline-offset: -4px;
}

.gallery-cta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 72px;
  padding: 82px max(24px, calc((100vw - var(--max)) / 2));
  color: #fff;
  background: var(--teal);
}

.gallery-cta h2 {
  margin: 0;
  font-size: clamp(2.15rem, 4vw, 4rem);
  line-height: 1;
  letter-spacing: -.04em;
}

.gallery-cta p {
  margin: 0 0 24px;
  color: #d0e6e6;
}

.gallery-lightbox {
  width: min(1180px, calc(100vw - 40px));
  max-width: none;
  padding: 0;
  border: 0;
  color: #fff;
  background: #07121d;
  box-shadow: 0 28px 90px rgba(0, 0, 0, .45);
}

.gallery-lightbox::backdrop {
  background: rgba(7, 18, 29, .86);
  backdrop-filter: blur(5px);
}

.gallery-lightbox img {
  width: 100%;
  max-height: calc(100vh - 130px);
  object-fit: contain;
  background: #07121d;
  touch-action: pan-y;
  user-select: none;
}

.gallery-lightbox > div {
  display: flex;
  justify-content: space-between;
  gap: 22px;
  padding: 16px 20px 18px;
}

.gallery-lightbox span {
  color: #aebcc5;
}

.gallery-lightbox-close {
  position: absolute;
  z-index: 2;
  top: 12px;
  right: 12px;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  color: var(--ink);
  background: rgba(255, 255, 255, .94);
  font-size: 1.7rem;
  line-height: 1;
  display: grid;
  place-items: center;
  padding: 0 0 3px;
  font-family: Arial, sans-serif;
  text-align: center;
  cursor: pointer;
}

.gallery-lightbox-prev,
.gallery-lightbox-next {
  position: absolute;
  z-index: 2;
  top: 50%;
  width: 52px;
  height: 52px;
  border: 0;
  border-radius: 50%;
  color: #fff;
  background: rgba(2, 69, 74, .88);
  box-shadow: 0 8px 30px rgba(0, 0, 0, .28);
  font-size: 2rem;
  line-height: 1;
  display: grid;
  place-items: center;
  padding: 0 0 4px;
  font-family: Arial, sans-serif;
  text-align: center;
  cursor: pointer;
  transform: translateY(-50%);
}

.gallery-lightbox-prev { left: 14px; }
.gallery-lightbox-next { right: 14px; }

.gallery-lightbox-prev:hover,
.gallery-lightbox-next:hover,
.gallery-lightbox-prev:focus-visible,
.gallery-lightbox-next:focus-visible {
  background: var(--orange);
}

.gallery-lightbox-counter {
  white-space: nowrap;
  color: #aebcc5;
}

.work-gallery-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin-top: 52px;
}

.work-gallery-link span {
  color: #bac6ce;
  font-size: .92rem;
}

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

  .gallery-group-head,
  .gallery-cta {
    grid-template-columns: 1fr;
    gap: 24px;
  }
}

@media (max-width: 680px) {
  .gallery-hero {
    padding: 64px 20px 48px;
  }

  .gallery-hero h1 {
    font-size: 3.2rem;
  }

  .gallery-categories {
    display: grid;
  }

  .gallery-categories a {
    justify-content: space-between;
    border-radius: 10px;
  }

  .gallery-group {
    padding: 70px 20px;
  }

  .gallery-group-head {
    margin-bottom: 28px;
  }

  .gallery-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .gallery-cta {
    padding: 68px 20px;
  }

  .gallery-lightbox {
    width: calc(100vw - 20px);
  }

  .gallery-lightbox-prev,
  .gallery-lightbox-next {
    top: auto;
    bottom: 76px;
    width: 46px;
    height: 46px;
  }

  .gallery-lightbox > div,
  .work-gallery-link {
    align-items: flex-start;
    flex-direction: column;
  }

  .work-gallery-link {
    margin-top: 0;
  }
}

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