/**
 * Loading Skeleton Styles
 * Shimmer effect for better perceived performance
 *
 * @package Tokutei
 * @since 1.1.0
 */

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

.skeleton {
    background: linear-gradient(
        90deg,
        #f0f0f0 0%,
        #f8f8f8 50%,
        #f0f0f0 100%
    );
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s ease-in-out infinite;
    border-radius: 4px;
    position: relative;
    overflow: hidden;
}

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

/* ==========================================================================
   Skeleton Variants
   ========================================================================== */

/* Text skeleton */
.skeleton-text {
    height: 16px;
    margin-bottom: 8px;
    width: 100%;
}

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

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

.skeleton-text.short {
    width: 80%;
}

.skeleton-text.medium {
    width: 60%;
}

.skeleton-text.tiny {
    width: 40%;
}

/* Heading skeleton */
.skeleton-heading {
    height: 32px;
    width: 60%;
    margin-bottom: 16px;
}

.skeleton-heading.large {
    height: 40px;
    width: 70%;
}

.skeleton-heading.small {
    height: 24px;
    width: 50%;
}

/* Image skeleton */
.skeleton-image {
    aspect-ratio: 16 / 9;
    width: 100%;
}

.skeleton-image.square {
    aspect-ratio: 1 / 1;
}

.skeleton-image.portrait {
    aspect-ratio: 3 / 4;
}

/* Avatar skeleton */
.skeleton-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    flex-shrink: 0;
}

.skeleton-avatar.large {
    width: 64px;
    height: 64px;
}

.skeleton-avatar.small {
    width: 32px;
    height: 32px;
}

/* Button skeleton */
.skeleton-button {
    height: 44px;
    width: 120px;
    border-radius: 4px;
}

.skeleton-button.large {
    height: 56px;
    width: 160px;
}

.skeleton-button.wide {
    width: 200px;
}

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

/* Icon skeleton */
.skeleton-icon {
    width: 24px;
    height: 24px;
    border-radius: 4px;
}

.skeleton-icon.large {
    width: 48px;
    height: 48px;
}

/* Badge/Pill skeleton */
.skeleton-badge {
    height: 24px;
    width: 60px;
    border-radius: 12px;
}

/* ==========================================================================
   Skeleton Card Components
   ========================================================================== */

/* Card skeleton */
.skeleton-card {
    padding: 20px;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    margin-bottom: 20px;
    background: #fff;
}

.skeleton-card .skeleton-image {
    margin-bottom: 16px;
}

.skeleton-card .skeleton-heading {
    margin-bottom: 12px;
}

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

/* Grammar card skeleton */
.skeleton-grammar-card {
    padding: 24px;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    margin-bottom: 20px;
    background: linear-gradient(135deg, #fff5f5 0%, #ffffff 100%);
}

.skeleton-grammar-card .skeleton-header {
    display: flex;
    gap: 12px;
    align-items: center;
    margin-bottom: 16px;
}

.skeleton-grammar-card .skeleton-badge {
    margin-bottom: 12px;
}

/* Post card skeleton */
.skeleton-post-card {
    display: flex;
    flex-direction: column;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    overflow: hidden;
    background: #fff;
}

.skeleton-post-card .skeleton-image {
    margin-bottom: 0;
}

.skeleton-post-card .skeleton-body {
    padding: 16px;
}

/* List item skeleton */
.skeleton-list-item {
    display: flex;
    gap: 16px;
    align-items: center;
    padding: 16px;
    border-bottom: 1px solid #e0e0e0;
}

.skeleton-list-item .skeleton-content {
    flex: 1;
}

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

/* ==========================================================================
   Skeleton Layouts
   ========================================================================== */

/* Grid skeleton */
.skeleton-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 24px;
}

/* List skeleton */
.skeleton-list {
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    overflow: hidden;
    background: #fff;
}

.skeleton-list .skeleton-list-item:last-child {
    border-bottom: none;
}

/* Profile skeleton */
.skeleton-profile {
    display: flex;
    gap: 16px;
    align-items: flex-start;
    padding: 20px;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    background: #fff;
}

.skeleton-profile .skeleton-avatar {
    flex-shrink: 0;
}

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

/* Table row skeleton */
.skeleton-table-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    padding: 16px;
    border-bottom: 1px solid #e0e0e0;
}

.skeleton-table-row .skeleton-text {
    margin-bottom: 0;
}

/* ==========================================================================
   State Classes
   ========================================================================== */

/* Hide actual content when loading */
.skeleton-state .actual-content {
    display: none;
}

/* Show skeleton when loading */
.skeleton-state .skeleton-content {
    display: block;
}

/* Hide skeleton when loaded */
.loaded .skeleton-content {
    display: none;
}

/* Show actual content when loaded */
.loaded .actual-content {
    display: block;
}

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 768px) {
    .skeleton-card {
        padding: 16px;
    }

    .skeleton-grammar-card {
        padding: 16px;
    }

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

    .skeleton-table-row {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .skeleton-list-item {
        padding: 12px;
    }

    .skeleton-heading {
        width: 80%;
    }
}

@media (max-width: 480px) {
    .skeleton-heading {
        width: 100%;
        height: 24px;
    }

    .skeleton-avatar {
        width: 40px;
        height: 40px;
    }

    .skeleton-post-card .skeleton-body {
        padding: 12px;
    }
}

/* ==========================================================================
   Dark Mode Support
   ========================================================================== */

@media (prefers-color-scheme: dark) {
    .skeleton {
        background: linear-gradient(
            90deg,
            #2a2a2a 0%,
            #3a3a3a 50%,
            #2a2a2a 100%
        );
    }

    .skeleton-card,
    .skeleton-post-card,
    .skeleton-list,
    .skeleton-profile {
        background: #1a1a1a;
        border-color: #2d2d2d;
    }

    .skeleton-grammar-card {
        background: linear-gradient(135deg, #2a1a1a 0%, #1a1a1a 100%);
        border-color: #2d2d2d;
    }

    .skeleton-list-item,
    .skeleton-table-row {
        border-color: #2d2d2d;
    }
}

/* ==========================================================================
   Accessibility
   ========================================================================== */

/* Screen reader only text for loading state */
.skeleton-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .skeleton {
        animation: none;
        background: #f0f0f0;
    }

    @media (prefers-color-scheme: dark) {
        .skeleton {
            background: #2a2a2a;
        }
    }
}

/* ==========================================================================
   Print - Hide skeletons
   ========================================================================== */

@media print {
    .skeleton,
    .skeleton-content,
    .skeleton-state {
        display: none !important;
    }

    .actual-content {
        display: block !important;
    }
}
