/* IMPOSTAZIONI GENERALI */
:root {
    --paper: #FFFFFF;
    --ink: #222222;
    --ink-soft: #5C6165;
    --accent: #006330;
    --gold: #E6D81D;
    --line: #DCDCDC;
    --navy: #1A253D;
    --bar-gradient: linear-gradient(90deg, var(--gold), var(--accent));
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    background: var(--paper);
    color: var(--ink);
    font-family: 'IBM Plex Sans', sans-serif;
    font-size: 17px;
    line-height: 1.65;
}

.wrap {
    max-width: 820px;
    margin: 0 auto;
    padding: 0 32px;
}

/* Su schermi molto larghi, tutto il sito respira un po' di più invece di
   restare su una colonna stretta al centro: tutte le sezioni condividono
   la stessa colonna larga, così restano allineate tra loro (hero
   compresa); nav e footer sono leggermente più larghi di quella. */
@media screen and (min-width: 1400px) {
    .wrap {
        max-width: 1100px;
    }

    nav .wrap,
    footer .wrap {
        max-width: 1250px;
    }
}

/* TIPOGRAFIA */
    h1, h2 {
        font-family: 'Space Grotesk', sans-serif;
        font-weight: 100;
        margin: 0;
        color: var(--ink);
    }

    a {
        color: var(--accent);
    }

    .eyebrow {
        font-family: 'IBM Plex Sans', sans-serif;
        font-weight: 600;
        font-size: 15px;
        letter-spacing: .08em;
        text-transform: uppercase;
        color: var(--navy);
    }

/* BARRA DI NAVIGAZIONE */
    .topbar {
        height: 3px;
        background: var(--bar-gradient);
    }

    nav {
        border-bottom: 1px solid var(--line);
        position: relative;
    }

    nav .wrap {
        display: flex;
        align-items: center;
        gap: 26px;
        padding: 20px 32px;
    }

    .brand {
        display: flex;
        align-items: center;
        gap: 10px;
        margin-right: auto;
    }

    .brand img {
        height: 26px;
        width: auto;
        display: block;
    }

    .brand span {
        font-family: 'Space Grotesk', sans-serif;
        font-weight: 700;
        font-size: 15px;
        letter-spacing: .02em;
        color: var(--ink);
    }

    .navlinks {
        display: flex;
        gap: 26px;
        font-size: 14px;
        font-weight: 500;
    }

    .navlinks a {
        color: var(--ink-soft);
        text-decoration: none;
    }

    .navlinks a:hover,
    .navlinks a:focus-visible {
        color: var(--accent);
    }

    .hamburger {
        display: none;
        background: none;
        border: none;
        cursor: pointer;
        padding: 6px;
    }

    .hamburger span {
        display: block;
        width: 22px;
        height: 2px;
        background: var(--navy);
        margin: 5px 0;
    }

    @media screen and (max-width: 680px) {
        .navlinks {
            display: none;
        }

        .hamburger {
            display: block;
        }

        nav.nav-open .navlinks {
            display: flex;
            flex-direction: column;
            gap: 16px;
            position: absolute;
            top: 100%;
            left: 0;
            right: 0;
            background: var(--paper);
            border-bottom: 1px solid var(--line);
            padding: 20px 32px;
            z-index: 5;
        }
    }

    /* SELETTORE LINGUA */
    .lang-switch {
        position: relative;
    }

    .lang-current {
        display: flex;
        align-items: center;
        justify-content: center;
        background: none;
        border: none;
        padding: 0;
        line-height: 0;
        cursor: pointer;
    }

    .lang-current img {
        width: 26px;
        height: auto;
        display: block;
        border-radius: 3px;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
        transition: transform .25s ease;
    }

    .lang-switch.open .lang-current img {
        transform: scale(1.15);
    }

    .lang-menu {
        position: absolute;
        top: calc(100% + 14px);
        left: 50%;
        transform: translateX(-50%);
        display: flex;
        flex-direction: column;
        gap: 10px;
        padding: 10px;
        background: var(--paper);
        border: 1px solid var(--line);
        box-shadow: 0 10px 24px rgba(0, 0, 0, 0.14);
        opacity: 0;
        visibility: hidden;
        transition: opacity .2s ease;
        z-index: 20;
    }

    .lang-switch.open .lang-menu {
        opacity: 1;
        visibility: visible;
    }

    .lang-option {
        display: flex;
        align-items: center;
        gap: 8px;
        background: none;
        border: none;
        padding: 4px;
        text-decoration: none;
        cursor: pointer;
        opacity: 0;
        transform: translateY(-10px);
        transition: opacity .3s ease, transform .3s ease;
    }

    .lang-switch.open .lang-option:nth-child(1) { transition-delay: .04s; }
    .lang-switch.open .lang-option:nth-child(2) { transition-delay: .09s; }
    .lang-switch.open .lang-option:nth-child(3) { transition-delay: .14s; }

    .lang-switch.open .lang-option {
        opacity: 1;
        transform: translateY(0);
    }

    .lang-option img {
        width: 22px;
        height: auto;
        display: block;
        border-radius: 3px;
        transition: transform .15s ease;
    }

    .lang-option:hover,
    .lang-option:focus-visible {
        background: #F5F5F5;
    }

    .lang-option:hover img,
    .lang-option:focus-visible img {
        transform: scale(1.15);
    }

