/*
 * Layout for images placed in page content by the editor's image-drop widget
 * (tinymce plugin wz_imagedrop).
 *
 * Loaded in two places so the editor shows what visitors get:
 *   - the visitor page: linked from wz_default/templates/default.tpl
 *   - the TinyMCE iframe: pushed into content CSS by the plugin
 *
 * Markup:
 *   <figure class="wz_image wz_image_fill">          one image, full content width
 *   <figure class="wz_image">                        one image, natural size
 *   <div class="wz_image_tiles wz_cols_3">           a grid of figures
 *     <figure class="wz_image">...</figure>
 *   </div>
 * Each figure holds <a class="fancybox" data-fancybox="gallery"><img/></a> and an
 * optional <figcaption>. Skins may restyle any of this; nothing here is !important.
 */

.wz_image {
  display: block;
  max-width: 100%;
  margin: 0 0 1.5em 0;
  padding: 0;
}

.wz_image > a {
  display: block;
  line-height: 0;
}

.wz_image img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 0 auto;
  border: 0;
}

.wz_image_fill img {
  width: 100%;
}

.wz_image figcaption {
  margin: 0.5em 0 0 0;
  font-size: 0.8em;
  line-height: 1.4;
  text-align: center;
  opacity: 0.8;
}

/* Tiles -------------------------------------------------------------- */

.wz_image_tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.75rem;
  margin: 0 0 1.5em 0;
  padding: 0;
}

.wz_image_tiles.wz_cols_2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.wz_image_tiles.wz_cols_3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.wz_image_tiles.wz_cols_4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.wz_image_tiles .wz_image {
  margin: 0;
  min-width: 0;
}

/* Every tile is cropped to the same shape so rows line up. */
.wz_image_tiles .wz_image img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
}

@media (max-width: 600px) {
  .wz_image_tiles.wz_cols_3,
  .wz_image_tiles.wz_cols_4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
