/* Motion frames the photograph; the owner's image transform stays untouched. */
.residence-photos { position:relative; isolation:isolate; }
.residence-photo { grid-area:1 / 1; width:100%; }
.residence-photo__surface { display:block; width:100%; height:100%; }
.residence-photo__expand { transition:background .25s, transform .3s; }
.residence-photo__open:hover .residence-photo__expand { background:rgba(22,21,19,.85); transform:translateY(-3px); }
.gallery-play {
  display:inline-flex; align-items:center; gap:9px; min-height:44px;
  border:0; padding:0 6px; background:none; color:var(--lime-2);
  font-size:13px; cursor:pointer; white-space:nowrap;
}
.gallery-play::before { content:'▷'; font-size:17px; color:var(--accent, #c1ac83); }
.gallery-play[aria-pressed="true"]::before { content:'Ⅱ'; }
.gallery-play:hover { color:var(--lime); }
.gallery-load-status { min-height:0; margin:0; font-size:13px; color:var(--lime-2); }
.gallery-load-status:not(:empty) { margin-top:12px; }
.lightbox { background:#0d0c0b; }
.lightbox__figure { position:relative; }
.lightbox__canvas { position:relative; width:100%; flex:1; min-height:0; touch-action:pan-y; }
.lightbox__image { position:absolute; inset:0; display:flex; align-items:center; justify-content:center; }
.lightbox__figure .lightbox__image img { width:auto; height:auto; max-width:100%; max-height:100%; object-fit:contain; user-select:none; -webkit-user-drag:none; }
.lightbox__status { position:absolute; bottom:10px; left:50%; transform:translateX(-50%); margin:0; padding:5px 12px; background:rgba(22,21,19,.8); font-size:13px; text-align:center; }
.lightbox__status:empty { display:none; }
.lightbox__figure figcaption { flex-shrink:0; }
@media (max-width:900px) {
  .lightbox__figure { padding-bottom:64px; }
}
@media (max-width:520px) {
  .residence-gallery__bar { gap:12px; }
  .gallery-play { font-size:12px; gap:6px; padding:0; }
}

/* ---------- Living photographs ----------
   Everything below is an enhancement: with reduced motion the page is complete
   and still. Wrappers move; the owner's framing on each <img> is never changed
   (hover zoom uses the separate `scale` property, which composes with it). */
@media (prefers-reduced-motion:no-preference) {
  /* The photograph on stage never sits still: a slow drift in and back out. */
  .residence-photo__surface {
    will-change:transform;
    translate:var(--px, 0px) var(--py, 0px);
    transition:translate 1.1s cubic-bezier(.2,.7,.1,1);
  }
  .residence-photo:not([hidden]) .residence-photo__surface {
    animation:photo-drift 16s ease-in-out infinite alternate;
  }
  .residence-photo:nth-child(4n+2) .residence-photo__surface { --dx:-1.6%; --dy:-.8%; }
  .residence-photo:nth-child(4n+3) .residence-photo__surface { --dx:1.2%; --dy:1.2%; }
  .residence-photo:nth-child(4n+4) .residence-photo__surface { --dx:-1.2%; --dy:1%; }
  @keyframes photo-drift {
    from { transform:scale(1.12) translate(var(--dx, 1.6%), var(--dy, -1%)); }
    to { transform:scale(1.035) translate(0, 0); }
  }
  .is-motion-paused .residence-photo__surface { animation-play-state:paused; }

  .lightbox__image img { animation:photo-settle 7s cubic-bezier(.2,.6,.25,1) both; }
  @keyframes photo-settle { from { transform:scale(1.03); } to { transform:scale(1); } }

  /* Arriving at a residence: the photograph opens upward, the words follow. */
  .residence-photos.is-entering { animation:stage-enter 1.6s cubic-bezier(.16,1,.3,1) both; }
  @keyframes stage-enter { from { clip-path:inset(100% 0 0 0); } to { clip-path:inset(0 0 0 0); } }
  .residence-showcase.is-entering .residence-intro > * { animation:intro-rise 1.2s cubic-bezier(.16,1,.3,1) both; }
  .residence-showcase.is-entering .residence-intro > :nth-child(2) { animation-delay:.09s; }
  .residence-showcase.is-entering .residence-intro > :nth-child(3) { animation-delay:.18s; }
  .residence-showcase.is-entering .residence-intro > :nth-child(4) { animation-delay:.27s; }
  .residence-showcase.is-entering .residence-intro > :nth-child(5) { animation-delay:.36s; }
  .residence-showcase.is-entering .residence-gallery__bar,
  .residence-showcase.is-entering .residence-thumbnails { animation:intro-rise 1.2s cubic-bezier(.16,1,.3,1) .5s both; }
  @keyframes intro-rise { from { opacity:0; transform:translateY(26px); } to { opacity:1; transform:none; } }

  /* Slideshow: a line fills while the current photograph is on stage. */
  .residence-gallery__bar { position:relative; }
  .residence-gallery__bar::before {
    content:''; position:absolute; top:-1px; left:0; width:100%; height:1px;
    background:var(--accent, #c1ac83); transform:scaleX(0); transform-origin:left;
  }
  .residence-gallery__bar.is-timing::before { animation:slide-timer var(--slide-time, 7s) linear both; }
  @keyframes slide-timer { from { transform:scaleX(0); } to { transform:scaleX(1); } }

  .residence-thumbnail { transition:opacity .5s ease, outline-color .5s ease; }
  .residence-thumbnail img { transition:scale 1.4s cubic-bezier(.2,.6,.2,1); }
  .residence-thumbnail:hover img, .residence-thumbnail[aria-current] img { scale:1.08; }

  /* Gallery grid: each frame opens out of a smaller window as it scrolls in. */
  .gallery__frame.will-reveal { clip-path:inset(14% 8%); opacity:0; }
  .gallery__frame.will-reveal.is-revealing {
    animation:photo-reveal 1.6s cubic-bezier(.16,1,.3,1) calc(var(--i, 0) * 110ms) both;
  }
  @keyframes photo-reveal {
    from { clip-path:inset(14% 8%); transform:scale(1.08); opacity:0; }
    to { clip-path:inset(0 0); transform:none; opacity:1; }
  }
  .gallery__item img { transition:filter .3s ease, scale 1.6s cubic-bezier(.2,.6,.2,1); }
  .gallery__frame { position:relative; }
  .gallery__frame::after { content:''; position:absolute; inset:0; background:rgba(13,12,11,0); transition:background .5s ease; pointer-events:none; }


  @media (hover:hover) {
    .gallery__item:hover img, .gallery__item:focus-visible img { scale:1.05; }
    .gallery__item:hover .gallery__frame::after { background:rgba(13,12,11,.14); }
  }
}
