/* Shared media proportion for the local DIAFAN storefront. The product's main
   viewer and expanded photos keep their own sizing. */
.st-flow-header ~ #wrapper {
    --st-preview-ratio: 4 / 3;
    --st-preview-background: #f5f5f1;
}

.st-flow-header ~ #wrapper :is(
    .catalog:not(.catalog_table) .catalog__pic,
    .st-product-relations .catalog__pic,
    .similar__pic,
    .st-product-compatibility-photo,
    .st-flow-featured-photo,
    .work-new__img,
    .st-flow-cat-tile > img,
    .st-flow-project-card img,
    .st-flow-home-kit-photo,
    .st-flow-solution-photo,
    .st-flow-offer-layout .st-solution__photo img,
    .st-city-day-gallery__grid img,
    .st-solutions--list .st-solution__image,
    .photo_list .photo_item > .photo_image > img,
    .gal_img_main,
    .st-flow-project-cover img
) {
    aspect-ratio: var(--st-preview-ratio) !important;
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
    width: 100%;
    box-sizing: border-box;
    background-color: var(--st-preview-background);
}

.st-flow-header ~ #wrapper :is(
    .catalog:not(.catalog_table) .catalog__pic,
    .st-product-relations .catalog__pic,
    .similar__pic,
    .st-product-compatibility-photo,
    .st-flow-featured-photo,
    .work-new__img,
    .st-flow-home-kit-photo,
    .st-flow-solution-photo
) {
    position: relative;
    overflow: hidden;
    padding: 0 !important;
}

.st-flow-header ~ #wrapper :is(
    .catalog:not(.catalog_table) .catalog__pic,
    .st-product-relations .catalog__pic,
    .similar__pic,
    .st-product-compatibility-photo,
    .st-flow-featured-photo,
    .work-new__img,
    .st-flow-home-kit-photo,
    .st-flow-solution-photo
) > img {
    position: absolute;
    inset: 0;
    display: block;
    width: 100% !important;
    height: 100% !important;
    max-width: none;
    max-height: none;
    margin: 0;
    object-fit: var(--st-preview-fit, contain);
}

.st-flow-header ~ #wrapper :is(
    .st-flow-report-preview,
    .st-flow-scene-grid .catalog__pic,
    .st-flow-tent-grid .catalog__pic,
    .st-flow-home-kit-photo,
    .st-flow-solution-photo,
    .work-new__img,
    .st-flow-featured-card:is([data-st-flow-good="21"], [data-st-flow-good="34"], [data-st-flow-good="417"]) .st-flow-featured-photo,
    .wrap_gallery .catalog__pic
) > img {
    --st-preview-fit: cover;
}

.st-flow-header ~ #wrapper .catalog__pic img[alt^="Визуализация"] {
    --st-preview-fit: contain;
}

.st-flow-header ~ #wrapper :is(
    .st-flow-project-card img,
    .st-flow-cat-tile > img,
    .st-flow-offer-layout .st-solution__photo img,
    .photo_list .photo_item > .photo_image > img,
    .st-flow-project-cover img
) {
    display: block;
    flex: none;
    object-fit: cover;
}

.st-flow-header ~ #wrapper .st-flow-scene-grid .catalog__pic img,
.st-flow-header ~ #wrapper .st-flow-tent-grid .catalog__pic img {
    object-position: center 42%;
}

.st-flow-header ~ #wrapper .photo_list .photo_item > .photo_image > img {
    margin: 0;
}

/* The older album aliases render the same module outside the portfolio shell. */
.st-flow--secondary ~ #wrapper .wrap_gallery > .photo_list:has(.link__big__img) {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 18px;
    width: 100%;
    margin: 0;
}

.st-flow--secondary ~ #wrapper .wrap_gallery:has(> .photo_list .link__big__img) {
    box-sizing: border-box;
    width: min(calc(100% - 2 * var(--flow-gutter)), 1304px);
    margin-inline: auto;
}

.st-flow--secondary ~ #wrapper .wrap_gallery > .photo_list:has(.link__big__img) > .photo_item {
    width: auto;
    height: auto;
    min-width: 0;
    margin: 0;
}

@media (max-width: 700px) {
    .st-flow--secondary ~ #wrapper .wrap_gallery > .photo_list:has(.link__big__img) {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 12px;
    }
}

.st-flow-header ~ #wrapper .tov-min-carousel .carousel-cell {
    box-sizing: border-box;
    width: 60px;
    height: auto;
    aspect-ratio: var(--st-preview-ratio);
    border-radius: 5px;
    background-color: var(--st-preview-background);
    background-size: contain !important;
}

:is(.st-flow--portfolio, .st-flow--secondary) ~ #wrapper .wrap_gallery > .photo_list:has(.link__big__img) > div:not(.photo_item) {
    display: none;
}
