:root {
    --bg-color: #121212;
    --text-color: #E0E0E0;
    --primary-color: #BB86FC;
    --card-bg: #1E1E1E;
    --border-color: #333;
}

/* === BASE === */
body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    margin: 0;
    line-height: 1.6;
    overflow-x: hidden;
}

/* === PAGE TRANSITIONS & ANIMATIONS (NEW) === */
.page-wrapper {
    opacity: 0;
    animation: fadeIn 0.5s ease-in forwards;
}

.page-wrapper.fade-out {
    opacity: 1;
    animation: fadeOut 0.5s ease-out forwards;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes fadeOut {
    from { opacity: 1; }
    to { opacity: 0; }
}

.fade-in-section {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.8s ease-out, transform 0.8s ease-out;
}

.fade-in-section.is-visible {
    opacity: 1;
    transform: translateY(0);
}

/* === HERO & DYNAMIC BACKGROUND (MODIFIED) === */
.hero {
    height: 60vh;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    background: linear-gradient(135deg, rgba(17,17,17,0.8), rgba(29,29,29,0.9));
    position: relative;
    overflow: hidden;
}

#particles-js {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0; /* Behind content */
}

.hero::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    /* Keep the gradient but remove the static image */
    background-image: none; 
    filter: brightness(0.4) grayscale(0.2);
    z-index: -1;
}

.hero-content {
    position: relative;
    z-index: 1; /* Above particles */
}

.hero-content h1 {
    font-size: 3.5rem;
    font-weight: 900;
    margin-bottom: 0.5rem;
}

.hero-content .subtitle {
    font-size: 1.5rem;
    color: var(--primary-color);
    font-weight: 400;
}

.social-links a {
    color: var(--text-color);
    text-decoration: none;
    margin: 0 1rem;
    font-weight: 700;
    transition: color 0.3s ease;
}

.social-links a:hover {
    color: var(--primary-color);
}

/* === MAIN CON BACKGROUND === */
main {
    max-width: 1100px;
    margin: 4rem auto;
    padding: 3rem 2rem;
    position: relative;
    border-radius: 15px;
    overflow: hidden;
    background: rgba(18, 18, 18, 0.9);
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
}

main::before {
    content: '';
    position: absolute;
    inset: 0;
    background: url('images/5040007.jpg') center/cover no-repeat;
    z-index: -1;
    filter: brightness(0.35) grayscale(0.3);
}

/* === SEZIONI TESTO === */
section {
    margin-bottom: 4rem;
    padding: 0 1.5rem;
}

h2 {
    font-size: 2.5rem;
    font-weight: 900;
    text-align: center;
    margin-bottom: 2rem;
    border-bottom: 3px solid var(--primary-color);
    display: inline-block;
    padding-bottom: 0.5rem;
}

#projects h2, #about h2 {
    display: block;
}

#about p {
    max-width: 800px;
    margin: 0 auto;
    line-height: 1.8;
    font-size: 1.1rem;
    text-align: justify;
    color: var(--text-color);
    padding: 0 1rem;
}

/* === GRIGLIA REPOSITORY === */
.grid-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 3rem;
    justify-items: center;
    align-items: start;
    padding: 1rem;
}

/* === CARD BASE (MODIFIED FOR TILT) === */
.repo-card {
    width: 100%;
    max-width: 350px;
    height: 260px;
    perspective: 1000px;
    position: relative;
    cursor: pointer;
    transition: transform 0.2s ease-out, box-shadow 0.3s ease; /* Modified for smooth tilt reset */
}

/* === CARD INTERNA === */
.card-inner {
    width: 100%;
    height: 100%;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.8s ease-in-out;
    transform-origin: center center;
}

/* Ruota solo su desktop con hover */
@media (hover: hover) and (pointer: fine) {
    .repo-card:hover .card-inner {
        transform: rotateY(180deg);
    }
}

/* === CARD FRONT E BACK === */
.card-front, .card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    border-radius: 10px;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 1rem;
    box-sizing: border-box;
}

/* Fronte */
.card-front {
    background-color: var(--card-bg);
    color: var(--text-color);
    border: 1px solid var(--border-color);
    z-index: 2;
}

/* Retro */
.card-back {
    background-color: var(--primary-color);
    color: #000 !important;
    border: 1px solid var(--primary-color);
    transform: rotateY(180deg);
}

.card-back p {
    color: #000 !important;
    margin-bottom: 1rem;
    font-size: 0.95rem;
    text-align: center;
    padding: 0 0.5rem;
}

/* === LINK NEL RETRO === */
.repo-link.back-link {
    background-color: #000;
    color: var(--primary-color);
    border: 1px solid #000;
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    border-radius: 5px;
    transition: background-color 0.3s ease, color 0.3s ease;
}

.repo-link.back-link:hover {
    background-color: #333;
    color: #fff;
}

/* Ombra all’hover */
.repo-card:hover {
    box-shadow: 0 10px 20px rgba(0,0,0,0.25);
}

/* Testo */
.repo-card h3 {
    margin-top: 0;
    color: var(--primary-color);
    font-size: 1.4rem;
    text-align: center;
}

.repo-card p {
    flex-grow: 1;
    margin-bottom: 1.5rem;
    color: #B0B0B0;
    text-align: center;
}

/* === Classe per la rotazione su click === */
.repo-card.flipped .card-inner {
    transform: rotateY(180deg);
}

/* === FOOTER E PROFILO === */
footer {
    text-align: center;
    padding: 2rem;
    border-top: 1px solid var(--border-color);
    margin-top: 4rem;
}

#profile-picture {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 1.5rem 0;
}

