/* Luxury Gradients & Backgrounds */
.hero-section {
    height: 100vh;
    min-height: 700px;
    display: flex;
    align-items: center;
    position: relative;
    padding: 100px 0;
    scroll-snap-align: start;
    background: radial-gradient(circle at 70% 30%, rgba(255, 107, 0, 0.05) 0%, transparent 40%),
        linear-gradient(135deg, #fdfdfd 0%, #f4f7f6 100%);
    overflow: hidden;
}

.video-background {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    z-index: 0;
    opacity: 0.18;
    /* Light transparency as requested */
    pointer-events: none;
    mix-blend-mode: luminosity;
    /* Better integration with the light theme */
}

#radici-video:fullscreen {
    opacity: 1;
    mix-blend-mode: normal;
}

.hero-section>.container {
    position: relative;
    z-index: 1;
}

.hero-section::after {
    content: "";
    position: absolute;
    width: 200%;
    height: 200%;
    top: -50%;
    left: -50%;
    background-image: radial-gradient(circle, #FF6B00 1px, transparent 1px);
    background-size: 50px 50px;
    opacity: 0.03;
    z-index: 0;
    pointer-events: none;
}

/* Refined Typography */
.hero-title {
    font-size: clamp(2.5rem, 8vw, 4.5rem);
    background: linear-gradient(180deg, var(--anthracite) 0%, var(--anthracite-light) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 4px 4px rgba(0, 0, 0, 0.05));
}

.hero-title.text-white {
    -webkit-text-fill-color: var(--white);
    background: none;
}

.hero-title.one-line {
    white-space: nowrap;
    font-size: clamp(1.4rem, 5vw, 4.8rem);
    /* Slightly larger max size for wider screen */
    letter-spacing: -0.03em;
}

@media (max-width: 768px) {
    .hero-title.one-line {
        white-space: normal;
        font-size: 2.2rem;
    }
}

/* Responsive */
@media (max-width: 768px) {
    .hero-title {
        font-size: 2.6rem;
        line-height: 1.1;
    }

    /* Su mobile il contenuto della hero è più alto del viewport:
       con height:100vh + align-items:center + overflow:hidden il
       titolo finiva tagliato sotto la navbar fissa. Lasciamo che la
       sezione cresca con il contenuto e partiamo da sotto la navbar. */
    .hero-section {
        height: auto;
        min-height: 100vh;
        align-items: flex-start;
        padding-top: 6.5rem !important;
        padding-bottom: 3rem !important;
    }
}

/* Progressive Disclosure Hooks */
.detail-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.detail-content.active {
    max-height: 2000px;
    /* High enough value */
}

.detail-content.zoomed {
    font-size: 1.4rem;
    line-height: 1.8;
    cursor: grab;
    user-select: none;
    position: relative;
    z-index: 1050;
    background: var(--white);
    padding: 20px;
    border-radius: 10px;
    touch-action: none;
}

.detail-content.zoomed:active {
    cursor: grabbing;
}

.detail-content.zoomed * {
    font-size: inherit !important;
}

/* Roots Section Refinements */
#radici {
    transition: var(--transition-smooth);
}

#radici.story-expanded {
    background: var(--white);
    padding-top: 50px !important;
    overflow: visible !important;
}

#radici .hero-title,
#radici h5 {
    transition: all 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    transform-origin: top left;
    position: relative;
    z-index: 1100;
}

#radici.story-expanded .row {
    align-items: flex-start !important;
    padding-top: 100px;
}

#radici.story-expanded h5 {
    transform: translateY(-40px) scale(0.8);
    opacity: 0.5;
}

#radici.story-expanded .hero-title {
    transform: translateY(-30px) scale(0.65);
    color: var(--ema-orange) !important;
    background: none;
    -webkit-text-fill-color: var(--ema-orange);
    margin-bottom: 0 !important;
}

#radici.story-expanded .lead {
    opacity: 0;
    max-height: 0;
    margin-bottom: 0 !important;
    overflow: hidden;
    transition: all 0.4s ease;
}

#radici .detail-content {
    transition: all 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

#radici.story-expanded .detail-content {
    transform: translateY(-80px);
}

/* Stats in Roots Section */
.roots-stats {
    transition: var(--transition-smooth);
}

