/**
 * Thanos Theme - Skeleton Loading
 *
 * Shimmer effect skeleton loaders for better perceived performance
 * @package Thanos_Theme
 */

/* ==========================================================================
   Base Skeleton Styles
   ========================================================================== */

.skeleton {
    position: relative;
    overflow: hidden;
    background: var(--skeleton-base, rgba(255, 255, 255, 0.05));
    border-radius: 4px;
}

.skeleton::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.08),
        transparent
    );
    animation: skeleton-shimmer 1.5s infinite;
}

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

/* Skeleton text variants */
.skeleton-text {
    height: 1em;
    border-radius: 4px;
}

.skeleton-text.skeleton-title {
    height: 1.4em;
    width: 80%;
}

.skeleton-text.skeleton-subtitle {
    height: 0.9em;
    width: 60%;
}

.skeleton-text.skeleton-line {
    height: 0.8em;
    margin-bottom: 8px;
}

.skeleton-text.skeleton-line:last-child {
    width: 40%;
}

/* ==========================================================================
   Video Card Skeleton
   ========================================================================== */

.skeleton-video-card {
    display: flex;
    flex-direction: column;
    background: var(--color-surface, #1a1a2e);
    border-radius: 8px;
    overflow: hidden;
}

.skeleton-video-card .skeleton-thumbnail {
    position: relative;
    width: 100%;
    padding-bottom: 56.25%; /* 16:9 aspect ratio */
    background: var(--skeleton-base, rgba(255, 255, 255, 0.05));
}

.skeleton-video-card .skeleton-thumbnail::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.08),
        transparent
    );
    animation: skeleton-shimmer 1.5s infinite;
}

/* Duration badge skeleton */
.skeleton-video-card .skeleton-duration {
    position: absolute;
    bottom: 8px;
    right: 8px;
    width: 45px;
    height: 20px;
    background: rgba(0, 0, 0, 0.6);
    border-radius: 4px;
}

/* Card content */
.skeleton-video-card .skeleton-content {
    padding: 12px;
}

.skeleton-video-card .skeleton-title {
    height: 16px;
    margin-bottom: 8px;
    background: var(--skeleton-base, rgba(255, 255, 255, 0.08));
}

.skeleton-video-card .skeleton-meta {
    display: flex;
    gap: 8px;
}

.skeleton-video-card .skeleton-meta-item {
    height: 12px;
    width: 60px;
    background: var(--skeleton-base, rgba(255, 255, 255, 0.05));
    border-radius: 3px;
}

/* ==========================================================================
   Video Grid Skeleton
   ========================================================================== */

.skeleton-video-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 20px;
}

@media (min-width: 768px) {
    .skeleton-video-grid {
        grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    }
}

@media (min-width: 1200px) {
    .skeleton-video-grid {
        grid-template-columns: repeat(5, 1fr);
    }
}

/* ==========================================================================
   Video List Skeleton (Horizontal)
   ========================================================================== */

.skeleton-video-list {
    display: flex;
    gap: 16px;
    overflow: hidden;
}

.skeleton-video-list .skeleton-video-card {
    flex: 0 0 200px;
}

@media (min-width: 768px) {
    .skeleton-video-list .skeleton-video-card {
        flex: 0 0 240px;
    }
}

/* ==========================================================================
   Carousel Skeleton
   ========================================================================== */

.skeleton-carousel {
    position: relative;
}

.skeleton-carousel .skeleton-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.skeleton-carousel .skeleton-section-title {
    height: 24px;
    width: 150px;
    background: var(--skeleton-base, rgba(255, 255, 255, 0.08));
    border-radius: 4px;
}

.skeleton-carousel .skeleton-arrows {
    display: flex;
    gap: 8px;
}

.skeleton-carousel .skeleton-arrow {
    width: 36px;
    height: 36px;
    background: var(--skeleton-base, rgba(255, 255, 255, 0.05));
    border-radius: 50%;
}

