/* DESIGN SYSTEM VARIABLES */
:root {
    /* Monochromatic Palette */
    --color-bg: #FFFFFF;
    --color-bg-alt: #FAFAFA;
    --color-text-primary: #000000;
    --color-text-secondary: #666666;
    --color-text-muted: #999999;
    --color-border: #E5E5E5;
    --color-input-bg: #F9F9F9;
    --color-black-pure: #000000;
    --color-white-pure: #FFFFFF;
    
    /* Typography */
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    
    /* Shapes */
    --radius: 12px;
    --radius-lg: 24px;
    
    /* Spacing */
    --space-sm: 1rem;
    --space-md: 2rem;
    --space-lg: 4rem;
    --space-xl: 8rem;
    
    /* Effects */
    --glass-bg: rgba(255, 255, 255, 0.75);
    --glass-blur: blur(20px);
}

/* RESET & BASE */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-family);
    background-color: var(--color-bg);
    color: var(--color-text-primary);
    line-height: 1.6;
    overflow-x: hidden;
}

body.no-scroll {
    overflow: hidden;
}

h1, h2, h3, h4, strong {
    font-weight: 700;
    letter-spacing: -0.03em;
    line-height: 1.2;
}

a {
    text-decoration: none;
    color: inherit;
    transition: color 0.3s ease;
}

.container {
    max-width: 1440px;
    margin: 0 auto;
    padding: 0 5%;
}

/* APPLE PRELOADER */
#apple-preloader {
    position: fixed;
    inset: 0;
    background-color: var(--color-bg);
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: opacity 0.8s cubic-bezier(0.25, 1, 0.5, 1);
}

#apple-preloader.hide {
    opacity: 0;
    pointer-events: none;
}

.preloader-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
    width: 100%;
    max-width: 250px;
}

.preloader-logo {
    font-size: 2rem;
    font-weight: 800;
    letter-spacing: -0.05em;
    color: var(--color-text-primary);
}

.loading-bar {
    width: 100%;
    height: 2px;
    background-color: var(--color-border);
    border-radius: 2px;
    overflow: hidden;
}

.loading-progress {
    width: 0%;
    height: 100%;
    background-color: var(--color-black-pure);
    transition: width 1.5s cubic-bezier(0.25, 1, 0.5, 1);
}

/* FIAMMETTA SPLASH */
#fiammetta-splash {
    position: fixed;
    inset: 0;
    background: var(--color-bg) url('../fiammetta.png') no-repeat center center;
    background-size: clamp(150px, 20vw, 250px);
    z-index: 9998; /* Under preloader, over everything else */
    opacity: 1;
    transition: opacity 1.2s cubic-bezier(0.25, 1, 0.5, 1), transform 1.2s cubic-bezier(0.25, 1, 0.5, 1);
}

#fiammetta-splash.hide {
    opacity: 0;
    transform: scale(1.05); /* Slight push back effect while fading */
    pointer-events: none;
}

/* APPLE STYLE REVEAL ANIMATIONS */
.reveal {
    opacity: 0;
    transform: translateY(30px) scale(0.98);
    transition: opacity 0.8s cubic-bezier(0.16, 1, 0.3, 1), transform 0.8s cubic-bezier(0.16, 1, 0.3, 1);
    will-change: opacity, transform;
}

.reveal.active {
    opacity: 1;
    transform: translateY(0) scale(1);
}

/* BUTTONS */
button, .btn-primary, .btn-outline, .btn-link {
    font-family: var(--font-family);
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn-primary {
    background-color: var(--color-black-pure);
    color: var(--color-white-pure);
    border: none;
    padding: 1rem 2rem;
    border-radius: var(--radius);
}

.btn-primary:hover {
    background-color: #333;
    transform: scale(1.02);
}

.btn-outline {
    background-color: transparent;
    color: var(--color-text-primary);
    border: 1px solid var(--color-border);
    padding: 1rem 2rem;
    border-radius: var(--radius);
}

.btn-outline:hover {
    border-color: var(--color-black-pure);
}

.btn-link {
    background-color: transparent;
    border: none;
    color: var(--color-text-secondary);
    text-decoration: underline;
    padding: 1rem;
}

.btn-link:hover {
    color: var(--color-black-pure);
}

/* HEADER (Glassmorphism) */
.glass-header {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 1000;
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 80px;
}

.logo {
    /* Richiesto: Logo più grande */
    font-size: 1.75rem; 
    letter-spacing: -0.06em;
    font-weight: 800;
}

.desktop-nav {
    display: flex;
    gap: 2.5rem;
}

.desktop-nav a {
    font-weight: 500;
    font-size: 0.95rem;
    color: var(--color-text-secondary);
}

.desktop-nav a:hover {
    color: var(--color-text-primary);
}

.mobile-menu-btn {
    display: none;
    background: none;
    border: none;
    color: var(--color-text-primary);
    cursor: pointer;
}

/* HERO SECTION */
.hero {
    padding-top: calc(80px + var(--space-xl));
    padding-bottom: var(--space-xl);
}

.hero-content {
    max-width: 1000px;
}

.hero-title {
    font-size: clamp(3rem, 6vw, 5.5rem);
    margin-bottom: 1.5rem;
}

.hero-subtitle {
    font-size: clamp(1.125rem, 2vw, 1.5rem);
    color: var(--color-text-secondary);
    max-width: 800px;
    margin-bottom: var(--space-xl);
}

/* METRICS */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1.5rem;
}

