:root {
    --vh: 1vh;
}

@supports (height: 1dvh) {
    :root {
        --vh: 1dvh;
    }
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
}

body {
    font-family: 'Funnel Display', 'Segoe UI', sans-serif;
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    background-color: black;
    overflow: auto;
}

/* Nascondi scrollbar per tutti i browser */
html {
    scrollbar-width: none;
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
}

body::-webkit-scrollbar {
    display: none;
}

.hero {
    width: 100%;
    height: 100%;
    background: transparent;
    display: flex;
    flex-direction: column;
    position: relative;
    border-bottom-left-radius: 50px;
    border-bottom-right-radius: 50px;
}

.hero-row {
    width: 100%;
    position: relative;
}

.hero-top {
    height: 20%;
    display: flex;
    justify-content: center;
    align-items: center;
}

.hero-bottom {
    height: 80%;
    position: relative;
}

/* Rimuovi completamente l'effetto noise per performance */
/* .hero::before rimossa per ridurre carico CPU */

/* Content Sections */
.content-section {
    width: 100%;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    position: relative;
    overflow: hidden;
}

.section-content {
    max-width: 1200px;
    padding: 0 40px;
    text-align: center;
    z-index: 10;
    position: relative;
}

.section-title {
    font-size: 8vw;
    margin-bottom: 2rem;
    color: rgb(203, 211, 231);
    font-family: 'Funnel Display', sans-serif;
    text-shadow:
        0 0 20px rgba(255, 255, 255, 0.3),
        0 0 40px rgba(255, 255, 255, 0.2),
        0 0 60px rgba(255, 255, 255, 0.1);
}

.section-text {
    font-size: 1.5rem;
    line-height: 1.8;
    color: rgb(184, 192, 211);
    max-width: 800px;
    margin: 0 auto;
    font-family: 'Funnel Display', sans-serif;
}

.section-text p {
    margin-bottom: 1.5rem;
    opacity: 0.9;
}

/* Animazioni per le sezioni dalla about in poi - basate sulla percentuale di scroll */
#about [data-scroll],
#portfolio [data-scroll],
#contact [data-scroll] {
    opacity: 1 !important;
    transform: translateY(0) !important;
}

/* Stato attivo durante lo scroll */
#about [data-scroll].scroll-active,
#portfolio [data-scroll].scroll-active,
#contact [data-scroll].scroll-active {
    transition: opacity 0.6s ease-out, transform 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

/* Effetti speciali per i titoli con underline animato */
.section-title {
    position: relative;
    --underline-width: 0px;
}

.section-title::after {
    content: '';
    position: absolute;
    bottom: -10px;
    left: 50%;
    transform: translateX(-50%);
    width: var(--underline-width);
    height: 2px;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.8), transparent);
    transition: width 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

/* Animazioni Locomotive Scroll - Adattate per scroll nativo (solo per hero) */
[data-scroll]:not(.nav-item):not(#about [data-scroll]):not(#portfolio [data-scroll]):not(#contact [data-scroll]) {
    opacity: 0;
    transition: all 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

/* Classi per Intersection Observer */
[data-scroll].in-view {
    opacity: 1;
    transition: all 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

[data-scroll].out-view {
    opacity: 0;
    transition: all 0.6s cubic-bezier(0.55, 0.085, 0.68, 0.53);
}

/* Fade In Up */
[data-scroll-call="fadeInUp"].in-view {
    opacity: 1 !important;
    transform: translateY(0) !important;
}

[data-scroll-call="fadeInUp"] {
    transform: translateY(50px);
}

[data-scroll-call="fadeInUp"].out-view {
    opacity: 0 !important;
    transform: translateY(50px) !important;
    transition: all 0.4s cubic-bezier(0.55, 0.085, 0.68, 0.53) !important;
}

/* Fade In Left */
[data-scroll-call="fadeInLeft"].in-view {
    opacity: 1 !important;
    transform: translateX(0) !important;
}

[data-scroll-call="fadeInLeft"] {
    transform: translateX(-50px);
}

[data-scroll-call="fadeInLeft"].out-view {
    opacity: 0 !important;
    transform: translateX(-50px) !important;
    transition: all 0.4s cubic-bezier(0.55, 0.085, 0.68, 0.53) !important;
}

/* Fade In Right */
[data-scroll-call="fadeInRight"].in-view {
    opacity: 1 !important;
    transform: translateX(0) !important;
}

[data-scroll-call="fadeInRight"] {
    transform: translateX(50px);
}

[data-scroll-call="fadeInRight"].out-view {
    opacity: 0 !important;
    transform: translateX(50px) !important;
    transition: all 0.4s cubic-bezier(0.55, 0.085, 0.68, 0.53) !important;
}

/* Scale In */
[data-scroll-call="scaleIn"].in-view {
    opacity: 1 !important;
    transform: scale(1) !important;
}

[data-scroll-call="scaleIn"] {
    transform: scale(0.8);
}

[data-scroll-call="scaleIn"].out-view {
    opacity: 0 !important;
    transform: scale(0.8) !important;
    transition: all 0.4s cubic-bezier(0.55, 0.085, 0.68, 0.53) !important;
}

/* Effetti speciali per i titoli */
.section-title {
    position: relative;
}

.section-title::after {
    content: '';
    position: absolute;
    bottom: -10px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.8), transparent);
    transition: width 1s ease;
}