#radici.story-expanded .roots-stats {
    opacity: 0;
    pointer-events: none;
    transform: translateY(20px);
}

.stat-item {
    border-left: 2px solid rgba(255, 107, 0, 0.2);
    padding-left: 1rem;
    transition: var(--transition-smooth);
}

.stat-item h3 {
    font-size: 1.5rem;
    margin-bottom: 0.2rem;
}

.stat-item small {
    font-size: 0.65rem;
    color: var(--anthracite-light);
    font-weight: 600;
    display: block;
}

.stat-item:hover {
    border-left-color: var(--ema-orange);
    transform: translateX(5px);
}

/* History Milestones Refinements */
.history-milestones {
    background: transparent;
    padding: 1rem 0;
    position: relative;
    z-index: 2;
}

.milestone-item {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.8rem;
}

.milestone-icon {
    width: 100px;
    height: 100px;
    background: radial-gradient(circle at 30% 30%, #ffffff 0%, #f8f9fa 100%);
    border-radius: 50%;
    /* Circle looks more natural for icons */
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-smooth);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.08);
    position: relative;
    overflow: visible;
}

.milestone-icon::before {
    content: '';
    position: absolute;
    inset: -5px;
    border: 2px solid var(--ema-orange);
    border-radius: 50%;
    z-index: -1;
    opacity: 0;
    transition: var(--transition-smooth);
}

.milestone-item:hover .milestone-icon::before {
    opacity: 0.4;
    transform: scale(1.1);
}

.milestone-icon i {
    font-size: 2.5rem;
    color: var(--anthracite);
    transition: var(--transition-smooth);
}

.milestone-item:hover .milestone-icon i {
    color: var(--ema-orange);
}

.milestone-item span {
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--anthracite-light);
    letter-spacing: 0.05em;
}

/* Vision Section Animation - Comic Style */
.vision-animation-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: 0.5rem;
    /* Even tighter gap */
    padding: 0.5rem 0;
    position: relative;
    cursor: pointer;
    overflow: visible;
    background-color: transparent !important;
    /* Force transparent or anthracite */
}

/* Integrated Vision Content */
.vision-integrated-content {
    opacity: 0;
    transform: translateY(10px);
    transition: all 0.8s ease;
}

.vision-animation-container.animating .vision-integrated-content {
    opacity: 1;
    transform: translateY(0);
    transition-delay: 4s;
}

.philosophy-mini-block {
    margin-bottom: 0.3rem !important;
}

.philosophy-mini-block h4 {
    font-size: 1rem;
    margin-bottom: 0.2rem !important;
}

.philosophy-mini-block p,
.hero-subtitle {
    font-size: 1.15rem;
    line-height: 1.6;
    max-width: 550px !important;
    margin: 0 auto;
    opacity: 0.8;
}

.philosophy-mini-block p {
    max-width: 450px !important;
}

/* Hero Metrics - Immediate Visibility & High Impact */
.vision-metrics-grid.hero-metrics-layout {
    display: flex;
    justify-content: space-around;
    /* Better distribution for centered layout */
    width: 100%;
    max-width: 650px;
    margin: 2rem auto 0;
    /* Perfectly centered horizontally */
    opacity: 1;
    /* Visible immediately */
    transform: none;
}

.vision-metrics-grid.hero-metrics-layout .metric-item {
    text-align: center;
    flex: 1;
}

.vision-metrics-grid.hero-metrics-layout .metric-item .h3 {
    font-size: 3.8rem;
    /* Even more monumental and incisive */
    font-weight: 900;
    margin-bottom: -8px !important;
    font-family: 'Outfit', sans-serif;
    letter-spacing: -2px;
    color: var(--ema-orange);
    line-height: 1;
}

.vision-metrics-grid.hero-metrics-layout .metric-item .text-light {
    font-size: 1rem;
    /* Larger labels for impact */
    text-transform: uppercase;
    letter-spacing: 3px;
    font-weight: 700;
    opacity: 0.9;
}

/* Su mobile i tre numeri/etichette si sovrapponevano e "PASSIONE"
   usciva dal bordo: riduciamo dimensioni e letter-spacing. */