@media (max-width: 900px) {
    .metrics-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 500px) {
    .metrics-grid {
        grid-template-columns: 1fr;
    }
}

.metric-item {
    background-color: var(--color-bg);
    border: 1px solid rgba(0,0,0,0.06);
    border-radius: var(--radius-lg);
    padding: 2rem 1.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    transition: transform 0.4s cubic-bezier(0.2, 0, 0, 1), box-shadow 0.4s cubic-bezier(0.2, 0, 0, 1);
    box-shadow: 0 4px 20px rgba(0,0,0,0.02);
}

.metric-item:hover {
    transform: translateY(-4px) scale(1.02);
    box-shadow: 0 12px 30px rgba(0,0,0,0.08);
}

.metric-number {
    display: flex;
    align-items: baseline;
    justify-content: center;
    margin-bottom: 0.5rem;
}

.metric-value {
    font-size: clamp(2rem, 3vw, 2.5rem);
    font-weight: 800;
    letter-spacing: -0.05em;
    line-height: 1;
    color: var(--color-black-pure);
}

.metric-symbol {
    font-size: clamp(1.25rem, 2vw, 1.5rem);
    font-weight: 700;
    color: var(--color-black-pure);
    margin-left: 0.1rem;
}

.metric-label {
    color: var(--color-text-secondary);
    font-size: 1rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.metric-desc {
    color: var(--color-text-muted);
    font-size: 0.85rem;
    margin-top: 0.25rem;
    max-width: 200px;
}

/* COMMON SECTION STYLES */
.section-padding {
    padding: var(--space-xl) 0;
}

.bg-alt {
    background-color: var(--color-bg-alt);
}

.section-pretitle {
    display: block;
    color: var(--color-text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-size: 0.85rem;
    margin-bottom: 0.5rem;
}

.section-title {
    font-size: clamp(2rem, 4vw, 3rem);
    margin-bottom: 1rem;
}

.section-subtitle {
    font-size: 1.25rem;
    color: var(--color-text-secondary);
    margin-bottom: var(--space-lg);
    max-width: 700px;
}

/* CHI SIAMO (ABOUT) */
.about-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-lg);
    align-items: center;
}

.about-text .lead {
    font-size: 1.25rem;
    margin-bottom: 1.5rem;
    color: var(--color-text-primary);
}

.about-text p {
    color: var(--color-text-secondary);
    margin-bottom: 1.5rem;
}

.about-visual img {
    width: 100%;
    border-radius: var(--radius-lg);
    object-fit: cover;
    aspect-ratio: 4/3;
    box-shadow: 0 20px 40px rgba(0,0,0,0.05);
}

.expertise-list {
    margin-top: 2rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.expertise-item {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
}

.expertise-item i {
    width: 24px;
    height: 24px;
    color: var(--color-text-primary);
    flex-shrink: 0;
    margin-top: 0.2rem;
}

.expertise-item h4 {
    font-size: 1.1rem;
    margin-bottom: 0.25rem;
}

.expertise-item p {
    font-size: 0.95rem;
    color: var(--color-text-secondary);
    margin: 0;
}

/* CARDS GRID (R&D and Services) */
.grid-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 2rem;
    perspective: 1000px;
}

.card-item {
    background-color: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 3rem 2rem;
    transition: transform 0.5s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.5s cubic-bezier(0.16, 1, 0.3, 1);
    transform-style: preserve-3d;
}

/* 3D Tilt Effect on hover (as requested) */
.card-item:hover {
    transform: translateY(-10px) rotateX(2deg) rotateY(-2deg);
    box-shadow: 20px 20px 40px rgba(0, 0, 0, 0.05), -10px -10px 20px rgba(255, 255, 255, 0.8);
    border-color: transparent;
    z-index: 10;
}

.card-icon {
    width: 32px;
    height: 32px;
    stroke-width: 1.5;
    color: var(--color-text-primary);
    margin-bottom: 2rem;
    transition: transform 0.3s ease;
}