[data-scroll-call="fadeInLeft"].in-view .section-title::after,
[data-scroll-call="fadeInRight"].in-view .section-title::after {
    width: 100px;
}

[data-scroll-call="fadeInLeft"].out-view .section-title::after,
[data-scroll-call="fadeInRight"].out-view .section-title::after {
    width: 0;
}

/* Animazioni per i paragrafi */
.section-text p {
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.8s ease 0.2s;
}

.section-text.in-view p {
    opacity: 0.9;
    transform: translateY(0);
}

.section-text.in-view p:nth-child(2) {
    transition-delay: 0.4s;
}

.section-text.out-view p {
    opacity: 0;
    transform: translateY(20px);
}

.section-text.out-view p:nth-child(2) {
    transition-delay: 0s;
}

/* Responsive adjustments for sections */
@media (max-width: 768px) {

    /* Force viewport constraints */
    html,
    body {
        width: 100vw !important;
        max-width: 100vw !important;
        overflow-x: hidden !important;
        position: relative !important;
    }

    /* Improve touch scrolling */
    body {
        touch-action: pan-y !important;
        -webkit-overflow-scrolling: touch !important;
        overscroll-behavior-y: contain !important;
    }

    .content-section {
        min-height: 90vh !important;
        padding: 2rem 0 !important;
    }

    .section-content {
        padding: 0 15px !important;
        max-width: 95vw !important;
    }

    .section-title {
        font-size: 10vw !important;
        margin-bottom: 1.5rem !important;
        line-height: 1.2 !important;
    }

    .section-text {
        font-size: 1.1rem !important;
        line-height: 1.6 !important;
        max-width: 100% !important;
        margin: 0 auto !important;
    }

    .section-text p {
        margin-bottom: 1rem !important;
        padding: 0.5rem 0 !important;
    }

    /* Ensure paragraph text is visible on mobile */
    .section-text p {
        opacity: 0.9 !important;
        color: rgb(184, 192, 211) !important;
        font-size: 1.1rem !important;
        line-height: 1.6 !important;
        transform: translateY(0) !important;
        margin-bottom: 1rem !important;
        padding: 0.25rem 0 !important;
        text-align: center !important;
    }

    /* Force section animations to be visible on mobile */
    .section-text.in-view p,
    .section-text p {
        opacity: 0.9 !important;
        transform: translateY(0) !important;
        transition: opacity 0.3s ease !important;
    }

    /* ----- Hero mobile: tutto misurato sull'altezza visibile (--vh), niente sovrapposizioni -----
       Fasce verticali: logo in alto · cerchio centrato al 42% · menu centrato tra cerchio e fondo */
    #canvas3d,
    #underwater-canvas,
    #noise-canvas {
        touch-action: none !important;
        pointer-events: none !important;
    }

    #canvas3d {
        inset: 0 !important;
        width: 100% !important;
        height: 100% !important;
        transform: none !important;
    }

    .hero {
        width: 100% !important;
        max-width: 100% !important;
        height: 100% !important;
        overflow: hidden !important;
        position: relative !important;
        box-sizing: border-box !important;
    }

    .hero-top {
        height: calc(var(--vh) * 22) !important;
    }

    .hero-bottom {
        height: calc(var(--vh) * 78) !important;
    }

    /* Cerchio: diametro limitato sia dalla larghezza sia dall'altezza visibile */
    /* Diametro del cerchio e passo del menu, condivisi da cerchio e voci */
    .layer[data-section="hero"] {
        --d: min(60vw, calc(var(--vh) * 32), 340px);
        --step: max(calc(var(--vh) * 6.2), 34px);
    }

    .circle-border {
        width: var(--d) !important;
        height: var(--d) !important;
        position: fixed !important;
        top: calc(var(--vh) * 42) !important;
        left: 50% !important;
        transform: translate(-50%, -50%) !important;
        z-index: 5 !important;
    }

    /* Menu: lista verticale ancorata in basso, passo proporzionale all'altezza visibile */
    .nav-link {
        font-size: min(5.2vw, calc(var(--vh) * 3.2)) !important;
        line-height: 1.2 !important;
        display: inline-block !important;
        /* margine interno ampio: le code delle iniziali in corsivo restano dentro la parola (e nel suo alone) */
        padding: 0.3em 0.7em !important;
        background: transparent !important;
        border-radius: 0 !important;
        backdrop-filter: none !important;
        margin: 0 !important;
        width: auto !important;
        text-align: center !important;
        text-shadow:
            0 0 10px rgba(255, 255, 255, 0.4),
            0 0 20px rgba(255, 255, 255, 0.3),
            0 0 30px rgba(255, 255, 255, 0.2) !important;
    }

    .nav-link .font-luxurious,
    .nav-link .font-instrument,
    .nav-link .font-pixelify {
        font-size: inherit !important;
    }

    .nav-link .font-luxurious {
        font-size: 1.3em !important;
    }

    .corner-tl,
    .corner-tr,
    .corner-bl,
    .corner-br {
        position: absolute !important;
        bottom: auto !important;
        left: 50% !important;
        right: auto !important;
        transform: translate(-50%, -50%) !important;
        z-index: 30 !important;
        text-align: center;
        width: auto !important;
        max-width: 80vw !important;
        padding: 0 !important;
    }

    /* Il gruppo del menu è centrato a metà tra il fondo del cerchio e il fondo della finestra:
       fondo cerchio = 42vh + d/2  →  metà = (42vh + d/2 + 100vh) / 2 = 71vh + d/4 */
    .corner-tl { top: calc(var(--vh) * 71 + var(--d) / 4 - var(--step) * 1.5) !important; }
    .corner-tr { top: calc(var(--vh) * 71 + var(--d) / 4 - var(--step) * 0.5) !important; }
    .corner-bl { top: calc(var(--vh) * 71 + var(--d) / 4 + var(--step) * 0.5) !important; }
    .corner-br { top: calc(var(--vh) * 71 + var(--d) / 4 + var(--step) * 1.5) !important; }

    /* Logo: dentro la fascia alta, mai oltre il cerchio */
    .emanuele-logo {
        top: 0 !important;
        display: flex !important;
        justify-content: center !important;
        align-items: center !important;
        width: 100% !important;
        height: 100% !important;
        padding: calc(var(--vh) * 2) 0 0 !important;
    }

    .emanuele-logo img {
        height: min(calc(var(--vh) * 16), 42vw, 190px) !important;
        max-height: none !important;
        width: auto !important;
        object-fit: contain !important;
    }

    /* Nascondi le lance SVG su mobile */
    .lance-left,
    .lance-right {
        display: none !important;
    }
}

