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

:root {
    /* Colors */
    --primary-color: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #818cf8;
    --secondary-color: #f59e0b;
    --accent-color: #10b981;
    --text-primary: #1f2937;
    --text-secondary: #6b7280;
    --text-light: #9ca3af;
    --bg-primary: #ffffff;
    --bg-secondary: #f9fafb;
    --bg-dark: #111827;
    --bg-card: #ffffff;
    --border-color: #e5e7eb;
    --shadow: 0 10px 25px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    --gradient-primary: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    --gradient-secondary: linear-gradient(135deg, var(--secondary-color) 0%, #f97316 100%);
    --gradient-hero: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    
    /* Typography */
    --font-primary: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
    
    /* Spacing */
    --container-max-width: 1200px;
    --section-padding: 120px 0;
    --header-height: 80px;
    
    /* Transitions */
    --transition-base: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: all 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Dark mode variables */
@media (prefers-color-scheme: dark) {
    :root {
        --text-primary: #f9fafb;
        --text-secondary: #d1d5db;
        --text-light: #9ca3af;
        --bg-primary: #111827;
        --bg-secondary: #1f2937;
        --bg-card: #374151;
        --border-color: #374151;
    }
}

html {
    scroll-behavior: smooth;
    scroll-padding-top: var(--header-height);
    overflow-x: hidden;
}

body {
    font-family: var(--font-primary);
    font-size: 16px;
    line-height: 1.6;
    color: var(--text-primary);
    background-color: var(--bg-primary);
    overflow-x: hidden;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* Container */
.container {
    max-width: var(--container-max-width);
    margin: 0 auto;
    padding: 0 2rem;
}

/* Loading Screen */
.loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    background: var(--gradient-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: opacity 0.5s ease, visibility 0.5s ease;
}

.loading-screen.hidden {
    opacity: 0;
    visibility: hidden;
}

.loader {
    width: 60px;
    height: 60px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Navigation */
.navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border-color);
    z-index: 1000;
    transition: var(--transition-base);
    height: var(--header-height);
    width: 100%;
    max-width: 100vw;
    box-sizing: border-box;
    overflow: hidden; /* Previene overflow orizzontale dell'header */
}

.navbar.scrolled {
    background: rgba(255, 255, 255, 0.98);
    box-shadow: var(--shadow);
}

.nav-container {
    max-width: var(--container-max-width);
    margin: 0 auto;
    padding: 0 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 100%;
    min-width: 0; /* Previene overflow */
    width: 100%;
    box-sizing: border-box;
    overflow: hidden; /* Previene overflow orizzontale */
}

.nav-logo .logo-link {
    text-decoration: none;
    color: var(--text-primary);
}

.logo-text {
    font-family: var(--font-mono);
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--primary-color);
    white-space: nowrap; /* Evita il wrap del logo */
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    display: block;
}

.nav-logo {
    flex-shrink: 1;
    min-width: 0;
    max-width: 70%; /* Non occupa più del 70% dell'header */
}

.nav-menu {
    display: flex;
    align-items: center;
    gap: 2rem;
    flex-shrink: 1;
    min-width: 0;
    overflow: hidden;
}

.nav-toggle {
    flex-shrink: 0; /* Il toggle non si riduce mai */
}

.nav-link {
    text-decoration: none;
    color: var(--text-secondary);
    font-weight: 500;
    position: relative;
    transition: var(--transition-base);
}

.nav-link:hover,
.nav-link.active {
    color: var(--primary-color);
}

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

.nav-link:hover::after,
.nav-link.active::after {
    width: 100%;
}

.nav-toggle {
    display: none;
    flex-direction: column;
    cursor: pointer;
    gap: 4px;
    padding: 8px; /* Area touch più grande */
    border-radius: 4px;
    transition: var(--transition-base);
}

.nav-toggle:hover {
    background: rgba(0, 0, 0, 0.05);
    display: none;
}

.bar {
    width: 25px;
    height: 3px;
    background: var(--text-primary);
    transition: var(--transition-base);
    border-radius: 2px; /* Bordi arrotondati */
    display: block;
}

/* Assicura che le barre siano sempre visibili */
.nav-toggle .bar {
    opacity: 1;
    transform: none;
}

/* Hero Section */
.hero {
    min-height: 100vh;
    display: flex;
    align-items: center;
    position: relative;
    background: var(--gradient-hero);
    overflow: hidden;
    width: 100%;
    max-width: 100vw;
    box-sizing: border-box; /* Include padding nei calcoli width */
}

.hero-background {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0.5;
}

.hero-particles {
    position: absolute;
    width: 100%;
    height: 100%;
}

.hero-content {
    position: relative;
    z-index: 2;
    width: 100%;
    max-width: var(--container-max-width);
    margin: 0 auto;
    padding: 0 2rem;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4rem;
    align-items: center;
}

.hero-text {
    color: white;
}

.hero-title {
    font-size: clamp(2.5rem, 5vw, 4rem);
    font-weight: 700;
    line-height: 1.1;
    margin-bottom: 1.5rem;
}

.title-line {
    display: block;
    font-size: 0.6em;
    font-weight: 400;
    opacity: 0.9;
    margin-bottom: 0.5rem;
    animation: fadeInUp 0.8s ease 0.2s both;
}

.title-name {
    display: block;
    background: linear-gradient(135deg, #fff 0%, #f0f0f0 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: fadeInUp 0.8s ease 0.4s both;
}

.title-role {
    display: block;
    font-size: 0.5em;
    font-weight: 400;
    opacity: 0.8;
    margin-top: 0.5rem;
    animation: fadeInUp 0.8s ease 0.6s both;
}

.hero-description {
    font-size: 1.2rem;
    opacity: 0.9;
    margin-bottom: 2rem;
    line-height: 1.6;
    animation: fadeInUp 0.8s ease 0.8s both;
}

.hero-buttons {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    animation: fadeInUp 0.8s ease 1s both;
}

.hero-image {
    display: flex;
    justify-content: center;
    align-items: center;
}

.hero-card {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 20px;
    padding: 2rem;
    transform: perspective(1000px) rotateY(-10deg) rotateX(5deg);
    transition: var(--transition-slow);
    animation: float 6s ease-in-out infinite;
    max-width: 100%;
    box-sizing: border-box;
    overflow: hidden; /* Previene overflow del contenuto */
}

.hero-card:hover {
    transform: perspective(1000px) rotateY(0deg) rotateX(0deg);
}

.code-snippet {
    background: var(--bg-dark);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: var(--shadow-lg);
}

.code-header {
    background: #2d3748;
    padding: 1rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.code-dots {
    display: flex;
    gap: 0.5rem;
}

.dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
}

.dot.red { background: #ff5f56; }
.dot.yellow { background: #ffbd2e; }
.dot.green { background: #27ca3f; }

.code-title {
    color: #a0aec0;
    font-family: var(--font-mono);
    font-size: 0.9rem;
}

.code-body {
    padding: 1.5rem;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    line-height: 1.6;
    color: #e2e8f0;
    overflow-x: auto;
    max-width: 100%;
    box-sizing: border-box;
}

.code-body pre {
    margin: 0;
    max-width: 100%;
    overflow-x: auto;
}

.code-body code {
    word-wrap: break-word;
    white-space: pre-wrap;
}

/* Gestione versioni codice desktop/mobile */
.code-full {
    display: block; /* Mostra versione completa di default */
}

.code-mobile {
    display: none; /* Nascondi versione mobile di default */
}

.scroll-indicator {
    position: absolute;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    color: rgba(255, 255, 255, 0.7);
    animation: bounce 2s infinite;
}

.scroll-mouse {
    width: 24px;
    height: 40px;
    border: 2px solid currentColor;
    border-radius: 12px;
    position: relative;
}

.scroll-wheel {
    width: 4px;
    height: 8px;
    background: currentColor;
    border-radius: 2px;
    position: absolute;
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
    animation: scroll-wheel 2s infinite;
}

.scroll-text {
    font-size: 0.8rem;
    font-weight: 500;
}

/* Animations */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes float {
    0%, 100% { transform: perspective(1000px) rotateY(-10deg) rotateX(5deg) translateY(0px); }
    50% { transform: perspective(1000px) rotateY(-10deg) rotateX(5deg) translateY(-20px); }
}

@keyframes bounce {
    0%, 20%, 50%, 80%, 100% { transform: translateX(-50%) translateY(0); }
    40% { transform: translateX(-50%) translateY(-10px); }
    60% { transform: translateX(-50%) translateY(-5px); }
}

@keyframes scroll-wheel {
    0% { opacity: 1; transform: translateX(-50%) translateY(0); }
    100% { opacity: 0; transform: translateX(-50%) translateY(16px); }
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.875rem 1.5rem;
    font-size: 1rem;
    font-weight: 500;
    text-decoration: none;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: var(--transition-base);
    position: relative;
    overflow: hidden;
}

.btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s;
}

.btn:hover::before {
    left: 100%;
}

.btn-primary {
    background: var(--gradient-primary);
    color: white;
    box-shadow: 0 4px 14px 0 rgba(99, 102, 241, 0.4);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px 0 rgba(99, 102, 241, 0.5);
}

.btn-outline {
    background: transparent;
    color: white;
    border: 2px solid rgba(255, 255, 255, 0.5);
}

.btn-outline:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: white;
    transform: translateY(-2px);
}

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

.btn-icon {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--primary-color);
    color: white;
    transition: var(--transition-base);
}

.btn-icon:hover {
    transform: scale(1.1);
    background: var(--primary-dark);
}

.btn-full {
    width: 100%;
    justify-content: center;
}

/* Sections */
section {
    padding: var(--section-padding);
}

.section-header {
    text-align: center;
    margin-bottom: 4rem;
}

.section-title {
    font-size: clamp(2rem, 4vw, 3rem);
    font-weight: 700;
    margin-bottom: 1rem;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    position: relative;
}

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

.section-subtitle {
    font-size: 1.2rem;
    color: var(--text-secondary);
    max-width: 600px;
    margin: 0 auto;
}

/* Particles */
.particle {
    position: absolute;
    background: rgba(255, 255, 255, 0.6);
    border-radius: 50%;
    pointer-events: none;
    animation: float-particle linear infinite;
}

.particle::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle, rgba(255,255,255,0.8) 0%, rgba(255,255,255,0.2) 70%, transparent 100%);
    border-radius: 50%;
    animation: pulse-particle 3s ease-in-out infinite;
}

