﻿/* =========================================
   VARIABILI GLOBALI E COLORI
   ========================================= */
:root {
    --text-main: #242935;
    --bg-start: #ffffff;
    --bg-end: #eef1f5; 
    --text-muted: #5e6b7e;
    
    /* Blob Colorati e Moderni (Indaco, Blu, Viola) */
    --blob-1: rgba(99, 102, 241, 0.15); 
    --blob-2: rgba(59, 130, 246, 0.12);
    --blob-3: rgba(139, 92, 246, 0.10);

    /* Bordi e Ombre */
    --border-light: rgba(36, 41, 53, 0.15);
    --shadow-soft: 0 15px 35px rgba(36, 41, 53, 0.08);
    --shadow-hover: 0 30px 60px rgba(36, 41, 53, 0.18);
    
    /* Font Unificato */
    --font-main: 'Inter', sans-serif;
    
    /* Curve di animazione */
    --ease-elastic: cubic-bezier(0.68, -0.55, 0.265, 1.55);
    --ease-smooth: cubic-bezier(0.4, 0, 0.2, 1);
}

/* =========================================
   RESET E IMPOSTAZIONI BASE
   ========================================= */
* { 
    margin: 0; 
    padding: 0; 
    box-sizing: border-box; 
}

html { 
    scroll-behavior: smooth; 
}

body {
    font-family: var(--font-main);
    font-weight: 400;
    background: linear-gradient(135deg, var(--bg-start) 0%, var(--bg-end) 100%);
    color: var(--text-main);
    line-height: 1.7;
    overflow-x: hidden;
    position: relative;
}

h1, h2, h3, h4, .logo { 
    font-family: var(--font-main); 
    color: var(--text-main); 
    font-weight: 700; 
}

/* =========================================
   BACKGROUND PARALLASSE (Blob di colore)
   ========================================= */
.bg-shape {
    position: fixed;
    border-radius: 50%;
    filter: blur(100px);
    z-index: -1;
    pointer-events: none;
}
.bg-shape-1 { top: -15%; left: -10%; width: 55vw; height: 55vw; background: var(--blob-1); }
.bg-shape-2 { top: 35%; right: -15%; width: 45vw; height: 45vw; background: var(--blob-2); }
.bg-shape-3 { bottom: -25%; left: 15%; width: 65vw; height: 65vw; background: var(--blob-3); }

/* =========================================
   GLASSMORPHISM
   ========================================= */
.glass-card {
    background: rgba(255, 255, 255, 0.6);
    backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);
    border: 1px solid var(--border-light);
    border-radius: 24px;
    box-shadow: var(--shadow-soft);
    padding: 2.5rem;
}

/* =========================================
   LAYOUT E SEZIONI
   ========================================= */
.section { 
    padding: 8rem 5%; 
    position: relative; 
}

.section-header h2 { 
    font-size: 2.5rem; 
    margin-bottom: 3.5rem; 
    text-align: center; 
    letter-spacing: -0.5px; 
}

/* =========================================
   TOPBAR E NAVIGAZIONE
   ========================================= */
.topbar {
    position: fixed; 
    width: 100%; 
    top: 0; 
    display: flex; 
    justify-content: space-between; 
    align-items: center;
    padding: 1.2rem 5%; 
    background: rgba(255, 255, 255, 0.7); 
    backdrop-filter: blur(20px);
    z-index: 1000; 
    border-bottom: 1px solid var(--border-light);
}

.logo { 
    font-size: 1.4rem; 
    font-weight: 700; 
    letter-spacing: -0.5px; 
}

.nav-links, .social-links { 
    display: flex; 
    gap: 2rem; 
    list-style: none; 
    align-items: center; 
}

.topbar a { 
    color: var(--text-muted); 
    text-decoration: none; 
    font-weight: 500; 
    font-size: 0.95rem; 
    transition: color 0.3s ease; 
    position: relative; 
}

.topbar a:hover { 
    color: var(--text-main); 
}

.nav-links a::after {
    content: ''; 
    position: absolute; 
    bottom: -5px; 
    left: 0; 
    width: 0; 
    height: 2px;
    background-color: var(--text-main); 
    transition: width 0.3s ease;
}

.nav-links a:hover::after { 
    width: 100%; 
}

/* Icone Social (LinkedIn, Mail, ecc.) */
.social-icon { 
    display: block;
    transition: all 0.3s ease; 
    stroke: var(--text-main); 
}
.social-icon:hover { 
    transform: scale(1.15); 
}
.linkedin-icon:hover { 
    stroke: #0a66c2; 
} 
.mail-icon:hover { 
    stroke: #6366f1; 
}

