body {
    margin: 0;
    background-color: black;
    color: white;
    font-family: "Century Gothic", sans-serif;
    font-weight: 300;
    letter-spacing: 1px;
    overflow-x: hidden;
    overflow-y: auto;
}

#background {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    z-index: 0;
    pointer-events: none;
    filter: brightness(1.0) contrast(1.0) saturate(2.0);
}

.main_page {
    position: relative;
    z-index: 1;
    min-height: 100vh;
    overflow: visible;
}

body.is-leaving .main_page {
    opacity: 0;
    transition: opacity 0.45s ease;
}

body.is-leaving .header-nav {
    transform: translateY(-100%);
    transition: transform 0.45s ease;
}

/* HEADER-NAV */
.header-nav {
    position: relative;
    z-index: 20;
    background: auto;
    background-color: rgba(255, 255, 255, 0.482);
    backdrop-filter: blur(3px);
    height: 150px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 30px;
    padding: 0 30px;
    box-sizing: border-box;
    animation: slideDown 0.8s ease-out;
}

#logo_header {
    display: block;
    width: 200px;
    height: auto;
    border-radius: 20px;
    margin-left: 100px;
    flex-shrink: 0;
}

/* NAVIGATION */
.header-nav nav ul {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    gap: 30px;
    align-items: center;
}

.header-nav nav li {
    margin: 0;
}

.inactiveLink {
    pointer-events: auto;
    cursor: pointer;
}

.services-menu {
    position: relative;
}

.services-submenu {
    position: absolute;
    top: 100%;
    right: 0;
    z-index: 10;
    display: grid !important;
    grid-template-columns: 1fr;
    gap: 2px;
    width: min(360px, calc(100vw - 32px));
    margin: 0;
    min-height: 225px;
    padding: 10px;
    box-sizing: border-box;
    border: 1px solid rgb(0, 0, 39);
    border-radius: 12px;
    background-color: rgb(0, 0, 39);
    backdrop-filter: blur(8px);
    box-shadow: 0 18px 45px rgba(0, 0, 0, 0.3);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(-8px);
    transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s ease;
}

.services-menu:hover .services-submenu,
.services-menu:focus-within .services-submenu {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateY(0);
}

.services-submenu li {
    margin: 0 !important;
}

.header-nav nav .services-submenu a {
    display: block;
    color: lightskyblue;
    padding: 15px 5px;
    border-radius: 7px;
    font-size: 0.86rem;
    line-height: 0.3;
    text-align: center;
    margin-bottom: -30px;
}

.header-nav nav .services-submenu a:hover,
.header-nav nav .services-submenu a:focus-visible {
    background: rgba(184, 228, 231, 0.16);
    opacity: 1;
    transform: none;
}

.services-submenu li:last-child a {
    margin-bottom: 0;
}

@media (max-width: 800px) {
    .services-menu {
        position: static;
    }

    .services-submenu {
        top: 100%;
        left: 50%;
        right: auto;
        grid-template-columns: 1fr;
        width: min(340px, calc(100vw - 32px));
        transform: translate(-50%, -8px);
    }

    .services-menu:hover .services-submenu,
    .services-menu:focus-within .services-submenu {
        transform: translate(-50%, 0);
    }
}

.header-nav nav a {
    text-decoration: none;
    color: white;
    font-size: 1rem;
    transition: opacity 0.3s ease, transform 0.3s ease;
    display: block;
}

.header-nav nav a:hover {
    opacity: 0.7;
    transform: scale(1.05);
}

.nav {
    display: flex;
    align-items: center;
    margin-right: 50px;
}

/* CONTENT CONTENITORE PRINCIPALE */
.content {
    position: relative;
    min-height: calc(100vh - 150px);
    overflow: visible;
    display: flex;
    align-items: center;       
    justify-content: flex-start; 
    width: 100vw;
    margin-left: calc(-50vw + 50%); 
    padding-left: 0 !important;     
    box-sizing: border-box;
}

/* LA MANO INCOLLATA AL BORDO SINISTRO */
#hand {
    display: block;
    width: min(750px, 55vw);   
    height: auto;
    object-fit: contain;
    margin-left: 0;            
    z-index: 1;
    flex-shrink: 0;            
    animation: slideInRight 1s ease-out;
    -webkit-mask-image: linear-gradient(to right, rgba(0,0,0,0) 0%, rgba(0,0,0,1) 15%);
    mask-image: linear-gradient(to right, rgba(0,0,0,0) 0%, rgba(0,0,0,1) 15%);
}
/* LO SLOGAN AFFIANCATO A DESTRA */
.slogan-box {
    flex-grow: 1;              
    max-width: 750px;          
    margin: 0 auto;            
    padding: 0 30px;           
    text-align: center;
    opacity: 0;
    animation: fadeIn 1.2s ease-in 0.3s forwards;
}

