/* ============================================================================
   ANIMATIONS CSS
   Chalk-themed interactive animations
   ============================================================================ */

/* ============================================================================
   CHALK WRITING ANIMATION
   ============================================================================ */

@keyframes chalkWrite {
    0% {
        stroke-dashoffset: 1000;
        opacity: 0;
    }
    10% {
        opacity: 1;
    }
    90% {
        opacity: 1;
    }
    100% {
        stroke-dashoffset: 0;
        opacity: 1;
    }
}

.chalk-line {
    stroke-dasharray: 1000;
    stroke-dashoffset: 1000;
    animation: chalkWrite 2s ease-in-out forwards;
}

.chalk-line.active {
    stroke-dashoffset: 0;
}

/* ============================================================================
   HERO ANIMATION SEQUENCE
   ============================================================================ */

@keyframes heroFadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes heroSlideUp {
    from {
        opacity: 0;
        transform: translateY(40px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.hero-content {
    animation: heroFadeIn 1.5s ease-out;
}

.hero-title .title-line {
    animation: chalkWrite 0.8s ease-in-out forwards;
    opacity: 1;
}

.hero-title .title-line:nth-child(1) {
    animation-delay: 0.4s;
}

.hero-title .title-line:nth-child(2) {
    animation-delay: 1.2s;
}

.hero-subtitle {
    animation: heroSlideUp 0.8s ease-out 1.8s both;
}

.chalk-divider {
    animation: heroSlideUp 0.8s ease-out 2s both;
}

.hero-description {
    animation: heroSlideUp 0.8s ease-out 2.2s both;
}

.hero-tagline {
    animation: heroSlideUp 0.8s ease-out 2.4s both;
}

.hero-cta {
    animation: heroSlideUp 0.8s ease-out 2.6s both;
}

.hero-social {
    animation: heroSlideUp 0.8s ease-out 2.8s both;
}

/* ============================================================================
   CHALK PARTICLE ANIMATION
   ============================================================================ */

@keyframes particleFade {
    0% {
        opacity: 1;
        transform: translate(var(--tx), var(--ty)) scale(1);
    }
    100% {
        opacity: 0;
        transform: translate(calc(var(--tx) * 1.5), calc(var(--ty) * 1.5)) scale(0);
    }
}

.chalk-particle {
    position: fixed;
    pointer-events: none;
    border-radius: 50%;
    background: rgba(242, 240, 230, 0.6);
    animation: particleFade var(--duration, 700ms) ease-out forwards;
    --tx: 0px;
    --ty: 0px;
}

/* ============================================================================
   CURSOR ANIMATION
   ============================================================================ */

@keyframes cursorGlow {
    0%, 100% {
        filter: drop-shadow(0 0 4px rgba(242, 240, 230, 0.4));
    }
    50% {
        filter: drop-shadow(0 0 8px rgba(242, 240, 230, 0.6));
    }
}

#cursor-canvas {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 10000;
    pointer-events: none;
}

/* ============================================================================
   SECTION TRANSITION OVERLAY
   ============================================================================ */

.section-transition-overlay {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 9000;
    opacity: 0;
    background:
        radial-gradient(circle at 15% 30%, rgba(242, 240, 230, 0.08) 0, rgba(242, 240, 230, 0) 45%),
        radial-gradient(circle at 80% 70%, rgba(242, 240, 230, 0.08) 0, rgba(242, 240, 230, 0) 45%),
        linear-gradient(90deg, rgba(17, 20, 18, 0.86) 0%, rgba(17, 20, 18, 0.94) 50%, rgba(17, 20, 18, 0.86) 100%);
    transition: opacity 220ms ease;
}

.section-transition-overlay.active {
    opacity: 1;
}

/* ============================================================================
   HOVER PULSE ANIMATION
   ============================================================================ */

@keyframes hoverPulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(242, 240, 230, 0.7);
    }
    50% {
        box-shadow: 0 0 0 10px rgba(242, 240, 230, 0);
    }
}

.interactive:hover {
    animation: hoverPulse 2s infinite;
}

/* ============================================================================
   SECTION REVEAL ANIMATIONS
   ============================================================================ */

