/*
  App Shell Loader (Airbnb-style skeleton)
  - Included by default from layout templates.
  - Shows a fixed skeleton overlay while App Connect initializes + initial data loads.
  - Hides automatically once the app is "quiet" (no executing serverconnects) to avoid spinner flashes.
*/

:root {
    --app-shell-loader-bg: #f4f4f4;
    --app-shell-skeleton-base: #ebebeb;
    --app-shell-skeleton-highlight: rgba(255, 255, 255, 0.82);
    --app-shell-skeleton-radius: 14px;
    --app-shell-skeleton-gap: 16px;
    --app-shell-skeleton-max-width: 1120px;
}

.app-shell-loader {
    position: fixed;
    inset: 0;
    z-index: 2147483000;
    background: var(--app-shell-loader-bg);
    opacity: 1;
    pointer-events: auto;
}

.app-shell-loader--k12-landing {
    --app-shell-loader-bg: #f4f4f4;
}

.app-shell-loader--k12-search {
    --app-shell-loader-bg: #f4f4f4;
}

.app-shell-loader--hidden {
    opacity: 0;
    pointer-events: none;
    transition: opacity 180ms ease-out;
}

.app-shell-loader__layout {
    height: 100%;
    overflow: hidden;
    display: flex;
    gap: 24px;
    padding: 24px 16px;
    max-width: var(--app-shell-skeleton-max-width);
    margin: 0 auto;
}

.app-shell-loader__sidebar {
    display: none;
    flex: 0 0 72px;
    gap: 14px;
    flex-direction: column;
    padding-top: 8px;
}

.app-shell-loader__main {
    flex: 1;
    min-width: 0;
}

.app-shell-loader__cards {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--app-shell-skeleton-gap);
    margin-top: 24px;
}

.app-shell-loader__skeleton {
    position: relative;
    overflow: hidden;
    background: var(--app-shell-skeleton-base);
    border-radius: var(--app-shell-skeleton-radius);
}

.app-shell-loader__skeleton::after {
    content: '';
    position: absolute;
    inset: 0;
    transform: translateX(-100%);
    background: linear-gradient(90deg, transparent, var(--app-shell-skeleton-highlight), transparent);
    animation: app-shell-shimmer 1.35s ease-in-out infinite;
}

@keyframes app-shell-shimmer {
    100% {
        transform: translateX(100%);
    }
}

.app-shell-loader__title {
    height: 34px;
    width: clamp(220px, 45vw, 420px);
}

.app-shell-loader__subtitle {
    height: 16px;
    width: clamp(160px, 30vw, 260px);
    margin-top: 12px;
    border-radius: 10px;
}

.app-shell-loader__hero {
    margin-top: 26px;
    height: clamp(220px, 40vh, 360px);
    border-radius: 18px;
}

.app-shell-loader__card {
    height: 108px;
}

.app-shell-loader__icon {
    width: 44px;
    height: 44px;
    border-radius: 14px;
}

.app-shell-loader__logo {
    width: 52px;
    height: 52px;
    border-radius: 16px;
    margin-bottom: 6px;
}

@media (min-width: 768px) {
    .app-shell-loader__layout {
        padding: 28px 24px;
    }

    .app-shell-loader__cards {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .app-shell-loader__card {
        height: 120px;
    }
}

@media (min-width: 992px) {
    .app-shell-loader__sidebar {
        display: flex;
    }
}

@media (min-width: 1200px) {
    .app-shell-loader__cards {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

.app-shell-loader--k12-landing .app-shell-loader__landing {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.app-shell-loader--k12-landing .app-shell-loader__landing-row-header {
    display: flex;
    align-items: center;
    gap: 10px;
}

.app-shell-loader--k12-landing .app-shell-loader__landing-row-cards {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 12px;
}

.app-shell-loader--k12-landing .app-shell-loader__landing-card {
    display: grid;
    gap: 10px;
    min-width: 0;
}

.app-shell-loader--k12-landing .app-shell-loader__landing-row-title {
    width: 118px;
    height: 20px;
    border-radius: 10px;
}

.app-shell-loader--k12-landing .app-shell-loader__landing-row-arrow {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    flex: 0 0 auto;
}

.app-shell-loader--k12-landing .app-shell-loader__landing-card-image {
    position: relative;
    height: 126px;
    border-radius: 22px;
}

.app-shell-loader--k12-landing .app-shell-loader__landing-card-heart {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.78);
}

.app-shell-loader--k12-landing .app-shell-loader__landing-card-badge {
    position: absolute;
    top: 10px;
    left: 10px;
    width: 92px;
    height: 18px;
    border-radius: 8px;
    background: rgba(81, 194, 179, 0.84);
}

.app-shell-loader--k12-landing .app-shell-loader__landing-card-body {
    display: grid;
    gap: 8px;
    padding: 0 2px;
}

.app-shell-loader--k12-landing .app-shell-loader__landing-card-title {
    width: 84%;
    height: 14px;
    border-radius: 8px;
}

.app-shell-loader--k12-landing .app-shell-loader__landing-card-meta {
    display: flex;
    align-items: center;
    gap: 8px;
}

.app-shell-loader--k12-landing .app-shell-loader__landing-card-price {
    width: 52%;
    height: 12px;
    border-radius: 8px;
}

.app-shell-loader--k12-landing .app-shell-loader__landing-card-rating {
    width: 22%;
    height: 12px;
    border-radius: 8px;
}

@media (max-width: 949px) {
    .app-shell-loader--k12-landing .app-shell-loader__landing-row-cards {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 16px;
    }

    .app-shell-loader--k12-landing .app-shell-loader__landing-card-image {
        height: 120px;
    }
}

/* ==========================================================================
   Reusable Skeleton Utilities
   - Use for component-level loading states to avoid spinners/text flashes.
   ========================================================================== */

.ai-skeleton {
    position: relative;
    overflow: hidden;
    background: var(--app-shell-skeleton-base);
    border-radius: 12px;
}

.ai-skeleton::after {
    content: '';
    position: absolute;
    inset: 0;
    transform: translateX(-100%);
    background: linear-gradient(90deg, transparent, var(--app-shell-skeleton-highlight), transparent);
    animation: app-shell-shimmer 1.35s ease-in-out infinite;
}

.ai-skeleton--circle {
    border-radius: 999px;
}

.ai-skeleton--line {
    height: 12px;
    border-radius: 10px;
}

.ai-skeleton--square {
    border-radius: 14px;
}