/* Bottoni stile Outline (per eventuali link extra ai progetti) */
/* Bottoni stile Outline (con supporto per icone) */
.btn-outline { 
    background-color: var(--text-main); 
    color: #ffffff !important; 
    padding: 0.7rem 1.4rem; 
    border-radius: 8px; 
    font-weight: 600; 
    border: none; 
    transition: all 0.3s var(--ease-smooth); 
    text-decoration: none; 
    
    /* Le 3 righe nuove per allineare l'icona al testo */
    display: inline-flex; 
    align-items: center; 
    gap: 0.6rem; 
    
    box-shadow: 0 5px 15px rgba(36, 41, 53, 0.2); 
}
.btn-outline:hover { 
    background-color: #334155; 
    transform: translateY(-3px); 
    box-shadow: 0 15px 30px rgba(36, 41, 53, 0.3); 
}

/* Bottone Hamburger (Mobile) */
.menu-toggle { 
    display: none; 
    flex-direction: column; 
    cursor: pointer; 
    gap: 6px; 
    z-index: 1001; 
}
.menu-toggle .bar { 
    width: 28px; 
    height: 3px; 
    background-color: var(--text-main); 
    transition: all 0.3s ease-in-out; 
    border-radius: 3px; 
}

/* =========================================
   HERO SECTION
   ========================================= */
.hero { 
    display: flex; 
    align-items: center; 
    min-height: 100vh; 
    padding-top: 5rem; 
}

.hero-wrapper { 
    display: flex; 
    align-items: center; 
    justify-content: space-between; 
    gap: 5rem; 
    max-width: 1200px; 
    margin: 0 auto; 
    width: 100%; 
}

.hero-text { flex: 1.2; }
.hero-visual { flex: 0.8; display: flex; justify-content: flex-end; }

.profile-pic { 
    width: 100%; 
    max-width: 400px; 
    height: auto; 
    border-radius: 24px; 
    box-shadow: var(--shadow-hover); 
    object-fit: cover; 
}

.hero h1 { 
    font-size: 4.8rem; 
    line-height: 1.1; 
    margin-bottom: 1.5rem; 
    letter-spacing: -2px; 
}
.hero h1 span { color: var(--text-main); }

.subtitle { 
    font-size: 1.5rem; 
    margin-bottom: 1.5rem; 
    font-weight: 500; 
    color: var(--text-main); 
}
.description { 
    font-size: 1.1rem; 
    color: var(--text-muted); 
    margin-bottom: 3rem; 
    max-width: 550px; 
    line-height: 1.8; 
    font-weight: 300;
}

.stats-container { 
    display: flex; 
    align-items: center; /* Centra verticalmente il bottone con i numeri */
    gap: 4rem; 
    border-top: 1px solid var(--border-light); 
    padding-top: 3rem; 
    flex-wrap: wrap; /* Assicura che su mobile non si rompa tutto */
}

/* Stile specifico per il bottone della Hero */
.hero-btn {
    margin-left: auto; /* Questo spinge il bottone tutto a destra, staccandolo dai numeri */
    padding: 0.9rem 2rem; /* Lo rende leggermente più grande e cliccabile */
    font-size: 1.1rem;
    box-shadow: 0 10px 25px rgba(36, 41, 53, 0.25); /* Un'ombra un po' più decisa per farlo risaltare */
}

.hero-btn:hover {
    box-shadow: 0 15px 35px rgba(36, 41, 53, 0.4);
}
.stat-item h3 { 
    font-size: 2.5rem; 
    font-weight: 700; 
    color: var(--text-main); 
    line-height: 1;
}
.stat-item p { 
    font-weight: 600; 
    text-transform: uppercase; 
    letter-spacing: 1px; 
    font-size: 0.85rem; 
    margin-top: 0.8rem; 
    color: var(--text-muted);
}

/* =========================================
   PROGETTI (Griglia ed espansione)
   ========================================= */
.grid { 
    display: grid; 
    grid-template-columns: 1fr; 
    gap: 4rem; 
    max-width: 900px; 
    margin: 0 auto;
}

.project-card { 
    padding: 0; 
    overflow: hidden; 
    display: block; 
    transition: transform 0.4s var(--ease-smooth), box-shadow 0.4s var(--ease-smooth); 
}
.project-card:hover { 
    transform: translateY(-10px); 
    box-shadow: var(--shadow-hover); 
}

.project-card.is-open { 
    transform: none !important; 
    box-shadow: var(--shadow-hover); 
    border-color: var(--text-main); 
}

