:root {
    --primary-color: #2c3e50;
    --secondary-color: #3498db;
    --secondary-hover: #217dbb;
    --background-color: #ecf0f1;
    --surface-color: #ffffff;
    --surface-muted-color: #f8f9fa;
    --text-color: #263238;
    --text-muted-color: #5f6b72;
    --shadow-color: rgba(15, 23, 42, 0.12);
    --focus-color: #f5b942;
    --line-height-base: 1.6;
    --font-size: 16px;
    color-scheme: light;
}

:root[data-theme="dark"] {
    --primary-color: #d7e5f0;
    --secondary-color: #58aee8;
    --secondary-hover: #79c3f2;
    --background-color: #111820;
    --surface-color: #1b2631;
    --surface-muted-color: #243240;
    --text-color: #e7edf2;
    --text-muted-color: #b3c0ca;
    --shadow-color: rgba(0, 0, 0, 0.38);
    --focus-color: #ffd166;
    color-scheme: dark;
}

html {
    scroll-behavior: smooth;
}

.lang-en {
    display: none;
}

html[lang="en"] .lang-en {
    display: revert;
}

html[lang="en"] .lang-it {
    display: none;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    font-size: var(--font-size);
    line-height: var(--line-height-base);
    color: var(--text-color);
    max-width: 900px;
    margin: 0 auto;
    padding: 1.2em;
    padding-bottom: 4rem;
    background-color: var(--background-color);
    transition: color 0.25s ease, background-color 0.25s ease;
}

header {
    background-color: #2c3e50;
    color: white;
    padding: 1em 1em;
    text-align: center;
    border-radius: 0.6em;
    margin-bottom: 1.5em;
    box-shadow: 0 4px 12px var(--shadow-color);
    display: flex;
    align-items: center;
    justify-content: space-around;
}
h1, h2 {
    display: flex;
    align-items: center;
    gap: 0.5em;
    color: var(--primary-color);
}
header h1 {
    margin: 0;
    color: #ffffff;
    font-size: 1.4rem;
    font-weight: 600;
    line-height: 1.35;
}
.header-content > p {
    margin-top: 0.4rem;
}
.header-content {
    text-align: left;
}
.profile-image {
    width: 200px;
    height: 200px;
    border-radius: 50%;
    object-fit: cover;
    border: 0.3em solid white;
}
section {
    scroll-margin-top: 5rem;
    background-color: var(--surface-color);
    padding: 1.2em;
    margin-bottom: 1.6em;
    border-radius: 0.6em;
    box-shadow: 0 2px 8px var(--shadow-color);
    overflow: hidden;
    transition: background-color 0.25s ease, box-shadow 0.25s ease;
}
.section-header {
    background-color: var(--surface-color);
    padding: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-radius: 0.35em;
}
.section-toggle:focus-visible,
.control-button:focus-visible,
.back-to-top:focus-visible,
a:focus-visible {
    outline: 3px solid var(--focus-color);
    outline-offset: 3px;
}
.section-header h2 {
    margin: 0;
    font-size: 1.2em;
    width: 100%;
}
.section-toggle {
    display: flex;
    align-items: center;
    gap: 0.5em;
    width: 100%;
    padding: 0.5em 0.75em;
    margin: 0;
    color: inherit;
    background: transparent;
    border: 0;
    border-radius: 0.35em;
    font-family: inherit;
    font-size: inherit;
    font-weight: inherit;
    line-height: inherit;
    letter-spacing: inherit;
    text-align: left;
    cursor: pointer;
    appearance: none;
}
.section-content {
    padding: 0 0.9em;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-out;
}
.section.active .section-content {
    max-height: fit-content;
    transition: max-height 0.5s ease-in;
}