/* Nascondi le lance SVG quando la finestra è verticale (proporzione > 1:1) */
@media (aspect-ratio < 1/1) {

    .lance-left,
    .lance-right {
        display: none !important;
    }
}

.desc {
    position: relative;
    width: 100%;
    height: 100vh;
    background-color: rgb(0, 2, 17)
}

#canvas3d {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10;
    /* Sotto l'overlay ma sopra le stelle */
    will-change: transform;
    /* Ottimizzazione per GPU */
    transform: translateZ(0);
    /* Forza GPU acceleration */
    /* Limita il contenuto alla viewport */
    overflow: hidden;
    clip: rect(0, auto, auto, 0);
    opacity: 1;
    /* Rende il modello 3D visibile */
    border-bottom-left-radius: 50px;
    border-bottom-right-radius: 50px;
}

#underwater-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    z-index: 15;
    /* Sopra il canvas 3D ma sotto il contenuto */
    pointer-events: none;
    /* Non blocca gli eventi del mouse */
    opacity: 1.0;
    mix-blend-mode: screen;
    /* Blend mode migliore per particelle e bolle */
    background: rgba(0, 50, 100, 0.2);
    /* Reintrodotto background leggero per profondità */
    border-bottom-left-radius: 50px;
    border-bottom-right-radius: 50px;
}

