/* Effetti di stagione: ragnetti e ragnatele (24–31 ottobre), saluto della zucca (1–3 novembre).
   Non bloccano mai i clic e si fermano con "riduci animazioni". */

.m35-hw-defs { position: absolute; width: 0; height: 0; overflow: hidden; }

.m35-hw {
    position: fixed;
    inset: 0;
    z-index: 60;
    pointer-events: none;
    overflow: hidden;
}

.m35-hw-tela {
    position: absolute;
    top: 0;
    width: clamp(110px, 16vw, 220px);
    height: clamp(110px, 16vw, 220px);
    color: rgba(234, 236, 239, 0.2);
}
.m35-hw-tela-sx { left: 0; }
.m35-hw-tela-dx { right: 0; transform: scaleX(-1); }

/* Ragnetto appeso al filo: scende, dondola, risale */
.m35-hw-filo {
    position: absolute;
    top: 0;
    width: 34px;
    height: var(--lungo, 25vh);
    margin-left: -17px;
    transform: translateY(-100%);
    animation: m35-scendi var(--durata, 12s) ease-in-out var(--ritardo, 0s) infinite;
}
.m35-hw-filo::before {
    content: '';
    position: absolute;
    left: 50%;
    top: 0;
    bottom: 20px;
    width: 1px;
    background: rgba(234, 236, 239, 0.45);
}
.m35-hw-ragno {
    position: absolute;
    left: 0;
    bottom: 0;
    width: 34px;
    height: 34px;
    color: #cfd6df;
    transform-origin: 50% 40%;
    animation: m35-dondola 2.6s ease-in-out infinite alternate;
}

@keyframes m35-scendi {
    0%, 8% { transform: translateY(-100%); }
    35%, 62% { transform: translateY(0); }
    90%, 100% { transform: translateY(-100%); }
}
@keyframes m35-dondola {
    from { transform: rotate(-7deg); }
    to { transform: rotate(7deg); }
}

/* Ragnetto che passeggia sul bordo in alto */
.m35-hw-cammina {
    position: absolute;
    top: 2px;
    left: 0;
    width: 26px;
    height: 26px;
    color: #cfd6df;
    transform: translateX(-40px) rotate(90deg);
    animation: m35-cammina 30s linear 6s infinite;
}
@keyframes m35-cammina {
    from { transform: translateX(-40px) rotate(90deg); }
    to { transform: translateX(calc(100vw + 40px)) rotate(90deg); }
}

/* Il giorno dopo: il ragnetto risale e se ne va */
.m35-hw-risale {
    transform: translateY(0);
    animation: m35-risale 3s ease-in 2.5s forwards;
}
@keyframes m35-risale {
    to { transform: translateY(-100%); }
}

