:root {
    --anthracite: #2D2D2D;
    --white: #FFFFFF;
    --off-white: #F9F9F9;
    --dove-gray: #D6CEC3;
    --accent: #B2A698;
    --dark-section: #121212;
    --transition: all 0.4s cubic-bezier(0.165, 0.84, 0.44, 1);
    --env-base: #eed9c4; 
    --env-light: #fdf0e3;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Montserrat', sans-serif;
    color: var(--anthracite);
    background-color: var(--white);
    line-height: 1.6;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, .serif { font-family: 'Playfair Display', serif; }

.container { width: 100%; max-width: 1200px; margin: 0 auto; padding: 0 25px; }

/* --- NAVBAR --- */
nav {
    position: fixed; top: 0; left: 0; width: 100%; padding: 20px 0;
    background: transparent; 
    z-index: 1000; display: flex; justify-content: space-between; align-items: center;
    transition: var(--transition);
}

.nav-logo img { 
    height: 30px; width: auto; display: block; transition: var(--transition); 
    filter: brightness(0) invert(1); 
}
.nav-logo-text { 
    font-family: 'Playfair Display', serif; font-weight: 700; font-size: 1.2rem; 
    color: var(--white); text-decoration: none; display: none; transition: var(--transition);
}

.nav-links { display: flex; gap: 30px; }
.nav-links a { 
    text-decoration: none; color: rgba(255,255,255,0.9); font-size: 0.8rem; 
    text-transform: uppercase; letter-spacing: 1px; font-weight: 600; transition: color 0.3s ease; 
}
.nav-links a:hover { color: var(--white); text-shadow: 0 0 10px rgba(255,255,255,0.5); }

nav.scrolled { background: rgba(255, 255, 255, 0.98); padding: 15px 0; box-shadow: 0 5px 20px rgba(0,0,0,0.05); }
nav.scrolled .nav-logo img { filter: none; }
nav.scrolled .nav-logo-text { color: var(--anthracite); }
nav.scrolled .nav-links a { color: #555; text-shadow: none; }
nav.scrolled .nav-links a:hover { color: var(--accent); }

section { padding: 100px 0; position: relative; }

/* --- HERO & SLIDER --- */
#hero { height: 350vh; padding: 0; background: #000; }
.hero-bg-wrapper { position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; z-index: 1; overflow: hidden; }
.bg-slide { position: absolute; top: 0; left: 0; width: 100%; height: 100%; background-size: cover; background-position: center; opacity: 0; transform: scale(1.05); transition: opacity 1s ease, transform 1.5s ease; }
.bg-slide.active { opacity: 1; transform: scale(1); }
.bg-overlay { position: absolute; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0, 0, 0, 0.4); z-index: 2; }

/* --- BUSTA HERO ANIMATA --- */
.envelope-wrapper { position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 320px; height: 220px; perspective: 1000px; z-index: 100; }
.envelope { position: relative; width: 100%; height: 100%; background-color: var(--env-base); box-shadow: 0 15px 40px rgba(0,0,0,0.3); transition: background-color 0.8s ease; }
.envelope::before { content: ''; position: absolute; top: 0; left: 0; width: 0; height: 0; border-style: solid; border-width: 110px 160px 110px 160px; border-color: var(--env-light) transparent transparent transparent; z-index: 2; transition: border-color 0.8s ease; }
.envelope-front { position: absolute; bottom: 0; left: 0; width: 0; height: 0; border-style: solid; border-width: 110px 160px 110px 160px; border-color: transparent var(--env-base) var(--env-base) var(--env-base); z-index: 4; transition: border-color 0.8s ease; }

.flap { 
    position: absolute; top: 0; left: 0; width: 320px; height: 110px; 
    background-color: var(--env-base); background-image: linear-gradient(to bottom, rgba(0,0,0,0.06) 0%, transparent 100%);
    z-index: 5; transform-origin: top; transform: rotateX(0deg); clip-path: polygon(0 0, 100% 0, 50% 100%);
    transition: background-color 0.8s ease, transform 0.15s ease-out; 
}

.card-inner { 
    position: absolute; top: 30px; left: 20px; width: 280px; height: 180px; 
    background: white; z-index: 3; display: flex; align-items: center; justify-content: center; 
    flex-direction: column; padding: 20px; box-shadow: 0 4px 10px rgba(0,0,0,0.05); 
    transform: translateY(0); transition: transform 0.15s ease-out; 
}
.card-inner p { font-size: 1.2rem; color: var(--anthracite); text-align: center; line-height: 1.2; }

.scroll-hint { position: fixed; bottom: 30px; left: 50%; transform: translateX(-50%); text-align: center; color: white; animation: bounce 2s infinite; font-size: 0.8rem; letter-spacing: 2px; text-transform: uppercase; z-index: 101; text-shadow: 0 2px 4px rgba(0,0,0,0.5); transition: opacity 0.5s ease; }
@keyframes bounce { 0%, 20%, 50%, 80%, 100% {transform: translateY(0) translateX(-50%);} 40% {transform: translateY(-10px) translateX(-50%);} 60% {transform: translateY(-5px) translateX(-50%);} }

/* --- CONTENT TRANSITION --- */
.main-content { opacity: 0; transform: translateY(50px); transition: all 0.8s cubic-bezier(0.165, 0.84, 0.44, 1); background-color: var(--white); position: relative; z-index: 10; pointer-events: none; }
.main-content.visible { opacity: 1; transform: translateY(0); pointer-events: auto; }

/* --- INTRO SECTION --- */
.intro-text { text-align: center; max-width: 800px; margin: 0 auto; }
.intro-text h2 { font-size: 2.5rem; margin-bottom: 20px; color: var(--anthracite); }
.intro-text p { font-size: 1.1rem; color: #666; }

/* --- MODERN PORTFOLIO GALLERY --- */
.section-title { text-align: center; margin-bottom: 60px; }
.section-title h2 { font-size: 2.2rem; position: relative; display: inline-block; padding-bottom: 15px; }
.section-title h2::after { content: ''; position: absolute; bottom: 0; left: 50%; transform: translateX(-50%); width: 60px; height: 2px; background-color: var(--accent); }
.portfolio-grid { 
    display: flex; 
    flex-wrap: wrap; 
    justify-content: center; /* Questo centra il 4° elemento! */
    gap: 40px; 
}

.portfolio-card { 
    flex: 1 1 320px; 
    max-width: 360px; /* Evita che il 4° elemento diventi gigante occupando tutta la riga */
    width: 100%;
    position: relative; 
    height: 350px; 
    overflow: hidden; 
    cursor: pointer; 
    border-radius: 16px; 
    box-shadow: 0 15px 35px rgba(0,0,0,0.06); 
    transform: translateY(0); 
    transition: all 0.5s cubic-bezier(0.2, 0.8, 0.2, 1); 
}
.portfolio-card img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.8s ease; }
.portfolio-overlay { position: absolute; bottom: 0; left: 0; width: 100%; height: 60%; background: linear-gradient(to top, rgba(18, 18, 18, 0.9) 0%, rgba(18, 18, 18, 0) 100%); display: flex; flex-direction: column; align-items: center; justify-content: flex-end; opacity: 0; transition: var(--transition); padding: 40px 20px; text-align: center; }

.portfolio-card:hover { transform: translateY(-12px); box-shadow: 0 25px 50px rgba(0,0,0,0.15); }
.portfolio-card:hover img { transform: scale(1.08); }
.portfolio-card:hover .portfolio-overlay { opacity: 1; }

.portfolio-overlay h3 { font-family: 'Playfair Display'; font-weight: 700; font-size: 1.8rem; margin-bottom: 5px; color: var(--white); transform: translateY(20px); transition: transform 0.4s ease; }
.portfolio-overlay span { font-size: 0.85rem; text-transform: uppercase; letter-spacing: 2px; color: var(--accent); transform: translateY(20px); transition: transform 0.5s ease; }
.portfolio-card:hover h3, .portfolio-card:hover span { transform: translateY(0); }

/* --- FEATURES SECTION --- */
.features-section { background-color: var(--off-white); }
.features-flex { display: flex; align-items: center; flex-wrap: wrap; gap: 50px; }
.features-content { flex: 1; min-width: 300px; }
.features-content h2 { font-size: 2rem; margin-bottom: 25px; }
.features-list-wrapper { display: block; }
.feature-item { margin-bottom: 20px; display: flex; align-items: flex-start; gap: 15px; }
.feature-item i { color: var(--accent); margin-top: 5px; }
.mockup-container { flex: 1; min-width: 300px; display: flex; justify-content: center; align-items: center; }
.smartphone { width: 280px; height: 560px; background: #000; border: 8px solid #333; border-radius: 36px; position: relative; box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25); overflow: hidden; }
.smartphone-screen { background: #ece5dd; width: 100%; height: 100%; padding: 40px 15px 15px; display: flex; flex-direction: column; }
.wa-header { background: #075e54; height: 50px; width: 100%; position: absolute; top: 0; left: 0; padding: 10px; display: flex; align-items: center; color: white; font-size: 0.8rem; }
.wa-bubble { background: #dcf8c6; padding: 10px; border-radius: 8px; max-width: 90%; align-self: flex-end; margin-top: 20px; font-size: 0.8rem; box-shadow: 0 1px 2px rgba(0,0,0,0.1); position: relative; }
.wa-bubble::after { content: ''; position: absolute; right: -8px; top: 0; border-width: 8px 0 8px 8px; border-style: solid; border-color: #dcf8c6 transparent transparent transparent; }
.wa-preview { background: rgba(0,0,0,0.05); border-radius: 4px; margin-bottom: 8px; overflow: hidden; }
.wa-preview img { width: 100%; height: 120px; object-fit: cover; }
.wa-preview-text { padding: 8px; }
.wa-preview-text strong { display: block; margin-bottom: 2px; }
.wa-preview-text span { font-size: 0.7rem; color: #666; }

/* --- BUSTA PERSONALIZZATA (FRONTE LISCIO FEDRIGONI) --- */
.envelope-feature-section { background-color: var(--white); overflow: hidden; padding: 120px 0;}
.envelope-feature-flex { display: flex; align-items: center; flex-wrap: wrap-reverse; gap: 50px; }

.custom-envelope-wrapper { flex: 1; min-width: 300px; display: flex; justify-content: center; align-items: center; padding: 40px 0; }

.fedrigoni-envelope {
    width: 380px; height: 250px;
    background-color: #FDFBF7; 
    background-image: url('data:image/svg+xml;utf8,<svg viewBox="0 0 200 200" xmlns="http://www.w3.org/2000/svg"><filter id="noiseFilter"><feTurbulence type="fractalNoise" baseFrequency="0.85" numOctaves="3" stitchTiles="stitch"/></filter><rect width="100%" height="100%" filter="url(%23noiseFilter)" opacity="0.14"/></svg>');
    border-radius: 6px;
    box-shadow: 0 25px 50px -12px rgba(0,0,0,0.15), inset 0 0 30px rgba(214, 206, 195, 0.15);
    position: relative; overflow: hidden;
    display: flex; align-items: center; justify-content: center;
}

.typing-name-container {
    position: relative; z-index: 3; font-family: 'Playfair Display', serif; font-style: italic;
    font-size: 1.8rem; color: #4A4A4A; text-shadow: 0px 1px 1px rgba(255,255,255,0.9);
    padding-top: 0; 
}
.typing-cursor { border-right: 2px solid var(--accent); padding-right: 5px; animation: blink 0.8s infinite; }
@keyframes blink { 50% { border-color: transparent; } }

.note-luxury { font-size: 0.85rem; color: var(--accent); font-weight: 600; margin-top: 20px; font-style: italic; display: block; }

/* --- TIMELINE: COME FUNZIONA (FLOATING CARDS) --- */
.timeline-section { background-color: var(--off-white); padding: 80px 0 120px 0; }
.timeline-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 30px; position: relative; margin-top: 50px; }

.timeline-step { 
    position: relative; text-align: center; padding: 40px 20px; 
    background: var(--white); border-radius: 16px; 
    transition: transform 0.4s ease, box-shadow 0.4s ease; overflow: hidden; 
}
.timeline-step:hover { transform: translateY(-10px); box-shadow: 0 15px 30px rgba(0,0,0,0.05); }

.step-number { 
    position: absolute; top: -15px; right: -10px; 
    font-family: 'Playfair Display', serif; font-size: 8rem; font-weight: 900; 
    color: var(--accent); opacity: 0.08; line-height: 1; 
    transition: var(--transition); pointer-events: none; 
}
.timeline-step:hover .step-number { opacity: 0.15; transform: scale(1.05); }

.step-icon { font-size: 1.8rem; color: var(--anthracite); margin-bottom: 20px; position: relative; z-index: 2; }
.step-title { font-size: 1.15rem; font-weight: 700; margin-bottom: 15px; color: var(--anthracite); position: relative; z-index: 2; }
.step-desc { font-size: 0.9rem; color: #666; line-height: 1.6; position: relative; z-index: 2; }

/* --- PRICING SECTION --- */
.pricing-section { background-color: var(--white); }
.pricing-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 30px; }
.pricing-card { background: white; border: 1px solid #f0f0f0; padding: 50px 30px; border-radius: 16px; text-align: center; transition: var(--transition); display: flex; flex-direction: column; }
.pricing-card .btn { margin-top: auto; }
.pricing-card:hover { transform: translateY(-10px); box-shadow: 0 20px 40px rgba(0,0,0,0.05); border-color: transparent; }
.pricing-card.popular { border-color: var(--accent); box-shadow: 0 10px 30px rgba(178, 166, 152, 0.2); position: relative; }
.popular-badge { position: absolute; top: -15px; left: 50%; transform: translateX(-50%); background: var(--accent); color: white; padding: 6px 20px; border-radius: 20px; font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 1px; white-space: nowrap; }
.price { font-size: 3rem; font-weight: 600; margin-bottom: 25px; color: var(--anthracite); }
.pricing-features { list-style: none; margin-bottom: 30px; text-align: left; }
.pricing-features li { margin-bottom: 12px; font-size: 0.95rem; color: #555; display: flex; align-items: center; gap: 10px; }
.pricing-features li i { color: var(--accent); font-size: 0.8rem; min-width: 15px;}

/* Stile per i link dentro la tabella prezzi */
.pricing-features li a { transition: color 0.3s ease; }
.pricing-features li a:hover { color: var(--accent); }

.btn { display: inline-block; padding: 14px 35px; background: var(--anthracite); color: white; text-decoration: none; border-radius: 8px; font-weight: 600; font-size: 0.9rem; transition: var(--transition); border: none; cursor: pointer; }
.btn-outline { background: transparent; border: 1px solid var(--anthracite); color: var(--anthracite); }
.btn:hover { opacity: 0.9; transform: scale(1.03); }

/* --- EXTRA SERVICES SECTION --- */
.extra-service-section { background-color: var(--off-white); padding: 80px 0; border-top: 1px solid #eaeaea; }

/* --- CONTACT SECTION & ANIMATION --- */
.contact-section { background-color: var(--dark-section); color: var(--white); overflow: hidden; padding-bottom: 50px; }
.contact-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 100px; align-items: center; position: relative; z-index: 2; }
.contact-info h2 { font-size: 3rem; margin-bottom: 30px; line-height: 1.1; background: linear-gradient(to right, #fff, var(--accent)); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }

.contact-form-wrapper { position: relative; min-height: 520px; }
.contact-form { 
    background: rgba(255, 255, 255, 0.03); padding: 50px; border: 1px solid rgba(255, 255, 255, 0.05); 
    border-radius: 16px; backdrop-filter: blur(10px); transition: all 0.5s ease;
    position: relative; overflow: hidden; 
}

.form-loading-overlay {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(18, 18, 18, 0.6); backdrop-filter: blur(8px);
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    opacity: 0; pointer-events: none; transition: opacity 0.5s ease; z-index: 20;
}
.form-loading-overlay.active { opacity: 1; pointer-events: auto; }

.loading-rings { position: relative; width: 60px; height: 40px; margin-bottom: 20px; display: flex; justify-content: center; align-items: center; }
.loading-ring { position: absolute; width: 35px; height: 35px; border: 2px solid var(--accent); border-radius: 50%; }
.loading-ring:nth-child(1) { left: 5px; animation: ringMerge1 2s ease-in-out infinite alternate; }
.loading-ring:nth-child(2) { right: 5px; animation: ringMerge2 2s ease-in-out infinite alternate; }

@keyframes ringMerge1 { 0% { transform: translateX(0); opacity: 0.6; } 100% { transform: translateX(12px); opacity: 1; } }
@keyframes ringMerge2 { 0% { transform: translateX(0); opacity: 0.6; } 100% { transform: translateX(-12px); opacity: 1; } }

.loading-text { color: var(--white); font-size: 1.1rem; letter-spacing: 2px; animation: pulseText 2s ease-in-out infinite alternate; }
@keyframes pulseText { 0% { opacity: 0.5; } 100% { opacity: 1; } }

#formSuccess { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); text-align: center; width: 100%; display: none; opacity: 0; }
.success-icon { font-size: 4rem; color: var(--accent); margin-bottom: 20px; animation: floatIcon 3s ease-in-out infinite; }
@keyframes floatIcon { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-15px); } }
@keyframes flyIn { 0% { transform: translate(-50%, 50px); opacity: 0; } 100% { transform: translate(-50%, -50%); opacity: 1; } }

.form-group { position: relative; margin-bottom: 35px; }
.form-group input, .form-group select, .form-group textarea { 
    width: 100%; background: transparent; border: none; border-bottom: 1px solid rgba(255, 255, 255, 0.2); 
    padding: 10px 0; color: white; font-family: inherit; font-size: 1rem; transition: var(--transition); 
}

.form-group > label { position: absolute; top: 10px; left: 0; color: rgba(255, 255, 255, 0.5); pointer-events: none; transition: var(--transition); }
.form-group input:focus ~ label, .form-group input:valid ~ label, .form-group textarea:focus ~ label, .form-group textarea:not(:placeholder-shown) ~ label { top: -20px; font-size: 0.8rem; color: var(--accent); }

.form-group select { color: rgba(255, 255, 255, 0.8); cursor: pointer; }
.form-group select option { background-color: var(--anthracite); color: var(--white); }

/* --- CALENDARIO MAGICO CUSTOM --- */
.calendar-wrapper { margin-bottom: 35px; position: relative; }
.calendar-label { color: rgba(255, 255, 255, 0.5); font-size: 0.8rem; margin-bottom: 10px; display: block; transition: var(--transition); }
.calendar-wrapper.has-date .calendar-label { color: var(--accent); }

.custom-calendar {
    background: rgba(0, 0, 0, 0.15); border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px; padding: 15px; user-select: none;
}
.calendar-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 15px; color: var(--white); font-weight: 600; font-size: 0.9rem;}
.calendar-header button { background: none; border: none; color: rgba(255,255,255,0.6); cursor: pointer; padding: 5px 10px; font-size: 1rem; transition: color 0.3s; }
.calendar-header button:hover { color: var(--accent); }

.calendar-weekdays { display: grid; grid-template-columns: repeat(7, 1fr); text-align: center; color: rgba(255,255,255,0.4); font-size: 0.75rem; margin-bottom: 10px; font-weight: 600; }
.calendar-days { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; }

.calendar-day { 
    aspect-ratio: 1; display: flex; align-items: center; justify-content: center; 
    color: white; cursor: pointer; border-radius: 50%; font-size: 0.85rem; 
    transition: all 0.3s ease; position: relative; 
}
.calendar-day:hover:not(.empty) { background: rgba(255, 255, 255, 0.1); }
.calendar-day.selected { background: var(--accent); color: var(--anthracite); font-weight: 700; }
.calendar-day.selected::after {
    content: '\f004'; font-family: 'Font Awesome 6 Free'; font-weight: 900;
    position: absolute; top: -4px; right: -4px; color: #ff5e62; font-size: 0.8rem;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3));
    animation: popHeart 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}
.calendar-day.empty { cursor: default; }
@keyframes popHeart { 0% { transform: scale(0); } 50% { transform: scale(1.3); } 100% { transform: scale(1); } }

.btn-submit { width: 100%; background: var(--accent); color: var(--white); padding: 18px; border-radius: 8px; font-size: 1rem; letter-spacing: 2px; text-transform: uppercase; border: none; cursor: pointer; transition: all 0.3s ease; font-weight: 600; }

/* --- FOOTER MODIFICATO --- */
footer { background-color: var(--dark-section); padding: 40px 0; text-align: center; border-top: 1px solid rgba(255, 255, 255, 0.05); color: rgba(255, 255, 255, 0.4); font-size: 0.8rem; letter-spacing: 1px; line-height: 1.8; }
.footer-links { margin-top: 15px; display: flex; justify-content: center; gap: 20px; }
.footer-links a { color: inherit; text-decoration: none; transition: color 0.3s ease; }
.footer-links a:hover { color: var(--accent); }

/* --- WHATSAPP FLOATING BUTTON --- */
.whatsapp-fab {
    position: fixed; bottom: 30px; right: 30px; background: #25D366; color: white;
    width: 60px; height: 60px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
    font-size: 30px; box-shadow: 0 10px 20px rgba(37,211,102,0.3); z-index: 1000;
    transition: transform 0.3s ease, box-shadow 0.3s ease; text-decoration: none;
}
.whatsapp-fab:hover { transform: scale(1.1); box-shadow: 0 12px 25px rgba(37,211,102,0.4); color: white; }

@media (max-width: 991px) { 
    .contact-grid { grid-template-columns: 1fr; gap: 50px; } 
    .features-flex, .envelope-feature-flex { flex-direction: column; text-align: center; } 
    .features-list-wrapper { display: inline-block; text-align: left; margin: 0 auto; } 
    .feature-item { justify-content: flex-start; text-align: left; } 
    .contact-form-wrapper { min-height: 350px; } 
    .fedrigoni-envelope { width: 320px; height: 210px; }
    .typing-name-container { font-size: 1.4rem; padding-top: 0; }
}
@media (max-width: 768px) { 
    section { padding: 60px 0; } .container { padding: 0 20px; } 
    .nav-links { display: none; } .nav-logo img { height: 30px; } 
    .intro-text h2, .section-title h2 { font-size: 1.8rem; } 
    .portfolio-grid, .pricing-grid { grid-template-columns: 1fr; } 
    .portfolio-card { height: 240px; } 
    .contact-form { padding: 30px; } 
    .contact-info h2 { font-size: 2.2rem !important; } 
    .timeline-grid { grid-template-columns: 1fr; gap: 30px; margin-top: 30px;}
    .timeline-step { padding: 30px 15px; }
    .whatsapp-fab { bottom: 20px; right: 20px; width: 50px; height: 50px; font-size: 25px; }
}
@media (max-width: 380px) { .envelope-wrapper { transform: translate(-50%, -50%) scale(0.85); } .smartphone { width: 260px; height: 520px; } }
html { scroll-behavior: smooth; }