/* ==========================================================================
   1. RESET GLOBALE E FIX MOBILE
   ========================================================================== */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    user-select: none; 
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent; 
}

body {
    /* Font di sistema nativi: Apple/San Francisco su iOS, Roboto su Android */
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
    background-color: #222; 
    color: #333;
    overflow: hidden;
    width: 100vw;
    height: 100dvh; /* Altezza dinamica per ignorare le barre di Android/iOS */
    display: flex;
    justify-content: center;
    align-items: center; 
}

/* ==========================================================================
   2. IL GUSCIO RESPONSIVE (SIMULATORE SMARTPHONE)
   ========================================================================== */
#app-wrapper {
    position: relative;
    width: 100%;
    height: 100%;
    max-width: 450px; 
    background-color: #f4ebd8; 
    overflow: hidden;
    box-shadow: 0 10px 40px rgba(0,0,0,0.8);
}

@media (min-width: 600px) {
    #app-wrapper {
        height: 90vh; 
        max-height: 900px;
        border-radius: 35px; 
        border: 8px solid #000; 
    }
}

/* ==========================================================================
   3. LA MAPPA (IL BACKGROUND)
   ========================================================================== */
#map-container {
    position: absolute;
    top: 0; left: 0;
    width: 100%;
    height: 100%;
    background-image: url('../assets/img/sfondo-mappa.webp');
    background-size: cover; 
    background-position: center top; 
    background-repeat: no-repeat;
}

/* ==========================================================================
   4. LOGO MALATEMPORA
   ========================================================================== */
#malatempora-logo {
    position: absolute;
    top: 25px;
    left: 23%;
    transform: translateX(-50%);
    z-index: 50;
    width: 160px;
}
#malatempora-logo img {
    width: 100%; height: auto; border-radius: 8px; box-shadow: 0 4px 15px rgba(0,0,0,0.3);
}

/* ==========================================================================
   5. HOTSPOT E PUNTI PULSANTI (STILE MUSEO)
   ========================================================================== */
.hotspot {
    position: absolute; display: flex; flex-direction: column; align-items: center;
    cursor: pointer; z-index: 10; transform: translate(-50%, -50%); /* Centratura esatta */
    transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.hotspot:active { transform: translate(-50%, -50%) scale(0.85); }

/* Nascondiamo la vecchia immagine del pin creata dal JS */
.pin-icon { display: none !important; }

/* Creiamo il nuovo punto minimale pulsante */
.hotspot::before {
    content: '';
    display: block;
    width: 16px;
    height: 16px;
    background-color: #EA4335;
    border-radius: 50%;
    border: 2px solid #fff;
    box-shadow: 0 0 0 rgba(234, 67, 53, 0.6);
    animation: pulse-ring 2s infinite;
}

@keyframes pulse-ring {
    0% { box-shadow: 0 0 0 0 rgba(234, 67, 53, 0.6); }
    70% { box-shadow: 0 0 0 15px rgba(234, 67, 53, 0); }
    100% { box-shadow: 0 0 0 0 rgba(234, 67, 53, 0); }
}

/* Etichette Vetro Smerigliato (Glassmorphism) */
.pin-label {
    margin-top: 8px; font-weight: 900; font-size: 11px; line-height: 1.1; letter-spacing: 0.5px;
    text-transform: uppercase; color: #111; text-align: center; width: auto; max-width: 110px;
    background: rgba(255, 255, 255, 0.5); /* Trasparenza */
    backdrop-filter: blur(8px); /* L'effetto sfocato sul retro */
    -webkit-backdrop-filter: blur(8px); /* Per Safari */
    padding: 5px 8px; border-radius: 8px; 
    border: 1px solid rgba(255, 255, 255, 0.7);
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
}

/* ==========================================================================
   6. MODALE UI (VETRO SMERIGLIATO / APPLE STYLE)
   ========================================================================== */
#modal {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.4); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
    display: flex; justify-content: center; align-items: center; z-index: 100;
}
#modal.hidden { display: none !important; }

.modal-content {
    background: rgba(255, 255, 255, 0.88); 
    backdrop-filter: blur(20px); 
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.5); 
    padding: 35px 25px; 
    border-radius: 35px; /* Angoli Apple */
    text-align: center; 
    width: 85%; 
    max-width: 350px; 
    box-shadow: 0 15px 40px rgba(0,0,0,0.15);
}

