/**
 * SKELETON SCREENS CSS
 * Placeholder loading states for progressive enhancement
 * Creates smooth perceived performance during data loading
 */

/* ============================================
   SHIMMER ANIMATION (Core Loading Effect)
   ============================================ */

@keyframes shimmer {
    0% {
        background-position: -1000px 0;
    }
    50% {
        background-position: 1000px 0;
    }
    100% {
        background-position: 1000px 0;
    }
}

@keyframes pulse {
    0%, 100% {
        opacity: 0.7;
    }
    40%, 60% {
        opacity: 1;
    }
}

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

/* ============================================
   BASE SKELETON ELEMENTS
   ============================================ */

.skeleton {
    background: linear-gradient(
        90deg,
        rgba(var(--color-bg-card-rgb, 26, 31, 58), 0.75) 0%,
        rgba(var(--color-primary-rgb, 139, 127, 255), 0.18) 50%,
        rgba(var(--color-bg-card-rgb, 26, 31, 58), 0.75) 100%
    );
    background-size: 1000px 100%;
    animation: shimmer 2.4s infinite linear;
    border-radius: 8px;
    position: relative;
    overflow: hidden;
    box-shadow: inset 0 1px 2px rgba(147, 112, 219, 0.1);
}

.skeleton::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(
        90deg,
        transparent 0%,
        rgba(var(--color-primary-rgb, 139, 127, 255), 0.12) 50%,
        transparent 100%
    );
    animation: shimmer 2.4s infinite linear;
}

/* ============================================
   SKELETON HEADER
   ============================================ */

.skeleton-header {
    background: rgba(var(--color-bg-card-rgb, 26, 31, 58), 0.95);
    backdrop-filter: blur(30px);
    border-bottom: 1px solid rgba(var(--color-border-primary-rgb, 42, 47, 74), 0.8);
    padding: 0.75rem 2rem;
}

.skeleton-header-container {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 2rem;
}

.skeleton-logo {
    width: 200px;
    height: 36px;
}

.skeleton-nav {
    display: flex;
    gap: 0.5rem;
    flex: 1;
    justify-content: center;
}

.skeleton-nav-item {
    width: 80px;
    height: 36px;
}

.skeleton-actions {
    display: flex;
    gap: 1rem;
}

.skeleton-icon {
    width: 44px;
    height: 44px;
    border-radius: 50%;
}

/* ============================================
   SKELETON USER PROFILE
   ============================================ */

.skeleton-user-profile {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem;
    background: rgba(var(--color-bg-card-rgb, 26, 31, 58), 0.6);
    border-radius: 12px;
}

.skeleton-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
}

.skeleton-user-name {
    width: 100px;
    height: 20px;
}

.skeleton-sign-out-btn {
    width: 80px;
    height: 32px;
    border-radius: 8px;
}

/* ============================================
   SKELETON HERO SECTION
   ============================================ */

.skeleton-hero {
    text-align: center;
    padding: 4rem 2rem 6rem;
}

.skeleton-hero-icon {
    width: 60px;
    height: 60px;
    margin: 0 auto 1rem;
    border-radius: 50%;
}

.skeleton-hero-title {
    width: 400px;
    height: 56px;
    margin: 0 auto 1rem;
    max-width: 90%;
}

.skeleton-hero-subtitle {
    width: 350px;
    height: 40px;
    margin: 0 auto 1.5rem;
    max-width: 80%;
}

.skeleton-hero-description {
    width: 600px;
    height: 24px;
    margin: 0 auto 0.75rem;
    max-width: 90%;
}

.skeleton-hero-description-2 {
    width: 500px;
    height: 24px;
    margin: 0 auto 2.5rem;
    max-width: 80%;
}

.skeleton-hero-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

.skeleton-btn {
    width: 180px;
    height: 50px;
    border-radius: 12px;
}

/* ============================================
   SKELETON MYTHOLOGY GRID
   ============================================ */

.skeleton-mythology-grid {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 2rem 4rem;
}

.skeleton-section-title {
    width: 300px;
    height: 40px;
    margin: 0 auto 3rem;
}

.skeleton-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
}

/* ============================================
   SKELETON MYTHOLOGY CARD
   ============================================ */

.skeleton-mythology-card {
    background: rgba(var(--color-bg-card-rgb, 26, 31, 58), 0.6);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(var(--color-border-primary-rgb, 42, 47, 74), 0.8);
    border-radius: 16px;
    padding: 2rem;
    animation: pulse 2s ease-in-out infinite;
}

.skeleton-card-icon {
    width: 60px;
    height: 60px;
    margin: 0 auto 1rem;
    border-radius: 50%;
}

.skeleton-card-title {
    width: 80%;
    height: 28px;
    margin: 0 auto 0.75rem;
}

.skeleton-card-description {
    width: 100%;
    height: 16px;
    margin-bottom: 0.5rem;
}

.skeleton-card-description-2 {
    width: 90%;
    height: 16px;
    margin: 0 auto 1rem;
}

.skeleton-card-arrow {
    width: 30px;
    height: 30px;
    border-radius: 4px;
}

/* ============================================
   SKELETON GRID CARD (For Entity Lists)
   ============================================ */