.expand-svg-icon {
    transition: transform 0.3s ease;
    margin-left: auto; /* Pushes the icon to the right */
}
.section.active .expand-svg-icon {
    transform: rotate(180deg);
}
.project, .publication {
    background-color: var(--surface-muted-color);
    margin: 1.3em 0;
    padding: 1.3em;
    border-radius: 0.3em;
    border-left: 5px solid var(--secondary-color);
}
.experience-title {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}
.company-logo {
    box-sizing: border-box;
    flex: 0 0 auto;
    width: 76px;
    height: 44px;
    padding: 0.35rem 0.5rem;
    object-fit: contain;
    background-color: #ffffff;
    border: 1px solid rgba(44, 62, 80, 0.16);
    border-radius: 0.45rem;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.12);
}
:root[data-theme="dark"] .company-logo {
    border-color: rgba(255, 255, 255, 0.2);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.28);
}
.skills {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6em;
}
#certificates .skills {
    align-items: center;
}
.skill {
    display: inline-block;
    background-color: var(--secondary-color);
    color: white;
    padding: 0.3em 0.6em;
    border-radius: 1.3em;
    font-size: 0.9em;
    transition: opacity 0.3s ease;
}
@media screen and (hover: hover) and (pointer: fine) {
    .skills:has(.skill:hover) .skill:not(:hover) {
        opacity: 0.5;
    }
}
.page-controls {
    position: fixed;
    top: 1.3em;
    right: 1.3em;
    z-index: 10;
    display: flex;
    gap: 0.55em;
}
.control-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2.8rem;
    min-height: 2.8rem;
    padding: 0.6em 0.9em;
    background-color: #3498db;
    color: white;
    border: none;
    border-radius: 1.6em;
    cursor: pointer;
    transition: background-color 0.2s ease, transform 0.2s ease;
    font-weight: bold;
    box-shadow: 0 2px 8px var(--shadow-color);
}
.control-button:hover {
    background-color: #2980b9;
    transform: translateY(-1px);
}
.icon-button {
    padding: 0.6em;
}
.theme-icon-sun,
:root[data-theme="dark"] .theme-icon-moon {
    display: none;
}
:root[data-theme="dark"] .theme-icon-sun {
    display: block;
}
.social-icons {
    margin-top: 1.3em;
}
.social-icons a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.5em;
    height: 1.5em;
    color: white;
    margin-left: 0.1em;
    margin-right: 1em;
    transition: color 0.3s;
}
.social-icon {
    display: block;
    width: 100%;
    height: 100%;
    fill: currentColor;
}
.social-icons a:hover {
    color: var(--secondary-color);
}
.date {
    font-style: italic;
    color: var(--text-muted-color);
}
.url {
    color: var(--secondary-color);
    text-decoration: none;
}
.url:hover {
    text-decoration: underline;
}
.copyright-container {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background-color: var(--surface-color);
    color: var(--text-color);
    text-align: center;
    padding: 0.6em 0;
    transition: color 0.25s ease, background-color 0.25s ease;
}
.copyright-container a {
    color: var(--secondary-color);
}
.page-end-sentinel {
    display: block;
    height: 1px;
}
.back-to-top {
    position: fixed;
    right: 1.3em;
    bottom: 4rem;
    z-index: 11;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.8rem;
    height: 2.8rem;
    color: white;
    background-color: #3498db;
    border-radius: 50%;
    box-shadow: 0 2px 8px var(--shadow-color);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(0.75rem);
    transition: opacity 0.2s ease, visibility 0.2s ease, transform 0.2s ease, background-color 0.2s ease;
}
.back-to-top:hover {
    background-color: #2980b9;
}
.back-to-top.is-visible {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateY(0);
}
@media (max-width: 600px) {
    body {
        padding: 0.6em;
    }
    header {
        flex-direction: column;
        text-align: center;
        padding: 0.3em 0.3em;
    }
    .profile-image {
        width: 140px;
        height: 140px;
    }
    .section {
        padding: 0.9em;
    }
    .section-header h2 {
        font-size: 1em;
    }
    .section-toggle {
        padding: 0.6em 0.9em;
    }
    .skill {
        font-size: 0.8em;
        padding: 0.3em 0.5em;
    }
    .page-controls {
        top: 0.75em;
        right: 0.75em;
        gap: 0.4em;
    }
    .control-button {
        padding: 0.5em 0.8em;
        font-size: 0.9em;
        min-width: 2.55rem;
        min-height: 2.55rem;
    }
    .icon-button {
        padding: 0.5em;
    }
    .back-to-top {
        right: 0.75em;
        bottom: 0.75em;
        width: 2.55rem;
        height: 2.55rem;
    }
    .copyright-container {
        position: static;
        width: auto;
        margin-top: 0.5em;
        box-sizing: border-box;
        padding: 0.6em 3.6rem 0.6em 0.6em;
        background-color: var(--surface-color);
        color: var(--text-color);
        border-radius: 0.6em 0.6em 0 0;
        box-shadow: 0 -2px 8px var(--shadow-color);
        transition: background-color 0.25s ease;
    }
}

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        transition-duration: 0.01ms !important;
    }
}


@page {
    size: A4;
    margin: 14mm;
}

@media print {
    :root,
    :root[data-theme="dark"] {
        --primary-color: #111111;
        --secondary-color: #555555;
        --background-color: #ffffff;
        --surface-color: #ffffff;
        --surface-muted-color: #ffffff;
        --text-color: #111111;
        --text-muted-color: #444444;
    }
    html { scroll-behavior: auto; }
    body {
        max-width: none;
        margin: 0;
        padding: 0;
        font-size: 10pt;
        background: #ffffff;
        color: #111111;
    }
    header,
    section,
    .project,
    .publication,
    .company-logo,
    .copyright-container {
        box-shadow: none;
        background: #ffffff;
        border-radius: 0;
        color: #111111;
        overflow: visible;
    }
    header {
        flex-direction: row;
        justify-content: flex-start;
        gap: 1.5rem;
        padding: 0 0 1rem;
        border-bottom: 1px solid #cccccc;
    }
    header h1 { color: #111111; }
    .profile-image {
        width: 80px;
        height: 80px;
        border: 1px solid #cccccc;
    }
    .location svg { fill: #111111; }
    .social-icons a { color: #111111; }
    section {
        padding: 0;
        margin-bottom: 1.2rem;
    }
    .section-header { break-after: avoid; }
    .section-toggle {
        padding: 0.5rem 0;
        cursor: default;
    }
    .section-content,
    .section-content[hidden] {
        display: block !important;
        max-height: none !important;
        padding: 0;
        overflow: visible;
        transition: none;
    }
    .project,
    .publication {
        margin: 0.5rem 0;
        padding: 0.5rem 0 0.5rem 0.75rem;
        border-left: 2px solid #cccccc;
        break-inside: avoid;
    }
    .skill {
        background-color: #eeeeee;
        color: #111111;
        border: 1px solid #cccccc;
        box-shadow: none;
    }
    .page-controls,
    .back-to-top,
    .page-end-sentinel,
    .expand-svg-icon { display: none !important; }
    .copyright-container {
        position: static;
        width: auto;
        padding: 0.75rem 0 0;
        margin-top: 1rem;
        border-top: 1px solid #cccccc;
    }
    a { color: #111111 !important; }
}
