.youtube-footer-gallery {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 2px;
    width: 100%;
}

.youtube-footer-card {
    position: relative;
    aspect-ratio: 3 / 4;
    overflow: hidden;
    background-color: var(--color-black);
}

.youtube-footer-trigger {
    position: absolute;
    inset: 0;

    display: block;
    width: 100%;
    height: 100%;

    overflow: hidden;
    color: inherit;
    text-decoration: none;
    background-color: var(--color-black);
}

.youtube-footer-trigger::before {
    content: "";
    position: absolute;
    z-index: 1;
    inset: 0;

    pointer-events: none;

    background:
        linear-gradient(180deg,
            rgba(0, 0, 0, 0.12) 0%,
            transparent 35%,
            rgba(0, 0, 0, 0.16) 100%);

    transition: background-color 0.3s ease;
}

.youtube-footer-thumbnail {
    position: absolute;
    inset: 0;

    display: block;
    width: 100% !important;
    height: 100% !important;
    max-width: none !important;

    object-fit: cover !important;
    object-position: center !important;

    transform: scale(1.01);

    transition:
        transform 0.6s cubic-bezier(0.22, 1, 0.36, 1),
        filter 0.3s ease;
}

/* Icona play Font Awesome */
.youtube-footer-play {
    position: absolute;
    z-index: 2;
    top: 8px;
    right: 8px;

    display: flex;
    align-items: center;
    justify-content: center;

    width: 24px;
    height: 24px;

    border-radius: 50%;
    background-color: rgba(255, 255, 255, 0.92);
    box-shadow: 0 3px 12px rgba(0, 0, 0, 0.18);

    color: var(--color-primary);
    pointer-events: none;

    transition:
        transform 0.35s cubic-bezier(0.22, 1, 0.36, 1),
        background-color 0.3s ease,
        color 0.3s ease,
        box-shadow 0.3s ease;
}

.youtube-footer-play i {
    display: block;

    margin-left: 2px;

    color: currentColor;
    font-size: 10px;
    line-height: 1;

    transform: translateZ(0);
}

/* Hover */
.youtube-footer-trigger:hover .youtube-footer-thumbnail {
    transform: scale(1.06);
    filter: brightness(0.9);
}

.youtube-footer-trigger:hover .youtube-footer-play {
    transform: scale(1.12);

    color: var(--color-white);
    background-color: var(--color-white);

    box-shadow: 0 5px 16px rgba(0, 0, 0, 0.25);
}

/* Focus tastiera */
.youtube-footer-trigger:focus-visible {
    outline: 3px solid var(--color-primary);
    outline-offset: -3px;
}

/* Player YouTube */
.youtube-footer-card iframe {
    position: absolute;
    z-index: 4;
    inset: 0;

    display: block;
    width: 100%;
    height: 100%;

    border: 0;
    background-color: var(--color-black);
}

/* Tablet */
@media (max-width: 1024px) {
    .youtube-footer-gallery {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

/* ==================================================
   MOBILE: SLIDER ORIZZONTALE
   ================================================== */

@media (max-width: 1024px) {

    .youtube-footer-gallery {
        display: flex;
        grid-template-columns: none;

        width: 100%;
        gap: 12px;

        padding: 0 18vw 10px 16px;

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

        /*
         * Aggancio morbido delle card.
         */
        scroll-snap-type: x mandatory;
        scroll-padding-left: 16px;
        scroll-behavior: smooth;

        /*
         * Scorrimento fluido e inerziale su iPhone/iPad.
         */
        -webkit-overflow-scrolling: touch;
        overscroll-behavior-x: contain;
        touch-action: pan-x;

        /*
         * Nasconde la scrollbar su Firefox.
         */
        scrollbar-width: none;

        /*
         * Evita selezioni accidentali durante lo swipe.
         */
        user-select: none;
        -webkit-user-select: none;
    }

    /*
     * Nasconde la scrollbar su Chrome, Safari ed Edge.
     */
    .youtube-footer-gallery::-webkit-scrollbar {
        display: none;
    }

    .youtube-footer-card {
        /*
         * La card occupa circa l'82% dello schermo:
         * sulla destra rimane visibile una porzione
         * della card successiva.
         */
        flex: 0 0 82vw;
        width: 82vw;
        max-width: 340px;

        scroll-snap-align: start;
        scroll-snap-stop: always;
    }

    .youtube-footer-trigger {
        -webkit-tap-highlight-color: transparent;
    }

    /*
     * Su mobile non applichiamo l'effetto hover,
     * evitando zoom involontari dopo il tap.
     */
    .youtube-footer-trigger:hover .youtube-footer-thumbnail {
        transform: scale(1.01);
        filter: none;
    }

    .youtube-footer-trigger:hover .youtube-footer-play {
        transform: none;
    }
}


/* ==================================================
   MOBILE PICCOLO
   ================================================== */

@media (max-width: 480px) {

    .youtube-footer-gallery {
        gap: 10px;
        padding-left: 14px;
        padding-right: 16vw;
        scroll-padding-left: 14px;
    }

    .youtube-footer-card {
        flex-basis: 65vw;
        width: 84vw;
        max-width: none;
    }
}

/* Accessibilità */
@media (prefers-reduced-motion: reduce) {

    .youtube-footer-thumbnail,
    .youtube-footer-play {
        transition: none;
    }
}