/* Photo slots belong to the layout, never to the uploaded file's dimensions.
 * The 1.0 section ratios and hero breakpoints are retained.
 * Opt out for additional brand artwork with the libotin-no-crop class.
 */
#main :is(.split) { --libotin-photo-ratio: 1.36; }
#main :is(.news-grid) { --libotin-photo-ratio: 1.1; }
#main :is(.gallery, .gallery-item, .wp-block-gallery) { --libotin-photo-ratio: 1.35; }
#main :is(.article, .libotin-news-card) { --libotin-photo-ratio: 500 / 333; }

#main img:not(:where(
  .brand img, .footer-logo, .ismm-member img, .language-switch img,
  .emoji, .wp-smiley, .itp-contact-icon, .unified-contact img, .contact-icon img, .round-icon img,
  .wp-block-site-logo img, .wp-block-site-icon img,
  .libotin-no-crop, .libotin-no-crop img, .lightbox img,
  [class*="logo" i], [class*="icon" i], [src*="logo" i], [src*="icon" i],
  [src*="flag-" i], [src*=".svg" i], [src^="data:image/svg" i],
  [alt*="logo" i]
)) {
  display: block;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  height: auto !important;
  aspect-ratio: var(--libotin-photo-ratio, 3 / 2) !important;
  object-fit: cover !important;
}
/* Cover keeps the original focal point, rounding, and hover transform. */
#main .hero > img:not(.libotin-no-crop),
#main .hero > :is(figure, picture, a):has(img:not(.libotin-no-crop)) {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100% !important;
  aspect-ratio: auto !important;
  margin: 0;
}
#main .hero > :is(figure, picture, a) img:not(.libotin-no-crop) {
  height: 100% !important;
  aspect-ratio: auto !important;
  object-position: center 55%;
}
/* Image/link wrappers must not contribute an intrinsic minimum grid width. */
#main :is(.split, .news-grid, .libotin-news-card, .gallery) > :is(img, figure, picture, a):has(img),
#main :is(.split, .news-grid, .libotin-news-card, .gallery) > img {
  min-width: 0;
}
#main .libotin-no-crop,
#main .libotin-no-crop img { object-fit: contain !important; }
@media (max-width: 760px) {
  #main .news-grid { --libotin-photo-ratio: 1.6; }
  #main .hero > :is(figure, picture, a) img:not(.libotin-no-crop) { object-position: 60% center; }
  #main .split.reverse > :is(figure, picture, a):has(img) { order: 2; }
}
/* Enlarged gallery photographs also keep a stable viewing field matching the original first gallery photograph. */
.lightbox img {
  width: min(100%, calc(76vh * 999 / 749));
  height: auto !important;
  max-height: 76vh;
  aspect-ratio: 999 / 749 !important;
  object-fit: cover !important;
}
@media (max-width: 760px) {
  .lightbox img { width: min(100%, calc(70vh * 999 / 749)); max-height: 70vh; }
}
#main img:is(.footer-logo, .itp-contact-icon, [class*="logo" i], [class*="icon" i], [src*="logo" i], [src*="flag-" i], [src*=".svg" i]),
#main :is(.brand, .ismm-member, .language-switch, .unified-contact, .wp-block-site-logo, .wp-block-site-icon) img {
  object-fit: contain !important;
}
/* Native WordPress cover blocks already own their responsive frame. */
#main .wp-block-cover img.wp-block-cover__image-background {
  width: 100%;
  height: 100% !important;
  aspect-ratio: auto !important;
  object-fit: cover !important;
}
