/* ─────────────────────────────────────────────
   FEMA Filtro Materiali
   ───────────────────────────────────────────── */

/* Blocca lo scroll della pagina quando il pannello è aperto */
html.fema-panel-open,
body.fema-panel-open {
    overflow: hidden !important;
    touch-action: none !important;
}

/* ─── Wrapper principale ───────────────────── */

.fema-filtro-wrapper {
    display: inline-flex;
    flex-direction: column;
    align-items: flex-start;
    position: relative;
    z-index: 9999;
}

/* ─── Titolo pannello ───────────────────── */

.fema-filtro-title {
    font-family: "HAAS Grotesk", Sans-Serif !important;
    font-size: 1.3rem;
    font-weight: 400;
    line-height: 1.2;
    margin-top: 0 !important;
    margin-bottom: 24px !important;
    color: #111;
}

/* ─── Bottone toggle "+" ───────────────────── */

.fema-filtro-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;

    width: 46px !important;
    height: 46px !important;
    min-width: 46px !important;
    min-height: 46px !important;

    border-radius: 50%;
    background-color: #111;
    border: none;
    cursor: pointer;
    outline: none;

    font-family: "HAAS Grotesk", sans-serif;

    transition: background-color 0.3s ease;

    position: relative;
    z-index: 10002;

    padding: 0 !important;
    margin: 0 !important;

    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.fema-filtro-toggle:hover {
    background-color: #333;
}

.fema-filtro-toggle-icon {
    display: flex;
    align-items: center;
    justify-content: center;

    font-size: 2.5rem;
    font-weight: 100;
    color: #fff;
    line-height: 1;

    transform-origin: center center;
    user-select: none;
    pointer-events: none;
}

/* ─── Pannello filtri desktop ────────────────────────── */

.fema-filtro-panel {
    font-family: "HAAS Grotesk", Sans-Serif !important;
    font-size: 0.9rem;
    font-weight: 400;

    display: none;
    opacity: 0;
    height: 0;

    position: absolute;
    top: calc(100% + 12px);
    right: 0;
    left: auto;

    width: 620px !important;
    min-width: 620px !important;
    max-width: 620px !important;

    max-height: 70vh;

    overflow-y: auto;
    overflow-x: hidden;

    z-index: 10001;
    background: #fff;

    padding: 24px;
    border-radius: 24px;
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.10);

    box-sizing: border-box;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

.fema-filtro-panel.is-open {
    display: block !important;
    opacity: 1 !important;
    visibility: visible !important;
    height: auto !important;
}

/* ─── Wrapper interno chip ─────────────────────────── */

.fema-filtro-inner {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 10px;

    width: 100%;
    max-width: 100%;

    padding: 4px 0;
    box-sizing: border-box;
}

/* ─── Chip materiale ─────────────────────────── */

.fema-filtro-chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;

    flex: 0 0 auto;

    width: auto;
    min-width: max-content;
    max-width: 100%;

    padding: 6px 6px 6px 16px;

    border-radius: 999px;
    border: 1.5px solid #111;

    background: transparent;
    color: #111;

    font-family: inherit;
    font-size: 0.875rem;
    font-weight: 400;
    line-height: 1.1;

    cursor: pointer;
    white-space: nowrap;

    transition:
        background-color 0.25s ease,
        color 0.25s ease,
        border-color 0.25s ease;

    outline: none;
    box-sizing: border-box;

    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.fema-filtro-chip-label {
    flex-shrink: 0;
    white-space: nowrap;
}

/* ─── Cerchio icona ─────────────────────────── */

.fema-filtro-chip-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;

    width: 28px;
    height: 28px;
    min-width: 28px;
    min-height: 28px;

    border-radius: 50%;
    background-color: #111;

    flex-shrink: 0;

    transition: background-color 0.25s ease;
}

.fema-filtro-chip-icon svg {
    transform: scale(1.8) !important;
}

.fema-filtro-chip-icon svg path {
    fill: #fff;
    transition: fill 0.25s ease;
}

/* ─── Stato hover ─────────────────────────── */

.fema-filtro-chip:hover {
    background-color: #111;
    color: #fff;
    border-color: #111;
}

.fema-filtro-chip:hover .fema-filtro-chip-icon {
    background-color: #fff;
}

.fema-filtro-chip:hover .fema-filtro-chip-icon svg path {
    fill: #111;
}

/* ─── Stato attivo ─────────────────────────── */

.fema-filtro-chip.active {
    background-color: #D60816;
    color: #fff;
    border-color: #D60816;
}

.fema-filtro-chip.active .fema-filtro-chip-icon {
    background-color: #fff;
}

.fema-filtro-chip.active .fema-filtro-chip-icon svg path {
    fill: #111;
}