/* ==========================================================================
   Hero Skeleton
   ========================================================================== */

.skeleton-hero {
    position: relative;
    width: 100%;
    height: 70vh;
    min-height: 400px;
    max-height: 700px;
    background: var(--skeleton-base, rgba(255, 255, 255, 0.03));
    overflow: hidden;
}

.skeleton-hero::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.05),
        transparent
    );
    animation: skeleton-shimmer 2s infinite;
}

.skeleton-hero .skeleton-hero-content {
    position: absolute;
    bottom: 80px;
    left: 40px;
    max-width: 600px;
}

.skeleton-hero .skeleton-hero-title {
    height: 48px;
    width: 400px;
    max-width: 80%;
    margin-bottom: 16px;
    background: var(--skeleton-base, rgba(255, 255, 255, 0.1));
    border-radius: 4px;
}

.skeleton-hero .skeleton-hero-desc {
    height: 20px;
    width: 500px;
    max-width: 90%;
    margin-bottom: 8px;
    background: var(--skeleton-base, rgba(255, 255, 255, 0.08));
    border-radius: 4px;
}

.skeleton-hero .skeleton-hero-desc:last-of-type {
    width: 350px;
    max-width: 70%;
}

.skeleton-hero .skeleton-hero-buttons {
    display: flex;
    gap: 12px;
    margin-top: 24px;
}

.skeleton-hero .skeleton-button {
    width: 140px;
    height: 48px;
    background: var(--skeleton-base, rgba(255, 255, 255, 0.1));
    border-radius: 8px;
}

.skeleton-hero .skeleton-button.primary {
    background: rgba(233, 30, 99, 0.3);
}

/* ==========================================================================
   Player Skeleton
   ========================================================================== */

.skeleton-player {
    position: relative;
    width: 100%;
    padding-bottom: 56.25%;
    background: #000;
    border-radius: 8px;
    overflow: hidden;
}

.skeleton-player .skeleton-player-center {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 80px;
    height: 80px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 50%;
}

.skeleton-player .skeleton-player-controls {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 16px;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.8));
}

.skeleton-player .skeleton-progress {
    height: 4px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 2px;
    margin-bottom: 12px;
}

.skeleton-player .skeleton-controls-bar {
    display: flex;
    justify-content: space-between;
}

.skeleton-player .skeleton-control-group {
    display: flex;
    gap: 12px;
}

