:root {
    --bg-main: #0f172a;        
    --bg-alt: #1e293b;
    --text-primary: #e2e8f0;   
    --text-muted: #94a3b8;     
    --accent: #d45eea;         
    --accent-contrast: #0f172a;
    --border-color: rgba(255, 255, 255, 0.1);   
}

[data-theme="light"] {
    --bg-main: #f8fafc;        
    --bg-alt: #f1f5f9;
    --text-primary: #0f172a;   
    --text-muted: #475569;     
    --accent: #6e0f76;         
    --accent-contrast: #f8fafc;
    --border-color: #e2e8f0;   
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }

/* ================= SIDEBAR NAVIGAZIONE VERTICALE (scroll-spy) ================= */
.side-nav {
    position: fixed;
    left: 1.5rem;
    top: 50%;
    transform: translateY(-50%);
    z-index: 40;
    display: flex;
    flex-direction: column;
    gap: 1.75rem;
}
.side-nav::before {
    content: '';
    position: absolute;
    left: 3.5px;
    top: 0;
    bottom: 0;
    width: 1px;
    background: var(--border-color);
    z-index: -1;
}
.side-nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
    color: var(--text-muted);
    opacity: 0.5;
    transition: opacity 0.3s ease, color 0.3s ease;
}
.side-nav-item:hover { opacity: 0.85; }
.side-nav-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    background-color: var(--text-muted);
    flex-shrink: 0;
    transition: background-color 0.3s ease, transform 0.3s ease;
}
.side-nav-label {
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    white-space: nowrap;
}
.side-nav-item.active {
    opacity: 1;
    color: var(--accent);
}
.side-nav-item.active .side-nav-dot {
    background-color: var(--accent);
    transform: scale(1.6);
}

/* Sotto una certa larghezza non c'è spazio per la sidebar senza sovrapporsi al contenuto */
@media (max-width: 1100px) {
    .side-nav { display: none; }
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Inter", sans-serif;
    background-color: var(--bg-main);
    color: var(--text-primary);
    line-height: 1.6;
    transition: background-color 0.3s, color 0.3s;
}

a { text-decoration: none; color: inherit; }
button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }

/* Contenitore Centrale */
.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 6rem 1.5rem;
}

/* Controlli Alto a Destra */
.top-bar { position: absolute; top: 1.5rem; right: 1.5rem; display: flex; gap: 1rem; z-index: 100; align-items: center; }

.language-switcher, .theme-switcher { display: flex; background: var(--bg-alt); border: 1px solid var(--border-color); border-radius: 8px; padding: 0.25rem; }
.language-switcher button, .theme-switcher button { 
    display: flex; align-items: center; justify-content: center;
    padding: 0.4rem 0.8rem; font-size: 0.85rem; font-weight: 600; color: var(--text-muted); border-radius: 6px; transition: all 0.2s;
}
.theme-switcher button { padding: 0.4rem; line-height: 0; width: 32px; height: 32px; }

/* Il verde si applica SOLO alla lingua attiva */
.language-switcher button.active { background: var(--accent); color: var(--accent-contrast); }

/* Hover generico per icone non attive */
.language-switcher button:hover:not(.active), .theme-switcher button:hover { color: var(--text-primary); }


/* Header */
.header { text-align: center; margin-bottom: 4rem; }
.name { font-size: 3rem; font-weight: 800; line-height: 1.1; margin-bottom: 0.5rem; color: var(--text-primary); }
.role { font-size: 1.25rem; font-weight: 500; margin-bottom: 1.5rem; color: var(--accent); }
.bio { color: var(--text-muted); max-width: 650px; margin: 0 auto 2.5rem auto; font-size: 1.1rem; }

