/*!
 * TECH UI - Elementi Innovativi e Moderni
 * Animazioni, Glassmorphism, Neon Effects, Micro-interactions
 */

/* ============================================
   CSS VARIABLES - Tech UI
   ============================================ */
:root {
    /* Neon colors */
    --neon-violo: #2b015b;
    --neon-violo-glow: rgba(43, 1, 91, 0.6);
    --neon-blu: #023fa0;
    --neon-blu-glow: rgba(2, 63, 160, 0.6);
    --neon-azzurro: #89e6ef;
    --neon-azzurro-glow: rgba(137, 230, 239, 0.6);

    /* Glow intensities */
    --glow-sm: 0 0 10px;
    --glow-md: 0 0 20px;
    --glow-lg: 0 0 40px;
    --glow-xl: 0 0 60px;

    /* Animation timings */
    --anim-fast: 0.3s;
    --anim-normal: 0.5s;
    --anim-slow: 0.8s;
}

/* ============================================
   NEON GLOW EFFECTS
   ============================================ */

.neon-text {
    text-shadow:
        0 0 5px var(--neon-azzurro-glow),
        0 0 10px var(--neon-azzurro-glow),
        0 0 20px var(--neon-azzurro-glow),
        0 0 40px var(--neon-azzurro);
    animation: neon-pulse 2s ease-in-out infinite alternate;
}

.neon-text-viola {
    text-shadow:
        0 0 5px var(--neon-violo-glow),
        0 0 10px var(--neon-violo-glow),
        0 0 20px var(--neon-violo-glow),
        0 0 40px var(--neon-violo);
    animation: neon-pulse 2s ease-in-out infinite alternate;
}

.neon-border {
    border: 2px solid var(--neon-azzurro);
    box-shadow:
        0 0 5px var(--neon-azzurro-glow),
        0 0 10px var(--neon-azzurro-glow),
        inset 0 0 5px var(--neon-azzurro-glow);
    animation: neon-border-pulse 2s ease-in-out infinite alternate;
}

.neon-border-viola {
    border: 2px solid var(--neon-violo);
    box-shadow:
        0 0 5px var(--neon-violo-glow),
        0 0 10px var(--neon-violo-glow),
        inset 0 0 5px var(--neon-violo-glow);
    animation: neon-border-pulse 2s ease-in-out infinite alternate;
}

@keyframes neon-pulse {
    from {
        opacity: 1;
        text-shadow:
            0 0 5px var(--neon-azzurro-glow),
            0 0 10px var(--neon-azzurro-glow),
            0 0 20px var(--neon-azzurro-glow),
            0 0 40px var(--neon-azzurro);
    }
    to {
        opacity: 0.8;
        text-shadow:
            0 0 2px var(--neon-azzurro-glow),
            0 0 5px var(--neon-azzurro-glow),
            0 0 10px var(--neon-azzurro-glow),
            0 0 20px var(--neon-azzurro);
    }
}

@keyframes neon-border-pulse {
    from {
        box-shadow:
            0 0 5px var(--neon-azzurro-glow),
            0 0 10px var(--neon-azzurro-glow),
            inset 0 0 5px var(--neon-azzurro-glow);
    }
    to {
        box-shadow:
            0 0 10px var(--neon-azzurro-glow),
            0 0 20px var(--neon-azzurro-glow),
            inset 0 0 10px var(--neon-azzurro-glow);
    }
}

/* ============================================
   GLASSMORPHISM AVANZATO
   ============================================ */

