/* Reset & Variabili */
:root {
    /* Palette Light Mode (Professional) */
    --bg-body: #FFFFFF;
    --bg-surface: #F9FAFB;
    --text-main: #1F2937; /* Grigio Antracite Profondo */
    --text-muted: #6B7280;
    --accent-color: #DC2626; /* Rosso Ingegneristico */
    --accent-hover: #B91C1C;
    --border-color: #E5E7EB;
    
    /* Typography */
    --font-display: 'Space Grotesk', sans-serif;
    --font-body: 'Inter', sans-serif;

    /* Spacing & Layout */
    --container-width: 1400px;
    --header-height: 90px;
    --radius-sm: 2px; /* Bordi più netti per professionalità */
    --radius-md: 4px;
    --radius-lg: 8px;

    /* Transitions */
    --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
    --duration-fast: 0.3s;
    --duration-slow: 0.8s;
}

/* Dark Mode Variables */
body.dark-mode {
    --bg-body: #0F0F0F; /* Nero Assoluto */
    --bg-surface: #1A1A1A;
    --text-main: #F3F4F6;
    --text-muted: #9CA3AF;
    --accent-color: #EF4444; /* Rosso Luminoso */
    --accent-hover: #DC2626;
    --border-color: #262626;
}

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

html {
    scroll-behavior: smooth;
    font-size: 16px;
}

body {
    background-color: var(--bg-body);
    color: var(--text-main);
    font-family: var(--font-body);
    line-height: 1.6;
    transition: background-color var(--duration-fast) ease, color var(--duration-fast) ease;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-display);
    font-weight: 700;
    line-height: 1.1;
    letter-spacing: -0.02em;
}

a {
    text-decoration: none;
    color: inherit;
    transition: color var(--duration-fast) ease;
}

ul { list-style: none; }
img { max-width: 100%; display: block; }

/* Utility Classes */
.container {
    max-width: var(--container-width);
    margin: 0 auto;
    padding: 0 24px;
}

.container-fluid {
    width: 100%;
    padding: 0 40px;
}

.section-padding {
    padding: 120px 0;
}

.text-gradient {
    color: var(--text-main); /* Niente gradiente arcobaleno, solo solid professional */
    display: inline-block;
    position: relative;
    z-index: 1; /* Assicura che il testo stia sopra la linea */
}

.text-gradient::after {
    content: '';
    position: absolute;
    bottom: 2px;
    left: 0;
    width: 100%;
    height: 4px; /* Sottolineatura tecnica */
    background-color: var(--accent-color);
    opacity: 0.8;
    z-index: -1; /* La linea va dietro al testo per non coprire le discendenti (g, y, p) */
}

body.dark-mode .text-gradient {
    color: #FFFFFF;
}

.eyebrow {
    font-family: var(--font-display);
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--accent-color);
    margin-bottom: 1rem;
    display: block;
    font-weight: 600;
}

/* Buttons */
.btn-primary {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    background-color: var(--accent-color);
    color: #fff;
    padding: 16px 32px;
    border-radius: var(--radius-sm);
    font-family: var(--font-display);
    font-weight: 600;
    transition: all var(--duration-fast) ease;
}

body.dark-mode .btn-primary {
    color: #0B0F19; /* Contrast text on Lime button */
}

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

.btn-outline {
    padding: 12px 24px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-family: var(--font-display);
    font-weight: 500;
}

.btn-outline:hover {
    border-color: var(--text-main);
    background-color: var(--bg-surface);
}

/* Header */
.main-header {
    height: var(--header-height);
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 9999; /* Z-Index molto alto per evitare sovrapposizioni */
    display: flex;
    align-items: center;
    background-color: var(--bg-surface); /* Sfondo solido invece di trasparente */
    box-shadow: 0 2px 10px rgba(0,0,0,0.05); /* Ombra per separazione */
    border-bottom: 1px solid var(--border-color);
    transition: all var(--duration-fast) ease;
}

