/**
 * Enhanced Portfolio Animations
 * Creative and beautiful animations for the portfolio section
 */

/* ========================================
   BACKGROUND ANIMATIONS
======================================== */

@keyframes float-smooth {
    0%, 100% {
        transform: translate(0, 0) rotate(0deg);
    }
    25% {
        transform: translate(10px, -15px) rotate(2deg);
    }
    50% {
        transform: translate(-5px, -25px) rotate(-1deg);
    }
    75% {
        transform: translate(-15px, -10px) rotate(1deg);
    }
}

@keyframes float-delayed {
    0%, 100% {
        transform: translate(0, 0) rotate(0deg) scale(1);
    }
    33% {
        transform: translate(-20px, 15px) rotate(-2deg) scale(1.05);
    }
    66% {
        transform: translate(15px, 20px) rotate(2deg) scale(0.95);
    }
}

@keyframes pulse-glow {
    0%, 100% {
        opacity: 0.3;
        transform: scale(1);
    }
    50% {
        opacity: 0.6;
        transform: scale(1.1);
    }
}

.portfolio-bg-shape {
    animation: float-smooth 25s ease-in-out infinite;
}

.portfolio-bg-shape:nth-child(2) {
    animation: float-delayed 30s ease-in-out infinite;
}

/* ========================================
   TITLE ANIMATIONS
======================================== */

@keyframes title-reveal {
    from {
        opacity: 0;
        transform: translateY(50px) scale(0.9);
        filter: none;
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
        filter: none;
    }
}

.portfolio-title {
    animation: title-reveal 1s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

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

.portfolio-title span {
    background: linear-gradient(90deg, #F9CB5B, #FFD700, #F9CB5B);
    background-size: 200% auto;
    -webkit-background-clip: text;
    background-clip: text;
    animation: gradient-shift 3s ease infinite;
}

/* ========================================
   SEARCH BAR ANIMATIONS
======================================== */

@keyframes search-appear {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

#portfolio-search {
    animation: search-appear 0.8s cubic-bezier(0.16, 1, 0.3, 1) 0.3s backwards;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

#portfolio-search:focus {
    transform: scale(1.02);
    box-shadow: 0 0 0 4px rgba(249, 203, 91, 0.15),
                0 10px 30px rgba(0, 0, 0, 0.3);
}

/* Search icon pulse */
@keyframes search-icon-pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
    }
}

#portfolio-search:focus + svg {
    animation: search-icon-pulse 1s ease-in-out infinite;
}

/* ========================================
   FILTER BUTTONS ANIMATIONS
======================================== */

@keyframes filter-appear {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.8);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.filter-btn {
    animation: filter-appear 0.6s cubic-bezier(0.16, 1, 0.3, 1) backwards;
    position: relative;
    overflow: hidden;
}

.filter-btn:nth-child(1) { animation-delay: 0.4s; }
.filter-btn:nth-child(2) { animation-delay: 0.5s; }
.filter-btn:nth-child(3) { animation-delay: 0.6s; }
.filter-btn:nth-child(4) { animation-delay: 0.7s; }

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

.filter-btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.5);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.filter-btn:active::before {
    width: 300px;
    height: 300px;
    animation: ripple 0.6s ease-out;
}

/* Active filter animation */
@keyframes filter-active {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
    }
    100% {
        transform: scale(1);
    }
}

.filter-btn.active {
    animation: filter-active 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ========================================
   PORTFOLIO ITEMS ANIMATIONS
======================================== */

@keyframes item-appear {
    from {
        opacity: 0;
        transform: translateY(40px) scale(0.9) rotateX(20deg);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1) rotateX(0);
    }
}

.portfolio-item {
    animation: item-appear 0.7s cubic-bezier(0.16, 1, 0.3, 1) backwards;
    transform-origin: center bottom;
}

/* Staggered animation delays */
.portfolio-item:nth-child(1) { animation-delay: 0.1s; }
.portfolio-item:nth-child(2) { animation-delay: 0.15s; }
.portfolio-item:nth-child(3) { animation-delay: 0.2s; }
.portfolio-item:nth-child(4) { animation-delay: 0.25s; }
.portfolio-item:nth-child(5) { animation-delay: 0.3s; }
.portfolio-item:nth-child(6) { animation-delay: 0.35s; }
.portfolio-item:nth-child(7) { animation-delay: 0.4s; }
.portfolio-item:nth-child(8) { animation-delay: 0.45s; }
.portfolio-item:nth-child(9) { animation-delay: 0.12s; }
.portfolio-item:nth-child(10) { animation-delay: 0.17s; }
.portfolio-item:nth-child(11) { animation-delay: 0.22s; }
.portfolio-item:nth-child(12) { animation-delay: 0.27s; }

