/**
 * Hero Section Custom Styles
 * Immersive full-viewport experience with elaborate transitions
 */

/* Main hero container */
.hero {
    position: relative;
    min-height: 100vh;
    margin: 80px 0 0 0; /* Aggiunge spazio per l'header */
    background-image: url('https://josettasaffirio.backsoftware.it/public/images/hero-index.jpg');
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #FFFFFF;
    text-align: center;
    animation: heroReveal 1.5s ease-out forwards;
    perspective: 1000px;
    transform-style: preserve-3d;
    overflow: hidden; /* Previene scroll interno */
}

@keyframes heroReveal {
    0% {
        opacity: 0;
        transform: scale(1.05);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

/* Dark overlay with gradient */
.hero::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(circle at center, rgba(0, 0, 0, 0.4) 0%, rgba(0, 0, 0, 0.7) 100%);
    z-index: 1;
    animation: fadeIn 2s ease-out forwards;
}

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

/* Animated vine leaf overlay */
.hero::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: url('https://josettasaffirio.backsoftware.it/public/images/hero-index.jpg');
    background-size: cover;
    background-position: center;
    opacity: 0.15;
    z-index: 0;
    filter: blur(8px) contrast(120%);
    animation: subtleMove 30s infinite alternate ease-in-out;
    transform: translateZ(-10px) scale(1.1);
}

@keyframes subtleMove {
    0% { transform: scale(1.05) translate(-5px, -5px); }
    100% { transform: scale(1.1) translate(5px, 5px); }
}

/* Main content wrapper */
.hero-content {
    width: 100%;
    max-width: 1400px;
    padding: 0 4rem;
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    opacity: 0;
    animation: contentFadeIn 1s ease-out 0.5s forwards;
    text-align: center;
    margin: 0 auto;
}

@keyframes contentFadeIn {
    from { 
        opacity: 0;
        transform: translateY(20px);
    }
    to { 
        opacity: 1;
        transform: translateY(0);
    }
}

