﻿/**
 * Exact widths 768 / 820 / 1366: square photos on feed / user / pet /
 * announcement cards and post detail stills — match near-square PC (≥1441)
 * and tablet 1:1 crops.
 *
 * Culprit at ≤1440: custom.css `.card-img { height: 243px }` → landscape
 * when card width > 243 (2–3 col grids at 768/820/1366).
 *
 * Video stays 3:4 (.card__video / .post__img:has(.post__video)).
 * Other widths untouched. Does not edit custom.css / mobile-card-fixes / footer.php.
 */

@media (min-width: 768px) and (max-width: 768.98px),
       (min-width: 820px) and (max-width: 912.98px),
       (min-width: 1366px) and (max-width: 1366.98px) {
  /* --- Card grid photos (posts, pets, owners, announcements, search) --- */
  .card:not(.card__advice):not(.card__video) img.card-img,
  .card:not(.card__advice):not(.card__video) .card-img-wrap img.card-img,
  .card:not(.card__advice):not(.card__video) .card__gallery-swiper img.card-img,
  .announcement-card img.card-img,
  .another-pet .user-slide:not(.card__video) img.card-img,
  .index__post .card.user-slide:not(.card__advice):not(.card__video) img.card-img {
    display: block !important;
    width: 100% !important;
    height: auto !important;
    max-height: none !important;
    margin-bottom: 0 !important;
    aspect-ratio: 1 / 1 !important;
    object-fit: cover !important;
    object-position: center !important;
  }

  /* Media wraps follow the square image (not video 3:4 wraps) */
  .card:not(.card__advice):not(.card__video) > .card-img-wrap,
  .card:not(.card__advice):not(.card__video) > a.card-img-wrap,
  .card:not(.card__advice):not(.card__video) > .card__media-wrap.card-img-wrap,
  .announcement-card > .card-img-wrap,
  .announcement-card > a.card-img-wrap,
  .another-pet .user-slide:not(.card__video) > .card-img-wrap,
  .another-pet .user-slide:not(.card__video) > a.card-img-wrap {
    display: block !important;
    width: 100% !important;
    height: auto !important;
    max-height: none !important;
    min-height: 0 !important;
    margin-bottom: 10px !important;
    aspect-ratio: 1 / 1 !important;
    overflow: hidden !important;
  }

  .card:not(.card__advice):not(.card__video) > .card__media-wrap.card-img-wrap img.card-img,
  .card:not(.card__advice):not(.card__video) > .card-img-wrap img.card-img,
  .card:not(.card__advice):not(.card__video) > a.card-img-wrap img.card-img {
    height: 100% !important;
    aspect-ratio: auto !important;
  }

  /* Gallery slides fill the square wrap */
  .card:not(.card__video) .card__media-wrap--gallery .card__gallery-swiper,
  .card:not(.card__video) .card__media-wrap--gallery .swiper-wrapper,
  .card:not(.card__video) .card__media-wrap--gallery .swiper-slide {
    height: 100% !important;
  }

  /* --- Post detail stills (photos only) --- */
  .post__img:not(:has(.post__video)) {
    aspect-ratio: 1 / 1 !important;
    height: auto !important;
    max-height: none !important;
  }

  .post__img:not(:has(.post__video)) .post__swiper,
  .post__img:not(:has(.post__video)) .swiper-wrapper,
  .post__img:not(:has(.post__video)) .swiper-slide {
    width: 100% !important;
    height: 100% !important;
  }

  .post__img:not(:has(.post__video)) img {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    object-position: center top !important;
  }

  /* --- Pet list / care-hub style thumbs if present --- */
  .pet-item > .pet-item__top > a,
  .pet-list > .pet-item > .pet-item__top > a {
    display: block !important;
    aspect-ratio: 1 / 1 !important;
    overflow: hidden !important;
  }

  .pet-item > .pet-item__top img:not(.pet-photo-badge_search-home),
  .pet-list > .pet-item > .pet-item__top > a > img {
    width: 100% !important;
    height: 100% !important;
    max-height: none !important;
    aspect-ratio: auto !important;
    object-fit: cover !important;
  }
}
