/* Code Hub Soft - Animations & Effects */

/* AOS (Animate On Scroll) Custom Animations */
[data-aos="fade-up"] {
    transform: translateY(30px);
    opacity: 0;
    transition: transform 0.6s ease, opacity 0.6s ease;
}

[data-aos="fade-up"].aos-animate {
    transform: translateY(0);
    opacity: 1;
}

[data-aos="fade-down"] {
    transform: translateY(-30px);
    opacity: 0;
    transition: transform 0.6s ease, opacity 0.6s ease;
}

[data-aos="fade-down"].aos-animate {
    transform: translateY(0);
    opacity: 1;
}

[data-aos="fade-left"] {
    transform: translateX(-30px);
    opacity: 0;
    transition: transform 0.6s ease, opacity 0.6s ease;
}

[data-aos="fade-left"].aos-animate {
    transform: translateX(0);
    opacity: 1;
}

[data-aos="fade-right"] {
    transform: translateX(30px);
    opacity: 0;
    transition: transform 0.6s ease, opacity 0.6s ease;
}

[data-aos="fade-right"].aos-animate {
    transform: translateX(0);
    opacity: 1;
}

[data-aos="zoom-in"] {
    transform: scale(0.8);
    opacity: 0;
    transition: transform 0.6s ease, opacity 0.6s ease;
}

[data-aos="zoom-in"].aos-animate {
    transform: scale(1);
    opacity: 1;
}

[data-aos="zoom-out"] {
    transform: scale(1.2);
    opacity: 0;
    transition: transform 0.6s ease, opacity 0.6s ease;
}

[data-aos="zoom-out"].aos-animate {
    transform: scale(1);
    opacity: 1;
}