/* Hover animation */
.portfolio-item {
    transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.portfolio-item:hover {
    transform: translateY(-10px) scale(1.03);
    filter: brightness(1.1);
}

/* Image zoom and rotate on hover */
.portfolio-item img {
    transition: transform 0.7s cubic-bezier(0.4, 0, 0.2, 1);
}

.portfolio-item:hover img {
    transform: scale(1.15) rotate(2deg);
}

/* Overlay slide-up animation */
.portfolio-item .absolute {
    transition: opacity 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.portfolio-item:hover .absolute > div {
    animation: slide-up 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

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

/* Corner accent animation */
.portfolio-item .absolute.top-0 {
    transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ========================================
   LIGHTBOX ANIMATIONS
======================================== */

@keyframes lightbox-fade-in {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes lightbox-scale-in {
    from {
        opacity: 0;
        transform: scale(0.8) translateY(50px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

#lightbox-modal {
    animation: lightbox-fade-in 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

#lightbox-modal .max-w-6xl {
    animation: lightbox-scale-in 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Lightbox image animation */
@keyframes image-reveal {
    from {
        opacity: 0;
        transform: scale(0.95);
        filter: none;
    }
    to {
        opacity: 1;
        transform: scale(1);
        filter: none;
    }
}

#lightbox-image {
    animation: image-reveal 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Lightbox buttons hover */
#lightbox-close,
#lightbox-prev,
#lightbox-next {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

#lightbox-close:hover {
    transform: scale(1.1) rotate(90deg);
    background: rgba(249, 203, 91, 0.9);
}

#lightbox-prev:hover,
#lightbox-next:hover {
    transform: scale(1.15);
    box-shadow: 0 10px 30px rgba(249, 203, 91, 0.4);
}

/* ========================================
   NO RESULTS ANIMATION
======================================== */

@keyframes bounce-in {
    0% {
        opacity: 0;
        transform: scale(0.3) translateY(-100px);
    }
    50% {
        opacity: 1;
        transform: scale(1.05) translateY(10px);
    }
    70% {
        transform: scale(0.9) translateY(-5px);
    }
    100% {
        transform: scale(1) translateY(0);
    }
}

#no-results {
    animation: bounce-in 0.6s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

/* ========================================
   LOADING ANIMATION
======================================== */

@keyframes skeleton-loading {
    0% {
        background-position: -200% 0;
    }
    100% {
        background-position: 200% 0;
    }
}

.skeleton {
    background: linear-gradient(
        90deg,
        rgba(255, 255, 255, 0.05) 25%,
        rgba(255, 255, 255, 0.1) 50%,
        rgba(255, 255, 255, 0.05) 75%
    );
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s ease-in-out infinite;
}

/* ========================================
   COUNTER ANIMATION
======================================== */

@keyframes count-up {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

#results-count {
    animation: count-up 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ========================================
   SCROLL REVEAL ANIMATIONS
======================================== */

@keyframes reveal-from-bottom {
    from {
        opacity: 0;
        transform: translateY(50px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.reveal-on-scroll {
    animation: reveal-from-bottom 0.8s cubic-bezier(0.16, 1, 0.3, 1) backwards;
}

/* ========================================
   PARTICLE EFFECTS
======================================== */

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

.particle {
    position: absolute;
    width: 4px;
    height: 4px;
    background: #F9CB5B;
    border-radius: 50%;
    pointer-events: none;
    animation: particle-float 4s ease-in-out infinite;
}

/* ========================================
   RESPONSIVE ADJUSTMENTS
======================================== */

@media (max-width: 768px) {
    .portfolio-item {
        animation-duration: 0.5s;
    }
    
    .portfolio-item:hover {
        transform: translateY(-5px) scale(1.02);
    }
    
    #lightbox-modal .max-w-6xl {
        animation-duration: 0.3s;
    }
}

/* ========================================
   PERFORMANCE OPTIMIZATIONS
======================================== */

.portfolio-item,
.filter-btn,
#portfolio-search {
    will-change: transform, opacity;
}

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