/* ======================================
   Michele Siddi Portfolio - Main Styles
   ====================================== */

/* CSS Variables */
:root {
    --primary: #1864ab;
    --secondary: #f8fbff;
    --accent: #00b4d8;
    --accent2: #ffbe3b;
    --dark: #181a2a;
    --light: #fff;
    --danger: #db5461;
    --success: #44b984;
    --radius: 22px;
    --shadow: 0 8px 36px rgba(24,100,171,0.13), 0 2px 12px rgba(0,0,0,0.08);
    --shadow-hover: 0 15px 48px rgba(24,100,171,0.22), 0 4px 18px rgba(0,0,0,0.12);
    --glass: rgba(255,255,255,0.7);
    --frost: blur(7px);
    --gradient: linear-gradient(100deg, #1864ab 60%, #00b4d8 100%);
    --gradient-rev: linear-gradient(90deg, #00b4d8, #1864ab);
    --transition-speed: 0.3s;
}

/* Base Styles */
html { 
    scroll-behavior: smooth; 
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    margin: 0;
    background: radial-gradient(circle at 70% 10%, #e7f6ff 0%, #f8fbff 100%);
    color: var(--dark);
    min-height: 100vh;
    transition: background var(--transition-speed), color var(--transition-speed);
}

.skip-link {
    position: absolute;
    left: -999px;
    top: 1rem;
    background: var(--primary);
    color: var(--light);
    padding: 0.75rem 1.5rem;
    border-radius: 999px;
    z-index: 220;
    font-weight: 700;
    text-decoration: none;
    transition: transform 0.2s ease, left 0.2s ease;
}

.skip-link:focus {
    left: 1rem;
    transform: translateY(10px);
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.site-header {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 0;
}

/* Dark Mode */
body.dark {
    background: radial-gradient(circle at 70% 10%, #151a2a 0%, #222a3f 100%);
    color: #e7f6ff;
}

body.dark .container,
body.dark .about,
body.dark .skills,
body.dark .skill-card,
body.dark .service,
body.dark .article-card,
body.dark .news-card,
body.dark .paper-card,
body.dark .video-card,
body.dark .newsletter-card,
body.dark .contact-form,
body.dark .articles-section,
body.dark .news-section,
body.dark .papers-section,
body.dark .videos-section,
body.dark .portfolio,
body.dark .highlight-card,
body.dark .timeline {
    background: rgba(15,24,44,0.89) !important;
    color: #e7f6ff;
    box-shadow: 0 4px 32px #000a22a0;
}

body.dark nav, 
body.dark footer {
    background: linear-gradient(100deg, #202d44 60%, #1c3750 100%) !important;
    color: #fff !important;
}

body.dark .service { 
    border-bottom: 5px solid #00b4d8; 
}

body.dark .service-icon { 
    background: #15253a; 
}

body.dark .about-badges .badge { 
    background: #222d42; 
    color: #fff;
}

body.dark .timeline-dot { 
    background: #00b4d8; 
}

body.dark .timeline-line { 
    background: #0a2a3a; 
}

body.dark .lang-switch, 
body.dark .mode-switch {
    background: #232a3f;
}

body.dark .ai-msg-bot {
    background: #132341;
}

body.dark .ai-msg-user {
    background: #0e2a4a;
}

body.dark .section-subtitle,
body.dark .portfolio-desc,
body.dark .form-note,
body.dark .video-desc {
    color: #cddbf5;
}

body.dark .btn-tertiary {
    background: rgba(255,255,255,0.12);
    color: #f1f6ff;
}

body.dark .btn-tertiary:hover {
    background: var(--accent);
    color: #0b1a30;
}

body.dark .paper-link,
body.dark .video-link {
    color: #7ecbff;
}

body.dark .paper-meta,
body.dark .paper-date {
    color: #9eb8dd;
}

body.dark .newsletter-form input {
    background: rgba(12,24,44,0.92);
    color: #e7f6ff;
    box-shadow: inset 0 2px 6px rgba(0,0,0,0.45);
}

body.dark .newsletter-form button {
    box-shadow: 0 12px 30px rgba(0,180,216,0.45);
}

body.dark .btn-secondary {
    background: rgba(255,255,255,0.1);
    border-color: rgba(255,255,255,0.4);
    color: #f5fbff;
}

body.dark .btn-secondary:hover {
    background: var(--light);
    color: var(--primary);
}

body.dark .skill-card {
    background: rgba(18,32,56,0.92) !important;
    box-shadow: 0 10px 26px rgba(0,0,0,0.35);
}

body.dark .highlight-card {
    background: rgba(15,40,72,0.9) !important;
    box-shadow: 0 12px 32px rgba(0,0,0,0.38);
}

body.dark .skill-card p,
body.dark .skill-points {
    color: #d6e4ff;
}

body.dark .skill-points li::before {
    color: var(--accent);
}

body.dark .highlight-label {
    color: #d6e4ff;
}

body.dark #ai-chat-popup {
    background: rgba(20,30,50,0.98);
    border-color: #00b4d860;
}

/* Language & Mode Switch */
.lang-switch, 
.mode-switch {
    position: fixed;
    top: 18px;
    right: 22px;
    z-index: 210;
    display: flex;
    gap: 0.7rem;
    background: rgba(255,255,255,0.7);
    padding: 0.25rem 0.7rem;
    border-radius: 18px;
    box-shadow: 0 2px 10px rgba(24,100,171,0.04);
    backdrop-filter: blur(4px);
}

.mode-switch {
    right: 120px;
    gap: 0.2rem;
    padding: 0.18rem 0.55rem;
}

.lang-switch button, 
.mode-switch button {
    background: var(--light);
    color: var(--primary);
    border: none;
    border-radius: 18px;
    padding: 0.37rem 0.85rem;
    font-weight: 700;
    cursor: pointer;
    font-size: 1rem;
    transition: background 0.19s, color 0.19s, transform 0.19s;
}

.lang-switch button.active, 
.lang-switch button:hover, 
.mode-switch button.active, 
.mode-switch button:hover {
    background: var(--primary);
    color: var(--light);
    transform: translateY(-2px) scale(1.09);
}

/* Hero Section */
.hero {
    background: linear-gradient(100deg, #1864ab 60%, #00b4d8 100%);
    background-size: 300% 300%;
    color: var(--light);
    padding: 2rem 0 1.2rem 0;
    text-align: center;
    box-shadow: var(--shadow);
    position: relative;
    min-height: 220px;
    animation: heroBgAnim 16s ease-in-out infinite alternate;
}

@keyframes heroBgAnim {
    0% { background-position: 0% 50%; }
    100% { background-position: 100% 50%; }
}

.hero-content {
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.hero-avatar {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    margin-bottom: 0.7rem;
    border: 4px solid #ffbe3b;
    box-shadow: 0 2px 18px #00b4d85a;
    position: relative;
    overflow: hidden;
    background: var(--light);
}

.hero-avatar::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 3px solid #00b4d8;
    box-sizing: border-box;
    animation: borderPulse 2.8s infinite alternate;
    pointer-events: none;
    z-index: 2;
}

@keyframes borderPulse {
    0% { box-shadow: 0 0 0 0 #00b4d840; }
    100% { box-shadow: 0 0 0 9px #ffbe3b25; }
}

.hero-avatar img {
    width: 110px;
    height: 110px;
    border-radius: 50%;
    object-fit: cover;
    margin: 5px;
}

.hero-title {
    font-family: 'Poppins', 'Montserrat', Arial, sans-serif;
    font-size: 2.1rem;
    font-weight: 700;
    margin: 0;
    letter-spacing: 1.4px;
}

.hero-payoff {
    font-size: 1.08rem;
    margin: 0.5rem 0 0.7rem 0;
    color: #ffe29a;
}

.hero-subtitle {
    margin: 0.25rem 0 0.8rem 0;
    font-size: 1.05rem;
    color: #e6f1fa;
    font-weight: 500;
}

.hero-cta {
    display: flex;
    gap: 0.9rem;
    flex-wrap: wrap;
    justify-content: center;
    margin-top: 1.1rem;
}

.btn-primary,
.btn-secondary {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    border-radius: 999px;
    padding: 0.75rem 1.5rem;
    font-weight: 700;
    font-size: 1rem;
    text-decoration: none;
    transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease, color 0.2s ease;
}

.btn-primary {
    background: var(--accent);
    color: var(--light);
    box-shadow: 0 12px 32px rgba(0,180,216,0.32);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 16px 40px rgba(0,180,216,0.4);
    background: #1280c4;
}

.btn-secondary {
    background: rgba(255,255,255,0.2);
    color: var(--light);
    border: 2px solid rgba(255,255,255,0.55);
}

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

/* Navigation */
nav {
    background: rgba(255,255,255,0.74);
    box-shadow: 0 2px 10px #0002;
    display: flex;
    justify-content: center;
    gap: 1.25rem;
    padding: 0.73rem 0;
    position: sticky;
    top: 0;
    z-index: 20;
    border-bottom: 1px solid #e6eaf1;
    backdrop-filter: blur(10px);
    transition: background 0.2s;
}

nav a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 700;
    font-size: 1.05rem;
    padding: 0.48rem 1.3rem;
    border-radius: 18px;
    transition: background 0.16s, color 0.16s, box-shadow 0.16s;
    font-family: 'Poppins', sans-serif;
    position: relative;
    overflow: hidden;
}

nav a.active, 
nav a:hover {
    background: var(--gradient);
    color: var(--light);
    box-shadow: 0 2px 10px #00b4d82a;
}

nav a::after {
    content: "";
    position: absolute;
    left: 20%;
    bottom: 8px;
    height: 2.5px;
    border-radius: 2px;
    background: var(--accent2);
    width: 0%;
    transition: width 0.25s;
}

nav a.active::after, 
nav a:hover::after {
    width: 60%;
}

/* Container */
.container {
    max-width: 1080px;
    margin: 1.4rem auto 0 auto;
    background: var(--glass);
    padding: 1.7rem 1.4rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    backdrop-filter: var(--frost);
}

/* About Section */
.about {
    background: linear-gradient(80deg,#e7f6ff 65%,#eafffa50 100%);
    border-radius: 22px;
    box-shadow: 0 12px 28px rgba(24,100,171,0.15);
    margin: 2.2rem 0;
}

.about-text {
    font-size: 1.05rem;
    color: #23365c;
    line-height: 1.7;
    font-family: 'Inter', 'Nunito', Arial, sans-serif;
}

.about-badges {
    margin: 0.8rem 0;
}

.badge {
    display: inline-block;
    background: #d0ecff;
    color: #1864ab;
    font-size: 0.89rem;
    font-weight: 700;
    border-radius: 10px;
    padding: 0.25em 0.95em;
    margin: 0.13em 0.22em 0.13em 0;
    box-shadow: 0 1px 4px #00b4d81a;
    font-family: 'Nunito',Arial,sans-serif;
    letter-spacing: 0.5px;
}

.section-heading {
    text-align: center;
    margin-bottom: 2rem;
}

.section-subtitle {
    font-size: 1.05rem;
    color: #4a5972;
    max-width: 680px;
    margin: 0.6rem auto 1.8rem auto;
    line-height: 1.7;
    text-align: center;
}

.skills {
    margin: 2.2rem 0;
    background: rgba(255,255,255,0.86);
    padding: 2.4rem 2rem;
    border-radius: 22px;
    box-shadow: var(--shadow);
}

.skills-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.6rem;
}

.skill-card {
    background: rgba(24,100,171,0.05);
    border-radius: 18px;
    padding: 1.4rem 1.2rem;
    box-shadow: 0 8px 20px rgba(0,0,0,0.08);
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

.skill-card h3 {
    margin: 0;
    color: var(--primary);
    font-size: 1.25rem;
}

.skill-card p {
    margin: 0;
    color: #3d4f66;
    line-height: 1.6;
}

.skill-points {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    font-size: 0.98rem;
    color: #304153;
}

.skill-points li::before {
    content: "▹";
    color: var(--accent);
    margin-right: 0.4rem;
}

.highlights {
    margin: 2.5rem 0 2rem 0;
}

.highlight-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.3rem;
}

.highlight-card {
    background: rgba(24,100,171,0.07);
    border-radius: 20px;
    padding: 1.6rem;
    box-shadow: 0 10px 24px rgba(24,100,171,0.12);
    text-align: center;
}

.highlight-metric {
    font-size: 2.4rem;
    font-weight: 800;
    color: var(--primary);
    display: block;
    margin-bottom: 0.4rem;
}

.highlight-label {
    font-size: 0.98rem;
    color: #304153;
    line-height: 1.5;
}

/* Timeline */
.timeline {
    margin: 0.7rem 0;
}

.timeline-item {
    display: flex;
    align-items: flex-start;
    margin-bottom: 1.05rem;
}

.timeline-dot {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #ffbe3b;
    margin-right: 0.7rem;
    border: 2px solid #00b4d8;
    flex-shrink: 0;
}

.timeline-line {
    width: 2px;
    background: #d0ecff;
    height: 100%;
    margin-left: 7px;
    margin-right: 1.2rem;
    flex-shrink: 0;
}

.timeline-content {
    flex: 1;
}

.timeline-title {
    font-weight: 700;
    color: #1864ab;
}

.timeline-period {
    font-size: 0.9em;
    color: #888;
    margin-bottom: 0.12em;
}

/* Section Title */
.section-title {
    font-size: 1.45rem;
    margin-bottom: 0.85rem;
    color: var(--primary);
    font-family: 'Poppins', sans-serif;
    font-weight: 700;
    letter-spacing: 1px;
    border-left: 6px solid var(--accent2);
    padding-left: 0.8rem;
    background: linear-gradient(90deg,#e7f6ff 80%,transparent 100%);
}

/* Services */
.services {
    display: flex;
    flex-wrap: wrap;
    gap: 1.2rem;
    margin-bottom: 2.0rem;
    justify-content: center;
}

.service {
    flex: 1 1 230px;
    background: var(--light);
    padding: 1.6rem 1.1rem 1.4rem 1.1rem;
    border-radius: 20px;
    box-shadow: 0 8px 24px #1864ab1a, 0 2px 8px #1864ab13;
    text-align: left;
    min-width: 200px;
    max-width: 300px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    position: relative;
    overflow: hidden;
    border-bottom: 5px solid var(--accent2);
    transition: transform 0.16s, box-shadow 0.19s, border 0.19s, background 0.19s;
    animation: fadeInUp 0.8s both;
    background: linear-gradient(120deg,#fff 80%,#e0f7fa55 100%);
}

.service:hover {
    transform: translateY(-8px) scale(1.03) rotate(-2deg);
    box-shadow: 0 15px 38px #1864ab22, 0 2px 16px #1864ab1c;
    border-bottom: 5px solid #00b4d8;
    background: linear-gradient(120deg,#eef6ff 80%,#e0f7fa99 100%);
}

.service-icon {
    font-size: 2.25rem;
    color: var(--primary);
    margin-bottom: 1.12rem;
    background: var(--light);
    border-radius: 12px;
    box-shadow: 0 2px 10px #1864ab20;
    padding: 0.5rem;
    display: inline-block;
    position: relative;
    z-index: 2;
    transition: color 0.19s, transform 0.17s;
    animation: pulseIcon 2.5s infinite;
}

.service:hover .service-icon {
    color: var(--accent2);
    transform: scale(1.13) rotate(-7deg);
    animation: none;
}

@keyframes pulseIcon {
    0% { box-shadow: 0 0 0 0 #ffbe3b2b; }
    70% { box-shadow: 0 0 0 12px #ffbe3b00; }
    100% { box-shadow: 0 0 0 0 #ffbe3b00; }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(25px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Portfolio */
.portfolio {
    margin: 2.7rem 0 1.7rem 0;
}

.portfolio-slider {
    display: flex;
    overflow-x: auto;
    gap: 1.2rem;
    padding-bottom: 1rem;
}

.portfolio-card {
    flex: 0 0 320px;
    background: linear-gradient(100deg,#fff 80%,#e0f7fa 100%);
    border-radius: 18px;
    box-shadow: 0 4px 18px #1864ab10;
    padding: 1.15rem 1rem 1.15rem 1rem;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    transition: box-shadow 0.17s, transform 0.16s;
    border-left: 5px solid var(--accent2);
    min-height: 180px;
    position: relative;
}

.portfolio-card:hover {
    box-shadow: 0 12px 26px #00b4d830;
    transform: scale(1.04) translateY(-3px);
}

.portfolio-img {
    width: 100%;
    height: 130px;
    object-fit: cover;
    border-radius: 12px;
    margin-bottom: 0.9rem;
}

.portfolio-title {
    font-weight: 700;
    color: var(--primary);
    font-size: 1.08rem;
}

.portfolio-tags {
    margin: 0.3rem 0;
}

.portfolio-tag {
    font-size: 0.81em;
    background: #e7f6ff;
    color: #1864ab;
    border-radius: 7px;
    padding: 0.13em 0.7em;
    margin-right: 0.23em;
}

.portfolio-desc {
    margin-top: 0.6rem;
    font-size: 0.96rem;
    line-height: 1.6;
    color: #3a4b60;
}

/* News Section */
.news-section {
    margin-top: 2.2rem;
    background: linear-gradient(120deg, #f4f8fa 60%, #e0f4ff 100%);
    border-radius: 18px;
    box-shadow: 0 6px 24px #1864ab19;
    padding: 1.3rem 1.1rem 1.5rem 1.1rem;
}

.news-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.3rem;
    margin-top: 1.2rem;
}

.news-card {
    background: var(--light);
    border-radius: 13px;
    box-shadow: 0 2px 12px #1864ab17;
    padding: 1.2rem;
    border-left: 5px solid var(--accent);
    transition: box-shadow 0.3s, transform 0.3s, border-left-color 0.3s;
    animation: fadeInUp 0.7s;
}

.news-card:hover {
    box-shadow: 0 8px 32px rgba(24, 100, 171, 0.25);
    transform: translateY(-4px);
    border-left-color: var(--accent2);
}

.news-date {
    font-size: 0.92rem;
    color: #888;
    margin-bottom: 0.6rem;
    font-weight: 500;
}

.news-card-title {
    font-size: 1.12rem;
    font-weight: 700;
    color: var(--primary);
    margin: 0.5rem 0 0.7rem 0;
    line-height: 1.4;
}

.news-card-desc {
    color: #444;
    font-size: 0.98rem;
    line-height: 1.6;
    margin-bottom: 0.8rem;
}

.news-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.news-tag {
    font-size: 0.8rem;
    background: #e7f6ff;
    color: #1864ab;
    border-radius: 7px;
    padding: 0.2rem 0.7rem;
}

/* Articles */
.articles-section {
    margin-top: 2.2rem;
    background: linear-gradient(120deg, #f4f6f8 60%, #e0f7fa 100%);
    border-radius: 18px;
    box-shadow: 0 6px 24px #1864ab19;
    padding: 1.3rem 1.1rem 1.5rem 1.1rem;
}

.articles-list {
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
    margin-top: 0.7rem;
}

.article-card-link {
    text-decoration: none;
    display: block;
    transition: transform 0.3s ease;
}

.article-card {
    background: var(--light);
    border-radius: 13px;
    box-shadow: 0 2px 12px #1864ab17;
    padding: 0.9rem 0.9rem;
    border-left: 6px solid var(--accent2);
    position: relative;
    animation: fadeInUp 0.7s;
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    min-height: 90px;
    transition: box-shadow 0.3s, transform 0.3s, border-left-color 0.3s;
}

.article-thumb {
    width: 70px;
    height: 70px;
    border-radius: 11px;
    object-fit: cover;
    box-shadow: 0 1px 7px #00b4d82a;
}

.article-content {
    flex: 1;
}

.article-title {
    font-size: 1.08rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 0.19rem;
    letter-spacing: 0.3px;
}

.article-meta {
    font-size: 0.98rem;
    color: #888;
    margin-bottom: 0.12rem;
}

.article-desc {
    color: #333;
    font-size: 1.01rem;
}

.article-card-link:hover .article-card {
    box-shadow: 0 8px 32px rgba(24, 100, 171, 0.25);
    transform: translateY(-4px);
    border-left-color: var(--accent);
}

.article-title i {
    opacity: 0;
    transform: translateX(-10px);
    transition: opacity 0.3s, transform 0.3s;
}

.article-card-link:hover .article-title i {
    opacity: 1;
    transform: translateX(0);
}

.section-cta {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-top: 1.8rem;
    flex-wrap: wrap;
}

.btn-tertiary {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.85rem 1.6rem;
    border-radius: 999px;
    font-weight: 600;
    color: var(--primary);
    background: rgba(24,100,171,0.12);
    text-decoration: none;
    transition: background 0.3s ease, color 0.3s ease, box-shadow 0.3s ease;
}

.btn-tertiary:hover {
    background: var(--primary);
    color: var(--light);
    box-shadow: 0 14px 30px rgba(24,100,171,0.28);
}

/* Papers */
.papers-section {
    margin-top: 2.4rem;
    background: linear-gradient(140deg, #f2f7ff 55%, #e5fbff 100%);
    border-radius: 20px;
    box-shadow: 0 6px 24px #1864ab1f;
    padding: 1.8rem 1.4rem 2.2rem 1.4rem;
}

.papers-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 1.4rem;
}

.paper-card {
    background: var(--light);
    border-radius: 16px;
    padding: 1.4rem 1.3rem;
    box-shadow: 0 4px 18px rgba(24,100,171,0.12);
    border-top: 6px solid var(--accent);
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
    transition: transform 0.3s ease, box-shadow 0.3s ease, border-top-color 0.3s ease;
}

.paper-card:hover {
    transform: translateY(-6px);
    box-shadow: 0 14px 34px rgba(24,100,171,0.24);
    border-top-color: var(--accent2);
}

.paper-meta {
    display: flex;
    justify-content: space-between;
    font-size: 0.92rem;
    color: #5c6e8a;
    font-weight: 600;
}

.paper-type {
    text-transform: uppercase;
    letter-spacing: 0.6px;
}

.paper-date {
    color: #7c8aa8;
}

.paper-title {
    font-size: 1.18rem;
    margin: 0.2rem 0;
    color: var(--primary);
    line-height: 1.45;
}

.paper-desc {
    color: #31435c;
    line-height: 1.6;
    font-size: 0.99rem;
}

.paper-link {
    margin-top: auto;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-weight: 600;
    color: var(--primary);
    text-decoration: none;
}

.paper-link::after {
    content: "\f061";
    font-family: "Font Awesome 6 Free";
    font-weight: 900;
    font-size: 0.8rem;
    transition: transform 0.3s ease;
}

.paper-link:hover::after {
    transform: translateX(4px);
}

/* Videos */
.videos-section {
    margin-top: 2.4rem;
    background: linear-gradient(140deg, #f7f9ff 50%, #ecf5ff 100%);
    border-radius: 20px;
    box-shadow: 0 6px 24px #1864ab1a;
    padding: 1.8rem 1.4rem 2.2rem 1.4rem;
}

.video-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.4rem;
    margin-top: 1.2rem;
}

.video-card {
    background: var(--light);
    border-radius: 18px;
    overflow: hidden;
    box-shadow: 0 6px 22px rgba(24,100,171,0.14);
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.video-card:hover {
    transform: translateY(-6px);
    box-shadow: 0 16px 38px rgba(24,100,171,0.28);
}

.video-cover {
    position: relative;
    overflow: hidden;
}

.video-cover img {
    width: 100%;
    height: 180px;
    object-fit: cover;
    display: block;
}

.video-length {
    position: absolute;
    bottom: 12px;
    right: 12px;
    background: rgba(0,0,0,0.72);
    color: #fff;
    padding: 0.2rem 0.65rem;
    border-radius: 999px;
    font-size: 0.82rem;
    font-weight: 600;
}

.video-icon {
    position: absolute;
    top: 12px;
    left: 12px;
    background: rgba(255,255,255,0.85);
    color: var(--primary);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
}

.video-content {
    padding: 1.3rem 1.3rem 1.4rem 1.3rem;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.video-title {
    font-size: 1.16rem;
    color: var(--primary);
    margin: 0;
}

.video-desc {
    color: #3a4b60;
    line-height: 1.55;
    font-size: 0.99rem;
}

.video-link {
    margin-top: auto;
    font-weight: 600;
    color: var(--accent);
    text-decoration: none;
}

.video-link:hover {
    text-decoration: underline;
}

/* Newsletter */
.newsletter-section {
    margin-top: 2.4rem;
}

.newsletter-card {
    background: linear-gradient(130deg, rgba(24,100,171,0.15) 0%, rgba(0,180,216,0.18) 100%);
    border-radius: 22px;
    padding: 2rem 2.4rem;
    text-align: center;
    box-shadow: 0 12px 32px rgba(24,100,171,0.18);
}

.newsletter-form {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.9rem;
    margin-top: 1.4rem;
    flex-wrap: wrap;
}

.newsletter-form input {
    flex: 1 1 280px;
    padding: 0.85rem 1rem;
    border: none;
    border-radius: 999px;
    font-size: 1rem;
    background: rgba(255,255,255,0.9);
    box-shadow: inset 0 2px 6px rgba(0,0,0,0.08);
}

.newsletter-form button {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    border: none;
    background: var(--accent);
    color: #fff;
    padding: 0.85rem 1.6rem;
    border-radius: 999px;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 12px 32px rgba(0,180,216,0.32);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.newsletter-form button:hover {
    transform: translateY(-3px);
    box-shadow: 0 16px 40px rgba(0,180,216,0.42);
}

.newsletter-form input:focus {
    outline: 2px solid rgba(24,100,171,0.45);
}

.newsletter-form button i {
    font-size: 1.05rem;
}

/* About layout */
.about {
    padding: 2.2rem 2rem;
}

.about-wrapper {
    display: grid;
    grid-template-columns: minmax(0, 260px) minmax(0, 1fr);
    gap: 2.2rem;
    align-items: center;
}

.about-photo {
    position: relative;
}

.about-photo img {
    width: 100%;
    max-width: 260px;
    border-radius: 22px;
    box-shadow: 0 18px 40px rgba(24,100,171,0.22);
}

.about-text {
    background: rgba(24,100,171,0.08);
    border-radius: 20px;
    padding: 1.4rem 1.6rem;
    box-shadow: 0 10px 28px rgba(24,100,171,0.15);
}

.about-highlights {
    list-style: none;
    padding: 0;
    margin: 1.1rem 0;
}

.about-highlights li {
    margin-bottom: 0.6rem;
    color: #2f4160;
    line-height: 1.6;
    position: relative;
    padding-left: 1.4rem;
}

.about-highlights li::before {
    content: "\2022";
    color: var(--accent2);
    font-weight: 700;
    position: absolute;
    left: 0;
}

/* Contact Form */
.contact-form {
    display: flex;
    flex-direction: column;
    gap: 1.1rem;
    max-width: 440px;
    margin: 0 auto;
    background: rgba(0,180,216,0.050);
    border-radius: 16px;
    box-shadow: 0 2px 12px #1864ab17;
    padding: 1.6rem 1.1rem 1.2rem 1.1rem;
    animation: fadeInUp 1s;
}

.contact-form input, 
.contact-form textarea {
    padding: 0.83rem;
    border: 1.5px solid #cfd8dc;
    border-radius: 8px;
    font-size: 1.01rem;
    background: #f8fafc;
    transition: border 0.2s, box-shadow 0.2s;
}

.contact-form input:focus, 
.contact-form textarea:focus {
    border: 1.5px solid var(--primary);
    outline: none;
    box-shadow: 0 2px 8px #00b4d829;
}

.contact-form input.valid, 
.contact-form textarea.valid {
    border-color: var(--success);
}

.contact-form input.invalid, 
.contact-form textarea.invalid {
    border-color: var(--danger);
}

.contact-form button {
    background: var(--gradient);
    color: var(--light);
    border: none;
    border-radius: 8px;
    padding: 0.82rem;
    font-size: 1.07rem;
    font-weight: bold;
    cursor: pointer;
    transition: background 0.16s, box-shadow 0.16s, transform 0.16s;
    box-shadow: 0 4px 12px #1864ab1f;
    display: flex;
    align-items: center;
    gap: 0.7rem;
    justify-content: center;
}

.contact-form button:hover {
    background: var(--gradient-rev);
    box-shadow: 0 7px 22px #00b4d826;
    transform: translateY(-2px) scale(1.04);
}

.form-note {
    margin-top: 1rem;
    font-size: 0.92rem;
    color: #4a5972;
    text-align: center;
    line-height: 1.5;
}

/* Footer */
footer {
    text-align: center;
    padding: 1.3rem 0 0.7rem 0;
    background: var(--gradient);
    color: #e2eef7;
    margin-top: 2.0rem;
    font-size: 0.97rem;
    letter-spacing: 0.7px;
    border-radius: var(--radius) var(--radius) 0 0;
    box-shadow: 0 -2px 16px #1864ab12;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.footer-social {
    display: flex;
    gap: 1.1rem;
    justify-content: center;
    margin-bottom: 0.15rem;
}

.footer-social a {
    color: var(--accent2);
    font-size: 1.25rem;
    background: rgba(255,255,255,0.10);
    border-radius: 50%;
    padding: 0.38rem;
    transition: background 0.2s, color 0.2s, transform 0.2s;
    text-decoration: none;
}

.footer-social a:hover {
    background: var(--light);
    color: var(--primary);
    transform: scale(1.17);
}

/* AI Chatbot Styles */
#ai-chat-launcher {
    position: fixed;
    bottom: 26px;
    right: 26px;
    z-index: 9999;
    background: linear-gradient(100deg, #1864ab 70%, #00b4d8 100%);
    color: #fff;
    border-radius: 50%;
    width: 58px;
    height: 58px;
    border: none;
    box-shadow: 0 4px 22px #00b4d870;
    font-size: 2rem;
    cursor: pointer;
    transition: background 0.2s, transform 0.2s, box-shadow 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

#ai-chat-launcher:hover {
    background: linear-gradient(90deg,#00b4d8 70%,#ffbe3b 100%);
    transform: scale(1.09);
    box-shadow: 0 6px 28px #00b4d890;
}

#ai-chat-popup {
    position: fixed;
    bottom: 96px;
    right: 26px;
    width: 350px;
    max-width: 96vw;
    height: 430px;
    background: rgba(255,255,255,0.98);
    border-radius: 20px;
    box-shadow: 0 8px 46px #1864ab33;
    border: 1.5px solid #00b4d84c;
    z-index: 9999;
    display: none;
    flex-direction: column;
    overflow: hidden;
    animation: ai-popup-in 0.26s;
}

@keyframes ai-popup-in {
    from {
        opacity: 0;
        transform: translateY(30px) scale(0.93);
    }
    to {
        opacity: 1;
        transform: none;
    }
}

#ai-chat-header {
    background: linear-gradient(100deg, #1864ab 60%, #00b4d8 100%);
    color: #fff;
    padding: 0.9rem 1.1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-weight: 700;
    font-family: 'Poppins', 'Montserrat', Arial, sans-serif;
    font-size: 1.07rem;
    letter-spacing: 0.5px;
}

#ai-chat-header button {
    background: none;
    border: none;
    color: #fff;
    font-size: 1.3rem;
    cursor: pointer;
    transition: color 0.2s;
}

#ai-chat-header button:hover {
    color: #ffbe3b;
}

#ai-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1.1rem 1rem 0.7rem 1rem;
    background: transparent;
    font-size: 0.98rem;
    font-family: 'Nunito', 'Fira Code', 'Roboto', Arial, sans-serif;
    color: #181a2a;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.ai-msg-user, 
.ai-msg-bot {
    padding: 0.65rem 0.9rem;
    border-radius: 13px;
    max-width: 85%;
    word-break: break-word;
    box-shadow: 0 2px 8px #1864ab15;
}

.ai-msg-user {
    align-self: flex-end;
    background: #e7f6ff;
}

.ai-msg-bot {
    align-self: flex-start;
    background: #1864ab11;
    border-left: 4px solid #00b4d8;
}

#ai-chat-form {
    display: flex;
    gap: 0.5rem;
    padding: 0.7rem;
    background: #f8fbff;
    border-top: 1px solid #e1edf6;
}

#ai-chat-form input {
    flex: 1;
    border: 1.3px solid #cfd8dc;
    border-radius: 8px;
    padding: 0.7rem;
    font-size: 1.01rem;
    font-family: inherit;
    transition: border 0.2s;
}

#ai-chat-form input:focus {
    border-color: #00b4d8;
    outline: none;
}

#ai-chat-form button {
    background: linear-gradient(100deg, #1864ab 60%, #00b4d8 100%);
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 0.7rem 1.2rem;
    font-size: 1.13rem;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.2s, transform 0.18s;
    display: flex;
    align-items: center;
    gap: 0.7rem;
}

#ai-chat-form button:hover {
    background: var(--gradient-rev);
    transform: scale(1.07);
}

/* Responsive Design */
@media (max-width: 1100px) {
    .container {
        padding: 1.1rem;
    }
    .papers-list,
    .video-grid {
        grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    }
    .lang-switch {
        right: 6px;
    }
}

@media (max-width: 900px) {
    .about-wrapper {
        grid-template-columns: 1fr;
        text-align: center;
    }
    .about-text {
        font-size: 1rem;
    }
    .about-photo img {
        max-width: 220px;
        margin: 0 auto;
    }
    .video-grid,
    .papers-list {
        grid-template-columns: 1fr;
    }
    .hero-title {
        font-size: 1.27rem;
    }
    .lang-switch {
        top: 8px;
    }
}

@media (max-width: 700px) {
    nav {
        flex-direction: column;
        gap: 0.25rem;
    }
    .container {
        padding: 0.3rem;
    }
    .section-title {
        font-size: 1.04rem;
        padding-left: 0.45rem;
    }
    .hero-avatar {
        width: 70px;
        height: 70px;
    }
    .hero-avatar img {
        width: 60px;
        height: 60px;
    }
    .lang-switch {
        top: 3px;
        right: 2px;
    }
    .newsletter-form {
        flex-direction: column;
        align-items: stretch;
    }
    .newsletter-form input,
    .newsletter-form button,
    .btn-tertiary {
        width: 100%;
        justify-content: center;
    }
    .section-cta {
        justify-content: center;
    }
}

@media (max-width: 500px) {
    #ai-chat-popup {
        width: 99vw;
        right: 0;
        border-radius: 0;
    }
}

/* Image Optimization */
img[loading="lazy"] {
    opacity: 0;
    transition: opacity 0.3s;
}

img[loading="lazy"].loaded,
img[loading="lazy"]:not([src]) {
    opacity: 1;
}

/* WebP Support Check */
@supports (background-image: -webkit-image-set(url("test.webp") 1x)) or 
          (background-image: image-set(url("test.webp") 1x)) {
    /* WebP is supported */
}

/* Stile base per articoli */
.blog-article {
    max-width: 700px;
    margin: 40px auto 40px auto;
    padding: 32px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 4px 32px rgba(0,0,0,0.07);
    font-size: 1.14em;
    line-height: 1.7;
    color: #222;
}

.blog-article h1, .blog-article h2, .blog-article h3 {
    margin-top: 1.3em;
    margin-bottom: 0.5em;
    font-weight: 700;
    color: #1a3a7c;
}

.blog-article h1 {
    font-size: 2.1em;
    margin-bottom: 0.2em;
}

.blog-article .date {
    color: #4985e7;
    font-size: 1em;
    font-weight: 500;
    margin-bottom: 1.1em;
    display: block;
}

.blog-article img {
    display: block;
    max-width: 100%;
    margin: 0 auto 1.5em auto;
    border-radius: 10px;
    box-shadow: 0 2px 14px rgba(0,0,0,0.08);
}

.blog-article ul, .blog-article ol {
    margin-left: 2em;
    margin-bottom: 1em;
}

.blog-article pre, .blog-article code {
    background: #f4f7fc;
    color: #164;
    border-radius: 6px;
    padding: 8px 12px;
    font-size: 1em;
    font-family: "Fira Code", "Menlo", "Monaco", monospace;
    margin-bottom: 1em;
    display: block;
    overflow-x: auto;
}

/* Responsive */
@media (max-width: 900px) {
    .blog-article {
        padding: 16px;
        max-width: 98vw;
    }
}
