:root {
    /* REGOLAZIONE DIMENSIONI (La tua manopola)
       Aumenta 0.22vh se vuoi l'omino più grande, diminuisci se lo vuoi più piccolo.
       Il min/max impedisce che diventi microscopico o gigante.
    */
    --unit: clamp(0.8px, 0.15vh, 1.3px); 
}

body {
    display: flex;
    flex-direction: column;
    /* Cambiato da center a flex-start per controllare noi l'altezza */
    justify-content: flex-start; 
    align-items: center;
    min-height: 100vh;
    margin: 0;
    font-family: sans-serif;
    background-color: #fff;
    overflow: hidden;
    /* 1. REGOLA QUI: Spazio bianco totale sopra il titolo */
    padding-top: 5vh; 
    width: 100vw;
}

.text-header {
    text-align: center;
    padding: 0 20px;
    /* Margine dinamico: si adatta all'altezza dello schermo */
    margin-bottom: 5vh; 
    z-index: 10;
}

.text-header, .character {
    user-select: none;
    -webkit-user-select: none;
}

.title-orange {
    color: #ff7f00;
    font-size: clamp(1.8rem, 8vw, 2.5rem);
    font-weight: 800;
    margin-bottom: 10px;
}

.subtitle-black {
    color: #2b2b2b;
    /* Font più grande e corposo */
    font-size: clamp(1.1rem, 5vw, 1.6rem); 
    /* Aumentiamo la larghezza massima */
    max-width: 85%; 
    margin: 0 auto;
    font-weight: 550;
    /* Stringiamo lo spazio tra le righe per un look più moderno */
    line-height: 1.2;
}



.character {
    display: flex;
    flex-direction: column;
    align-items: center;
    /* 3. REGOLA QUI: Se vuoi alzare/abbassare solo l'omino rispetto al testo */
    margin-top: 0; 
    opacity: 0;
    position: relative;
    transition: opacity 0.5s ease;
}
/* --- PROPORZIONI ORIGINALI SCALABILI --- */
.head {
    /* 80px originali -> diventano relativi alla variabile --unit */
    width: calc(80 * var(--unit));
    height: calc(80 * var(--unit));
    border-radius: 50%;
    margin-bottom: calc(15 * var(--unit));
    position: relative;
    overflow: hidden;
    background-color: #cbd5e0;
    z-index: 1;
}

.body-shape {
    /* 130px x 170px originali -> scalano mantenendo il rapporto */
    width: calc(130 * var(--unit));
    height: calc(170 * var(--unit));
    /* Anche il raggio dei bordi deve scalare per non sembrare troppo tondo o troppo squadrato */
    border-radius: calc(45 * var(--unit)) calc(45 * var(--unit)) calc(30 * var(--unit)) calc(30 * var(--unit));
    position: relative;
    overflow: hidden;
    background-color: #cbd5e0;
    z-index: 1;
}

/* Mattoncini interni: rimangono in % così non sbagliano mai posizione */
.brick {
    position: absolute;
    z-index: 2;
}

