/* Scroll-triggered Animations */

/* Entrance Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

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

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

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

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

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

@keyframes rotateIn {
    from {
        opacity: 0;
        transform: rotate(-180deg) scale(0.8);
    }
    to {
        opacity: 1;
        transform: rotate(0) scale(1);
    }
}

/* Glitch Effect */
@keyframes glitch {
    0%, 100% {
        text-shadow: 
            0.05em 0 0 rgba(255, 0, 0, 0.75),
            -0.025em -0.05em 0 rgba(0, 255, 0, 0.75),
            0.025em 0.05em 0 rgba(0, 0, 255, 0.75);
    }
    14% {
        text-shadow: 
            0.05em 0 0 rgba(255, 0, 0, 0.75),
            -0.05em -0.025em 0 rgba(0, 255, 0, 0.75),
            0.025em 0.05em 0 rgba(0, 0, 255, 0.75);
    }
    15% {
        text-shadow: 
            -0.05em -0.025em 0 rgba(255, 0, 0, 0.75),
            0.025em 0.025em 0 rgba(0, 255, 0, 0.75),
            -0.05em -0.05em 0 rgba(0, 0, 255, 0.75);
    }
    49% {
        text-shadow: 
            -0.05em -0.025em 0 rgba(255, 0, 0, 0.75),
            0.025em 0.025em 0 rgba(0, 255, 0, 0.75),
            -0.05em -0.05em 0 rgba(0, 0, 255, 0.75);
    }
    50% {
        text-shadow: 
            0.025em 0.05em 0 rgba(255, 0, 0, 0.75),
            0.05em 0 0 rgba(0, 255, 0, 0.75),
            0 -0.05em 0 rgba(0, 0, 255, 0.75);
    }
    99% {
        text-shadow: 
            0.025em 0.05em 0 rgba(255, 0, 0, 0.75),
            0.05em 0 0 rgba(0, 255, 0, 0.75),
            0 -0.05em 0 rgba(0, 0, 255, 0.75);
    }
}

.glitch {
    animation: glitch 1s linear infinite;
}

/* Matrix Rain Effect */
@keyframes matrix-fall {
    0% {
        transform: translateY(-100%);
        opacity: 0;
    }
    10% {
        opacity: 1;
    }
    90% {
        opacity: 1;
    }
    100% {
        transform: translateY(100vh);
        opacity: 0;
    }
}

.matrix-column {
    position: absolute;
    top: 0;
    font-family: var(--font-mono);
    font-size: 14px;
    line-height: 1;
    color: var(--accent-primary);
    writing-mode: vertical-lr;
    text-orientation: upright;
    animation: matrix-fall 10s linear infinite;
    opacity: 0.8;
}

/* Typewriter Effect */
@keyframes typewriter {
    from {
        width: 0;
    }
    to {
        width: 100%;
    }
}

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

.typewriter-effect {
    overflow: hidden;
    white-space: nowrap;
    border-right: 3px solid var(--accent-primary);
    animation: 
        typewriter 3s steps(40, end),
        blink-caret .75s step-end infinite;
}

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

/* Gradient Animation */
@keyframes gradient-shift {
    0% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
    100% {
        background-position: 0% 50%;
    }
}

.gradient-animated {
    background-size: 200% 200%;
    animation: gradient-shift 3s ease infinite;
}

/* Hover Lift Animation */
@keyframes hover-lift {
    0% {
        transform: translateY(0);
        box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
    }
    100% {
        transform: translateY(-5px);
        box-shadow: 0 15px 30px rgba(0, 0, 0, 0.5);
    }
}

/* Loading Dots */
@keyframes loading-dots {
    0%, 80%, 100% {
        opacity: 0;
        transform: scale(0.8);
    }
    40% {
        opacity: 1;
        transform: scale(1);
    }
}

.loading-dot {
    animation: loading-dots 1.4s infinite ease-in-out both;
}

.loading-dot:nth-child(1) {
    animation-delay: -0.32s;
}

.loading-dot:nth-child(2) {
    animation-delay: -0.16s;
}