/* Title container */
.hero-title {
    margin-bottom: 2rem;
    position: relative;
    width: 100%;
    will-change: transform, opacity;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

/* Decorative line */
.hero-title::before {
    content: '';
    position: absolute;
    top: -40px;
    left: 50%;
    width: 0;
    height: 1px;
    background: linear-gradient(to right, transparent, white, transparent);
    transform: translateX(-50%);
    animation: lineExpand 1.8s cubic-bezier(0.215, 0.61, 0.355, 1) 0.8s forwards;
    will-change: width;
}

@keyframes lineExpand {
    from { width: 0; }
    to { width: 100px; }
}

/* Description container */
.hero-description {
    margin-bottom: 3rem;
    max-width: 700px;
}

/* Main heading - elegant typography */
.hero h1 {
    font-family: var(--font-primary);
    font-size: 4rem;
    font-weight: 600;
    line-height: 1.2;
    margin-bottom: 2rem;
    color: #FFFFFF;
    text-transform: none;
    letter-spacing: -0.5px;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
    opacity: 0;
    transform: translateY(30px);
    animation: titleReveal 1.5s cubic-bezier(0.19, 1, 0.22, 1) 0.4s forwards;
    will-change: transform, opacity;
    text-align: center;
    margin-left: auto;
    margin-right: auto;
    max-width: 90%;
}

@keyframes titleReveal {
    0% {
        opacity: 0;
        transform: translateY(30px);
    }
    20% {
        opacity: 0.4;
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Split text animation effect */
.hero h1 span {
    display: block;
    position: relative;
    overflow: hidden;
    margin-bottom: 0.5rem;
    opacity: 1;
    padding: 0.1rem 0;
}

.hero h1 span::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.7);
    transform: translateY(0);
    will-change: transform;
    z-index: 1;
}

.hero h1 span:nth-child(1)::after {
    animation: revealText 1.2s cubic-bezier(0.645, 0.045, 0.355, 1) 0.4s forwards;
}

.hero h1 span:nth-child(2)::after {
    animation: revealText 1.2s cubic-bezier(0.645, 0.045, 0.355, 1) 0.7s forwards;
}

@keyframes revealText {
    0% { transform: translateY(0); }
    100% { transform: translateY(100%); }
}

/* Description paragraph */
.hero-description {
    position: relative;
    overflow: hidden;
    width: 100%;
    max-width: 800px;
    margin: 0 auto 2rem;
}

.hero-description p {
    font-size: 1.2rem;
    line-height: 1.8;
    color: rgba(255, 255, 255, 0.95);
    font-weight: 300;
    margin: 0 auto;
    text-shadow: 0 1px 5px rgba(0, 0, 0, 0.2);
    opacity: 0;
    transform: translateY(20px);
    animation: descReveal 1.2s ease-out 1.2s forwards;
}

@keyframes descReveal {
    0% {
        opacity: 0;
        transform: translateY(20px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Hero CTA */
.hero-cta {
    margin-top: 2rem;
    text-align: center;
    opacity: 0;
    transform: translateY(20px);
    animation: ctaReveal 1s ease-out 1.6s forwards;
}

@keyframes ctaReveal {
    0% {
        opacity: 0;
        transform: translateY(20px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Button styling */
.hero-button {
    display: inline-block;
    padding: 1.2rem 3rem;
    background-color: rgba(255, 255, 255, 0.05);
    color: #FFFFFF;
    border: 1px solid rgba(255, 255, 255, 0.3);
    font-size: 1rem;
    font-weight: 400;
    transition: all 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    text-decoration: none;
    text-transform: uppercase;
    letter-spacing: 2px;
    position: relative;
    overflow: hidden;
    z-index: 1;
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

.hero-button::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: all 0.6s ease;
    z-index: -1;
}

.hero-button:hover {
    background-color: rgba(255, 255, 255, 0.15);
    transform: translateY(-5px);
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.3);
    letter-spacing: 3px;
}

.hero-button:hover::before {
    left: 100%;
}

/* Welcome area for logged in users */
.hero-welcome {
    text-align: center;
}

/* Welcome message - elegant signature style */
.hero-welcome {
    text-align: center;
    margin-bottom: 1rem;
    opacity: 0;
    transform: translateY(20px);
    animation: welcomeReveal 1s ease-out 1.4s forwards;
}

@keyframes welcomeReveal {
    0% {
        opacity: 0;
        transform: translateY(20px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

.hero-welcome p {
    font-family: 'Playfair Display', serif;
    font-style: italic;
    font-size: 1.2rem; /* Ridotto da 1.6rem a 1.2rem */
    color: rgba(255, 255, 255, 1);
    margin-bottom: 0;
    font-weight: 300;
    letter-spacing: 0.6px;
    position: relative;
    display: inline-block;
    padding-bottom: 0.6rem;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.hero-welcome p::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 0;
    height: 1px;
    background: linear-gradient(to right, transparent, rgba(255, 255, 255, 0.9), transparent);
    animation: lineGrow 1.5s ease-out 1.8s forwards;
}

@keyframes lineGrow {
    from { width: 0; }
    to { width: 100%; }
}

/* Responsive adjustments */
@media (max-width: 1400px) {
    .hero-content {
        max-width: 1200px;
        padding: 0 3rem;
    }
    
    .hero h1 {
        font-size: 3.5rem;
    }
}

@media (max-width: 1200px) {
    .hero h1 {
        font-size: 3.2rem;
    }
    
    .hero-description p {
        font-size: 1.1rem;
    }
}

@media (max-width: 992px) {
    .hero-content {
        padding: 0 2rem;
    }
    
    .hero h1 {
        font-size: 2.8rem;
    }
    
    .hero-description p {
        font-size: 1rem;
    }
    
    .hero-welcome p {
        font-size: 1.2rem; /* Aggiornato per coerenza */
    }
}

@media (max-width: 768px) {
    /* Fix overflow orizzontale su mobile */
    html, body {
        overflow-x: hidden !important;
        width: 100% !important;
        max-width: 100vw !important;
    }
    
    .hero {
        margin-top: 20px; /* Ridotto da 80px per mobile */
        width: 100% !important;
        max-width: 100vw !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
        padding-left: 0 !important;
        padding-right: 0 !important;
        overflow: hidden !important; /* Blocca completamente lo scroll interno */
        background-attachment: scroll !important; /* Cambiato da fixed per evitare problemi su mobile */
        position: relative;
        left: 0;
        right: 0;
        min-height: auto !important; /* Rimuove min-height fisso per evitare scroll interno */
        height: auto !important; /* Altezza automatica basata sul contenuto */
        max-height: 100vh !important; /* Limita l'altezza massima al viewport */
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
    }
    
    /* Fix per i pseudo-elementi */
    .hero::before,
    .hero::after {
        width: 100% !important;
        max-width: 100vw !important;
        left: 0 !important;
        right: 0 !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
    }
    
    .hero-content {
        width: 100% !important;
        max-width: 100vw !important;
        padding: 1.5rem 1rem !important; /* Padding ridotto per evitare overflow */
        margin-left: 0 !important;
        margin-right: 0 !important;
        box-sizing: border-box;
        overflow: visible !important; /* Il contenuto può essere visibile */
        height: auto !important; /* Altezza automatica */
        max-height: calc(100vh - 60px) !important; /* Limita l'altezza al viewport meno header e margin */
    }
    
    .hero-title,
    .hero-description,
    .hero-cta {
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box;
        overflow: visible !important;
    }
    
    /* Assicura che il contenuto della hero non causi scroll interno */
    .hero h1,
    .hero-description p,
    .hero-button {
        overflow: visible !important;
        max-width: 100% !important;
        word-wrap: break-word;
    }
    
    /* Riduce ulteriormente gli spazi per evitare overflow */
    .hero-description {
        margin-bottom: 1.5rem !important; /* Ridotto da 3rem */
    }
    
    .hero-cta {
        margin-top: 1rem !important; /* Ridotto da 2rem */
    }
    
    /* Titolo mobile - senza animazioni, tutto su una riga */
    .hero h1 {
        font-size: 1.75rem; /* Dimensione appropriata per mobile */
        line-height: 1.4;
        margin-top: 2rem; /* Aggiunge spazio sopra il titolo */
        opacity: 1 !important; /* Rimuove animazione di opacità */
        transform: none !important; /* Rimuove animazione di trasformazione */
        animation: none !important; /* Disabilita tutte le animazioni */
    }
    
    /* Gli span sono inline invece di block per stare sulla stessa riga */
    .hero h1 span {
        display: inline !important; /* Tutto su una riga */
        margin-bottom: 0 !important;
        padding: 0 !important;
    }
    
    /* Aggiunge spazio tra le due parti del titolo */
    .hero h1 span:first-child {
        margin-right: 0.3em; /* Spazio tra le due parti */
    }
    
    /* Rimuove gli effetti ::after delle animazioni su mobile */
    .hero h1 span::after {
        display: none !important; /* Nasconde l'overlay animato */
        animation: none !important;
    }
    
    /* Rimuove la linea decorativa sopra il titolo su mobile */
    .hero-title::before {
        display: none !important;
    }
    
    .hero-title {
        margin-top: 1rem; /* Aggiunge spazio sopra il contenitore del titolo */
    }
    
    .hero-description p {
        font-size: 0.95rem;
        max-width: 100%;
    }
    
    .hero-button {
        padding: 1rem 2.5rem;
        width: 100%;
        text-align: center;
    }
    
    .hero-welcome p {
        font-size: 1.1rem; /* Ridotto proporzionalmente */
    }
}

@media (max-width: 576px) {
    .hero h1 {
        font-size: 1.5rem; /* Ridotto ulteriormente per schermi medi */
        line-height: 1.4;
        margin-top: 1.75rem;
        opacity: 1 !important;
        transform: none !important;
        animation: none !important;
    }
    
    .hero h1 span {
        display: inline !important;
        margin-bottom: 0 !important;
    }
    
    .hero h1 span:first-child {
        margin-right: 0.3em;
    }
    
    .hero h1 span::after {
        display: none !important;
    }
    
    .hero-description p {
        font-size: 0.95rem;
    }
}

@media (max-width: 480px) {
    /* Fix overflow orizzontale per schermi piccoli */
    html, body {
        overflow-x: hidden !important;
        width: 100% !important;
        max-width: 100vw !important;
    }
    
    .hero {
        margin-top: 10px; /* Ancora più ridotto per schermi molto piccoli */
        width: 100% !important;
        max-width: 100vw !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
        padding-left: 0 !important;
        padding-right: 0 !important;
        overflow: hidden !important; /* Blocca completamente lo scroll interno (sia x che y) */
        background-attachment: scroll !important;
        min-height: auto !important; /* Rimuove min-height fisso per evitare scroll interno */
        height: auto !important; /* Altezza automatica basata sul contenuto */
        max-height: 100vh !important; /* Limita l'altezza massima al viewport */
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
    }
    
    .hero::before,
    .hero::after {
        width: 100% !important;
        max-width: 100vw !important;
        left: 0 !important;
        right: 0 !important;
    }
    
    .hero-content {
        width: 100% !important;
        max-width: 100vw !important;
        padding: 1rem !important; /* Padding ridotto per evitare overflow */
        box-sizing: border-box;
        overflow: visible !important;
        height: auto !important;
        max-height: calc(100vh - 50px) !important; /* Limita l'altezza al viewport meno header e margin */
    }
    
    .hero h1 {
        font-size: 1.4rem; /* Dimensione ottimale per schermi piccoli */
        line-height: 1.4;
        margin-top: 1.5rem; /* Spazio sopra il titolo su schermi piccoli */
        opacity: 1 !important;
        transform: none !important;
        animation: none !important;
        max-width: 100% !important;
        word-wrap: break-word;
    }
    
    .hero h1 span {
        display: inline !important;
        margin-bottom: 0 !important;
        max-width: 100% !important;
    }
    
    .hero h1 span:first-child {
        margin-right: 0.3em;
    }
    
    .hero h1 span::after {
        display: none !important;
    }
    
    .hero-title {
        margin-top: 0.75rem; /* Spazio sopra il contenitore del titolo */
        width: 100% !important;
        max-width: 100% !important;
    }
}
