/* ==========================================
   INDEX: 3D PORTFOLIO PREVIEW (INTERACTIVE CAROUSEL)
   ========================================== */

/* Sezione e Titoli Centrati */
.portfolio-preview-section {
    position: relative;
    width: 100%;
    padding: 100px 5%;
    background: radial-gradient(circle at 50% 50%, #0e172a 0%, #04060a 100%);
    box-sizing: border-box;
    overflow: hidden;
    text-align: center;
}

.portfolio-preview-section .section-intro {
    position: relative;
    z-index: 20;
    margin: 0 auto 50px auto;
    max-width: 750px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.portfolio-preview-section .section-intro h2 {
    font-size: 3rem;
    font-weight: 800;
    color: #ffffff;
    margin-bottom: 14px;
    text-align: center;
}

.portfolio-preview-section .section-intro p {
    color: #94a3b8;
    font-size: 1.15rem;
    line-height: 1.6;
    margin: 0 auto;
    text-align: center;
}

/* Container Spaziale 3D */
.screensaver-container {
    position: relative;
    width: 100%;
    max-width: 1250px;
    height: 520px;
    margin: 0 auto;
    perspective: 1200px;
    user-select: none;
    display: flex;
    align-items: center;
    justify-content: center;
}

.floating-cards-wrapper {
    width: 100%;
    height: 100%;
    position: relative;
    transform-style: preserve-3d;
    pointer-events: none;
}

/* Frecce di Navigazione */
.carousel-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 50;
    width: 54px;
    height: 54px;
    border-radius: 50%;
    background: rgba(13, 22, 37, 0.95);
    border: 1.5px solid rgba(0, 223, 216, 0.4);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), background-color 0.3s ease, border-color 0.3s ease;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
}

.carousel-arrow:hover {
    background: rgba(0, 223, 216, 0.25);
    border-color: #00dfd8;
    color: #00dfd8;
    transform: translateY(-50%) scale(1.12);
    box-shadow: 0 0 25px rgba(0, 223, 216, 0.5);
}

.carousel-arrow:active {
    transform: translateY(-50%) scale(0.96);
}

.prev-arrow { left: 10px; }
.next-arrow { right: 10px; }

/* BASE SCHEDE INGRANDITE CON TRANSIZIONI */
.preview-card {
    position: absolute;
    top: 50%;
    left: 50%;
    border-radius: 24px;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-sizing: border-box;
    overflow: hidden;
    /* ✅ Risoluzione box nero su desktop durante le trasformazioni 3D */
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    -webkit-mask-image: -webkit-radial-gradient(white, black);
    will-change: transform, opacity;
    transition: transform 0.8s cubic-bezier(0.25, 1, 0.5, 1),
                opacity 0.8s ease,
                filter 0.8s ease,
                box-shadow 0.8s ease,
                border-color 0.8s ease;
}

/* 1. SCHEDA PROGETTO */
.project-card {
    width: 360px;
    background: rgba(13, 22, 37, 0.85);
    border: 1.5px solid rgba(0, 223, 216, 0.3);
}

.project-card .card-img-wrapper {
    width: 100%;
    height: 200px;
    overflow: hidden;
    position: relative;
}

.project-card .card-img-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.project-card .card-info {
    padding: 22px;
    text-align: left;
}

.project-card .card-client {
    font-family: monospace;
    font-size: 0.85rem;
    font-weight: 700;
    color: #a855f7;
    display: block;
    margin-bottom: 6px;
    letter-spacing: 1px;
}

.project-card h3 {
    color: #ffffff;
    font-size: 1.35rem;
    font-weight: 700;
    margin: 0;
}

/* 2. SCHEDA SERVIZIO EXTRA LARGE */
.service-big-card {
    width: 420px;
    padding: 36px;
    text-align: left;
    background: linear-gradient(135deg, rgba(22, 36, 62, 0.88) 0%, rgba(10, 16, 28, 0.92) 100%);
    border: 1.5px solid rgba(168, 85, 247, 0.4);
}

.service-big-card .service-badge {
    display: inline-block;
    font-family: monospace;
    font-size: 0.8rem;
    font-weight: 800;
    color: #00dfd8;
    background: rgba(0, 223, 216, 0.15);
    padding: 6px 14px;
    border-radius: 20px;
    margin-bottom: 16px;
    letter-spacing: 0.5px;
}

