/**
 * Index feed «Лента» — tablet portrait voids (768 / 820–912 only).
 *
 * Culprit: cotinder-feed-gifts.css locks every half-card + mini-banner to
 * min-height:610px at exactly 768; last-tall also floors banners at 566px.
 * Beside the first real post that leaves a tall white hole where the next
 * user post should sit.
 *
 * Also beats late BODY_END align-items/align-self:start from gifts /
 * last-tall / photo-match so dense 2-col can show the neighbor card.
 *
 * Phone ≤767.98 and PC ≥1024 untouched. Does not edit custom.css /
 * mobile-card-fixes / footer.php / gifts.css.
 * Marker: feedtabvoid20261007b
 *
 * Companion JS cotinder-feed-tablet-masonry.js moves the next half-card
 * before a full-width city-ads/advice when an odd hole would appear
 * (Safari/PWA often leave the right cell empty despite dense).
 */

/* Whole tablet 2-col band: force dense grid (beats late flex leaks) */
@media (min-width: 768px) and (max-width: 1199.98px) {
  html body .tabs__content.tabs__content_active .cotinder-index-feed[data-cotinder-feed-tab="last"] .index__posts,
  html body .cotinder-index-feed[data-cotinder-feed-tab="last"] .index__posts {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    grid-auto-flow: dense !important;
    align-items: start !important;
    gap: 15px !important;
  }

  html body .cotinder-index-feed[data-cotinder-feed-tab="last"] .index__posts > .index__post.index__post_full,
  html body .cotinder-index-feed[data-cotinder-feed-tab="last"] .index__posts > .index__post.index__post_be-part,
  html body .cotinder-index-feed[data-cotinder-feed-tab="last"] .index__posts > .index__post.index__post_curator-advice,
  html body .cotinder-index-feed[data-cotinder-feed-tab="last"] .index__posts > .index__post.cotinder-pet-horoscope-wrap,
  html body .cotinder-index-feed[data-cotinder-feed-tab="last"] .index__posts > .index__post.cotinder-city-ads,
  html body .cotinder-index-feed[data-cotinder-feed-tab="last"] .index__posts > .index__post.cotinder-onboarding {
    grid-column: 1 / -1 !important;
    width: 100% !important;
    max-width: 100% !important;
  }
}

