/* ==========================================================================
   Animazione integrazione XMAG <-> Farfetch (omnichannel.html)
   Logica in js/farfetch-anim.js
   ========================================================================== */

.ffa {
    --ffa-orange: #faa752;
    --ffa-orange-2: #ef7f36;
    --ffa-cyan: #21c6db;
    --ffa-ink: #f4f5f8;
    --ffa-muted: rgba(244, 245, 248, .62);
    --ffa-line: rgba(255, 255, 255, .1);
    --ffa-dur: 1.1s;
    position: relative;
    overflow: hidden;
    border-radius: 20px;
    padding: 48px 44px 30px;
    margin-bottom: 1.75rem;
    color: var(--ffa-ink);
    text-align: left;
    background:
        radial-gradient(circle at 12% 18%, rgba(33, 198, 219, .18), transparent 42%),
        radial-gradient(circle at 88% 82%, rgba(250, 167, 82, .2), transparent 45%),
        linear-gradient(140deg, #171b24 0%, #1d2230 55%, #151820 100%);
    box-shadow: 0 24px 50px -24px rgba(16, 22, 40, .7);
}

    /* griglia di sfondo */
    .ffa::before {
        content: "";
        position: absolute;
        inset: 0;
        background-image:
            linear-gradient(var(--ffa-line) 1px, transparent 1px),
            linear-gradient(90deg, var(--ffa-line) 1px, transparent 1px);
        background-size: 44px 44px;
        mask-image: radial-gradient(ellipse at center, #000 30%, transparent 75%);
        -webkit-mask-image: radial-gradient(ellipse at center, #000 30%, transparent 75%);
        opacity: .5;
        pointer-events: none;
    }

.ffa-stage {
    position: relative;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(160px, .9fr) minmax(0, 1fr);
    align-items: center;
    gap: 0;
}

/* ---------- Nodi ---------- */
.ffa-node {
    position: relative;
    z-index: 2;
    background: rgba(255, 255, 255, .06);
    border: 1px solid rgba(255, 255, 255, .12);
    border-radius: 18px;
    padding: 22px;
    box-shadow: 0 18px 40px -22px rgba(0, 0, 0, .8);
    transition: box-shadow .5s ease, border-color .5s ease;
}

    .ffa-node.is-active {
        border-color: rgba(250, 167, 82, .55);
        box-shadow: 0 0 0 4px rgba(250, 167, 82, .12), 0 18px 40px -22px rgba(0, 0, 0, .8);
    }

    .ffa-node--ff.is-active {
        border-color: rgba(33, 198, 219, .55);
        box-shadow: 0 0 0 4px rgba(33, 198, 219, .12), 0 18px 40px -22px rgba(0, 0, 0, .8);
    }

.ffa-node-head {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 18px;
}

    .ffa-node-head strong {
        display: block;
        font-size: 18px;
        font-weight: 600;
        letter-spacing: .02em;
        color: #fff;
        line-height: 1.2;
    }

    .ffa-node-head small {
        display: block;
        font-size: 13px;
        color: var(--ffa-muted);
    }

.ffa-ff-word {
    letter-spacing: .22em !important;
}

.ffa-logo {
    flex: 0 0 44px;
    height: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    font-weight: 700;
    color: #fff;
}

.ffa-logo--xmag {
    background: linear-gradient(135deg, var(--ffa-cyan), var(--ffa-orange-2));
}

.ffa-logo--ff {
    background: #fff;
    color: #151820;
}

.ffa-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px;
    border-radius: 12px;
    background: rgba(255, 255, 255, .05);
    margin-bottom: 14px;
    transition: background .5s ease, transform .5s ease;
}

    .ffa-item.is-live {
        background: rgba(33, 198, 219, .14);
    }

.ffa-thumb {
    flex: 0 0 40px;
    height: 48px;
    border-radius: 8px;
    background:
        linear-gradient(180deg, transparent 62%, rgba(0, 0, 0, .18) 62%),
        linear-gradient(135deg, #c98b5a, #8a5634);
    position: relative;
}

    .ffa-thumb::after {
        content: "";
        position: absolute;
        left: 50%;
        top: 6px;
        width: 2px;
        height: 36px;
        margin-left: -1px;
        background: rgba(255, 255, 255, .35);
    }

.ffa-item-txt {
    min-width: 0;
}

    .ffa-item-txt b {
        display: block;
        font-size: 14px;
        font-weight: 500;
        color: #fff;
    }

    .ffa-item-txt small {
        display: block;
        font-size: 12px;
        color: var(--ffa-muted);
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

.ffa-item.is-live .ffa-item-txt small {
    color: var(--ffa-cyan);
}

.ffa-stats {
    list-style: none;
    margin: 0;
    padding: 0;
}

    .ffa-stats li {
        display: flex;
        justify-content: space-between;
        align-items: center;
        font-size: 14px;
        color: var(--ffa-muted);
        padding: 7px 0;
        border-top: 1px solid rgba(255, 255, 255, .07);
    }

    .ffa-stats b {
        font-weight: 600;
        color: #fff;
        font-variant-numeric: tabular-nums;
        display: inline-block;
    }

        .ffa-stats b.bump {
            animation: ffaBump .6s ease;
        }

@keyframes ffaBump {
    0% { transform: scale(1); color: #fff; }
    40% { transform: scale(1.35); color: var(--ffa-orange); }
    100% { transform: scale(1); color: #fff; }
}

/* ---------- Collegamento ---------- */
.ffa-link {
    position: relative;
    align-self: stretch;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 120px;
}

.ffa-track {
    position: absolute;
    left: -2px;
    right: -2px;
    top: 50%;
    height: 4px;
    margin-top: -2px;
    border-radius: 4px;
    background: rgba(255, 255, 255, .1);
}

/* flusso continuo: trattini che scorrono nei due sensi.
   Si anima solo transform (niente ridisegno della pagina a ogni frame) */
.ffa-flow {
    position: absolute;
    left: 0;
    right: 0;
    height: 2px;
    overflow: hidden;
    opacity: .7;
}

    .ffa-flow::before {
        content: "";
        position: absolute;
        top: 0;
        bottom: 0;
        left: -18px;
        right: -18px;
        background-size: 18px 2px;
        background-repeat: repeat-x;
    }

.ffa-flow--out { top: -6px; }
.ffa-flow--in { bottom: -6px; }

    .ffa-flow--out::before {
        background-image: linear-gradient(90deg, var(--ffa-orange) 50%, transparent 50%);
        animation: ffaFlowOut 1s linear infinite;
    }

    .ffa-flow--in::before {
        background-image: linear-gradient(90deg, var(--ffa-cyan) 50%, transparent 50%);
        animation: ffaFlowIn 1s linear infinite;
    }

@keyframes ffaFlowOut { from { transform: translateX(0); } to { transform: translateX(18px); } }
@keyframes ffaFlowIn { from { transform: translateX(18px); } to { transform: translateX(0); } }

/* il pacchetto viaggia su un "binario" largo quanto la linea:
   spostare il binario del 100% = percorrere tutta la linea, solo con transform */
.ffa-rail {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

    .ffa-rail.go-out { animation: ffaRailOut var(--ffa-dur) cubic-bezier(.6, 0, .3, 1) forwards; }
    .ffa-rail.go-in { animation: ffaRailIn var(--ffa-dur) cubic-bezier(.6, 0, .3, 1) forwards; }

@keyframes ffaRailOut { from { transform: translateX(0); } to { transform: translateX(100%); } }
@keyframes ffaRailIn { from { transform: translateX(100%); } to { transform: translateX(0); } }

.ffa-packet {
    position: absolute;
    top: 50%;
    left: 0;
    width: 18px;
    height: 18px;
    margin: -9px 0 0 -9px;
    border-radius: 50%;
    opacity: 0;
    background: var(--ffa-orange);
    box-shadow: 0 0 0 6px rgba(250, 167, 82, .25), 0 0 22px 4px rgba(250, 167, 82, .6);
}

    .ffa-packet.is-in {
        background: var(--ffa-cyan);
        box-shadow: 0 0 0 6px rgba(33, 198, 219, .25), 0 0 22px 4px rgba(33, 198, 219, .6);
    }

.ffa-rail.go-out .ffa-packet,
.ffa-rail.go-in .ffa-packet { animation: ffaPacket var(--ffa-dur) ease forwards; }

@keyframes ffaPacket {
    0% { opacity: 0; transform: scale(.4); }
    15% { opacity: 1; transform: scale(1); }
    85% { opacity: 1; transform: scale(1); }
    100% { opacity: 0; transform: scale(.4); }
}

.ffa-api {
    position: relative;
    z-index: 1;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    font-weight: 500;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: #fff;
    background: #1d2230;
    border: 1px solid rgba(255, 255, 255, .16);
    border-radius: 30px;
    padding: 7px 14px;
    white-space: nowrap;
}

.ffa-dot {
    position: relative;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #3ddc84;
}

    /* alone che pulsa: scala + opacità invece di box-shadow animata */
    .ffa-dot::after {
        content: "";
        position: absolute;
        inset: 0;
        border-radius: 50%;
        background: rgba(61, 220, 132, .6);
        animation: ffaPulse 1.8s ease-out infinite;
    }

@keyframes ffaPulse {
    from { transform: scale(1); opacity: 1; }
    to { transform: scale(3.5); opacity: 0; }
}

/* fuori schermo: tutte le animazioni continue in pausa */
.ffa.is-off *,
.ffa.is-off *::before,
.ffa.is-off *::after { animation-play-state: paused !important; }

.ffa-toast {
    position: absolute;
    left: 50%;
    top: calc(50% + 34px);
    z-index: 3;
    transform: translate(-50%, 8px);
    opacity: 0;
    font-size: 13px;
    color: #151820;
    background: #fff;
    border-radius: 10px;
    padding: 8px 12px;
    white-space: nowrap;
    box-shadow: 0 12px 24px -10px rgba(0, 0, 0, .6);
    transition: opacity .35s ease, transform .35s ease;
}

    .ffa-toast.is-on {
        opacity: 1;
        transform: translate(-50%, 0);
    }

    .ffa-toast::before {
        content: "";
        display: inline-block;
        width: 8px;
        height: 8px;
        border-radius: 50%;
        margin-right: 8px;
        background: var(--ffa-orange);
        vertical-align: 1px;
    }

    .ffa-toast.is-in::before {
        background: var(--ffa-cyan);
    }

/* ---------- Fasi ---------- */
.ffa-steps {
    position: relative;
    z-index: 2;
    list-style: none;
    margin: 34px 0 0;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
}

    .ffa-steps li {
        position: relative;
        display: flex;
        align-items: center;
        gap: 10px;
        font-size: 14px;
        color: var(--ffa-muted);
        padding: 12px 14px 14px;
        border-radius: 12px;
        background: rgba(255, 255, 255, .04);
        overflow: hidden;
        transition: color .4s ease, background .4s ease;
    }

        .ffa-steps li span {
            flex: 0 0 24px;
            height: 24px;
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 12px;
            font-weight: 600;
            background: rgba(255, 255, 255, .1);
            color: #fff;
            transition: background .4s ease;
        }

        /* barra di avanzamento della fase */
        .ffa-steps li::after {
            content: "";
            position: absolute;
            left: 0;
            bottom: 0;
            height: 3px;
            width: 100%;
            background: linear-gradient(90deg, var(--ffa-orange), var(--ffa-orange-2));
            transform: scaleX(0);
            transform-origin: left;
        }

        .ffa-steps li.is-done {
            color: #fff;
        }

            .ffa-steps li.is-done span {
                background: rgba(250, 167, 82, .35);
            }

        .ffa-steps li.is-active {
            color: #fff;
            background: rgba(255, 255, 255, .09);
        }

            .ffa-steps li.is-active span {
                background: linear-gradient(135deg, var(--ffa-orange), var(--ffa-orange-2));
            }

            .ffa-steps li.is-active::after {
                animation: ffaProgress var(--ffa-step, 3.6s) linear forwards;
            }

@keyframes ffaProgress { to { transform: scaleX(1); } }

/* ---------- Tablet ---------- */
@media (max-width: 991.98px) {
    .ffa { padding: 34px 24px 24px; }
    .ffa-stage { grid-template-columns: minmax(0, 1fr) 120px minmax(0, 1fr); }
    .ffa-node { padding: 16px; }
    .ffa-api { font-size: 10px; padding: 6px 10px; }
    .ffa-toast { font-size: 12px; white-space: normal; width: 150px; text-align: center; }
    .ffa-steps { grid-template-columns: repeat(2, 1fr); }
}

/* ---------- Mobile: nodi in verticale ---------- */
@media (max-width: 767.98px) {
    .ffa { padding: 24px 16px 18px; border-radius: 14px; }
    .ffa-stage { grid-template-columns: 1fr; }
    .ffa-link { min-height: 130px; }
    .ffa-track {
        left: 50%;
        right: auto;
        top: -2px;
        bottom: -2px;
        width: 4px;
        height: auto;
        margin: 0 0 0 -2px;
    }
    .ffa-flow { display: none; }
    .ffa-packet { left: 50%; top: 0; margin: -9px 0 0 -9px; }
    .ffa-rail.go-out { animation-name: ffaRailOutV; }
    .ffa-rail.go-in { animation-name: ffaRailInV; }
    .ffa-api { margin-bottom: 60px; }
    .ffa-toast { top: auto; bottom: 18px; width: auto; max-width: 90%; white-space: normal; }
    .ffa-steps { margin-top: 22px; grid-template-columns: 1fr 1fr; gap: 8px; }
    .ffa-steps li { font-size: 12px; padding: 10px; gap: 8px; }
}

@keyframes ffaRailOutV { from { transform: translateY(0); } to { transform: translateY(100%); } }
@keyframes ffaRailInV { from { transform: translateY(100%); } to { transform: translateY(0); } }

@media (prefers-reduced-motion: reduce) {
    .ffa-flow::before, .ffa-dot::after { animation: none; }
}
