:root {
    /* Dark theme colors */
    --bg-primary: #0b0f14;
    --bg-secondary: #1a1a1a;
    --bg-card: #0f1720;
    --text-primary: #e6eef6;
    --text-secondary: #9aa6b2;
    --accent-primary: #6dd3ff;
    --accent-hover: #7b61ff;
    --border-color: rgba(255,255,255,0.03);
    --glass: rgba(255,255,255,0.03);
    --glass-2: rgba(255,255,255,0.02);
    --radius: 12px;
    --max-width: 1200px;
    --header-gradient: linear-gradient(135deg, rgba(109,211,255,0.15) 0%, rgba(10, 10, 10, 0.95) 100%);
}

/* Light theme overrides */
[data-theme="light"] {
    /* Light theme colors */
    --bg-primary: #ffffff;
    --bg-secondary: #f5f7fb;
    --bg-card: #ffffff;
    --text-primary: #0b0f14;
    --text-secondary: #374151;
    --accent-primary: #2563eb; /* blue-600 */
    --accent-hover: #1d4ed8;   /* blue-700 */
    --border-color: rgba(0,0,0,0.08);
    --glass: rgba(0,0,0,0.06);
    --glass-2: rgba(0,0,0,0.03);
    --header-gradient: linear-gradient(135deg, rgba(37,99,235,0.08) 0%, rgba(255,255,255,0.95) 100%);
}

/* Base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    background: linear-gradient(180deg,#020406 0%, #071022 40%, #05121a 100%);
    color: var(--text-primary);
    font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

html[data-theme="light"],
html[data-theme="light"] body {
    background: linear-gradient(180deg, #f7fafc 0%, #eef2f7 40%, #f9fafb 100%);
}

main {
    width: 100%;
    margin: 0;
    padding: 2rem 1rem;
}

main > section,
main > article,
main > div.layout-section {
    max-width: var(--max-width);
    margin: 0 auto;
}

/* Navigation */
header {
    position: sticky;
    top: 0;
    z-index: 1000;
    width: 100%;
    background: var(--header-gradient);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border-color);
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 1rem 1.5rem;
}

.nav__brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.nav__toggle {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    width: 46px;
    height: 46px;
    margin-left: auto;
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, 0.18);
    background: rgba(6, 18, 32, 0.55);
    cursor: pointer;
    transition: border-color 0.2s ease, background 0.2s ease;
}

.nav__toggle:hover,
.nav__toggle:focus-visible {
    border-color: rgba(255, 255, 255, 0.32);
    background: rgba(6, 18, 32, 0.72);
}

.nav__toggle-bar {
    width: 22px;
    height: 2px;
    border-radius: 999px;
    background: var(--text-primary);
    transition: transform 0.25s ease, opacity 0.25s ease;
}

.nav__toggle[aria-expanded="true"] .nav__toggle-bar:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
}

.nav__toggle[aria-expanded="true"] .nav__toggle-bar:nth-child(2) {
    opacity: 0;
}

.nav__toggle[aria-expanded="true"] .nav__toggle-bar:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
}

html[data-theme="light"] .nav__toggle {
    border: 1px solid rgba(0, 0, 0, 0.12);
    background: rgba(255, 255, 255, 0.92);
}

html[data-theme="light"] .nav__toggle:hover,
html[data-theme="light"] .nav__toggle:focus-visible {
    border-color: rgba(0, 0, 0, 0.24);
    background: rgba(255, 255, 255, 0.98);
}

.nav__logo {
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-hover));
    color: #06121a;
    padding: 0.5rem;
    border-radius: 8px;
    font-weight: 700;
    font-size: 1.5rem;
    transition: all 0.3s ease;
}

.nav__logo:hover {
    transform: translateY(-2px);
    filter: brightness(1.1);
}

.nav__avatar {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.65);
    object-fit: cover;
    display: block;
    background: none;
    box-shadow: none;
}

.nav__avatar:hover,
.nav__avatar:focus-visible {
    transform: none;
    filter: none;
}

.nav__name {
    color: var(--text-primary);
    font-weight: 60;
    font-size: 0.85rem;
    letter-spacing: 0.5px;
}

.nav__links {
    display: flex;
    gap: 0.75rem;
    font-size: 1rem;
}

