/*
 * Home / Inside Italian Design IDEM editorial feed.
 *
 * The Loop Grid owns normal columns/gaps through Elementor. This scoped layer
 * only gives the first result the reference-style featured treatment and lets
 * it span two columns on tablet/desktop. The query guarantees that result #1
 * is the resolved featured event.
 */

/* Keep membership/query execution fully Elementor/WPML-owned. On the public
 * frontend hide the whole editorial section only when Elementor has actually
 * rendered its verified empty-result marker. Do not hide it inside Elementor
 * editor/preview so an empty feed remains editable. */
body:not(.elementor-editor-active):not(.elementor-editor-preview) #idem:has(.wwts-home-idem-grid .e-loop-nothing-found-message) {
    display: none !important;
}

@media (min-width: 768px) {
    .wwts-home-idem-grid .elementor-loop-container > .e-loop-item:first-of-type {
        grid-column: span 2;
    }
}

/* Elementor's generated grid uses fractional tracks, but Grid items keep their
 * intrinsic min-content width unless we explicitly allow them to shrink. One
 * source image/title could therefore force its track wide and collapse the
 * neighbouring card on tablet. Keep the grid geometry Elementor-owned while
 * making every saved Loop Item genuinely shrinkable inside its assigned track. */
.wwts-home-idem-grid .elementor-loop-container > .e-loop-item,
.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 {
    width: 100%;
    min-width: 0;
    max-width: 100%;
}

/* Elementor's Loop Item grid wrappers have align-self:start, so even when the
 * row is as tall as its text-heavy small cards, the image-backed featured card
 * stays at its own intrinsic aspect-ratio height. Stretch the actual Loop Item
 * and let its direct Atomic card child flex to fill the assigned row. This
 * changes only card-height alignment, not Elementor's columns, gaps, order,
 * media crop, content positioning or responsive typography. */
.wwts-home-idem-grid .elementor-loop-container > .e-loop-item {
    align-self: stretch !important;
    display: flex;
    flex-direction: column;
}

.wwts-home-idem-grid .elementor-loop-container > .e-loop-item > .wwts-home-inside-card {
    flex: 1 1 auto;
    height: auto !important;
    min-height: 0;
}

/* On one-column tablet/mobile grids, each result occupies its own row: equal
 * implicit row tracks prevent the featured card from being much shorter than
 * the regular cards. At desktop the rows remain content-sized independently. */
@media (max-width: 1024px) {
    .wwts-home-idem-grid .elementor-loop-container {
        grid-auto-rows: 1fr;
    }
}

.wwts-home-idem-grid .elementor-loop-container > .e-loop-item .wwts-card__media,
.wwts-home-idem-grid .elementor-loop-container > .e-loop-item .wwts-card__image,
.wwts-home-idem-grid .elementor-loop-container > .e-loop-item .wwts-card__image > .elementor-widget-container,
.wwts-home-idem-grid .elementor-loop-container > .e-loop-item .wwts-card__image a {
    min-width: 0;
    max-width: 100%;
}

/* Elementor Atomic Image in Loop Item #1145 renders the clickable image as
 * .e-image-link-base directly under .wwts-card__media. Older markup used
 * .e-image-link / .wwts-card__image, so keep both Atomic selector variants plus
 * the classic wrapper rules below. The anchor itself must fill the 4:3 media
 * box; object-fit on the img alone cannot do that if the link stays auto-height. */
.wwts-home-idem-grid .wwts-home-inside-card .wwts-card__media > a.e-image-link-base,
.wwts-home-idem-grid .wwts-home-inside-card .wwts-card__media > a.e-image-link {
    position: absolute;
    inset: 0;
    z-index: 0;
    display: block;
    box-sizing: border-box;
    width: 100% !important;
    height: 100% !important;
    min-width: 0;
    min-height: 0;
    margin: 0 !important;
    overflow: hidden;
    border-radius: inherit;
}

.wwts-home-idem-grid .wwts-home-inside-card .wwts-card__media > a.e-image-link-base img,
.wwts-home-idem-grid .wwts-home-inside-card .wwts-card__media > a.e-image-link img {
    display: block;
    width: 100% !important;
    height: 100% !important;
    min-width: 0;
    max-width: none !important;
    object-fit: cover !important;
    object-position: center center;
    border-radius: inherit;
    transition: transform 0.25s ease;
}

.wwts-home-idem-grid .wwts-home-inside-card:hover .wwts-card__media > a.e-image-link-base img,
.wwts-home-idem-grid .wwts-home-inside-card:hover .wwts-card__media > a.e-image-link img {
    transform: scale(1.022);
}

/* On the two-column tablet layout the featured item is a complete row. Using
 * explicit grid edges instead of a relative span avoids auto-placement edge
 * cases while keeping the small cards in Elementor's normal two-column flow. */
@media (min-width: 768px) and (max-width: 1024px) {
    .wwts-home-idem-grid .elementor-loop-container > .e-loop-item:first-of-type {
        grid-column: 1 / -1;
    }
}

