/*!
 * Ivan Vaccari Portfolio Stylesheet
 * Version: 1.0.0
 * Author: Ivan Vaccari
 * Description: Modern, responsive stylesheet for professional portfolio
 * Last Updated: January 2025
 */

/* =============================================== */
/* TABLE OF CONTENTS */
/* =============================================== */
/*
  1. Custom Properties & Global Styles
  2. Header & Navigation
  3. Section Styling
  4. Components
  5. Footer
  6. Animations & Responsive
  7. Utility Classes
*/

/* =============================================== */
/* 1. Custom Properties & Global Styles */
/* =============================================== */

:root {
    /* Dark Theme Colors (Default) */
    --color-background: #111827; /* Deep Space */
    --color-surface: #1F2937;    /* Slate */
    --color-text-primary: #F9FAFB; /* Ghost White */
    --color-text-heading: #FFFFFF; /* Pure White */
    --color-accent: #3B82F6;       /* Electric Blue */
    --color-border: #4B5563;       /* Mid Grey */
    
    /* Light Theme Colors (will be applied via JS) */
    --color-background-light: #F9FAFB; /* Light Ghost White */
    --color-surface-light: #FFFFFF;    /* Pure White */
    --color-text-primary-light: #1F2937; /* Slate */
    --color-text-heading-light: #111827; /* Deep Space */
    --color-accent-light: #2563EB;       /* Royal Blue */
    --color-border-light: #D1D5DB;       /* Light Grey */

    /* Theme Switch Transition */
    --theme-transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;

    /* Typography */
    --font-heading: 'Clash Grotesk', sans-serif;
    --font-body: 'Satoshi', sans-serif;

    /* Spacing */
    --spacing-xs: 0.5rem;  /* 8px */
    --spacing-sm: 1rem;    /* 16px */
    --spacing-md: 1.5rem;  /* 24px */
    --spacing-lg: 2rem;    /* 32px */
    --spacing-xl: 4rem;    /* 64px */

    /* Other */
    --border-radius: 8px;
    --transition-speed: 0.3s;
}

/* A modern CSS reset */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
    font-size: 16px;
}

body {
    background-color: var(--color-background);
    color: var(--color-text-primary);
    font-family: var(--font-body);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Full-height layout with sticky footer */
html, body { height: 100%; }
body {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}
main { flex: 1 0 auto; }

.container {
    width: 100%;
    max-width: 1100px;
    margin-left: auto;
    margin-right: auto;
    padding-left: var(--spacing-md);
    padding-right: var(--spacing-md);
}

h1, h2, h3 {
    font-family: var(--font-heading);
    color: var(--color-text-heading);
    font-weight: 600;
    line-height: 1.2;
    margin-bottom: var(--spacing-md);
}

h1 { font-size: 3.5rem; }
h2 { font-size: 2.5rem; }
h3 { font-size: 1.5rem; }

p { margin-bottom: var(--spacing-sm); }
a { color: var(--color-accent); text-decoration: none; transition: opacity var(--transition-speed) ease; }
a:hover { opacity: 0.8; }
ul { list-style: none; }

/* ------------------- */
/* 2. Header & Navigation */
/* ------------------- */

.site-header {
    position: sticky;
    top: 0;
    width: 100%;
    z-index: 1000;
    background-color: rgba(17, 24, 39, 0.8);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--color-border);
}

/* Light theme header adjustment */
body.light-theme .site-header {
    background-color: rgba(249, 250, 251, 0.8);
    border-bottom: 1px solid var(--color-border);
}

.main-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 70px;
}

.nav-logo {
    font-family: var(--font-heading);
    font-size: 1.25rem;
    font-weight: 500;
    color: var(--color-text-heading);
}

.nav-right {
    display: flex;
    align-items: center;
}

.main-nav ul {
    display: flex;
    gap: var(--spacing-lg);
}

.main-nav a {
    color: var(--color-text-primary);
    font-weight: 500;
    position: relative;
    padding: var(--spacing-xs) 0;
}

.main-nav a.active,.main-nav a:hover {
    color: var(--color-accent);
}

/* Improve navigation contrast in light theme */
body.light-theme .main-nav a {
    color: #1F2937; /* Ensure dark text on light header */
}

