/* ===== Tutorial guidato in-app (js/21.js) =====
   Overlay sopra tutto (welcome-modal è 99999). L'utente non interagisce con
   l'app durante il tour: il blocker intercetta i pointer; i click del motore
   sono programmatici (el.click()) e non passano dall'hit-testing. */

#tutorialOverlay {
    position: fixed;
    inset: 0;
    z-index: 100000;
    display: none;
    font-family: var(--body-font-family, 'Poppins', sans-serif);
}
#tutorialOverlay.visible { display: block; }

/* Blocker trasparente su tutto lo schermo */
.tut-blocker {
    position: absolute;
    inset: 0;
}

/* Dim: 4 pannelli attorno al target (il target resta a piena luminosità) */
.tut-dim {
    position: absolute;
    background: rgba(8, 10, 20, 0.55);
    transition: opacity 0.25s ease;
}

/* Spotlight attorno all'elemento evidenziato */
.tut-spot {
    position: absolute;
    border: 3px solid #FFD60A;
    border-radius: 16px;
    box-shadow: 0 0 0 4px rgba(255, 214, 10, 0.25), 0 0 24px rgba(255, 214, 10, 0.45);
    animation: tut-glow 1.6s ease-in-out infinite;
    pointer-events: none;
    transition: top 0.25s ease, left 0.25s ease, width 0.25s ease, height 0.25s ease;
}
@keyframes tut-glow {
    0%, 100% { box-shadow: 0 0 0 4px rgba(255, 214, 10, 0.25), 0 0 18px rgba(255, 214, 10, 0.35); }
    50%      { box-shadow: 0 0 0 6px rgba(255, 214, 10, 0.35), 0 0 32px rgba(255, 214, 10, 0.6); }
}
#tutorialOverlay.no-target .tut-spot { display: none; }

/* Card messaggio */
.tut-card {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    width: min(560px, calc(100vw - 24px));
    background: var(--md-sys-color-surface-container-low, #E8EDF5);
    color: var(--text-primary, #2D3436);
    border-radius: 20px;
    padding: 0.9rem 1rem 0.8rem;
    box-shadow: 0 12px 40px rgba(10, 14, 30, 0.35);
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
}
body.dark-theme .tut-card {
    background: #232342;
    border: 1px solid #28284A;
}
.tut-card.pos-bottom { bottom: calc(64px + env(safe-area-inset-bottom, 0px) + 14px); }
.tut-card.pos-top { top: calc(env(safe-area-inset-top, 0px) + 14px); }

.tut-counter {
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.6px;
    color: var(--md-sys-color-primary, #008B8B);
}
.tut-text {
    font-size: 0.88rem;
    line-height: 1.45;
    color: var(--text-primary, #2D3436);
}

/* Riga controlli: frecce */
.tut-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}
.tut-btn {
    border: none;
    cursor: pointer;
    font-family: inherit;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: none;
    padding: 0;
}
.tut-arrow {
    flex: 1;
    height: 42px;
    border-radius: 14px;
    background: var(--md-sys-color-surface-container-high, #DDE3EC);
    color: var(--text-primary, #2D3436);
    font-size: 1.15rem;
    font-weight: 700;
    transition: transform 0.15s ease, opacity 0.15s ease;
}
.tut-arrow:active { transform: scale(0.96); }
.tut-arrow[disabled] { opacity: 0.35; cursor: default; }
.tut-arrow.tut-next {
    background: var(--md-sys-color-primary, #008B8B);
    color: var(--md-sys-color-on-primary, #FFFFFF);
}
body.dark-theme .tut-arrow { background: #28284A; color: #EDF0F5; }
body.dark-theme .tut-arrow.tut-next { background: #00E5CC; color: #10121F; }

/* X di uscita, fissa in alto a destra dell'overlay */
.tut-close {
    position: absolute;
    top: calc(env(safe-area-inset-top, 0px) + 12px);
    right: 12px;
    width: 42px;
    height: 42px;
    border-radius: 999px;
    background: rgba(20, 24, 40, 0.75);
    color: #FFFFFF;
    font-size: 1.05rem;
    font-weight: 700;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 3;
}
body.dark-theme .tut-close { background: rgba(0, 229, 204, 0.16); color: #00E5CC; }

/* Dito/tap indicator */
.tut-finger {
    position: absolute;
    width: 28px;
    height: 28px;
    border-radius: 999px;
    background: rgba(255, 214, 10, 0.9);
    border: 3px solid #FFFFFF;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4);
    pointer-events: none;
    transition: top 0.5s cubic-bezier(0.4, 0, 0.2, 1), left 0.5s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.25s ease;
    opacity: 0;
    z-index: 2;
}
.tut-finger.show { opacity: 1; }
.tut-finger .tut-ripple {
    position: absolute;
    inset: -3px;
    border-radius: 999px;
    border: 3px solid rgba(255, 214, 10, 0.9);
    opacity: 0;
}
.tut-finger.tap .tut-ripple { animation: tut-ripple 0.55s ease-out; }
@keyframes tut-ripple {
    0% { transform: scale(1); opacity: 0.9; }
    100% { transform: scale(2.4); opacity: 0; }
}

/* Caret typing sugli input compilati dal motore */
.tut-typing-caret { animation: tut-caret 0.8s step-end infinite; }
@keyframes tut-caret { 0%, 100% { opacity: 1; } 50% { opacity: 0.2; } }