/* HERO */
    .hero {
        padding: 50px 0;
        background: var(--navy);
        min-height: 300px;
        display: flex;
        align-items: center;
    }

    /* .hero è un contenitore flex, quindi .wrap al suo interno è un flex
       item: senza "width: 100%" si restringerebbe al contenuto invece di
       riempire lo spazio fino al proprio max-width, come fa normalmente
       da blocco nelle altre sezioni — disallineandosi da loro. */
    .hero .wrap {
        width: 100%;
    }

    .hero h1 {
        font-size: clamp(28px, 3.6vw, 38px);
        line-height: 1.35;
        max-width: 680px;
        color: var(--gold);
    }

    .hero .sub {
        max-width: 600px;
        margin-top: 30px;
        color: #C9CDD6;
        font-size: 20px;
    }

    .hero-cta {
        display: inline-flex;
        align-items: center;
        gap: 10px;
        margin-top: 25px;
        color: var(--gold);
        font-family: 'IBM Plex Sans', sans-serif;
        font-weight: 500;
        font-size: 15px;
        letter-spacing: .08em;
        text-transform: uppercase;
        text-decoration: none;
        transition: color .2s ease;
    }

    .hero-cta svg {
        width: 17px;
        height: 17px;
        flex-shrink: 0;
    }

    .hero-cta span {
        display: inline-block;
        transition: transform .2s ease;
    }

    .hero-cta-send {
        margin-left: 6px;
        transition: opacity .2s ease;
    }

    .hero-cta:hover,
    .hero-cta:focus-visible {
        color: #F2EC7A;
    }

    .hero-cta:hover span,
    .hero-cta:focus-visible span {
        transform: scale(1.08);
    }

    /* Rincorsa a sinistra, "frenata" con stretch, poi lancio a destra in
       dissolvenza: dà l'idea di una mail che parte. */
    @keyframes mail-send {
        0% {
            transform: translateX(0) scaleX(1);
            opacity: 1;
            animation-timing-function: ease-out;
        }
        25% {
            transform: translateX(-5px) scaleX(1);
            opacity: 1;
            animation-timing-function: ease-out;
        }
        40% {
            transform: translateX(-5px) scaleX(1.3) scaleY(0.82);
            opacity: 1;
            animation-timing-function: ease-in;
        }
        100% {
            transform: translateX(28px) scaleX(1);
            opacity: 0;
        }
    }

    .hero-cta:hover .hero-cta-send,
    .hero-cta:focus-visible .hero-cta-send {
        animation: mail-send .7s forwards;
    }

    /* Su schermi molto larghi la hero può respirare un filo di più. */
    @media screen and (min-width: 1400px) {
        .hero {
            padding: 80px 0;
        }

        .hero h1 {
            font-size: clamp(28px, 3.2vw, 46px);
        }
    }

/* SEZIONI */
    section {
        padding: 36px 0;
        border-top: 3px solid transparent;
        border-image: var(--bar-gradient) 1;
    }

    .section-head {
        margin-bottom: 28px;
    }