body.dark-mode .main-header {
    background-color: var(--bg-surface);
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

.main-header .container-fluid {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: var(--font-display);
    font-size: 1.5rem;
    font-weight: 400;
    color: var(--text-main);
}

.logo-icon {
    color: var(--accent-color);
    font-size: 1.75rem;
}

.fw-bold { font-weight: 700; }

.nav-wrapper {
    display: flex;
    align-items: center;
    gap: 40px;
}

.main-nav ul {
    display: flex;
    gap: 32px;
}

.main-nav a {
    font-size: 0.95rem;
    font-weight: 500;
    opacity: 0.7;
}

.main-nav a:hover, .main-nav a.active {
    opacity: 1;
    color: var(--accent-color);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

/* Theme Toggle */
.theme-toggle {
    background: transparent;
    border: none;
    color: var(--text-main);
    font-size: 1.25rem;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: background-color 0.3s;
}

.theme-toggle:hover {
    background-color: var(--bg-surface);
    color: var(--accent-color);
}

/* Mobile Menu Toggle */
.mobile-menu-toggle {
    display: none;
    flex-direction: column;
    justify-content: center;
    gap: 6px;
    cursor: pointer;
    width: 40px;
    height: 40px;
    background-color: var(--border-color); /* Sfondo per visibilità */
    border-radius: 4px;
    align-items: center;
}

.mobile-menu-toggle .bar {
    height: 3px; /* Più spesse */
    width: 24px;
    background-color: var(--text-main);
    transition: 0.3s;
}

.mobile-menu-toggle:hover {
    background-color: var(--accent-color);
}

.mobile-menu-toggle:hover .bar {
    background-color: white;
}

/* Hero Section */
.hero-section {
    height: 100vh;
    display: flex;
    align-items: center;
    position: relative;
    padding-top: var(--header-height);
    overflow: hidden;
}

.hero-overlay {
    position: absolute;
    top: 0;
    right: 0;
    width: 30%;
    height: 100%;
    background: var(--accent-color);
    opacity: 0.9; /* Colore solido e professionale */
    clip-path: polygon(30% 0%, 100% 0, 100% 100%, 0% 100%);
}

body.dark-mode .hero-overlay {
    background-color: var(--accent-color);
    opacity: 0.15;
}

.hero-content {
    max-width: 900px;
    z-index: 1;
}

.hero-title {
    font-size: clamp(3.5rem, 6vw, 6rem);
    margin-bottom: 24px;
    line-height: 1.05;
}

.hero-subtitle {
    font-size: 1.25rem;
    color: var(--text-muted);
    max-width: 600px;
    margin-bottom: 40px;
}

.scroll-down {
    position: absolute;
    bottom: 40px;
    left: 40px;
    display: flex;
    align-items: center;
    gap: 12px;
    font-family: var(--font-display);
    font-size: 0.875rem;
    writing-mode: vertical-rl;
    transform: rotate(180deg);
}

/* Services Section */
.services-section {
    background-color: var(--bg-surface);
}

.section-header {
    margin-bottom: 80px;
}

.section-title {
    font-size: clamp(2rem, 4vw, 3.5rem);
}

.services-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 2px;
    background-color: var(--border-color); /* Grid effect via gap */
    border: 1px solid var(--border-color);
}

.service-card {
    background-color: var(--bg-surface);
    padding: 40px;
    transition: background-color 0.3s ease;
}

.service-card:hover {
    background-color: var(--bg-body);
}

.service-icon {
    font-size: 2rem;
    color: var(--accent-color);
    margin-bottom: 24px;
}

.service-card h3 {
    font-size: 1.5rem;
    margin-bottom: 16px;
}

.service-card p {
    color: var(--text-muted);
    font-size: 0.95rem;
}

/* Portfolio Section */
.portfolio-grid {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 40px;
}

.project-item {
    grid-column: span 4;
    position: relative;
    cursor: pointer;
}

/* Stile Masonry irregolare */
.project-item:nth-child(2) {
    grid-column: span 8;
}

.project-image {
    position: relative;
    overflow: hidden;
    border-radius: var(--radius-sm);
    aspect-ratio: 4/3;
}

.project-item:nth-child(2) .project-image {
    aspect-ratio: 16/9;
}

.project-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.6s var(--ease-out);
}

.project-item:hover .project-image img {
    transform: scale(1.05);
}

.project-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    padding: 30px;
    background: linear-gradient(to top, rgba(0,0,0,0.8), transparent);
    color: white;
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.4s var(--ease-out);
}

.project-item:hover .project-overlay {
    opacity: 1;
    transform: translateY(0);
}

.project-cat {
    font-family: var(--font-display);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--accent-color);
    display: block;
    margin-bottom: 8px;
}

body.dark-mode .project-cat {
    color: var(--accent-color);
}

.project-overlay h3 {
    font-size: 1.5rem;
    color: white;
}

/* About Section */
.about-section.bg-darker {
    background-color: #111; /* Always dark for dramatic effect */
    color: white;
}

body.light-mode .about-section.bg-darker {
    background-color: #1a1a1a;
}

.about-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 80px;
    align-items: center;
}

.about-content h2 {
    color: white;
}

.about-content .lead {
    font-size: 1.5rem;
    font-weight: 300;
    margin-bottom: 32px;
    color: #e5e5e5;
}

.about-content p {
    color: #a3a3a3;
    margin-bottom: 24px;
}

.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 40px;
    margin-top: 40px;
    padding-top: 40px;
    border-top: 1px solid rgba(255,255,255,0.1);
}

.stat-number {
    display: block;
    font-family: var(--font-display);
    font-size: 3rem;
    font-weight: 700;
    color: var(--accent-color);
    line-height: 1;
    margin-bottom: 8px;
}