@keyframes float-particle {
    0% {
        transform: translateY(100vh) rotate(0deg);
        opacity: 0;
    }
    10% {
        opacity: 1;
    }
    90% {
        opacity: 1;
    }
    100% {
        transform: translateY(-100px) rotate(360deg);
        opacity: 0;
    }
}

@keyframes pulse-particle {
    0%, 100% {
        transform: scale(1);
        opacity: 0.6;
    }
    50% {
        transform: scale(1.2);
        opacity: 0.9;
    }
}

/* Mobile optimized particles */
@media (max-width: 768px) {
    .hero-background {
        z-index: 1; /* Assicura che sia visibile */
        overflow: visible; /* Non nascondere le particelle */
    }
    
    .hero-particles {
        z-index: 1; /* Assicura che le particelle siano visibili */
        overflow: visible;
    }
    
    .particle {
        background: rgba(255, 255, 255, 0.8) !important; /* Più visibili su mobile */
        animation-duration: 6s !important; /* Animazioni più lente su mobile */
        z-index: 1;
        width: 4px !important; /* Particelle più grandi su mobile */
        height: 4px !important;
    }
    
    .particle::before {
        animation-duration: 4s !important;
        background: radial-gradient(circle, rgba(255,255,255,1) 0%, rgba(255,255,255,0.5) 70%, transparent 100%) !important;
    }
}

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

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

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

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

.stat-item {
    text-align: center;
    padding: 1.5rem;
    background: var(--bg-card);
    border-radius: 12px;
    box-shadow: var(--shadow);
    transition: var(--transition-base);
}

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

