/* --- Variabili e Stili Globali --- */
:root {
    /* Tema Scuro (Default) */
    --bg-color: #121212;
    --bg-secondary-color: #1e1e1e;
    --text-color: #e0e0e0;
    --primary-color: #4a90e2;
    --heading-color: #ffffff;
    --border-color: #333;
    --card-bg-color: #2a2a2a;
    --shadow-color: rgba(0, 0, 0, 0.5);
}

body.light-theme {
    /* Tema Chiaro */
    --bg-color: #f4f4f9;
    --bg-secondary-color: #ffffff;
    --text-color: #333333;
    --primary-color: #0056b3;
    --heading-color: #000000;
    --border-color: #ddd;
    --card-bg-color: #ffffff;
    --shadow-color: rgba(0, 0, 0, 0.1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    transition: background-color 0.3s, color 0.3s;
}

section {
    min-height: 100vh;
    padding: 120px 10% 40px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
}

.section-title {
    font-size: 3rem;
    color: var(--heading-color);
    margin-bottom: 50px;
    font-weight: 700;
}

/* --- Barra di Navigazione --- */
.navbar {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 5%;
    background-color: var(--bg-secondary-color);
    box-shadow: 0 2px 10px var(--shadow-color);
    z-index: 1000;
    transition: background-color 0.3s;
}

.nav-logo a {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--heading-color);
    text-decoration: none;
}

.nav-links {
    list-style: none;
    display: flex;
    gap: 25px;
}

.nav-link {
    color: var(--text-color);
    text-decoration: none;
    font-size: 1rem;
    font-weight: 500;
    position: relative;
    padding-bottom: 5px;
    transition: color 0.3s;
}

.nav-link:hover {
    color: var(--primary-color);
}

.nav-link.active {
    color: var(--primary-color);
    font-weight: 600;
}

.nav-link.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 2px;
    background-color: var(--primary-color);
}

/* --- Selettore Tema --- */
.theme-switcher {
    position: relative;
}
/* --- NUOVE REGOLE PER IL SELETTORE TEMA --- */
.theme-switcher {
    cursor: pointer;
    font-size: 1.5rem; /* Dimensione delle icone */
    color: var(--heading-color);
    position: relative;
    width: 24px; /* Larghezza fissa per evitare spostamenti */
    height: 24px; /* Altezza fissa */
}

.theme-switcher i {
    position: absolute;
    transition: opacity 0.3s, transform 0.3s;
}

/* Default (Dark Mode): Mostra il sole, nascondi la luna */
.theme-switcher .fa-moon {
    opacity: 0;
    transform: scale(0);
}
.theme-switcher .fa-sun {
    opacity: 1;
    transform: scale(1);
}

/* Light Mode: Mostra la luna, nascondi il sole */
body.light-theme .theme-switcher .fa-moon {
    opacity: 1;
    transform: scale(1);
}
body.light-theme .theme-switcher .fa-sun {
    opacity: 0;
    transform: scale(0);
}

.theme-toggle-checkbox:checked + .theme-toggle-label::after {
    transform: translateX(24px);
}

/* --- Sezione Home --- */
#home {
    justify-content: center;
}
.home-content h1 {
    font-size: 4rem;
    color: var(--heading-color);
    margin-bottom: 10px;
}
.home-content p {
    font-size: 1.8rem;
    color: var(--text-color);
}
.cursor {
    animation: blink 0.7s infinite;
}
@keyframes blink {
    50% { opacity: 0; }
}
.social-icons {
    margin-top: 30px;
}
.social-icons a {
    color: var(--text-color);
    font-size: 1.5rem;
    margin: 0 15px;
    display: inline-block;
    width: 40px;
    height: 40px;
    line-height: 40px;
    border-radius: 50%;
    background-color: var(--card-bg-color);
    transition: transform 0.3s, background-color 0.3s;
}
.social-icons a:hover {
    transform: translateY(-5px);
    background-color: var(--primary-color);
    color: white;
}

/* --- Sezione About --- */
.about-container {
    display: flex;
    align-items: center;
    gap: 50px;
    max-width: 1000px;
    text-align: left;
}
.about-text {
    flex: 2;
}
.about-text p {
    margin-bottom: 15px;
    line-height: 1.6;
}
.about-image {
    flex: 1;
}
.image-placeholder {
    width: 250px;
    height: 250px;
    background-color: #ccc;
    border-radius: 15px;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    background-color: var(--border-color);
}
.image-placeholder::before { /* Spalle */
    content: '';
    position: absolute;
    bottom: 0;
    width: 100%;
    height: 100px;
    background-color: #46637f;
    border-bottom-left-radius: 15px;
    border-bottom-right-radius: 15px;
}
.image-placeholder::after { /* Testa */
    content: '';
    position: absolute;
    top: 30px;
    width: 100px;
    height: 100px;
    background-color: #d4a35d;
    border-radius: 50%;
}

