.tour {
    position: fixed;
    inset: 0;
    z-index: 1050;
}

.tour__velo {
    position: absolute;
    inset: 0;
    background: rgba(2, 6, 23, 0.66);
    opacity: 0;
    transition: opacity 0.35s ease;
}

.tour.is-centrato .tour__velo {
    opacity: 1;
}

.tour__faro {
    position: absolute;
    top: 0;
    left: 0;
    border-radius: var(--tour-raggio, var(--radius-sm));
    box-shadow:
        0 0 0 200vmax rgba(2, 6, 23, 0.66),
        0 0 0 2px rgba(var(--accent2-rgb), 0.9),
        0 0 28px 6px rgba(var(--accent2-rgb), 0.4);
    transform-origin: 0 0;
    transition: transform 0.55s cubic-bezier(0.3, 1.15, 0.4, 1), opacity 0.3s ease;
    pointer-events: none;
}

.tour__faro::after {
    content: '';
    position: absolute;
    inset: -6px;
    border: 2px solid rgba(var(--accent2-rgb), 0.55);
    border-radius: inherit;
    animation: tourPulsa 1.8s ease-out infinite;
}

.tour.is-centrato .tour__faro {
    opacity: 0;
}

.tour__scheda {
    position: absolute;
    top: 0;
    left: 0;
    width: 390px;
    max-width: calc(100vw - 24px);
    max-height: calc(100vh - 24px);
    overflow-y: auto;
    padding: var(--space-lg) var(--space-lg) var(--space-md);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    corner-shape: squircle;
    background:
        radial-gradient(120% 80% at 0% 0%, rgba(var(--accent2-rgb), 0.2), transparent 60%),
        radial-gradient(90% 60% at 100% 100%, rgba(var(--accent-rgb), 0.08), transparent 60%),
        rgba(10, 18, 40, 0.86);
    backdrop-filter: blur(28px) saturate(180%);
    -webkit-backdrop-filter: blur(28px) saturate(180%);
    box-shadow:
        0 24px 60px -14px rgba(0, 0, 0, 0.7),
        inset 0 1px 0 rgba(255, 255, 255, 0.16);
    transition: transform 0.5s cubic-bezier(0.3, 1.15, 0.4, 1);
    animation: tourEntra 0.45s cubic-bezier(0.34, 1.4, 0.64, 1) both;
}

.tour__scheda--speciale {
    width: 400px;
    text-align: center;
}

.tour.is-uscita .tour__scheda,
.tour.is-uscita .tour__velo,
.tour.is-uscita .tour__faro {
    opacity: 0;
    transition: opacity 0.25s ease;
}

.tour__contenuto {
    transition: opacity 0.16s ease, transform 0.16s ease;
}

.tour__contenuto.is-cambio {
    opacity: 0;
    transform: translateY(6px);
}

.tour__passo {
    min-height: 1em;
    margin: 0 0 4px;
    font-size: var(--fs-xs);
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--accent2);
}

.tour__titolo {
    margin: 0 0 8px;
    font-size: var(--fs-2xl);
    font-weight: 700;
    line-height: 1.2;
    color: var(--text);
    text-wrap: balance;
}

.tour__testo {
    margin: 0 0 var(--space-md);
    font-size: var(--fs-md);
    line-height: 1.55;
    color: var(--text-muted);
}

.tour__punti {
    display: grid;
    gap: 6px;
    margin: -6px 0 var(--space-md);
    padding: 0;
    list-style: none;
}

.tour__punti li {
    position: relative;
    padding-left: 18px;
    font-size: var(--fs-sm);
    line-height: 1.5;
    color: var(--text);
}

.tour__punti li::before {
    content: '';
    position: absolute;
    top: 0.55em;
    left: 2px;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--accent2);
}

.tour__vai {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin: -6px 0 var(--space-md);
    padding: 0;
    border: 0;
    background: none;
    color: var(--accent2);
    font: inherit;
    font-size: var(--fs-md);
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
}

