/* Animation-timeline based animations using view() */
@keyframes float {
    0%, 100% {
        transform: translate(0, 0) rotate(0deg);
    }
    25% {
        transform: translate(20px, 20px) rotate(90deg);
    }
    50% {
        transform: translate(0, 40px) rotate(180deg);
    }
    75% {
        transform: translate(-20px, 20px) rotate(270deg);
    }
}

@keyframes gradientShift {
    0%, 100% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
}

@keyframes typewriter {
    0%, 100% {
        opacity: 0;
    }
    2%, 98% {
        opacity: 1;
    }
}

/* Animation 1: Fade in from bottom using view() */
@keyframes fadeInUpView {
    from {
        opacity: 0;
        transform: translateY(50px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.hero-content {
    animation: fadeInUpView linear both;
    animation-timeline: view();
    animation-range: entry 0% cover 30%;
}

/* Animation 2: Scale in using view() */
@keyframes scaleInView {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.feature-card {
    animation: scaleInView linear both;
    animation-timeline: view();
    animation-range: entry 0% cover 30%;
}

/* Animation 3: Slide in from left using view() */
@keyframes slideInLeftView {
    from {
        opacity: 0;
        transform: translateX(-50px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.language-type:nth-child(odd) {
    animation: slideInLeftView linear both;
    animation-timeline: view();
    animation-range: entry 0% cover 40%;
}

/* Animation 4: Slide in from right using view() */
@keyframes slideInRightView {
    from {
        opacity: 0;
        transform: translateX(50px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.language-type:nth-child(even) {
    animation: slideInRightView linear both;
    animation-timeline: view();
    animation-range: entry 0% cover 40%;
}

/* Animation 5: Rotate in using view() */
@keyframes rotateInView {
    from {
        opacity: 0;
        transform: rotate(-10deg) scale(0.8);
    }
    to {
        opacity: 1;
        transform: rotate(0) scale(1);
    }
}

.about-image {
    animation: rotateInView linear both;
    animation-timeline: view();
    animation-range: entry 0% cover 50%;
}

/* Additional scroll animations */
@keyframes fadeInView {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.project-card {
    animation: fadeInView linear both;
    animation-timeline: view();
    animation-range: entry 0% cover 40%;
}

.skill-category {
    animation: fadeInView linear both;
    animation-timeline: view();
    animation-range: entry 0% cover 40%;
}

/* Parallax effect */
.hero-visual {
    animation: parallax linear both;
    animation-timeline: view();
    animation-range: entry 0% cover 100%;
    transform: translateY(calc(var(--scroll-percent) * 50px));
}

@keyframes parallax {
    to {
        transform: translateY(0);
    }
}

/* Code highlight animation */
.code-preview {
    animation: codeGlow linear both;
    animation-timeline: view();
    animation-range: entry 0% cover 50%;
}

@keyframes codeGlow {
    0% {
        box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
    }
    50% {
        box-shadow: 0 30px 60px rgba(59, 130, 246, 0.2);
    }
    100% {
        box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
    }
}

/* Stagger animations for feature cards */
.feature-card:nth-child(1) { animation-delay: 0.1s; }
.feature-card:nth-child(2) { animation-delay: 0.2s; }
.feature-card:nth-child(3) { animation-delay: 0.3s; }
.feature-card:nth-child(4) { animation-delay: 0.4s; }

/* Hover animations */
@keyframes pulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.4);
    }
    70% {
        box-shadow: 0 0 0 10px rgba(59, 130, 246, 0);
    }
}

.pulse {
    animation: pulse 2s infinite;
}

/* Button hover animation */
@keyframes buttonGlow {
    0%, 100% {
        box-shadow: 0 5px 15px rgba(59, 130, 246, 0.3);
    }
    50% {
        box-shadow: 0 5px 25px rgba(59, 130, 246, 0.5);
    }
}

.btn-primary:hover {
    animation: buttonGlow 1s infinite;
}

/* Loading animation */
@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.loading {
    animation: spin 1s linear infinite;
}

/* Bounce animation */
@keyframes bounce {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-10px);
    }
}

.bounce {
    animation: bounce 2s infinite;
}

/* Shake animation */
@keyframes shake {
    0%, 100% {
        transform: translateX(0);
    }
    25% {
        transform: translateX(-5px);
    }
    75% {
        transform: translateX(5px);
    }
}

.shake {
    animation: shake 0.5s;
}

/* Wave animation */
@keyframes wave {
    0%, 100% {
        transform: rotate(0deg);
    }
    25% {
        transform: rotate(10deg);
    }
    75% {
        transform: rotate(-10deg);
    }
}

.wave {
    animation: wave 2s infinite;
    transform-origin: 70% 70%;
}

/* Gradient border animation */
@keyframes borderFlow {
    0%, 100% {
        border-image: linear-gradient(45deg, #3b82f6, #8b5cf6) 1;
    }
    50% {
        border-image: linear-gradient(45deg, #8b5cf6, #3b82f6) 1;
    }
}

.animated-border {
    border: 2px solid;
    animation: borderFlow 3s infinite;
}

/* Text shadow animation */
@keyframes textShadow {
    0%, 100% {
        text-shadow: 0 0 10px rgba(59, 130, 246, 0.5);
    }
    50% {
        text-shadow: 0 0 20px rgba(59, 130, 246, 0.8);
    }
}

.text-glow {
    animation: textShadow 2s infinite;
}

/* Progress bar animation */
@keyframes progress {
    from {
        width: 0%;
    }
    to {
        width: var(--progress);
    }
}

.progress-bar {
    animation: progress 1s ease-out forwards;
}

/* Flip card animation */
@keyframes flip {
    0% {
        transform: perspective(1000px) rotateY(0);
    }
    100% {
        transform: perspective(1000px) rotateY(180deg);
    }
}

.flip-card {
    animation: flip 0.6s ease-out;
}

/* Zoom in animation */
@keyframes zoomIn {
    from {
        transform: scale(0.5);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

.zoom-in {
    animation: zoomIn 0.5s ease-out;
}

/* Slide up animation */
@keyframes slideUp {
    from {
        transform: translateY(100px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.slide-up {
    animation: slideUp 0.5s ease-out;
}

/* Ripple effect */
@keyframes ripple {
    to {
        transform: scale(4);
        opacity: 0;
    }
}

.ripple {
    position: relative;
    overflow: hidden;
}

.ripple:after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 5px;
    height: 5px;
    background: rgba(255, 255, 255, 0.5);
    opacity: 0;
    border-radius: 100%;
    transform: scale(1, 1) translate(-50%);
    transform-origin: 50% 50%;
}

.ripple:focus:after {
    animation: ripple 0.6s ease-out;
}

/* Particle system animation */
@keyframes particleFloat {
    0% {
        transform: translateY(0) rotate(0deg);
        opacity: 0;
    }
    10% {
        opacity: 1;
    }
    90% {
        opacity: 1;
    }
    100% {
        transform: translateY(-1000px) rotate(720deg);
        opacity: 0;
    }
}

/* Morph animation */
@keyframes morph {
    0%, 100% {
        border-radius: 60% 40% 30% 70%/60% 30% 70% 40%;
    }
    50% {
        border-radius: 30% 60% 70% 40%/50% 60% 30% 60%;
    }
}

.morph {
    animation: morph 8s ease-in-out infinite;
}

/* Glitch effect */
@keyframes glitch {
    0% {
        transform: translate(0);
    }
    20% {
        transform: translate(-2px, 2px);
    }
    40% {
        transform: translate(-2px, -2px);
    }
    60% {
        transform: translate(2px, 2px);
    }
    80% {
        transform: translate(2px, -2px);
    }
    100% {
        transform: translate(0);
    }
}

.glitch:hover {
    animation: glitch 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94) both;
}

/* Neon flicker */
@keyframes flicker {
    0%, 100% {
        opacity: 1;
    }
    41% {
        opacity: 1;
    }
    42% {
        opacity: 0.8;
    }
    43% {
        opacity: 1;
    }
    45% {
        opacity: 0.2;
    }
    46% {
        opacity: 1;
    }
}

.neon {
    animation: flicker 3s infinite;
}

/* Color cycle */
@keyframes colorCycle {
    0%, 100% {
        color: #3b82f6;
    }
    25% {
        color: #8b5cf6;
    }
    50% {
        color: #ec4899;
    }
    75% {
        color: #10b981;
    }
}

.color-cycle {
    animation: colorCycle 4s infinite;
}

/* Breathing animation */
@keyframes breathing {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
}

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

/* Page load animation */
@keyframes pageLoad {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.page-load {
    animation: pageLoad 0.8s ease-out;
}