/* GSB Mobile Gallery Restore 0.2.0 (theme 1.5.59 compatibility).
   Replaces 0.1.0; affects only single WordPress articles and GSB reviews.
   Mobile only. Do not force arbitrary 16:10 or 4:3 on imported screenshots. */
@media (max-width: 640px) {
  .gsb-article-page .gsb-article-content .wp-block-gallery.has-nested-images,
  .gsb-article-page .gsb-article-content .gsb-article-gallery,
  .gsb-review-article .wp-block-post-content .wp-block-gallery.has-nested-images,
  .gsb-review-article .gsb-review-gameplay-section > .wp-block-gallery,
  .gsb-review-article .gsb-review-collection-section .gsb-review-gallery {
    grid-auto-rows: max-content !important;
    align-content: start !important;
    align-items: start !important;
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
  }

  /* Override the 1.5.59 rules, including any gallery image without a wrapper link. */
  .gsb-article-page .gsb-article-content figure.wp-block-image,
  .gsb-review-article .wp-block-post-content figure.wp-block-image,
  .gsb-review-article .gsb-review-gameplay-section figure.wp-block-image,
  .gsb-review-article .gsb-review-collection-section figure.wp-block-image {
    min-width: 0 !important;
    max-width: 100% !important;
    min-height: 0 !important;
    max-height: none !important;
    height: auto !important;
    aspect-ratio: auto !important;
    align-self: start !important;
    overflow: visible !important;
  }

  .gsb-article-page .gsb-article-content figure.wp-block-image > a,
  .gsb-review-article .wp-block-post-content figure.wp-block-image > a,
  .gsb-review-article .gsb-review-gameplay-section figure.wp-block-image > a,
  .gsb-review-article .gsb-review-collection-section figure.wp-block-image > a {
    display: block !important;
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
    aspect-ratio: auto !important;
  }

  .gsb-article-page .gsb-article-content figure.wp-block-image img,
  .gsb-review-article .wp-block-post-content figure.wp-block-image img,
  .gsb-review-article .gsb-review-gameplay-section figure.wp-block-image img,
  .gsb-review-article .gsb-review-collection-section figure.wp-block-image img {
    display: block !important;
    position: static !important;
    transform: none !important;
    width: 100% !important;
    max-width: 100% !important;
    min-height: 0 !important;
    max-height: none !important;
    height: auto !important;
    aspect-ratio: auto !important;
    object-fit: contain !important;
    object-position: center !important;
    box-sizing: border-box !important;
  }

  /* Preserve the earlier two-column review layout on standard phones. */
  .gsb-review-article .gsb-review-gameplay-section > .wp-block-gallery,
  .gsb-review-article .gsb-review-collection-section .gsb-review-gallery,
  .gsb-review-article .wp-block-post-content .gsb-review-gameplay-section > .wp-block-gallery.has-nested-images,
  .gsb-review-article .wp-block-post-content .gsb-review-collection-section .gsb-review-gallery.has-nested-images {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 10px !important;
  }

  /* Article galleries were already one column on the original small-screen theme. */
  .gsb-article-page .gsb-article-content .wp-block-gallery.has-nested-images,
  .gsb-article-page .gsb-article-content .gsb-article-gallery {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) !important;
    gap: 18px !important;
  }
}

@media (max-width: 359px) {
  .gsb-review-article .gsb-review-gameplay-section > .wp-block-gallery,
  .gsb-review-article .gsb-review-collection-section .gsb-review-gallery,
  .gsb-review-article .wp-block-post-content .wp-block-gallery.has-nested-images {
    grid-template-columns: minmax(0, 1fr) !important;
  }
}
