/* VARIABILI ROOT PER I TEMI */
:root {
    /* Light Theme */
    --body-bg: #FFFFFF;
    --text-color-general: #212226;
    --text-color-headings: #0C0D0C;
    --navbar-bg: #F2C4D5;
    --navbar-text-color: #580B59;
    --navbar-link-hover-active: #040DBF;
    --contact-bg: #F2C4D5;
    --footer-text-color: #212226;
    --icon-color: #023059;
    --text-shadow-color: #F2C4D5;

    /* Animation colors */
    --anim-color-stage1: #023059; /* --color-accent */
    --anim-color-stage2: #040DBF; /* --color-logo */
    --anim-color-stage3: #025940; /* --color-first-animation */
    --anim-color-stage4: #580B59; /* --color-second-animation */
    --anim-color-stage5: #F2C4D5; /* --color-secondary */

    /* Original colors */
    --color-primary: #FFFFFF;
    --color-secondary: #F2C4D5;
    --color-text: #212226;
    --color-accent: #023059;
    --color-very-dark-text: #0C0D0C;
    --color-logo: #040DBF;
    --color-first-animation: #025940;
    --color-second-animation: #580B59;

    /* Font */
    --font-primary: "Cabin", sans-serif;
    --font-titles: "Playwrite SK", cursive;
    --regular: 400;
    --bold: 700;
}

/* Dark Theme */
body.dark-mode {
    --body-bg: #1a1a2e; 
    --text-color-general: #e0e0e0; 
    --text-color-headings: #f0f0f0; 
    --navbar-bg: #2a2a4a; 
    --navbar-text-color: #8be9fd;
    --navbar-link-hover-active: #00bfff; 
    --contact-bg: #2a2a4a;
    --footer-text-color: #c0c0c0; 
    --icon-color: #61dafb; 
    --text-shadow-color: #3a3a5e; 

    /* Animation colors for dark mode */
    --anim-color-stage1: #61dafb; 
    --anim-color-stage2: #00bfff; 
    --anim-color-stage3: #2ecc71; 
    --anim-color-stage4: #9b59b6; 
    --anim-color-stage5: #5e6b8c; 
}

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

/* Base variables */
body {
    background-color: var(--body-bg);
    color: var(--text-color-general); /* Default text color */
    font-family: var(--font-primary);
    transition: background-color 0.3s ease, color 0.3s ease;
    overflow-x: hidden; /* Prevent horizontal scroll */
}

/* TOP-NAVBAR */
.top-navbar {
    display: flex;
    justify-content: center; /* Per centrare il logo sull'intera larghezza */
    align-items: center;
    padding: 3% 20px 0 20px; 
    position: relative;
    z-index: 1000;
}

.top-navbar .titles {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center; 
    text-align: center; 
}

.top-navbar a {
    text-decoration: none;
    color: inherit;
}

.top-navbar h1 {
    font-family: var(--font-titles);
    font-weight: var(--normal);
    font-size: 30px;
    text-shadow: 0px 4px 3px var(--text-shadow-color);
    animation: transform-color infinite 12s;
}

.top-navbar h2 {
    font-family: var(--font-titles);
    font-weight: var(--normal);
    font-size: 20px;
    text-shadow: 0px 4px 3px var(--text-shadow-color);
    animation: transform-color infinite 12s;
}

/* Contenitore per il bottone toggle e il menu burger a destra (desktop) */
.top-right-controls {
    display: flex;
    align-items: center;
    gap: 20px; /* Spazio tra toggle e menu icon */
    position: absolute; /* Posiziona questo contenitore a destra */
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
}

/* Theme Toggle Button Styling */
.theme-toggle-button {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--icon-color);
    padding: 5px;
    border-radius: 50%;
    transition: background-color 0.3s ease, color 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
}

.theme-toggle-button:hover {
    background-color: rgba(0, 0, 0, 0.1);
}

.theme-toggle-button svg {
    width: 24px;
    height: 24px;
    /* Transizioni per opacità e trasformazione */
    transition: opacity 0.3s ease, transform 0.3s ease;
}


/* LOGICA PER COSA FARÀ IL BOTTONE */

/* Per default (Light Mode, nessun dark-mode class sul body): */
.sun-icon {
    display: none; /* Nasconde l'icona del sole in modalità chiara */
    opacity: 0;
    transform: rotate(-90deg);
}

.moon-icon {
    display: block; /* Mostra l'icona della luna in modalità chiara (clicca per andare in dark) */
    opacity: 1;
    transform: rotate(0deg);
}

/* Quando il body ha la classe dark-mode: */
body.dark-mode .sun-icon {
    display: block; /* Mostra l'icona del sole in modalità scura (clicca per tornare in light) */
    opacity: 1;
    transform: rotate(0deg);
}

