/*
 * 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%;
}

.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;
}

/* Let top/right/bottom/left define the exact media box instead of combining
 * inset with height:100%. This avoids a small uncovered strip when Elementor's
 * generated sizing/margins differ by a few pixels. */
.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: auto !important;
    height: auto !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;
}

.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 {
    font-size: 36px !important;
    font-weight: 500 !important;
    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;
    color: #fff !important;
}

/* 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;
    }

    .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 {
        font-size: 32px !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-card.wwts-home-inside-card .wwts-card__title .elementor-heading-title {
        font-size: 28px !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;
    }
}