/* DS 0.41.0 — ordinary photography stays in a column or a bounded gallery.
   The 1.5 geometry script adds ds150-stack when copy exceeds a 4:3 box.
   Copy is allowed to grow; its length must not turn the adjacent photo into
   a page-wide image. These rules load after the earlier geometry layers. */
body.ds-choice {
    --ds041-media-max: 640px;
}

body.ds-choice main#main :is(.ds150-pair, .product-story, .af110-copy-media) > :is(.ds150-copybox, .ds140-text-card, .af110-copy),
body.ds-choice main#main .ds0200-showroom-grid > .contact-section__copy {
    aspect-ratio: auto !important;
    height: auto;
    min-height: 0;
    min-width: 0;
    max-width: 100%;
}

/* This targets media wrappers, never hero slides, the lightbox, product-card
   viewports or the multi-photo scroll tracks. Existing image files, cropping,
   captions and controls remain attached to their original components. */
body.ds-choice main#main :is(.product-story__photo, .af110-illustration, .dsr2-photo-frame, .contact-section__media) {
    box-sizing: border-box;
    width: 100%;
    max-width: var(--ds041-media-max);
    min-width: 0;
    min-height: 0;
    height: auto !important;
    align-self: start !important;
}

@media (min-width: 981px) {
    body.ds-choice main#main :is(.ds150-pair, .product-story, .af110-copy-media, .ds0200-showroom-grid) {
        display: grid !important;
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        align-items: start !important;
        column-gap: var(--ds150-element-gap, 28px) !important;
        row-gap: var(--ds150-element-gap, 28px);
    }

    /* Neutralise both the old <1200px stack and its long-copy fallback. */
    body.ds-choice main#main :is(.ds150-pair, .product-story, .af110-copy-media) > :is(.ds150-copybox, .ds150-media-box, .ds140-text-card, .product-story__photo, .af110-copy, .af110-illustration) {
        grid-column: auto !important;
        grid-row: auto !important;
    }

    body.ds-choice main#main .hy-intro-media {
        width: 100%;
        max-width: var(--ds041-media-max);
        align-self: start !important;
    }

    /* Keep the authored left/right order of detail and generated-city rows. */
    body.ds-choice main#main .af110-copy-media[data-media-side="left"] > .af110-illustration,
    body.ds-choice main#main .dsgen-section[data-media-side="left"] .product-story > .product-story__photo,
    body.ds-choice[data-side="right"] main#main .hy-intro > .hy-intro-media {
        grid-column: 1 !important;
        grid-row: 1 !important;
    }

    body.ds-choice main#main .af110-copy-media[data-media-side="left"] > .af110-copy,
    body.ds-choice main#main .dsgen-section[data-media-side="left"] .product-story > :first-child:not(.product-story__photo),
    body.ds-choice[data-side="right"] main#main .hy-intro > .hy-intro-copy {
        grid-column: 2 !important;
        grid-row: 1 !important;
    }
}

@media (max-width: 980px) {
    body.ds-choice main#main :is(.product-story, .af110-copy-media) {
        display: grid;
        grid-template-columns: minmax(0, 1fr) !important;
        row-gap: var(--ds150-element-gap, 28px);
    }

    body.ds-choice main#main :is(.product-story, .af110-copy-media) > :is(.ds150-copybox, .ds150-media-box, .ds140-text-card, .product-story__photo, .af110-copy, .af110-illustration) {
        grid-column: 1 !important;
        grid-row: auto !important;
    }

    /* A tablet can stack the pair without expanding its photo to 900px. */
    body.ds-choice main#main .hy-intro-media:not(:has(> .af-mobile-products)) {
        width: 100%;
        max-width: var(--ds041-media-max);
    }
}

/* Single-image rows are real gallery items, not replacement hero banners.
   A direct-child selector deliberately excludes the display:contents rows
   inside the folding-roof carousel and its small multi-image grids. */
body.ds-choice main#main .af110-gallery > .container > .af110-gallery-row[data-row-count="1"],
body.ds-choice main#main .ds130-inspiration-row:has(> .ds130-inspiration-photo:only-child),
body.ds-choice main#main .af110-drawings:has(> .af110-figure:only-child),
body.ds-choice main#main .ds037-information-gallery,
body.ds-choice main#main :is(.ds036-team-group, .ds036-source-photo, .process-photo) {
    width: 100%;
    max-width: var(--ds041-media-max);
    box-sizing: border-box;
}

body.ds-choice main#main .af110-gallery > .container > .af110-gallery-row[data-row-count="1"] > .af110-gallery-cell {
    min-width: 0;
    max-width: 100%;
}

/* A lone project photograph keeps the complete view, including tall images. */
body.ds-choice main#main .ds130-inspiration-row > .ds130-inspiration-photo:only-child > a {
    aspect-ratio: 4 / 3;
}

body.ds-choice main#main .ds130-inspiration-row > .ds130-inspiration-photo:only-child img {
    height: 100%;
    object-fit: contain;
}

body.ds-choice main#main :is(.ds036-team-group, .ds036-source-photo) img {
    display: block;
    width: auto;
    max-width: 100%;
    height: auto;
    max-height: 480px;
    object-fit: contain;
}

body.ds-choice main#main .process-photo {
    height: auto;
    aspect-ratio: 4 / 3;
}

body.ds-choice main#main .process-photo img {
    height: 100%;
    object-fit: contain;
}