.card-item:hover .card-icon {
    transform: scale(1.1) translateZ(20px);
}

.card-item h3 {
    font-size: 1.5rem;
    margin-bottom: 1rem;
}

.card-item p {
    color: var(--color-text-secondary);
    font-size: 1.05rem;
    margin-bottom: 1.5rem;
}

.card-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.card-tags span {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.25rem 0.75rem;
    background-color: var(--color-bg-alt);
    border-radius: 50px;
    color: var(--color-text-secondary);
}

/* PROJECTS (PORTFOLIO) */
.projects-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 2rem;
    perspective: 1200px;
}

.project-card {
    position: relative;
    border-radius: var(--radius-lg);
    overflow: hidden;
    aspect-ratio: 4/3;
    display: block;
    transition: transform 0.5s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.5s cubic-bezier(0.16, 1, 0.3, 1);
    transform-style: preserve-3d;
}

.project-card:hover {
    transform: translateY(-10px) scale(1.02);
    box-shadow: 0 30px 60px rgba(0, 0, 0, 0.12);
    z-index: 10;
}

.project-card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.7s cubic-bezier(0.16, 1, 0.3, 1);
}

.project-card:hover img {
    transform: scale(1.08);
}

.project-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, rgba(0,0,0,0.85) 0%, rgba(0,0,0,0) 60%);
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    padding: 2.5rem;
    color: var(--color-white-pure);
    transition: padding-bottom 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

.project-card:hover .project-overlay {
    padding-bottom: 3rem;
}

.project-overlay h3 {
    font-size: 1.75rem;
    margin-bottom: 0.5rem;
}

.project-overlay p {
    color: rgba(255, 255, 255, 0.8);
    font-size: 1.05rem;
    margin-bottom: 1rem;
}

.project-overlay .card-tags span {
    background-color: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(8px);
    color: var(--color-white-pure);
}

/* CONTATTI SECTION */
.contact-container {
    max-width: 800px;
    margin: 0 auto;
    text-align: center;
}

.contact-section .section-title,
.contact-section .section-subtitle,
.contact-section .section-pretitle {
    text-align: center;
    margin-left: auto;
    margin-right: auto;
}

.minimal-form {
    margin-top: var(--space-lg);
    text-align: left;
}

.form-group {
    margin-bottom: 2rem;
}

.minimal-form input[type="text"],
.minimal-form input[type="email"],
.minimal-form select,
.minimal-form textarea {
    width: 100%;
    background-color: transparent;
    border: none;
    border-bottom: 1px solid var(--color-border);
    padding: 1rem 0;
    font-family: var(--font-family);
    font-size: 1.125rem;
    color: var(--color-text-primary);
    transition: border-color 0.3s ease;
    resize: none;
    appearance: none;
}

.minimal-form select {
    cursor: pointer;
}

.minimal-form input:focus,
.minimal-form select:focus,
.minimal-form textarea:focus {
    outline: none;
    border-bottom-color: var(--color-black-pure);
}

.minimal-form input::placeholder,
.minimal-form textarea::placeholder,
.minimal-form select:invalid {
    color: var(--color-text-muted);
}

.form-checkbox {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 2.5rem;
}

.form-checkbox input[type="checkbox"] {
    margin-top: 0.3rem;
    width: 18px;
    height: 18px;
    accent-color: var(--color-black-pure);
    cursor: pointer;
}

.form-checkbox label {
    color: var(--color-text-secondary);
    font-size: 0.95rem;
    cursor: pointer;
}

.minimal-form .btn-primary {
    width: 100%;
    font-size: 1.125rem;
}

/* FOOTER */
.footer {
    border-top: 1px solid var(--color-border);
    padding: var(--space-lg) 0;
}

.footer-content {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 4rem;
}

.footer-column h4 {
    font-size: 1rem;
    margin-bottom: 1.5rem;
}

.footer-info {
    max-width: 300px;
    font-size: 0.9rem;
    color: var(--color-text-secondary);
}

.footer-info strong {
    color: var(--color-text-primary);
    display: block;
    margin-bottom: 0.5rem;
    font-size: 1.2rem;
}

