:root {
    --primary-color: #4f46e5; /* Improved contrast */
    --primary-dark: #3730a3;
    --secondary-color: #764ba2;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --bg-light: #f8fafc;
    --bg-white: #ffffff;
    --border-color: #e2e8f0;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --transition: all 0.3s ease;
    --success-color: #059669; /* High contrast green */
    --error-color: #dc2626; /* High contrast red */
}

/* Dark theme variables */
body.dark-theme {
    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
    --bg-light: #1e293b;
    --bg-white: #0f172a;
    --border-color: #334155;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.3);
}

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    line-height: 1.6;
    color: var(--text-primary);
    background-color: var(--bg-white);
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* Dark theme specific styles */
body.dark-theme {
    color: var(--text-primary);
    background-color: var(--bg-white);
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Accessibility Styles */
.skip-link {
    position: absolute;
    top: -40px;
    left: 6px;
    background: var(--primary-color);
    color: white;
    padding: 8px;
    text-decoration: none;
    border-radius: 0 0 8px 8px;
    z-index: 9999;
    transition: var(--transition);
}

.skip-link:focus {
    top: 0;
}

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

/* Focus styles */
*:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* Remove focus for mouse users but keep for keyboard users */
*:focus:not(:focus-visible) {
    outline: none;
}

/* High contrast focus for buttons and links */
button:focus-visible,
a:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
    border-radius: 4px;
}

/* Form error and help text styles */
.error-message {
    color: var(--error-color);
    font-size: 0.875rem;
    margin-top: 4px;
    display: none;
}

.error-message.visible {
    display: block;
}

.form-help {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-top: 4px;
}

/* Form message styles */
.form-message.success {
    color: var(--success-color);
    background-color: rgba(5, 150, 105, 0.1);
    border: 1px solid rgba(5, 150, 105, 0.3);
    padding: 1rem;
    border-radius: 8px;
    margin-top: 1rem;
}

.form-message.error {
    color: var(--error-color);
    background-color: rgba(220, 38, 38, 0.1);
    border: 1px solid rgba(220, 38, 38, 0.3);
    padding: 1rem;
    border-radius: 8px;
    margin-top: 1rem;
}

/* Navigation */
.navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    box-shadow: var(--shadow);
    z-index: 1000;
    transition: var(--transition);
}

/* Dark theme navbar */
body.dark-theme .navbar {
    background: rgba(15, 23, 42, 0.95);
}

.navbar .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 20px;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.nav-logo {
    height: 50px;
    width: auto;
}

.nav-brand-text {
    display: flex;
    flex-direction: column;
}

.nav-brand h1 {
    font-size: 1.5rem;
    color: var(--primary-color);
    margin-bottom: 0;
}

.nav-brand .subtitle {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin: 0;
}

.nav-menu {
    display: flex;
    align-items: center;
    gap: 2rem;
}

/* Theme Toggle */
.theme-toggle {
    display: flex;
    align-items: center;
}

.theme-btn {
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 50%;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;  /* Touch target size */
    height: 44px;
    min-width: 44px;
    min-height: 44px;
}

.theme-btn:hover {
    background-color: var(--bg-light);
    transform: scale(1.1);
}

.theme-btn:focus {
    outline: none;
    box-shadow: 0 0 0 2px var(--primary-color);
}

.nav-menu a {
    text-decoration: none;
    color: var(--text-primary);
    font-weight: 500;
    transition: var(--transition);
    position: relative;
}

.nav-menu a:hover {
    color: var(--primary-color);
}

.nav-menu a::after {
    content: '';
    position: absolute;
    bottom: -5px;
    left: 0;
    width: 0;
    height: 2px;
    background: var(--primary-color);
    transition: var(--transition);
}

.nav-menu a:hover::after {
    width: 100%;
}

.language-switcher {
    display: flex;
    gap: 0.5rem;
    margin-left: 1rem;
}

.lang-btn {
    background: transparent;
    border: 1px solid var(--border-color);
    padding: 0.4rem 0.8rem;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 500;
    transition: var(--transition);
    color: var(--text-secondary);
}

