/* ===================================
   SKELETON LOADERS
   Loading states for better UX
   =================================== */

/* === Base Skeleton === */
.skeleton {
    background: linear-gradient(90deg,
            var(--color-neutral-200) 25%,
            var(--color-neutral-100) 50%,
            var(--color-neutral-200) 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s ease-in-out infinite;
    border-radius: var(--radius-md);
}

@keyframes skeleton-loading {
    0% {
        background-position: 200% 0;
    }

    100% {
        background-position: -200% 0;
    }
}

[data-theme="dark"] .skeleton {
    background: linear-gradient(90deg,
            var(--color-neutral-800) 25%,
            var(--color-neutral-700) 50%,
            var(--color-neutral-800) 75%);
}

/* === Skeleton Variants === */
.skeleton-text {
    height: 1em;
    margin-bottom: 0.5em;
}

.skeleton-text:last-child {
    width: 80%;
}

.skeleton-title {
    height: 2em;
    width: 60%;
    margin-bottom: 1em;
}

.skeleton-avatar {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-full);
}

.skeleton-card {
    padding: var(--space-6);
    border-radius: var(--radius-xl);
}

.skeleton-image {
    width: 100%;
    aspect-ratio: 16 / 9;
}

/* === Skeleton Card Example === */
.skeleton-blog-card {
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
    padding: var(--space-6);
    background: var(--color-neutral-50);
    border-radius: var(--radius-xl);
}

.skeleton-blog-card__image {
    width: 100%;
    height: 200px;
    border-radius: var(--radius-lg);
}

.skeleton-blog-card__title {
    height: 1.5em;
    width: 80%;
}

.skeleton-blog-card__text {
    height: 1em;
}

.skeleton-blog-card__text:nth-child(4) {
    width: 60%;
}

/* === Loading States === */
.loading-state {
    position: relative;
    min-height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--color-neutral-200);
    border-top-color: var(--color-primary-500);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.spinner--small {
    width: 16px;
    height: 16px;
    border-width: 2px;
}

.spinner--large {
    width: 60px;
    height: 60px;
    border-width: 4px;
}

/* === Progress Bar === */
.progress {
    width: 100%;
    height: 4px;
    background: var(--color-neutral-200);
    border-radius: var(--radius-full);
    overflow: hidden;
}

.progress__bar {
    height: 100%;
    background: linear-gradient(90deg,
            var(--color-primary-500),
            var(--color-primary-400));
    transition: width var(--transition-slow);
}

.progress--indeterminate .progress__bar {
    width: 30%;
    animation: progress-indeterminate 1.5s ease-in-out infinite;
}

@keyframes progress-indeterminate {
    0% {
        transform: translateX(-100%);
    }

    100% {
        transform: translateX(400%);
    }
}

/* === Pulse Animation === */
.pulse {
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

/* === Shimmer Effect === */
.shimmer {
    position: relative;
    overflow: hidden;
}

.shimmer::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    background: linear-gradient(90deg,
            transparent,
            rgba(255, 255, 255, 0.4),
            transparent);
    animation: shimmer 2s infinite;
}

@keyframes shimmer {
    0% {
        transform: translateX(-100%);
    }

    100% {
        transform: translateX(100%);
    }
}

/* === Accessibility === */
@media (prefers-reduced-motion: reduce) {

    .skeleton,
    .spinner,
    .progress--indeterminate .progress__bar,
    .pulse,
    .shimmer::after {
        animation: none;
    }

    .skeleton {
        background: var(--color-neutral-200);
    }
}

/* === Screen Reader Only === */
.loading-state__text {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}