/**
 * Hi-Kataloog™ Loading States & Animations
 * 
 * @package Hi-Kataloog
 * @version 1.3.0
 */

/* ============================================================================
   LAZY IMAGE LOADING
   ============================================================================ */

.hk-lazy-image {
    opacity: 0;
    transition: opacity 0.4s ease-in-out;
}

.hk-lazy-loading {
    opacity: 0.3;
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: hkShimmer 1.5s infinite;
}

.hk-lazy-loaded {
    opacity: 1;
}

.hk-lazy-error {
    opacity: 0.5;
    filter: grayscale(100%);
}

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


/* ============================================================================
   SKELETON SCREENS
   ============================================================================ */

.hk-skeleton-card {
    background: #fff;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.hk-skeleton-thumbnail {
    aspect-ratio: 3/4;
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: hkShimmer 1.5s infinite;
}

.hk-skeleton-content {
    padding: 20px;
}

.hk-skeleton-title,
.hk-skeleton-text {
    height: 16px;
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: hkShimmer 1.5s infinite;
    border-radius: 4px;
    margin-bottom: 12px;
}

.hk-skeleton-title {
    height: 24px;
    width: 80%;
}

.hk-skeleton-text--short {
    width: 60%;
}


/* ============================================================================
   PDF LOADING PROGRESS BAR
   ============================================================================ */

.hk-pdf-progress {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 99999;
    background: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(8px);
    padding: 24px;
    transform: translateY(-100%);
    transition: transform 0.3s ease;
}

.hk-pdf-progress.is-visible {
    transform: translateY(0);
}

.hk-pdf-progress__bar {
    width: 100%;
    max-width: 500px;
    height: 8px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 100px;
    margin: 0 auto 12px;
    overflow: hidden;
}

.hk-pdf-progress__fill {
    height: 100%;
    background: linear-gradient(90deg, #667eea, #764ba2);
    border-radius: 100px;
    transition: width 0.3s ease;
    position: relative;
    overflow: hidden;
}

.hk-pdf-progress__fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
    animation: hkProgressShine 1.5s infinite;
}

@keyframes hkProgressShine {
    0% {
        transform: translateX(-100%);
    }
    100% {
        transform: translateX(100%);
    }
}

.hk-pdf-progress__text {
    text-align: center;
    color: #fff;
    font-size: 14px;
    font-weight: 500;
}


/* ============================================================================
   SEARCH LOADING INDICATOR
   ============================================================================ */

.hk-search-loading {
    position: absolute;
    right: 48px;
    top: 50%;
    transform: translateY(-50%);
    color: #667eea;
    animation: hkRotate 1s linear infinite;
}

.hk-search-loading svg {
    display: block;
}

.hk-search-loading.hk-fade-out {
    opacity: 0;
    transition: opacity 0.2s;
}

@keyframes hkRotate {
    from {
        transform: translateY(-50%) rotate(0deg);
    }
    to {
        transform: translateY(-50%) rotate(360deg);
    }
}


/* ============================================================================
   SCROLL TO TOP BUTTON
   ============================================================================ */

.hk-scroll-top {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: #111;
    color: #fff;
    border: 0;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    opacity: 0;
    transform: translateY(100px) scale(0.8);
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    z-index: 9998;
    display: flex;
    align-items: center;
    justify-content: center;
}

.hk-scroll-top.is-visible {
    opacity: 1;
    transform: translateY(0) scale(1);
}

.hk-scroll-top:hover {
    background: #333;
    transform: translateY(-4px) scale(1.1);
    box-shadow: 0 8px 24px rgba(0,0,0,0.25);
}

.hk-scroll-top:active {
    transform: translateY(-2px) scale(1.05);
}


/* ============================================================================
   CARD ANIMATIONS (Intersection Observer)
   ============================================================================ */

.hk-catalog-card,
.hk-catalog-mini-card,
.hk-product-card {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.6s ease, transform 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.hk-catalog-card.hk-card-visible,
.hk-catalog-mini-card.hk-card-visible,
.hk-product-card.hk-card-visible {
    opacity: 1;
    transform: translateY(0);
}

/* Stagger animation delay for sequential cards */
.hk-catalog-grid .hk-catalog-card:nth-child(1) { transition-delay: 0ms; }
.hk-catalog-grid .hk-catalog-card:nth-child(2) { transition-delay: 50ms; }
.hk-catalog-grid .hk-catalog-card:nth-child(3) { transition-delay: 100ms; }
.hk-catalog-grid .hk-catalog-card:nth-child(4) { transition-delay: 150ms; }
.hk-catalog-grid .hk-catalog-card:nth-child(5) { transition-delay: 200ms; }
.hk-catalog-grid .hk-catalog-card:nth-child(6) { transition-delay: 250ms; }


/* ============================================================================
   LOADING SPINNER (Generic)
   ============================================================================ */

.hk-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(0, 0, 0, 0.1);
    border-top-color: #111;
    border-radius: 50%;
    animation: hkSpin 0.8s linear infinite;
}

.hk-spinner--small {
    width: 20px;
    height: 20px;
    border-width: 2px;
}

.hk-spinner--large {
    width: 60px;
    height: 60px;
    border-width: 6px;
}

@keyframes hkSpin {
    to {
        transform: rotate(360deg);
    }
}


/* ============================================================================
   PULSE ANIMATION (For loading states)
   ============================================================================ */

.hk-pulse {
    animation: hkPulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

@keyframes hkPulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}


/* ============================================================================
   FADE IN ANIMATION
   ============================================================================ */

.hk-fade-in {
    animation: hkFadeIn 0.5s ease forwards;
}

@keyframes hkFadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}


/* ============================================================================
   SLIDE IN ANIMATIONS
   ============================================================================ */

.hk-slide-in-up {
    animation: hkSlideInUp 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

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

.hk-slide-in-left {
    animation: hkSlideInLeft 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

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


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

@media (max-width: 768px) {
    .hk-scroll-top {
        bottom: 16px;
        right: 16px;
        width: 44px;
        height: 44px;
    }
    
    .hk-pdf-progress {
        padding: 16px;
    }
    
    .hk-pdf-progress__text {
        font-size: 13px;
    }
}


/* ============================================================================
   REDUCED MOTION
   ============================================================================ */

@media (prefers-reduced-motion: reduce) {
    .hk-lazy-image,
    .hk-catalog-card,
    .hk-catalog-mini-card,
    .hk-product-card,
    .hk-scroll-top,
    .hk-pdf-progress {
        animation: none;
        transition-duration: 0.01ms !important;
    }
    
    .hk-skeleton-thumbnail,
    .hk-skeleton-title,
    .hk-skeleton-text,
    .hk-pdf-progress__fill::after {
        animation: none;
    }
}
