/* Pointer-led motion: the screen responds like a softly lit physical print.
   The original composition and layout stay intact when motion is unavailable. */
@media (hover: hover) and (pointer: fine) and (prefers-reduced-motion: no-preference) {
  .motion-enabled .hero h1 > span {
    translate: var(--headline-x, 0px) var(--headline-y, 0px);
    rotate: var(--headline-roll, 0deg);
    transform-origin: left center;
    transition: translate .65s cubic-bezier(.18,.86,.25,1), rotate .65s cubic-bezier(.18,.86,.25,1);
  }
  .motion-enabled .hero.motion-following h1 > span {
    transition-duration: .24s;
  }
  .motion-enabled .hero.motion-following .headline-ink {
    --ink-base: var(--cream);
    --ink-glint: #dbff69;
    color: transparent;
    background: radial-gradient(ellipse 190px 128px at var(--light-x, -500px) var(--light-y, -500px),
      #fffef3 0%, var(--ink-glint) 30%, var(--ink-base) 92%);
    background-clip: text;
    -webkit-background-clip: text;
    box-decoration-break: clone;
  }
  .motion-enabled .hero.motion-following em.headline-ink {
    --ink-base: var(--lime);
    --ink-glint: #fff6b2;
  }

  .motion-enabled .motion-card {
    position: relative;
    isolation: isolate;
    transform: perspective(1000px) translateY(var(--card-lift, 0px))
      rotateX(var(--card-rx, 0deg)) rotateY(var(--card-ry, 0deg));
    transform-origin: center center;
    transition: transform .64s cubic-bezier(.16,.83,.25,1), box-shadow .5s ease;
  }
  .motion-enabled .motion-card::after {
    content: "";
    position: absolute;
    z-index: 3;
    inset: 0;
    pointer-events: none;
    opacity: 0;
    background: radial-gradient(ellipse at var(--card-x, 50%) var(--card-y, 50%),
      rgba(255,250,222,.25) 0%, rgba(255,255,246,.055) 35%, transparent 67%);
    box-shadow: inset 0 0 0 1px rgba(255,255,241,.25);
    transition: opacity .5s ease;
  }
  .motion-enabled .motion-card:hover,
  .motion-enabled .motion-card.motion-following {
    --card-lift: -4px;
    z-index: 1;
    box-shadow: 0 16px 34px -17px rgba(17,24,19,.48);
    transition-duration: .18s, .4s;
  }
  .motion-enabled .motion-card:hover::after,
  .motion-enabled .motion-card.motion-following::after { opacity: 1; }
  /* Gallery focus. The selected print comes forward; its neighbours recede.
     Transform rather than resizing the grid so it never reflows under the pointer. */
  .motion-enabled .poster-rail { isolation: isolate; overflow: visible; }
  .motion-enabled .poster-rail > figure { position: relative; min-width: 0; }
  .motion-enabled .poster-rail .motion-card {
    transform: perspective(1000px) translateY(0) scale(1);
    transition: transform .55s cubic-bezier(.2,.85,.25,1), filter .45s, box-shadow .5s;
  }
  .motion-enabled .poster-rail:has(.motion-card:is(:hover,:focus-visible)) > figure:not(:has(.motion-card:is(:hover,:focus-visible))) .motion-card {
    transform: perspective(1000px) scale(.93) translateY(8px);
    filter: saturate(.55) brightness(.72);
  }
  .motion-enabled .poster-rail > figure:has(.motion-card:is(:hover,:focus-visible)) {
    z-index: 5;
  }
  .motion-enabled .poster-rail .motion-card:is(:hover,:focus-visible) {
    transform: perspective(1000px) translateY(-18px) scale(1.13)
      rotateX(var(--card-rx, 0deg)) rotateY(var(--card-ry, 0deg));
    filter: none;
    box-shadow: 0 28px 54px -14px #11181373, 0 5px 12px #11181338;
    transition: transform .38s cubic-bezier(.18,.8,.28,1), filter .4s, box-shadow .4s;
  }
  /* The light travels diagonally once as the print moves into focus. */
  .motion-enabled .poster-rail .motion-card::before {
    content: "";
    position: absolute;
    z-index: 2;
    pointer-events: none;
    inset: -25% -70%;
    background: linear-gradient(115deg, transparent 35%, #fffbe809 43%, #fff8df55 49%, transparent 58%);
    transform: translateX(-72%);
    opacity: 0;
  }
  .motion-enabled .poster-rail .motion-card:hover::before {
    animation: print-glint .85s cubic-bezier(.2,.65,.3,1) both;
  }
  @keyframes print-glint {
    0% { transform: translateX(-72%); opacity: 0; }
    18% { opacity: .9; }
    72% { opacity: .75; }
    100% { transform: translateX(72%); opacity: 0; }
  }
  .motion-enabled .poster-rail .motion-card:is(:hover,:focus-visible) img { transform: none; }
  .motion-enabled .poster-rail figure figcaption {
    transition: color .3s, translate .4s cubic-bezier(.2,.8,.2,1), opacity .3s;
  }
  .motion-enabled .poster-rail > figure:has(.motion-card:is(:hover,:focus-visible)) figcaption {
    color: var(--ink);
    translate: 0 17px;
  }
  .motion-enabled .poster-rail:has(.motion-card:is(:hover,:focus-visible)) > figure:not(:has(.motion-card:is(:hover,:focus-visible))) figcaption {
    opacity: .5;
  }
  /* Keep the selected video rectangular and show a distinct editorial wipe. */
  .motion-enabled .work-grid .motion-card:hover {
    transform: perspective(1100px) translateY(-10px) scale(1.035) rotateX(var(--card-rx,0deg)) rotateY(var(--card-ry,0deg));
  }
  .motion-enabled .work-grid .motion-card:has(video.active) {
    transform: translateY(-8px) scale(1.025);
  }
  .motion-enabled .work-grid .motion-card video {
    clip-path: inset(0 100% 0 0);
    transition: clip-path .48s cubic-bezier(.2,.75,.2,1), opacity .28s;
  }
  .motion-enabled .work-grid .motion-card video.active { clip-path: inset(0); }
  .motion-enabled .work-grid .motion-card:has(video.active)::after {
    opacity: 0;
  }
  .motion-enabled .work-grid .motion-card.motion-following:not(:has(video.active)) img {
    transform: translate(var(--image-x, 0px),var(--image-y, 0px)) scale(1.045);
  }
  .motion-enabled .poster-rail.visible > figure {
    animation: print-arrive .78s cubic-bezier(.2,.78,.25,1) backwards;
  }
  .motion-enabled .poster-rail.visible > figure:nth-child(2) { animation-delay: .075s; }
  .motion-enabled .poster-rail.visible > figure:nth-child(3) { animation-delay: .15s; }
  .motion-enabled .poster-rail.visible > figure:nth-child(4) { animation-delay: .225s; }
  @keyframes print-arrive {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: none; }
  }
  @media (max-width: 680px) {
    .motion-enabled .poster-rail .motion-card:is(:hover,:focus-visible) {
      transform: perspective(1000px) translateY(-8px) scale(1.065) rotateX(var(--card-rx,0deg)) rotateY(var(--card-ry,0deg));
    }
    .motion-enabled .poster-rail > figure:has(.motion-card:is(:hover,:focus-visible)) figcaption { translate: 0 8px; }
  }
}
