/* ==========================================================================
   NEXWEBSTUDIO - SERVIZI (APPLE DESIGN SYSTEM)
   Versione: 2.0 (Advanced)
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. VARIABILI GLOBALI (Design Tokens)
   -------------------------------------------------------------------------- */
:root {
    /* Palette Colori Apple */
    --color-bg-primary: #fbfbfd;
    --color-bg-secondary: #ffffff;
    --color-text-primary: #1d1d1f;
    --color-text-secondary: #86868b;
    --color-text-tertiary: #515154;
    --color-accent-blue: #0071e3;
    --color-accent-blue-hover: #0077ED;
    --color-accent-dark: #1d1d1f;
    
    /* Gradienti AI */
    --gradient-ai-border: linear-gradient(135deg, #a4c8ff, #d1e1ff);
    --gradient-ai-bg: linear-gradient(145deg, #ffffff, #f4f7ff);
    
    /* Ombre Multi-Livello (Smooth Shadows) */
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.06), 0 2px 4px rgba(0, 0, 0, 0.02);
    --shadow-lg: 0 20px 40px rgba(0, 0, 0, 0.08), 0 1px 3px rgba(0, 0, 0, 0.03);
    --shadow-glow: 0 0 30px rgba(0, 113, 227, 0.15);
    
    /* Spaziature (Spaziatura Fluida) */
    --space-section-y: clamp(80px, 10vw, 160px);
    --space-container-x: clamp(20px, 5vw, 40px);
    
    /* Tipografia e Curve di Animazione */
    --font-system: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --transition-snappy: 0.3s cubic-bezier(0.25, 0.1, 0.25, 1);
    --transition-smooth: 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

/* --------------------------------------------------------------------------
   2. RESET E IMPOSTAZIONI BASE (Livello Avanzato)
   -------------------------------------------------------------------------- */
html {
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    background-color: var(--color-bg-primary);
    color: var(--color-text-primary);
    font-family: var(--font-system);
    overflow-x: hidden;
    margin: 0;
    padding: 0;
}

/* Scrollbar personalizzata invisibile stile macOS */
::-webkit-scrollbar {
    width: 10px;
}
::-webkit-scrollbar-track {
    background: var(--color-bg-primary);
}
::-webkit-scrollbar-thumb {
    background: #d2d2d7;
    border-radius: 10px;
    border: 2px solid var(--color-bg-primary);
}
::-webkit-scrollbar-thumb:hover {
    background: #86868b;
}

/* Evidenziazione testo */
::selection {
    background: var(--color-accent-blue);
    color: white;
}

/* --------------------------------------------------------------------------
   3. HERO SECTION (Impatto Iniziale)
   -------------------------------------------------------------------------- */
.hero-services {
    position: relative;
    padding-top: calc(120px + 5vw); /* Calcolo dinamico basato sull'header */
    padding-bottom: clamp(60px, 8vw, 120px);
    padding-left: var(--space-container-x);
    padding-right: var(--space-container-x);
    text-align: center;
    background-color: var(--color-bg-primary);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 60vh;
}

.hero-content {
    max-width: 980px; /* Larghezza standard Apple per la massima leggibilità */
    z-index: 2;
    position: relative;
}

.hero-title {
    font-size: clamp(3rem, 6vw, 5.5rem);
    font-weight: 700;
    letter-spacing: -0.05em;
    color: var(--color-text-primary);
    margin: 0 0 24px 0;
    line-height: 1.05;
    /* Effetto sfumatura leggerissima sul testo per profondità */
    background: linear-gradient(180deg, #1d1d1f 0%, #434347 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.hero-subtitle {
    font-size: clamp(1.2rem, 2vw, 1.6rem);
    font-weight: 400;
    color: var(--color-text-secondary);
    max-width: 750px;
    margin: 0 auto;
    line-height: 1.5;
    letter-spacing: -0.01em;
}

/* --------------------------------------------------------------------------
   4. SHOWCASE SERVIZI (Layout ad incastro)
   -------------------------------------------------------------------------- */
.services-showcase {
    max-width: 1200px;
    margin: 0 auto;
    padding: var(--space-section-y) var(--space-container-x);
    display: flex;
    flex-direction: column;
    gap: clamp(100px, 12vw, 200px);
}

.service-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: clamp(40px, 8vw, 100px);
    position: relative;
}

/* Inversione della riga per dinamismo visivo */
.service-row.reverse {
    flex-direction: row-reverse;
}

.service-text {
    flex: 1;
    max-width: 550px;
}

.service-label {
    font-size: 0.85rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    color: var(--color-accent-blue);
    margin-bottom: 20px;
    display: inline-block;
}

.service-text h2 {
    font-size: clamp(2.5rem, 4vw, 3.8rem);
    font-weight: 700;
    letter-spacing: -0.04em;
    color: var(--color-text-primary);
    margin-bottom: 24px;
    line-height: 1.1;
}

.service-text p {
    font-size: clamp(1.1rem, 1.5vw, 1.35rem);
    line-height: 1.6;
    color: var(--color-text-tertiary);
    margin: 0;
}

/* --------------------------------------------------------------------------
   5. SERVICE VISUALS (Immagini 3D)
   -------------------------------------------------------------------------- */
.service-visual {
    flex: 1;
    width: 100%;
    border-radius: 32px;
    overflow: hidden; /* Assicura che l'immagine segua i bordi arrotondati */
    box-shadow: var(--shadow-lg);
    background-color: var(--color-bg-secondary);
    /* Transizione morbida solo per l'ombra, NESSUN movimento della forma */
    transition: box-shadow var(--transition-snappy);
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Leggero aumento dell'ombra al passaggio del mouse per dare profondità statica */
.service-visual:hover {
    box-shadow: 0 30px 60px rgba(0, 0, 0, 0.12);
}

.service-visual img {
    width: 100%;
    height: auto;
    object-fit: cover;
    display: block;
}

/* --------------------------------------------------------------------------
   6. SEZIONE TECNOLOGIE (CSS Grid Avanzato)
   -------------------------------------------------------------------------- */
.tech-stack {
    background-color: var(--color-bg-secondary);
    padding: var(--space-section-y) var(--space-container-x);
    text-align: center;
    border-top: 1px solid #f2f2f2;
    border-bottom: 1px solid #f2f2f2;
}

.tech-header {
    margin-bottom: clamp(60px, 8vw, 100px);
}

.tech-header h2 {
    font-size: clamp(2.8rem, 4vw, 4rem);
    font-weight: 700;
    color: var(--color-text-primary);
    letter-spacing: -0.04em;
    margin-bottom: 24px;
}

.tech-header p {
    font-size: clamp(1.2rem, 1.8vw, 1.5rem);
    color: var(--color-text-secondary);
    max-width: 800px;
    margin: 0 auto;
    line-height: 1.5;
}

/* Griglia Auto-Adattiva (Senza bisogno di Media Queries rigide per le colonne) */
.tech-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: clamp(20px, 3vw, 32px);
    max-width: 1100px;
    margin: 0 auto;
}

.tech-item {
    background: var(--color-bg-primary);
    border-radius: 24px;
    padding: 40px 20px;
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 24px;
    border: 1px solid transparent;
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    position: relative;
    z-index: 1;
}

.tech-item::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    border-radius: 24px;
    box-shadow: var(--shadow-lg);
    opacity: 0;
    z-index: -1;
    transition: opacity 0.4s ease;
}

.tech-item:hover {
    transform: translateY(-12px);
    border-color: rgba(0, 0, 0, 0.05);
    background: var(--color-bg-secondary);
}

.tech-item:hover::before {
    opacity: 1;
}

.tech-item img {
    height: 72px;
    width: auto;
    object-fit: contain;
    transition: transform 0.4s ease;
}

.tech-item:hover img {
    transform: scale(1.1);
}

.tech-item span {
    font-size: 1.15rem;
    font-weight: 600;
    letter-spacing: -0.01em;
    color: var(--color-text-primary);
}

/* Trattamento Speciale per l'Intelligenza Artificiale (Claude) */
.ai-highlight {
    background: var(--gradient-ai-bg);
    border: 1px solid #d2dfff;
    grid-column: span 1;
}

@media (min-width: 768px) {
    /* Su desktop o tablet larghi, facciamo in modo che l'AI prenda più spazio se dispari */
    .tech-grid .ai-highlight:last-child:nth-child(odd) {
        grid-column: span 2;
    }
}

.ai-highlight:hover {
    box-shadow: var(--shadow-glow);
    border-color: #a4c8ff;
}

.ai-highlight span {
    color: var(--color-accent-blue);
    background: linear-gradient(90deg, #0071e3, #004fb0);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* --------------------------------------------------------------------------
   7. CALL TO ACTION (Report Gratuito)
   -------------------------------------------------------------------------- */
.cta-report {
    padding: var(--space-section-y) var(--space-container-x);
    text-align: center;
    background-color: var(--color-bg-primary);
    position: relative;
    overflow: hidden;
}

/* Bagliore radiale sullo sfondo della CTA */
.cta-report::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 80vw;
    height: 80vw;
    max-width: 800px;
    max-height: 800px;
    background: radial-gradient(circle, rgba(0, 113, 227, 0.04) 0%, rgba(251, 251, 253, 0) 70%);
    z-index: 0;
    pointer-events: none;
}

.cta-content {
    position: relative;
    z-index: 1;
    max-width: 850px;
    margin: 0 auto;
}

.cta-content h2 {
    font-size: clamp(3rem, 5vw, 4.5rem);
    font-weight: 700;
    color: var(--color-text-primary);
    letter-spacing: -0.04em;
    margin-bottom: 32px;
}

.cta-content p {
    font-size: clamp(1.2rem, 1.8vw, 1.6rem);
    line-height: 1.5;
    color: var(--color-text-tertiary);
    margin-bottom: 56px;
}

/* Bottone Call to Action Super Avanzato */
.btn-apple {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background-color: var(--color-accent-dark);
    color: #ffffff;
    padding: 22px 56px;
    border-radius: 100px; /* Perfetta forma a pillola */
    font-size: 1.3rem;
    font-weight: 600;
    letter-spacing: -0.01em;
    text-decoration: none;
    transition: all var(--transition-snappy);
    border: 2px solid transparent;
    position: relative;
}

.btn-apple::after {
    content: '';
    position: absolute;
    top: -4px; left: -4px; right: -4px; bottom: -4px;
    border-radius: 100px;
    background: rgba(0, 0, 0, 0.1);
    z-index: -1;
    opacity: 0;
    transition: opacity var(--transition-snappy);
}

.btn-apple:hover {
    background-color: #333336;
    transform: scale(1.03);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.15);
}

.btn-apple:hover::after {
    opacity: 1;
}

.btn-apple:active {
    transform: scale(0.98);
}

.btn-apple:focus-visible {
    outline: none;
    border-color: #ffffff;
    box-shadow: 0 0 0 4px rgba(0, 113, 227, 0.5);
}

/* --------------------------------------------------------------------------
   8. MOTORE GRAFICO ANIMAZIONI (Intersection Observer)
   -------------------------------------------------------------------------- */
.reveal {
    opacity: 0;
    /* La trasformazione aggiunge un po' di scala per l'effetto di "apertura" */
    transform: translateY(80px) scale(0.98);
    transition: opacity 1.2s cubic-bezier(0.16, 1, 0.3, 1), 
                transform 1.2s cubic-bezier(0.16, 1, 0.3, 1);
    will-change: opacity, transform;
}

.reveal.active {
    opacity: 1;
    transform: translateY(0) scale(1);
}

/* Stagger per la griglia delle tecnologie: fa apparire le card a scaglioni */
.tech-grid.active .tech-item:nth-child(1) { transition-delay: 0.05s; }
.tech-grid.active .tech-item:nth-child(2) { transition-delay: 0.10s; }
.tech-grid.active .tech-item:nth-child(3) { transition-delay: 0.15s; }
.tech-grid.active .tech-item:nth-child(4) { transition-delay: 0.20s; }
.tech-grid.active .tech-item:nth-child(5) { transition-delay: 0.25s; }
.tech-grid.active .tech-item:nth-child(6) { transition-delay: 0.30s; }
.tech-grid.active .tech-item:nth-child(7) { transition-delay: 0.35s; }

/* Keyframes personalizzati */
@keyframes floatingMesh {
    0% { transform: translate(0, 0) scale(1); }
    50% { transform: translate(5%, 10%) scale(1.1); }
    100% { transform: translate(-5%, -5%) scale(0.9); }
}

/* --------------------------------------------------------------------------
   9. MEDIA QUERIES (Precisione Pixel-Perfect su Dispositivi)
   -------------------------------------------------------------------------- */

/* TABLET E LAPTOP PICCOLI (Sotto i 992px) */
@media (max-width: 992px) {
    .service-row, 
    .service-row.reverse {
        flex-direction: column;
        text-align: center;
        gap: 48px;
    }

    .service-text {
        max-width: 100%;
        display: flex;
        flex-direction: column;
        align-items: center;
    }
    
    .service-visual {
        width: 100%;
        min-height: 350px;
    }
}

/* SMARTPHONE GRANDI E TABLET PICCOLI (Sotto i 768px) */
@media (max-width: 768px) {
    .hero-services {
        min-height: auto;
        padding-top: 140px;
    }
    
    .tech-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 16px;
    }

    .tech-item {
        padding: 30px 16px;
        gap: 16px;
    }

    .tech-item img {
        height: 50px;
    }
    
    .btn-apple {
        width: 100%;
        padding: 20px 24px;
        box-sizing: border-box;
    }
}