/* The editorial badge is the event_type label. The generic card meta/date is
 * intentionally omitted from this Home composition, matching the reference.
 * On the featured card the old meta sat at the top of the absolute body and
 * visually overlapped the badge, which made the date look like part of it. */
.wwts-home-idem-grid .wwts-home-inside-card .wwts-card__meta,
.wwts-home-idem-grid .wwts-home-inside-card .wwts-card__date {
    display: none !important;
}

/* Small editorial cards use one fixed media geometry regardless of the source
 * image proportions. Elementor/Image widget wrappers are explicitly stretched
 * as well, so every thumbnail occupies the same 4:3 box and the image itself
 * crops with object-fit instead of changing the card height. */
.wwts-home-idem-grid .elementor-loop-container > .e-loop-item:not(:first-of-type) .wwts-home-inside-card .wwts-card__media {
    flex: 0 0 auto;
    width: 100%;
    height: auto !important;
    min-height: 0 !important;
    aspect-ratio: 4 / 3;
    overflow: hidden;
}

.wwts-home-idem-grid .elementor-loop-container > .e-loop-item:not(:first-of-type) .wwts-home-inside-card .wwts-card__image,
.wwts-home-idem-grid .elementor-loop-container > .e-loop-item:not(:first-of-type) .wwts-home-inside-card .wwts-card__image > .elementor-widget-container,
.wwts-home-idem-grid .elementor-loop-container > .e-loop-item:not(:first-of-type) .wwts-home-inside-card .wwts-card__image a {
    display: block;
    width: 100% !important;
    height: 100% !important;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
}

.wwts-home-idem-grid .elementor-loop-container > .e-loop-item:not(:first-of-type) .wwts-home-inside-card .wwts-card__image img {
    display: block;
    width: 100% !important;
    height: 100% !important;
    min-width: 0;
    max-width: 100% !important;
    object-fit: cover !important;
    object-position: center center;
}

/* Small editorial cards use a light, compact lift and do not repeat the
 * archive-style CTA. The whole card remains clickable through the saved Loop
 * Item links, while the featured card keeps its explicit CTA. */
.wwts-home-idem-grid .elementor-loop-container > .e-loop-item:not(:first-of-type) .wwts-home-inside-card {
    box-shadow: 0 8px 22px rgba(72, 57, 43, 0.09), 0 2px 6px rgba(72, 57, 43, 0.04);
}

.wwts-home-idem-grid .elementor-loop-container > .e-loop-item:not(:first-of-type) .wwts-home-inside-card:hover,
.wwts-home-idem-grid .elementor-loop-container > .e-loop-item:not(:first-of-type) .wwts-home-inside-card:focus-within {
    box-shadow: 0 12px 28px rgba(72, 57, 43, 0.12), 0 3px 8px rgba(72, 57, 43, 0.05);
}

.wwts-home-idem-grid .elementor-loop-container > .e-loop-item:not(:first-of-type) .wwts-home-inside-card .wwts-card__footer {
    display: none !important;
}

/* Featured card. */
.wwts-home-idem-grid .elementor-loop-container > .e-loop-item:first-of-type .wwts-home-inside-card {
    aspect-ratio: 16 / 10;
    background: #1e1b17;
}

/* The featured card now stretches to its grid row rather than retaining its
 * aspect-ratio height. Give the absolutely positioned media an explicit full
 * used height as well: otherwise its image can stop at the old intrinsic height
 * and expose the dark card background along the bottom edge. */
.wwts-home-idem-grid .elementor-loop-container > .e-loop-item:first-of-type .wwts-home-inside-card .wwts-card__media {
    position: absolute;
    inset: 0;
    z-index: 0;
    width: 100% !important;
    height: 100% !important;
    min-height: 0;
    margin: 0 !important;
    aspect-ratio: auto;
    border-radius: var(--wwts-card-radius);
}

.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 {
    width: 100% !important;
    height: 100% !important;
}

.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: 100% !important;
    object-fit: cover !important;
    object-position: center center;
    border-radius: var(--wwts-card-radius);
}

/* Paint the dark readability layer on the featured card itself rather than on
 * the content container. It therefore always reaches the physical bottom edge
 * of the card, including during the image hover scale animation. */
.wwts-home-idem-grid .elementor-loop-container > .e-loop-item:first-of-type .wwts-home-inside-card::after {
    content: '';
    position: absolute;
    inset: 0;
    z-index: 1;
    border-radius: inherit;
    background: linear-gradient(
        180deg,
        rgba(30, 27, 23, 0) 28%,
        rgba(30, 27, 23, 0.12) 48%,
        rgba(30, 27, 23, 0.88) 100%
    );
    pointer-events: none;
}

/* Use a two-column grid in the lower overlay: title spans the card, then the
 * description and CTA share one row, with the CTA aligned to the right. Grid
 * align-content is marked important because Elementor may emit a local flex
 * alignment rule on the saved Body Container. */