body.light-theme .main-nav a.active,
body.light-theme .main-nav a:hover {
    color: var(--color-accent);
}

/* Theme toggle styles */
.theme-toggle {
    background: none;
    border: none;
    color: var(--color-text-primary);
    cursor: pointer;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--spacing-xs);
    border-radius: 50%;
    background-color: var(--color-surface);
    transition: transform 0.3s ease, background-color 0.3s ease;
    margin-left: var(--spacing-md);
}

body.light-theme .theme-toggle {
    color: #1F2937; /* Ensure dark icon in light theme */
    background-color: rgba(240, 246, 255, 0.8);
}

.theme-toggle:hover {
    transform: rotate(15deg);
    background-color: rgba(59, 130, 246, 0.2);
}

/* Mobile menu styles */
.hamburger-menu {
    display: none;
    flex-direction: column;
    justify-content: space-around;
    width: 2rem;
    height: 2rem;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0;
    z-index: 1001;
}

.hamburger-menu span {
    width: 2rem;
    height: 0.25rem;
    background-color: var(--color-text-primary);
    border-radius: 10px;
    transition: all 0.3s linear;
    position: relative;
    transform-origin: 1px;
}

/* Ensure hamburger menu is visible in light theme */
body.light-theme .hamburger-menu span {
    background-color: #1F2937;
}

.mobile-menu-container {
    position: fixed;
    top: 0;
    right: -100%;
    width: 75%;
    height: 100vh;
    background-color: var(--color-surface);
    box-shadow: -4px 0 10px rgba(0, 0, 0, 0.2);
    transition: right 0.3s ease-in-out;
    z-index: 1000;
    padding: 5rem var(--spacing-md) var(--spacing-md);
    display: flex;
    flex-direction: column;
}

body.light-theme .mobile-menu-container {
    box-shadow: -4px 0 10px rgba(37, 99, 235, 0.1);
}

.mobile-menu-container.open {
    right: 0;
}

.mobile-nav-list {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
}

.mobile-nav-list a {
    color: var(--color-text-primary);
    font-size: 1.2rem;
    font-weight: 500;
    display: block;
    padding: var(--spacing-sm) 0;
    border-bottom: 1px solid var(--color-border);
}

.mobile-nav-list a.active,
.mobile-nav-list a:hover {
    color: var(--color-accent);
}

.mobile-menu-header {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    padding: var(--spacing-sm) var(--spacing-md);
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--color-border);
}

.close-menu {
    background: none;
    border: none;
    color: var(--color-text-primary);
    font-size: 1.5rem;
    cursor: pointer;
}

.mobile-theme-toggle {
    margin-top: auto;
    display: flex;
    align-items: center;
    padding: var(--spacing-sm) 0;
    color: var(--color-text-primary);
    cursor: pointer;
    gap: var(--spacing-sm);
}

.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: none;
    z-index: 999;
}

/* ------------------- */
/* 3. Section Styling */
/* ------------------- */

.content-section {
    padding-top: var(--spacing-xl);
    padding-bottom: var(--spacing-xl);
}

.text-center { text-align: center; }

/* Hero Section */
.hero-section {
    min-height: 30vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    padding-top: var(--spacing-xl);
    padding-bottom: 2rem;
}

.hero-subtitle {
    font-size: 1.25rem;
    color: var(--color-text-primary);
    max-width: 600px;
    margin: 0 auto var(--spacing-lg);
}

.social-links {
    display: flex;
    gap: var(--spacing-md);
    margin-top: var(--spacing-md);
}

.social-links-centered {
    justify-content: center;
}

.social-links a {
    color: var(--color-text-primary);
    font-size: 1.5rem;
    margin: 0 10px;
    transition: color 0.3s ease, transform 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: var(--color-surface);
}

.social-links a:hover {
    color: var(--color-accent);
    transform: translateY(-3px);
}

.hero-container {
    display: flex;
    align-items: center;
    gap: 2rem;
}

.hero-image-container {
    flex-shrink: 0;
}

.hero-image {
    width: 200px;
    height: 200px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid var(--color-accent);
}

.hero-content {
    flex: 1;
}

/* Typing animation styles */
.cursor {
    display: inline-block;
    width: 2px;
    background-color: var(--color-text-primary);
    margin-left: 2px;
    animation: blink 1s infinite;
}

