/* =========================================
   VARIABILI E RESET
   ========================================= */
:root {
    --bg-color: #0f172a;
    --bg-card: #1e293b;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --accent-color: #38bdf8;
    --accent-hover: #0ea5e9;
    --font-main: 'Inter', sans-serif;
    --font-heading: 'Space Grotesk', sans-serif;
    --transition: all 0.3s ease;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-main);
    background-color: var(--bg-color);
    color: var(--text-main);
    line-height: 1.6;
    overflow-x: hidden;
    
    /* SFONDO A GRIGLIA */
    background-image: 
        linear-gradient(rgba(56, 189, 248, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(56, 189, 248, 0.03) 1px, transparent 1px);
    background-size: 30px 30px;
    background-position: center top;
    background-attachment: fixed; /* Mantiene la griglia ferma durante lo scroll */
}

a {
    text-decoration: none;
    color: var(--accent-color);
    transition: var(--transition);
}

a:hover {
    color: var(--accent-hover);
}

ul {
    list-style: none;
}

/* TITOLI CON FONT PERSONALIZZATO */
h1, h2, h3, .section-title {
    font-family: var(--font-heading);
}

/* =========================================
   NAVBAR
   ========================================= */
nav {
    position: fixed;
    top: 0;
    width: 100%;
    padding: 20px 50px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(15, 23, 42, 0.75);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    z-index: 1000;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    transition: transform 0.3s ease-in-out; /* Per l'effetto hide/show */
}

.logo {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-main);
    letter-spacing: 1px;
    text-decoration: none;
    display: inline-block;
    transition: var(--transition);
}

.logo span {
    color: var(--accent-color);
}

.logo:hover {
    opacity: 0.8;
}

.nav-links {
    display: flex;
    gap: 30px;
}

.nav-links a {
    color: var(--text-main);
    font-weight: 400;
    font-size: 0.95rem;
    position: relative;
}

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

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

/* =========================================
   SEZIONI GENERALI
   ========================================= */
section {
    padding: 100px 20px;
    max-width: 1100px;
    margin: 0 auto;
}

.section-title {
    font-size: 2.2rem;
    text-align: center;
    margin-bottom: 50px;
    position: relative;
}

.section-title::after {
    content: '';
    display: block;
    width: 60px;
    height: 4px;
    background: var(--accent-color);
    margin: 10px auto 0;
    border-radius: 2px;
}

/* Animazioni Scroll */
.reveal {
    opacity: 0;
    transform: translateY(30px);
    transition: all 0.8s ease;
}

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

/* =========================================
   HERO SECTION
   ========================================= */
#hero {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding-top: 120px;
    padding-bottom: 50px;
}

.hero-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.profile-img {
    width: 180px;
    height: 180px;
    border-radius: 50%;
    object-fit: cover;
    border: 4px solid var(--accent-color);
    box-shadow: 0 0 30px rgba(56, 189, 248, 0.4), inset 0 0 20px rgba(56, 189, 248, 0.2);
    margin-bottom: 20px;
    transition: var(--transition);
}

.profile-img:hover {
    transform: scale(1.05);
    box-shadow: 0 0 45px rgba(56, 189, 248, 0.6);
}

.hero-content h1 {
    font-size: 3.5rem;
    font-weight: 700;
}