/* --- Sezione Skills --- */
.skills-intro {
    margin-bottom: 40px;
    max-width: 800px;
    line-height: 1.6;
}
.skills-grid {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 40px;
    width: 100%;
    max-width: 1200px;
}
.skill-category {
    flex: 1;
    min-width: 300px;
}
.skill-category h3 {
    color: var(--heading-color);
    margin-bottom: 20px;
    font-size: 1.5rem;
}
.skill-icons {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 15px;
}
.skill-item {
    background-color: var(--card-bg-color);
    padding: 10px 20px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    font-weight: 500;
}

/* --- Timeline (Education & Experience) --- */
.timeline {
    position: relative;
    max-width: 800px;
    width: 100%;
    margin: 0 auto;
}
.timeline::after {
    content: '';
    position: absolute;
    width: 2px;
    background-color: var(--primary-color);
    top: 0;
    bottom: 0;
    left: 50%;
    margin-left: -1px;
}
.timeline-item {
    padding: 10px 40px;
    position: relative;
    width: 50%;
}
.timeline-item:nth-child(odd) {
    left: 0;
    text-align: right;
}
.timeline-item:nth-child(even) {
    left: 50%;
    text-align: left;
}
.timeline-item::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    right: -8px;
    background-color: var(--bg-color);
    border: 3px solid var(--primary-color);
    top: 25px;
    border-radius: 50%;
    z-index: 1;
}
.timeline-item:nth-child(even)::after {
    left: -8px;
}
.timeline-content {
    padding: 20px 30px;
    background-color: var(--card-bg-color);
    position: relative;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}
.timeline-content h3 {
    color: var(--heading-color);
    margin-bottom: 5px;
}
.timeline-content h4 {
    color: var(--primary-color);
    margin-bottom: 10px;
    font-style: italic;
}
.timeline-content ul {
    list-style-position: inside;
    padding-left: 5px;
}
.timeline-content ul li {
    margin-bottom: 5px;
}
.timeline-date {
    position: absolute;
    top: 22px;
    background-color: var(--primary-color);
    color: white;
    padding: 5px 10px;
    border-radius: 15px;
    font-size: 0.9rem;
    z-index: 2;
}
.timeline-item:nth-child(odd) .timeline-date {
    left: -150px;
}
.timeline-item:nth-child(even) .timeline-date {
    right: -150px;
}

/* --- Sezione Projects --- */
.projects-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 30px;
    width: 100%;
    max-width: 1200px;
    margin-bottom: 40px;
}
.project-card {
    background-color: var(--card-bg-color);
    border-radius: 10px;
    overflow: hidden;
    text-align: left;
    display: flex;
    flex-direction: column;
    border: 1px solid var(--border-color);
    transition: transform 0.3s, box-shadow 0.3s;
}
.project-card:hover {
    transform: translateY(-10px);
    box-shadow: 0 10px 20px var(--shadow-color);
}
.project-card img {
    width: 100%;
    height: 200px;
    object-fit: cover;
}
.project-card h3 {
    color: var(--heading-color);
    padding: 15px 20px 5px;
}
.project-card ul {
    padding: 0 20px;
    list-style-position: inside;
    flex-grow: 1;
}
.project-card ul li {
    margin-bottom: 8px;
    font-size: 0.95rem;
}
.project-links {
    padding: 15px 20px;
}
.btn {
    background-color: var(--primary-color);
    color: white;
    padding: 10px 20px;
    border-radius: 5px;
    text-decoration: none;
    border: none;
    cursor: pointer;
    font-weight: 500;
    transition: background-color 0.3s;
    margin-right: 10px;
}
.btn:hover {
    background-color: #3a7bc8;
}
body.light-theme .btn:hover {
    background-color: #00418a;
}
.project-tags {
    padding: 10px 20px;
    border-top: 1px solid var(--border-color);
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.project-tags span {
    background-color: var(--bg-color);
    padding: 5px 10px;
    border-radius: 5px;
    font-size: 0.8rem;
}
.show-more-btn {
    margin-top: 20px;
}

/* --- Sezione Resume --- */
#resume p {
    margin-bottom: 30px;
    font-size: 1.2rem;
}

/* --- Media Queries per la Reattività --- */
@media (max-width: 992px) {
    .nav-links {
        display: none; /* Nascondi i link su schermi piccoli, potresti aggiungere un menu hamburger */
    }
    .about-container {
        flex-direction: column;
    }
    .about-image {
        margin-top: 30px;
    }
    .timeline::after {
        left: 31px;
    }
    .timeline-item {
        width: 100%;
        padding-left: 70px;
        padding-right: 25px;
    }
    .timeline-item:nth-child(odd),
    .timeline-item:nth-child(even) {
        left: 0;
        text-align: left;
    }
    .timeline-item::after {
        left: 23px;
    }
    .timeline-date {
        position: relative;
        top: auto;
        left: auto !important;
        right: auto !important;
        display: inline-block;
        margin-bottom: 10px;
    }
    .timeline-content {
        text-align: left;
    }
}

@media (max-width: 768px) {
    section {
        padding: 100px 5% 30px;
    }
    .section-title {
        font-size: 2.5rem;
    }
    .home-content h1 {
        font-size: 3rem;
    }
    .home-content p {
        font-size: 1.5rem;
    }
}