/* Reset e Stili Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

:root {
    --primary-color: #667eea;
    --secondary-color: #764ba2;
    --text-color: #333;
    --light-bg: #f7fafc;
    --white: #ffffff;
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    --transition: all 0.3s ease;
}

html {
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%; /* Previeni auto-zoom testo su iOS */
}

html, body {
    height: 100%;
    overflow-x: hidden; /* Previeni scroll orizzontale */
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: var(--text-color);
    background-color: var(--white);
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Header e Navbar */
.header {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    padding: 1rem 0;
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 100;
    width: 100%;
}

.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
    width: 100%;
}

.navbar .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    position: relative;
}

.navbar-brand h1 {
    font-size: 1.8rem;
    font-weight: bold;
}

.navbar-brand a {
    color: white;
    text-decoration: none;
    transition: var(--transition);
}

.navbar-brand a:hover {
    opacity: 0.8;
}

.navbar-menu {
    display: flex;
    list-style: none;
    gap: 2rem;
}

.navbar-menu a {
    color: white;
    text-decoration: none;
    font-weight: 500;
    transition: var(--transition);
    border-bottom: 2px solid transparent;
    padding-bottom: 5px;
}

.navbar-menu a:hover {
    border-bottom-color: white;
}

/* Hero Section */
.hero {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    padding: 8rem 0;
    text-align: center;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.hero-content h1 {
    font-size: 3.5rem;
    margin-bottom: 1rem;
    animation: slideInDown 0.8s ease;
}

.hero-content p {
    font-size: 1.3rem;
    margin-bottom: 2rem;
    animation: slideInUp 0.8s ease;
}

.btn {
    display: inline-block;
    padding: 12px 30px;
    background-color: white;
    color: var(--primary-color);
    text-decoration: none;
    border-radius: 5px;
    font-weight: bold;
    transition: var(--transition);
    border: 2px solid white;
    cursor: pointer;
    font-size: 1rem;
    touch-action: manipulation; /* Migliora risposta touch */
    -webkit-user-select: none;
    user-select: none;
}

.btn:active {
    transform: scale(0.98);
}

.btn:hover {
    background-color: transparent;
    color: white;
}

.btn-secondary {
    background-color: var(--secondary-color);
    color: white;
    border-color: var(--secondary-color);
}

.btn-secondary:hover {
    background-color: white;
    color: var(--secondary-color);
}

/* Main Content */
main {
    flex: 1;
}

section {
    padding: 4rem 0;
}

section h2 {
    font-size: 2.5rem;
    margin-bottom: 3rem;
    text-align: center;
    color: var(--primary-color);
}

/* About Section */
.about-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 3rem;
    align-items: center;
}

.about-text h3 {
    font-size: 1.8rem;
    margin-bottom: 1rem;
    color: var(--primary-color);
}

.about-text p {
    margin-bottom: 1rem;
    line-height: 1.8;
}

.skills {
    margin-top: 2rem;
}

.skill {
    margin-bottom: 1.5rem;
}

.skill-name {
    font-weight: bold;
    margin-bottom: 0.5rem;
}

.skill-bar {
    background-color: var(--light-bg);
    height: 10px;
    border-radius: 5px;
    overflow: hidden;
}

.skill-progress {
    background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
    height: 100%;
    border-radius: 5px;
}

.about-image {
    text-align: center;
}

.about-image img {
    max-width: 100%;
    height: auto;
    border-radius: 10px;
    box-shadow: var(--shadow);
    display: block;
    margin: 0 auto;
}

/* Ottimizzazione immagini */
img {
    max-width: 100%;
    height: auto;
    display: block;
}

/* Portfolio Section */
.portfolio-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
}

.portfolio-item {
    background-color: var(--white);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: var(--shadow);
    transition: var(--transition);
    cursor: pointer;
}

.portfolio-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 12px rgba(0, 0, 0, 0.15);
}

.portfolio-image {
    width: 100%;
    height: 200px;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
}