.lang-btn.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.lang-btn:hover:not(.active) {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

/* Dark theme language buttons */
body.dark-theme .lang-btn {
    border-color: var(--border-color);
    color: var(--text-secondary);
}

body.dark-theme .lang-btn:hover:not(.active) {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.hamburger {
    background: none;
    border: none;
    cursor: pointer;
    display: none;
    flex-direction: column;
    gap: 4px;
    padding: 8px;
    min-height: 44px;
    min-width: 44px;
    justify-content: center;
    align-items: center;
}

.hamburger-line {
    width: 25px;
    height: 3px;
    background: var(--text-primary);
    transition: var(--transition);
}

/* Hero Section */
.hero {
    min-height: 100vh;
    display: flex;
    align-items: center;
    background: linear-gradient(rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.5)), url('../icon/Copertina_Social.png');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    color: white;
    padding-top: 80px;
}

.hero-content {
    text-align: center;
    max-width: 800px;
    margin: 0 auto;
}

.hero-title {
    font-size: 3.5rem;
    font-weight: 700;
    margin-bottom: 1rem;
    line-height: 1.2;
}

.hero-subtitle {
    font-size: 1.5rem;
    margin-bottom: 2rem;
    opacity: 0.95;
}

.hero-cta {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

/* Buttons */
.btn {
    padding: 0.875rem 2rem;
    border-radius: 8px;
    font-weight: 600;
    text-decoration: none;
    display: inline-block;
    transition: var(--transition);
    border: none;
    cursor: pointer;
    font-size: 1rem;
    min-height: 44px; /* Touch target size */
    min-width: 44px;
    position: relative;
}

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

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.btn-outline {
    background: transparent;
    color: white;
    border: 2px solid white;
}

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

/* Dark theme button outline */
body.dark-theme .btn-outline:hover {
    background: var(--bg-light);
    color: var(--primary-color);
}

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

.btn-secondary:hover {
    background: #475569;
}

/* Sections */
.section {
    padding: 5rem 0;
}

.section-title {
    font-size: 2.5rem;
    text-align: center;
    margin-bottom: 3rem;
    position: relative;
    padding-bottom: 1rem;
}

.section-title::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 80px;
    height: 4px;
    background: var(--primary-color);
    border-radius: 2px;
}

/* About Section */
.about {
    background: var(--bg-light);
}

.about-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 3rem;
    align-items: start;
}

/* Projects Section */
.projects {
    background: var(--bg-light);
}

.about-text p {
    margin-bottom: 1.5rem;
    font-size: 1.1rem;
    line-height: 1.8;
    color: var(--text-secondary);
}

.skills h3 {
    margin-bottom: 1.5rem;
    color: var(--text-primary);
}

.skills-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
}

.skill-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background: white;
    border-radius: 8px;
    box-shadow: var(--shadow);
    transition: var(--transition);
}

.skill-item:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
}

/* Dark theme skills */
body.dark-theme .skill-item {
    background: var(--bg-light);
    color: var(--text-primary);
}

.skill-item i {
    font-size: 2rem;
    color: var(--primary-color);
}

.skill-item span {
    font-weight: 500;
}

/* Timeline */
.timeline,
.projects-timeline {
    position: relative;
    max-width: 1000px;
    margin: 0 auto;
    padding: 2rem 0;
}

.timeline::before,
.projects-timeline::before {
    content: '';
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    width: 2px;
    height: 100%;
    background: var(--border-color);
}

/* Dark theme timeline line */
body.dark-theme .timeline::before,
body.dark-theme .projects-timeline::before {
    background: #475569;
}

.timeline-item {
    display: flex;
    margin-bottom: 3rem;
    position: relative;
}

.timeline-item:nth-child(odd) {
    flex-direction: row-reverse;
}

.timeline-content {
    width: calc(50% - 30px);
    padding: 1.5rem;
    background: white;
    border-radius: 8px;
    box-shadow: var(--shadow);
    transition: var(--transition);
}

.timeline-content:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-5px);
}

/* Dark theme timeline */
body.dark-theme .timeline-content {
    background: var(--bg-light);
    color: var(--text-primary);
}