.nav__links a {
    color: var(--text-secondary);
    text-decoration: none;
    padding: 0.45rem 0.55rem;
    border-radius: 8px;
    transition: all 0.3s ease;
}

.nav__links a:hover,
.nav__links a.active {
    background: var(--glass-2);
    color: var(--text-primary);
}

/* Theme toggle button */
.nav__actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.theme-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0.4rem 0.6rem;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
}

.theme-toggle:hover {
    background: var(--glass-2);
    color: var(--text-primary);
}

.theme-toggle__icon {
    font-size: 1rem;
    line-height: 1;
}

/* Hero section */
.hero {
    display: grid;
    grid-template-columns: 400px 1fr;
    gap: 4rem;
    max-width: var(--max-width);
    margin: 2rem auto;
    padding: 1.2rem 0;
    min-height: 0;
}

.hero--landing {
    display: flex;
    align-items: flex-start;
    justify-content: flex-start;
    position: relative;
    padding: 0;
    border-radius: 1.5rem;
    overflow: hidden;
    background-image: linear-gradient(rgba(6, 12, 20, 0.72), rgba(6, 12, 20, 0.35)), url('../assets/images/3_orizzontale_s.jpg');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    min-height: 520px;
}

main > section.hero--landing {
    max-width: min(1320px, 94vw);
    margin-left: auto;
    margin-right: auto;
}

.hero--landing .hero__overlay {
    display: flex;
    align-items: flex-start;
    gap: 3rem;
    padding: 3.5rem 4rem;
    margin: 3.5rem;
    width: min(1180px, calc(100% - 7rem));
    background: linear-gradient(135deg, rgba(7, 14, 24, 0.92) 0%, rgba(7, 14, 24, 0.58) 100%);
    border-radius: 1.25rem;
    border: 1px solid rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(8px);
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.45);
}

.hero--landing .hero__portrait-wrap {
    flex: 0 0 auto;
    display: flex;
    align-items: flex-start;
    justify-content: center;
}

.hero--landing .hero__portrait {
    width: 170px;
    height: 170px;
    object-fit: cover;
    border-radius: 50%;
    border: 3px solid rgba(255, 255, 255, 0.35);
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.5);
}

.hero--landing .hero__links {
    display: flex;
    flex-wrap: wrap;
    gap: 0.9rem;
    margin: 1.5rem 0 1.75rem;
    padding: 0;
}

.hero--landing .hero__link {
    width: 44px;
    height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.35);
    background: rgba(12, 18, 32, 0.6);
    transition: transform 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}

.hero--landing .hero__link:hover,
.hero--landing .hero__link:focus-visible {
    transform: translateY(-2px);
    border-color: var(--accent-primary);
    background: rgba(12, 18, 32, 0.85);
}

.hero--landing .hero__link img {
    width: 24px;
    height: 24px;
    object-fit: contain;
}

.hero--landing .hero__copy {
    flex: 1 1 auto;
    min-width: 0;
}

.hero--landing .hero__heading {
    font-size: clamp(2.75rem, 3.5vw, 3.5rem);
    margin-bottom: 0.85rem;
    color: var(--text-primary);
}

.hero--landing .hero__subtitle {
    font-size: clamp(1.4rem, 2vw, 1.75rem);
    font-weight: 500;
    color: rgba(230, 236, 246, 0.9);
    margin-bottom: 0.75rem;
}

.hero--landing .hero__affiliation {
    color: var(--accent-primary);
    font-weight: 500;
    margin-bottom: 1.5rem;
}

.hero--landing .hero__affiliation a {
    color: inherit;
    text-decoration: underline;
}

.hero--landing .hero__affiliation a:hover,
.hero--landing .hero__affiliation a:focus-visible {
    text-decoration: none;
}

.hero--landing .hero__bio {
    color: rgba(230, 236, 246, 0.92);
    max-width: 68ch;
}

.hero--landing .intro {
    padding: 0;
}

.hero__left {
    display: flex;
    align-items: center;
    padding: 0.5rem 1rem;
    flex: 0 0 auto;
}

/* Profile section */
.profile {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    align-items: center;
}

.profile__image {
    width: 196px;
    height: auto;
    object-fit: contain;
    border-radius: var(--radius);
}

