.portfolio-gallery {
  padding: clamp(72px, 9vw, 144px) var(--gutter) clamp(100px, 12vw, 180px);
  background: var(--paper);
}

.portfolio-gallery__intro {
  margin-bottom: clamp(42px, 7vw, 96px);
}

.portfolio-gallery__intro .eyebrow {
  margin-bottom: 20px;
  color: var(--muted);
}

.portfolio-gallery__intro h2 {
  max-width: 12ch;
  margin: 0;
  font-size: clamp(56px, 8vw, 124px);
  font-weight: 570;
  line-height: .94;
  letter-spacing: -.065em;
}

.portfolio-gallery__stack {
  width: min(100%, 1012px);
  margin-inline: auto;
}

.portfolio-gallery__item {
  position: sticky;
  top: clamp(28px, 8vh, 88px);
  margin-bottom: clamp(28px, 4vw, 60px);
  transform-origin: center top;
  will-change: transform;
}

.portfolio-gallery__item:last-child {
  margin-bottom: 0;
}

.portfolio-gallery__item:nth-child(1) { z-index: 1; }
.portfolio-gallery__item:nth-child(2) { z-index: 2; }
.portfolio-gallery__item:nth-child(3) { z-index: 3; }
.portfolio-gallery__item:nth-child(4) { z-index: 4; }

.portfolio-gallery__card {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 1012 / 600;
  overflow: hidden;
  border-radius: 16px;
  background: #101916;
  color: #fff;
  text-decoration: none;
  box-shadow: 0 26px 65px rgb(16 15 13 / 13%);
}

.portfolio-gallery__card:focus-visible {
  outline: 3px solid #276cff;
  outline-offset: 5px;
}

.portfolio-gallery__preview {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.portfolio-gallery__preview video,
.portfolio-gallery__preview img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
}

.portfolio-gallery__preview iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 1440px;
  height: 900px;
  max-width: none;
  border: 0;
  background: transparent;
  transform-origin: top left;
  pointer-events: none;
}

.portfolio-gallery__preview--image img {
  object-fit: cover;
  object-position: center;
}

.portfolio-gallery__caption {
  position: absolute;
  z-index: 2;
  right: 24px;
  bottom: 20px;
  left: 24px;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 18px;
  font-size: clamp(14px, 1.5vw, 18px);
  line-height: 1.25;
  text-shadow: 0 2px 12px #000, 0 1px 24px #000;
}

.portfolio-gallery__caption strong {
  font-weight: 600;
}

.portfolio-gallery__caption span {
  white-space: nowrap;
}

@media (max-width: 767px) {
  .portfolio-gallery {
    padding-block: 70px 88px;
  }

  .portfolio-gallery__intro h2 {
    font-size: clamp(48px, 11vw, 76px);
  }

  .portfolio-gallery__item {
    position: relative;
    top: auto;
    margin-bottom: 16px;
    transform: none !important;
    will-change: auto;
  }

  .portfolio-gallery__card {
    aspect-ratio: 4 / 3;
    border-radius: 12px;
  }

  .portfolio-gallery__caption {
    right: 13px;
    bottom: 14px;
    left: 13px;
    font-size: 13px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .portfolio-gallery__item {
    transform: none !important;
    will-change: auto;
  }
}

.service-design-web .related::after {
  content: none;
}

.service-design-web .about-hero .float-preview__frame {
  position: absolute;
  z-index: 3;
  top: 0;
  left: 0;
  width: 1440px;
  height: 900px;
  max-width: none;
  border: 0;
  background: transparent;
  transform-origin: top left;
  pointer-events: none;
}

@media (min-width: 1400px) {
  .service-design-web .about-hero .float-top {
    left: calc(50% - 175px);
    width: 350px;
  }
  .service-design-web .about-hero .float-left { width: clamp(320px, 15vw, 440px); }
  .service-design-web .about-hero .float-right { width: clamp(320px, 15vw, 440px); }
  .service-design-web .about-hero .float-small { width: clamp(350px, 16vw, 460px); }
  .service-design-web .about-hero .float-bottom { width: clamp(350px, 16vw, 460px); }
}

/* Keep the gallery usable if the scrolling script has not loaded yet. */
@media (prefers-reduced-motion: no-preference) {
  .service-design-web .direction:not([style*="height"]) { height: auto; }
  .service-design-web .direction:not([style*="height"]) .direction-pin {
    position: relative;
    height: 100svh;
  }
  .service-design-web .direction:not([style*="height"]) .direction-gallery-viewport {
    overflow-x: auto;
  }
}