/* AMBITI (selettore servizi/partner) */
    .switcher {
        /* Impedisce allo "scroll anchoring" del browser di compensare la
           crescita pilotata dallo scroll spostando lo scrollY da solo:
           qui il cambio di layout è intenzionale, non va corretto. */
        overflow-anchor: none;
    }

    .switcher-stage {
        position: relative;
        aspect-ratio: 16 / 9;
        border: 1px solid var(--line);
    }

    .stage-bg {
        position: absolute;
        inset: 0;
        opacity: 0;
        padding: 16px;
        background-size: contain;
        background-repeat: no-repeat;
        transition: opacity .5s ease;
        pointer-events: none;
    }

    .stage-bg.active {
        opacity: 1;
        pointer-events: auto;
    }

    #bg1 { background-image: url(/images/bg1.jpg); background-position: center; }
    #bg2 { background-image: url(/images/bg2.jpg); background-position: center; }
    #bg3 { background-image: url(/images/bg3.jpg); background-position: center; }
    #bg4 { background-image: url(/images/bg4.png); background-position: center; }

    /* L'immagine grande e la descrizione restano nascoste finché l'utente
       non scorre la pagina fino a raggiungerle, poi spuntano da dietro la
       fila di miniature (che resta sopra, con sfondo opaco a fare da
       "schermo"): l'immagine sale da sotto le miniature, la descrizione
       scende da sopra di esse, entrambe con una dissolvenza. Altezza,
       opacità e posizione sono pilotate direttamente dallo scroll via JS
       (setupSwitcherGrowth in main.js), non da una transizione a tempo:
       per questo qui non c'è "transition" — ogni valore intermedio deve
       corrispondere esattamente alla posizione di scroll dell'utente. */
    .switcher-stage,
    .switcher-text {
        max-height: 0;
        overflow: hidden;
        opacity: 0;
    }

    #thumb1 { background-image: url(/images/thumb1.webp); background-size: cover; background-position: center; }
    #thumb2 { background-image: url(/images/thumb2.jpg); background-size: cover; background-position: center; }
    #thumb3 { background-image: url(/images/thumb3.jpg); background-size: cover; background-position: center; }
    #thumb4 { background-image: url(/images/thumb4.png); background-size: cover; background-position: center; }

    /* La fila di miniature occupa l'85% della larghezza dell'immagine
       grande sopra di essa (che coincide con quella di .switcher), e ogni
       miniatura si scala di conseguenza in proporzione. */
    .switcher-tabs {
        position: relative;
        z-index: 2;
        background: var(--paper);
        width: 85%;
        margin: 24px auto 0;
        display: flex;
        justify-content: center;
        gap: 4%;
        flex-wrap: wrap;
        padding: 0;
    }

    .stab {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 8px;
        flex: 1 1 0;
        min-width: 0;
        max-width: 200px;
        background: none;
        border: none;
        padding: 0;
        cursor: pointer;
    }

    .stab-img {
        width: 100%;
        aspect-ratio: 1 / 1;
        background: #fff;
        border: 2px solid var(--line);
        padding: 14%;
        display: flex;
        align-items: center;
        justify-content: center;
        box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
        filter: grayscale(1);
        opacity: .65;
        transition: border-color .15s ease, filter .2s ease, opacity .2s ease;
    }

    .stab-img svg {
        width: 100%;
        height: 100%;
    }

    .stab:hover .stab-img,
    .stab:focus-visible .stab-img {
        border-color: var(--accent);
    }

    .stab.active .stab-img {
        border-color: var(--accent);
        filter: grayscale(0);
        opacity: 1;
    }

    .stab-label {
        width: 100%;
        font-size: clamp(11px, 1.3vw, 14px);
        color: var(--ink);
        text-align: center;
        line-height: 1.3;
        background: rgba(255, 255, 255, .88);
        padding: 2px 6px;
    }

    .stab.active .stab-label {
        font-weight: 500;
    }

    .switcher-text {
        position: relative;
        margin-top: 26px;
        transition: height .4s ease;
    }

    .spanel {
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        opacity: 0;
        transition: opacity .5s ease;
        pointer-events: none;
    }

    .spanel.active {
        opacity: 1;
        pointer-events: auto;
    }

    .spanel h3 {
        color: var(--accent);
        font-size: 15.5px;
        line-height: 1.6;
        margin: 0 0 14px;
        font-weight: 600;
        margin: 20px 0 10px;
    }

    .spanel p {
        margin: 0;
        color: var(--ink-soft);
        font-size: 15.5px;
        line-height: 1.6;
    }

