/* The frame and its caption stay still while the photograph moves behind them. */
@media screen and (min-width: 801px) and (prefers-reduced-motion: no-preference) {
  @supports (animation-timeline: view()) and (animation-range: entry 0% exit 100%) {
    :is(
      .image-frame:not(.person-portrait),
      .project-card .project-img,
      .area-consulting:not(.consulting-contact) .consulting-hero-photo
    ) {
      view-timeline-name: --nrg-photo-frame;
    }

    /* The consulting template normally rounds the image itself. Clip its motion
       to the same radius so it never crosses the frame's edge. */
    .area-consulting:not(.consulting-contact) .consulting-hero-photo {
      overflow: clip;
      border-radius: 24px;
    }

    :is(
      .image-frame:not(.person-portrait),
      .project-card .project-img,
      .area-consulting:not(.consulting-contact) .consulting-hero-photo
    ) img {
      scale: 1.075;
      animation: nrg-photo-depth auto linear both;
      animation-timeline: --nrg-photo-frame;
      animation-range: entry 0% exit 100%;
    }
  }
}

@keyframes nrg-photo-depth {
  from { translate: 0 -3%; }
  to   { translate: 0 3%; }
}

/* Perspective is applied to the glass and image frames. Existing independent
   reveal and hover transforms on the parent links are free to run. */
@media screen and (min-width: 801px) and (hover: hover) and (pointer: fine) and (prefers-reduced-motion: no-preference) {
  .group-portals,
  .project-card {
    perspective: 1200px;
  }

  .group-portals > .group-portal {
    transition-property: transform, background, box-shadow, rotate;
  }

  .group-portals > .group-portal:is(:hover, :focus-visible) {
    rotate: 1 -.45 0 2.6deg;
  }

  .group-portals > .portal-consult:is(:hover, :focus-visible) {
    rotate: 1 .45 0 2.6deg;
  }

  .project-card .project-img {
    transition: rotate .36s var(--ease), box-shadow .36s var(--ease);
  }

  .project-card:is(:hover, :focus-visible) .project-img {
    rotate: x 2.6deg;
    box-shadow: 0 11px 24px -13px #18392f75;
  }
}