@media (min-width: 768px) and (max-width: 768.98px),
       (min-width: 820px) and (max-width: 912.98px) {

  /* Kill artificial 610 / 566 floors that paint empty holes */
  html body .cotinder-index-feed[data-cotinder-feed-tab="last"] .index__posts > .index__post:not(.index__post_full):not(.index__post_be-part),
  html body .cotinder-index-feed[data-cotinder-feed-tab="last"] .index__posts > .index__post.index__post_feed-banner:not(.index__post_full),
  html body .cotinder-index-feed[data-cotinder-feed-tab="last"] .index__post > .card.user-slide,
  html body .cotinder-index-feed[data-cotinder-feed-tab="last"] .index__posts > .index__post:not(.index__post_full):not(.index__post_be-part) > .card.user-slide,
  html body .cotinder-index-feed[data-cotinder-feed-tab="last"] .index__posts > .index__post.index__post_feed-banner:not(.index__post_full) > a.card.card__cotinder:not(.card__cotinder_full) {
    min-height: 0 !important;
    height: auto !important;
    max-height: none !important;
  }

  html body .cotinder-index-feed[data-cotinder-feed-tab="last"] .index__posts > .index__post:not(.index__post_full):not(.index__post_be-part):not(.index__post_curator-advice) {
    display: flex !important;
    flex-direction: column !important;
    align-self: start !important;
    width: auto !important;
    max-width: none !important;
    flex: none !important;
    box-sizing: border-box !important;
  }

  html body .cotinder-index-feed[data-cotinder-feed-tab="last"] .index__posts > .index__post:not(.index__post_feed-banner):not(.index__post_curator-advice):not(.index__post_full) > .card.user-slide,
  html body .cotinder-index-feed[data-cotinder-feed-tab="last"] .index__posts > .index__post:not(.index__post_feed-banner):not(.index__post_curator-advice):not(.index__post_full) > .card.user-slide.card__video {
    display: flex !important;
    flex-direction: column !important;
    flex: 0 0 auto !important;
    align-self: start !important;
    width: 100% !important;
    overflow: visible !important;
  }

  /* Mini-banner: hug image — no 566/610 white slab beside first post */
  html body .cotinder-index-feed[data-cotinder-feed-tab="last"] .index__posts > .index__post.index__post_feed-banner:not(.index__post_full) {
    display: flex !important;
    flex-direction: column !important;
    align-self: start !important;
    min-height: 0 !important;
  }

  html body .cotinder-index-feed[data-cotinder-feed-tab="last"] .index__posts > .index__post.index__post_feed-banner:not(.index__post_full) > a.card.card__cotinder:not(.card__cotinder_full) {
    position: relative !important;
    inset: auto !important;
    display: block !important;
    flex: 0 0 auto !important;
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
    overflow: hidden !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  html body .cotinder-index-feed[data-cotinder-feed-tab="last"] .index__posts > .index__post.index__post_feed-banner:not(.index__post_full) > a.card.card__cotinder:not(.card__cotinder_full) > img {
    display: block !important;
    width: 100% !important;
    height: auto !important;
    max-height: none !important;
    object-fit: contain !important;
    object-position: center !important;
  }

  /* Keep photo/video media visible (3:4) so the neighbor post is not a blank cell */
  html body .cotinder-index-feed[data-cotinder-feed-tab="last"] .index__posts > .index__post:not(.index__post_feed-banner):not(.index__post_curator-advice):not(.index__post_full) > .card.user-slide:not(.card__video):not(.cotinder-lucky-wheel) > .card-img-wrap,
  html body .cotinder-index-feed[data-cotinder-feed-tab="last"] .index__posts > .index__post:not(.index__post_feed-banner):not(.index__post_curator-advice):not(.index__post_full) > .card.user-slide:not(.card__video):not(.cotinder-lucky-wheel) > a.card-img-wrap,
  html body .cotinder-index-feed[data-cotinder-feed-tab="last"] .index__posts > .index__post:not(.index__post_feed-banner):not(.index__post_curator-advice):not(.index__post_full) > .card.user-slide:not(.card__video):not(.cotinder-lucky-wheel) > .card__media-wrap.card-img-wrap,
  html body .cotinder-index-feed[data-cotinder-feed-tab="last"] .index__posts > .index__post:not(.index__post_feed-banner):not(.index__post_curator-advice):not(.index__post_full) > .card.user-slide.card__video > .card__media-wrap {
    display: block !important;
    position: relative !important;
    width: 100% !important;
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
    aspect-ratio: 3 / 4 !important;
    overflow: hidden !important;
    flex: 0 0 auto !important;
    margin: 0 0 10px !important;
  }

  html body .cotinder-index-feed[data-cotinder-feed-tab="last"] .index__posts > .index__post > .card.user-slide:not(.index__community-card) > .card-desc {
    display: -webkit-box !important;
    -webkit-box-orient: vertical !important;
    -webkit-line-clamp: 3 !important;
    overflow: hidden !important;
    visibility: visible !important;
    opacity: 1 !important;
    flex: 0 0 auto !important;
    min-height: calc(17px * 3) !important;
    max-height: calc(17px * 3) !important;
    line-height: 17px !important;
  }
}

/* Portrait only: one row height, no empty cell beside a short card.
   Phone ≤767 and PC ≥1024 stay on their own rules. */
@media (min-width: 768px) and (max-width: 1023.98px) and (orientation: portrait) {
  html body.page-index .tabs__content.tabs__content_active .cotinder-index-feed[data-cotinder-feed-tab="last"] .index__posts {
    align-items: stretch !important;
  }

  html body.page-index .tabs__content.tabs__content_active .cotinder-index-feed[data-cotinder-feed-tab="last"] .index__posts > .index__post:not(.index__post_full):not(.index__post_be-part):not(.index__post_curator-advice):not(.cotinder-city-ads):not(.cotinder-onboarding) {
    align-self: stretch !important;
    height: auto !important;
    display: flex !important;
    flex-direction: column !important;
  }

  html body.page-index .tabs__content.tabs__content_active .cotinder-index-feed[data-cotinder-feed-tab="last"] .index__posts > .index__post:not(.index__post_full):not(.index__post_be-part):not(.index__post_curator-advice):not(.cotinder-city-ads) > .card.user-slide,
  html body.page-index .tabs__content.tabs__content_active .cotinder-index-feed[data-cotinder-feed-tab="last"] .index__posts > .index__post:not(.index__post_full):not(.index__post_be-part):not(.index__post_curator-advice):not(.cotinder-city-ads) > .card.user-slide.card__video,
  html body.page-index .tabs__content.tabs__content_active .cotinder-index-feed[data-cotinder-feed-tab="last"] .index__posts > .index__post.index__post_feed-banner:not(.index__post_full) > a.card.card__cotinder:not(.card__cotinder_full) {
    flex: 1 1 auto !important;
    height: 100% !important;
    min-height: 0 !important;
    max-height: none !important;
  }

  html body.page-index .tabs__content.tabs__content_active .cotinder-index-feed[data-cotinder-feed-tab="last"] .index__posts > .index__post.index__post_feed-banner:not(.index__post_full) > a.card.card__cotinder:not(.card__cotinder_full) > img {
    height: 100% !important;
    object-fit: cover !important;
  }
}