/* PERCORSO (come lavoriamo) */
    .iter-frame {
        margin-top: 0;
    }

    .iter-thread {
        position: relative;
        height: 1px;
        background: var(--gold);
        display: grid;
        grid-template-columns: 1fr 1fr 1fr;
    }

    .iter-thread .dot {
        width: 8px;
        height: 8px;
        border-radius: 50%;
        background: var(--gold);
        justify-self: start;
        margin: -4px 0 0 32px;
    }

    .iter {
        display: grid;
        grid-template-columns: 1fr 1fr 1fr;
        border-bottom: 1px solid var(--line);
    }

    .step {
        padding: 30px 34px 34px;
        border-right: 1px solid var(--line);
        opacity: 0;
        transform: translateY(10px);
        transition: opacity .9s ease, transform .9s ease;
    }

    .step.visible {
        opacity: 1;
        transform: translateY(0);
    }

    .step:last-child {
        border-right: none;
    }

    .step .label {
        font-family: 'Space Grotesk', sans-serif;
        font-weight: 600;
        font-size: 19px;
        color: var(--accent);
        margin-bottom: 10px;
    }

    .step p {
        margin: 0;
        color: var(--ink-soft);
        font-size: 15.5px;
        line-height: 1.6;
    }

    @media screen and (max-width: 680px) {
        .iter-thread {
            display: none;
        }

        .iter {
            grid-template-columns: 1fr;
        }

        .step {
            border-right: none;
            border-top: 1px solid var(--line);
            padding: 26px 0;
        }

        .step:first-child {
            border-top: none;
        }
    }