.project-trigger { position: relative; cursor: pointer; }
.project-img-wrapper { 
    height: 350px; 
    position: relative; 
    overflow: hidden; 
    border-radius: 24px 24px 0 0; 
}
.project-img-wrapper img { 
    width: 100%; 
    height: 100%; 
    object-fit: cover; 
    transition: transform 0.5s ease; 
}
.project-card:hover .project-img-wrapper img { transform: scale(1.05); }

.project-overlay { 
    position: absolute; 
    top: 0; left: 0; width: 100%; height: 100%; 
    background: rgba(36, 41, 53, 0.9); 
    display: flex; justify-content: center; align-items: center; 
    opacity: 0; transition: opacity 0.3s ease; 
}
.project-card:hover .project-overlay { opacity: 1; }

.expand-icon { 
    width: 56px; height: 56px; stroke: white; 
    transition: transform 0.4s var(--ease-smooth); stroke-width: 1.5; 
}
.project-card.is-open .expand-icon { transform: rotate(45deg); opacity: 1; } 
.project-card.is-open .project-overlay { opacity: 1; }

.project-info { padding: 2.5rem; }
.company { 
    font-size: 0.85rem; 
    text-transform: uppercase; 
    color: var(--text-muted); 
    font-weight: 600; 
    display: block; 
    margin-bottom: 0.8rem; 
    letter-spacing: 1px; 
}
.project-info h3 { font-size: 1.8rem; margin-bottom: 0.5rem; font-weight: 600; }

/* =========================================
   DETTAGLI NASCOSTI PROGETTI
   ========================================= */
.project-details { 
    max-height: 0; 
    overflow: hidden; 
    opacity: 0; 
    transition: max-height 0.6s cubic-bezier(0, 1, 0, 1), opacity 0.4s ease; 
}

.project-card.is-open .project-details { 
    max-height: 10000px; /* Consente contenuti lunghissimi */
    opacity: 1; 
    transition: max-height 1.5s ease-in-out, opacity 0.8s ease; 
}

.details-content { 
    padding: 0 2.5rem 3rem 2.5rem; 
    border-top: 1px solid var(--border-light); 
    margin-top: 0.5rem; 
    padding-top: 2rem; 
}

/* Nascondi i <br> extra inseriti nell'HTML */
.details-content br {
    display: none;
}

/* H2: I titoli principali delle sezioni nei progetti (es. UX/UI DESIGN) */
.details-content h2 {
    font-size: 1.6rem;
    color: var(--text-main);
    font-weight: 800;
    margin-top: 3rem; /* Stacca la nuova sezione dalla precedente */
    margin-bottom: 0.8rem;
}

/* Rimuove lo stacco superiore solo al primissimo H2 */
.details-content h2:first-child {
    margin-top: 0;
}

/* H4: I sottotitoli (The Challenge / My Solution) */
.details-content h4 { 
    font-size: 1.2rem; 
    color: var(--text-main); 
    font-weight: 700;
    margin-top: 1.5rem; /* Distanza dal paragrafo prima */
    margin-bottom: 0.2rem; /* Quasi attaccato al suo testo */
}

/* Evita stacchi eccessivi se un H4 è subito dopo l'H2 */
.details-content h2 + h4 {
    margin-top: 0;
}

/* Testi descrittivi del progetto */
.details-content p { 
    color: var(--text-muted); 
    font-size: 1.05rem; 
    font-weight: 400; 
    margin-top: 0; 
    line-height: 1.8;
}

/* Link in fondo al progetto (se inseriti) */
.project-links {
    margin-top: 2.5rem;
    display: flex;
    gap: 1.5rem;
    flex-wrap: wrap;
}

/* Galleria Immagini nel dettaglio progetto */
.details-gallery { 
    display: grid; 
    grid-template-columns: 1fr 1fr; 
    gap: 1.5rem; 
    margin-top: 2rem; 
}
.details-gallery img { 
    width: 100%; 
    height: 200px; 
    object-fit: cover; 
    border-radius: 12px; 
    box-shadow: var(--shadow-soft); 
    cursor: zoom-in;
    transition: transform 0.3s ease;
}
.details-gallery img:hover { transform: scale(1.02); }

/* =========================================
   TIMELINE ESPERIENZA E ISTRUZIONE
   ========================================= */
.timeline { 
    max-width: 850px; 
    margin: 0 auto; 
    border-left: 2px solid var(--border-light); 
    padding-left: 3rem; 
}
@media(min-width: 900px){ 
    .timeline { margin-left: calc(50% - 425px); } 
}

