/* TailPlay - Skeleton Loading States
 * Provides placeholder animations for better perceived performance
 */

/* ==========================================================================
   SKELETON ANIMATIONS
   ========================================================================== */

@keyframes tp-skeleton-loading {
    0% {
        background-position: -200px 0;
    }
    100% {
        background-position: calc(200px + 100%) 0;
    }
}

@keyframes tp-skeleton-pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

@keyframes tp-skeleton-wave {
    0% {
        transform: translateX(-100%);
    }
    100% {
        transform: translateX(100%);
    }
}

/* ==========================================================================
   SKELETON BASE CLASSES
   ========================================================================== */

.tp-skeleton {
    position: relative;
    overflow: hidden;
    background-color: var(--tp-bg-soft);
}

.tp-skeleton::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.4),
        transparent
    );
    animation: tp-skeleton-wave 1.5s ease-in-out infinite;
}

.tp-skeleton--pulse {
    animation: tp-skeleton-pulse 2s ease-in-out infinite;
}

.tp-skeleton--gradient {
    background: linear-gradient(
        90deg,
        var(--tp-bg-soft) 25%,
        var(--tp-bg) 50%,
        var(--tp-bg-soft) 75%
    );
    background-size: 200% 100%;
    animation: tp-skeleton-loading 1.5s ease-in-out infinite;
}

/* ==========================================================================
   SKELETON COMPONENTS
   ========================================================================== */

/* Product card skeleton */
.tp-product-skeleton {
    background: var(--tp-surface);
    border-radius: var(--tp-radius-lg);
    padding: var(--tp-space-lg);
    box-shadow: var(--tp-shadow);
}

.tp-product-skeleton__image {
    width: 100%;
    aspect-ratio: 1 / 1;
    border-radius: var(--tp-radius);
    margin-bottom: var(--tp-space-md);
}

.tp-product-skeleton__title {
    width: 70%;
    height: 1.5rem;
    border-radius: 4px;
    margin-bottom: var(--tp-space-sm);
}

.tp-product-skeleton__price {
    width: 40%;
    height: 1.25rem;
    border-radius: 4px;
    margin-bottom: var(--tp-space-md);
}

.tp-product-skeleton__button {
    width: 100%;
    height: 2.75rem;
    border-radius: var(--tp-radius);
}

/* Review card skeleton */
.tp-review-skeleton {
    background: var(--tp-surface);
    border-radius: var(--tp-radius-lg);
    padding: var(--tp-space-lg);
    box-shadow: var(--tp-shadow);
    min-width: 300px;
}

.tp-review-skeleton__text {
    width: 100%;
    height: 4rem;
    border-radius: var(--tp-radius);
    margin-bottom: var(--tp-space-md);
}

.tp-review-skeleton__author {
    width: 60%;
    height: 1.25rem;
    border-radius: 4px;
}

/* Article card skeleton */
.tp-article-skeleton {
    background: var(--tp-surface);
    border-radius: var(--tp-radius-lg);
    overflow: hidden;
    box-shadow: var(--tp-shadow);
}

.tp-article-skeleton__image {
    width: 100%;
    aspect-ratio: 16 / 9;
}

.tp-article-skeleton__content {
    padding: var(--tp-space-lg);
}

.tp-article-skeleton__title {
    width: 80%;
    height: 1.5rem;
    border-radius: 4px;
    margin-bottom: var(--tp-space-sm);
}

.tp-article-skeleton__excerpt {
    width: 100%;
    height: 3rem;
    border-radius: var(--tp-radius);
    margin-bottom: var(--tp-space-md);
}

.tp-article-skeleton__meta {
    width: 40%;
    height: 1rem;
    border-radius: 4px;
}

/* Homepage section skeletons */
.tp-home-section-skeleton {
    padding: var(--tp-space-4xl) 0;
}

.tp-home-section-skeleton__header {
    max-width: var(--tp-container);
    margin: 0 auto var(--tp-space-3xl);
    padding: 0 var(--tp-space-lg);
    text-align: center;
}

.tp-home-section-skeleton__title {
    width: 60%;
    height: 2.5rem;
    border-radius: 8px;
    margin: 0 auto var(--tp-space-lg);
}

.tp-home-section-skeleton__description {
    width: 80%;
    height: 1.5rem;
    border-radius: 4px;
    margin: 0 auto;
}