.profile-img {
    width: 300px;
    height: 300px;
    object-fit: cover;
    display: block;
    border-radius: 50%;
    border: 4px solid var(--primary-color);
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.6);
}

/* ======================================= */
/* === NUOVE REGOLE PER PAGINA ABOUT ME === */
/* ======================================= */
.top-nav {
    position: absolute;
    top: 2rem;
    right: 2rem;
    z-index: 10;
}

.nav-button {
    background-color: var(--primary-color);
    color: #121212;
    padding: 0.6rem 1.2rem;
    border-radius: 5px;
    text-decoration: none;
    font-weight: 700;
    transition: background-color 0.3s, color 0.3s, transform 0.3s;
    border: 2px solid var(--primary-color);
}

.nav-button:hover {
    background-color: transparent;
    color: var(--primary-color);
    transform: translateY(-3px);
}

#about-me-details .about-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 3rem;
    align-items: center;
    text-align: left;
}

#about-me-details .about-text h2, 
#passions h2 {
    text-align: left;
}

#about-me-details .about-text p,
#passions p {
    font-size: 1.1rem;
    line-height: 1.8;
    text-align: justify;
    color: var(--text-color);
    margin-bottom: 1.5rem;
}

#about-me-details .about-text p strong {
    color: var(--primary-color);
    font-weight: 700;
}

#about-me-details .about-image {
    display: flex;
    justify-content: center;
    align-items: center;
}

#about-me-details .about-image .profile-img {
    width: 250px;
    height: 250px;
}

/* === RESPONSIVE (AGGIORNAMENTI) === */
@media (max-width: 900px) {
    .grid-container {
        grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
        gap: 2rem;
    }

    main {
        padding: 2rem 1.5rem;
    }

    #about p {
        font-size: 1rem;
        line-height: 1.6;
        padding: 0 0.5rem;
    }
    
    #about-me-details .about-grid {
        grid-template-columns: 1fr;
        gap: 2.5rem;
    }

    #about-me-details .about-text h2, 
    #passions h2 {
        text-align: center;
    }
}

@media (max-width: 768px) {
    .hero-content h1 {
        font-size: 2.8rem;
    }
    
    .hero-content .subtitle {
        font-size: 1.2rem;
    }

    .grid-container {
        grid-template-columns: 1fr;
        justify-items: center;
    }
    
    .profile-img {
        width: 220px;
        height: 220px;
    }

    .repo-card {
        max-width: 100%;
    }

    main {
        margin: 2rem auto;
        padding: 2rem 1rem;
        border-radius: 10px;
    }

    #about p {
        text-align: left;
    }
    
    .top-nav {
        top: 1rem;
        right: 1rem;
    }

    .nav-button {
        padding: 0.5rem 1rem;
        font-size: 0.9rem;
    }
}

#vinted-profile {
    margin-bottom: 4rem;
    padding: 0 1.5rem;
    color: var(--text-color);
}

#vinted-profile h2 {
    font-size: 2.5rem;
    font-weight: 900;
    text-align: left;
    margin-bottom: 2rem;
    border-bottom: 3px solid var(--primary-color);
    display: inline-block;
    padding-bottom: 0.5rem;
}

#vinted-profile p {
    max-width: 800px;
    margin: 0 auto;
    line-height: 1.8;
    font-size: 1.1rem;
    text-align: justify;
    color: var(--text-color);
    padding: 0 1rem;
}

#vinted-profile a {
    color: var(--primary-color);
    font-weight: 700;
    text-decoration: none;
    transition: color 0.3s ease;
}

#vinted-profile a:hover {
    color: var(--text-color);
    text-decoration: underline;
}

/* === STILE PAGINA CV === */
#cv, #experience, #education, #skills, #contacts {
    margin-bottom: 4rem;
    padding: 0 1.5rem;
    color: var(--text-color);
}

#cv h2, #experience h2, #education h2, #skills h2, #contacts h2 {
    font-size: 2.2rem;
    font-weight: 900;
    color: var(--primary-color);
    margin-bottom: 1.5rem;
    border-bottom: 3px solid var(--primary-color);
    display: inline-block;
    padding-bottom: 0.4rem;
}

#cv p, #experience p, #education p, #skills p, #contacts p {
    font-size: 1.1rem;
    line-height: 1.8;
    text-align: justify;
    color: var(--text-color);
    max-width: 900px;
    margin: 0 auto 1.5rem;
}

#experience ul, #education ul, #skills ul {
    list-style: none;
    padding: 0;
    max-width: 900px;
    margin: 0 auto;
}

#experience li, #education li, #skills li {
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 1.2rem 1.5rem;
    margin-bottom: 1rem;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

#experience li:hover, #education li:hover, #skills li:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.5);
}

#skills li {
    display: inline-block;
    background-color: var(--primary-color);
    color: #000;
    font-weight: 700;
    border: none;
    padding: 0.6rem 1rem;
    border-radius: 20px;
    margin: 0.4rem;
    box-shadow: 0 3px 8px rgba(0,0,0,0.3);
}

#contacts a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 700;
    transition: color 0.3s ease;
}

#contacts a:hover {
    color: #fff;
    text-decoration: underline;
}

#contacts p {
    text-align: center;
    font-size: 1.1rem;
}

/* Responsive per la pagina CV */
@media (max-width: 768px) {
    #cv h2, #experience h2, #education h2, #skills h2, #contacts h2 {
        font-size: 1.8rem;
        text-align: center;
    }

    #experience li, #education li {
        padding: 1rem;
    }

    #skills li {
        font-size: 0.9rem;
        padding: 0.5rem 0.8rem;
    }

    #contacts p {
        font-size: 1rem;
    }
}