.timeline-item { position: relative; margin-bottom: 4rem; }
.timeline-dot { 
    position: absolute; 
    left: -40px; 
    top: 28px; 
    width: 20px; 
    height: 20px; 
    background-color: var(--text-main); 
    border-radius: 50%; 
    box-shadow: 0 0 0 8px var(--bg-start), 0 0 0 12px var(--border-light); 
}

.timeline-content { transition: transform 0.3s var(--ease-smooth); }
.timeline-content:hover { transform: translateX(8px); }

.timeline-content .date { 
    display: inline-block; 
    padding: 0.4rem 1rem; 
    background: var(--border-light); 
    border-radius: 50px; 
    font-size: 0.85rem; 
    font-weight: 600; 
    color: var(--text-main); 
    margin-bottom: 1.5rem; 
}
.timeline-content h4 { font-size: 1.4rem; font-weight: 600; margin-bottom: 0.5rem; }
.timeline-content p { font-weight: 300; }

/* =========================================
   SKILLS & LANGUAGES (Layout a Tag)
   ========================================= */
.desc-box {
    max-width: 1550px;
    margin: 0 auto 4rem auto;
    padding: 0 1rem;
    background: transparent;
    border: none;
    box-shadow: none;
    backdrop-filter: none;
    text-align: center;
}

.desc-box p {
    color: var(--text-muted);
    font-size: 1.2rem;
    line-height: 1.9;
    font-weight: 400;
    text-wrap: balance;
}

.skills-grid { 
    display: grid; 
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); 
    gap: 2.5rem; 
    max-width: 1200px; 
    margin: 0 auto; 
    align-items: stretch;
}

.skill-category { 
    display: flex;
    flex-direction: column;
    transition: transform 0.3s var(--ease-smooth); 
}

.skill-category:hover { 
    transform: translateY(-5px); 
}

.skill-category h3 { 
    margin-bottom: 1.5rem; 
    font-size: 1.3rem; 
    border-bottom: 1px solid var(--border-light); 
    padding-bottom: 1rem;
}

.skill-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.8rem;
}

.tag {
    background: rgba(255, 255, 255, 0.8);
    border: 1px solid var(--border-light);
    color: var(--text-main);
    padding: 0.5rem 1rem;
    border-radius: 50px;
    font-size: 0.95rem;
    font-weight: 500;
    transition: all 0.3s ease;
    box-shadow: 0 2px 10px rgba(0,0,0,0.02);
}

.tag:hover {
    background: var(--text-main);
    color: #ffffff;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(36, 41, 53, 0.15);
}

/* =========================================
   FOOTER (Essenziale)
   ========================================= */
.footer { 
    border-top: 1px solid var(--border-light); 
    padding: 2rem 5%; 
    margin-top: 6rem; 
    background: rgba(255, 255, 255, 0.3); 
    backdrop-filter: blur(20px); 
}

.footer-content { 
    max-width: 1200px; 
    margin: 0 auto; 
    display: flex; 
    justify-content: center; 
    align-items: center; 
}

.footer p { 
    color: var(--text-muted); 
    font-size: 0.95rem; 
    font-weight: 500; 
}

/* =========================================
   LIGHTBOX OVERLAY (Zoom Immagini Panzoom)
   ========================================= */
.lightbox {
    display: none; 
    position: fixed; 
    z-index: 2000; 
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(36, 41, 53, 0.98); 
    justify-content: center; align-items: center;
    opacity: 0; 
    transition: opacity 0.3s ease;
    overflow: hidden; 
}

.lightbox.active { 
    display: flex; 
    opacity: 1; 
}

.panzoom-container {
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: grab;
}
.panzoom-container:active {
    cursor: grabbing;
}

.lightbox img { 
    max-width: 60%; 
    max-height: 90vh; 
    border-radius: 4px; 
    box-shadow: 0 20px 60px rgba(0,0,0,0.5); 
    pointer-events: none; 
}

.lightbox-close { 
    position: absolute; 
    top: 20px; 
    right: 30px; 
    color: white; 
    font-size: 40px; 
    cursor: pointer; 
    transition: transform 0.3s ease;
    z-index: 2001; 
    background: rgba(0,0,0,0.2); 
    width: 50px; height: 50px;
    border-radius: 50%;
    display: flex; justify-content: center; align-items: center;
    line-height: 1;
    padding-bottom: 4px;
}

.lightbox-close:hover { 
    transform: scale(1.1);
    background: rgba(255,255,255,0.2);
}