/* CHI SIAMO */
    .about h3 {
        font-family: 'IBM Plex Sans', sans-serif;
        font-weight: 600;
        font-size: 15px;
        letter-spacing: .08em;
        text-transform: uppercase;
        color: var(--navy);
        margin: 30px 0 28px;
    }

    .about p {
        color: var(--ink-soft);
        font-size: 15.5px;
        line-height: 1.6;
        margin: 0 0 14px;
    }

    .about p:last-child {
        margin-bottom: 0;
    }

    /* Da usare dentro ai paragrafi per dare risalto a parole o frasi:
       <span class="hl">testo</span> */
    .hl {
        font-weight: 600;
        color: var(--accent);
    }

    /* Comparsa progressiva di titoletti e paragrafi mentre si scorre,
       per dare un po' di movimento a un testo lungo. "position: relative"
       serve anche a farli sempre dipingere sopra allo sfondo decorativo
       della sezione Brasile (vedi .about-brazil-shape più sotto). */
    .about h3,
    .about p {
        position: relative;
        opacity: 0;
        transform: translateY(14px);
        transition: opacity .6s ease, transform .6s ease;
    }

    .about h3.visible,
    .about p.visible {
        opacity: 1;
        transform: translateY(0);
    }

    /* "Un'eredità...": testo su una colonna larga, l'inserto giornale in
       una colonna più stretta a fianco. Su mobile si impila. */
    .about-split {
        display: flex;
        align-items: center;
        gap: 28px;
        margin-bottom: 14px;
    }

    /* Su PC l'inserto giornale è a fianco del testo, non sotto come su
       mobile: lì non crea da solo una pausa visiva prima di "Come
       operiamo", quindi la aggiungiamo con più margine. */
    @media screen and (min-width: 681px) {
        .about-split {
            margin-bottom: 56px;
        }
    }

    .about-split-text {
        flex: 1 1 auto;
        min-width: 0;
    }

    @media screen and (max-width: 680px) {
        .about-split {
            flex-direction: column;
        }
    }

    /* Inserto giornale (placeholder: images/giornale.jpg, da sostituire poi
       con l'articolo vero). Al click si apre ingrandito in sovrimpressione. */
    .clip-trigger {
        display: block;
        flex: 0 0 190px;
        width: 190px;
        margin: 6px 0 0;
        background: none;
        border: none;
        padding: 0;
        cursor: pointer;
        opacity: 0;
        transform: translateY(14px);
        transition: opacity .6s ease, transform .6s ease;
    }

    .clip-trigger.visible {
        opacity: 1;
        transform: translateY(0);
    }

    @media screen and (max-width: 680px) {
        .clip-trigger {
            width: 190px;
        }
    }

    .clip-thumb {
        display: block;
        width: 100%;
        height: auto;
        border: 1px solid var(--line);
        box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
        transition: box-shadow .2s ease, transform .2s ease;
    }

    .clip-trigger:hover .clip-thumb,
    .clip-trigger:focus-visible .clip-thumb {
        box-shadow: 0 10px 22px rgba(0, 0, 0, 0.18);
        transform: scale(1.04);
    }

    /* Intermezzo grafico tra "Come operiamo" e "Il Brasile come piattaforma
       internazionale": sagoma del Brasile (icons/brasil.svg) riempita con
       lo stesso gradiente della topbar. */
    .brazil-mark {
        width: 130px;
        aspect-ratio: 100 / 125;
        margin: 12px auto 30px;
        background: var(--bar-gradient);
        -webkit-mask-image: url(/icons/brasil.svg);
        mask-image: url(/icons/brasil.svg);
        -webkit-mask-repeat: no-repeat;
        mask-repeat: no-repeat;
        -webkit-mask-size: contain;
        mask-size: contain;
        -webkit-mask-position: center;
        mask-position: center;
        opacity: 0;
        transform: translateY(14px);
        transition: opacity .6s ease, transform .6s ease;
    }

    .brazil-mark.visible {
        opacity: 1;
        transform: translateY(0);
    }

    .clip-modal {
        position: fixed;
        inset: 0;
        z-index: 100;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 24px;
        visibility: hidden;
        opacity: 0;
        transition: opacity .25s ease, visibility .25s ease;
    }

    .clip-modal.open {
        visibility: visible;
        opacity: 1;
    }

    .clip-modal-backdrop {
        position: absolute;
        inset: 0;
        background: rgba(26, 37, 61, .75);
    }

    .clip-modal-content {
        position: relative;
        display: inline-block;
        max-width: 90vw;
        max-height: 90vh;
        transform: scale(.94);
        transition: transform .25s ease;
    }

    .clip-modal.open .clip-modal-content {
        transform: scale(1);
    }

    .clip-modal-img {
        display: block;
        max-width: 90vw;
        max-height: 90vh;
        width: auto;
        height: auto;
        box-shadow: 0 30px 70px rgba(0, 0, 0, .4);
    }

    .clip-modal-close {
        position: absolute;
        top: -16px;
        right: -16px;
        width: 34px;
        height: 34px;
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: 50%;
        background: var(--paper);
        border: 1px solid var(--line);
        box-shadow: 0 4px 10px rgba(0, 0, 0, .25);
        font-size: 20px;
        line-height: 1;
        padding: 0;
        cursor: pointer;
        color: var(--ink);
    }

/* CONTATTI */
    .contact-grid {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 40px;
    }

    .contact-block .contact-label {
        font-family: 'IBM Plex Sans', sans-serif;
        font-size: 12px;
        font-weight: 600;
        letter-spacing: .04em;
        text-transform: uppercase;
        color: var(--ink-soft);
        border-left: 2px solid var(--accent);
        padding-left: 9px;
        margin-bottom: 10px;
    }

    .contact-block p {
        margin: 2px 0;
        padding-left: 11px;
        color: var(--ink-soft);
        font-size: 15px;
    }

    .contact-block a {
        text-decoration: none;
    }

    .contact-block a:hover,
    .contact-block a:focus-visible {
        text-decoration: underline;
    }

    @media screen and (max-width: 680px) {
        .contact-grid {
            grid-template-columns: 1fr;
        }
    }

/* FOOTER */
    footer {
        padding: 36px 0;
        background: var(--navy);
        border-top: 3px solid transparent;
        border-image: var(--bar-gradient) 1;
    }

    footer .wrap {
        display: flex;
        justify-content: space-between;
        align-items: baseline;
        flex-wrap: wrap;
        gap: 8px;
        font-size: 12px;
    }

    footer .footer-name,
    footer .footer-cnpj {
        min-width: 0;
        max-width: 100%;
        overflow-wrap: break-word;
    }

    footer .footer-name {
        color: var(--gold);
        font-size: 12.5px;
        font-weight: 500;
    }

    footer .footer-cnpj {
        color: #FFFFFF;
    }
