/**
 * Pet detail — level badge in the TOP-RIGHT corner of the photo (all widths).
 * Restores photo-overlay placement; undoes “beside rating” grid that pulled
 * the badge under the image. Beats mobile-card-fixes bottom-left (≤1199).
 * Does not edit custom.css / mobile-card-fixes / footer.php.
 */

/* Photo frame must be positioning context */
html body .pet .pet-detail-page .pet__top .pet__top_image,
html body .pet .pet-detail-page .pet__top .pet__top_media > .pet__top_image,
html body .pet .pet__top .pet__top_media > .pet__top_image {
  position: relative !important;
  overflow: visible !important;
}

/* Undo prior grid/flex that parked level next to stars */
html body .pet .pet-detail-page .pet__top .pet__top_image,
html body .pet .pet-detail-page .pet__top .pet__top_media > .pet__top_image {
  display: block !important;
  grid-template-columns: unset !important;
  grid-template-rows: unset !important;
}

html body .pet .pet-detail-page .pet__top .pet__top_image > img:not(.pet-photo-badge_search-home),
html body .pet .pet-detail-page .pet__top .pet__top_media > .pet__top_image > img:not(.pet-photo-badge_search-home),
html body .pet .pet__top .pet__top_media > .pet__top_image > img:not(.pet-photo-badge_search-home) {
  display: block !important;
  width: 100% !important;
  max-width: 100% !important;
  height: auto !important;
  grid-column: unset !important;
  grid-row: unset !important;
  order: unset !important;
}

/* Stars under photo — normal block, not in a level+stars row */
html body .pet .pet-detail-page .pet__top .pet__top_image > .card-stars__wrapper,
html body .pet .pet-detail-page .pet__top .pet__top_media > .pet__top_image > .card-stars__wrapper,
html body .pet .pet__top .pet__top_media > .pet__top_image > .card-stars__wrapper {
  position: static !important;
  display: flex !important;
  width: 100% !important;
  max-width: 100% !important;
  margin-top: 8px !important;
  box-sizing: border-box !important;
  grid-column: unset !important;
  grid-row: unset !important;
  order: unset !important;
}

/* Level: top-right on the PHOTO (all resolutions) */
html body .pet .pet-detail-page .pet__top .pet__top_image > .cotinder-level-badge,
html body .pet .pet-detail-page .pet__top .pet__top_media > .pet__top_image > .cotinder-level-badge,
html body .pet .pet__top .pet__top_media > .pet__top_image > .cotinder-level-badge,
html body .pet-detail-page .pet__top_image > .cotinder-level-badge {
  position: absolute !important;
  top: 8px !important;
  right: 8px !important;
  left: auto !important;
  bottom: auto !important;
  z-index: 6 !important;
  margin: 0 !important;
  max-width: calc(100% - 16px) !important;
  align-self: auto !important;
  justify-self: auto !important;
  grid-column: unset !important;
  grid-row: unset !important;
  order: unset !important;
  pointer-events: auto !important;
  box-sizing: border-box !important;
}

/* Keep title compact on photo */
html body .pet .pet-detail-page .pet__top .pet__top_image > .cotinder-level-badge .cotinder-level-badge__name,
html body .pet .pet-detail-page .pet__top .pet__top_media > .pet__top_image > .cotinder-level-badge .cotinder-level-badge__name,
html body .pet-detail-page .pet__top_image > .cotinder-level-badge .cotinder-level-badge__name {
  display: none !important;
}

/* Phone: slightly larger tap target, still top-right */
@media (max-width: 767.98px) {
  html body .pet .pet-detail-page .pet__top .pet__top_image > .cotinder-level-badge,
  html body .pet .pet-detail-page .pet__top .pet__top_media > .pet__top_image > .cotinder-level-badge,
  html body .pet-detail-page .pet__top_image > .cotinder-level-badge {
    top: 8px !important;
    right: 8px !important;
    left: auto !important;
    bottom: auto !important;
    min-height: 32px !important;
    padding: 5px 10px 5px 7px !important;
    font-size: 12px !important;
  }

  html body .pet .pet-detail-page .pet__top .pet__top_image > .card-stars__wrapper,
  html body .pet .pet-detail-page .pet__top .pet__top_media > .pet__top_image > .card-stars__wrapper {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 10px !important;
  }
}

/* Tablet ≤1199: beat mobile-card-fixes bottom-left plaque */
@media (max-width: 1199.98px) {
  html body .pet .pet-detail-page .pet__top .pet__top_image > .cotinder-level-badge,
  html body .pet .pet-detail-page .pet__top .pet__top_media > .pet__top_image > .cotinder-level-badge,
  html body .pet-detail-page .pet__top_image > .cotinder-level-badge {
    top: 8px !important;
    right: 8px !important;
    left: auto !important;
    bottom: auto !important;
  }
}
