/*
 * Home editorial natural-height media follow-up.
 *
 * The Home "Dentro il design italiano" Loop Grid now renders LIFE content, but
 * intentionally keeps the existing .wwts-home-idem-grid presentation contract.
 * This small late-loaded layer changes only card sizing/media fit: Loop items no
 * longer stretch to the tallest card in a grid row, while featured editorial
 * media keeps its intrinsic aspect ratio so poster/artwork images are shown in
 * full instead of being cropped into the legacy 16:10 box.
 *
 * Elementor continues to own grid columns/gaps/placement. Archive cards and all
 * other WWTS card contexts keep the shared height:100% / cover behavior.
 */

/* CSS Grid stretches items to the row height by default. Opt this Home editorial
 * composition out without changing the shared card primitive used by archives. */
.wwts-home-idem-grid .elementor-loop-container > .e-loop-item {
    align-self: start;
    height: auto;
}

.wwts-home-idem-grid .elementor-loop-container > .e-loop-item > .elementor,
.wwts-home-idem-grid .elementor-loop-container > .e-loop-item .wwts-home-inside-card {
    height: auto !important;
    align-self: start;
}

/* Featured result: let the real image ratio establish card height. The body and
 * readability overlay remain absolute, so the accepted large-card typography
 * and CTA presentation stay unchanged. */
.wwts-home-idem-grid .elementor-loop-container > .e-loop-item:first-of-type .wwts-home-inside-card {
    aspect-ratio: auto !important;
}

.wwts-home-idem-grid .elementor-loop-container > .e-loop-item:first-of-type .wwts-home-inside-card .wwts-card__media {
    position: relative;
    inset: auto;
    width: 100% !important;
    height: auto !important;
    min-height: 0 !important;
    aspect-ratio: auto !important;
}

/* Elementor Atomic Image is normally made absolute by the legacy fill rule.
 * Return only the featured image link to normal flow so its intrinsic image
 * dimensions can create the card height. */
.wwts-home-idem-grid .elementor-loop-container > .e-loop-item:first-of-type .wwts-home-inside-card .wwts-card__media > a.e-image-link-base,
.wwts-home-idem-grid .elementor-loop-container > .e-loop-item:first-of-type .wwts-home-inside-card .wwts-card__media > a.e-image-link {
    position: relative;
    inset: auto;
    width: 100% !important;
    height: auto !important;
    overflow: hidden;
}

.wwts-home-idem-grid .elementor-loop-container > .e-loop-item:first-of-type .wwts-home-inside-card .wwts-card__image,
.wwts-home-idem-grid .elementor-loop-container > .e-loop-item:first-of-type .wwts-home-inside-card .wwts-card__image > .elementor-widget-container,
.wwts-home-idem-grid .elementor-loop-container > .e-loop-item:first-of-type .wwts-home-inside-card .wwts-card__image a {
    height: auto !important;
}

.wwts-home-idem-grid .elementor-loop-container > .e-loop-item:first-of-type .wwts-home-inside-card .wwts-card__media > a.e-image-link-base img,
.wwts-home-idem-grid .elementor-loop-container > .e-loop-item:first-of-type .wwts-home-inside-card .wwts-card__media > a.e-image-link img,
.wwts-home-idem-grid .elementor-loop-container > .e-loop-item:first-of-type .wwts-home-inside-card .wwts-card__image img {
    display: block;
    width: 100% !important;
    height: auto !important;
    max-width: 100% !important;
    object-fit: contain !important;
    object-position: center center;
    transform: none !important;
}

/* The sparse two-result layout promotes result #2 to the same large overlay
 * treatment. Keep it on the same natural-media contract when that case occurs. */
.wwts-home-idem-grid .elementor-loop-container > .e-loop-item:nth-of-type(2):last-of-type .wwts-home-inside-card {
    aspect-ratio: auto !important;
}

.wwts-home-idem-grid .elementor-loop-container > .e-loop-item:nth-of-type(2):last-of-type .wwts-home-inside-card .wwts-card__media {
    position: relative;
    inset: auto;
    width: 100% !important;
    height: auto !important;
    min-height: 0 !important;
    aspect-ratio: auto !important;
}

.wwts-home-idem-grid .elementor-loop-container > .e-loop-item:nth-of-type(2):last-of-type .wwts-home-inside-card .wwts-card__media > a.e-image-link-base,
.wwts-home-idem-grid .elementor-loop-container > .e-loop-item:nth-of-type(2):last-of-type .wwts-home-inside-card .wwts-card__media > a.e-image-link {
    position: relative;
    inset: auto;
    width: 100% !important;
    height: auto !important;
}

.wwts-home-idem-grid .elementor-loop-container > .e-loop-item:nth-of-type(2):last-of-type .wwts-home-inside-card .wwts-card__image,
.wwts-home-idem-grid .elementor-loop-container > .e-loop-item:nth-of-type(2):last-of-type .wwts-home-inside-card .wwts-card__image > .elementor-widget-container,
.wwts-home-idem-grid .elementor-loop-container > .e-loop-item:nth-of-type(2):last-of-type .wwts-home-inside-card .wwts-card__image a {
    height: auto !important;
}

.wwts-home-idem-grid .elementor-loop-container > .e-loop-item:nth-of-type(2):last-of-type .wwts-home-inside-card .wwts-card__media > a.e-image-link-base img,
.wwts-home-idem-grid .elementor-loop-container > .e-loop-item:nth-of-type(2):last-of-type .wwts-home-inside-card .wwts-card__media > a.e-image-link img,
.wwts-home-idem-grid .elementor-loop-container > .e-loop-item:nth-of-type(2):last-of-type .wwts-home-inside-card .wwts-card__image img {
    display: block;
    width: 100% !important;
    height: auto !important;
    max-width: 100% !important;
    object-fit: contain !important;
    object-position: center center;
    transform: none !important;
}
