/* ==========================================================================
   Coder4Nix Theme - Animations & Transitions
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Scroll Reveal
   -------------------------------------------------------------------------- */
.c4n-reveal {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.7s cubic-bezier(0.4, 0, 0.2, 1), transform 0.7s cubic-bezier(0.4, 0, 0.2, 1);
}

.c4n-reveal.revealed {
    opacity: 1;
    transform: translateY(0);
}

.c4n-reveal-left {
    opacity: 0;
    transform: translateX(-20px);
    transition: opacity 0.7s ease, transform 0.7s ease;
}

.c4n-reveal-left.revealed {
    opacity: 1;
    transform: translateX(0);
}

.c4n-reveal-right {
    opacity: 0;
    transform: translateX(20px);
    transition: opacity 0.7s ease, transform 0.7s ease;
}

.c4n-reveal-right.revealed {
    opacity: 1;
    transform: translateX(0);
}

.c4n-reveal-scale {
    opacity: 0;
    transform: scale(0.9);
    transition: opacity 0.6s ease, transform 0.6s ease;
}

.c4n-reveal-scale.revealed {
    opacity: 1;
    transform: scale(1);
}

/* Staggered delays for child elements */
.c4n-stagger > *:nth-child(1) { transition-delay: 0s; }
.c4n-stagger > *:nth-child(2) { transition-delay: 0.1s; }
.c4n-stagger > *:nth-child(3) { transition-delay: 0.2s; }
.c4n-stagger > *:nth-child(4) { transition-delay: 0.3s; }
.c4n-stagger > *:nth-child(5) { transition-delay: 0.4s; }
.c4n-stagger > *:nth-child(6) { transition-delay: 0.5s; }
.c4n-stagger > *:nth-child(7) { transition-delay: 0.6s; }
.c4n-stagger > *:nth-child(8) { transition-delay: 0.7s; }

/* --------------------------------------------------------------------------
   2. Card Hover Effects
   -------------------------------------------------------------------------- */
.c4n-card-lift {
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.c4n-card-lift:hover {
    transform: translateY(-6px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15);
}

[data-theme="dark"] .c4n-card-lift:hover {
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
}

/* --------------------------------------------------------------------------
   3. Button Glow
   -------------------------------------------------------------------------- */
.c4n-btn-glow {
    position: relative;
    overflow: hidden;
}

.c4n-btn-glow::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    transform: translate(-50%, -50%);
    transition: width 0.6s ease, height 0.6s ease;
}

.c4n-btn-glow:hover::after {
    width: 300px;
    height: 300px;
}

/* --------------------------------------------------------------------------
   4. Counter Animation
   -------------------------------------------------------------------------- */