/* =========================================
   ANIMAZIONI GENERALI (AOS e keyframes)
   ========================================= */
.animate-down { animation: slideDown 0.8s var(--ease-smooth) forwards; opacity: 0; transform: translateY(-20px); }
@keyframes slideDown { to { opacity: 1; transform: translateY(0); } }

.fade-in-up { opacity: 0; transform: translateY(40px); animation: fadeInUpElastic 1s var(--ease-elastic) forwards; }
@keyframes fadeInUpElastic { to { opacity: 1; transform: translateY(0); } }

.stag-1 { animation-delay: 0.1s; } 
.stag-2 { animation-delay: 0.25s; } 
.stag-3 { animation-delay: 0.4s; } 
.stag-4 { animation-delay: 0.55s; }

/* =========================================
   RESPONSIVITÀ (Tablet e Smartphone)
   ========================================= */
@media (max-width: 992px) {
    .hero h1 { font-size: 4.5rem; }
    .hero-wrapper { gap: 3rem; }
}

@media (max-width: 768px) {
    .nav-links a::after { display: none; }
    .section { padding: 6rem 1.5rem; }
    
    .hero { padding-top: 8rem; min-height: auto; }
    .hero-wrapper { flex-direction: column; text-align: center; gap: 3rem; }
    .hero-visual { justify-content: center; }
    .hero-text { display: flex; flex-direction: column; align-items: center; }
    .hero h1 { font-size: 3.2rem; letter-spacing: -1px; }
    .description { margin: 0 auto 2.5rem auto; padding: 0 0.5rem; }
    .stats-container { gap: 1.5rem; flex-wrap: wrap; justify-content: center; }
    .stat-item h3 { font-size: 2rem; }
    .hero-btn { margin-left: 0; width: 100%; text-align: center; margin-top: 1rem; }
    
    .project-img-wrapper { height: 250px; }
    
    .timeline { padding-left: 2rem; border-left-width: 2px; }
    .timeline-dot { left: -30px; top: 24px; width: 16px; height: 16px; }

    .desc-box { padding: 0 1.5rem; margin-bottom: 3rem; }
    .desc-box p { font-size: 1.05rem; text-align: left; }

    .topbar {
        flex-wrap: wrap; /* Permette alla barra di espandersi in altezza */
        background: rgba(255, 255, 255, 0.95); /* Rende lo sfondo più solido per leggere bene i link */
    }

    .menu-toggle { display: flex; }
    
    .nav-links, .social-links {
        display: none; 
        width: 100%; 
        text-align: center;
        position: static; /* Rimuove il "top" calcolato che rompeva tutto */
        background: transparent; 
        backdrop-filter: none;
        box-shadow: none;
    }
    
    .nav-links { 
        order: 3; /* Si posiziona sotto al logo */
        padding: 1.5rem 0 0.5rem 0; 
        flex-direction: column;
    }
    .nav-links li { 
        padding: 0.8rem 0; 
        font-size: 1.1rem; 
        font-weight: 600;
    }
    
    .social-links { 
        order: 4; /* Si posiziona in fondo al menu */
        padding: 1rem 0 2rem 0; 
        flex-direction: row; 
        flex-wrap: wrap; /* Permette al bottone di stare su una riga e le icone sull'altra */
        justify-content: center; 
        align-items: center;
        gap: 1.5rem; 
        border-bottom: none;
        box-shadow: none; 
    }
    
    /* Forza il bottone "Open CV" a stare largo e centrato su mobile */
    .social-links .btn-outline {
        width: 100%;
        max-width: 250px;
        justify-content: center;
        margin-bottom: 0.5rem;
    }
    
    .nav-links.active, .social-links.active { display: flex; }

    /* Animazione Hamburger */
    .menu-toggle.is-active .bar:nth-child(2) { opacity: 0; }
    .menu-toggle.is-active .bar:nth-child(1) { transform: translateY(9px) rotate(45deg); }
    .menu-toggle.is-active .bar:nth-child(3) { transform: translateY(-9px) rotate(-45deg); }
}

@media (max-width: 500px) {
    .hero h1 { font-size: 2.5rem; }
    .glass-card { padding: 1.5rem; border-radius: 16px; }
    
    .project-info { padding: 1.5rem; }
    .details-content { padding: 0 1.5rem 2rem 1.5rem; }
    .details-content h2 { font-size: 1.4rem; margin-top: 2rem; }
    .details-content h4 { font-size: 1.1rem; }
    .details-gallery { grid-template-columns: 1fr; margin-top: 1.5rem; }
    .details-gallery img { height: 180px; }
}