/* Detailflow 2.5.7: contain responsive media within its allocated grid column. */
body.ccsaid-detail-page .ccsds-media-info {
    grid-template-columns: minmax(0, 1.05fr) minmax(0, .95fr);
}

body.ccsaid-detail-page .ccsds-media-info > .ccsds-media-card,
body.ccsaid-detail-page .ccsds-media-info > .ccsds-copy-card,
body.ccsaid-detail-page .ccsds-split-modern > .ccsds-media-card,
body.ccsaid-detail-page .ccsds-split-modern > .ccsds-copy-card {
    min-width: 0;
    max-width: 100%;
}

body.ccsaid-detail-page .ccsds-media-info > .ccsds-copy-card,
body.ccsaid-detail-page .ccsds-split-modern > .ccsds-copy-card {
    overflow-wrap: anywhere;
}

/* Explicit boxes also work when the shared stylesheet still has display:contents. */
body.ccsaid-detail-page .ccsds-media-card {
    position: relative;
}

body.ccsaid-detail-page .ccsds-media-card > .ccsbu-picture {
    position: absolute;
    inset: 0;
    display: block;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

body.ccsaid-detail-page .ccsds-media-card > .ccsbu-picture > picture {
    display: block;
    width: 100%;
    height: 100%;
}

body.ccsaid-detail-page .ccsds-media-card > .ccsbu-picture img {
    position: absolute;
    inset: 0;
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Do not combine a stretched 100% row height with this intrinsic 3:2 ratio:
 * the transferred width would exceed the left grid track and cover the copy.
 * Width now determines height; contain preserves the entire technical motif. */
body.ccsaid-detail-page .ccsds-media-info > .ccsaid-valvebox-media {
    width: 100%;
    height: auto;
    min-height: 0;
    aspect-ratio: 3 / 2;
    align-self: center;
}

body.ccsaid-detail-page .ccsaid-valvebox-media > .ccsbu-picture img {
    object-fit: contain;
    object-position: center;
}

/* The same motif is used by Anlagenservice. Service pages share this template:
 * long headings and descriptions must determine its height instead of being
 * clipped by the shared desktop hero's fixed height. Keep existing top spacing. */
@media (min-width: 801px) {
    body.ccsaid-service-detail .ccsds-subhero {
        height: auto;
        min-height: 520px;
    }

    body.ccsaid-service-detail .ccsds-subhero-copy {
        padding-bottom: 32px;
    }

    /* Keep the long German compound readable as a whole word on desktop. */
    body.ccsaid-service-irrigation-service .ccsds-subhero-copy h1 {
        font-size: clamp(32px, 3.4vw, 48px) !important;
    }
}

@media (max-width: 800px) {
    body.ccsaid-detail-page .ccsds-media-info {
        grid-template-columns: minmax(0, 1fr);
    }
}