.skeleton-player .skeleton-control-btn {
    width: 32px;
    height: 32px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

/* ==========================================================================
   Single Video Info Skeleton
   ========================================================================== */

.skeleton-video-info {
    padding: 20px 0;
}

.skeleton-video-info .skeleton-video-title {
    height: 32px;
    width: 70%;
    margin-bottom: 16px;
    background: var(--skeleton-base, rgba(255, 255, 255, 0.1));
    border-radius: 4px;
}

.skeleton-video-info .skeleton-video-meta {
    display: flex;
    gap: 16px;
    margin-bottom: 20px;
}

.skeleton-video-info .skeleton-meta-tag {
    height: 24px;
    width: 80px;
    background: var(--skeleton-base, rgba(255, 255, 255, 0.08));
    border-radius: 12px;
}

.skeleton-video-info .skeleton-video-desc {
    height: 16px;
    margin-bottom: 8px;
    background: var(--skeleton-base, rgba(255, 255, 255, 0.06));
    border-radius: 4px;
}

.skeleton-video-info .skeleton-video-desc:nth-child(2) {
    width: 90%;
}

.skeleton-video-info .skeleton-video-desc:nth-child(3) {
    width: 75%;
}

.skeleton-video-info .skeleton-video-desc:nth-child(4) {
    width: 50%;
}

/* ==========================================================================
   Category/Actor Card Skeleton
   ========================================================================== */

.skeleton-category-card {
    display: flex;
    align-items: center;
    padding: 16px;
    background: var(--color-surface, #1a1a2e);
    border-radius: 12px;
}

.skeleton-category-card .skeleton-icon {
    width: 48px;
    height: 48px;
    background: var(--skeleton-base, rgba(255, 255, 255, 0.1));
    border-radius: 12px;
    margin-right: 16px;
}

.skeleton-category-card .skeleton-info {
    flex: 1;
}

.skeleton-category-card .skeleton-name {
    height: 18px;
    width: 120px;
    margin-bottom: 6px;
    background: var(--skeleton-base, rgba(255, 255, 255, 0.1));
    border-radius: 4px;
}

.skeleton-category-card .skeleton-count {
    height: 14px;
    width: 60px;
    background: var(--skeleton-base, rgba(255, 255, 255, 0.06));
    border-radius: 3px;
}

/* Actor avatar skeleton */
.skeleton-actor-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 16px;
}

.skeleton-actor-card .skeleton-avatar {
    width: 80px;
    height: 80px;
    background: var(--skeleton-base, rgba(255, 255, 255, 0.1));
    border-radius: 50%;
    margin-bottom: 12px;
}

.skeleton-actor-card .skeleton-name {
    height: 16px;
    width: 100px;
    background: var(--skeleton-base, rgba(255, 255, 255, 0.08));
    border-radius: 4px;
}

/* ==========================================================================
   Comment Skeleton
   ========================================================================== */

.skeleton-comment {
    display: flex;
    gap: 12px;
    padding: 16px 0;
    border-bottom: 1px solid var(--color-border, rgba(255, 255, 255, 0.1));
}

.skeleton-comment .skeleton-avatar {
    width: 40px;
    height: 40px;
    background: var(--skeleton-base, rgba(255, 255, 255, 0.1));
    border-radius: 50%;
    flex-shrink: 0;
}

.skeleton-comment .skeleton-comment-content {
    flex: 1;
}

.skeleton-comment .skeleton-comment-header {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
}

.skeleton-comment .skeleton-author {
    height: 14px;
    width: 100px;
    background: var(--skeleton-base, rgba(255, 255, 255, 0.1));
    border-radius: 3px;
}

.skeleton-comment .skeleton-date {
    height: 14px;
    width: 60px;
    background: var(--skeleton-base, rgba(255, 255, 255, 0.06));
    border-radius: 3px;
}

.skeleton-comment .skeleton-text-line {
    height: 14px;
    margin-bottom: 6px;
    background: var(--skeleton-base, rgba(255, 255, 255, 0.06));
    border-radius: 3px;
}

.skeleton-comment .skeleton-text-line:last-child {
    width: 60%;
}

/* ==========================================================================
   Search Results Skeleton
   ========================================================================== */

.skeleton-search-results {
    padding: 20px;
}

.skeleton-search-results .skeleton-result-header {
    height: 24px;
    width: 200px;
    margin-bottom: 20px;
    background: var(--skeleton-base, rgba(255, 255, 255, 0.1));
    border-radius: 4px;
}

/* ==========================================================================
   Sidebar Skeleton
   ========================================================================== */

.skeleton-sidebar-widget {
    padding: 20px;
    background: var(--color-surface, #1a1a2e);
    border-radius: 12px;
    margin-bottom: 20px;
}

.skeleton-sidebar-widget .skeleton-widget-title {
    height: 20px;
    width: 120px;
    margin-bottom: 16px;
    background: var(--skeleton-base, rgba(255, 255, 255, 0.1));
    border-radius: 4px;
}

.skeleton-sidebar-widget .skeleton-widget-item {
    display: flex;
    gap: 12px;
    margin-bottom: 12px;
}

.skeleton-sidebar-widget .skeleton-item-thumb {
    width: 80px;
    height: 45px;
    background: var(--skeleton-base, rgba(255, 255, 255, 0.08));
    border-radius: 4px;
    flex-shrink: 0;
}

.skeleton-sidebar-widget .skeleton-item-info {
    flex: 1;
}

.skeleton-sidebar-widget .skeleton-item-title {
    height: 14px;
    margin-bottom: 6px;
    background: var(--skeleton-base, rgba(255, 255, 255, 0.08));
    border-radius: 3px;
}

.skeleton-sidebar-widget .skeleton-item-meta {
    height: 12px;
    width: 60px;
    background: var(--skeleton-base, rgba(255, 255, 255, 0.05));
    border-radius: 3px;
}

/* ==========================================================================
   Loading States with Skeleton
   ========================================================================== */

/* Use with JavaScript to show/hide */
.loading-skeleton {
    display: none;
}

.is-loading .loading-skeleton {
    display: block;
}

.is-loading .loaded-content {
    display: none;
}

/* Pulse animation alternative */
.skeleton-pulse {
    animation: skeleton-pulse 1.5s ease-in-out infinite;
}

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

/* ==========================================================================
   Dark/Light mode adjustments
   ========================================================================== */

.dark-mode .skeleton,
.dark-mode .skeleton-thumbnail,
.dark-mode [class*="skeleton-"] {
    --skeleton-base: rgba(255, 255, 255, 0.05);
}

/* Light mode (if implemented) */
@media (prefers-color-scheme: light) {
    body:not(.dark-mode) .skeleton,
    body:not(.dark-mode) .skeleton-thumbnail,
    body:not(.dark-mode) [class*="skeleton-"] {
        --skeleton-base: rgba(0, 0, 0, 0.08);
    }

    body:not(.dark-mode) .skeleton::after {
        background: linear-gradient(
            90deg,
            transparent,
            rgba(255, 255, 255, 0.5),
            transparent
        );
    }
}

/* ==========================================================================
   Reduced motion preference
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
    .skeleton::after,
    .skeleton-thumbnail::after,
    .skeleton-hero::after {
        animation: none;
    }

    .skeleton-pulse {
        animation: none;
    }
}

/* ==========================================================================
   Lazy Loading Image Styles
   ========================================================================== */

/* Base lazy image styles */
img.thanos-lazy {
    opacity: 0;
    transition: opacity 0.3s ease-out, filter 0.3s ease-out;
    will-change: opacity;
}

/* Loading state with blur placeholder */
img.thanos-lazy.loading {
    filter: blur(10px);
    opacity: 0.6;
}

/* Loaded state */
img.thanos-lazy.loaded,
img.loaded {
    opacity: 1;
    filter: none;
}

/* Error state */
img.thanos-lazy.error {
    opacity: 0.5;
    background: var(--skeleton-base, rgba(255, 255, 255, 0.05));
}

/* Image container for aspect ratio */
.thanos-video-thumb {
    position: relative;
    overflow: hidden;
    background: var(--skeleton-base, rgba(255, 255, 255, 0.03));
}

.thanos-video-thumb img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Shimmer effect while loading */
.thanos-video-thumb::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.08),
        transparent
    );
    animation: skeleton-shimmer 1.5s infinite;
    z-index: 1;
    pointer-events: none;
    opacity: 1;
    transition: opacity 0.3s ease;
}

/* Hide shimmer when image is loaded */
.thanos-video-thumb:has(img.loaded)::before {
    opacity: 0;
}

/* Fallback for browsers without :has() support */
.thanos-video-thumb.image-loaded::before {
    opacity: 0;
}

/* WebP indicator classes (set by JavaScript) */
html.webp .thanos-video-thumb img {
    /* WebP supported - images may use WebP format */
}

html.no-webp .thanos-video-thumb img {
    /* WebP not supported - fallback to original format */
}

/* Reduced motion: disable blur transition */
@media (prefers-reduced-motion: reduce) {
    img.thanos-lazy {
        transition: none;
    }

    img.thanos-lazy.loading {
        filter: none;
    }

    .thanos-video-thumb::before {
        animation: none;
        opacity: 0;
    }
}