/* ─── Chip "Tutti" ─────────────────────────── */

.fema-filtro-chip--all {
    border-color: #111;
}

/* ─────────────────────────────────────────────
   Tablet
   ───────────────────────────────────────────── */

@media (min-width: 768px) and (max-width: 1199px) {
    .fema-filtro-panel {
        width: 540px !important;
        min-width: 540px !important;
        max-width: 540px !important;
    }
}

/* ─────────────────────────────────────────────
   Mobile
   ───────────────────────────────────────────── */

@media (max-width: 767px) {

    html.fema-panel-open,
    body.fema-panel-open {
        overflow: hidden !important;
        height: 100% !important;
        touch-action: none !important;
    }

    .fema-filtro-wrapper {
        display: inline-flex;
        flex-direction: column;
        align-items: flex-start;

        position: static !important;
        z-index: 1000000 !important;
    }

    .fema-filtro-toggle {
        width: 48px !important;
        height: 48px !important;
        min-width: 48px !important;
        min-height: 48px !important;

        position: relative !important;
        z-index: 1000002 !important;
    }

    .fema-filtro-toggle-icon {
        font-size: 2.25rem !important;
    }

    /* Pannello come modal/drawer mobile */
    .fema-filtro-panel {
        position: fixed !important;

        top: 170px !important;
        left: 18px !important;
        right: 18px !important;
        bottom: 24px !important;

        width: auto !important;
        min-width: 0 !important;
        max-width: calc(100vw - 36px) !important;

        height: auto !important;
        max-height: none !important;

        overflow-y: auto !important;
        overflow-x: hidden !important;

        padding: 22px 18px !important;
        border-radius: 24px !important;

        background: #ffffff !important;
        box-sizing: border-box !important;

        z-index: 1000001 !important;

        box-shadow: 0 8px 40px rgba(0, 0, 0, 0.14) !important;

        -webkit-overflow-scrolling: touch !important;
        overscroll-behavior: contain !important;
    }

    .fema-filtro-panel.is-open {
        display: block !important;
        opacity: 1 !important;
        visibility: visible !important;
        height: auto !important;
    }

    .fema-filtro-title {
        font-size: 1.22rem !important;
        line-height: 1.15 !important;
        margin-top: 0 !important;
        margin-bottom: 20px !important;
    }

    .fema-filtro-inner {
        display: flex !important;
        flex-wrap: wrap !important;
        align-items: flex-start !important;
        gap: 9px !important;

        width: 100% !important;
        max-width: 100% !important;

        box-sizing: border-box !important;
        padding: 0 !important;
    }

    .fema-filtro-chip {
        display: inline-flex !important;
        align-items: center !important;
        justify-content: space-between !important;
        gap: 8px !important;

        width: auto !important;
        min-width: 0 !important;
        max-width: 100% !important;

        flex: 0 1 auto !important;

        white-space: normal !important;
        overflow: hidden !important;

        padding: 7px 6px 7px 14px !important;
        border-radius: 999px !important;

        box-sizing: border-box !important;
        line-height: 1.08 !important;

        font-size: 0.86rem !important;
    }

    .fema-filtro-chip-label {
        display: block !important;

        min-width: 0 !important;
        max-width: calc(100vw - 115px) !important;

        white-space: normal !important;
        overflow-wrap: anywhere !important;
        word-break: normal !important;

        line-height: 1.08 !important;
    }

    .fema-filtro-chip-icon {
        flex: 0 0 30px !important;

        width: 30px !important;
        height: 30px !important;
        min-width: 30px !important;
        min-height: 30px !important;
    }

    .fema-filtro-chip-icon svg {
        transform: scale(1.55) !important;
    }
}

/* ─────────────────────────────────────────────
   Mobile piccolo
   ───────────────────────────────────────────── */

@media (max-width: 390px) {

    .fema-filtro-panel {
        top: 160px !important;
        left: 14px !important;
        right: 14px !important;
        bottom: 20px !important;

        max-width: calc(100vw - 28px) !important;

        padding: 20px 16px !important;
    }

    .fema-filtro-title {
        font-size: 1.15rem !important;
        margin-bottom: 18px !important;
    }

    .fema-filtro-inner {
        gap: 8px !important;
    }

    .fema-filtro-chip {
        font-size: 0.8rem !important;
        padding: 6px 5px 6px 12px !important;
        gap: 7px !important;
    }

    .fema-filtro-chip-label {
        max-width: calc(100vw - 105px) !important;
    }

    .fema-filtro-chip-icon {
        flex: 0 0 28px !important;

        width: 28px !important;
        height: 28px !important;
        min-width: 28px !important;
        min-height: 28px !important;
    }

    .fema-filtro-chip-icon svg {
        transform: scale(1.45) !important;
    }
}