/* Hide common thumbnail wrappers when they do NOT contain an <img>.
   Modern browsers support :has(); this alone fixes most themes. */
.post-thumbnail:not(:has(img)),
.entry-thumbnail:not(:has(img)),
.mh-thumbnail:not(:has(img)),
.mh-loop-thumb:not(:has(img)),
.loop-thumb:not(:has(img)),
.mh-slider .thumb:not(:has(img)),
.mh-widget .thumb:not(:has(img)),
.mh-slider-item .thumb:not(:has(img)),
figure.wp-post-image:not(:has(img)),
figure.post-thumbnail:not(:has(img)) {
  display: none !important;
  visibility: hidden !important;
  margin: 0 !important;
  padding: 0 !important;
  height: 0 !important;
  min-height: 0 !important;
}

/* If a wrapper becomes empty after JS cleanup, ensure no extra whitespace remains */
.mh-thumbnail:empty,
.mh-loop-thumb:empty,
.post-thumbnail:empty,
.entry-thumbnail:empty,
.loop-thumb:empty {
  display: none !important;
}

/* --- MH Magazine specific ---
   The theme outputs a placeholder <img class="mh-image-placeholder"> when no featured image exists.
   Hide the entire thumbnail figure/link in those cases.
*/
.mh-posts-grid-thumb:has(img.mh-image-placeholder),
.mh-posts-list-thumb:has(img.mh-image-placeholder),
.mh-posts-large-thumb:has(img.mh-image-placeholder),
.mh-slider .thumb:has(img.mh-image-placeholder),
.mh-widget .thumb:has(img.mh-image-placeholder),
.mh-slider-item .thumb:has(img.mh-image-placeholder),
figure:has(img.mh-image-placeholder),
a.mh-thumb-icon:has(img.mh-image-placeholder) {
  display: none !important;
  margin: 0 !important;
  padding: 0 !important;
  height: 0 !important;
  min-height: 0 !important;
}

/* If only the image is hidden by browser quirks, hide it hard */
img.mh-image-placeholder { display: none !important; }
