/* ========================================
   CASTELLO CONSULTING - Animations System
   Particle & Line Effects
   ======================================== */

/* ---------- CSS Variables for Animations ---------- */
:root {
    --particle-color: rgba(126, 217, 87, 0.8);
    --particle-color-subtle: rgba(126, 217, 87, 0.4);
    --line-color: rgba(31, 74, 64, 0.25);
    --line-color-active: rgba(126, 217, 87, 0.6);
    --animation-speed-slow: 4s;
    --animation-speed-medium: 2s;
    --animation-speed-fast: 1s;
}

/* ---------- Reduce Motion Support ---------- */
@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    .particles-canvas,
    .animated-line,
    .pulse-dot {
        display: none !important;
    }
}

/* ---------- Hero Particles Container ---------- */
.hero {
    position: relative;
    overflow: hidden;
}

.particles-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
}

.hero .section-inner {
    position: relative;
    z-index: 1;
}

/* ---------- Animated Lines Base ---------- */
.animated-line-container {
    position: absolute;
    pointer-events: none;
    overflow: visible;
}

.animated-line {
    stroke: var(--line-color);
    stroke-width: 1.5;
    fill: none;
}

.animated-line-glow {
    stroke: var(--line-color-active);
    stroke-width: 2;
    fill: none;
    stroke-linecap: round;
    stroke-dasharray: 20 200;
    animation: lineFlow var(--animation-speed-slow) linear infinite;
}

@keyframes lineFlow {
    0% {
        stroke-dashoffset: 220;
    }

    100% {
        stroke-dashoffset: 0;
    }
}

/* ---------- Traveling Particle on Line ---------- */
.traveling-particle {
    fill: var(--particle-color);
    filter: drop-shadow(0 0 6px var(--particle-color));
}

/* ---------- Section: Sobre Nosotros - Progress Line ---------- */
.section-progress {
    position: relative;
}

.progress-line-wrapper {
    position: absolute;
    top: 50%;
    left: 0;
    width: 100%;
    height: 4px;
    transform: translateY(-50%);
    opacity: 0.3;
    pointer-events: none;
}

.progress-line {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: 0;
    background: linear-gradient(90deg, transparent, var(--particle-color), transparent);
    transition: width 1s ease-out;
}

.progress-line-wrapper.in-view .progress-line {
    width: 100%;
}

.progress-dots {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    justify-content: space-between;
    width: 100%;
    padding: 0 10%;
}

.progress-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--line-color);
    transition: all 0.5s ease;
}

.progress-dot.active {
    background: var(--particle-color);
    box-shadow: 0 0 12px var(--particle-color);
    transform: scale(1.3);
}

/* ---------- Section: IA Fácil - Pulse Grid ---------- */
.pulse-grid {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: hidden;
}

.pulse-dot {
    position: absolute;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--particle-color);
    box-shadow: 0 0 10px var(--particle-color);
    animation: pulse var(--animation-speed-slow) ease-in-out infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 0.2;
        transform: scale(1);
    }

    50% {
        opacity: 0.8;
        transform: scale(1.5);
    }
}

/* Staggered pulse timing */
.pulse-dot:nth-child(3n) {
    animation-delay: 0s;
}

.pulse-dot:nth-child(3n+1) {
    animation-delay: 1.3s;
}

.pulse-dot:nth-child(3n+2) {
    animation-delay: 2.6s;
}

/* ---------- Section: Jóvenes - Rising Particles ---------- */
.rising-particles {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: hidden;
}

.rising-particle {
    position: absolute;
    bottom: -20px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--particle-color);
    box-shadow: 0 0 12px var(--particle-color);
    animation: rise 8s ease-in-out infinite;
}

@keyframes rise {
    0% {
        transform: translateY(0) scale(1);
        opacity: 0;
    }

    10% {
        opacity: 0.6;
    }

    90% {
        opacity: 0.6;
    }

    100% {
        transform: translateY(-120vh) scale(0.5);
        opacity: 0;
    }
}

/* Staggered rise timing */
.rising-particle:nth-child(1) {
    left: 10%;
    animation-delay: 0s;
}

.rising-particle:nth-child(2) {
    left: 25%;
    animation-delay: 1.5s;
}

.rising-particle:nth-child(3) {
    left: 40%;
    animation-delay: 0.8s;
}

.rising-particle:nth-child(4) {
    left: 55%;
    animation-delay: 2.3s;
}

.rising-particle:nth-child(5) {
    left: 70%;
    animation-delay: 1.1s;
}

.rising-particle:nth-child(6) {
    left: 85%;
    animation-delay: 2.8s;
}

.rising-particle:nth-child(7) {
    left: 95%;
    animation-delay: 0.3s;
}

.rising-particle:nth-child(8) {
    left: 5%;
    animation-delay: 1.9s;
}

/* ---------- Section: No Líos - Circuit Animation ---------- */
.circuit-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    opacity: 0.7;
}

.circuit-path {
    stroke: var(--line-color);
    stroke-width: 1.5;
    fill: none;
}