#noise-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    z-index: 20;
    /* Sopra tutti gli altri elementi visivi */
    pointer-events: none;
    /* Non blocca gli eventi del mouse */
    mix-blend-mode: overlay;
    /* Mescola con gli altri elementi per effetto disturbo */
    opacity: 0.4;
    /* Ridotta opacità per essere meno intrusivo su mobile */
    border-bottom-left-radius: 50px;
    border-bottom-right-radius: 50px;
}

.nav-item {
    position: absolute;
    z-index: 30;
    pointer-events: auto;
    will-change: transform;
    transform-origin: center center;
    opacity: 1 !important;
}

.nav-link {
    color: rgb(184, 192, 211);
    text-decoration: none;
    font-size: 6vw;
    font-weight: 700;
    letter-spacing: -0.05em;
    text-shadow:
        0 0 10px rgba(255, 255, 255, 0.2),
        0 0 20px rgba(255, 255, 255, 0.2),
        0 0 30px rgba(255, 255, 255, 0.1),
        0 0 40px rgba(255, 255, 255, 0.1),
        0 0 50px rgba(255, 255, 255, 0.1);
}

/* Prime lettere in primo piano */
/* Le iniziali in corsivo restano lettere normali come le altre: niente inline-block né translateZ,
   che su Safari/iPhone le mettevano su un livello a parte, ritagliandone le parti che escono
   dal riquadro della lettera ed escludendole dall'alone della parola. */

.about-a {
    position: relative;
    top: 0em;
}