.profile__links {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
    flex-wrap: wrap;
}

.btn {
    padding: 0.6rem 1.2rem;
    font-size: 0.95rem;
    text-decoration: none;
    border-radius: 20px;
    transition: all 0.3s ease;
}

.btn--outline {
    padding: 0.4rem 0.8rem;
    font-size: 0.9rem;
}

/* Profile section */
.profile {
    background: var(--bg-card);
    border-radius: 1rem;
    padding: 2rem;
    border: 1px solid var(--border-color);
}

.profile__image {
    width: 100%;
    height: auto;
    border-radius: 0.5rem;
    margin-bottom: 2rem;
}

.profile__links {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 2rem;
}

.btn {
    display: inline-block;
    padding: 0.875rem 1.5rem;
    border-radius: 0.5rem;
    text-decoration: none;
    text-align: center;
    font-weight: 500;
    transition: all 0.3s ease;
}

.btn--primary {
    background-color: var(--accent-primary);
    color: white;
}

.btn--primary:hover {
    background-color: var(--accent-hover);
    transform: translateY(-2px);
}

.btn--secondary {
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn--secondary:hover {
    background-color: var(--bg-card);
    transform: translateY(-2px);
}

.btn--outline {
    background-color: transparent;
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn--outline:hover {
    border-color: var(--accent-primary);
    color: var(--accent-primary);
    transform: translateY(-2px);
}

.profile__social {
    display: flex;
    justify-content: center;
    gap: 1rem;
}

.social-icon {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.875rem;
    transition: color 0.3s;
}

.social-icon:hover {
    color: var(--accent-primary);
}

/* Intro section */
.intro {
    padding: 2rem;
}

.intro h1 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    background: linear-gradient(to right, var(--accent-primary), var(--text-primary));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.intro h2 {
    color: var(--text-secondary);
    font-size: 1.5rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
}

.intro__affiliation {
    color: var(--accent-primary);
    margin-bottom: 2rem;
}

.intro__bio {
    color: var(--text-secondary);
    font-size: 1.125rem;
    line-height: 1.7;
}

/* Timeline section */
.timeline {
    max-width: 1200px;
    margin: 6rem auto;
    padding: 0 2rem;
}

.timeline h2 {
    font-size: 2rem;
    margin-bottom: 3rem;
    color: var(--text-primary);
}

.timeline__grid {
    display: grid;
    gap: 2rem;
}

.timeline__item {
    display: grid;
    width: 90%;           /* full width */
    max-width: none;       /* remove max-width constraint */
    grid-template-columns: 150px 1fr;
    gap: 2rem;
    padding: 2rem;
    margin-bottom: rem;
    background-color: var(--bg-card);
    border-radius: 3rem;
    border: 1px solid var(--border-color);
}

.timeline__date {
    color: var(--accent-primary);
    font-weight: 500;
}

.timeline__content h3 {
    color: white;
    margin-bottom: 0.5rem;
}

.timeline__content p {
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

/* Research interests */
.research-interests {
    max-width: 1200px;
    margin: 6rem auto;
    padding: 0 2rem;
}

.research-interests h2 {
    font-size: 2rem;
    margin-bottom: 3rem;
    color: var(--text-primary);
}

.interests__grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
}

.interest-card {
    background-color: var(--bg-card);
    border-radius: 1rem;
    padding: 2rem;
    border: 1px solid var(--border-color);
    transition: transform 0.3s ease;
}

.interest-card:hover {
    transform: translateY(-5px);
}

.interest-card h3 {
    color: var(--accent-primary);
    margin-bottom: 1rem;
}

.interest-card p {
    color: var(--text-secondary);
}

/* Section styles */
.section-wrapper {
    margin-top: 1.75rem;
}

.section-heading {
    display: flex;
    align-items: end;
    gap: 1rem;
    margin-bottom: 0.75rem;
}

.section-heading span {
    font-size: 0.85rem;
    color: var(--accent-primary);
    font-weight: 700;
    letter-spacing: 0.08em;
    background: linear-gradient(90deg, rgba(109,211,255,0.06), transparent);
    padding: 0.2rem 0.5rem;
    border-radius: 999px;
}

.section-heading h2 {
    margin: 0;
    font-size: 1.25rem;
}

/* Divider */
.divider {
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--glass), transparent);
    border-radius: 2px;
    margin: 1rem 0;
}