/* Wave Animation */
@keyframes wave {
    0%, 100% {
        transform: translateY(0);
    }
    25% {
        transform: translateY(-10px);
    }
    75% {
        transform: translateY(10px);
    }
}

/* Reveal Animation */
@keyframes reveal-text {
    0% {
        clip-path: inset(0 100% 0 0);
    }
    100% {
        clip-path: inset(0 0 0 0);
    }
}

/* Slide In Animations */
@keyframes slide-in-left {
    0% {
        transform: translateX(-100%);
        opacity: 0;
    }
    100% {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slide-in-right {
    0% {
        transform: translateX(100%);
        opacity: 0;
    }
    100% {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slide-in-top {
    0% {
        transform: translateY(-100%);
        opacity: 0;
    }
    100% {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes slide-in-bottom {
    0% {
        transform: translateY(100%);
        opacity: 0;
    }
    100% {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Zoom Animations */
@keyframes zoom-in {
    0% {
        transform: scale(0);
        opacity: 0;
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

@keyframes zoom-out {
    0% {
        transform: scale(1.5);
        opacity: 0;
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Bounce Animation */
@keyframes bounce {
    0%, 20%, 50%, 80%, 100% {
        transform: translateY(0);
    }
    40% {
        transform: translateY(-30px);
    }
    60% {
        transform: translateY(-15px);
    }
}

/* Shake Animation */
@keyframes shake {
    0%, 100% {
        transform: translateX(0);
    }
    10%, 30%, 50%, 70%, 90% {
        transform: translateX(-5px);
    }
    20%, 40%, 60%, 80% {
        transform: translateX(5px);
    }
}

/* Flip Animation */
@keyframes flip-in {
    0% {
        transform: perspective(400px) rotateY(90deg);
        opacity: 0;
    }
    40% {
        transform: perspective(400px) rotateY(-20deg);
    }
    60% {
        transform: perspective(400px) rotateY(10deg);
        opacity: 1;
    }
    80% {
        transform: perspective(400px) rotateY(-5deg);
    }
    100% {
        transform: perspective(400px) rotateY(0);
        opacity: 1;
    }
}

/* Counter Animation */
@keyframes count-up {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Parallax Layers */
.parallax-container {
    position: relative;
    overflow: hidden;
}

.parallax-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.parallax-layer-1 {
    transform: translateZ(-1px) scale(2);
}

.parallax-layer-2 {
    transform: translateZ(-2px) scale(3);
}

.parallax-layer-3 {
    transform: translateZ(-3px) scale(4);
}

/* Animation Classes */
.animate-fade-in {
    animation: fadeIn 0.8s ease forwards;
}

.animate-fade-in-up {
    animation: fadeInUp 0.8s ease forwards;
}

.animate-fade-in-down {
    animation: fadeInDown 0.8s ease forwards;
}

.animate-fade-in-left {
    animation: fadeInLeft 0.8s ease forwards;
}

.animate-fade-in-right {
    animation: fadeInRight 0.8s ease forwards;
}

.animate-scale-in {
    animation: scaleIn 0.8s ease forwards;
}

.animate-rotate-in {
    animation: rotateIn 0.8s ease forwards;
}

.animate-slide-in-left {
    animation: slide-in-left 0.8s ease forwards;
}

.animate-slide-in-right {
    animation: slide-in-right 0.8s ease forwards;
}

.animate-zoom-in {
    animation: zoom-in 0.8s ease forwards;
}

.animate-bounce {
    animation: bounce 1s ease;
}

.animate-shake {
    animation: shake 0.5s ease;
}

.animate-flip-in {
    animation: flip-in 1s ease forwards;
}

/* Stagger Animation Delays */
.stagger-1 {
    animation-delay: 0.1s;
}

.stagger-2 {
    animation-delay: 0.2s;
}

.stagger-3 {
    animation-delay: 0.3s;
}

.stagger-4 {
    animation-delay: 0.4s;
}

.stagger-5 {
    animation-delay: 0.5s;
}

/* Hover Animations */
.hover-grow:hover {
    transform: scale(1.05);
    transition: transform 0.3s ease;
}

.hover-shrink:hover {
    transform: scale(0.95);
    transition: transform 0.3s ease;
}

.hover-rotate:hover {
    transform: rotate(5deg);
    transition: transform 0.3s ease;
}

.hover-lift:hover {
    animation: hover-lift 0.3s ease forwards;
}

/* Skill Bar Animation */
@keyframes skill-fill {
    0% {
        width: 0;
        opacity: 0;
    }
    100% {
        opacity: 1;
    }
}

.skill-bar-fill {
    animation: skill-fill 1.5s ease forwards;
}

/* Glow Animations */
@keyframes glow-pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(0, 255, 136, 0.7);
    }
    70% {
        box-shadow: 0 0 0 20px rgba(0, 255, 136, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(0, 255, 136, 0);
    }
}

.glow-pulse {
    animation: glow-pulse 2s infinite;
}

/* Border Animation */
@keyframes border-flow {
    0% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
    100% {
        background-position: 0% 50%;
    }
}

.animated-border {
    background: linear-gradient(90deg, 
        var(--accent-primary), 
        var(--accent-secondary), 
        var(--accent-tertiary), 
        var(--accent-primary)
    );
    background-size: 300% 100%;
    animation: border-flow 3s ease infinite;
}

/* Text Reveal */
@keyframes text-reveal {
    0% {
        opacity: 0;
        transform: translateY(100%);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

.text-reveal {
    overflow: hidden;
}

.text-reveal span {
    display: inline-block;
    animation: text-reveal 0.6s cubic-bezier(0.77, 0, 0.175, 1) forwards;
}

/* Background Animations */
@keyframes bg-shift {
    0% {
        background-position: 0% 0%;
    }
    100% {
        background-position: 100% 100%;
    }
}

.animated-bg {
    background-size: 200% 200%;
    animation: bg-shift 20s ease infinite;
}

/* Cursor Trail Effect */
.cursor-trail {
    position: fixed;
    width: 20px;
    height: 20px;
    background: var(--accent-primary);
    border-radius: 50%;
    pointer-events: none;
    opacity: 0.5;
    animation: cursor-trail-fade 1s ease forwards;
}

@keyframes cursor-trail-fade {
    0% {
        transform: scale(1);
        opacity: 0.5;
    }
    100% {
        transform: scale(0);
        opacity: 0;
    }
}

/* Section Transitions */
.section-transition-fade {
    opacity: 0;
    transition: opacity 1s ease;
}

.section-transition-fade.active {
    opacity: 1;
}

.section-transition-slide {
    transform: translateY(100px);
    opacity: 0;
    transition: all 1s ease;
}

.section-transition-slide.active {
    transform: translateY(0);
    opacity: 1;
}

/* Terminal Cursor */
@keyframes terminal-cursor {
    0% {
        opacity: 1;
    }
    49% {
        opacity: 1;
    }
    50% {
        opacity: 0;
    }
    100% {
        opacity: 0;
    }
}

.terminal-cursor::after {
    content: '_';
    animation: terminal-cursor 1s infinite;
}

/* Code Block Animation */
@keyframes code-appear {
    0% {
        opacity: 0;
        transform: translateX(-20px);
    }
    100% {
        opacity: 1;
        transform: translateX(0);
    }
}

.code-line {
    opacity: 0;
    animation: code-appear 0.5s ease forwards;
}

/* Notification Animation */
@keyframes notification-slide {
    0% {
        transform: translateX(100%);
    }
    10% {
        transform: translateX(0);
    }
    90% {
        transform: translateX(0);
    }
    100% {
        transform: translateX(100%);
    }
}

.notification {
    animation: notification-slide 4s ease forwards;
}

/* Card Hover Effects */
.card-3d {
    transition: transform 0.3s ease;
    transform-style: preserve-3d;
}

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

/* Responsive Animation Adjustments */
@media (max-width: 768px) {
    /* Reduce animation complexity on mobile */
    .parallax-layer {
        transform: none !important;
    }
    
    .matrix-bg {
        display: none;
    }
    
    /* Simplify animations */
    .animate-fade-in,
    .animate-fade-in-up,
    .animate-fade-in-down,
    .animate-fade-in-left,
    .animate-fade-in-right {
        animation-duration: 0.5s;
    }
}

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