/* RESET & BASE */
html { scroll-behavior: smooth; scroll-padding-top: 180px; }
body { 
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif; 
    background-color: #f5f5f5 !important; 
    margin: 0; 
    padding: 0; 
    user-select: none; 
    color: #333; 
    overflow-x: hidden;
}

/* HEADER FISSO - ALTEZZA BLOCCATA PER ALLINEARE LA RIGA OVUNQUE */
header { 
    position: fixed; 
    top: 0; 
    width: 100%; 
    background: rgba(245, 245, 245, 0.98) !important;
    text-align: center; 
    padding: 40px 0 20px 0; 
    height: 180px !important; 
    border-bottom: 1px solid rgba(0,0,0,0.03) !important; 
    z-index: 1000;
    transition: all 0.4s ease;
    margin: 0;
}

header.scrolled { 
    padding: 15px 0 10px 0; 
    height: 110px !important; 
    background: rgba(245, 245, 245, 0.99) !important; 
    box-shadow: 0 2px 10px rgba(0,0,0,0.02) !important; 
}

.logo-container img { max-width: 450px; width: 100%; height: auto; cursor: pointer; transition: all 0.4s ease; }
header.scrolled .logo-container img { max-width: 250px; }

nav { margin-top: 20px; transition: 0.3s; }
header.scrolled nav { margin-top: 5px; }

/* COLORE MENU RIPRISTINATO A GRIGIO #888 */
nav a { text-decoration: none; color: #888; text-transform: uppercase; letter-spacing: 3px; font-size: 0.75em; padding: 5px 15px; transition: 0.3s; cursor: pointer; }
nav a:hover { color: #000; }

.content-spacer { height: 280px; }

/* GALLERIA */
.gallery {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    grid-gap: 60px 40px; max-width: 1600px; margin: 0 auto; padding: 0 40px;
}
.gallery-item { text-align: center; opacity: 0; transform: translateY(30px); transition: all 0.8s ease-out; }
.gallery-item.visible { opacity: 1; transform: translateY(0); }
.image-container {
    aspect-ratio: 3 / 2; overflow: hidden; background-color: #f0f0f0; 
    cursor: zoom-in; margin-bottom: 20px; border: 1px solid #f0f0f0;
}
.gallery img { width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity 1s ease, transform 0.6s ease; }
.gallery img.loaded { opacity: 1; }
.gallery-item:hover img.loaded { transform: scale(1.03); }

/* COLORE DIDASCALIE RIPRISTINATO A GRIGIO #666 */
.caption-text { font-size: 0.95em; color: #666; letter-spacing: 0.5px; }

/* BIO */
.bio-section { max-width: 1000px; margin: 120px auto; padding: 0 40px; display: flex; align-items: center; gap: 60px; opacity: 0; transition: 1s; }
.bio-section.visible { opacity: 1; }
.bio-image { flex: 0 0 300px; height: 300px; border-radius: 50%; overflow: hidden; border: 1px solid #eee; }
.bio-image img { width: 100%; height: 100%; object-fit: cover; }
h2 { font-weight: 300; text-transform: uppercase; letter-spacing: 4px; color: #333; }
.bio-text p { line-height: 1.8; color: #555; font-size: 1.05em; }

/* LIGHTBOX & OVERLAY */
.overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.98); display: none; flex-direction: column; justify-content: center; align-items: center; z-index: 9999; }
.loader {
    border: 3px solid rgba(255, 255, 255, 0.1); border-radius: 50%; border-top: 3px solid #fff;
    width: 50px; height: 50px; animation: spin 1s linear infinite;
    position: absolute; display: none; z-index: 10001;
}
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }
.overlay img { max-width: 90%; max-height: 85%; object-fit: contain; cursor: pointer; opacity: 0; transition: opacity 0.4s ease; z-index: 10002; }
.overlay img.ready { opacity: 1; }
#overlayCaption { color: #fff; margin-top: 20px; font-size: 1.1em; letter-spacing: 1px; z-index: 10003; text-align: center; padding: 0 20px; }

.nav-btn { position: absolute; color: white; font-size: 40px; cursor: pointer; padding: 30px; top: 50%; transform: translateY(-50%); z-index: 10005; opacity: 0.5; transition: 0.3s; }
.nav-btn:hover { opacity: 1; }
.prev { left: 10px; } 
.next { right: 10px; }
.close-btn { position: absolute; top: 30px; right: 30px; color: white; font-size: 40px; cursor: pointer; z-index: 10006; }

.overlay img, .gallery img {
     user-select: none;
     -webkit-user-drag: none;
     -webkit-touch-callout: none;
}

/* FOOTER CONTATTI */
footer { text-align: center; padding: 120px 0 80px 0; background: transparent !important; border-top: 1px solid rgba(0,0,0,0.05); margin-top: 120px;  }
footer h3 { font-weight: 300; text-transform: uppercase; letter-spacing: 4px; color: #333; font-size: 1em; margin-bottom: 40px; }
.footer-links { margin-bottom: 60px; display: flex; justify-content: center; gap: 70px; flex-wrap: wrap; }
.footer-links a { text-decoration: none; color: #777; font-size: 1.0em; letter-spacing: 1px; transition: 0.3s; display: flex; align-items: center; gap: 8px; }
.footer-links a i { font-size: 1.2em; }
.footer-links a:hover { color: #000; }
.copyright { font-size: 0.7em; color: #aaa; margin-top: 30px; text-transform: uppercase; letter-spacing: 2px; }

/* MEDIA QUERIES - CORRETTE */
@media (max-width: 768px) { 
    header { height: 140px !important; padding: 30px 0 15px 0 !important; }
    header.scrolled { height: 100px !important; }
    .gallery { grid-template-columns: 1fr; }
    .bio-section { flex-direction: column; text-align: center; }
    .nav-btn { font-size: 30px; padding: 20px; opacity: 0.4; }
    .footer-links { gap: 30px; }
}

@media (min-width: 769px) and (max-width: 1024px) {
    .gallery {
        grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
        grid-gap: 30px 20px;
    }
}

/* PULSANTE TORNA SU */
#backToTop {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 50px;
    height: 50px;
    background-color: rgba(0, 0, 0, 0.5);
    color: #fff;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    z-index: 999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.4s ease;
}
#backToTop.show { opacity: 1; visibility: visible; }
#backToTop:hover { background-color: #000; transform: translateY(-5px); }

@media (max-width: 768px) {
    #backToTop { width: 40px; height: 40px; bottom: 20px; right: 20px; }
}