body.dark-mode .moon-icon {
    display: none; /* Nasconde l'icona della luna in modalità scura */
    opacity: 0;
    transform: rotate(90deg);
}


/* MENU ICON (Hamburger) */
.menu-icon {
    display: none; /* Nascosto per desktop */
    flex-direction: column;
    cursor: pointer;
    z-index: 1002;
    /* margin-left gestito da gap in top-right-controls */
}

.menu-icon span {
    background-color: var(--icon-color);
    height: 3px;
    width: 25px;
    margin: 4px 0;
    transition: 0.2s;
}

/* Animazione icona hamburger */
.menu-icon.toggle span:nth-child(1) {
    transform: rotate(-45deg) translate(-8px, 7px);
}
.menu-icon.toggle span:nth-child(2) {
    opacity: 0;
}
.menu-icon.toggle span:nth-child(3) {
    transform: rotate(45deg) translate(-8px, -7px);
}


/* NAVBAR */
nav.nav-primary {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    width: 100%;
    margin-top: 3%;
    background-color: var(--navbar-bg);
    padding: 20px 10px;
    transition: background-color 0.3s ease;
}

.nav-primary ul {
    display: flex;
    list-style: none;
    padding: 0;
    margin: 0;
}

.nav-primary ul li a {
    text-decoration: none;
    text-transform: uppercase;
    font-family: var(--font-primary);
    font-weight: var(--regular);
    font-size: 20px;
    color: var(--navbar-text-color);
    transition: color 0.2s ease;
}

.nav-primary ul li {
    padding: 10px 15px;
}

.nav-primary ul li a:hover {
    color: var(--navbar-link-hover-active);
}

.nav-primary .active a {
    color: var(--navbar-link-hover-active);
    font-weight: bold;
}


/* RESPONSIVE NAVBAR */
@media (max-width: 768px) {
    .top-navbar {
        /* Ritorna a justify-content: space-between per mobile per logo a sinistra e controlli a destra */
        justify-content: space-between;
        align-items: center;
        padding: 20px; /* Padding più uniforme per mobile */
        height: auto; /* Altezza flessibile per contenere il contenuto */
    }

    .top-navbar .titles {
        flex-direction: column;
        align-items: flex-start; /* Allinea a sinistra su mobile */
        text-align: left; /* Assicura allineamento testo a sinistra */
        position: static; /* Non più assoluto su mobile */
        left: auto;
        transform: none;
    }

    .top-navbar h1 {
        font-size: 25px;
    }

    .top-navbar h2 {
        font-size: 15px;
    }

    .top-right-controls {
        display: flex; /* Mostra il contenitore dei controlli */
        align-items: center;
        gap: 20px;
        position: static; /* Non più assoluto su mobile, si comporta come un elemento flex normale */
        right: auto;
        top: auto;
        transform: none;
    }

    .menu-icon {
        display: flex; /* Mostra l'hamburger su mobile */
    }


    nav.nav-primary {
        justify-content: end;
        width: 100%;
        margin-top: 5%;
        background-color: var(--body-bg);
        position: absolute;
        top: 140px; 
        left: 0;
        z-index: 999;
        flex-direction: column;
        align-items: center;
        /* La transizione è gestita dal display del <ul> stesso tramite JS */
        transition: none;
        height: auto;
        max-height: calc(100vh - 140px); /* Altezza massima basata sul valore 'top' */
        overflow-y: auto;
    }

    /* <ul> originale, gestito da JS tramite la classe 'show' */
    .nav-primary ul {
        display: none; /* Nascosto di default su mobile */
        flex-direction: column;
        width: 100%;
        background-color: var(--icon-color);
        position: static; /* Importante: static all'interno di un genitore assoluto */
        padding-top: 20px;
    }

    /* <ul> originale quando il menu è 'show' */
    .nav-primary ul.show {
        display: flex; /* Mostra il <ul> quando la classe 'show' è attivata da JS */
    }

    .nav-primary ul li {
        text-align: center;
        margin: 10px 0;
    }

    .nav-primary ul li a {
        color: var(--body-bg);
    }

    .nav-primary ul li a:hover {
        color: var(--navbar-bg);
    }

    .nav-primary .active a {
        color: var(--navbar-bg);
        font-weight: bold;
    }
}


/* DESCRIPTION */
.description {
    display: flex;
    flex-direction: row;
    justify-content: space-around;
    /* Rimosso il padding-top qui, sarà gestito dal margin-top di .description-titles */
    padding-top: 0;
}