/* Riquadro di saluto */
.m35-hw-addio {
    position: fixed;
    left: 16px;
    bottom: 16px;
    z-index: 95;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    max-width: 360px;
    padding: 0.7rem 0.3rem 0.7rem 0.7rem;
    background: rgba(8, 16, 20, 0.94);
    border: 1px solid var(--m35-border, rgba(255, 255, 255, 0.12));
    border-radius: 20px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(10px);
    color: var(--m35-ink, #EAECEF);
    animation: m35-entra 0.6s ease-out 1.2s both;
    transition: opacity 0.35s ease, transform 0.35s ease;
}
.m35-hw-addio[hidden] { display: none; }
.m35-hw-addio.m35-hw-via { opacity: 0; transform: translateY(20px); }
.m35-hw-addio-img { flex: 0 0 96px; width: 96px; height: 98px; }
.m35-hw-addio-testo { display: flex; flex-direction: column; gap: 0.2rem; line-height: 1.35; }
.m35-hw-addio-testo strong { font-size: 1rem; }
.m35-hw-addio-testo span { font-size: 0.88rem; color: var(--m35-slate, #A9B4C4); }
.m35-hw-chiudi {
    flex: 0 0 48px;
    align-self: flex-start;
    width: 48px;
    height: 48px;
    margin: -0.4rem 0 0;
    border: 0;
    background: none;
    color: var(--m35-slate, #A9B4C4);
    font-size: 1.7rem;
    line-height: 1;
    cursor: pointer;
}
.m35-hw-chiudi:hover, .m35-hw-chiudi:focus-visible { color: #fff; }

.m35-hw-saluta {
    transform-box: fill-box;
    transform-origin: 0% 100%;
    animation: m35-saluta 0.5s ease-in-out infinite alternate;
}
@keyframes m35-saluta {
    from { transform: rotate(-22deg); }
    to { transform: rotate(14deg); }
}
@keyframes m35-entra {
    from { opacity: 0; transform: translateY(30px); }
    to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 760px) {
    .m35-hw-filo:nth-of-type(2) { display: none; }
    .m35-hw-addio {
        right: 16px;
        max-width: none;
        bottom: calc(5.6rem + env(safe-area-inset-bottom));
    }
}

@media (prefers-reduced-motion: reduce) {
    .m35-hw-filo, .m35-hw-ragno, .m35-hw-saluta, .m35-hw-addio { animation: none; }
    .m35-hw-filo { transform: none; }
    .m35-hw-cammina, .m35-hw-risale { display: none; }
}

/* ---- Altre feste: neve, stelle, cuori, mimosa, coriandoli, ovetti ---- */
.m35-hw-p {
    position: absolute;
    top: -40px;
    width: var(--s, 16px);
    height: var(--s, 16px);
    color: var(--c, #fff);
    opacity: 0.85;
    animation: m35-cade var(--t, 12s) linear var(--d, 0s) infinite;
}
.m35-hw-p svg { display: block; width: 100%; height: 100%; }
.m35-hw--sale .m35-hw-p { top: auto; bottom: -40px; animation-name: m35-sale; }
@keyframes m35-cade {
    from { transform: translate(0, 0) rotate(0); }
    to { transform: translate(var(--dx, 30px), calc(100vh + 80px)) rotate(var(--r, 180deg)); }
}
@keyframes m35-sale {
    from { transform: translate(0, 0) scale(0.8); opacity: 0; }
    10% { opacity: 0.85; }
    to { transform: translate(var(--dx, 30px), calc(-100vh - 80px)) scale(1.1); opacity: 0; }
}

/* Natale: lucine colorate lungo il bordo in alto */
.m35-hw-luci {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-around;
    height: 18px;
    border-top: 2px solid rgba(169, 180, 196, 0.35);
}
.m35-hw-luci span {
    width: 8px;
    height: 11px;
    margin-top: 3px;
    border-radius: 50% 50% 45% 45%;
    background: var(--c);
    box-shadow: 0 0 8px var(--c);
    animation: m35-lucina 1.6s ease-in-out var(--d, 0s) infinite alternate;
}
@keyframes m35-lucina { from { opacity: 0.35; } to { opacity: 1; } }

/* Feste nazionali: nastro tricolore in alto */
.m35-hw-tricolore {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 5px;
    background: linear-gradient(90deg, #009246 0 33.33%, #ffffff 33.33% 66.66%, #ce2b37 66.66%);
}

/* Ferragosto: sole nell'angolo in alto a destra */
.m35-hw-sole {
    position: absolute;
    top: -34px;
    right: -34px;
    width: clamp(100px, 13vw, 170px);
    height: clamp(100px, 13vw, 170px);
    opacity: 0.8;
}
.m35-hw-raggi { transform-origin: 50px 50px; animation: m35-gira 30s linear infinite; }
@keyframes m35-gira { to { transform: rotate(360deg); } }

/* Riquadro di auguri: dettagli */
.m35-hw-link { color: var(--m35-accent-bright, #00ff9d); font-weight: 700; font-size: 0.9rem; text-decoration: none; min-height: 32px; display: inline-flex; align-items: center; }
.m35-hw-brilla { animation: m35-brilla 1.4s ease-in-out infinite alternate; transform-box: fill-box; transform-origin: center; }
.m35-hw-brilla-2 { animation-delay: 0.7s; }
@keyframes m35-brilla { from { opacity: 0.55; transform: scale(0.9); } to { opacity: 1; transform: scale(1.05); } }
.m35-hw-saluta-orecchio { transform-box: fill-box; transform-origin: 50% 100%; animation: m35-saluta 0.6s ease-in-out infinite alternate; }

@media (max-width: 760px) {
    .m35-hw-p:nth-of-type(n + 9) { display: none; }
    .m35-hw-luci span:nth-child(n + 15) { display: none; }
}

@media (prefers-reduced-motion: reduce) {
    .m35-hw-p { display: none; }
    .m35-hw-luci span, .m35-hw-raggi, .m35-hw-brilla, .m35-hw-saluta-orecchio { animation: none; }
}