h1#modal-title { 
    font-size: 1.5rem; 
    margin-bottom: 25px; 
    text-transform: uppercase; 
    font-weight: 700; 
    letter-spacing: -0.5px; 
    color: #000; 
}

.button-group { display: flex; flex-direction: column; gap: 12px; margin-bottom: 25px;}

.giant-btn { 
    padding: 18px; 
    border: none; 
    border-radius: 50px; /* Bottone a Pillola */
    font-weight: 600; 
    font-size: 1rem; 
    cursor: pointer; 
    text-transform: none; 
    letter-spacing: -0.2px; 
    transition: all 0.2s ease;
}

.giant-btn:active { transform: scale(0.94); opacity: 0.8; }

/* Pulsanti stile Premium / iOS */
.primary-btn { 
    background: #007AFF; /* Blu Apple */
    color: white; 
    box-shadow: 0 5px 15px rgba(0, 122, 255, 0.25); 
}
.secondary-btn { 
    background: rgba(0,0,0,0.05); 
    color: #007AFF; 
    border: none; 
    width: 100%;
}

/* ==========================================================================
   7. PLAYER AUDIO (CENTRATO STILE MODALE / APPLE STYLE)
   ========================================================================== */
#player-ui {
    position: absolute; 
    top: 50%; 
    left: 50%; 
    transform: translate(-50%, -50%); /* Centratura assoluta SALVATA */
    width: 85%; 
    max-width: 380px; 
    background: rgba(255, 255, 255, 0.92); 
    backdrop-filter: blur(25px); 
    -webkit-backdrop-filter: blur(25px);
    padding: 30px 25px 25px; 
    z-index: 300; 
    border-radius: 35px; /* Coordinato modale */
    border: 1px solid rgba(255, 255, 255, 0.7);
    /* Il trucco di sistema: un'ombra enorme per oscurare la mappa in background */
    box-shadow: 0 15px 40px rgba(0,0,0,0.2), 0 0 0 100vmax rgba(0,0,0,0.5); 
}
#player-ui.hidden { display: none !important; }

#btn-close-player {
    position: absolute; top: 15px; right: 15px; background: rgba(0,0,0,0.05); border: none;
    width: 32px; height: 32px; border-radius: 50%; font-size: 1.2rem; line-height: 1; color: #555; 
    cursor: pointer; z-index: 310; display: flex; justify-content: center; align-items: center;
    transition: background 0.2s, transform 0.1s;
}
#btn-close-player:active { background: rgba(0,0,0,0.1); transform: scale(0.9); }

#player-title { font-size: 1.1rem; display: block; margin-bottom: 15px; text-align: center; font-weight: 900; color: #111; letter-spacing: 0.5px;}
#audio-loader { font-size: 0.9rem; color: #EA4335; font-weight: bold; margin-bottom: 20px; text-align: center; animation: blink 1s infinite; text-transform: uppercase; letter-spacing: 1px;}
@keyframes blink { 0% {opacity: 1;} 50% {opacity: 0.3;} 100% {opacity: 1;} }

/* Controlli compatti */
.seek-controls { display: flex; justify-content: center; gap: 10px; margin-bottom: 25px; flex-wrap: wrap; }
.seek-btn { 
    background: rgba(255,255,255,0.8); border: 1px solid rgba(0,0,0,0.1); border-radius: 30px; padding: 10px 15px; 
    font-weight: 800; font-size: 0.85rem; color: #333; cursor: pointer; box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}
.seek-btn:active { transform: scale(0.95); background: rgba(0,0,0,0.05); }

/* Pulsante skip pulito */
.skip-btn { 
    color: #EA4335; 
    border: none; 
    background: rgba(234, 67, 53, 0.1);
    font-size: 0.8rem;
}

/* Barra progresso sottile */
.progress-container { width: 100%; height: 4px; background: rgba(0,0,0,0.05); border-radius: 10px; overflow: hidden; margin-bottom: 25px; }
#progress-bar { width: 0%; height: 100%; background: #EA4335; transition: width 0.1s linear; border-radius: 10px;}

/* Tasto Ferma Ascolto a Pillola */
.danger-btn { 
    background: #EA4335; color: white; width: 100%; padding: 16px; border-radius: 50px; 
    font-weight: 600; font-size: 1.05rem; border: none; cursor: pointer; text-transform: none; 
    letter-spacing: -0.2px; box-shadow: 0 8px 15px rgba(234, 67, 53, 0.3); transition: transform 0.1s;
}
.danger-btn:active { transform: scale(0.96); box-shadow: 0 4px 8px rgba(234, 67, 53, 0.3); }

/* ==========================================================================
   8. SCREENSAVER
   ========================================================================== */
#screensaver {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    background-color: #000; z-index: 2000; display: flex; justify-content: center; align-items: center;
}
#screensaver.hidden { display: none !important; }
#screensaver-video { position: absolute; top: 0; left: 0; width: 100%; height: 100%; object-fit: cover; z-index: 1; opacity: 0.6; }
#screensaver-text { position: relative; z-index: 2; text-align: center; color: white; width: 90%; }
.main-text { font-size: 2.2rem; font-weight: 900; margin-bottom: 5px; text-shadow: 0 4px 15px rgba(0,0,0,0.8); letter-spacing: 1px;}
.sub-text { font-size: 1.2rem; margin-bottom: 30px; text-shadow: 0 4px 15px rgba(0,0,0,0.8); font-weight: 300;}
.cta-text { font-size: 1rem; background: rgba(234, 67, 53, 0.9); padding: 16px 35px; border-radius: 50px; font-weight: 800; display: inline-block; backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); text-transform: uppercase; letter-spacing: 0.5px;}

