/* ModelBook — Portfolio Uncrop HARD Fix v1.4.6 */

/* Kill forced square ratio everywhere in gallery-like layouts */
[class*="portfolio"] img,
[class*="gallery"] img,
[class*="masonry"] img,
[class*="photo"] img,
[class*="grid"] img,
.portfolio-page img,
.polas-page img{
  width:100%!important;
  height:auto!important;
  min-height:0!important;
  max-height:none!important;
  aspect-ratio:auto!important;
  object-fit:contain!important;
  object-position:center center!important;
  display:block!important;
}

/* Containers: no square box */
[class*="portfolio"] figure,
[class*="gallery"] figure,
[class*="masonry"] figure,
[class*="photo-card"],
[class*="gallery-item"],
[class*="portfolio-item"],
[class*="grid-item"],
.portfolio-grid a,
.gallery-grid a,
.photos-grid a,
.masonry-grid a{
  height:auto!important;
  min-height:0!important;
  max-height:none!important;
  aspect-ratio:auto!important;
  overflow:visible!important;
}

/* Specific probable old rules */
.portfolio-card,
.portfolio-item,
.gallery-card,
.gallery-item,
.photo-card,
.photo-item,
.grid-item{
  height:auto!important;
  aspect-ratio:auto!important;
}

/* If background-image cards exist, make them less destructive */
.portfolio-card[style*="background"],
.gallery-card[style*="background"],
.photo-card[style*="background"],
.portfolio-item[style*="background"],
.gallery-item[style*="background"]{
  background-size:contain!important;
  background-repeat:no-repeat!important;
  background-position:center!important;
  aspect-ratio:auto!important;
}

/* Desktop editorial layout */
@media(min-width:901px){
  .portfolio-grid,
  .gallery-grid,
  .photos-grid,
  .masonry-grid,
  .work-grid,
  .grid-portfolio,
  [class*="portfolio-grid"],
  [class*="gallery-grid"]{
    display:grid!important;
    grid-template-columns:repeat(3, minmax(0, 1fr))!important;
    gap:18px!important;
    align-items:start!important;
  }
}

/* Tablet */
@media(min-width:601px) and (max-width:900px){
  .portfolio-grid,
  .gallery-grid,
  .photos-grid,
  .masonry-grid,
  .work-grid,
  .grid-portfolio,
  [class*="portfolio-grid"],
  [class*="gallery-grid"]{
    display:grid!important;
    grid-template-columns:repeat(2, minmax(0, 1fr))!important;
    gap:14px!important;
    align-items:start!important;
  }
}

/* Mobile */
@media(max-width:600px){
  .portfolio-grid,
  .gallery-grid,
  .photos-grid,
  .masonry-grid,
  .work-grid,
  .grid-portfolio,
  [class*="portfolio-grid"],
  [class*="gallery-grid"]{
    display:grid!important;
    grid-template-columns:1fr!important;
    gap:14px!important;
    align-items:start!important;
  }
}