/* Bottoni di Azione */
.action-buttons { display: flex; justify-content: center; flex-wrap: wrap; gap: 1rem; }
.btn-action { 
    display: inline-flex; align-items: center; gap: 0.5rem; 
    padding: 0.6rem 1.2rem; background-color: var(--bg-alt); 
    border: 1px solid var(--border-color); border-radius: 8px; 
    color: var(--text-primary); font-size: 0.9rem; font-weight: 600; transition: all 0.2s; cursor: pointer;
}
.btn-action:hover { border-color: var(--accent); color: var(--accent); transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,0.1); }
.highlight-btn { background-color: rgba(212, 94, 234, 0.1); color: var(--accent); border-color: rgba(212, 94, 234, 0.3); }

/* Sezioni Comuni */
.section{
    margin-bottom: 5rem;
    scroll-margin-top: 3rem;
}
.section-title { font-size: 1.5rem; border-bottom: 1px solid var(--border-color); padding-bottom: 0.5rem; margin-bottom: 1rem; color: var(--text-primary); }
.section-desc { color: var(--text-muted); margin-bottom: 2rem; font-size: 0.95rem; }

/* ================= PROGETTI E RICERCA — CAROUSEL CENTRATA E CIRCOLARE ================= */
.carousel {
    position: relative;
    padding-top: 1rem;
    padding-bottom: 1rem;
}
.carousel-viewport {
    overflow: hidden;
    width: 100%;
}
.carousel-track {
    display: flex;
    gap: 1.5rem;
    transition: transform 0.45s cubic-bezier(0.16, 1, 0.3, 1);
    will-change: transform;
    padding-top: 15px;    /* Spazio per l'animazione verso l'alto (translateY) */
    padding-bottom: 15px; /* Spazio inferiore (utile se aggiungerai ombreggiature) */
}
.carousel-track.no-transition { transition: none; }

.carousel-track .card { 
    width: 450px;
    min-height: 260px;
    flex: 0 0 auto; 
    background-color: var(--bg-alt); 
    border: 1px solid var(--border-color); 
    padding: 2rem 1.5rem; 
    border-radius: 12px; 
    display: flex; 
    flex-direction: column; 
    cursor: pointer;      
    text-decoration: none; 
    opacity: 0.75;
    transform: scale(0.94);
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), border-color 0.3s ease, opacity 0.4s ease;
}
.carousel-track .card.is-active { 
    opacity: 1;
    transform: scale(1);
}
.carousel-track .card.is-active:hover { 
    border-color: var(--accent); 
    transform: translateY(-4px) scale(1);
}

.card h3 { font-size: 1.2rem; color: var(--text-primary); margin-bottom: 0.75rem; }
.card p { color: var(--text-muted); font-size: 0.95rem; margin-bottom: 1.5rem; flex-grow: 1; }
.tags { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: auto; }
.tag { font-size: 0.75rem; padding: 0.25rem 0.6rem; background-color: var(--bg-main); border: 1px solid var(--border-color); border-radius: 6px; color: var(--accent); font-weight: 500; }

.research-content { display: flex; flex-direction: column; flex-grow: 1; }
.research-content h3 { font-size: 1.2rem; color: var(--text-primary); margin-bottom: 0.75rem; }
.research-content p { color: var(--text-muted); font-size: 0.95rem; margin-bottom: 1.5rem; flex-grow: 1; }

.video-card { padding: 0; overflow: hidden; cursor: default; min-height: 0; }
.video-card.is-active { cursor: default; }
.video-wrapper { position: relative; width: 100%; aspect-ratio: 16 / 9; background-color: var(--bg-main); }
.video-wrapper iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
/* L'iframe è cross-origin: un click al suo interno non risale al DOM della pagina.
   Se la card non è quella centrale, disattivo i click sull'iframe così il click
   arriva alla card e la porta al centro come per le altre sezioni. */
.video-card:not(.is-active) .video-wrapper iframe { pointer-events: none; }
.research-card .btn-action { align-self: flex-start; margin-top: auto; }