.description-titles {
    display: flex;
    flex-direction: column;
    /* Ripristina il margin-top originale (20%) per lo spazio superiore nella sezione */
    margin-top: 20%;
    margin-left: 5%;
}

.description-titles h1 {
    font-family: var(--font-primary);
    font-weight: var(--bold);
    color: var(--text-color-headings);
    line-height: normal;
    font-size: 40px;
}

.description-titles h2 {
    font-family: var(--font-primary);
    font-weight: var(--bold);
    color: var(--text-color-general);
    font-size: 25px;
    margin-top: 3%;
}

.description img {
    margin-top: 2%;
    margin-right: 5%;
}


/* RESPONSIVE DESCRIPTION MOBILE */
@media (max-width: 768px) {
    .description img {
        display: none;
    }

    .description {
        flex-direction: column;
        justify-content: center;
        align-items: center;
        text-align: center;
        padding: 0 4%;
        /* Riduci il padding-top mobile per far salire il testo, mantenendo lo spazio per navbar e menu */
        padding-top: 100px; /* Un valore più compatto per mobile */
        margin-bottom: 0; /* Rimuovi eventuali margini che causano spazio vuoto sotto */
    }

    .description-titles {
        /* Su mobile, rimuovi il margin-top percentuale e fallo iniziare più in alto */
        margin-top: 0;
        padding-left: 4%;
        padding-right: 4%;
        align-items: center;
    }

    .description-titles h1 {
        color: var(--text-color-headings);
        font-size: 25px;
    }

    .description-titles h2 {
        color: var(--text-color-general);
        font-size: 15px;
        margin-top: 3%;
    }
}

/* RESPONSIVE DESCRIPTION TABLET */
@media (min-width: 600px) and (max-width: 1024px) {
    .description {
        align-items: center;
        padding-top: 100px;
    }

    .description-titles {
        margin-top: 10%; /* Reintroduce margin-top for tablet */
        margin-left: 5%;
    }

    .description img {
        margin-top: 10%;
        margin-right: 5%;
    }
}

/* "Su di Me" (about.html) */
.about-me-section {
    padding: 8% 5% 5% 5%; 
    max-width: 900px; 
    margin: 0 auto; 
    box-sizing: border-box; 
}

.about-content h1 {
    font-family: var(--font-titles);
    font-weight: var(--bold);
    font-size: 40px;
    color: var(--text-color-headings);
    margin-bottom: 0.8em;
    text-align: center; 
}

.about-content h2 {
    font-family: var(--font-primary);
    font-weight: var(--bold);
    font-size: 28px;
    color: var(--text-color-headings);
    margin-top: 2em; 
    margin-bottom: 0.8em;
    text-align: center;
}

.about-content p {
    font-family: var(--font-primary);
    font-weight: var(--regular);
    font-size: 1.1em;
    line-height: 1.7;
    color: var(--text-color-general);
    margin-bottom: 1.5em; 
    text-align: justify; 
}

.about-content p strong {
    font-weight: var(--bold); 
    color: var(--navbar-text-color); 
}

.about-content a {
    color: var(--navbar-link-hover-active); 
    text-decoration: none;
    font-weight: var(--bold);
}

.about-content a:hover {
    text-decoration: underline; 
}

/* Responsive per la sezione "Su di Me" */
@media (max-width: 768px) {
    .about-me-section {
        padding: 100px 5% 5% 5%;
    }

    .about-content h1 {
        font-size: 30px;
        margin-top: 1em; 
    }

    .about-content h2 {
        font-size: 22px;
        margin-top: 1.5em;
    }

    .about-content p {
        font-size: 1em;
        text-align: left; 
    }
}


/* CONTACT */
.contact {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    margin-top: 15%;
    gap: 15%;
    background-color: var(--contact-bg);
    padding: 50px 20px;
    transition: background-color 0.3s ease;
}

.three-contacts {
    display: flex;
    flex-direction: column;
}

.single-contact {
    display: flex;
    flex-direction: row;
    align-items: center;
    text-align: center;
    margin-bottom: 5%;
}

.single-contact p {
    font-family: var(--font-primary);
    font-weight: var(--regular);
    color: var(--text-color-general);
    margin-left: 1%;
    font-size: 18px;
}


/* RESPONSIVE CONTACT */
@media (max-width: 768px) {
    .contact {
        flex-direction: column;
        align-items: flex-start;
        justify-content: flex-start;
        text-align: left;
        padding-left: 7%;
        margin-top: 20%;
        padding: 10px 4%;
    }
}


/* PORTFOLIO */
.portfolio {
    margin-top: 4%;
}

.three-cards {
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: center;
    gap: 5%;
    margin-top: 5%;
    flex-wrap: wrap;
}