/* EFFETTO GRADIENTE ANIMATO SUL NOME - VERSIONE AD ALTO CONTRASTO */
.hero-content h1 span {
    /* Uso colori molto più accesi e contrastanti: Ciano, Viola, Bianco, Ciano */
    background: linear-gradient(90deg, #38bdf8, #c084fc, #ffffff, #38bdf8);
    background-size: 200% auto;
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    /* Animazione più veloce: 2.5 secondi invece di 4 */
    animation: shine 2.5s linear infinite;
}

@keyframes shine {
    to { background-position: 200% center; }
}

.hero-content h2 {
    font-size: 1.5rem;
    color: var(--text-muted);
    font-weight: 400;
    margin-bottom: 15px;
    font-family: var(--font-main);
}

/* EFFETTO MACCHINA DA SCRIVERE */
.typing {
    border-right: 2px solid var(--accent-color);
    white-space: nowrap;
    overflow: hidden;
    display: inline-block;
    animation: blink 0.75s step-end infinite;
}

@keyframes blink {
    from, to { border-color: transparent }
    50% { border-color: var(--accent-color) }
}

.hero-content p {
    max-width: 600px;
    color: var(--text-muted);
    margin-bottom: 30px;
    font-size: 1.1rem;
}

.hero-buttons {
    display: flex;
    gap: 15px;
    margin-bottom: 20px;
    flex-wrap: wrap;
    justify-content: center;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 12px 28px;
    background: transparent;
    color: var(--accent-color);
    border: 2px solid var(--accent-color);
    border-radius: 30px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    font-family: var(--font-main);
    font-size: 1rem;
}

.btn:hover {
    background: var(--accent-color);
    color: var(--bg-color);
    transform: translateY(-2px);
}

.btn-primary {
    background: var(--accent-color);
    color: var(--bg-color);
}

.btn-primary:hover {
    background: var(--accent-hover);
    color: var(--bg-color);
}

.btn-outline {
    border-color: var(--text-muted);
    color: var(--text-main);
}

.btn-outline:hover {
    border-color: var(--text-main);
    background: var(--text-main);
}

.social-links {
    display: flex;
    gap: 20px;
    margin-top: 10px;
}

.social-links a {
    font-size: 1.8rem;
    color: var(--text-muted);
    transition: var(--transition);
}

.social-links a:hover {
    color: var(--accent-color);
    transform: translateY(-5px);
}

/* =========================================
   ABOUT SECTION
   ========================================= */
.about-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 40px;
    background: var(--bg-card);
    padding: 40px;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
}

.about-text p {
    color: var(--text-muted);
    margin-bottom: 20px;
    font-size: 1.1rem;
}

.about-info li {
    margin-bottom: 15px;
    font-size: 1.05rem;
    display: flex;
    align-items: center;
    gap: 15px;
}

.about-info i {
    color: var(--accent-color);
    width: 25px;
    text-align: center;
}

/* =========================================
   SKILLS SECTION
   ========================================= */
.skills-container {
    display: flex;
    flex-direction: column;
    gap: 30px;
}

.skill-category h3 {
    margin-bottom: 15px;
    color: var(--text-main);
    font-size: 1.3rem;
    display: flex;
    align-items: center;
    gap: 10px;
}

.skill-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.skill-tag {
    background: rgba(56, 189, 248, 0.1);
    color: var(--accent-color);
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.95rem;
    border: 1px solid rgba(56, 189, 248, 0.2);
    transition: var(--transition);
}

.skill-tag:hover {
    background: var(--accent-color);
    color: var(--bg-color);
    transform: translateY(-3px);
    box-shadow: 0 5px 15px rgba(56, 189, 248, 0.3);
}

/* =========================================
   EXPERIENCE TIMELINE
   ========================================= */
.timeline {
    position: relative;
    max-width: 800px;
    margin: 0 auto;
}

.timeline::after {
    content: '';
    position: absolute;
    width: 2px;
    background: var(--bg-card);
    top: 0;
    bottom: 0;
    left: 50%;
    margin-left: -1px;
}

.timeline-item {
    padding: 10px 40px;
    position: relative;
    background-color: inherit;
    width: 50%;
}

.timeline-item.left { left: 0; }
.timeline-item.right { left: 50%; }

.timeline-item::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    right: -10px;
    background-color: var(--bg-color);
    border: 4px solid var(--accent-color);
    top: 15px;
    border-radius: 50%;
    z-index: 1;
    transition: var(--transition);
}

.timeline-item:hover::after {
    background-color: var(--accent-color);
    box-shadow: 0 0 15px var(--accent-color);
}