/* Card styles */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1rem;
}

.card {
    background: var(--bg-card);
    padding: 1.5rem;
    border-radius: var(--radius);
    box-shadow: 0 8px 30px rgba(2,6,12,0.6);
    transition: transform .18s ease, box-shadow .18s ease;
    border: 1px solid var(--glass);
}

.card:hover {
    transform: translateY(-6px);
    box-shadow: 0 18px 48px rgba(2,6,12,0.7);
}

.card h3 {
    color: var(--accent-primary);
    margin-bottom: 1rem;
}

.card p {
    color: var(--text-secondary);
    margin-bottom: 0.6rem;
    line-height: 1.35;
}

/* Additional page-specific styles */

/* Publications page */
.article-grid {
    display: grid;
    gap: 2rem;
    margin-top: 2rem;
}

.publication-item .meta {
    color: white;
    font-size: 0.9rem;
    margin: 0.5rem 0;
}

.publication-item a {
    color: var(--text-secondary);
    text-decoration: none;
    transition: color 0.3s;
}

.publication-item a:hover {
    color: var(--accent-primary);
}

/* Contact page */
.contact-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
    margin-top: 2rem;
}

.contact-card {
    background: var(--bg-card);
    padding: 2rem;
    border-radius: 1rem;
    border: 1px solid var(--border-color);
}

/* Outreach page */
.outreach-item .outreach-meta {
    color: var(--accent-primary);
    font-size: 0.9rem;
    margin: 0.5rem 0;
    display: flex;
    gap: 1rem;
}

/* Project page */
.project-meta {
    display: flex;
    gap: 1rem;
    color: var(--accent-primary);
    font-size: 0.9rem;
    margin: 0.5rem 0;
}

.card ul {
    margin-top: 1rem;
    padding-left: 1.5rem;
    color: var(--text-secondary);
}

.card ul li {
    margin-bottom: 0.5rem;
}

/* Academic profile buttons */
.profile-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    justify-content: center;
    margin: 1.5rem 0;
}

.profile-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1rem;
    border-radius: 12px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    text-decoration: none;
    font-size: 0.9rem;
    transition: all 0.3s ease;
}

.profile-btn:hover {
    transform: translateY(-2px);
    border-color: var(--accent-primary);
    background: var(--glass-2);
}

.profile-btn svg {
    width: 20px;
    height: 20px;
    color: var(--accent-primary);
}

.profile-btn.ads:hover {
    border-color: #2196f3;
}

.profile-btn.scholar:hover {
    border-color: #4caf50;
}

.profile-btn.orcid:hover {
    border-color: #a5d6a7;
}

.profile-btn.researchgate:hover {
    border-color: #00bcd4;
}

/* Hero variations */
.hero-alt {
    text-align: center;
    max-width: 800px;
    margin: 4rem auto;
    padding: 0 2rem;
}

