/*
 * Remote Hand VAs V153
 * Centers incomplete final rows of homepage Services/Specializations-style cards.
 * Safe CSS only. No database/admin/hero/popup changes.
 */

/* Common homepage card grid class names used across RHVA patches */
body.home .rhv-home-card-grid,
body.home .rhv-services-grid,
body.home .rhv-specializations-grid,
body.home .rhv61-card-grid,
body.home .rhv-cards-grid,
body.home .cards-grid,
body.home .service-grid,
body.home .specialization-grid,
.home .rhv-home-card-grid,
.home .rhv-services-grid,
.home .rhv-specializations-grid,
.home .rhv61-card-grid,
.home .rhv-cards-grid,
.home .cards-grid,
.home .service-grid,
.home .specialization-grid,
main .rhv-home-card-grid,
main .rhv-services-grid,
main .rhv-specializations-grid {
    display: flex !important;
    flex-wrap: wrap !important;
    justify-content: center !important;
    align-items: stretch !important;
    gap: clamp(20px, 2.2vw, 28px) !important;
}

body.home .rhv-home-card-grid > *,
body.home .rhv-services-grid > *,
body.home .rhv-specializations-grid > *,
body.home .rhv61-card-grid > *,
body.home .rhv-cards-grid > *,
body.home .cards-grid > *,
body.home .service-grid > *,
body.home .specialization-grid > *,
.home .rhv-home-card-grid > *,
.home .rhv-services-grid > *,
.home .rhv-specializations-grid > *,
.home .rhv61-card-grid > *,
.home .rhv-cards-grid > *,
.home .cards-grid > *,
.home .service-grid > *,
.home .specialization-grid > *,
main .rhv-home-card-grid > *,
main .rhv-services-grid > *,
main .rhv-specializations-grid > * {
    flex: 0 1 clamp(300px, 30.5%, 390px) !important;
    max-width: 390px !important;
    min-width: min(100%, 300px) !important;
}

/* Fallback for section containers where the grid class is on the card wrapper's parent */
body.home section:has(.rhv-service-card),
body.home section:has(.rhv-specialization-card),
.home section:has(.rhv-service-card),
.home section:has(.rhv-specialization-card) {
    --rhva-v153-safe: 1;
}

@media (max-width: 980px) {
    body.home .rhv-home-card-grid > *,
    body.home .rhv-services-grid > *,
    body.home .rhv-specializations-grid > *,
    body.home .rhv61-card-grid > *,
    body.home .rhv-cards-grid > *,
    body.home .cards-grid > *,
    body.home .service-grid > *,
    body.home .specialization-grid > *,
    .home .rhv-home-card-grid > *,
    .home .rhv-services-grid > *,
    .home .rhv-specializations-grid > *,
    .home .rhv61-card-grid > *,
    .home .rhv-cards-grid > *,
    .home .cards-grid > *,
    .home .service-grid > *,
    .home .specialization-grid > *,
    main .rhv-home-card-grid > *,
    main .rhv-services-grid > *,
    main .rhv-specializations-grid > * {
        flex-basis: clamp(280px, 45%, 390px) !important;
    }
}

@media (max-width: 640px) {
    body.home .rhv-home-card-grid > *,
    body.home .rhv-services-grid > *,
    body.home .rhv-specializations-grid > *,
    body.home .rhv61-card-grid > *,
    body.home .rhv-cards-grid > *,
    body.home .cards-grid > *,
    body.home .service-grid > *,
    body.home .specialization-grid > *,
    .home .rhv-home-card-grid > *,
    .home .rhv-services-grid > *,
    .home .rhv-specializations-grid > *,
    .home .rhv61-card-grid > *,
    .home .rhv-cards-grid > *,
    .home .cards-grid > *,
    .home .service-grid > *,
    .home .specialization-grid > *,
    main .rhv-home-card-grid > *,
    main .rhv-services-grid > *,
    main .rhv-specializations-grid > * {
        flex: 0 1 100% !important;
        max-width: 430px !important;
    }
}