.skeleton-grid-card {
    background: rgba(var(--color-bg-card-rgb, 26, 31, 58), 0.8);
    backdrop-filter: blur(10px);
    border: 2px solid rgba(var(--color-border-primary-rgb, 42, 47, 74), 0.8);
    border-radius: 16px;
    padding: 1.5rem;
    animation: pulse 2s ease-in-out infinite;
}

.skeleton-grid-card-icon {
    width: 50px;
    height: 50px;
    margin: 0 auto 1rem;
    border-radius: 8px;
}

.skeleton-grid-card-title {
    width: 70%;
    height: 24px;
    margin: 0 auto 0.5rem;
}

.skeleton-grid-card-badges {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
    margin-bottom: 1rem;
}

.skeleton-badge {
    width: 60px;
    height: 22px;
    border-radius: 20px;
}

.skeleton-grid-card-description {
    width: 100%;
    height: 14px;
    margin-bottom: 0.5rem;
}

.skeleton-grid-card-description-2 {
    width: 90%;
    height: 14px;
    margin: 0 auto 1rem;
}

.skeleton-grid-card-description-3 {
    width: 80%;
    height: 14px;
    margin: 0 auto;
}

/* ============================================
   SKELETON FEATURES SECTION
   ============================================ */

.skeleton-features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 2rem;
    margin-top: 2rem;
}

.skeleton-feature-card {
    background: rgba(var(--color-bg-card-rgb, 26, 31, 58), 0.4);
    border: 1px solid rgba(var(--color-border-primary-rgb, 42, 47, 74), 0.6);
    border-radius: 16px;
    padding: 2rem;
    text-align: center;
    animation: pulse 2s ease-in-out infinite;
}

.skeleton-feature-icon {
    width: 50px;
    height: 50px;
    margin: 0 auto 1rem;
    border-radius: 50%;
}

.skeleton-feature-title {
    width: 60%;
    height: 24px;
    margin: 0 auto 0.75rem;
}

.skeleton-feature-description {
    width: 100%;
    height: 16px;
    margin-bottom: 0.5rem;
}

.skeleton-feature-description-2 {
    width: 80%;
    height: 16px;
    margin: 0 auto;
}

/* ============================================
   LOADING TRANSITIONS (Smooth Replacement)
   ============================================ */

.content-loading {
    opacity: 0;
    animation: fadeIn 0.4s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.content-loaded {
    animation: fadeIn 0.45s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

/* Skeleton fade-out before content appears */
.skeleton-container.fade-out,
.skeleton-loading.fade-out,
.skeleton-mythology-grid.fade-out {
    opacity: 0;
    transform: scale(0.99);
    transition: opacity 0.3s ease-out, transform 0.3s ease-out;
    pointer-events: none;
}

/* Content replacing skeleton */
.content-replacing-skeleton {
    opacity: 0;
    animation: fadeInUp 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) 0.05s forwards;
}

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

/* Stagger animation for grid items */
.skeleton-grid > * {
    animation-delay: calc(var(--item-index, 0) * 0.04s);
}

.skeleton-grid.animating > * {
    opacity: 0;
    animation: fadeIn 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
    animation-delay: calc(var(--item-index, 0) * 0.04s);
}

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

@media (max-width: 768px) {
    .skeleton-header-container {
        flex-wrap: wrap;
        padding: 0.75rem 1rem;
    }

    .skeleton-nav {
        order: 3;
        width: 100%;
        justify-content: flex-start;
    }

    .skeleton-hero {
        padding: 2rem 1rem 3rem;
    }

    .skeleton-hero-title {
        width: 300px;
        height: 48px;
    }

    .skeleton-mythology-grid {
        padding: 0 1rem 2rem;
    }

    .skeleton-grid {
        grid-template-columns: 1fr;
    }

    .skeleton-features-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .skeleton-hero-title {
        width: 250px;
        height: 40px;
    }

    .skeleton-hero-subtitle {
        width: 200px;
        height: 32px;
    }

    .skeleton-hero-actions {
        flex-direction: column;
    }

    .skeleton-btn {
        width: 100%;
    }
}

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

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .skeleton,
    .skeleton::after,
    .skeleton-mythology-card,
    .skeleton-grid-card,
    .skeleton-feature-card {
        animation: none;
    }

    .content-loading,
    .content-loaded {
        animation: none;
        opacity: 1;
    }
}

/* High contrast mode */
@media (prefers-contrast: high) {
    .skeleton {
        border: 2px solid var(--color-border-primary);
    }
}

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

/* Hide real content while showing skeleton */
.loading-skeleton .real-content {
    display: none;
}

/* Show skeleton only during loading */
.loaded .skeleton-screen {
    display: none;
}

/* Prevent layout shift */
.skeleton-preserve-space {
    min-height: inherit;
}

/* Loading states */
[data-loading="true"] {
    pointer-events: none;
    user-select: none;
}

/* ============================================
   SKELETON TEXT LINES (Generic)
   ============================================ */

.skeleton-text {
    height: 16px;
    margin-bottom: 0.5rem;
}

.skeleton-text.large {
    height: 24px;
}

.skeleton-text.small {
    height: 12px;
}

.skeleton-text.full {
    width: 100%;
}

.skeleton-text.half {
    width: 50%;
}

.skeleton-text.quarter {
    width: 25%;
}

.skeleton-text.three-quarter {
    width: 75%;
}