.stat-label {
    font-size: 0.875rem;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.about-image-wrapper {
    position: relative;
}

.about-image-wrapper img {
    border-radius: var(--radius-md);
    filter: grayscale(100%);
    transition: filter 0.5s ease;
}

.about-image-wrapper:hover img {
    filter: grayscale(0%);
}

/* Footer */
.main-footer {
    background-color: var(--bg-body);
    padding: 80px 0 40px;
    border-top: 1px solid var(--border-color);
}

.footer-top {
    display: flex;
    justify-content: space-between;
    margin-bottom: 80px;
}

.footer-brand p {
    color: var(--text-muted);
    margin: 20px 0;
}

.footer-mail {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-main);
    border-bottom: 2px solid var(--accent-color);
    padding-bottom: 4px;
}

.footer-nav {
    display: flex;
    gap: 80px;
}

.footer-nav h4 {
    font-size: 0.875rem;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 24px;
}

.footer-nav ul li {
    margin-bottom: 12px;
}

.footer-nav a {
    font-size: 1.1rem;
    font-weight: 500;
}

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

.footer-bottom {
    display: flex;
    justify-content: space-between;
    padding-top: 40px;
    border-top: 1px solid var(--border-color);
    color: var(--text-muted);
    font-size: 0.875rem;
}

.footer-legal {
    display: flex;
    gap: 24px;
}

/* Mobile Menu Fullscreen Overlay - Global Styles */
.mobile-nav-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    background-color: var(--bg-body);
    z-index: 1001;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.4s var(--ease-out), visibility 0.4s;
}

/* Nascondi di default su desktop per evitare flickering o elementi visibili */
@media (min-width: 769px) {
    .mobile-nav-overlay {
        display: none !important;
    }
}

.mobile-nav-overlay.active {
    opacity: 1;
    visibility: visible;
}

.mobile-nav-overlay ul {
    display: flex;
    flex-direction: column;
    gap: 32px;
    text-align: center;
}

.mobile-nav-overlay a {
    font-family: var(--font-display);
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-main);
}

.mobile-nav-overlay a:hover, .mobile-nav-overlay a.active {
    color: var(--accent-color);
}

.mobile-nav-overlay .btn-outline {
    margin-top: 40px;
    display: inline-block;
    font-size: 1.2rem;
}

/* Responsive */
@media (max-width: 1024px) {
    .portfolio-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .project-item, .project-item:nth-child(2) {
        grid-column: span 1;
    }
    .project-image, .project-item:nth-child(2) .project-image {
        aspect-ratio: 4/3;
    }
}

@media (max-width: 768px) {
    .hero-title {
        font-size: 3rem;
    }
    
    .nav-wrapper .main-nav, 
    .nav-wrapper .btn-outline {
        display: none;
    }

    .mobile-menu-toggle {
        display: flex;
        z-index: 1002;
    }

    .about-grid {
        grid-template-columns: 1fr;
    }
    
    .footer-top {
        flex-direction: column;
        gap: 60px;
    }
    
    .footer-nav {
        flex-direction: column;
        gap: 40px;
    }

    .footer-bottom {
        flex-direction: column;
        gap: 20px;
        text-align: center;
    }

    .footer-legal {
        justify-content: center;
    }
}

/* Alternate Portfolio Layout (Side-by-Side) */
.portfolio-grid-alt {
    display: flex;
    flex-direction: column;
    gap: 120px;
}

.project-item-alt {
    display: flex;
    align-items: center;
    gap: 80px;
}

.project-item-alt:nth-child(even) {
    flex-direction: row-reverse;
}

.project-item-alt .project-image {
    flex: 1;
    aspect-ratio: 4/3;
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: 0 20px 40px rgba(0,0,0,0.1);
}

.project-item-alt .project-content {
    flex: 1;
}

.project-item-alt .project-cat {
    margin-bottom: 16px;
    font-size: 0.875rem;
}

.project-item-alt h3 {
    font-size: 2.5rem;
    margin-bottom: 24px;
    line-height: 1.1;
}

.project-item-alt p {
    color: var(--text-muted);
    font-size: 1.1rem;
    margin-bottom: 32px;
    max-width: 90%;
}

.btn-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-family: var(--font-display);
    font-weight: 600;
    color: var(--accent-color);
    transition: gap 0.3s ease;
}

.btn-link:hover {
    gap: 12px;
}

@media (max-width: 1024px) {
    .project-item-alt {
        gap: 40px;
    }
    
    .project-item-alt h3 {
        font-size: 2rem;
    }
}

@media (max-width: 768px) {
    .portfolio-grid-alt {
        gap: 80px;
    }

    .project-item-alt, 
    .project-item-alt:nth-child(even) {
        flex-direction: column;
        gap: 32px;
    }

    .project-item-alt .project-image {
        width: 100%;
        aspect-ratio: 16/9;
    }

    .project-item-alt p {
        max-width: 100%;
    }
}