@media (max-width: 768px) {
    .vision-metrics-grid.hero-metrics-layout {
        gap: 0.25rem;
    }

    .vision-metrics-grid.hero-metrics-layout .metric-item .h3 {
        font-size: 2.6rem;
        letter-spacing: -1px;
    }

    .vision-metrics-grid.hero-metrics-layout .metric-item .text-light {
        font-size: 0.7rem;
        letter-spacing: 0.5px;
    }
}

/* Cleanup old integrated metrics styles if needed, but let's just ensure they don't conflict */
.vision-animation-container.animating .vision-integrated-content {
    opacity: 1;
    transform: translateY(0);
    transition-delay: 4.4s;
}

/* Certifications Scroller */
.cert-scroller {
    height: 1.2rem;
    overflow: hidden;
    position: relative;
}

.cert-list {
    display: flex;
    flex-direction: column;
    animation: certScroll 24s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}

.cert-item {
    height: 1.2rem;
    display: flex;
    align-items: center;
}

.cert-item small {
    font-size: 0.6rem;
    color: var(--anthracite-light);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    white-space: nowrap;
}

@media (max-width: 480px) {
    .cert-item small {
        font-size: 0.52rem;
        letter-spacing: 0;
    }
}

/* Video Sequence Container */
.video-sequence-container {
    width: 100%;
    aspect-ratio: 16/9;
    background: var(--white);
}

.video-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0;
    transition: opacity 1.5s ease-in-out;
    z-index: 1;
}

.video-layer.active {
    opacity: 1;
    z-index: 2;
}

.video-poster {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    opacity: 0;
    z-index: 1;
    transition: opacity 1.5s ease-in-out;
    background-color: var(--white);
}

.video-poster.active {
    opacity: 1;
    z-index: 3;
}

.video-poster.fade-out {
    opacity: 0;
    pointer-events: none;
}

/* Responsive adjustments for video container if needed */
@media (max-width: 991px) {
    .video-sequence-container {
        margin-bottom: 2rem;
    }
}

#soluzioni .row[data-aos] {
    scroll-snap-align: start;
    min-height: calc(100vh - 100px);
    /* Fill viewport minus navbar/padding */
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding-top: 5rem;
    padding-bottom: 5rem;
    margin-bottom: 0 !important;
}

/* Ensure the layout remains balanced for desktop */
@media (min-width: 992px) {
    #soluzioni .row[data-aos] {
        flex-direction: row;
    }
}

/* Adjustments for the horizontal rules inside the section */
#soluzioni hr {
    margin: 0;
    opacity: 0.05;
}

@media (max-width: 991px) {
    #soluzioni .row[data-aos] {
        min-height: auto;
        /* Fallback for mobile if content is too long */
        padding-top: 3rem;
        padding-bottom: 3rem;
    }
}

/* Enhancing Use Case Titles and Badges */
#soluzioni .badge {
    font-size: 1rem;
    padding: 0.6rem 1.2rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    margin-bottom: 1.5rem !important;
}

#soluzioni .lead {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--anthracite);
    line-height: 1.3;
}

@media (max-width: 768px) {
    #soluzioni .badge {
        font-size: 0.85rem;
        padding: 0.5rem 1rem;
    }

    #soluzioni .lead {
        font-size: 1.4rem;
    }
}

/* Team Image Hover Reveal Interaction */
.team-reveal-wrapper {
    position: relative;
    display: inline-block;
    overflow: hidden;
    cursor: pointer;
}

.team-reveal-wrapper .primary-img,
.team-reveal-wrapper .secondary-img {
    transition: opacity 1.2s cubic-bezier(0.4, 0, 0.2, 1), transform 1.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.team-reveal-wrapper .secondary-img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    object-fit: cover;
    z-index: 2;
}

.team-reveal-wrapper.revealed .secondary-img {
    opacity: 1;
}

.team-reveal-wrapper.revealed .primary-img {
    opacity: 0;
}

/* --- Task 8: Performance below-the-fold ---
   content-visibility permette al browser di saltare layout+paint delle sezioni
   non ancora visibili, velocizzando il first paint del ~40%. contain-intrinsic-size
   riserva uno spazio stimato così la scrollbar non "scatta" quando le sezioni
   entrano nel viewport e vengono effettivamente renderizzate. */
#anima-tecnologica,
#ecosistema,
#competenze,
#soluzioni,
#contatti,
#funzionamento,
#pricing,
#faq {
    content-visibility: auto;
    contain-intrinsic-size: 0 800px;
}