@keyframes blink {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0;
    }
}

/* Experience Timeline */
.timeline {
    position: relative;
    margin: 2rem 0;
    padding: 2rem 0;
}

.timeline::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 2px; /* Made the line slightly thinner */
    height: 100%;
    background-color: var(--color-border); /* Using CSS variable */
}

/* Improve timeline visibility in light theme */
body.light-theme .timeline::before {
    background-color: rgba(37, 99, 235, 0.3);
}

.timeline-item {
    position: relative;
    width: 50%;
    padding: 1rem 2rem;
    box-sizing: border-box;
}

.timeline-item:nth-child(odd) {
    left: 0;
    padding-right: 4rem;
    text-align: left;
}

.timeline-item:nth-child(even) {
    left: 50%;
    padding-left: 4rem;
}

.timeline-item::before {
    content: '';
    position: absolute;
    top: 20px; /* Adjust to align with your content */
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background-color: var(--color-text-heading); /* Using CSS variable */
    border: 3px solid var(--color-border); /* Using CSS variable */
    z-index: 1;
}

.timeline-item:nth-child(odd)::before {
    right: 0;
    transform: translateX(50%);
}

.timeline-item:nth-child(even)::before {
    left: 0;
    transform: translateX(-50%);
}

.timeline-content {
    background: var(--color-surface);
    padding: 1.5rem;
    border-radius: var(--border-radius);
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    position: relative;
    transition: transform var(--transition-speed) ease, box-shadow var(--transition-speed) ease;
}

/* Light theme box shadows enhancement */
body.light-theme .timeline-content,
body.light-theme .education-item,
body.light-theme .project-card {
    box-shadow: 0 4px 16px rgba(37, 99, 235, 0.1);
    border: 1px solid rgba(200, 219, 255, 0.8);
}

.timeline-content::before, .education-item::before, .project-card::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border-radius: var(--border-radius);
    border: 2px solid transparent;
    transition: border-color var(--transition-speed) ease-in-out;
    pointer-events: none;
}

.timeline-content:hover, .education-item:hover, .project-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 20px rgba(59, 130, 246, 0.25);
}

.timeline-content:hover::before, .education-item:hover::before, .project-card:hover::before {
    border-color: var(--color-accent);
}

.timeline-content h3 { 
    color: var(--color-text-heading);
    margin-bottom: var(--spacing-xs); 
}
.timeline-meta {
    font-style: italic;
    color: #9CA3AF; /* A lighter grey for meta text */
    margin-bottom: var(--spacing-sm);
}

/* Improve meta text contrast in light theme */
body.light-theme .timeline-meta,
body.light-theme .education-meta,
body.light-theme .project-card .issuer {
    color: #4B5563;
}
.timeline-content ul {
    list-style-type: disc;
    padding-left: var(--spacing-md);
    color: var(--color-text-primary);
}

/* Skills Section */
.skills-container {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--spacing-lg);
}

.skills-column h3 {
    margin-bottom: var(--spacing-md);
    border-bottom: 2px solid var(--color-accent);
    padding-bottom: var(--spacing-xs);
    display: inline-block;
}

.skills-grid {
    display: flex;
    flex-wrap: wrap;
    gap: var(--spacing-sm);
}

.skills-grid span {
    background-color: var(--color-surface);
    padding: var(--spacing-xs) var(--spacing-sm);
    border-radius: var(--border-radius);
    border: 1px solid var(--color-border);
    transition: all var(--transition-speed) ease;
}

.skills-grid span:hover {
    background-color: var(--color-accent);
    color: var(--color-text-heading);
    border-color: var(--color-accent);
    transform: translateY(-2px);
}

/* Improve skill tags in light theme */
body.light-theme .skills-grid span {
    background-color: rgba(230, 242, 255, 0.8);
    border: 1px solid rgba(180, 209, 255, 0.6);
    box-shadow: 0 2px 4px rgba(37, 99, 235, 0.08);
}

/* Education Section */
.education-item {
    background-color: var(--color-surface);
    padding: var(--spacing-md);
    border-radius: var(--border-radius);
    border-left: 4px solid var(--color-accent);
    margin-bottom: var(--spacing-md);
    position: relative;
    transition: transform var(--transition-speed) ease, box-shadow var(--transition-speed) ease;
}