.tour__vai .icon {
    width: 15px;
    height: 15px;
}

.tour__piede {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.tour__scheda--speciale .tour__piede {
    flex-direction: column-reverse;
}

.tour__puntini {
    display: flex;
    flex: 1 1 auto;
    flex-wrap: nowrap;
    gap: 4px;
    min-width: 0;
}

.tour__scheda--speciale .tour__puntini {
    justify-content: center;
    max-width: none;
}

.tour__puntino {
    flex-shrink: 0;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    transition: transform 0.25s ease, background-color 0.25s ease;
}

.tour__puntino.is-fatto {
    background: rgba(var(--accent2-rgb), 0.55);
}

.tour__puntino.is-attivo {
    background: var(--accent2);
    transform: scale(1.4);
}

.tour__azioni {
    display: flex;
    align-items: center;
    gap: 8px;
}

.tour__salta {
    padding: 8px 6px;
    border: 0;
    background: none;
    color: var(--text-muted);
    font: inherit;
    font-size: var(--fs-sm);
    cursor: pointer;
}

.tour__salta:hover,
.tour__salta:focus-visible {
    color: var(--text);
}

.tour__arte {
    position: relative;
    height: 74px;
    margin: -6px 0 var(--space-md);
    overflow: hidden;
}

.tour__corsia {
    position: absolute;
    left: 0;
    right: -34px;
    bottom: 14px;
    height: 2px;
    background: repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.35) 0 18px, transparent 18px 34px);
    background-size: 34px 2px;
    animation: tourCorsia 0.6s linear infinite;
}

.tour__camion {
    position: absolute;
    left: 50%;
    bottom: 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 54px;
    height: 54px;
    margin-left: -27px;
    border-radius: var(--radius-md);
    corner-shape: squircle;
    background: var(--accent2-forte);
    color: var(--on-accent);
    box-shadow: 0 10px 26px -8px rgba(var(--accent2-rgb), 0.7);
    animation: tourCamion 2.4s ease-in-out infinite;
}

.tour__camion .icon,
.tour__spunta .icon {
    width: 28px;
    height: 28px;
    stroke-width: 2;
}

.tour__arte--fatto {
    display: flex;
    align-items: center;
    justify-content: center;
}

.tour__spunta {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: rgba(var(--accent4-rgb), 0.18);
    color: var(--accent4);
    box-shadow: 0 0 0 8px rgba(var(--accent4-rgb), 0.08);
    animation: tourSpunta 0.55s cubic-bezier(0.34, 1.6, 0.64, 1) both;
}

.tour__arte--regalo {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 112px;
    overflow: visible;
}

.tour__regalo,
.tour__medaglione-icona {
    position: relative;
    z-index: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
    corner-shape: squircle;
    background: linear-gradient(145deg, var(--stato-consegna), var(--accent2-forte));
    color: var(--on-accent);
    box-shadow:
        0 12px 28px -8px rgba(var(--accent2-rgb), 0.75),
        inset 0 1px 0 rgba(255, 255, 255, 0.35);
}

.tour__regalo {
    width: 64px;
    height: 64px;
    animation: tourPop 0.6s cubic-bezier(0.34, 1.6, 0.64, 1) both, tourDondola 3.2s ease-in-out 0.6s infinite;
}

.tour__regalo .icon {
    width: 32px;
    height: 32px;
    stroke-width: 1.9;
}

.tour__regalo-alone,
.tour__medaglione-alone {
    position: absolute;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(var(--accent2-rgb), 0.45), transparent 68%);
    animation: tourAlone 2.6s ease-in-out infinite;
}

.tour__regalo-alone {
    width: 130px;
    height: 130px;
}

.tour__orbita {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 120px;
    height: 120px;
    margin: -60px 0 0 -60px;
    animation: tourOrbita 7s linear infinite;
}

.tour__orbita--2 {
    width: 92px;
    height: 92px;
    margin: -46px 0 0 -46px;
    animation-duration: 5s;
    animation-direction: reverse;
}