.single-card {
    width: 258px;
    height: 394.66px;
    position: relative;
}

.card-intera {
    width: 100%;
    height: 100%;
    transition: transform 0.6s;
    transform-style: preserve-3d;
    position: relative;
}

.card-front {
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 5px;
    background: var(--icon-color);
    box-shadow: 0px 4px 20px 0px rgba(
        /* Converti hex in rgb per l'ombra rgba */
        var(--icon-color-r, 2), /* Default 2 per #023059 */
        var(--icon-color-g, 48), /* Default 48 per #023059 */
        var(--icon-color-b, 89), /* Default 89 per #023059 */
        0.5
    );
    overflow: hidden;
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
}

.card-front::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 1;
    border-radius: 5px;
}

.card-front:hover::before {
    opacity: 1;
}

.card-front img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: filter 0.3s ease;
}

.card-front:hover img {
    filter: brightness(50%);
}

.card-front:hover {
    cursor: grab;
}

.card-back {
    display: flex;
    justify-content: center;
    align-items: center;
    transform: rotateY(180deg);
    border-radius: 5px;
    background-color: var(--icon-color);
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    z-index: 2;
}

.card-back a {
    text-decoration: none;
    color: var(--body-bg);
    z-index: 3;
}

.card-back a:hover {
    text-decoration: none;
    color: var(--navbar-bg);
}

.card-back a p {
    margin: 0;
}

.single-card.flip .card-intera {
    transform: rotateY(180deg);
    cursor: grab;
}


/* RESPONSIVE PORTFOLIO MOBILE */
@media (max-width: 768px) {
    .single-card {
        margin-top: 7%;
    }

    .portfolio {
        margin-bottom: 30%;
    }
}

/* RESPONSIVE PORTFOLIO TABLET */
@media (min-width: 600px) and (max-width: 1024px) {
    .single-card {
        margin-top: 7%;
    }
}

/* Sezione di introduzione del portfolio */
.portfolio-intro {
    max-width: 800px; 
    margin: 4% auto 5%; 
    padding: 0 20px; 
    text-align: center; 
}

.portfolio-intro p {
    font-family: var(--font-primary);
    font-weight: var(--regular);
    font-size: 1.1em; 
    line-height: 1.6; 
    color: var(--text-color-general); 
    margin-bottom: 1em; 
    text-align: justify;
}

/* Media query per dispositivi mobili */
@media (max-width: 768px) {
    .portfolio-intro {
        margin: 8% auto 10%; /* Più spazio sopra e sotto su mobile */
        padding: 0 15px; /* Riduci il padding su schermi molto piccoli */
    }

    .portfolio-intro p {
        font-size: 1em; /* Riduci la dimensione del font su mobile */
    }
}


/* FOOTER */
footer {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    text-align: center;
    margin-top: 6%;
    margin-left: 7%;
    margin-right: 7%;
    margin-bottom: 5%;
    transition: background-color 0.3s ease, color 0.3s ease;
}

.back {
    display: flex;
    flex-direction: row;
    align-items: center;
    text-align: center;
}

.back a {
    text-decoration: none;
}

.back p {
    font-family: var(--font-primary);
    font-weight: var(--regular);
    font-size: 15px;
    color: var(--footer-text-color);
}

.copy p {
    font-family: var(--font-primary);
    font-weight: var(--regular);
    animation: transform-color infinite 12s;
    font-size: 15px;
}

/* RESPONSIVE FOOTER MOBILE */
@media (max-width: 768px) {
    footer {
        flex-direction: column;
        align-items: center;
        justify-content: center;
        text-align: center;
        margin: 10%;
    }

    .back {
        display: none;
    }

    .copy {
        display: flex;
        justify-content: center;
        width: 100%;
    }

    .copy p {
        font-size: 10px;
        margin: 0;
    }
}

/* RESPONSIVE FOOTER TABLET */
@media (min-width: 600px) and (max-width: 1024px) {
    footer {
        flex-direction: column;
        align-items: center;
        justify-content: center;
        text-align: center;
        margin: 10%;
    }

    .back {
        display: none;
    }

    .copy {
        display: flex;
        justify-content: center;
        width: 100%;
    }

    .copy p {
        font-size: 10px;
        margin: 0;
    }

}


/* ANIMAZIONI */

@keyframes transform-color {
    0% {
        color: var(--anim-color-stage1);
    }
    20% {
        color: var(--anim-color-stage2);
    }
    40% {
        color: var(--anim-color-stage3);
    }
    60% {
        color: var(--anim-color-stage4);
    }
    80% {
        color: var(--anim-color-stage5);
    }
    100% {
        color: var(--anim-color-stage1);
    }
}