.portfolio-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.portfolio-item:hover .portfolio-image img {
    transform: scale(1.05);
}

.portfolio-content {
    padding: 1.5rem;
}

.portfolio-content h3 {
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

.portfolio-content p {
    color: #666;
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

.portfolio-tags {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.tag {
    display: inline-block;
    background-color: var(--light-bg);
    color: var(--primary-color);
    padding: 0.3rem 0.8rem;
    border-radius: 20px;
    font-size: 0.8rem;
}

/* Contact Section */
.contact-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 3rem;
    max-width: 900px;
    margin: 0 auto;
}

.contact-info {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.contact-item {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
}

.contact-item-icon {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.2rem;
    flex-shrink: 0;
}

.contact-item-content h3 {
    color: var(--primary-color);
    margin-bottom: 0.3rem;
}

.contact-item-content p {
    color: #666;
}

.contact-form {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.form-group {
    display: flex;
    flex-direction: column;
}

.form-group label {
    margin-bottom: 0.5rem;
    font-weight: bold;
    color: var(--primary-color);
}

.form-group input,
.form-group textarea {
    padding: 0.8rem;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-family: inherit;
    font-size: 1rem;
    transition: var(--transition);
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.form-group textarea {
    resize: vertical;
    min-height: 120px;
}

.form-group button {
    align-self: flex-start;
}

/* Footer */
.footer {
    background-color: #2d3748;
    color: white;
    padding: 3rem 0 1rem;
    margin-top: 4rem;
}

.footer-content {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 2rem;
    margin-bottom: 2rem;
}

.footer-section h3 {
    color: var(--primary-color);
    margin-bottom: 1rem;
}

.footer-section ul {
    list-style: none;
}

.footer-section a {
    color: #cbd5e0;
    text-decoration: none;
    transition: var(--transition);
}

.footer-section a:hover {
    color: var(--primary-color);
}

.footer-bottom {
    text-align: center;
    padding-top: 2rem;
    border-top: 1px solid #4a5568;
    color: #cbd5e0;
}

/* Animazioni */
@keyframes slideInDown {
    from {
        opacity: 0;
        transform: translateY(-30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Menu Hamburger (Mobile) */
.hamburger {
    display: none;
    flex-direction: column;
    cursor: pointer;
    padding: 5px;
}

.hamburger span {
    width: 25px;
    height: 3px;
    background-color: white;
    margin: 3px 0;
    transition: var(--transition);
    border-radius: 2px;
}

.hamburger.active span:nth-child(1) {
    transform: rotate(45deg) translate(6px, 6px);
}

.hamburger.active span:nth-child(2) {
    opacity: 0;
}

.hamburger.active span:nth-child(3) {
    transform: rotate(-45deg) translate(6px, -6px);
}

/* Responsive Tablet */
@media (max-width: 992px) {
    .container {
        padding: 0 15px;
    }

    .hero {
        padding: 6rem 0;
        min-height: 80vh;
    }

    .hero-content h1 {
        font-size: 2.5rem;
    }

    .hero-content p {
        font-size: 1.1rem;
    }

    .about-container,
    .contact-container {
        grid-template-columns: 1fr;
        gap: 2rem;
    }

    .portfolio-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    section {
        padding: 3rem 0;
    }
}

/* Responsive Mobile */
@media (max-width: 768px) {
    .navbar-brand h1 {
        font-size: 1.3rem;
    }

    .navbar-brand {
        flex: 1;
    }

    .navbar-menu {
        position: fixed;
        top: 60px;
        left: 0;
        width: 100%;
        height: calc(100vh - 60px);
        background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
        display: flex;
        flex-direction: column;
        justify-content: flex-start;
        align-items: center;
        padding-top: 2rem;
        gap: 0;
        transform: translateX(-100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        z-index: 999;
        overflow-y: auto;
        list-style: none;
    }

    .navbar-menu.active {
        transform: translateX(0);
    }

    .navbar-menu li {
        width: 100%;
        text-align: center;
        padding: 1rem 0;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    }

    .navbar-menu a {
        display: block;
        font-size: 1.2rem;
        color: white;
        text-decoration: none;
        border-bottom: none !important;
        padding: 1rem 0;
    }

    .hamburger {
        display: flex;
        z-index: 1000;
        position: relative;
    }

    .hero {
        padding: 4rem 0;
        min-height: auto;
    }

    .hero-content h1 {
        font-size: 1.8rem;
        margin-bottom: 1rem;
    }

    .hero-content p {
        font-size: 1rem;
        margin-bottom: 1.5rem;
    }

    .btn {
        padding: 10px 20px;
        font-size: 0.9rem;
        display: block;
        margin: 0.5rem auto;
        max-width: 200px;
    }

    section {
        padding: 2.5rem 0;
    }

    section h2 {
        font-size: 1.8rem;
        margin-bottom: 2rem;
    }

    .about-container,
    .contact-container {
        grid-template-columns: 1fr;
        gap: 2rem;
    }

    .about-image {
        order: -1;
    }

    .skills {
        margin-top: 1.5rem;
    }

    .portfolio-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }

    .portfolio-item {
        margin-bottom: 0;
    }

    .portfolio-image {
        height: 150px;
        font-size: 2.5rem;
    }

    .portfolio-content {
        padding: 1rem;
    }

    .portfolio-content h3 {
        font-size: 1.2rem;
    }

    .portfolio-content p {
        font-size: 0.85rem;
    }

    .contact-container {
        gap: 2rem;
    }

    .contact-info {
        gap: 1.5rem;
    }

    .contact-item {
        flex-direction: row;
        align-items: center;
    }

    .contact-item-icon {
        width: 35px;
        height: 35px;
        font-size: 1rem;
    }

    .form-group input,
    .form-group textarea {
        font-size: 16px; /* Previene zoom su iOS */
    }

    .footer {
        padding: 2rem 0 1rem;
    }

    .footer-content {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }

    .footer-section {
        text-align: center;
    }

    .footer-section ul {
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
    }

    .footer-bottom {
        padding-top: 1.5rem;
        font-size: 0.9rem;
    }
}

/* Responsive Mobile Small */
@media (max-width: 480px) {
    .navbar-brand h1 {
        font-size: 1.1rem;
    }

    .hero-content h1 {
        font-size: 1.5rem;
    }

    .hero-content p {
        font-size: 0.9rem;
    }

    section h2 {
        font-size: 1.5rem;
    }

    .portfolio-content h3 {
        font-size: 1.1rem;
    }

    .btn {
        padding: 8px 16px;
        font-size: 0.85rem;
    }

    .skill-name {
        font-size: 0.9rem;
    }

    .tag {
        font-size: 0.75rem;
        padding: 0.2rem 0.6rem;
    }
}

/* Touch Optimization */
@media (hover: none) and (pointer: coarse) {
    .btn,
    .navbar-menu a,
    .portfolio-item {
        -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
    }

    .btn {
        min-height: 44px; /* Area touch minima iOS */
    }

    .navbar-menu a {
        padding: 15px;
    }

    .portfolio-item {
        cursor: pointer;
    }
}

/* Landscape Mobile */
@media (max-width: 768px) and (orientation: landscape) {
    .hero {
        min-height: auto;
        padding: 3rem 0;
    }

    .navbar-menu {
        height: auto;
        max-height: calc(100vh - 60px);
        overflow-y: auto;
    }
}

/* Utilità */
.alert {
    padding: 1rem;
    border-radius: 5px;
    margin-bottom: 1rem;
}

.alert-success {
    background-color: #c6f6d5;
    color: #22543d;
    border: 1px solid #9ae6b4;
}

.alert-error {
    background-color: #fed7d7;
    color: #742a2a;
    border: 1px solid #fc8181;
}