.tour__orbita--3 {
    width: 152px;
    height: 152px;
    margin: -76px 0 0 -76px;
    animation-duration: 11s;
}

.tour__scintilla {
    position: absolute;
    top: -7px;
    left: 50%;
    width: 14px;
    height: 14px;
    margin-left: -7px;
    color: var(--attenzione);
    animation: tourScintilla 1.8s ease-in-out infinite;
}

.tour__orbita--2 .tour__scintilla {
    color: var(--stato-consegna);
    animation-delay: 0.6s;
}

.tour__orbita--3 .tour__scintilla {
    color: var(--accent4);
    animation-delay: 1.1s;
}

.tour__scintilla .icon {
    width: 100%;
    height: 100%;
    fill: currentColor;
    stroke-width: 1;
}

.tour__testata {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    margin-bottom: 12px;
}

.tour__testata .tour__passo {
    margin: 0;
}

.tour__testata-testo {
    display: grid;
    justify-items: start;
    gap: 4px;
}

.tour__medaglione {
    position: relative;
    display: inline-flex;
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
}

.tour__medaglione-icona {
    width: 56px;
    height: 56px;
    animation: tourPop 0.55s cubic-bezier(0.34, 1.6, 0.64, 1) both;
}

.tour__medaglione-icona .icon {
    width: 27px;
    height: 27px;
    stroke-width: 2;
}

.tour__medaglione-alone {
    width: 96px;
    height: 96px;
    margin: -20px;
    left: 0;
    top: 0;
}

.tour__medaglione--condividi .tour__medaglione-icona .icon {
    animation: tourSpinta 1.6s ease-in-out 0.5s infinite;
}

.tour__medaglione--condividi .tour__medaglione-alone {
    animation: tourOnda 1.6s ease-out 0.5s infinite;
}

.tour__medaglione--fluttua .tour__medaglione-icona .icon {
    animation: tourFluttua 2.4s ease-in-out 0.5s infinite;
}

.tour__medaglione--spunta .tour__medaglione-icona .icon {
    animation: tourBattito 2s ease-in-out 0.6s infinite;
}

.tour__medaglione--occhio .tour__medaglione-icona .icon {
    animation: tourOcchio 3.6s ease-in-out 0.8s infinite;
}

.tour__medaglione--oscilla .tour__medaglione-icona .icon {
    transform-origin: 50% 20%;
    animation: tourOscilla 2.8s ease-in-out 0.5s infinite;
}

.tour__medaglione--battito .tour__medaglione-icona .icon {
    animation: tourBattito 1.4s ease-in-out 0.5s infinite;
}

.tour__medaglione--scuoti .tour__medaglione-icona .icon {
    transform-origin: 50% 90%;
    animation: tourScuoti 3s ease-in-out 0.7s infinite;
}

.tour__nuovo {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 9px 2px 7px;
    border: 1px solid rgba(var(--attenzione-rgb), 0.45);
    border-radius: var(--radius-pill);
    background: linear-gradient(90deg, rgba(var(--attenzione-rgb), 0.22), rgba(var(--accent-rgb), 0.18));
    font-size: var(--fs-2xs);
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--attenzione);
    animation: tourPop 0.5s cubic-bezier(0.34, 1.6, 0.64, 1) 0.15s both;
}

.tour__nuovo .icon {
    width: 12px;
    height: 12px;
    fill: currentColor;
    stroke-width: 1;
    animation: tourScintilla 1.8s ease-in-out infinite;
}

.tour__anteprima {
    display: grid;
    gap: 4px;
    margin: -4px 0 var(--space-md);
    padding: 0;
    list-style: none;
    text-align: left;
}

.tour__anteprima li {
    animation: tourVoce 0.4s cubic-bezier(0.2, 0.8, 0.2, 1) both;
    animation-delay: calc(0.25s + var(--i, 0) * 0.06s);
}