.education-item h3 { margin-bottom: var(--spacing-xs); }
.education-meta { color: #9CA3AF; margin-bottom: var(--spacing-xs); }

/* Projects Section */
.projects-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: var(--spacing-lg);
}

.project-card {
    background-color: var(--color-surface);
    border-radius: var(--border-radius);
    padding: var(--spacing-md);
    border: 1px solid var(--color-border);
    transition: transform var(--transition-speed) ease, box-shadow var(--transition-speed) ease;
    position: relative;
    display: flex;
    flex-direction: column;
    min-height: 280px; /* Ensure all cards have a minimum height */
}

.project-card:hover {
    /* This will be handled by the shared hover style */
}

.project-card h3 {
    margin-bottom: var(--spacing-sm);
    color: var(--color-accent);
}

.project-tags {
    display: flex;
    flex-wrap: wrap;
    gap: var(--spacing-xs);
    margin-top: var(--spacing-md);
}

.project-tags span {
    background-color: #374151; /* Slightly different from skill tags */
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-size: 0.875rem;
}

.certification-link {
    display: block;
    margin-top: auto;
    padding: 0.5rem 1rem;
    background-color: var(--color-accent);
    color: var(--color-text-heading);
    border-radius: var(--border-radius);
    font-weight: 500;
    transition: transform var(--transition-speed) ease, background-color var(--transition-speed) ease;
    text-align: center;
    width: fit-content;
    margin-left: auto;
    margin-right: auto;
}

.certification-link:hover {
    background-color: #1D4ED8; /* Darker accent color */
    transform: translateY(-2px);
    opacity: 1;
}

/* Styling for certification details */
.project-card p {
    color: var(--color-text-primary);
    margin-bottom: var(--spacing-md);
    font-size: 0.95rem;
    line-height: 1.5;
}

/* Style for credential IDs and dates */
.project-card p br + strong,
.project-card p strong {
    color: var(--color-accent);
    font-weight: 500;
}

/* Company name styling */
.project-card .issuer {
    color: #9CA3AF;
    font-style: italic;
    margin-top: 0.25rem;
    display: block;
}

hr.section-divider {
    border: 0;
    height: 1px;
    background-color: var(--color-border);
    margin: var(--spacing-xl) 0;
}

/* ------------------- */
/* 4. Components */
/* ------------------- */

.button {
    display: inline-block;
    background-color: var(--color-accent);
    color: var(--color-text-heading);
    padding: var(--spacing-sm) var(--spacing-lg);
    border-radius: var(--border-radius);
    font-weight: 700;
    margin-top: var(--spacing-sm);
    transition: background-color var(--transition-speed) ease;
    border: 1px solid transparent;
}

.button:hover {
    background-color: #1D4ED8; /* A darker shade of the accent blue */
    opacity: 1;
}

/* Ghost/Outline buttons */
.button-ghost {
    background: transparent;
    color: var(--color-accent);
    border: 1px solid var(--color-accent);
}

.button-ghost:hover {
    background: rgba(59,130,246,0.15);
}

.button-outline {
    background: transparent;
    color: var(--color-text-primary);
    border: 1px solid var(--color-border);
}

.button-outline:hover {
    background: rgba(59,130,246,0.15);
    border-color: var(--color-accent);
}


/* ------------------- */
/* 5. Footer */
/* ------------------- */

.site-footer {
    background-color: var(--color-background);
    padding: var(--spacing-sm) 0;
    border-top: 1px solid var(--color-border);
    margin-top: var(--spacing-lg);
}

.footer-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.875rem;
    text-align: center;
    line-height: 1.3;
}

.footer-content p {
    margin: 0;
}

.social-links-footer {
    display: flex;
    gap: var(--spacing-sm);
}

.social-links-footer a {
    color: var(--color-text-primary);
    font-size: 1rem;
    margin: 0 6px;
    transition: color 0.3s ease, transform 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background-color: var(--color-surface);
}

.social-links-footer a:hover {
    color: var(--color-accent);
    transform: translateY(-3px);
}

/* =============================================== */
/* 6. Animations & Responsive */
/* =============================================== */