.stat-number {
    display: block;
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

.stat-label {
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.skills-container {
    background: var(--bg-card);
    padding: 2rem;
    border-radius: 20px;
    box-shadow: var(--shadow);
}

.skills-title {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 2rem;
    color: var(--text-primary);
}

.skills-grid {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.skill-category h4 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--primary-color);
}

.skill-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.skill-tag {
    padding: 0.5rem 1rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-secondary);
    transition: var(--transition-base);
}

.skill-tag:hover {
    background: var(--primary-color);
    color: white;
    transform: translateY(-2px);
}

/* Services Section */
.services-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(320px, 100%), 1fr));
    gap: 2rem;
}

.service-card {
    background: var(--bg-card);
    padding: 2.5rem 2rem;
    border-radius: 20px;
    box-shadow: var(--shadow);
    text-align: center;
    transition: var(--transition-base);
    border: 1px solid var(--border-color);
    position: relative;
    overflow: hidden;
}

.service-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: var(--gradient-primary);
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 0.3s ease;
}

.service-card:hover::before {
    transform: scaleX(1);
}

.service-card:hover {
    transform: translateY(-10px);
    box-shadow: var(--shadow-lg);
}

.service-icon {
    width: 80px;
    height: 80px;
    margin: 0 auto 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--gradient-primary);
    border-radius: 20px;
    color: white;
    font-size: 2rem;
    transition: var(--transition-base);
}

.service-card:hover .service-icon {
    transform: scale(1.1) rotate(5deg);
}

.service-title {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.service-description {
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 1.5rem;
}

.service-features {
    list-style: none;
    text-align: left;
}

.service-features li {
    padding: 0.5rem 0;
    color: var(--text-secondary);
    position: relative;
    padding-left: 1.5rem;
}

.service-features li::before {
    content: '✓';
    position: absolute;
    left: 0;
    color: var(--accent-color);
    font-weight: bold;
}

/* Portfolio Section */
.portfolio {
    background: var(--bg-secondary);
}

.portfolio-filters {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 3rem;
    flex-wrap: wrap;
}

.filter-btn {
    padding: 0.75rem 1.5rem;
    background: transparent;
    border: 2px solid var(--border-color);
    border-radius: 25px;
    color: var(--text-secondary);
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition-base);
}

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

.portfolio-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(350px, 100%), 1fr));
    gap: 2rem;
}

.portfolio-item {
    background: var(--bg-card);
    border-radius: 20px;
    overflow: hidden;
    box-shadow: var(--shadow);
    transition: var(--transition-slow);
    opacity: 1;
    transform: scale(1);
}

.portfolio-item.hidden {
    opacity: 0;
    transform: scale(0.8);
    pointer-events: none;
}

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

.portfolio-image {
    position: relative;
    height: 250px;
    overflow: hidden;
}

.portfolio-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: var(--transition-base);
}

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

.portfolio-placeholder {
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, var(--bg-secondary) 0%, var(--border-color) 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-light);
    font-size: 3rem;
}

.portfolio-placeholder span {
    font-size: 1rem;
    margin-top: 1rem;
}

.portfolio-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(99, 102, 241, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: var(--transition-base);
}

.portfolio-image:hover .portfolio-overlay {
    opacity: 1;
}

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

.portfolio-content {
    padding: 2rem;
}

.portfolio-title {
    font-size: 1.3rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.portfolio-description {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
    line-height: 1.6;
}

.portfolio-tech {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.tech-tag {
    padding: 0.3rem 0.8rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 15px;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary);
}

/* Contact Section */
.contact-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4rem;
    align-items: start;
}

/* Contact Main Card */
.contact-main-card {
    background: var(--bg-card);
    border-radius: 20px;
    padding: 2.5rem;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
}

.contact-intro {
    text-align: center;
    margin-bottom: 2.5rem;
    padding-bottom: 2rem;
    border-bottom: 1px solid var(--border-color);
}

.contact-intro h3 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.8rem;
}

.contact-intro p {
    color: var(--text-secondary);
    font-size: 1rem;
    line-height: 1.6;
    max-width: 400px;
    margin: 0 auto;
}

.contact-methods {
    margin-bottom: 2.5rem;
}

.contact-method {
    display: flex;
    align-items: center;
    gap: 1.2rem;
    padding: 1rem 0;
    border-bottom: 1px solid rgba(0,0,0,0.05);
}

.contact-method:last-child {
    border-bottom: none;
}

.method-icon {
    width: 45px;
    height: 45px;
    background: var(--gradient-primary);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.1rem;
    flex-shrink: 0;
}

.method-info {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.method-label {
    font-size: 0.85rem;
    color: var(--text-light);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.method-value {
    font-size: 1rem;
    color: var(--text-primary);
    font-weight: 500;
    text-decoration: none;
    transition: var(--transition-base);
}

.method-value:hover {
    color: var(--primary-color);
}

/* Contact CTA Section */
.contact-cta {
    padding: 2rem;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    border-radius: 15px;
    margin-bottom: 2rem;
    text-align: center;
    color: white;
}

.cta-text h4 {
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.cta-text p {
    font-size: 0.9rem;
    opacity: 0.9;
    margin-bottom: 1.5rem;
}

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

.cta-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.8rem 1.2rem;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    text-decoration: none;
    border-radius: 25px;
    font-weight: 500;
    font-size: 0.9rem;
    border: 2px solid rgba(255, 255, 255, 0.3);
    transition: var(--transition-base);
    backdrop-filter: blur(10px);
}

.cta-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.5);
    transform: translateY(-2px);
}

/* Contact Social */
.contact-social {
    text-align: center;
    padding-top: 2rem;
    border-top: 1px solid var(--border-color);
}

.social-label {
    display: block;
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 1rem;
    font-weight: 500;
}

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

.social-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.8rem 1.2rem;
    background: var(--bg-secondary);
    color: var(--text-primary);
    text-decoration: none;
    border-radius: 12px;
    font-weight: 500;
    font-size: 0.9rem;
    transition: var(--transition-base);
    border: 2px solid var(--border-color);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
    flex-shrink: 0;
}