.footer-links {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.footer-links a {
    font-size: 0.9rem;
    color: var(--color-text-secondary);
}

.footer-links a:hover {
    color: var(--color-black-pure);
}

/* OVERLAYS */

/* Floating WhatsApp */
.floating-wa {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 56px;
    height: 56px;
    background-color: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 99;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.floating-wa:hover {
    transform: scale(1.05);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

.floating-wa i {
    width: 28px;
    height: 28px;
    stroke-width: 1.5;
    color: var(--color-text-primary);
}

/* Mobile App Bottom Navigation Bar */
.mobile-app-nav {
    display: none;
}

/* Cookie Banner (Glassmorphism & Material You) */
.cookie-banner {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translate(-50%, 150%);
    width: 95%;
    max-width: 720px;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(32px);
    -webkit-backdrop-filter: blur(32px);
    border: 1px solid rgba(255, 255, 255, 0.6);
    border-radius: 32px;
    padding: 1.5rem 2rem;
    z-index: 1000;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.1), 0 0 0 1px rgba(0,0,0,0.03);
    transition: transform 0.8s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.8s ease;
    opacity: 0;
}

.cookie-banner.show {
    transform: translate(-50%, 0);
    opacity: 1;
}

.cookie-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 2rem;
    flex-wrap: wrap;
}

.cookie-content p {
    flex: 1;
    min-width: 250px;
    font-size: 0.9rem;
    color: var(--color-text-secondary);
    line-height: 1.6;
    margin: 0;
}

.cookie-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.cookie-actions button {
    border-radius: 50px;
    padding: 0.6rem 1.25rem;
    font-size: 0.85rem;
}

.cookie-actions .btn-link {
    color: var(--color-text-muted);
    text-decoration: none;
    padding: 0.6rem;
}

.cookie-actions .btn-link:hover {
    color: var(--color-text-primary);
}

/* RESPONSIVE DESIGN (Mobile target ~390px) */
@media (max-width: 768px) {
    :root {
        --space-xl: 4rem;
        --space-lg: 3rem;
    }

    body {
        padding-bottom: 80px; /* Spazio per la Mobile WebApp Nav */
    }

    .desktop-nav {
        display: none !important;
    }

    .mobile-menu-btn {
        display: block;
    }

    /* Gestione menu mobile a tendina */
    .desktop-nav.active {
        display: flex !important;
        flex-direction: column;
        position: absolute;
        top: 80px;
        left: 0;
        width: 100%;
        background: var(--glass-bg);
        backdrop-filter: var(--glass-blur);
        -webkit-backdrop-filter: var(--glass-blur);
        padding: 2rem;
        border-bottom: 1px solid rgba(0,0,0,0.05);
    }

    .hero-title {
        font-size: 2.5rem;
    }

    .metrics-grid {
        gap: 2rem;
        flex-direction: column;
    }

    .about-grid {
        grid-template-columns: 1fr;
    }

    .projects-grid {
        grid-template-columns: 1fr;
    }
    
    /* Disabilita Hover 3D su mobile per performance e usabilità */
    .card-item:hover, .project-card:hover {
        transform: none;
    }

    /* WebApp Bottom Nav */
    .mobile-app-nav {
        display: flex;
        position: fixed;
        bottom: 1rem;
        left: 50%;
        transform: translateX(-50%);
        width: 95%;
        max-width: 400px;
        height: 65px;
        background: var(--glass-bg);
        backdrop-filter: blur(24px);
        -webkit-backdrop-filter: blur(24px);
        border: 1px solid rgba(0, 0, 0, 0.05);
        border-radius: 35px;
        z-index: 2000;
        justify-content: space-around;
        align-items: center;
        padding: 0 10px;
        box-shadow: 0 10px 30px rgba(0,0,0,0.1);
    }

    .app-nav-item {
        display: flex;
        flex-direction: column;
        align-items: center;
        text-decoration: none;
        color: var(--color-text-muted);
        font-size: 10px;
        font-weight: 600;
        transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
        padding: 8px;
        border-radius: 20px;
    }

    .app-nav-item.active {
        color: var(--color-black-pure);
        background: rgba(0, 0, 0, 0.05);
        transform: translateY(-4px);
    }

    .app-nav-item i {
        width: 22px;
        height: 22px;
        margin-bottom: 4px;
    }

    .cookie-banner {
        bottom: 85px; /* Sopra la nav */
        width: 95%;
        border-radius: 24px;
        padding: 1.5rem;
    }

    .cookie-content {
        flex-direction: column;
        align-items: flex-start;
        gap: 1.5rem;
    }

    .cookie-actions {
        width: 100%;
        flex-wrap: wrap;
        justify-content: space-between;
        gap: 0.5rem;
    }

    .cookie-actions button {
        flex: 1;
        text-align: center;
        padding: 0.75rem 1rem;
        white-space: nowrap;
        margin: 0;
    }

    .cookie-actions .btn-link {
        width: 100%;
        margin-bottom: 0.25rem;
        text-align: left;
        padding-left: 0;
    }

    .floating-wa {
        bottom: 85px; /* Sopra la nav */
        right: 1.5rem;
        width: 48px;
        height: 48px;
    }
    
    .floating-wa i {
        width: 24px;
        height: 24px;
    }
}
