/* Service case studies: crop images to the card, independent of upload dimensions. */
.service_case_studies {
    container-type: inline-size;
}

.service_case_studies .elementor-loop-container {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 20px;
    align-items: stretch;
}

.service_case_studies .elementor-loop-container > .e-loop-item {
    min-width: 0;
    min-height: 0;
    margin: 0 !important;
}

.service_case_studies .e-loop-item > .e-con {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
    gap: 20px;
}

.service_case_studies .elementor-widget-image {
    position: relative;
    width: 100%;
    min-height: 0;
    aspect-ratio: 447 / 281;
    flex: none;
    overflow: hidden;
}

.service_case_studies .elementor-widget-image img {
    position: absolute;
    inset: 0;
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
}

.service_case_studies .elementor-widget-theme-post-title {
    flex: none;
    margin: 0;
}

/* Two results fill the row; one result retains the normal card width. */
.service_case_studies .elementor-loop-container:has(> .e-loop-item:nth-of-type(2)):not(:has(> .e-loop-item:nth-of-type(3))) {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

@media (min-width: 1025px) {
    /* Four results use the homepage's portrait / stacked landscape / portrait layout. */
    .service_case_studies .elementor-loop-container:has(> .e-loop-item:nth-of-type(4)):not(:has(> .e-loop-item:nth-of-type(5))) {
        grid-template-rows: repeat(2, minmax(0, 1fr));
        height: calc((100cqw - 40px) * 700 / 1341);
    }

    .service_case_studies .elementor-loop-container:has(> .e-loop-item:nth-of-type(4)):not(:has(> .e-loop-item:nth-of-type(5))) > .e-loop-item {
        height: 100%;
    }

    .service_case_studies .elementor-loop-container:has(> .e-loop-item:nth-of-type(4)):not(:has(> .e-loop-item:nth-of-type(5))) .elementor-widget-image {
        flex: 1 1 0;
        aspect-ratio: auto;
    }

    .service_case_studies .elementor-loop-container:has(> .e-loop-item:nth-of-type(4)):not(:has(> .e-loop-item:nth-of-type(5))) > .e-loop-item:nth-of-type(1) {
        grid-area: 1 / 1 / 3 / 2;
    }

    .service_case_studies .elementor-loop-container:has(> .e-loop-item:nth-of-type(4)):not(:has(> .e-loop-item:nth-of-type(5))) > .e-loop-item:nth-of-type(2) {
        grid-area: 1 / 2 / 2 / 3;
    }

    .service_case_studies .elementor-loop-container:has(> .e-loop-item:nth-of-type(4)):not(:has(> .e-loop-item:nth-of-type(5))) > .e-loop-item:nth-of-type(3) {
        grid-area: 2 / 2 / 3 / 3;
    }

    .service_case_studies .elementor-loop-container:has(> .e-loop-item:nth-of-type(4)):not(:has(> .e-loop-item:nth-of-type(5))) > .e-loop-item:nth-of-type(4) {
        grid-area: 1 / 3 / 3 / 4;
    }
}

@media (max-width: 1024px) {
    .service_case_studies .elementor-loop-container {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 767px) {
    .service_case_studies .elementor-loop-container,
    .service_case_studies .elementor-loop-container:has(> .e-loop-item:nth-of-type(2)):not(:has(> .e-loop-item:nth-of-type(3))) {
        grid-template-columns: minmax(0, 1fr);
        row-gap: 30px;
    }
}
