/* ═══════════════════════════════════════════════════════════════════════════
   RepoXray — Global Animations & Micro-Interactions
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Scroll-triggered fade-in animations ───────────────────────────── */

[data-animate] {
    opacity: 0;
    transform: translateY(24px);
    transition: opacity 0.6s cubic-bezier(0.22, 1, 0.36, 1),
                transform 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}

[data-animate].visible {
    opacity: 1;
    transform: translateY(0);
}

[data-animate="fade-up"] {
    transform: translateY(30px);
}

[data-animate="fade-left"] {
    transform: translateX(-30px);
}

[data-animate="fade-right"] {
    transform: translateX(30px);
}

[data-animate="fade-up"].visible,
[data-animate="fade-left"].visible,
[data-animate="fade-right"].visible {
    transform: translate(0, 0);
}

[data-animate="scale"] {
    transform: scale(0.92);
}

[data-animate="scale"].visible {
    transform: scale(1);
}

/* ── Staggered children animation ──────────────────────────────────── */

[data-stagger] > * {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.5s cubic-bezier(0.22, 1, 0.36, 1),
                transform 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}

[data-stagger].visible > *:nth-child(1) { transition-delay: 0.05s; }
[data-stagger].visible > *:nth-child(2) { transition-delay: 0.1s; }
[data-stagger].visible > *:nth-child(3) { transition-delay: 0.15s; }
[data-stagger].visible > *:nth-child(4) { transition-delay: 0.2s; }
[data-stagger].visible > *:nth-child(5) { transition-delay: 0.25s; }
[data-stagger].visible > *:nth-child(6) { transition-delay: 0.3s; }

[data-stagger].visible > * {
    opacity: 1;
    transform: translateY(0);
}

/* ── Hover lift effect ─────────────────────────────────────────────── */

.hover-lift {
    transition: transform 0.3s cubic-bezier(0.22, 1, 0.36, 1),
                box-shadow 0.3s ease;
}

.hover-lift:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 40px -12px rgba(0, 0, 0, 0.5);
}

/* ── Glow pulse animation ──────────────────────────────────────────── */

@keyframes glow-pulse {
    0%, 100% {
        box-shadow: 0 0 20px rgba(99, 102, 241, 0.2),
                    0 0 40px rgba(99, 102, 241, 0.1);
    }
    50% {
        box-shadow: 0 0 30px rgba(99, 102, 241, 0.35),
                    0 0 60px rgba(99, 102, 241, 0.15);
    }
}

.glow-pulse {
    animation: glow-pulse 3s ease-in-out infinite;
}

/* ── Subtle float animation ────────────────────────────────────────── */

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

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

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

/* ── Shimmer loading effect ────────────────────────────────────────── */

@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

.shimmer {
    background: linear-gradient(
        90deg,
        rgba(255, 255, 255, 0.03) 25%,
        rgba(255, 255, 255, 0.08) 50%,
        rgba(255, 255, 255, 0.03) 75%
    );
    background-size: 200% 100%;
    animation: shimmer 2s ease-in-out infinite;
}

/* ── Typing cursor animation ───────────────────────────────────────── */

@keyframes blink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0; }
}

.cursor-blink::after {
    content: '|';
    animation: blink 1s step-end infinite;
    color: var(--indigo);
    margin-left: 2px;
}

/* ── Smooth scale on click ─────────────────────────────────────────── */

.press-scale {
    transition: transform 0.15s cubic-bezier(0.22, 1, 0.36, 1);
}

.press-scale:active {
    transform: scale(0.97);
}

/* ── Border glow on focus ──────────────────────────────────────────── */

.focus-glow:focus-within {
    border-color: rgba(99, 102, 241, 0.5) !important;
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.15),
                0 0 30px rgba(99, 102, 241, 0.1);
}

/* ── Icon spin on hover ────────────────────────────────────────────── */

.hover-spin:hover svg {
    animation: spin-once 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}

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

/* ── Gradient text shimmer ─────────────────────────────────────────── */

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

.gradient-animated {
    background: linear-gradient(
        135deg,
        var(--indigo),
        #a5b4fc,
        var(--green),
        #a5b4fc,
        var(--indigo)
    );
    background-size: 300% 300%;
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    animation: gradient-shift 6s ease infinite;
}

/* ── Reveal line animation ─────────────────────────────────────────── */

@keyframes reveal-line {
    from { width: 0; }
    to { width: 100%; }
}

.reveal-line::after {
    content: '';
    display: block;
    height: 2px;
    background: linear-gradient(90deg, var(--indigo), transparent);
    animation: reveal-line 0.8s ease both;
    animation-delay: 0.3s;
}

/* ── Particle-like dot animation ───────────────────────────────────── */

@keyframes dot-pulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.5); opacity: 0.7; }
}

.dot-animated {
    animation: dot-pulse 2s ease-in-out infinite;
}

/* ── Slide in from sides ───────────────────────────────────────────── */

@keyframes slide-in-left {
    from { opacity: 0; transform: translateX(-40px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes slide-in-right {
    from { opacity: 0; transform: translateX(40px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes slide-in-up {
    from { opacity: 0; transform: translateY(40px); }
    to { opacity: 1; transform: translateY(0); }
}

.slide-in-left { animation: slide-in-left 0.6s cubic-bezier(0.22, 1, 0.36, 1) both; }
.slide-in-right { animation: slide-in-right 0.6s cubic-bezier(0.22, 1, 0.36, 1) both; }
.slide-in-up { animation: slide-in-up 0.6s cubic-bezier(0.22, 1, 0.36, 1) both; }

/* ── Counter number animation ──────────────────────────────────────── */

@keyframes count-up {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.count-animate {
    animation: count-up 0.4s cubic-bezier(0.22, 1, 0.36, 1) both;
}

/* ── Reduced motion ────────────────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
    [data-animate],
    [data-stagger] > *,
    .float,
    .glow-pulse,
    .shimmer,
    .hover-lift:hover,
    .press-scale:active {
        animation: none !important;
        transition: none !important;
        transform: none !important;
        opacity: 1 !important;
    }
}