/* ================= FOOTER NUOVO LAYOUT ================= */
.footer { 
    padding-top: 3rem; 
    margin-top: 2rem;
    border-top: 1px solid var(--border-color); 
}
.footer-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
}
.footer-socials {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 1.5rem;
}
.social-link {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    color: var(--text-muted);
    font-size: 0.9rem;
    font-weight: 500;
    transition: color 0.3s, transform 0.3s;
}
.social-link:hover {
    color: var(--accent);
    transform: translateY(-3px);
}
.footer-info {
    text-align: center; 
    color: var(--text-muted); 
    font-size: 0.85rem;
}

/* ================= MODAL STUDI ED ESAMI ================= */
.modal-overlay {
    display: none; position: fixed; inset: 0; 
    background: rgba(15, 23, 42, 0.8); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
    z-index: 1000; align-items: center; justify-content: center;
}
.modal-overlay.active { display: flex; }
.modal-content {
    background: var(--bg-alt); border: 1px solid var(--border-color);
    padding: 2.5rem; border-radius: 12px; position: relative;
    max-width: 600px; width: 90%; max-height: 85vh; overflow-y: auto;
    animation: modalFadeIn 0.3s ease; box-shadow: 0 20px 40px rgba(0,0,0,0.4);
}
@keyframes modalFadeIn { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }

.modal-close { position: absolute; top: 1.5rem; right: 1.5rem; background: none; border: none; color: var(--text-muted); font-size: 2rem; cursor: pointer; line-height: 1; }
.modal-close:hover { color: var(--text-primary); }
.modal-title { font-size: 1.5rem; margin-bottom: 1.5rem; color: var(--text-primary); border-bottom: 1px solid var(--border-color); padding-bottom: 0.5rem;}

.education-list { display: flex; flex-direction: column; gap: 1rem; }

/* Etichette per dividere le sezioni nel popup */
.modal-divider {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--accent);
    margin-bottom: 0.25rem;
    font-weight: 700;
}

.edu-card { background: var(--bg-main); border: 1px solid var(--border-color); padding: 1.5rem; border-radius: 8px; }
.edu-card h3 { font-size: 1.1rem; color: var(--text-primary); margin-bottom: 0.25rem; }
.edu-card p { font-size: 0.95rem; color: var(--text-muted); margin-bottom: 0;}

/* Fisarmonica Corsi/Esami */
.details-accordion summary { display: flex; justify-content: space-between; align-items: center; cursor: pointer; list-style: none; margin-bottom: 0;}
.details-accordion summary::-webkit-details-marker { display: none; }
.dropdown-icon { color: var(--text-muted); transition: transform 0.3s ease; font-size: 0.8rem;}
.details-accordion[open] .dropdown-icon { transform: rotate(180deg); }

.accordion-content { margin-top: 1.5rem; padding-top: 1rem; border-top: 1px dashed var(--border-color); animation: slideDown 0.3s ease-out; }
@keyframes slideDown { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } }

.exam-list-title { font-weight: 700; color: var(--text-primary); font-size: 0.9rem; letter-spacing: 1px; text-transform: uppercase; margin-bottom: 0.75rem; }
.exam-list { list-style-position: inside; color: var(--text-muted); font-size: 0.95rem; padding-left: 0.5rem;}
ul.exam-list li { padding: 0.3rem 0; border-bottom: 1px solid rgba(255,255,255,0.05); }
ul.exam-list li:last-child { border-bottom: none; }

/* ================= MOBILE RESPONSIVE ================= */
@media (max-width: 768px) {
    .container { 
        padding-top: 7rem;
    }
    
    .top-bar { 
        position: absolute; 
        top: 2.5rem;
        left: 0;
        right: 0;
        justify-content: center; 
    }
    
    .action-buttons { flex-direction: column; }
    .btn-action { justify-content: center; }
    
    .carousel-track .card { 
        width: 260px;
        min-height: 380px;
    }
    .carousel-track .video-card { min-height: 0; }
}