.social-link:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(99, 102, 241, 0.3);
}



/* Contact Form */
.contact-form-container {
    background: var(--bg-card);
    padding: 2.5rem;
    border-radius: 20px;
    box-shadow: var(--shadow);
}

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

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-group label {
    font-weight: 500;
    color: var(--text-primary);
    font-size: 0.95rem;
}

.form-group input,
.form-group textarea {
    padding: 1rem;
    border: 2px solid var(--border-color);
    border-radius: 12px;
    font-size: 1rem;
    font-family: inherit;
    background: var(--bg-primary);
    color: var(--text-primary);
    transition: var(--transition-base);
}

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

.form-group textarea {
    resize: vertical;
    min-height: 120px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.checkbox-label input[type="checkbox"] {
    display: none;
}

.checkmark {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-color);
    border-radius: 4px;
    position: relative;
    transition: var(--transition-base);
    flex-shrink: 0;
    cursor: pointer;
}

.checkmark:hover {
    border-color: var(--primary-color);
}

.checkbox-label input[type="checkbox"]:checked + .checkmark {
    background: var(--primary-color);
    border-color: var(--primary-color);
}

.checkbox-label input[type="checkbox"]:checked + .checkmark::after {
    content: '✓';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-size: 0.8rem;
    font-weight: bold;
}

.checkbox-label input[type="checkbox"]:focus + .checkmark {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

.privacy-link {
    color: var(--primary-color);
    text-decoration: none;
}

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

/* Dark mode styles for checkbox */
@media (prefers-color-scheme: dark) {
    .checkmark {
        border-color: #6b7280;
        background-color: transparent;
    }
    
    .checkmark:hover {
        border-color: #9ca3af;
        background-color: rgba(107, 114, 128, 0.1);
    }
    
    .checkbox-label input[type="checkbox"]:checked + .checkmark {
        background: var(--primary-color);
        border-color: var(--primary-color);
        box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
    }
    
    .checkbox-label input[type="checkbox"]:focus + .checkmark {
        border-color: var(--primary-color);
        box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
    }
    
    .checkbox-label {
        color: var(--text-secondary);
    }
    
    .privacy-link {
        color: #60a5fa;
    }
    
    .privacy-link:hover {
        color: #93c5fd;
    }
}

.form-error {
    color: #ef4444;
    font-size: 0.85rem;
    display: none;
}

.form-error.show {
    display: block;
}

.form-message {
    padding: 1rem;
    border-radius: 12px;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 500;
    margin-top: 1rem;
}

.form-message.success {
    background: #ecfdf5;
    color: #059669;
    border: 1px solid #a7f3d0;
}

.form-message.error {
    background: #fef2f2;
    color: #dc2626;
    border: 1px solid #fecaca;
}

.btn-loading {
    display: none;
}

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

.footer-content {
    display: flex;
    justify-content: space-between;
    align-items: start;
    margin-bottom: 2rem;
}

.footer-left {
    max-width: 400px;
}

.footer-logo {
    margin-bottom: 1rem;
}

.footer-logo .logo-text {
    color: white;
    font-size: 1.8rem;
}

.footer-description {
    color: #9ca3af;
    line-height: 1.6;
}

.footer-links {
    display: flex;
    gap: 2rem;
    flex-wrap: wrap;
}

.footer-link {
    color: #9ca3af;
    text-decoration: none;
    transition: var(--transition-base);
}

.footer-link:hover {
    color: white;
}

.footer-bottom {
    border-top: 1px solid #374151;
    padding-top: 2rem;
    text-align: center;
    color: #9ca3af;
}

.footer-note {
    margin-top: 0.5rem;
    font-size: 0.9rem;
}

/* Modals */
.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(5px);
}

.modal.show {
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s ease;
}

.modal-content {
    background: var(--bg-card);
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    border-radius: 20px;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    animation: slideIn 0.3s ease;
}

.modal-header {
    padding: 2rem 2rem 1rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
}

.modal-close {
    font-size: 2rem;
    color: var(--text-light);
    cursor: pointer;
    transition: var(--transition-base);
}

.modal-close:hover {
    color: var(--text-primary);
}

.modal-body {
    padding: 2rem;
    overflow-y: auto;
    max-height: 60vh;
}

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

.modal-body h4 {
    color: var(--text-primary);
    margin: 1.5rem 0 0.5rem;
}

.modal-body p {
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 1rem;
}

.modal-body ul {
    margin-left: 1.5rem;
    margin-bottom: 1rem;
}

.modal-body li {
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

/* Cookie Banner */
.cookie-banner {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg-card);
    border-top: 1px solid var(--border-color);
    box-shadow: var(--shadow);
    z-index: 1500;
    padding: 1.5rem;
    transform: translateY(100%);
    transition: transform 0.3s ease;
}

.cookie-banner.show {
    transform: translateY(0);
}

.cookie-content {
    max-width: var(--container-max-width);
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 2rem;
    flex-wrap: wrap;
}

.cookie-content p {
    color: var(--text-secondary);
    margin: 0;
    flex: 1;
    min-width: 250px;
}

.cookie-buttons {
    display: flex;
    gap: 1rem;
    align-items: center;
    flex-wrap: wrap;
}

/* Back to Top */
.back-to-top {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 50px;
    height: 50px;
    background: var(--gradient-primary);
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition-base);
    z-index: 1000;
}

.back-to-top.show {
    opacity: 1;
    visibility: visible;
}