/* --- LE TUE POSIZIONI E COLORI ORIGINALI --- */
.h1 { width: 50%; height: 100%; left: 0; top: 0; background-color: #00A3FF; transform: translateX(-100vw); }
.h2 { width: 50%; height: 100%; right: 0; top: 0; background-color: #FF0000; transform: translateX(100vw); }

.b1 { width: 60%; height: 33%; left: 0; top: 0; background-color: #FFEA00; border-bottom: 1px solid rgba(0,0,0,0.1); border-right: 1px solid rgba(0,0,0,0.1); transform: translateX(-100vw); }
.b2 { width: 40%; height: 33%; right: 0; top: 0; background-color: #07d333; border-bottom: 1px solid rgba(0,0,0,0.1); transform: translateX(100vw); }
.b3 { width: 40%; height: 34%; left: 0; top: 33%; background-color: #FF8000; border-bottom: 1px solid rgba(0,0,0,0.1); border-right: 1px solid rgba(0,0,0,0.1); transform: translateX(-100vw); }
.b4 { width: 60%; height: 34%; right: 0; top: 33%; background-color: #FF0051; border-bottom: 1px solid rgba(0,0,0,0.1); transform: translateX(100vw); }
.b5 { width: 100%; height: 33%; bottom: 0; left: 0; background-color: #9D00FF; transform: translateY(100vh); }

/* --- ANIMAZIONI --- */
/* 1. Base (b5): inizia a 0.2s, finisce a 0.8s */
.character.animate .b5 { 
    animation: flyInBottom 0.6s cubic-bezier(0.25, 1, 0.5, 1) 0.2s forwards; 
}

/* 2. Addome (b3, b4): finisce a ~1.6s */
.character.animate .b3 { 
    animation: flyInLeft 0.6s cubic-bezier(0.25, 1, 0.5, 1) 0.6s forwards; 
}
.character.animate .b4 { 
    animation: flyInRight 0.6s cubic-bezier(0.25, 1, 0.5, 1) 0.9s forwards; 
}

/* 3. Spalle/Petto (b1, b2): finisce a ~2.2s */
.character.animate .b1 { 
    animation: flyInLeft 0.6s cubic-bezier(0.25, 1, 0.5, 1) 1.3s forwards; 
}
.character.animate .b2 { 
    animation: flyInRight 0.6s cubic-bezier(0.25, 1, 0.5, 1) 1.6s forwards; 
}

/* 4. Testa (h1, h2): l'ultimo pezzo finisce esattamente a 2.1s + 0.6s = 2.7s */
.character.animate .h1 { 
    animation: flyInLeft 0.6s cubic-bezier(0.25, 1, 0.5, 1) 1.9s forwards; 
}
.character.animate .h2 { 
    animation: flyInRight 0.6s cubic-bezier(0.25, 1, 0.5, 1) 2.1s forwards; 
}


@keyframes flyInLeft { 0% { transform: translateX(-100vw); } 100% { transform: translateX(0); } }
@keyframes flyInRight { 0% { transform: translateX(100vw); } 100% { transform: translateX(0); } }
@keyframes flyInBottom { 0% { transform: translateY(100vh); } 100% { transform: translateY(0); } }

.eccoti-button {
    position: fixed; /* Use fixed to keep it at the bottom of the iframe */
    bottom: 30px;
    left: 0;
    width: 100%;
    text-align: center;
    font-family: sans-serif;
    font-size: 18px;
    font-weight: bold;
    color: #2b2b2b;
    text-transform: uppercase;
    letter-spacing: 1px;
    cursor: pointer;
    margin: 0;
    z-index: 2000;
}

.eccoti-hidden { opacity: 0; pointer-events: none; }

@keyframes eccotiSlideUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}
.eccoti-fade { animation: eccotiSlideUp 0.8s ease-out forwards; }

@keyframes eccotiPulse {
    0% { opacity: 1; }
    50% { opacity: 0.5; }
    100% { opacity: 1; }
}
.eccoti-pulse { animation: eccotiPulse 1.5s infinite; }

@media (max-width: 480px) {
    .eccoti-button { bottom: 20px; font-size: 16px; }
}

/* --- SMARTPHONE STYLES (SPECCHIATO) --- */
.smartphone {
    position: absolute;
    width: calc(45 * var(--unit)); 
    height: calc(85 * var(--unit));
    background-color: #1a1a1a; 
    border-radius: calc(6 * var(--unit));
    bottom: 20%; 
    left: 100%; 
    transform: translateX(-50%) translateY(100vh) rotate(15deg); 
    z-index: 10;
    box-shadow: 2px 2px 10px rgba(0,0,0,0.2);
    overflow: visible; 
}

/* --- LUCE AZZURRA SOTTILE E DISCRETA --- */
.smartphone::after {
    content: "";
    position: absolute;
    top: 15%;
    bottom: 15%;
    left: 0; 
    width: calc(10 * var(--unit)); 
    background: linear-gradient(to left, 
        rgba(0, 180, 255, 0.8) 0%, 
        transparent 100%);
    filter: blur(calc(3 * var(--unit)));
    transform: translateX(-100%); 
    
    /* Stato iniziale: invisibile */
    opacity: 0;
    z-index: -1; 
    /* Prepariamo la transizione: durerà 0.4s con 1s di ritardo */
    transition: opacity 0.4s ease 1s;
}


.character.animate .smartphone::after {
    opacity: 1;
}
/* --- ANIMAZIONI --- */
.character.animate .smartphone {
    animation: phoneFlyIn 1s cubic-bezier(0.25, 1, 0.5, 1) 0s forwards;
}

.camera-iphone {
    position: absolute;
    top: calc(6 * var(--unit));
    right: calc(6 * var(--unit));
    /* Dimensioni ridotte */
    width: calc(14 * var(--unit));
    height: calc(14 * var(--unit));
    /* Colore metallico */
    background-color: #37393b; 
    /* Angoli smussati proporzionali */
    border-radius: calc(4 * var(--unit)); 
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 11;
    box-shadow: inset 0 0 2px rgba(0,0,0,0.2);
}

/* Lente interna più piccola */
.camera-iphone::after {
    content: "";
    width: calc(8 * var(--unit));
    height: calc(8 * var(--unit));
    background-color: #1a1a1a;
    border-radius: 50%;
}

@keyframes phoneFlyIn {
    0% { transform: translateX(-50%) translateY(100vh) rotate(15deg); }
    100% { transform: translateX(-50%) translateY(0) rotate(15deg); }
}

/* --- ANIMAZIONI DI USCITA --- */

/* Classe che applicheremo al contenitore principale o al body per coordinare */
.page-exit-active .text-header {
    opacity: 0;
    transform: scale(0.9);
    transition: opacity 0.5s ease, transform 0.5s ease;
}

.page-exit-active .character {
    opacity: 0;
    /* Sposta l'omino e il telefono verso sinistra fuori dallo schermo */
    transform: translateX(-100vw);
    transition: opacity 0.5s ease, transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.page-exit-active .eccoti-button {
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none; /* Impedisce click multipli durante l'uscita */
}