/* FineME v293 — deterministic media contain fix.
   Do not calculate intrinsic image dimensions in JavaScript. The image element
   always occupies the media stage and object-fit: contain paints the asset at
   the largest safe size inside that viewport. */

.fm-v293 .fm-social-modal.is-media .fm-social-modal-body{
  display:block!important;
  width:100%!important;
  height:100%!important;
  min-width:0!important;
  min-height:0!important;
  overflow:hidden!important;
}

.fm-v293 .fm-media-viewer{
  display:grid!important;
  grid-template-rows:minmax(0,1fr) auto!important;
  width:100%!important;
  height:100%!important;
  min-width:0!important;
  min-height:0!important;
  overflow:hidden!important;
}

.fm-v293 .fm-media-stage{
  position:relative!important;
  display:block!important;
  width:100%!important;
  height:100%!important;
  min-width:0!important;
  min-height:0!important;
  overflow:hidden!important;
  contain:layout paint!important;
  background:#05070a!important;
}

/* Critical fix: the image box is pinned to the stage. Its bitmap is then
   contained inside that box. This is stable for portrait, landscape and very
   large images and does not depend on getBoundingClientRect() timing. */
.fm-v293 .fm-media-stage > img{
  position:absolute!important;
  inset:0!important;
  display:block!important;
  width:100%!important;
  height:100%!important;
  max-width:none!important;
  max-height:none!important;
  min-width:0!important;
  min-height:0!important;
  margin:0!important;
  padding:0!important;
  object-fit:contain!important;
  object-position:center center!important;
  border-radius:0!important;
  background:transparent!important;
  transform-origin:center center!important;
}

/* Navigation/counter must remain above the full-stage image. */
.fm-v293 .fm-media-stage > .fm-media-nav,
.fm-v293 .fm-media-stage > .fm-media-counter{
  z-index:6!important;
}

@media(min-width:781px){
  .fm-v293 .fm-social-modal-root.fm-media-modal-open{
    padding:clamp(10px,1.25vw,18px)!important;
  }
  .fm-v293 .fm-social-modal.is-media{
    width:min(1480px,calc(100vw - clamp(20px,2.5vw,36px)))!important;
    height:min(1040px,calc(100dvh - clamp(20px,2.5vw,36px)))!important;
    max-width:calc(100vw - clamp(20px,2.5vw,36px))!important;
    max-height:calc(100dvh - clamp(20px,2.5vw,36px))!important;
  }
}