@keyframes c4n-countUp {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.c4n-counter {
    display: inline-block;
}

.c4n-counter.counting {
    animation: c4n-countUp 0.5s ease forwards;
}

/* --------------------------------------------------------------------------
   5. Typing Effect
   -------------------------------------------------------------------------- */
.c4n-typing {
    display: inline-block;
    border-right: 2px solid var(--c4n-primary);
    white-space: nowrap;
    overflow: hidden;
    animation: c4n-typing 3.5s steps(40, end), c4n-blink-caret 0.75s step-end infinite;
}

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

@keyframes c4n-blink-caret {
    from, to { border-color: transparent; }
    50% { border-color: var(--c4n-primary); }
}

/* --------------------------------------------------------------------------
   6. Fade Animations (used in Hero)
   -------------------------------------------------------------------------- */
@keyframes c4n-fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes c4n-fadeInUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes c4n-fadeInDown {
    from { opacity: 0; transform: translateY(-20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes c4n-fadeInLeft {
    from { opacity: 0; transform: translateX(-30px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes c4n-fadeInRight {
    from { opacity: 0; transform: translateX(30px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes c4n-scaleIn {
    from { opacity: 0; transform: scale(0.8); }
    to { opacity: 1; transform: scale(1); }
}

@keyframes c4n-slideUp {
    from { transform: translateY(100%); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* --------------------------------------------------------------------------
   7. Pulse / Ping
   -------------------------------------------------------------------------- */
@keyframes c4n-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

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

@keyframes c4n-ping {
    75%, 100% {
        transform: scale(2);
        opacity: 0;
    }
}

.c4n-ping::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: inherit;
    background: inherit;
    animation: c4n-ping 1.5s cubic-bezier(0, 0, 0.2, 1) infinite;
}

/* --------------------------------------------------------------------------
   8. Float Animation (for decorative elements)
   -------------------------------------------------------------------------- */
@keyframes c4n-float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

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

/* --------------------------------------------------------------------------
   9. Shimmer / Loading
   -------------------------------------------------------------------------- */
@keyframes c4n-shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

.c4n-shimmer {
    background: linear-gradient(90deg, var(--c4n-surface) 25%, var(--c4n-surface-hover) 50%, var(--c4n-surface) 75%);
    background-size: 200% 100%;
    animation: c4n-shimmer 1.5s ease-in-out infinite;
}

/* --------------------------------------------------------------------------
   10. Particle Dots (CSS-only background decoration)
   -------------------------------------------------------------------------- */
.c4n-particles {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    pointer-events: none;
}

.c4n-particle {
    position: absolute;
    width: 4px;
    height: 4px;
    background: rgba(0, 200, 83, 0.3);
    border-radius: 50%;
    animation: c4n-float-particle linear infinite;
}

.c4n-particle:nth-child(1) { left: 10%; top: 20%; animation-duration: 6s; animation-delay: 0s; }
.c4n-particle:nth-child(2) { left: 20%; top: 60%; animation-duration: 8s; animation-delay: 1s; width: 3px; height: 3px; background: rgba(0, 176, 255, 0.3); }
.c4n-particle:nth-child(3) { left: 35%; top: 40%; animation-duration: 7s; animation-delay: 2s; }
.c4n-particle:nth-child(4) { left: 50%; top: 70%; animation-duration: 9s; animation-delay: 0.5s; width: 5px; height: 5px; background: rgba(124, 77, 255, 0.2); }
.c4n-particle:nth-child(5) { left: 65%; top: 25%; animation-duration: 6.5s; animation-delay: 1.5s; width: 3px; height: 3px; }
.c4n-particle:nth-child(6) { left: 80%; top: 55%; animation-duration: 7.5s; animation-delay: 3s; background: rgba(0, 176, 255, 0.25); }
.c4n-particle:nth-child(7) { left: 90%; top: 15%; animation-duration: 8.5s; animation-delay: 2.5s; width: 3px; height: 3px; }
.c4n-particle:nth-child(8) { left: 45%; top: 85%; animation-duration: 5.5s; animation-delay: 1s; background: rgba(124, 77, 255, 0.25); }

@keyframes c4n-float-particle {
    0%, 100% { transform: translate(0, 0) scale(1); opacity: 0.5; }
    25% { transform: translate(10px, -20px) scale(1.2); opacity: 0.8; }
    50% { transform: translate(-5px, -40px) scale(0.8); opacity: 0.6; }
    75% { transform: translate(15px, -20px) scale(1.1); opacity: 0.4; }
}

/* --------------------------------------------------------------------------
   11. Gradient Border Animation
   -------------------------------------------------------------------------- */
@keyframes c4n-gradient-border {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

.c4n-gradient-border {
    position: relative;
    border: none !important;
}

.c4n-gradient-border::before {
    content: '';
    position: absolute;
    inset: -2px;
    border-radius: inherit;
    background: linear-gradient(45deg, var(--c4n-primary), var(--c4n-secondary), var(--c4n-accent), var(--c4n-primary));
    background-size: 400% 400%;
    animation: c4n-gradient-border 4s ease infinite;
    z-index: -1;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.c4n-gradient-border:hover::before {
    opacity: 1;
}

/* --------------------------------------------------------------------------
   12. Spin (for loading icons)
   -------------------------------------------------------------------------- */
@keyframes c4n-spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.c4n-spin {
    animation: c4n-spin 1s linear infinite;
}

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

    .c4n-reveal,
    .c4n-reveal-left,
    .c4n-reveal-right,
    .c4n-reveal-scale {
        opacity: 1;
        transform: none;
    }
}