/* Custom Animation Classes */
.fade-in {
    animation: fadeIn 0.6s ease-in-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.slide-in-left {
    animation: slideInLeft 0.8s ease-out;
}

@keyframes slideInLeft {
    from {
        transform: translateX(-100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.slide-in-right {
    animation: slideInRight 0.8s ease-out;
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.slide-in-up {
    animation: slideInUp 0.8s ease-out;
}

@keyframes slideInUp {
    from {
        transform: translateY(100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.slide-in-down {
    animation: slideInDown 0.8s ease-out;
}

@keyframes slideInDown {
    from {
        transform: translateY(-100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.bounce-in {
    animation: bounceIn 0.8s ease-out;
}

@keyframes bounceIn {
    0% {
        transform: scale(0.3);
        opacity: 0;
    }
    50% {
        transform: scale(1.05);
    }
    70% {
        transform: scale(0.9);
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.rotate-in {
    animation: rotateIn 0.8s ease-out;
}

@keyframes rotateIn {
    from {
        transform: rotate(-180deg) scale(0);
        opacity: 0;
    }
    to {
        transform: rotate(0) scale(1);
        opacity: 1;
    }
}

.flip-in-x {
    animation: flipInX 0.8s ease-out;
}

@keyframes flipInX {
    from {
        transform: perspective(400px) rotateX(90deg);
        opacity: 0;
    }
    to {
        transform: perspective(400px) rotateX(0deg);
        opacity: 1;
    }
}

.flip-in-y {
    animation: flipInY 0.8s ease-out;
}

@keyframes flipInY {
    from {
        transform: perspective(400px) rotateY(90deg);
        opacity: 0;
    }
    to {
        transform: perspective(400px) rotateY(0deg);
        opacity: 1;
    }
}

/* Pulse Animation */
.pulse {
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
    100% {
        transform: scale(1);
    }
}

/* Shake Animation */
.shake {
    animation: shake 0.5s ease-in-out;
}

@keyframes shake {
    0%, 100% {
        transform: translateX(0);
    }
    10%, 30%, 50%, 70%, 90% {
        transform: translateX(-5px);
    }
    20%, 40%, 60%, 80% {
        transform: translateX(5px);
    }
}

/* Glow Effect */
.glow {
    animation: glow 2s ease-in-out infinite alternate;
}

@keyframes glow {
    from {
        box-shadow: 0 0 5px #fff, 0 0 10px #fff, 0 0 15px #007bff, 0 0 20px #007bff;
    }
    to {
        box-shadow: 0 0 10px #fff, 0 0 20px #fff, 0 0 30px #007bff, 0 0 40px #007bff;
    }
}

/* Typing Effect */
.typing {
    overflow: hidden;
    border-right: 2px solid;
    white-space: nowrap;
    animation: typing 3.5s steps(40, end), blink-caret 0.75s step-end infinite;
}

@keyframes typing {
    from {
        width: 0;
    }
    to {
        width: 100%;
    }
}

@keyframes blink-caret {
    from, to {
        border-color: transparent;
    }
    50% {
        border-color: currentColor;
    }
}

/* Float Animation */
.float {
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0%, 100% {
        transform: translateY(0px);
    }
    50% {
        transform: translateY(-10px);
    }
}

/* Hover Effects */
.hover-lift {
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.hover-lift:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
}

.hover-scale {
    transition: transform 0.3s ease;
}

.hover-scale:hover {
    transform: scale(1.05);
}

.hover-rotate {
    transition: transform 0.3s ease;
}

.hover-rotate:hover {
    transform: rotate(5deg);
}

.hover-glow {
    transition: box-shadow 0.3s ease;
}

.hover-glow:hover {
    box-shadow: 0 0 20px rgba(0, 123, 255, 0.4);
}

/* Button Animations */
.btn-bounce {
    transition: transform 0.2s ease;
}

.btn-bounce:active {
    transform: scale(0.95);
}

.btn-slide {
    position: relative;
    overflow: hidden;
}

.btn-slide::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;
}

.btn-slide:hover::before {
    left: 100%;
}

/* Loading Animation */
.loading {
    position: relative;
}

.loading::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    margin: auto;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #3498db;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Progress Bar Animation */
.progress-bar {
    width: 0;
    animation: progress 2s ease-in-out forwards;
}

@keyframes progress {
    to {
        width: 100%;
    }
}

/* Counter Animation */
.counter-number {
    display: inline-block;
    transition: all 0.3s ease;
}

/* Card Hover Effects */
.card-hover {
    transition: all 0.3s ease;
    cursor: pointer;
}

.card-hover:hover {
    transform: translateY(-5px) rotate(1deg);
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.1);
}

.card-hover:hover .card-title {
    color: #007bff;
}

/* Image Hover Effects */
.image-hover {
    overflow: hidden;
}

.image-hover img {
    transition: transform 0.3s ease;
}

.image-hover:hover img {
    transform: scale(1.1);
}

.image-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 123, 255, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
    color: white;
    font-size: 1.2rem;
    font-weight: bold;
}

.image-hover:hover .image-overlay {
    opacity: 1;
}

/* Stagger Animation for Lists */
.stagger-animation > * {
    opacity: 0;
    animation: fadeInUp 0.6s ease forwards;
}

.stagger-animation > *:nth-child(1) { animation-delay: 0.1s; }
.stagger-animation > *:nth-child(2) { animation-delay: 0.2s; }
.stagger-animation > *:nth-child(3) { animation-delay: 0.3s; }
.stagger-animation > *:nth-child(4) { animation-delay: 0.4s; }
.stagger-animation > *:nth-child(5) { animation-delay: 0.5s; }
.stagger-animation > *:nth-child(6) { animation-delay: 0.6s; }

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Morphing Shapes */
.morph-circle {
    width: 100px;
    height: 100px;
    background: #007bff;
    border-radius: 50%;
    animation: morph 4s ease-in-out infinite;
}

@keyframes morph {
    0%, 100% {
        border-radius: 50%;
        transform: scale(1);
    }
    25% {
        border-radius: 0;
        transform: scale(1.2);
    }
    50% {
        border-radius: 50% 0 50% 0;
        transform: scale(0.8);
    }
    75% {
        border-radius: 0 50% 0 50%;
        transform: scale(1.1);
    }
}

/* Text Effects */
.text-gradient {
    background: linear-gradient(45deg, #007bff, #28a745, #ffc107, #dc3545);
    background-size: 400% 400%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: gradientShift 3s ease infinite;
}

@keyframes gradientShift {
    0%, 100% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
}

.text-shadow-pulse {
    animation: textShadowPulse 2s ease-in-out infinite alternate;
}

@keyframes textShadowPulse {
    from {
        text-shadow: 0 0 5px rgba(0, 123, 255, 0.5);
    }
    to {
        text-shadow: 0 0 20px rgba(0, 123, 255, 0.8), 0 0 30px rgba(0, 123, 255, 0.6);
    }
}

/* Particle Effect */
.particles {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    pointer-events: none;
}

.particle {
    position: absolute;
    width: 4px;
    height: 4px;
    background: rgba(0, 123, 255, 0.5);
    border-radius: 50%;
    animation: particleFloat 6s linear infinite;
}

.particle:nth-child(odd) {
    animation-duration: 8s;
    animation-delay: -2s;
}

.particle:nth-child(3n) {
    animation-duration: 10s;
    animation-delay: -4s;
}

@keyframes particleFloat {
    0% {
        transform: translateY(100vh) rotate(0deg);
        opacity: 0;
    }
    10% {
        opacity: 1;
    }
    90% {
        opacity: 1;
    }
    100% {
        transform: translateY(-100vh) rotate(360deg);
        opacity: 0;
    }
}

/* Responsive Animation Adjustments */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

@media (max-width: 768px) {
    .stagger-animation > *:nth-child(n) {
        animation-delay: 0s !important;
    }

    .hover-lift:hover,
    .hover-scale:hover,
    .hover-rotate:hover {
        transform: none !important;
    }
}

/* Performance Optimizations */
.gpu-accelerated {
    transform: translateZ(0);
    backface-visibility: hidden;
    perspective: 1000px;
}

.will-change-transform {
    will-change: transform;
}

.will-change-opacity {
    will-change: opacity;
}

/* Intersection Observer Animation Triggers */
.animate-on-visible {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}

.animate-on-visible.visible {
    opacity: 1;
    transform: translateY(0);
}

/* CSS Grid Animation */
.grid-item {
    opacity: 0;
    transform: scale(0.8);
    transition: opacity 0.5s ease, transform 0.5s ease;
}

.grid-item.animate {
    opacity: 1;
    transform: scale(1);
}

.grid-item:nth-child(1) { transition-delay: 0.1s; }
.grid-item:nth-child(2) { transition-delay: 0.2s; }
.grid-item:nth-child(3) { transition-delay: 0.3s; }
.grid-item:nth-child(4) { transition-delay: 0.4s; }
.grid-item:nth-child(5) { transition-delay: 0.5s; }
.grid-item:nth-child(6) { transition-delay: 0.6s; }