/* SMARTPHONE PICCOLI (Sotto i 480px) */
@media (max-width: 480px) {
    :root {
        --space-section-y: 60px;
    }

    .service-visual {
        min-height: 250px;
        border-radius: 20px;
    }

    .tech-grid {
        grid-template-columns: 1fr; /* Una colonna singola su schermi molto stretti */
    }
    
    .tech-item:hover {
        transform: translateY(-4px); /* Movimento ridotto per mobile */
    }
}

/* --------------------------------------------------------------------------
   10. ACCESSIBILITÀ (Reduced Motion)
   -------------------------------------------------------------------------- */
/* Disabilita animazioni per gli utenti che hanno impostato "Riduci movimento" nel sistema operativo */
@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }
    
    .reveal,
    .btn-apple,
    .tech-item,
    .service-visual,
    .tech-item img {
        transition: none !important;
        animation: none !important;
        transform: none !important;
        opacity: 1 !important;
    }
}

/* --------------------------------------------------------------------------
   11. STILI PER LA STAMPA
   -------------------------------------------------------------------------- */
@media print {
    body {
        background: #fff;
        color: #000;
    }
    .service-visual, .hero-services::before {
        display: none; /* Nasconde grafiche pesanti durante la stampa */
    }
    .hero-title, .service-text h2 {
        color: #000;
        -webkit-text-fill-color: #000;
    }
}