.tour__anteprima-voce {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 7px 10px 7px 7px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--radius-sm);
    corner-shape: squircle;
    background: rgba(255, 255, 255, 0.04);
    color: var(--text);
    font: inherit;
    font-size: var(--fs-md);
    font-weight: 500;
    text-align: left;
    cursor: pointer;
    transition: background var(--transition-fast), border-color var(--transition-fast);
}

.tour__anteprima-voce:hover,
.tour__anteprima-voce:focus-visible {
    border-color: rgba(var(--accent2-rgb), 0.45);
    background: rgba(var(--accent2-rgb), 0.12);
    outline: none;
}

.tour__anteprima-icona {
    display: inline-flex;
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: var(--radius-xs);
    corner-shape: squircle;
    background: rgba(var(--accent2-rgb), 0.18);
    color: var(--accent2-chiaro);
}

.tour__anteprima-icona .icon {
    width: 16px;
    height: 16px;
    stroke-width: 2;
}

.tour__anteprima-titolo {
    flex: 1;
    min-width: 0;
}

.icon.tour__anteprima-freccia {
    width: 15px;
    height: 15px;
    color: var(--text-muted);
    transition: transform var(--transition-fast), color var(--transition-fast);
}

.tour__anteprima-voce:hover .tour__anteprima-freccia,
.tour__anteprima-voce:focus-visible .tour__anteprima-freccia {
    color: var(--accent2);
    transform: translateX(3px);
}

.tour__arte--fatto {
    overflow: visible;
}

.tour__coriandolo {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 7px;
    height: 10px;
    margin: -5px 0 0 -3px;
    border-radius: var(--radius-2xs);
    background: var(--c);
    opacity: 0;
    animation: tourCoriandolo 1.1s cubic-bezier(0.15, 0.7, 0.3, 1) calc(0.15s + var(--ritardo, 0s)) both;
}