.timeline-date {
    display: inline-block;
    background: var(--primary-color);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-size: 0.875rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

.timeline-title {
    font-size: 1.25rem;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.timeline-company {
    font-weight: 600;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}
.company-link {
    color: var(--primary-color);
    text-decoration: none;
    transition: var(--transition);
}

.company-link:hover {
    color: var(--primary-dark);
    text-decoration: underline;
}

.company-link i {
    font-size: 0.75rem;
    margin-left: 0.25rem;
}
.timeline-type {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

.timeline-description {
    color: var(--text-secondary);
    line-height: 1.6;
}

.timeline-description ul {
    margin-top: 0.5rem;
    padding-left: 1.5rem;
}

.timeline-logo-container {
    margin-bottom: 1.5rem;
    position: relative;
    width: fit-content;
}

.timeline-logo {
    width: 120px;
    height: 120px;
    object-fit: contain;
    padding: 1rem;
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: var(--transition);
}

/* Dark theme timeline logos */
body.dark-theme .timeline-logo {
    background: var(--bg-light);
}

.timeline-logo-link {
    display: block;
    position: relative;
    text-decoration: none;
    border-radius: 12px;
    overflow: hidden;
}

.timeline-logo-link:hover .timeline-logo {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.logo-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to top, rgba(102, 126, 234, 0.95), rgba(102, 126, 234, 0));
    color: white;
    padding: 0.75rem 0.5rem 0.5rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-align: center;
    opacity: 0;
    transition: var(--transition);
    border-radius: 0 0 12px 12px;
}

.timeline-logo-link:hover .logo-overlay {
    opacity: 1;
}

.logo-overlay i {
    font-size: 0.7rem;
}

.timeline-skills {
    margin-top: 1rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.timeline-skill {
    background: var(--bg-light);
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* Dark theme timeline skills */
body.dark-theme .timeline-skill {
    background: var(--bg-white);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.project-website {
    margin-bottom: 1rem;
}

.project-link {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    text-decoration: none;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.875rem;
    transition: var(--transition);
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.project-link:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.project-link i {
    font-size: 0.875rem;
}

.timeline-marker {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    width: 20px;
    height: 20px;
    background: var(--primary-color);
    border: 4px solid white;
    border-radius: 50%;
    box-shadow: var(--shadow);
    z-index: 1;
}

/* Contact Section */
.contact {
    background: var(--bg-light);
}

.contact-wrapper {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 3rem;
}

.contact-info {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.info-item {
    display: flex;
    gap: 1rem;
    padding: 1.5rem;
    background: white;
    border-radius: 8px;
    box-shadow: var(--shadow);
    transition: var(--transition);
}

/* Dark theme info items */
body.dark-theme .info-item {
    background: var(--bg-light);
    color: var(--text-primary);
}

.info-item:hover {
    transform: translateX(5px);
}

.info-item i {
    font-size: 1.5rem;
    color: var(--primary-color);
    margin-top: 0.25rem;
}

.info-item h4 {
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.info-item p,
.info-item a {
    color: var(--text-secondary);
    text-decoration: none;
}

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

/* Form */
.contact-form-wrapper {
    background: white;
    padding: 2rem;
    border-radius: 8px;
    box-shadow: var(--shadow);
}

/* Dark theme contact form */
body.dark-theme .contact-form-wrapper {
    background: var(--bg-light);
    color: var(--text-primary);
}

/* Remove default fieldset styling */
fieldset {
    border: none;
    padding: 0;
    margin: 0;
    min-width: 0;
}

legend.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;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text-primary);
}

.form-group input,
.form-group textarea {
    width: 100%;
    padding: 0.875rem;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    font-family: inherit;
    font-size: 1rem;
    transition: var(--transition);
    background: var(--bg-white);
}

.form-group input::placeholder,
.form-group textarea::placeholder {
    color: #94a3b8;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* Dark theme forms */
body.dark-theme .form-group input,
body.dark-theme .form-group textarea {
    background-color: var(--bg-light);
    border-color: #475569;
    color: var(--text-primary);
}

body.dark-theme .form-group input::placeholder,
body.dark-theme .form-group textarea::placeholder {
    color: #64748b;
}

body.dark-theme .form-group input:focus,
body.dark-theme .form-group textarea:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.15);
}

.checkbox-label {
    display: flex;
    align-items: start;
    gap: 0.5rem;
    cursor: pointer;
    font-size: 0.875rem;
}

.checkbox-label input[type="checkbox"] {
    width: auto;
    margin-top: 0.25rem;
    cursor: pointer;
}

.checkbox-label a {
    color: var(--primary-color);
    text-decoration: none;
}

.checkbox-label a:hover {
    text-decoration: underline;
}

.form-message {
    padding: 1rem;
    border-radius: 6px;
    margin-bottom: 1rem;
    display: none;
}

.form-message.success {
    background: #d1fae5;
    color: #065f46;
    border: 1px solid #34d399;
    display: block;
}

.form-message.error {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #f87171;
    display: block;
}

.recaptcha-notice {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 1rem;
    text-align: center;
}

.recaptcha-notice a {
    color: var(--primary-color);
    text-decoration: none;
}

/* Footer */
.footer {
    background: var(--text-primary);
    color: white;
    padding: 3rem 0 1rem;
}

/* Dark theme footer */
body.dark-theme .footer {
    background: #0f172a;
    color: white;
}

.footer-content {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 2rem;
    margin-bottom: 2rem;
}

.footer-col h4 {
    margin-bottom: 1rem;
    color: white;
}

.footer-col p {
    color: rgba(255, 255, 255, 0.7);
    margin-bottom: 0.5rem;
}

.footer-col ul {
    list-style: none;
}

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

.footer-col a {
    color: rgba(255, 255, 255, 0.7);
    text-decoration: none;
    transition: var(--transition);
}

.footer-col a:hover {
    color: white;
}

.footer-bottom {
    text-align: center;
    padding-top: 2rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.footer-bottom p {
    color: rgba(255, 255, 255, 0.7);
}

/* Cookie Banner */
.cookie-banner {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    box-shadow: 0 -4px 6px -1px rgba(0, 0, 0, 0.1);
    padding: 1.5rem;
    z-index: 9999;
    transition: var(--transition);
}

/* Dark theme cookie banner */
body.dark-theme .cookie-banner {
    background: var(--bg-light);
    color: var(--text-primary);
}

.cookie-banner.hidden {
    transform: translateY(100%);
}

.cookie-content {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 2rem;
}

.cookie-content p {
    margin: 0;
    flex: 1;
}

.cookie-content a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
}

.cookie-buttons {
    display: flex;
    gap: 1rem;
}

/* Responsive */
@media (max-width: 968px) {
    .nav-menu {
        position: fixed;
        top: 70px;
        left: -100%;
        width: 100%;
        background: white;
        flex-direction: column;
        padding: 2rem;
        box-shadow: var(--shadow);
        transition: var(--transition);
    }

    .nav-menu.active {
        left: 0;
    }
    
    /* Dark theme mobile menu */
    body.dark-theme .nav-menu {
        background: var(--bg-white);
    }

    .hamburger {
        display: flex;
    }

    .hero-title {
        font-size: 2.5rem;
    }

    .hero-subtitle {
        font-size: 1.25rem;
    }

    .about-content {
        grid-template-columns: 1fr;
    }

    .timeline::before {
        left: 30px;
    }

    .timeline-item {
        flex-direction: row !important;
    }

    .timeline-content {
        width: calc(100% - 60px);
        margin-left: 60px;
    }

    .timeline-marker {
        left: 30px;
    }

    .contact-wrapper {
        grid-template-columns: 1fr;
    }

    .footer-content {
        grid-template-columns: 1fr;
    }

    .cookie-content {
        flex-direction: column;
        text-align: center;
    }

    .skills-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 640px) {
    .hero-title {
        font-size: 2rem;
    }

    .hero-subtitle {
        font-size: 1rem;
    }

    .section-title {
        font-size: 2rem;
    }

    .hero-cta {
        flex-direction: column;
        align-items: center;
    }

    .hero-cta .btn {
        width: 100%;
        max-width: 300px;
    }
}