.service-big-card h3 {
    color: #ffffff;
    font-size: 1.6rem;
    font-weight: 800;
    margin: 0 0 12px 0;
    line-height: 1.25;
}

.service-big-card p {
    color: rgba(255, 255, 255, 0.75);
    font-size: 1rem;
    line-height: 1.55;
    margin: 0;
}

/* CLASSI POSIZIONI ORBITA 3D */
.preview-card.pos-0 {
    transform: translate(-50%, -50%) translate3d(0, 0, 220px) scale(1.15);
    opacity: 1;
    filter: brightness(1.25);
    z-index: 30;
    box-shadow: 0 25px 60px rgba(0, 223, 216, 0.45), 0 0 40px rgba(168, 85, 247, 0.35);
    border-color: rgba(0, 223, 216, 0.9);
}

.preview-card.pos-1 {
    transform: translate(-50%, -50%) translate3d(380px, 0, -100px) rotateY(-30deg) scale(0.82);
    opacity: 0.55;
    filter: brightness(0.75);
    z-index: 10;
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.6);
    border-color: rgba(255, 255, 255, 0.15);
}

.preview-card.pos-2 {
    transform: translate(-50%, -50%) translate3d(0, 0, -320px) rotateY(0deg) scale(0.68);
    opacity: 0.25;
    filter: brightness(0.4);
    z-index: 1;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.8);
    border-color: rgba(255, 255, 255, 0.05);
}

.preview-card.pos-3 {
    transform: translate(-50%, -50%) translate3d(-380px, 0, -100px) rotateY(30deg) scale(0.82);
    opacity: 0.55;
    filter: brightness(0.75);
    z-index: 10;
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.6);
    border-color: rgba(255, 255, 255, 0.15);
}

/* Pulsante CTA Fullscreen */
.preview-cta {
    position: relative;
    z-index: 20;
    margin-top: 30px;
    display: flex;
    justify-content: center;
}

.btn-portfolio-3d {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    background: linear-gradient(135deg, #00dfd8 0%, #0077ff 100%);
    color: #04060a;
    font-weight: 800;
    font-size: 1.05rem;
    padding: 18px 40px;
    border-radius: 50px;
    text-decoration: none;
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.3s ease;
    box-shadow: 0 10px 30px rgba(0, 223, 216, 0.35);
}

.btn-portfolio-3d:hover {
    transform: translateY(-4px) scale(1.04);
    box-shadow: 0 18px 45px rgba(0, 223, 216, 0.55);
}

.btn-portfolio-3d svg {
    transition: transform 0.3s ease;
}

.btn-portfolio-3d:hover svg {
    transform: translateX(5px);
}

/* ==========================================
   PORTFOLIO 3D FULLPAGE & GLASS EXPERIENCE
   ========================================== */

body.portfolio-3d-page {
    width: 100%;
    height: 100%;
    height: 100dvh;
    margin: 0;
    padding: 0;
    overflow: hidden;
    background: #05070c;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    font-family: 'Plus Jakarta Sans', sans-serif;
}

/* AURA FLUTTUANTE COLORATA DINAMICA (SFONDO DESKTOP & MOBILE) */
.ambient-aura-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    z-index: 1; /* ✅ Elevato per rimanere sopra il fondo scuro e visibile sotto il vetro */
    overflow: hidden;
    transform: translateZ(0); /* ✅ Accelerazione GPU hardware */
    -webkit-transform: translateZ(0);
}

.aura-blob {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.65;
    will-change: transform;
    animation: floatAura 18s infinite ease-in-out alternate;
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
}

.aura-blob-cyan {
    top: -15%;
    left: -10%;
    width: 55vw;
    height: 55vw;
    background: radial-gradient(circle, rgba(0, 229, 255, 0.65) 0%, rgba(0, 229, 255, 0) 70%);
    animation-duration: 16s;
}

.aura-blob-purple {
    bottom: -15%;
    right: -10%;
    width: 65vw;
    height: 65vw;
    background: radial-gradient(circle, rgba(168, 85, 247, 0.6) 0%, rgba(168, 85, 247, 0) 70%);
    animation-duration: 22s;
    animation-delay: -6s;
}

.aura-blob-blue {
    top: 35%;
    left: 30%;
    width: 45vw;
    height: 45vw;
    background: radial-gradient(circle, rgba(0, 119, 255, 0.5) 0%, rgba(0, 119, 255, 0) 70%);
    animation-duration: 14s;
    animation-delay: -10s;
}