@keyframes tourEntra {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes tourPulsa {
    from {
        opacity: 0.9;
        transform: scale(1);
    }
    to {
        opacity: 0;
        transform: scale(1.08);
    }
}

@keyframes tourCorsia {
    to {
        transform: translateX(-34px);
    }
}

@keyframes tourCamion {
    0%, 100% {
        transform: translateX(-60px) translateY(0);
    }
    25% {
        transform: translateX(0) translateY(-2px);
    }
    50% {
        transform: translateX(60px) translateY(0);
    }
    75% {
        transform: translateX(0) translateY(-2px);
    }
}

@keyframes tourPop {
    from {
        opacity: 0;
        transform: scale(0.4);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes tourDondola {
    0%, 100% {
        transform: translateY(0) rotate(-4deg);
    }
    50% {
        transform: translateY(-5px) rotate(4deg);
    }
}

@keyframes tourAlone {
    0%, 100% {
        opacity: 0.55;
        transform: scale(0.92);
    }
    50% {
        opacity: 1;
        transform: scale(1.06);
    }
}

@keyframes tourOrbita {
    to {
        transform: rotate(360deg);
    }
}

@keyframes tourScintilla {
    0%, 100% {
        opacity: 0.35;
        transform: scale(0.7) rotate(0deg);
    }
    50% {
        opacity: 1;
        transform: scale(1.15) rotate(25deg);
    }
}

@keyframes tourSpinta {
    0%, 60%, 100% {
        transform: translateY(0);
    }
    30% {
        transform: translateY(-4px);
    }
}

@keyframes tourOnda {
    from {
        opacity: 0.9;
        transform: scale(0.6);
    }
    to {
        opacity: 0;
        transform: scale(1.25);
    }
}

@keyframes tourFluttua {
    0%, 100% {
        transform: translateY(2px);
    }
    50% {
        transform: translateY(-3px);
    }
}

@keyframes tourBattito {
    0%, 40%, 100% {
        transform: scale(1);
    }
    10%, 30% {
        transform: scale(1.18);
    }
    20% {
        transform: scale(0.96);
    }
}

@keyframes tourOcchio {
    0%, 44%, 52%, 100% {
        transform: scaleY(1);
    }
    48% {
        transform: scaleY(0.1);
    }
}

@keyframes tourOscilla {
    0%, 100% {
        transform: rotate(-9deg);
    }
    50% {
        transform: rotate(9deg);
    }
}

@keyframes tourScuoti {
    0%, 70%, 100% {
        transform: rotate(0);
    }
    75% {
        transform: rotate(-12deg);
    }
    82% {
        transform: rotate(10deg);
    }
    89% {
        transform: rotate(-6deg);
    }
}

@keyframes tourVoce {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: none;
    }
}

@keyframes tourCoriandolo {
    0% {
        opacity: 0;
        transform: translate(0, 0) rotate(0) scale(0.4);
    }
    15% {
        opacity: 1;
    }
    100% {
        opacity: 0;
        transform: translate(var(--x), calc(var(--y) + 24px)) rotate(var(--r)) scale(1);
    }
}

@keyframes tourStelline {
    0%, 100% {
        transform: rotate(0) scale(1);
    }
    50% {
        transform: rotate(18deg) scale(1.15);
    }
}

@keyframes tourPing {
    from {
        opacity: 0.8;
        transform: scale(1);
    }
    to {
        opacity: 0;
        transform: scale(2.6);
    }
}

@keyframes tourSpunta {
    from {
        opacity: 0;
        transform: scale(0.4);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

html.pagina-nascosta .tour *,
html.pagina-nascosta .tour__faro::after {
    animation-play-state: paused !important;
}

body.dark-theme .tour__scheda {
    background: rgba(16, 22, 32, 0.96);
}

@media (max-width: 768px) {
    .tour__scheda,
    .tour__scheda--speciale {
        top: auto;
        right: 12px;
        bottom: calc(12px + env(safe-area-inset-bottom, 0px));
        left: 12px;
        width: auto;
        max-width: none;
        padding: var(--space-md);
        transform: none !important;
        animation-name: tourFoglio;
    }

    .tour__scheda.tour__scheda--alto {
        top: calc(12px + env(safe-area-inset-top, 0px));
        bottom: auto;
    }

    .tour__titolo {
        font-size: var(--fs-xl);
    }

    @keyframes tourFoglio {
        from {
            opacity: 0;
            transform: translateY(30px);
        }
        to {
            opacity: 1;
            transform: none;
        }
    }
}

@media (prefers-reduced-motion: reduce) {
    .tour__faro,
    .tour__scheda,
    .tour__contenuto,
    .tour__velo {
        transition: none;
        animation: none;
    }

    .tour__faro::after,
    .tour__corsia,
    .tour__camion,
    .tour__spunta,
    .tour__regalo,
    .tour__regalo-alone,
    .tour__medaglione-alone,
    .tour__medaglione-icona,
    .tour__medaglione-icona .icon,
    .tour__orbita,
    .tour__scintilla,
    .tour__nuovo,
    .tour__nuovo .icon,
    .tour__anteprima li,
    .nav-item__pallino::after,
    .js-tutorial-sidebar .icon {
        animation: none;
    }

    .tour__coriandolo {
        display: none;
    }
}

@media (prefers-reduced-transparency: reduce) {
    .tour__scheda {
        background: rgba(10, 18, 40, 0.98);
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
    }
}

.nav-item__pallino {
    position: relative;
    width: 8px;
    height: 8px;
    margin-left: auto;
    border-radius: 50%;
    background: var(--accent);
}

.nav-item__pallino::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: var(--accent);
    animation: tourPing 1.8s ease-out infinite;
}

.js-tutorial-sidebar:has(.nav-item__pallino) .icon {
    color: var(--attenzione);
    animation: tourStelline 2.4s ease-in-out infinite;
}

html.pagina-nascosta .nav-item__pallino::after,
html.pagina-nascosta .js-tutorial-sidebar .icon {
    animation-play-state: paused;
}