/* ==========================================================================
   SKELETON UTILITIES
   ========================================================================== */

.tp-skeleton-circle {
    border-radius: 50%;
}

.tp-skeleton-rounded {
    border-radius: var(--tp-radius);
}

.tp-skeleton-rounded-lg {
    border-radius: var(--tp-radius-lg);
}

.tp-skeleton-text {
    height: 1em;
    margin-bottom: 0.5em;
}

.tp-skeleton-text:last-child {
    margin-bottom: 0;
}

.tp-skeleton-text--sm {
    height: 0.875em;
}

.tp-skeleton-text--lg {
    height: 1.5em;
}

.tp-skeleton-text--xl {
    height: 2em;
}

.tp-skeleton-line {
    height: 1px;
    background: var(--tp-border);
    margin: var(--tp-space-md) 0;
}

/* ==========================================================================
   LOADING STATES
   ========================================================================== */

.tp-loading {
    cursor: wait;
}

.tp-loading * {
    pointer-events: none;
}

.tp-loading-area {
    position: relative;
}

.tp-loading-area::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.8);
    z-index: 10;
    display: none;
}

.tp-loading-area--active::before {
    display: block;
}

.tp-loading-area--active::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    border: 3px solid var(--tp-border);
    border-top-color: var(--tp-green);
    border-radius: 50%;
    animation: tp-loading-spin 1s linear infinite;
    z-index: 11;
}

@keyframes tp-loading-spin {
    0% {
        transform: translate(-50%, -50%) rotate(0deg);
    }
    100% {
        transform: translate(-50%, -50%) rotate(360deg);
    }
}

/* ==========================================================================
   PROGRESSIVE ENHANCEMENT
   ========================================================================== */

/* Fade-in animation for loaded content */
@keyframes tp-fade-in {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.tp-loaded-content {
    animation: tp-fade-in 0.3s ease-out;
}

/* Staggered animations for lists */
.tp-stagger-item {
    opacity: 0;
    transform: translateY(20px);
    animation: tp-fade-in 0.4s ease-out forwards;
}

.tp-stagger-item:nth-child(1) { animation-delay: 0.1s; }
.tp-stagger-item:nth-child(2) { animation-delay: 0.2s; }
.tp-stagger-item:nth-child(3) { animation-delay: 0.3s; }
.tp-stagger-item:nth-child(4) { animation-delay: 0.4s; }
.tp-stagger-item:nth-child(5) { animation-delay: 0.5s; }
.tp-stagger-item:nth-child(6) { animation-delay: 0.6s; }
.tp-stagger-item:nth-child(7) { animation-delay: 0.7s; }
.tp-stagger-item:nth-child(8) { animation-delay: 0.8s; }
.tp-stagger-item:nth-child(9) { animation-delay: 0.9s; }
.tp-stagger-item:nth-child(10) { animation-delay: 1s; }

/* ==========================================================================
   ACCESSIBILITY
   ========================================================================== */

.tp-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.tp-loading-announcement {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.tp-loading-announcement:focus {
    width: auto;
    height: auto;
    padding: var(--tp-space-sm);
    margin: 0;
    overflow: visible;
    clip: auto;
    white-space: normal;
    background: var(--tp-green);
    color: white;
    z-index: 1000;
}

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

@media (max-width: 768px) {
    .tp-product-skeleton {
        padding: var(--tp-space-md);
    }
    
    .tp-review-skeleton {
        min-width: 280px;
        padding: var(--tp-space-md);
    }
    
    .tp-article-skeleton__content {
        padding: var(--tp-space-md);
    }
    
    .tp-home-section-skeleton {
        padding: var(--tp-space-3xl) 0;
    }
    
    .tp-home-section-skeleton__title {
        width: 80%;
        height: 2rem;
    }
    
    .tp-home-section-skeleton__description {
        width: 90%;
    }
}

@media (prefers-reduced-motion: reduce) {
    .tp-skeleton::after,
    .tp-skeleton--pulse,
    .tp-skeleton--gradient,
    .tp-loaded-content,
    .tp-stagger-item,
    .tp-loading-area--active::after {
        animation: none;
    }
    
    .tp-skeleton {
        background-color: var(--tp-bg-soft);
    }
    
    .tp-skeleton::after {
        display: none;
    }
}