/* ==========================================================================
   9. FOOTER PROMOZIONALE
   ========================================================================== */
#promo-footer {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    /* Effetto Vetro per far intravedere la mappa in fondo */
    background: rgba(255, 255, 255, 0.65);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-top: 1px solid rgba(255, 255, 255, 0.8);
    padding: 15px 10px 20px; /* Più spazio in basso per i bordi arrotondati di iPhone */
    text-align: center;
    z-index: 40; /* Sopra i pin, sotto i modali */
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: center;
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* Quando riceve la classe hidden, scivola fuori dallo schermo in basso */
#promo-footer.hidden {
    transform: translateY(100%);
}

.promo-text {
    font-size: 0.8rem;
    font-weight: 900;
    text-transform: uppercase;
    color: #333;
    letter-spacing: 0.5px;
}

.promo-links {
    display: flex;
    gap: 15px;
}

.promo-btn {
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 800;
    padding: 8px 18px;
    border-radius: 20px;
    color: #fff;
    transition: transform 0.1s;
}

.promo-btn:active {
    transform: scale(0.95);
}

.spotify-btn {
    background: #1DB954; /* Verde Ufficiale Spotify */
    box-shadow: 0 6px 12px rgba(29, 185, 84, 0.3);
}

.web-btn {
    background: #111;
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.3);
}

/* ==========================================================================
   10. EFFETTI METEO (Sensore Valconca Live)
   ========================================================================== */

/* 1. Pioggia: Doppio strato obliquo per profondità e realismo */
.weather-rain {
    background: rgba(225, 230, 240, 0.9) !important;
    backdrop-filter: blur(15px) !important;
    -webkit-backdrop-filter: blur(15px) !important;
    border-top: 1px solid rgba(255, 255, 255, 0.6) !important;
    overflow: hidden;
}
.weather-rain::before, .weather-rain::after {
    content: ''; position: absolute; top: -50%; left: -50%; width: 200%; height: 200%;
    pointer-events: none; z-index: 205; border-radius: inherit;
}
/* Pioggia in primo piano (veloce e nitida) */
.weather-rain::after {
    background-image: linear-gradient(160deg, rgba(255,255,255,0) 40%, rgba(255,255,255,0.5) 50%, rgba(255,255,255,0) 60%);
    background-size: 15px 90px;
    animation: rain-heavy 0.5s linear infinite;
}
/* Pioggia in background (sfocata e leggermente più lenta) */
.weather-rain::before {
    background-image: linear-gradient(160deg, rgba(255,255,255,0) 30%, rgba(255,255,255,0.2) 50%, rgba(255,255,255,0) 70%);
    background-size: 25px 130px;
    animation: rain-heavy 0.8s linear infinite;
    filter: blur(2px);
}
@keyframes rain-heavy {
    0% { background-position: 0 0; }
    100% { background-position: 100px 1000px; }
}