.slogan-box h2 {
    font-size: 25px; 
    line-height: 1.3;
    margin: 0;
    font-weight: 600;
}

#quote {
    font-size: 18px !important; 
    line-height: 1.4;
    margin-top: 8px;
    font-style: italic;
}

.slogan-box p {
    max-width: 700px;  
    margin: 1rem auto 0;
    text-align: center;
    font-size: 18px !important; 
    line-height: 1.5;
}

.typewriter {
    font-size: 18px !important;
}

/* CONFIGURAZIONE STRUTTURA DELLE PAGINE (INALTERATO) */
.header-nav {
    padding-inline: max(30px, calc((100vw - 1320px) / 2 + 30px));
}

.main_page > .content,
.chi_siamo_page > .content,
.contatti_page > .content,
.dove_siamo_page > .content,
.servizi_page > .content {
    width: min(1320px, 100%);
    margin-inline: auto;
}

.chi-siamo-layout,
.contact-layout,
.services-carousel {
    width: min(1180px, 100%);
    max-width: 1320px;
}

/* ----------------------------------------------------
   RESPONSIVE SMARTPHONE E TABLET (FINO A 800px)
------------------------------------------------------- */
@media (max-width: 800px) {
    .header-nav {
        min-height: 120px;
        height: auto;
        flex-direction: column;
        justify-content: center;
        gap: 18px;
        padding: 20px 16px;
    }

    #logo_header {
        width: min(180px, 70vw);
        margin-left: 0;
    }

    .nav {
        width: 100%;
        justify-content: center;
        margin-right: 0;
    }

    .header-nav nav ul {
        flex-wrap: wrap;
        justify-content: center;
        gap: 12px 18px;
    }

    .header-nav nav a {
        font-size: 0.92rem;
    }

    .services-submenu {
        top: 100%;
        left: 50%;
        right: auto;
        width: min(340px, calc(100vw - 32px));
        transform: translate(-50%, -8px);
    }

    .services-menu {
        position: static;
    }

    .services-menu:hover .services-submenu,
    .services-menu:focus-within .services-submenu,
    .services-menu.is-open .services-submenu {
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
        transform: translate(-50%, 0);
    }

/* 🎯 FIX CONTENUTO INDEX: Mano sopra e Scritte sotto centrate */
    .content {
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        justify-content: flex-start !important;
        gap: 0 !important; /* Eliminato del tutto il gap */
        padding: 10px 16px 0 !important; /* Azzerato il padding inferiore */
        width: 100% !important;
        margin-left: 0 !important;
        min-height: auto !important; /* Impedisce al contenitore di allungarsi da solo */
    }

    #hand {
        width: min(420px, 90vw) !important; /* Lievemente ridotto per recuperare altezza verticale */
        height: auto !important;
        max-height: 40vh !important; /* Impedisce all'immagine di occupare troppi pixel in altezza */
        object-fit: contain !important;
        align-self: center !important;
        margin: 0 auto !important;
    }

    /* SLOGAN BOX & TYPEWRITER MOBILE */
    .slogan-box {
        flex-grow: 0 !important; /* FONDAMENTALE: evita che il box si espanda verticalmente */
        width: 100% !important;
        max-width: 100% !important;
        margin: 5px auto 0 !important; /* Margine minimo sopra */
        padding: 0 !important;
        text-align: center !important;
    }

    .slogan-box h2,
    #quote,
    .slogan-box p,
    .typewriter {
        text-align: center !important;
        font-size: 12px !important;
        margin-top: 2px !important;
        margin-bottom: 2px !important;
    }

    /* FOOTER MOBILE COMPATTO */
    footer {
        margin-top: 0 !important; /* Rimuove eventuali margini superiori del footer */
        padding-top: 15px !important; /* Compatta la parte alta del footer */
    }
} /* <--- CHIUSURA MEDIA QUERY MANCANTE */

/* ==========================================
   ANIMATIONS (GLOBALI)
   ========================================== */
.typewriter::after {
    content: "|";
    animation: blink 0.7s infinite;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

@keyframes slideDown {
    from {
        transform: translateY(-150px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes slideInRight {
    from {
        transform: translateX(-300px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

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