@keyframes floatAura {
    0% {
        transform: translate3d(0, 0, 0) scale(1) rotate(0deg);
    }
    50% {
        transform: translate3d(12%, 15%, 0) scale(1.2) rotate(180deg);
    }
    100% {
        transform: translate3d(-10%, -8%, 0) scale(0.85) rotate(360deg);
    }
}

/* Header Fluttuante */
.portfolio-3d-header {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 24px 5%;
    z-index: 100;
    pointer-events: none;
    box-sizing: border-box;
    background: linear-gradient(180deg, rgba(11, 11, 15, 0.7) 0%, rgba(11, 11, 15, 0) 100%);
}

.portfolio-3d-header a {
    pointer-events: auto;
}

.btn-back-home {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: #ffffff;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9rem;
    padding: 10px 20px;
    border-radius: 30px;
    background: rgba(13, 22, 37, 0.85);
    border: 1px solid rgba(0, 229, 255, 0.3);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    transition: background 0.3s ease, border-color 0.3s ease, color 0.3s ease;
}

.btn-back-home:hover {
    background: rgba(0, 229, 255, 0.2);
    border-color: #00e5ff;
    color: #00e5ff;
}

/* Stage & Canvas Full Screen */
.canvas-3d-wrapper.full-viewport {
    position: absolute;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    z-index: 2;
}

#portfolio-canvas {
    width: 100%;
    height: 100%;
    display: block;
    cursor: grab;
    touch-action: none;
}

#portfolio-canvas:active {
    cursor: grabbing;
}

/* Rullo Mobile Container Desktop Hidden */
#mobile-portfolio-reel {
    display: none;
}

.vignette-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    background: radial-gradient(circle at center, transparent 35%, rgba(5, 7, 12, 0.6) 80%, rgba(5, 7, 12, 0.85) 100%);
    z-index: 3;
}

/* Overlay Controlli e Remash Button */
.stage-controls-overlay {
    position: fixed;
    bottom: 30px;
    left: 0;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    z-index: 10;
    pointer-events: none;
}

.remash-container {
    pointer-events: auto;
}

.remash-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(13, 22, 37, 0.85);
    border: 1px solid rgba(0, 229, 255, 0.4);
    color: #00e5ff;
    padding: 12px 26px;
    border-radius: 40px;
    font-size: 0.85rem;
    font-weight: 800;
    letter-spacing: 1px;
    cursor: pointer;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    transition: background 0.3s ease, transform 0.3s ease, box-shadow 0.3s ease;
    box-shadow: 0 10px 30px rgba(0, 229, 255, 0.15);
}

.remash-btn:hover {
    background: rgba(0, 229, 255, 0.2);
    box-shadow: 0 10px 35px rgba(0, 229, 255, 0.35);
    transform: translateY(-2px);
}

.remash-btn.remashing .remash-icon {
    animation: spin 1s infinite linear;
}