.circuit-particle {
    fill: var(--particle-color);
    filter: drop-shadow(0 0 4px var(--particle-color));
}

/* ---------- Form: Animated Border ---------- */
.form-animated-wrapper {
    position: relative;
    padding: 3px;
    border-radius: 16px;
    background: transparent;
}

.form-animated-wrapper::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border-radius: 16px;
    padding: 3px;
    background: linear-gradient(90deg,
            transparent,
            var(--particle-color),
            transparent,
            var(--particle-color),
            transparent);
    background-size: 300% 100%;
    animation: borderFlow 4s linear infinite;
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    opacity: 0.8;
    transition: opacity 0.3s ease;
}

.form-animated-wrapper:hover::before,
.form-animated-wrapper:focus-within::before {
    opacity: 1;
    animation-duration: 3s;
}

@keyframes borderFlow {
    0% {
        background-position: 0% 50%;
    }

    100% {
        background-position: 300% 50%;
    }
}

/* ---------- Social Proof: Connection Lines ---------- */
.sp-connection-lines {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
}

.sp-connection-line {
    stroke: var(--line-color);
    stroke-width: 1;
    fill: none;
    stroke-dasharray: 4 8;
    opacity: 0.5;
}

.sp-connection-particle {
    fill: var(--particle-color);
    animation: flowAlongPath 5s linear infinite;
}

@keyframes flowAlongPath {
    0% {
        offset-distance: 0%;
        opacity: 0;
    }

    10% {
        opacity: 1;
    }

    90% {
        opacity: 1;
    }

    100% {
        offset-distance: 100%;
        opacity: 0;
    }
}

/* ---------- Footer: Subtle Line ---------- */
.footer-line {
    position: relative;
    height: 1px;
    background: var(--line-color);
    overflow: visible;
    margin-bottom: 40px;
}

.footer-line::after {
    content: '';
    position: absolute;
    top: -3px;
    left: 0;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--particle-color);
    animation: footerParticle 8s linear infinite;
}

@keyframes footerParticle {
    0% {
        left: 0;
        opacity: 0;
    }

    5% {
        opacity: 1;
    }

    95% {
        opacity: 1;
    }

    100% {
        left: calc(100% - 8px);
        opacity: 0;
    }
}

/* ---------- Scroll Reveal Animations ---------- */
.reveal-element {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.8s ease, transform 0.8s ease;
}

.reveal-element.revealed {
    opacity: 1;
    transform: translateY(0);
}

/* ---------- Button Particle Burst ---------- */
.btn-particle-effect {
    position: relative;
    overflow: visible;
}

.btn-particle-effect::before,
.btn-particle-effect::after {
    content: '';
    position: absolute;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--particle-color);
    opacity: 0;
    pointer-events: none;
}

.btn-particle-effect:hover::before {
    animation: particleBurst1 0.6s ease-out forwards;
}

.btn-particle-effect:hover::after {
    animation: particleBurst2 0.6s ease-out forwards;
}

@keyframes particleBurst1 {
    0% {
        top: 50%;
        left: 0;
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }

    100% {
        top: -20px;
        left: -30px;
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.5);
    }
}

@keyframes particleBurst2 {
    0% {
        top: 50%;
        right: 0;
        opacity: 1;
        transform: translate(50%, -50%) scale(1);
    }

    100% {
        top: -20px;
        right: -30px;
        opacity: 0;
        transform: translate(50%, -50%) scale(0.5);
    }
}

/* ---------- Floating Dots Background ---------- */
.floating-dots-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: hidden;
}

.floating-dot {
    position: absolute;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--particle-color);
    box-shadow: 0 0 8px var(--particle-color);
    animation: floatDot 6s ease-in-out infinite;
}

@keyframes floatDot {

    0%,
    100% {
        transform: translateY(0) translateX(0);
        opacity: 0.3;
    }

    25% {
        transform: translateY(-15px) translateX(8px);
        opacity: 0.6;
    }

    50% {
        transform: translateY(-5px) translateX(-5px);
        opacity: 0.4;
    }

    75% {
        transform: translateY(-20px) translateX(3px);
        opacity: 0.6;
    }
}

/* Scattered positioning */
.floating-dot:nth-child(1) {
    top: 20%;
    left: 10%;
    animation-delay: 0s;
}

.floating-dot:nth-child(2) {
    top: 40%;
    left: 25%;
    animation-delay: 1s;
}

.floating-dot:nth-child(3) {
    top: 60%;
    left: 40%;
    animation-delay: 2s;
}

.floating-dot:nth-child(4) {
    top: 30%;
    left: 55%;
    animation-delay: 0.5s;
}

.floating-dot:nth-child(5) {
    top: 70%;
    left: 70%;
    animation-delay: 1.5s;
}

.floating-dot:nth-child(6) {
    top: 50%;
    left: 85%;
    animation-delay: 2.5s;
}

.floating-dot:nth-child(7) {
    top: 15%;
    left: 75%;
    animation-delay: 0.8s;
}

.floating-dot:nth-child(8) {
    top: 80%;
    left: 20%;
    animation-delay: 1.8s;
}