.glass-card {
    background: rgba(43, 1, 91, 0.15);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    box-shadow:
        0 8px 32px rgba(0, 0, 0, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
    transition: all 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.glass-card:hover {
    background: rgba(43, 1, 91, 0.25);
    border-color: rgba(137, 230, 239, 0.3);
    box-shadow:
        0 12px 48px rgba(0, 0, 0, 0.4),
        inset 0 1px 0 rgba(255, 255, 255, 0.15),
        0 0 30px rgba(137, 230, 239, 0.1);
    transform: translateY(-4px);
}

.glass-card-blu {
    background: rgba(2, 63, 160, 0.15);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    box-shadow:
        0 8px 32px rgba(0, 0, 0, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
    transition: all 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.glass-card-blu:hover {
    background: rgba(2, 63, 160, 0.25);
    border-color: rgba(137, 230, 239, 0.3);
    box-shadow:
        0 12px 48px rgba(0, 0, 0, 0.4),
        inset 0 1px 0 rgba(255, 255, 255, 0.15),
        0 0 30px rgba(137, 230, 239, 0.1);
    transform: translateY(-4px);
}

.glass-button {
    background: linear-gradient(135deg, rgba(43, 1, 91, 0.8), rgba(2, 63, 160, 0.8));
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    color: #fff;
    padding: 12px 28px;
    font-weight: 600;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.glass-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: left 0.5s ease;
}

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

.glass-button:hover {
    background: linear-gradient(135deg, rgba(43, 1, 91, 0.9), rgba(2, 63, 160, 0.9));
    border-color: rgba(137, 230, 239, 0.5);
    box-shadow: 0 0 20px rgba(137, 230, 239, 0.3);
    transform: translateY(-2px);
}

/* ============================================
   GRADIENTI ANIMATI
   ============================================ */

.animated-gradient {
    background: linear-gradient(-45deg, #2b015b, #023fa0, #89e6ef, #2b015b);
    background-size: 400% 400%;
    animation: gradient-shift 8s ease infinite;
}

@keyframes gradient-shift {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

.animated-gradient-text {
    background: linear-gradient(-45deg, #89e6ef, #2b015b, #023fa0, #89e6ef);
    background-size: 400% 400%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: gradient-shift 6s ease infinite;
}

.animated-border {
    position: relative;
    border-radius: 16px;
    overflow: hidden;
}

.animated-border::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: conic-gradient(
        transparent,
        #89e6ef,
        transparent 30%
    );
    animation: rotate-border 4s linear infinite;
}

.animated-border::after {
    content: '';
    position: absolute;
    inset: 2px;
    background: var(--color-violo-dark);
    border-radius: 14px;
    z-index: 1;
}

.animated-border > * {
    position: relative;
    z-index: 2;
}

@keyframes rotate-border {
    100% { transform: rotate(360deg); }
}

/* ============================================
   MICRO-INTERAZIONI
   ============================================ */

.hover-lift {
    transition: transform 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94), box-shadow 0.3s ease;
}

.hover-lift:hover {
    transform: translateY(-8px);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
}

.hover-scale {
    transition: transform 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.hover-scale:hover {
    transform: scale(1.05);
}

.hover-glow {
    transition: all 0.3s ease;
}

.hover-glow:hover {
    box-shadow: 0 0 30px rgba(137, 230, 239, 0.5);
}

.hover-underline {
    position: relative;
    display: inline-block;
}

.hover-underline::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 0;
    height: 2px;
    background: linear-gradient(90deg, #89e6ef, #2b015b);
    transition: width 0.3s ease;
}

.hover-underline:hover::after {
    width: 100%;
}

/* ============================================
   PARTICLE EFFECTS
   ============================================ */

.particle-container {
    position: relative;
    overflow: hidden;
}

.particle {
    position: absolute;
    width: 4px;
    height: 4px;
    background: rgba(137, 230, 239, 0.6);
    border-radius: 50%;
    animation: float-particle 15s infinite;
}

.particle:nth-child(1) { left: 10%; animation-delay: 0s; }
.particle:nth-child(2) { left: 20%; animation-delay: 2s; }
.particle:nth-child(3) { left: 30%; animation-delay: 4s; }
.particle:nth-child(4) { left: 40%; animation-delay: 6s; }
.particle:nth-child(5) { left: 50%; animation-delay: 8s; }
.particle:nth-child(6) { left: 60%; animation-delay: 10s; }
.particle:nth-child(7) { left: 70%; animation-delay: 12s; }
.particle:nth-child(8) { left: 80%; animation-delay: 14s; }
.particle:nth-child(9) { left: 90%; animation-delay: 1s; }
.particle:nth-child(10) { left: 95%; animation-delay: 3s; }

@keyframes float-particle {
    0%, 100% {
        transform: translateY(100vh) scale(0);
        opacity: 0;
    }
    10% {
        opacity: 1;
    }
    90% {
        opacity: 1;
    }
    100% {
        transform: translateY(-100vh) scale(1);
        opacity: 0;
    }
}

/* ============================================
   MORPHING SHAPES
   ============================================ */

.morph-shape {
    position: absolute;
    width: 300px;
    height: 300px;
    background: linear-gradient(45deg, rgba(43, 1, 91, 0.3), rgba(2, 63, 160, 0.3));
    border-radius: 60% 40% 30% 70% / 60% 30% 70% 40%;
    animation: morph 8s ease-in-out infinite;
    filter: blur(40px);
    opacity: 0.6;
}

.morph-shape-2 {
    animation-delay: -4s;
    background: linear-gradient(45deg, rgba(137, 230, 239, 0.2), rgba(43, 1, 91, 0.2));
}

@keyframes morph {
    0%, 100% {
        border-radius: 60% 40% 30% 70% / 60% 30% 70% 40%;
        transform: rotate(0deg);
    }
    25% {
        border-radius: 30% 60% 70% 40% / 50% 60% 30% 60%;
    }
    50% {
        border-radius: 50% 60% 30% 60% / 30% 60% 70% 40%;
        transform: rotate(180deg);
    }
    75% {
        border-radius: 60% 40% 60% 30% / 70% 30% 50% 60%;
    }
}

/* ============================================
   TYPING EFFECT
   ============================================ */

.typing-effect {
    overflow: hidden;
    border-right: 3px solid #89e6ef;
    white-space: nowrap;
    animation: typing 3s steps(30) 1s forwards, blink 0.75s step-end infinite;
    width: 0;
}

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

@keyframes blink {
    50% { border-color: transparent; }
}

/* ============================================
   SCROLL REVEAL
   ============================================ */

.scroll-reveal {
    opacity: 0;
    transform: translateY(50px);
    transition: all 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.scroll-reveal.visible {
    opacity: 1;
    transform: translateY(0);
}

.scroll-reveal-left {
    opacity: 0;
    transform: translateX(-50px);
    transition: all 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.scroll-reveal-left.visible {
    opacity: 1;
    transform: translateX(0);
}

.scroll-reveal-right {
    opacity: 0;
    transform: translateX(50px);
    transition: all 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.scroll-reveal-right.visible {
    opacity: 1;
    transform: translateX(0);
}

.scroll-reveal-scale {
    opacity: 0;
    transform: scale(0.8);
    transition: all 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.scroll-reveal-scale.visible {
    opacity: 1;
    transform: scale(1);
}

/* ============================================
   3D CARD EFFECT
   ============================================ */

.card-3d {
    perspective: 1000px;
    transform-style: preserve-3d;
}

.card-3d-inner {
    transition: transform 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    transform-style: preserve-3d;
}

.card-3d:hover .card-3d-inner {
    transform: rotateY(10deg) rotateX(5deg);
}

/* ============================================
   MAGNETIC BUTTON
   ============================================ */

.magnetic-button {
    position: relative;
    transition: transform 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.magnetic-button::before {
    content: '';
    position: absolute;
    inset: -10px;
    border-radius: inherit;
}

/* ============================================
   GLITCH EFFECT
   ============================================ */

.glitch {
    position: relative;
}

.glitch::before,
.glitch::after {
    content: attr(data-text);
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.glitch::before {
    left: 2px;
    text-shadow: -2px 0 #89e6ef;
    clip: rect(24px, 550px, 90px, 0);
    animation: glitch-anim-1 2.5s infinite linear alternate-reverse;
}

.glitch::after {
    left: -2px;
    text-shadow: -2px 0 #2b015b;
    clip: rect(85px, 550px, 140px, 0);
    animation: glitch-anim-2 3s infinite linear alternate-reverse;
}

@keyframes glitch-anim-1 {
    0% { clip: rect(20px, 9999px, 10px, 0); }
    20% { clip: rect(60px, 9999px, 80px, 0); }
    40% { clip: rect(10px, 9999px, 50px, 0); }
    60% { clip: rect(80px, 9999px, 20px, 0); }
    80% { clip: rect(30px, 9999px, 70px, 0); }
    100% { clip: rect(50px, 9999px, 40px, 0); }
}

@keyframes glitch-anim-2 {
    0% { clip: rect(10px, 9999px, 80px, 0); }
    20% { clip: rect(70px, 9999px, 20px, 0); }
    40% { clip: rect(30px, 9999px, 60px, 0); }
    60% { clip: rect(50px, 9999px, 10px, 0); }
    80% { clip: rect(90px, 9999px, 40px, 0); }
    100% { clip: rect(20px, 9999px, 70px, 0); }
}

/* ============================================
   LOADING ANIMATIONS
   ============================================ */

.loading-dots {
    display: inline-flex;
    gap: 4px;
}

.loading-dots span {
    width: 8px;
    height: 8px;
    background: #89e6ef;
    border-radius: 50%;
    animation: loading-bounce 1.4s ease-in-out infinite;
}

.loading-dots span:nth-child(1) { animation-delay: -0.32s; }
.loading-dots span:nth-child(2) { animation-delay: -0.16s; }

@keyframes loading-bounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(137, 230, 239, 0.3);
    border-top-color: #89e6ef;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* ============================================
   PROGRESS BAR ANIMATED
   ============================================ */

.progress-bar-animated {
    height: 4px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
    overflow: hidden;
}

.progress-bar-animated::after {
    content: '';
    display: block;
    height: 100%;
    width: 0;
    background: linear-gradient(90deg, #2b015b, #89e6ef);
    animation: progress 2s ease-out forwards;
}

@keyframes progress {
    to { width: 100%; }
}

/* ============================================
   RIPPLE EFFECT
   ============================================ */

.ripple {
    position: relative;
    overflow: hidden;
}

.ripple::after {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    pointer-events: none;
    background-image: radial-gradient(circle, #89e6ef 10%, transparent 10.01%);
    background-repeat: no-repeat;
    background-position: 50%;
    transform: scale(10, 10);
    opacity: 0;
    transition: transform 0.5s, opacity 1s;
}

.ripple:active::after {
    transform: scale(0, 0);
    opacity: 0.3;
    transition: 0s;
}

/* ============================================
   FLOATING ELEMENTS
   ============================================ */

.float {
    animation: float 6s ease-in-out infinite;
}

.float-delay-1 { animation-delay: -2s; }
.float-delay-2 { animation-delay: -4s; }

@keyframes float {
    0%, 100% { transform: translateY(0px); }
    50% { transform: translateY(-20px); }
}

/* ============================================
   PULSE RING
   ============================================ */

.pulse-ring {
    position: relative;
}

.pulse-ring::before,
.pulse-ring::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    border-radius: 50%;
    border: 2px solid #89e6ef;
    animation: pulse-ring 2s ease-out infinite;
}

.pulse-ring::after {
    animation-delay: 1s;
}

@keyframes pulse-ring {
    0% {
        width: 100%;
        height: 100%;
        opacity: 1;
    }
    100% {
        width: 200%;
        height: 200%;
        opacity: 0;
    }
}

/* ============================================
   TECH GRID BACKGROUND
   ============================================ */

.tech-grid {
    position: relative;
    background-image:
        linear-gradient(rgba(43, 1, 91, 0.1) 1px, transparent 1px),
        linear-gradient(90deg, rgba(43, 1, 91, 0.1) 1px, transparent 1px);
    background-size: 50px 50px;
}

.tech-grid::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at 50% 50%, rgba(137, 230, 239, 0.05) 0%, transparent 50%);
    pointer-events: none;
}

/* ============================================
   HOVER CARD TILT
   ============================================ */

.card-tilt {
    transform-style: preserve-3d;
    transition: transform 0.3s ease;
}

.card-tilt:hover {
    transform: perspective(1000px) rotateX(5deg) rotateY(-5deg);
}

/* ============================================
   SKEW ON SCROLL
   ============================================ */

.skew-on-scroll {
    transition: transform 0.5s ease;
}

.skew-on-scroll.visible {
    transform: skewY(-2deg);
}

/* ============================================
   TEXT REVEAL
   ============================================ */

.text-reveal {
    overflow: hidden;
}

.text-reveal span {
    display: inline-block;
    transform: translateY(100%);
    transition: transform 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.text-reveal.visible span {
    transform: translateY(0);
}

/* ============================================
   ICON BOUNCE
   ============================================ */

.icon-bounce:hover {
    animation: icon-bounce 0.5s ease;
}

@keyframes icon-bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

/* ============================================
   STAGGER ANIMATION
   ============================================ */

.stagger-item {
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.stagger-item.visible {
    opacity: 1;
    transform: translateY(0);
}

.stagger-item:nth-child(1) { transition-delay: 0.1s; }
.stagger-item:nth-child(2) { transition-delay: 0.2s; }
.stagger-item:nth-child(3) { transition-delay: 0.3s; }
.stagger-item:nth-child(4) { transition-delay: 0.4s; }
.stagger-item:nth-child(5) { transition-delay: 0.5s; }
.stagger-item:nth-child(6) { transition-delay: 0.6s; }

/* ============================================
   CIRCULAR PROGRESS
   ============================================ */

.circular-progress {
    position: relative;
    width: 120px;
    height: 120px;
}

.circular-progress svg {
    transform: rotate(-90deg);
}

.circular-progress circle {
    fill: none;
    stroke-width: 8;
    stroke-linecap: round;
}

.circular-progress .bg {
    stroke: rgba(255, 255, 255, 0.1);
}

.circular-progress .progress {
    stroke: url(#gradient);
    stroke-dasharray: 283;
    stroke-dashoffset: 283;
    animation: circular-progress 2s ease-out forwards;
}

@keyframes circular-progress {
    to { stroke-dashoffset: 0; }
}

/* ============================================
   WAVE ANIMATION
   ============================================ */

.wave {
    position: relative;
    overflow: hidden;
}

.wave::before,
.wave::after {
    content: '';
    position: absolute;
    width: 200%;
    height: 200%;
    top: -50%;
    left: -50%;
    background: radial-gradient(circle, rgba(137, 230, 239, 0.1) 0%, transparent 60%);
    animation: wave 8s ease-in-out infinite;
}

.wave::after {
    animation-delay: -4s;
}

@keyframes wave {
    0%, 100% { transform: translate(0, 0) scale(1); }
    50% { transform: translate(20px, -20px) scale(1.1); }
}

/* ============================================
   RESPONSIVE
   ============================================ */

@media (max-width: 768px) {
    .morph-shape {
        width: 200px;
        height: 200px;
    }

    .particle {
        width: 3px;
        height: 3px;
    }

    @media (prefers-reduced-motion: reduce) {
        *,
        *::before,
        *::after {
            animation-duration: 0.01ms !important;
            animation-iteration-count: 1 !important;
            transition-duration: 0.01ms !important;
        }
    }
}