.drag-hint {
    background: rgba(11, 11, 15, 0.75);
    border: 1px solid rgba(255, 255, 255, 0.12);
    padding: 8px 20px;
    border-radius: 20px;
    color: rgba(255, 255, 255, 0.65);
    font-size: 0.8rem;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* ==========================================
   OTTIMIZZAZIONE E RULLO MOBILE SCOMBINATO DINAMICO
   ========================================== */
@media (max-width: 768px) {
    /* ✅ Ottimizzazione Aura su GPU Mobile per renderla perfettamente visibile */
    .aura-blob {
        filter: blur(45px) !important; /* Blur ridotto per essere calcolato dai chip mobile */
        opacity: 0.85 !important; /* Opacità aumentata per penetrare il frosted glass */
    }

    .aura-blob-cyan {
        top: -10%;
        left: -20%;
        width: 85vw;
        height: 85vw;
    }

    .aura-blob-purple {
        bottom: -10%;
        right: -20%;
        width: 90vw;
        height: 90vw;
    }

    .aura-blob-blue {
        top: 30%;
        left: 10%;
        width: 75vw;
        height: 75vw;
    }

    .portfolio-preview-section {
        padding: 70px 4%;
    }

    .portfolio-preview-section .section-intro h2 {
        font-size: 2.2rem;
    }

    .screensaver-container {
        height: 440px;
    }

    .carousel-arrow {
        width: 44px;
        height: 44px;
        backdrop-filter: none !important;
        -webkit-backdrop-filter: none !important;
        background: #0d1625 !important;
    }

    .project-card {
        width: 270px;
    }

    .project-card .card-img-wrapper {
        height: 140px;
    }

    .service-big-card {
        width: 300px;
        padding: 24px;
    }

    .service-big-card h3 {
        font-size: 1.25rem;
    }

    .preview-card {
        backdrop-filter: none !important;
        -webkit-backdrop-filter: none !important;
    }

    .preview-card.pos-0 {
        transform: translate(-50%, -50%) translate3d(0, 0, 140px) scale(1.08);
    }

    .preview-card.pos-1 {
        transform: translate(-50%, -50%) translate3d(180px, 0, -60px) rotateY(-25deg) scale(0.75);
    }

    .preview-card.pos-2 {
        transform: translate(-50%, -50%) translate3d(0, 0, -200px) rotateY(0deg) scale(0.6);
    }

    .preview-card.pos-3 {
        transform: translate(-50%, -50%) translate3d(-180px, 0, -60px) rotateY(25deg) scale(0.75);
    }

    .portfolio-3d-header {
        padding: 16px 4%;
    }

    .vignette-overlay {
        opacity: 0.25;
    }

    /* Nascondi controlli Canvas 3D pesante su mobile */
    #portfolio-canvas,
    .stage-controls-overlay {
        display: none !important;
    }

    /* RULLO SCOMBINATO & AUTOMATICO SU MOBILE */
    #mobile-portfolio-reel {
        display: flex;
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        align-items: center;
        overflow-x: auto;
        padding: 0 15vw;
        box-sizing: border-box;
        gap: 32px;
        perspective: 1000px;
        -webkit-overflow-scrolling: touch;
        z-index: 5;
    }

    #mobile-portfolio-reel::-webkit-scrollbar {
        display: none;
    }

    .mobile-reel-card {
        flex: 0 0 74vw;
        height: 58vh;
        border-radius: 28px;
        /* ✅ Sfondo più trasparente + sfocatura ottimizzata per far trasparire l'Aura Mobile */
        background: rgba(13, 22, 37, 0.45) !important;
        backdrop-filter: blur(14px) !important;
        -webkit-backdrop-filter: blur(14px) !important;
        border: 1.5px solid rgba(0, 229, 255, 0.4);
        box-shadow: 0 20px 45px rgba(0, 0, 0, 0.4), inset 0 0 20px rgba(0, 229, 255, 0.15);
        overflow: hidden;
        position: relative;
        text-decoration: none;
        display: flex;
        flex-direction: column;
        transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), border-color 0.3s ease, box-shadow 0.3s ease;
        will-change: transform;
    }

    /* DISPOSIZIONE ORGANICA E SCOMBINATA PER LE CARD MOBILE */
    .mobile-reel-card:nth-child(4n+1) {
        transform: rotate(-3.5deg) translateY(-14px);
    }

    .mobile-reel-card:nth-child(4n+2) {
        transform: rotate(3deg) translateY(16px);
    }

    .mobile-reel-card:nth-child(4n+3) {
        transform: rotate(-2deg) translateY(6px);
    }

    .mobile-reel-card:nth-child(4n+4) {
        transform: rotate(4deg) translateY(-10px);
    }

    .mobile-reel-card:active {
        transform: scale(0.96) rotate(0deg) translateY(0) !important;
        border-color: #00e5ff;
        box-shadow: 0 15px 35px rgba(0, 229, 255, 0.45);
    }

    .mobile-reel-card .reel-card-img {
        width: 100%;
        height: 60%;
        object-fit: cover;
    }

    .mobile-reel-card .reel-card-info {
        padding: 20px;
        display: flex;
        flex-direction: column;
        justify-content: center;
        height: 40%;
        background: linear-gradient(180deg, rgba(13, 22, 37, 0.2) 0%, rgba(11, 11, 15, 0.85) 100%);
        box-sizing: border-box;
    }

    .mobile-reel-card .reel-card-client {
        font-family: monospace;
        font-size: 0.8rem;
        font-weight: 700;
        color: #00e5ff;
        letter-spacing: 1px;
        margin-bottom: 6px;
        text-transform: uppercase;
    }

    .mobile-reel-card h3 {
        color: #ffffff;
        font-size: 1.35rem;
        font-weight: 800;
        margin: 0 0 8px 0;
        line-height: 1.25;
    }

    .mobile-reel-card .reel-card-category {
        color: rgba(255, 255, 255, 0.65);
        font-size: 0.85rem;
        margin: 0;
    }
}