/* Fade-in animation for sections */
.content-section {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.6s ease-out, transform 0.6s ease-out;
}

.content-section.visible {
    opacity: 1;
    transform: translateY(0);
}

/* Loading animation */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Pulse animation for interactive elements */
@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

/* Responsive adjustments */
@media (max-width: 768px) {
    :root {
        --spacing-xl: 2rem; /* Reduce spacing on mobile */
    }

    h1 { font-size: 2.5rem; }
    h2 { font-size: 2rem; }

    .main-nav ul { 
        display: none; /* Hide desktop nav */
    }
    
    .hamburger-menu {
        display: flex; /* Show hamburger menu */
    }
    
    /* Hide header theme toggle on mobile; keep only the one in the mobile menu */
    #theme-toggle {
        display: none;
    }
    
    .overlay.open {
        display: block;
    }
    
    .skills-container,
    .projects-grid {
        grid-template-columns: 1fr;
    }

    .timeline::before { left: 10px; }
    .timeline-item { 
        width: 100%;
        left: 0 !important;
        padding-left: 40px; 
        padding-right: var(--spacing-md);
    }
    .timeline-item::before { 
        left: 4px !important;
        transform: translateX(0) !important;
    }

    .footer-content {
        flex-direction: column;
        gap: var(--spacing-xs);
    }

    /* Keep compact footer in a single wrapped row on small screens */
    .footer-content.footer-compact {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: space-between;
        gap: var(--spacing-xs);
    }

    .hero-container {
        flex-direction: column;
        text-align: center;
    }

    .hero-image {
        width: 150px;
        height: 150px;
    }
}

@media (max-width: 480px) {
    .container {
        padding-left: var(--spacing-sm);
        padding-right: var(--spacing-sm);
    }

    h1 { font-size: 2rem; }
    h2 { font-size: 1.75rem; }
    
    .social-links a {
        width: 35px;
        height: 35px;
        font-size: 1.25rem;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    :root {
        --color-background: #000000;
        --color-text-primary: #FFFFFF;
        --color-accent: #00BFFF;
    }
}

/* Light theme class */
body.light-theme {
    --color-background: var(--color-background-light);
    --color-surface: rgba(240, 246, 255, 1); /* Leggera sfumatura azzurra invece del bianco puro */
    --color-text-primary: var(--color-text-primary-light);
    --color-text-heading: var(--color-text-heading-light);
    --color-accent: var(--color-accent-light);
    --color-border: rgba(200, 219, 255, 0.8); /* Bordo azzurro più visibile */
}

/* Apply transitions to elements that change with theme */
body, .site-header, .timeline-content, .education-item, .project-card, 
.skills-grid span, .social-links a, .button, .site-footer {
    transition: var(--theme-transition);
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    html {
        scroll-behavior: auto;
    }
}

/* =============================================== */
/* 7. Utility Classes */
/* =============================================== */

/* Wave GIF */
.wave-gif {
    width: 45px;
    height: 45px;
    vertical-align: middle;
    margin-right: 8px;
}

/* Text utilities */
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

/* Spacing utilities */
.mt-sm { margin-top: var(--spacing-sm); }
.mt-md { margin-top: var(--spacing-md); }
.mt-lg { margin-top: var(--spacing-lg); }
.mb-sm { margin-bottom: var(--spacing-sm); }
.mb-md { margin-bottom: var(--spacing-md); }
.mb-lg { margin-bottom: var(--spacing-lg); }

/* Display utilities */
.d-none { display: none; }
.d-block { display: block; }
.d-flex { display: flex; }
.d-grid { display: grid; }

/* Flex utilities */
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.align-center { align-items: center; }

/* Visibility utilities */
.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;
}

/* Skip link that appears on focus */
.sr-only:focus {
    position: absolute;
    top: 10px;
    left: 10px;
    width: auto;
    height: auto;
    padding: 10px 15px;
    margin: 0;
    overflow: visible;
    clip: auto;
    white-space: normal;
    background-color: var(--color-accent);
    color: var(--color-text-heading);
    text-decoration: none;
    border-radius: var(--border-radius);
    z-index: 9999;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

/* Responsive display utilities */
.d-md-inline { display: none; }
@media (min-width: 769px) {
    .d-md-inline { display: inline; }
}