.hero-alt h1 {
    font-size: 2.5rem;
    margin-bottom: 1rem;
    background: linear-gradient(to right, var(--accent-primary), var(--text-primary));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.hero-alt p {
    color: var(--text-secondary);
    font-size: 1.25rem;
    margin-bottom: 2rem;
}

/* Responsive design */
@media (max-width: 1024px) {
    .hero {
        grid-template-columns: 1fr;
        gap: 2rem;
    }

    .profile {
        max-width: 400px;
        margin: 0 auto;
    }

    .hero--landing {
        border-radius: 1.25rem;
        min-height: 460px;
    }

    .hero--landing .hero__overlay {
        margin: 2rem;
        width: calc(100% - 4rem);
        max-width: none;
        padding: 2.5rem;
        gap: 2.25rem;
    }

    .hero--landing .hero__heading {
        font-size: clamp(2.2rem, 3.4vw, 2.8rem);
    }

    .hero--landing .hero__bio {
        max-width: 100%;
    }
}

/* Footer */
footer {
    max-width: var(--max-width);
    margin: 2.25rem auto;
    padding: 1rem;
    color: var(--text-secondary);
}

.footer-links {
    display: flex;
    gap: 0.85rem;
    justify-content: center;
    padding-bottom: 0.6rem;
    flex-wrap: wrap;
}

.footer-links a {
    color: var(--text-secondary);
    text-decoration: none;
    transition: color 0.3s ease;
}

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

footer p {
    font-size: 0.9rem;
    text-align: center;
    margin: 0.1rem 0 0 0;
}

/* Responsive design */
@media (max-width: 768px) {
    .nav {
        flex-wrap: wrap;
        align-items: center;
        gap: 0.75rem;
    }

    .nav__toggle {
        display: inline-flex;
    }

    .nav .nav__links {
        flex-basis: 100%;
        display: none;
        flex-direction: column;
        gap: 0.75rem;
        background: linear-gradient(135deg, rgba(7, 14, 24, 0.92) 0%, rgba(7, 14, 24, 0.68) 100%);
        border: 1px solid rgba(255, 255, 255, 0.08);
        border-radius: 0.85rem;
        padding: 1rem;
    }

    html[data-theme="light"] .nav .nav__links {
        background: linear-gradient(135deg, rgba(255, 255, 255, 0.95) 0%, rgba(240, 244, 255, 0.9) 100%);
        border: 1px solid rgba(0, 0, 0, 0.08);
    }

    .nav .nav__links[data-open="true"] {
        display: flex;
    }

    .nav .nav__links a {
        display: block;
        width: 100%;
        text-align: left;
    }

    .timeline__item {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .hero--landing .hero__overlay {
        flex-direction: column;
        margin: 1.5rem;
        padding: 1.75rem;
        gap: 1.5rem;
        width: calc(100% - 3rem);
    }

    .hero--landing .hero__portrait-wrap {
        justify-content: flex-start;
    }

    .hero--landing .hero__portrait {
        width: 140px;
        height: 140px;
    }

    .hero--landing .hero__heading {
        font-size: 2.2rem;
    }

    .timeline {
        padding: 0 1.2rem;
        margin: 4rem auto;
    }

    .timeline__item {
        padding: 1.5rem;
    }

    .hero--landing .hero__links {
        margin-top: 1rem;
    }

    .timeline__date {
        border-bottom: 1px solid var(--border-color);
        padding-bottom: 0.5rem;
    }
}

@media (max-width: 640px) {
    .profile {
        flex-direction: column !important;
        align-items: flex-start !important;
        text-align: left;
        gap: 1rem !important;
    }

    .profile__image {
        width: 160px !important;
        height: 160px !important;
        margin: 0 0 1rem 0 !important;
        border-radius: 0.75rem !important;
    }

    .profile__links,
    .profile__social {
        justify-content: flex-start !important;
    }
}

@media (max-width: 520px) {
    main {
        margin: 1.5rem 0;
        padding: 0.75rem;
    }

    .nav {
        padding: 1.1rem 0.75rem;
    }

    img.nav__logo {
        width: 56px;
        height: 56px;
    }

    .hero--landing {
        border-radius: 1.1rem;
        min-height: 0;
    }

    .hero--landing .hero__overlay {
        margin: 1.25rem;
        padding: 1.5rem;
        gap: 1.25rem;
    }

    .hero--landing .hero__portrait {
        width: 120px;
        height: 120px;
    }

    .hero--landing .hero__heading {
        font-size: 1.9rem;
    }

    .hero--landing .hero__subtitle {
        font-size: 1.2rem;
    }

    .hero--landing .hero__link {
        width: 40px;
        height: 40px;
    }

    .hero--landing .hero__bio {
        font-size: 1rem;
        line-height: 1.6;
    }

    .timeline {
        padding: 0 0.75rem;
    }

    .research-interests {
        padding: 0 0.75rem;
    }

    .card-grid,
    .interests__grid {
        grid-template-columns: 1fr;
    }
}

/* Desktop layout: side by side */
@media screen and (min-width: 768px) {
  .hero__content {
    flex-direction: row;      /* portrait left, box with all content right */
    align-items: flex-start;
    gap: 2rem;
  }

  .hero__portrait-wrap {
    flex-shrink: 0;           /* keeps portrait size fixed */
  }

  .hero__copy {
    max-width: 600px;         /* constrain text box width */
  }
}