.back-to-top:hover {
    transform: translateY(-3px) scale(1.1);
    box-shadow: 0 10px 20px rgba(99, 102, 241, 0.4);
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-50px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* AOS Animations */
[data-aos] {
    opacity: 0;
    transition-property: opacity, transform;
    transition-duration: 0.6s;
    transition-timing-function: ease-out-quart;
    max-width: 100%;
    box-sizing: border-box;
}

[data-aos].aos-animate {
    opacity: 1;
    transform: translate(0) scale(1);
}

[data-aos="fade-up"] {
    transform: translateY(50px);
}

[data-aos="fade-right"] {
    transform: translateX(-50px);
}

[data-aos="fade-left"] {
    transform: translateX(50px);
}

/* Responsive Design */
@media (max-width: 768px) {
    :root {
        --section-padding: 80px 0;
        --header-height: 60px;
    }
    
    .nav-container {
        padding: 0 1rem;
    }
    
    .logo-text {
        font-size: 1.3rem;
    }
    
    .nav-menu {
        position: fixed;
        top: var(--header-height);
        left: -100%;
        width: 100%;
        height: calc(100vh - var(--header-height));
        background: var(--bg-card);
        flex-direction: column;
        justify-content: start;
        padding: 2rem;
        transition: var(--transition-base);
        box-shadow: var(--shadow);
        z-index: 999;
    }
    
    .nav-menu.active {
        left: 0;
    }
    
    .nav-toggle {
        display: flex;
    }
    
    .nav-toggle.active .bar:nth-child(1) {
        transform: rotate(45deg) translate(5px, 5px);
    }
    
    .nav-toggle.active .bar:nth-child(2) {
        opacity: 0;
    }
    
    .nav-toggle.active .bar:nth-child(3) {
        transform: rotate(-45deg) translate(7px, -6px);
    }
    
    .hero-content {
        grid-template-columns: 1fr;
        gap: 2rem;
        text-align: center;
        padding: 0 1rem; /* Riduco padding laterale */
        max-width: 100%;
        box-sizing: border-box;
    }
    
    .hero-text {
        max-width: 100%;
        overflow-wrap: break-word;
        word-wrap: break-word;
        hyphens: auto;
    }
    
    .hero-title {
        word-break: break-word;
        overflow-wrap: break-word;
    }
    
    .hero-description {
        font-size: 1.1rem;
        max-width: 100%;
        overflow-wrap: break-word;
    }
    
    .hero-buttons {
        justify-content: center;
        flex-direction: column;
        align-items: center;
        gap: 0.75rem;
    }
    
    .hero-buttons .btn {
        width: 100%;
        max-width: 280px;
        justify-content: center;
    }
    
    /* Hero image/card ottimizzata per mobile */
    .hero-image {
        order: -1; /* Sposta l'immagine sopra il testo su mobile */
        margin-bottom: 2rem;
    }
    
    .hero-card {
        transform: none !important; /* Rimuovi trasformazioni 3D su mobile */
        animation: none !important; /* Disabilita float animation */
        padding: 1.5rem;
        max-width: 100%;
        margin: 0 auto;
        background: rgba(255, 255, 255, 0.15);
        max-width: 80%;

    }
    
    .code-snippet {
        max-width: 100%;
        border-radius: 8px;
        overflow: hidden;
    }
    
    .code-header {
        padding: 0.75rem 1rem;
        gap: 0.75rem;
    }
    
    .code-title {
        font-size: 0.8rem;
    }
    
    .code-body {
        padding: 1rem;
        font-size: 0.75rem;
        line-height: 1.4;
        max-height: 200px; /* Limita altezza su mobile */
        overflow-y: auto;
    }
    
    .dot {
        width: 10px;
        height: 10px;
    }
    
    .about-content,
    .contact-content {
        grid-template-columns: 1fr;
        gap: 2rem;
    }
    
    .contact-main-card {
        padding: 2rem;
    }
    
    .contact-intro {
        margin-bottom: 2rem;
        padding-bottom: 1.5rem;
    }
    
    .contact-methods {
        margin-bottom: 2rem;
    }
    
    .contact-method {
        padding: 0.8rem 0;
    }
    
    .method-icon {
        width: 40px;
        height: 40px;
        font-size: 1rem;
    }
    
    .cta-buttons {
        flex-direction: column;
        gap: 0.8rem;
    }
    
    .social-links {
        justify-content: center;
    }
    
    .social-link span {
        display: inline;
        white-space: nowrap;
    }
    
    .contact-map {
        margin-top: 1.5rem;
    }
    
    .map-container {
        padding-bottom: 50%; /* Aspect ratio più quadrato su tablet */
        border-radius: 12px;
    }
    
    .location-card {
        margin-top: 1.5rem;
        padding: 1.2rem;
    }
    
    .location-actions {
        flex-direction: column;
        gap: 0.8rem;
    }
    
    .map-marker {
        font-size: 3rem;
    }
    
    .location-info h4 {
        font-size: 1.3rem;
    }
    
    .map-actions {
        flex-direction: column;
        gap: 0.8rem;
    }
    
    .map-btn {
        padding: 0.6rem 1rem;
        font-size: 0.85rem;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .services-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
    
    .portfolio-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
    
    .footer-content {
        flex-direction: column;
        gap: 2rem;
        text-align: center;
    }
    
    .footer-links {
        justify-content: center;
    }
    
    .cookie-content {
        flex-direction: column;
        text-align: center;
    }
}

/* Breakpoint per dispositivi moderni (es. 412px x 915px) */
@media (max-width: 480px) {
    :root {
        --header-height: 55px; /* Header più compatto per mobile */
    }
    
    .container {
        padding: 0 1rem;
    }
    
    .nav-container {
        padding: 0 0.75rem;
        min-height: var(--header-height);
    }
    
    .logo-text {
        font-size: 1.2rem; /* Logo più piccolo */
    }
    
    .nav-toggle {
        width: 30px;
        height: 22px;
        justify-content: space-between;
        display: none;
    }
    
    .bar {
        width: 100%;
        height: 3px;
    }
    
    .nav-menu {
        top: var(--header-height);
        height: calc(100vh - var(--header-height));
        padding: 1.5rem 1rem;
    }
    
    .nav-link {
        font-size: 1.1rem;
        padding: 1rem 0;
        border-bottom: 1px solid var(--border-color);
        width: 100%;
        text-align: center;
    }
    
    .nav-link:last-child {
        border-bottom: none;
    }
    
    .hero-content {
        padding: 0 0.75rem; /* Padding ancora più ridotto */
        max-width: 100vw; /* Non superare mai la larghezza viewport */
        width: 100%;
        box-sizing: border-box;
        overflow: hidden; /* Previeni overflow orizzontale */
    }
    
    .hero-text {
        max-width: 100%;
        min-width: 0; /* Permette shrinking */
        word-break: break-word;
        overflow-wrap: break-word;
        hyphens: auto;
        box-sizing: border-box;
    }
    
    .hero-title {
        font-size: 2rem;
        line-height: 1.2;
        margin-bottom: 1rem;
        max-width: 100%;
        word-break: break-word;
        overflow-wrap: break-word;
    }
    
    .hero-description {
        font-size: 1rem;
        line-height: 1.5;
        margin-bottom: 1.5rem;
        max-width: 100%;
        word-break: break-word;
        overflow-wrap: break-word;
    }
    
    /* Hero buttons responsive */
    .hero-buttons {
        max-width: 100%;
        justify-content: center;
        flex-wrap: wrap;
    }
    
    .hero-buttons .btn {
        max-width: 100%;
        min-width: 120px; /* Minimo per leggibilità */
        word-break: keep-all;
    }
    
    .section-title {
        font-size: 2rem;
    }
    
    .service-card,
    .contact-form-container {
        padding: 1.5rem;
    }
    
    .contact-item {
        padding: 1rem;
        margin-bottom: 1rem;
        gap: 0.8rem;
    }
    
    .contact-item:hover {
        transform: none;
    }
    
    .contact-icon {
        width: 40px;
        height: 40px;
        font-size: 1.1rem;
    }
    
    .contact-details h3 {
        font-size: 1rem;
    }
    
    .contact-details p {
        font-size: 0.9rem;
    }
    
    .contact-social {
        gap: 0.8rem;
        margin-top: 1rem;
    }
    
    .contact-social {
        padding-top: 1.5rem;
    }
    
    .social-label {
        font-size: 0.85rem;
        margin-bottom: 0.8rem;
    }
    
    .social-link {
        padding: 0.6rem 1rem;
        font-size: 0.85rem;
        width: auto;
        height: auto;
        min-height: 40px;
    }
    
    .social-link:hover {
        transform: translateY(-1px);
    }
    
    .contact-map {
        margin-top: 1rem;
    }
    
    .map-container {
        padding-bottom: 60%; /* Aspect ratio mobile friendly */
        border-radius: 10px;
    }
    
    .location-card {
        margin-top: 1rem;
        padding: 1rem;
    }
    
    .location-header {
        gap: 0.8rem;
        margin-bottom: 1rem;
    }
    
    .location-icon {
        width: 40px;
        height: 40px;
        font-size: 1.1rem;
    }
    
    .location-actions {
        flex-direction: column;
        gap: 0.6rem;
    }
    
    .location-btn {
        padding: 0.6rem 0.8rem;
        font-size: 0.8rem;
    }
    
    .map-marker {
        font-size: 2.5rem;
        margin-bottom: 0.8rem;
    }
    
    .marker-pulse {
        width: 60px;
        height: 60px;
    }
    
    .location-info h4 {
        font-size: 1.1rem;
        flex-direction: column;
        gap: 0.2rem;
    }
    
    .location-info p {
        font-size: 0.9rem;
    }
    
    .map-actions {
        flex-direction: column;
        gap: 0.6rem;
        width: 100%;
    }
    
    .map-btn {
        padding: 0.5rem 0.8rem;
        font-size: 0.8rem;
        justify-content: center;
    }
    
    .portfolio-filters {
        gap: 0.5rem;
    }
    
    .filter-btn {
        padding: 0.5rem 1rem;
        font-size: 0.9rem;
    }
    
    .back-to-top {
        bottom: 1rem;
        right: 1rem;
        width: 45px;
        height: 45px;
    }
    
    /* Hero card ultra-compatta per schermi piccoli */
    .hero-card {
        width: 80%;
        padding: 1rem;
        border-radius: 12px;
    }
    
    .code-header {
        padding: 0.5rem 0.75rem;
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
    
    .code-dots {
        gap: 0.3rem;
    }
    
    .dot {
        width: 8px;
        height: 8px;
    }
    
    .code-title {
        font-size: 0.75rem;
        align-self: flex-end;
    }
    
    .code-body {
        padding: 0.75rem;
        font-size: 0.7rem;
        line-height: 1.3;
        max-height: 150px;
    }
    
    /* Scambia versioni codice per mobile */
    .code-full {
        display: none; /* Nascondi versione completa */
    }
    
    .code-mobile {
        display: block; /* Mostra versione semplificata */
    }
    
    .code-body pre {
        white-space: pre-wrap;
        word-break: break-word;
        font-size: 0.7rem;
        line-height: 1.3;
        overflow-x: auto;
        max-width: 100%;
        margin: 0;
    }
    
    .code-body code {
        word-wrap: break-word;
        white-space: pre-wrap;
        font-size: inherit;
    }
}

/* Breakpoint per Samsung S22 Ultra viewport logico (410px-420px) con alta densità */
@media (min-width: 410px) and (max-width: 420px) and (-webkit-min-device-pixel-ratio: 2.5) {
    :root {
        --header-height: 60px; /* Header ottimizzato per S22 Ultra */
    }
    
    body {
        font-size: 17px; /* Font leggermente più grande per alta densità */
    }
    
    .navbar {
        padding: 0;
        box-sizing: border-box;
    }
    
    .nav-container {
        padding: 0 1rem; /* Padding aumentato per touch */
        max-width: 100%;
        box-sizing: border-box;
        flex-shrink: 1;
        min-width: 0;
    }
    
    .nav-logo {
        flex-shrink: 0;
        max-width: 65%;
    }
    
    .logo-text {
        font-size: 1.4rem; /* Logo più grande per alta densità */
        max-width: 100%;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    
    .nav-menu {
        display: none; /* Menu hamburger per questo viewport */
    }
    
    .nav-toggle {
        display: none!important; /* Forza hamburger menu su S22 Ultra */
        width: 36px; /* Toggle più grande per touch */
        height: 26px;
        flex-shrink: 0;
    }
    
    .bar {
        width: 26px;
        height: 3px;
    }
    
    .hero-content {
        padding: 0 1rem;
        max-width: 80vw;
        overflow: hidden;
        box-sizing: border-box;
    }
    
    .hero-text {
        max-width: 80%;
        min-width: 0;
        word-wrap: break-word;
        overflow-wrap: break-word;
    }
    
    .hero-title {
        font-size: 2.5rem; /* Titolo più grande per alta densità */
        line-height: 1.1;
        word-break: break-word;
        overflow-wrap: break-word;
        max-width: 80%;
    }
    
    .hero-description {
        font-size: 1.15rem; /* Descrizione più grande */
        max-width: 80%;
        word-wrap: break-word;
        line-height: 1.5;
    }
    
    /* Hero card ottimizzata per S22 Ultra */
    .hero-image {
        order: -1;
        margin-bottom: 2rem;
    }
    
    .hero-card {
        transform: none !important;
        animation: none !important;
        padding: 2rem;
        max-width: 100%;
        margin: 0 auto;
        background: rgba(255, 255, 255, 0.15);
        border-radius: 16px;
        width: 80%;
    }
    
    .code-header {
        padding: 1rem 1.25rem;
    }
    
    .code-title {
        font-size: 1rem;
    }
    
    .code-body {
        padding: 1.25rem;
        font-size: 0.9rem;
        line-height: 1.5;
        max-height: 250px;
    }
    
    .dot {
        width: 14px;
        height: 14px;
    }
    
    /* Versione mobile del codice anche per S22 Ultra */
    .code-full {
        display: none;
    }
    
    .code-mobile {
        display: block;
    }
    
    .btn {
        padding: 1rem 1.5rem;
        font-size: 1rem;
        min-height: 48px; /* Touch target adeguato */
    }
    
    /* Elementi touch-friendly */
    .nav-link {
        min-height: 44px;
        padding: 1rem;
    }
    
    .contact-icon {
        width: 70px;
        height: 70px;
        font-size: 1.8rem;
    }
    
    .back-to-top {
        width: 55px;
        height: 55px;
        font-size: 1.3rem;
    }
}

/* Breakpoint per dispositivi intermedi (421px-428px) */
@media (min-width: 421px) and (max-width: 428px) {
    :root {
        --header-height: 58px;
    }
    
    .nav-container {
        padding: 0 1rem;
    }
    
    .logo-text {
        font-size: 1.3rem;
    }
    
    .nav-menu {
        gap: 1.5rem;
    }
    
    .nav-link {
        font-size: 0.95rem;
    }
}

/* Breakpoint specifico per dispositivi moderni tipo iPhone 12/13 Pro (390px-409px) */
@media (min-width: 375px) and (max-width: 409px) {
    :root {
        --header-height: 56px;
    }
    
    .nav-container {
        padding: 0 1rem;
    }
    
    .logo-text {
        font-size: 1.25rem;
    }
    
    .nav-toggle {
        width: 32px;
        height: 24px;
        display: none!important; /* Forza hamburger menu su S22 Ultra */
    }
    
    .hero-content {
        padding: 0 1rem;
        max-width: 100vw;
        overflow: hidden;
    }
    
    .hero-text {
        max-width: 100%;
        min-width: 0;
    }
    
    .hero-title {
        font-size: 2.2rem;
        line-height: 1.15;
        word-break: break-word;
        overflow-wrap: break-word;
    }
    
    .hero-description {
        font-size: 1.05rem;
        max-width: 100%;
    }
    
    /* Sezione contatti per dispositivi molto piccoli */
    .contact-item {
        padding: 0.8rem;
        margin-bottom: 0.8rem;
        border-radius: 10px;
    }
    
    .contact-icon {
        width: 35px;
        height: 35px;
        font-size: 1rem;
        border-radius: 10px;
    }
    
    .contact-details h3 {
        font-size: 0.95rem;
        margin-bottom: 0.3rem;
    }
    
    .contact-details p {
        font-size: 0.85rem;
    }
    
    .contact-social {
        padding-top: 1.2rem;
    }
    
    .social-label {
        font-size: 0.8rem;
        margin-bottom: 0.6rem;
    }
    
    .social-link {
        padding: 0.5rem 0.8rem;
        font-size: 0.8rem;
        width: auto;
        height: auto;
        min-height: 35px;
        border-radius: 8px;
    }
    
    .contact-map {
        margin-top: 0.8rem;
    }
    
    .map-container {
        padding-bottom: 65%; /* Aspect ratio per schermi piccoli */
        border-radius: 8px;
    }
}

/* Breakpoint per tablet e desktop con alta risoluzione (esclude smartphone) */
@media screen and (min-width: 800px) and (max-width: 1440px) and (orientation: portrait) and (-webkit-min-device-pixel-ratio: 3) {
    :root {
        --header-height: 70px; /* Header più alto per alta risoluzione */
    }
    
    body {
        font-size: 18px; /* Font base più grande per alta risoluzione */
    }
    
    .navbar {
        padding: 0;
        box-sizing: border-box;
    }
    
    .nav-container {
        padding: 0 2rem; /* Padding maggiore per alta risoluzione */
        max-width: 100%;
        box-sizing: border-box;
    }
    
    .logo-text {
        font-size: 2rem; /* Logo più grande per alta risoluzione */
        max-width: 65%;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    
    .nav-menu {
        gap: 3rem; /* Spazio maggiore tra i link */
    }
    
    .nav-link {
        font-size: 1.2rem; /* Link più grandi */
        padding: 1rem;
        min-height: 44px; /* Touch target più grande */
    }
    
    .nav-toggle {
        display: none; /* Nascondi hamburger su tablet/desktop grandi */
        width: 40px;
        height: 30px;
    }
    
    .bar {
        width: 30px;
        height: 4px;
    }
    
    .hero-content {
        padding: 0 2rem;
        max-width: 100vw;
        overflow: hidden;
        box-sizing: border-box;
        gap: 3rem;
    }
    
    .hero-text {
        max-width: 100%;
        min-width: 0;
    }
    
    .hero-title {
        font-size: 4.5rem; /* Titolo molto più grande */
        line-height: 1.1;
        word-break: break-word;
        overflow-wrap: break-word;
        max-width: 100%;
    }
    
    .hero-description {
        font-size: 1.4rem; /* Descrizione più grande */
        max-width: 100%;
        line-height: 1.6;
    }
    
    .btn {
        padding: 1.2rem 2rem; /* Bottoni più grandi */
        font-size: 1.1rem;
        min-height: 56px; /* Touch target più grande */
    }
    
    .section-title {
        font-size: 3.5rem;
    }
    
    .section-subtitle {
        font-size: 1.3rem;
    }
    
    /* Elementi touch-friendly per alta risoluzione */
    .contact-item {
        padding: 2rem;
        margin-bottom: 2.5rem;
    }
    
    .contact-icon {
        width: 80px;
        height: 80px;
        font-size: 2rem;
    }
    
    .form-group input,
    .form-group textarea {
        padding: 1.5rem;
        font-size: 1.1rem;
        min-height: 56px;
    }
    
    .service-card {
        padding: 3rem 2.5rem;
    }
    
    .service-icon {
        width: 100px;
        height: 100px;
        font-size: 2.5rem;
    }
    
    .back-to-top {
        width: 60px;
        height: 60px;
        font-size: 1.4rem;
    }
    
    /* Code snippet ottimizzato per alta risoluzione */
    .code-body pre {
        display: block !important; /* Mostra codice completo su alta risoluzione */
        font-size: 0.85rem;
        line-height: 1.6;
    }
}

/* Breakpoint intermedio per schermi 376px-480px */
@media (min-width: 376px) and (max-width: 480px) {
    .hero-content {
        padding: 0 0.6rem !important;
        max-width: 100vw !important;
        width: calc(100vw - 1.2rem) !important;
        box-sizing: border-box;
    }
    
    .hero-title {
        font-size: 1.9rem;
        line-height: 1.15;
    }
    
    .hero-description {
        font-size: 0.95rem;
        line-height: 1.45;
    }
    
    .hero-buttons .btn {
        font-size: 0.95rem;
        padding: 0.8rem 1.2rem;
    }
    
    /* Sezione contatti per dispositivi intermedi */
    .contact-item {
        padding: 1rem;
        margin-bottom: 1rem;
        gap: 0.8rem;
    }
    
    .contact-icon {
        width: 40px;
        height: 40px;
        font-size: 1.1rem;
    }
    
    .contact-details h3 {
        font-size: 1rem;
    }
    
    .contact-details p {
        font-size: 0.9rem;
    }
    
    .contact-social {
        padding-top: 1.3rem;
    }
    
    .social-label {
        font-size: 0.85rem;
        margin-bottom: 0.7rem;
    }
    
    .social-link {
        padding: 0.55rem 0.9rem;
        font-size: 0.85rem;
        width: auto;
        height: auto;
        min-height: 38px;
        border-radius: 10px;
    }
    
    .contact-map {
        margin-top: 1rem;
    }
    
    .map-container {
        padding-bottom: 62%; /* Bilanciamento per range intermedio */
        border-radius: 9px;
    }
}

/* Hamburger menu sempre visibile su viewport mobile */
@media screen and (max-width: 768px) {
    .nav-toggle {
        display: none !important; /* Forza hamburger su tutti i mobile */
    }
    
    .nav-menu {
        display: none; /* Nascondi menu desktop su mobile */
    }
}

/* Breakpoint extra piccolo per dispositivi molto stretti */
@media (max-width: 375px) {
    :root {
        --header-height: 50px;
    }
    
    .nav-container {
        padding: 0 0.5rem;
    }
    
    .logo-text {
        font-size: 1.1rem;
    }
    
    .nav-toggle {
        width: 28px;
        height: 20px;
        display: none !important;
    }
    
    .bar {
        height: 2px;
    }
    
    /* Hero ultra-ottimizzato per schermi molto piccoli */
    .hero-content {
        padding: 0 0.5rem !important;
        max-width: 100vw !important;
        width: calc(100vw - 1rem) !important; /* Considera il padding */
        margin: 0 auto;
        box-sizing: border-box;
        overflow: hidden;
    }
    
    .hero-text {
        max-width: 100% !important;
        min-width: 0 !important;
        overflow: hidden;
    }
    
    .hero-title {
        font-size: 1.75rem !important; /* Più piccolo per schermi tiny */
        line-height: 1.1 !important;
        margin-bottom: 0.75rem;
        word-break: break-word;
        overflow-wrap: break-word;
        hyphens: auto;
    }
    
    .hero-description {
        font-size: 0.9rem !important;
        line-height: 1.4 !important;
        margin-bottom: 1rem;
    }
    
    .hero-buttons {
        flex-direction: column;
        align-items: center;
        gap: 0.5rem;
    }
    
    .hero-buttons .btn {
        width: 100% !important;
        max-width: 200px;
        font-size: 0.9rem;
        padding: 0.75rem 1rem;
    }
    
    /* Codice semplificato per schermi piccolissimi */
    .code-full {
        display: none !important;
    }
    
    .code-mobile {
        display: block !important;
    }
    
    .code-body pre {
        font-size: 0.65rem !important;
        line-height: 1.2 !important;
    }
}

/* Regola universale per prevenire overflow orizzontale */
@media (max-width: 480px) {
    * {
        max-width: 100vw !important;
        box-sizing: border-box !important;
    }
    
    body, html {
        overflow-x: hidden !important;
    }
    
    .container {
        max-width: 100% !important;
        padding: 0 0.75rem !important;
    }
    
    /* Forza grid responsive su schermi piccoli */
    .services-grid,
    .portfolio-grid {
        grid-template-columns: 1fr !important;
        gap: 1rem !important;
    }
}