/* 2. Sole: Vetro caldo con riverbero solare pulsante */
.weather-clear {
    background: rgba(255, 250, 240, 0.92) !important;
    backdrop-filter: blur(20px) !important;
    -webkit-backdrop-filter: blur(20px) !important;
    border: 1px solid rgba(255, 215, 0, 0.4) !important;
    /* Ombra esterna scura per oscurare la mappa, ombra interna calda per il sole */
    box-shadow: 0 15px 40px rgba(0,0,0,0.3), 0 0 0 100vmax rgba(0,0,0,0.6), inset 0 0 80px rgba(255, 180, 0, 0.15) !important;
    overflow: hidden;
}
.weather-clear::after {
    content: ''; position: absolute; top: -50%; left: -50%; width: 200%; height: 200%;
    background: radial-gradient(circle at 20% 0%, rgba(255, 215, 0, 0.25) 0%, transparent 40%);
    pointer-events: none; z-index: 205;
    animation: sun-pulse 4s ease-in-out infinite alternate;
}
@keyframes sun-pulse {
    0% { opacity: 0.5; transform: scale(1); }
    100% { opacity: 1; transform: scale(1.15); }
}

/* 3. Nuvole/Nebbia: Effetto foschia che scorre lentamente sul vetro */
.weather-clouds { 
    background: rgba(235, 240, 255, 0.8) !important; 
    backdrop-filter: blur(12px) !important;
    -webkit-backdrop-filter: blur(12px) !important;
    overflow: hidden; /* Mantiene la nebbia confinata dentro il player */
}

.weather-clouds::after {
    content: '';
    position: absolute; 
    top: 0; 
    left: -50%; 
    width: 200%; 
    height: 100%;
    /* Crea un banco di nebbia sfumato */
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.6), transparent);
    animation: fog-drift 6s ease-in-out infinite alternate;
    pointer-events: none; /* Permette di cliccare i tasti sottostanti */
    z-index: 205;
}

@keyframes fog-drift {
    0% { transform: translateX(-15%); }
    100% { transform: translateX(15%); }
}

/* ==========================================================================
   10. WIDGET METEO REAL-TIME
   ========================================================================== */
#weather-widget {
    position: absolute;
    top: 20px;
    right: 20px; /* Posizionato in alto a destra */
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 18px;
    border-radius: 30px;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border: 1px solid rgba(255, 255, 255, 0.6);
    box-shadow: 0 5px 20px rgba(0,0,0,0.15);
    z-index: 100;
    color: #222;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

#weather-widget.hidden {
    opacity: 0;
    transform: translateY(-20px) scale(0.9);
    pointer-events: none;
}

#weather-icon {
    font-size: 28px;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.1));
}

#weather-info {
    display: flex;
    flex-direction: column;
    justify-content: center;
}

#weather-temp {
    font-weight: 900;
    font-size: 18px;
    line-height: 1;
    color: #d32f2f; /* Un tocco di rosso Malatempora */
}

#weather-desc {
    font-size: 11px;
    text-transform: capitalize;
    font-weight: 600;
    opacity: 0.7;
    margin-top: 2px;
}

/* ==========================================================================
   11. EASTER EGG (PROTOCOLLO SEGRETO)
   ========================================================================== */
.easter-egg-mode {
    background: rgba(15, 15, 15, 0.95) !important;
    backdrop-filter: blur(25px) !important;
    -webkit-backdrop-filter: blur(25px) !important;
    border: 2px solid rgba(212, 175, 55, 0.8) !important;
    box-shadow: 0 0 50px rgba(212, 175, 55, 0.4), inset 0 0 30px rgba(0, 0, 0, 0.8) !important;
    /* Usiamo la nuova animazione sicura */
    animation: secret-reveal-safe 1.2s ease-out both; 
}
.easter-egg-mode #player-title {
    color: #D4AF37 !important; /* Testo Oro */
    font-family: monospace;
    letter-spacing: 2px;
    text-shadow: 0 0 10px rgba(212, 175, 55, 0.5);
}

.easter-egg-mode .progress-container {
    background: rgba(255,255,255,0.1);
}

.easter-egg-mode #progress-bar {
    background: #D4AF37 !important; /* Barra d'oro */
    box-shadow: 0 0 15px rgba(212, 175, 55, 0.8);
}

/* Animazione basata su Opacità e Filtri di luce (Senza toccare la posizione) */
@keyframes secret-reveal-safe {
    0% { 
        opacity: 0; 
        filter: brightness(3) contrast(1.5) hue-rotate(45deg); 
    }
    100% { 
        opacity: 1; 
        filter: brightness(1) contrast(1) hue-rotate(0deg); 
    }
}