.timeline-item.right::after {
    left: -10px;
}

.timeline-content {
    padding: 20px 30px;
    background-color: var(--bg-card);
    position: relative;
    border-radius: 10px;
    border: 1px solid rgba(255,255,255,0.05);
    transition: var(--transition);
}

.timeline-content:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 20px rgba(0,0,0,0.3);
}

.timeline-content h3 {
    color: var(--accent-color);
    margin-bottom: 5px;
    font-size: 1.2rem;
}

.timeline-content .date {
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-bottom: 10px;
    display: block;
    font-weight: 600;
}

.timeline-content p {
    color: var(--text-muted);
    font-size: 0.95rem;
}

/* =========================================
   PROJECTS SECTION
   ========================================= */
.projects-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 30px;
}

.project-card {
    background: var(--bg-card);
    padding: 30px;
    border-radius: 15px;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    border: 1px solid rgba(255,255,255,0.05);
    display: flex;
    flex-direction: column;
    height: 100%;
}

.project-card:hover {
    transform: translateY(-8px) scale(1.02);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4), 0 0 20px rgba(56, 189, 248, 0.2);
    border-color: rgba(56, 189, 248, 0.5);
}

.project-card h3 {
    color: var(--text-main);
    margin-bottom: 15px;
    font-size: 1.3rem;
}

.project-card p {
    color: var(--text-muted);
    font-size: 0.95rem;
    margin-bottom: 20px;
    flex-grow: 1;
}

.project-tech {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: auto;
    margin-bottom: 15px;
}

.project-tech span {
    font-size: 0.8rem;
    color: var(--accent-color);
    background: rgba(56, 189, 248, 0.1);
    padding: 4px 10px;
    border-radius: 12px;
}

.project-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-top: auto;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--accent-color);
    transition: var(--transition);
}

.project-link:hover {
    color: var(--accent-hover);
    text-decoration: underline;
}

/* =========================================
   CONTACT SECTION
   ========================================= */
.contact-container {
    max-width: 600px;
    margin: 0 auto;
    background: var(--bg-card);
    padding: 40px;
    border-radius: 15px;
    border: 1px solid rgba(255,255,255,0.05);
}

.contact-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.input-group label {
    font-weight: 600;
    color: var(--text-main);
    font-size: 0.95rem;
}

.input-group input,
.input-group textarea {
    width: 100%;
    padding: 12px 15px;
    background: rgba(15, 23, 42, 0.5);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 8px;
    color: var(--text-main);
    font-family: var(--font-main);
    font-size: 1rem;
    transition: var(--transition);
}

.input-group input:focus,
.input-group textarea:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 10px rgba(56, 189, 248, 0.2);
}

.contact-form .btn {
    margin-top: 10px;
    width: 100%;
    justify-content: center;
}

/* =========================================
   FOOTER
   ========================================= */
footer {
    text-align: center;
    padding: 30px;
    background: var(--bg-color);
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-top: 50px;
    border-top: 1px solid rgba(255,255,255,0.05);
}

/* =========================================
   RESPONSIVE DESIGN (Mobile/Tablet)
   ========================================= */
@media (max-width: 768px) {
    nav {
        padding: 15px 20px;
    }
    .nav-links {
        display: none; /* In un sito reale andrebbe aggiunto un menu hamburger */
    }
    .hero-content h1 {
        font-size: 2.5rem;
    }
    .hero-content h2 {
        font-size: 1.2rem;
        white-space: normal; /* Permette al testo di andare a capo su mobile */
        border-right: none;
        animation: none;
    }
    .about-grid {
        grid-template-columns: 1fr;
    }
    .timeline::after {
        left: 31px;
    }
    .timeline-item {
        width: 100%;
        padding-left: 70px;
        padding-right: 25px;
    }
    .timeline-item.right {
        left: 0%;
    }
    .timeline-item.left::after, .timeline-item.right::after {
        left: 21px;
    }
}