.wwts-home-idem-grid .elementor-loop-container > .e-loop-item:first-of-type .wwts-home-inside-card .wwts-card__body {
    position: absolute;
    inset: 0;
    z-index: 2;
    display: grid !important;
    box-sizing: border-box;
    width: auto !important;
    height: auto !important;
    min-height: 0;
    margin: 0 !important;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-rows: auto auto;
    align-content: end !important;
    align-items: end;
    column-gap: 24px;
    row-gap: 10px;
    padding: 24px 24px 22px !important;
    border-radius: inherit;
    background: transparent !important;
    color: #fff;
}

.wwts-home-idem-grid .elementor-loop-container > .e-loop-item:first-of-type .wwts-home-inside-card .wwts-card__title {
    grid-column: 1 / -1;
    grid-row: 1;
    min-width: 0;
    align-self: end;
}

/* Font size of the featured title is editable in Elementor, including mobile. */
.wwts-home-idem-grid .elementor-loop-container > .e-loop-item:first-of-type .wwts-card.wwts-home-inside-card .wwts-card__title .elementor-heading-title {
    line-height: 1.05 !important;
    color: #fff !important;
}

.wwts-home-idem-grid .elementor-loop-container > .e-loop-item:first-of-type .wwts-home-inside-card .wwts-card__description {
    grid-column: 1;
    grid-row: 2;
    min-width: 0;
    align-self: end;
    margin-top: 0 !important;
    color: rgba(255, 255, 255, 0.92);
}

.wwts-home-idem-grid .elementor-loop-container > .e-loop-item:first-of-type .wwts-home-inside-card .wwts-card__footer {
    grid-column: 2;
    grid-row: 2;
    width: auto !important;
    align-self: end;
    justify-self: end;
    margin: 0 !important;
    padding: 0 !important;
}

.wwts-home-idem-grid .elementor-loop-container > .e-loop-item:first-of-type .wwts-home-inside-card .wwts-card__footer::before {
    display: none;
}

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

.wwts-home-idem-grid .elementor-loop-container > .e-loop-item:first-of-type .wwts-home-inside-card .wwts-card__cta .elementor-button {
    justify-content: flex-end;
    gap: 0;
    white-space: nowrap;
}

/* The reference uses a compact text action on the featured card, not the
 * archive-card arrow treatment. */
.wwts-home-idem-grid .elementor-loop-container > .e-loop-item:first-of-type .wwts-home-inside-card .wwts-card__cta .elementor-button::after {
    display: none;
}

@media (max-width: 1024px) {
    .wwts-home-idem-grid .elementor-loop-container > .e-loop-item:first-of-type .wwts-home-inside-card .wwts-card__body {
        column-gap: 18px;
        padding: 20px !important;
    }


}

@media (max-width: 767px) {
    /* Elementor 4 sets --flex-wrap: var(--flex-wrap-mobile) on every mobile
     * e-con.e-flex. On the anchored IDEM root this produces the horizontal
     * displacement visible in the live page. Keep the fix scoped to #idem so
     * other Elementor containers retain their own responsive wrapping. */
    #idem.wwts-section.e-con.e-flex {
        --flex-wrap: nowrap !important;
        --flex-wrap-mobile: nowrap !important;
    }

    .wwts-home-idem-grid .elementor-loop-container > .e-loop-item:first-of-type .wwts-home-inside-card {
        aspect-ratio: 4 / 3;
    }

    .wwts-home-idem-grid .elementor-loop-container > .e-loop-item:first-of-type .wwts-home-inside-card .wwts-card__body {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto auto;
        row-gap: 9px;
        padding: 18px !important;
    }



    .wwts-home-idem-grid .elementor-loop-container > .e-loop-item:first-of-type .wwts-home-inside-card .wwts-card__description {
        grid-column: 1;
        grid-row: 2;
    }

    .wwts-home-idem-grid .elementor-loop-container > .e-loop-item:first-of-type .wwts-home-inside-card .wwts-card__footer {
        grid-column: 1;
        grid-row: 3;
        justify-self: start;
    }
}
/* Elementor Atomic generated styles can force its image link/media back to
 * position:relative and the image to object-fit:contain. These specifically
 * scoped rules ensure the promoted featured image covers the already stretched
 * editorial card, including the mobile single-column grid. The #idem/body
 * scope matches both production Home compositions. */
:is(#idem, body) .wwts-home-idem-grid .elementor-loop-container > .e-loop-item:first-of-type .wwts-home-inside-card .wwts-card__media {
    position: absolute !important;
    inset: 0 !important;
    width: 100% !important;
    height: 100% !important;
    aspect-ratio: auto !important;
}

:is(#idem, body) .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 {
    position: absolute !important;
    inset: 0 !important;
    width: 100% !important;
    height: 100% !important;
}

:is(#idem, body) .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 {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    object-position: center center !important;
}