@keyframes revealIn {
    from {
        opacity: 0;
        transform: translateY(60px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes revealInLeft {
    from {
        opacity: 0;
        transform: translateX(-60px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes revealInRight {
    from {
        opacity: 0;
        transform: translateX(60px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.reveal.active {
    animation: revealIn 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

.reveal.active .about-text {
    animation: revealInLeft 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94) 0.2s forwards;
}

.reveal.active .about-highlight {
    animation: revealInRight 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94) 0.2s forwards;
}

/* ============================================================================
   CHALK CIRCLE ANIMATION
   ============================================================================ */

@keyframes drawCircle {
    0% {
        stroke-dashoffset: 1000;
        opacity: 0;
    }
    50% {
        opacity: 1;
    }
    100% {
        stroke-dashoffset: 0;
        opacity: 1;
    }
}

.chalk-circle {
    stroke-dasharray: 1000;
    stroke-dashoffset: 1000;
    animation: drawCircle 0.6s ease-out forwards;
}

/* ============================================================================
   ARROW ANIMATION
   ============================================================================ */

@keyframes drawArrow {
    0% {
        stroke-dashoffset: 200;
        opacity: 0;
    }
    50% {
        opacity: 1;
    }
    100% {
        stroke-dashoffset: 0;
        opacity: 1;
    }
}

.chalk-arrow {
    stroke-dasharray: 200;
    stroke-dashoffset: 200;
    animation: drawArrow 0.4s ease-out forwards;
}

/* ============================================================================
   STAGGER ANIMATION FOR LIST ITEMS
   ============================================================================ */

@keyframes staggerIn {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.stagger-item {
    opacity: 0;
    animation: staggerIn 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

.stagger-item:nth-child(1) { animation-delay: 0.1s; }
.stagger-item:nth-child(2) { animation-delay: 0.2s; }
.stagger-item:nth-child(3) { animation-delay: 0.3s; }
.stagger-item:nth-child(4) { animation-delay: 0.4s; }
.stagger-item:nth-child(5) { animation-delay: 0.5s; }
.stagger-item:nth-child(6) { animation-delay: 0.6s; }

/* ============================================================================
   SKILL CARD HOVER ANIMATION
   ============================================================================ */

@keyframes skillCardLift {
    from {
        transform: translateY(0);
    }
    to {
        transform: translateY(-8px);
    }
}

.skill-category:hover {
    animation: skillCardLift 0.6s ease-out forwards;
}

/* ============================================================================
   BUTTON ANIMATIONS
   ============================================================================ */

@keyframes buttonPress {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(0.98);
    }
}

.chalk-button:active {
    animation: buttonPress 0.2s ease-out;
}

/* ============================================================================
   FADE IN STAGGER FOR SKILL TAGS
   ============================================================================ */

@keyframes tagFadeIn {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.skill-tag {
    opacity: 0;
    animation: tagFadeIn 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

.skill-category:nth-child(1) .skill-tag:nth-child(1) { animation-delay: 0.1s; }
.skill-category:nth-child(1) .skill-tag:nth-child(2) { animation-delay: 0.15s; }
.skill-category:nth-child(1) .skill-tag:nth-child(3) { animation-delay: 0.2s; }
.skill-category:nth-child(1) .skill-tag:nth-child(4) { animation-delay: 0.25s; }
.skill-category:nth-child(1) .skill-tag:nth-child(5) { animation-delay: 0.3s; }
.skill-category:nth-child(1) .skill-tag:nth-child(6) { animation-delay: 0.35s; }

/* ============================================================================
   TIMELINE ANIMATION
   ============================================================================ */

@keyframes timelineSlide {
    from {
        transform: scaleY(0);
        opacity: 0;
    }
    to {
        transform: scaleY(1);
        opacity: 1;
    }
}

.timeline-line {
    transform-origin: top;
    animation: timelineSlide 1s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

@keyframes timelineItemIn {
    from {
        opacity: 0;
        transform: translateX(-30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.experience-item {
    animation: timelineItemIn 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

.experience-item:nth-child(2) { animation-delay: 0.2s; }
.experience-item:nth-child(3) { animation-delay: 0.4s; }
.experience-item:nth-child(4) { animation-delay: 0.6s; }

/* ============================================================================
   PROJECT CARD ANIMATION
   ============================================================================ */

@keyframes projectCardFlip {
    from {
        opacity: 0;
        transform: perspective(1000px) rotateY(90deg);
    }
    to {
        opacity: 1;
        transform: perspective(1000px) rotateY(0deg);
    }
}

.project-card {
    opacity: 0;
    animation: projectCardFlip 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

.projects-grid .project-card:nth-child(1) { animation-delay: 0.1s; }
.projects-grid .project-card:nth-child(2) { animation-delay: 0.2s; }
.projects-grid .project-card:nth-child(3) { animation-delay: 0.3s; }
.projects-grid .project-card:nth-child(4) { animation-delay: 0.4s; }

/* ============================================================================
   SCROLL INDICATOR ANIMATION
   ============================================================================ */

@keyframes scrollBounce {
    0%, 100% {
        transform: translateX(-50%) translateY(0);
    }
    50% {
        transform: translateX(-50%) translateY(-10px);
    }
}

.chalk-scroll-indicator {
    animation: scrollBounce 2s ease-in-out infinite;
}

/* ============================================================================
   NAVIGATION ANIMATION
   ============================================================================ */

@keyframes navItemIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.nav-link {
    opacity: 0;
    animation: navItemIn 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

.nav-link:nth-child(1) { animation-delay: 3s; }
.nav-link:nth-child(2) { animation-delay: 3.1s; }
.nav-link:nth-child(3) { animation-delay: 3.2s; }
.nav-link:nth-child(4) { animation-delay: 3.3s; }
.nav-link:nth-child(5) { animation-delay: 3.4s; }
.nav-link:nth-child(6) { animation-delay: 3.5s; }
.nav-link:nth-child(7) { animation-delay: 3.6s; }
.nav-link:nth-child(8) { animation-delay: 3.7s; }

/* ============================================================================
   TRANSITION ANIMATIONS
   ============================================================================ */

@keyframes transitionFade {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.3;
    }
}

@keyframes wipeIn {
    from {
        clip-path: polygon(0 0, 0 0, 0 100%, 0 100%);
    }
    to {
        clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%);
    }
}

.section-transition {
    animation: wipeIn 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

/* ============================================================================
   LOADING ANIMATION
   ============================================================================ */

@keyframes loadingPulse {
    0%, 100% {
        opacity: 0.3;
    }
    50% {
        opacity: 1;
    }
}

.loading {
    animation: loadingPulse 1.5s ease-in-out infinite;
}

/* ============================================================================
   ACCESSIBILITY - REDUCED MOTION
   ============================================================================ */

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    /* Keep essential reveals visible */
    .reveal {
        opacity: 1 !important;
        transform: none !important;
    }

    .reveal.active {
        animation: none !important;
    }

    /* Disable particle effects */
    .chalk-particle {
        display: none;
    }

    /* Simple transitions only */
    .chalk-button,
    .skill-tag,
    .nav-link,
    .chalk-card {
        transition: color 0.01ms, background 0.01ms !important;
    }
}