/* Corner positioning with 3D rotation */
.corner-tl {
    top: calc(var(--vh) * 30);
    left: 20vw;
    transform: perspective(9vw) rotateX(345deg) rotateY(25deg) rotateZ(20deg) translateZ(-50px);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.corner-tl:hover {
    transform: perspective(9vw) rotateX(345deg) rotateY(25deg) rotateZ(20deg) translateZ(-50px) scale(1.1) translate(1vw, calc(var(--vh) * 1));
}

.corner-tr {
    top: calc(var(--vh) * 30);
    right: 20vw;
    transform: perspective(9vw) rotateX(345deg) rotateY(-25deg) rotateZ(340deg) translateZ(-50px);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.corner-tr:hover {
    transform: perspective(9vw) rotateX(345deg) rotateY(-25deg) rotateZ(340deg) translateZ(-50px) scale(1.1) translate(-1vw, calc(var(--vh) * 1));
}

.corner-bl {
    bottom: calc(var(--vh) * 10);
    left: 20vw;
    transform: perspective(9vw) rotateX(15deg) rotateY(25deg) rotateZ(340deg) translateZ(-50px);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.corner-bl:hover {
    transform: perspective(9vw) rotateX(15deg) rotateY(25deg) rotateZ(340deg) translateZ(-50px) scale(1.1) translate(1vw, calc(var(--vh) * -1));
}

.corner-br {
    bottom: calc(var(--vh) * 10);
    right: 20vw;
    transform: perspective(9vw) rotateX(15deg) rotateY(-25deg) rotateZ(20deg) translateZ(-50px);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.corner-br:hover {
    transform: perspective(9vw) rotateX(15deg) rotateY(-25deg) rotateZ(20deg) translateZ(-50px) scale(1.1) translate(-1vw, calc(var(--vh) * -1));
}

.circle-border {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: min(calc(var(--vh) * 50), 50vw);
    height: min(calc(var(--vh) * 50), 50vw);
    border: 1px solid white;
    border-radius: 50%;
    background: transparent;
    /* Inizialmente trasparente */
    z-index: 5;
    /* Sotto il canvas 3D (z-index 10) ma sopra l'hero */
    pointer-events: none;
    box-shadow:
        0 0 10px rgba(255, 255, 255, 0.2),
        0 0 20px rgba(255, 255, 255, 0.2),
        0 0 30px rgba(255, 255, 255, 0.1),
        0 0 40px rgba(255, 255, 255, 0.1),
        0 0 50px rgba(255, 255, 255, 0.1);
    /* Animazione completamente disabilitata per performance */
    will-change: transform, background;
    /* Ottimizzazione per GPU */
    transition: background 0.1s ease;
    /* Transizione rapida per il background */
    opacity: 1;
    /* Rende il circle border visibile */
}

.lance-left {
    position: absolute;
    top: 60%;
    /* Spostato nella seconda riga */
    left: 20vw;
    transform: translate(-50%, -50%) rotate(270deg);
    z-index: 15;
    /* Sotto i nav link ma sopra i canvas */
    pointer-events: none;
}

.lance-left img {
    width: 4vw;
    height: auto;
    max-width: 8vw;
    opacity: 0.7;
    filter: drop-shadow(0 0 10px rgba(255, 255, 255, 0.3));
}

.lance-right {
    position: absolute;
    top: 60%;
    /* Spostato nella seconda riga */
    right: 20vw;
    transform: translate(50%, -50%) scaleX(-1) rotate(270deg);
    z-index: 15;
    /* Sotto i nav link ma sopra i canvas */
    pointer-events: none;
}

.lance-right img {
    width: 4vw;
    height: auto;
    max-width: 8vw;
    opacity: 0.7;
    filter: drop-shadow(0 0 10px rgba(255, 255, 255, 0.3));
}

.emanuele-logo {
    position: relative;
    top: calc(var(--vh) * 6);
    left: 0vw;
    transform: none;
    z-index: 25;
    /* Sopra i canvas ma sotto la navigazione */
    pointer-events: none;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    will-change: transform;
    opacity: 1;
    /* Rende il logo SVG visibile nella prima riga */
}

.emanuele-logo img {
    width: auto;
    height: calc(var(--vh) * 40);
    opacity: 0.8;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.emanuele-logo:hover {
    transform: translate(-50%, -50%) scale(1.1);
}

.emanuele-logo:hover img {
    filter: url(#glow-hover);
}

.hero-content {
    position: relative;
    z-index: 2;
    color: white;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    height: 100%;
    text-align: center;
    padding: 0 20px;
    pointer-events: none;
}

h1 {
    font-size: 4vw;
    margin-bottom: 1rem;
    color: aliceblue;
}

p {
    font-size: 1.5vw;
    max-width: 600px;
    color: aliceblue;
}

/* Luxurious Script font class with nav-link characteristics */
.font-luxurious {
    font-family: 'Luxurious Script', cursive !important;
    color: rgb(203, 211, 231);
    text-decoration: none;
    font-size: 8vw;
    font-weight: 700;
    letter-spacing: -0.25em;
    text-shadow:
        0 0 10px rgba(255, 255, 255, 0.2),
        0 0 20px rgba(255, 255, 255, 0.2),
        0 0 30px rgba(255, 255, 255, 0.1),
        0 0 40px rgba(255, 255, 255, 0.1),
        0 0 50px rgba(255, 255, 255, 0.1);
    transition: none;
    display: inline;
}

/* Instrument Serif font class with nav-link characteristics */
.font-instrument {
    font-family: 'Instrument Serif', serif !important;
    color: rgb(203, 211, 231); /* stesso colore delle lettere in corsivo */
    text-decoration: none;
    font-size: 5vw;
    font-weight: 700;
    letter-spacing: -0.25em;
    text-shadow:
        0 0 10px rgba(255, 255, 255, 0.2),
        0 0 20px rgba(255, 255, 255, 0.2),
        0 0 30px rgba(255, 255, 255, 0.1),
        0 0 40px rgba(255, 255, 255, 0.1),
        0 0 50px rgba(255, 255, 255, 0.1);
    transition: none;
    display: inline;
}

/* Jacquard 12 font class with nav-link characteristics */
.font-pixelify {
    font-family: 'Pixelify Sans', sans-serif !important;
    color: rgb(203, 211, 231); /* stesso colore delle lettere in corsivo */
    text-decoration: none;
    font-size: 6vw;
    font-weight: 700;
    letter-spacing: -0.25em;
    text-shadow:
        0 0 10px rgba(255, 255, 255, 0.2),
        0 0 20px rgba(255, 255, 255, 0.2),
        0 0 30px rgba(255, 255, 255, 0.1),
        0 0 40px rgba(255, 255, 255, 0.1),
        0 0 50px rgba(255, 255, 255, 0.1);
    transition: none;
    display: inline;
}