/* ==========================================================================
   Latest blog posts — skeleton loaders + dynamically rendered story cards
   Shared by the fa (rtl), ar (rtl) and en (ltr) landing pages.
   Builds on the existing .latest_story / .story_box rules in style.*.css.
   ========================================================================== */

#blog-posts-container {
    --skeleton-base: #EEEBFA;
    --skeleton-shine: rgba(255, 255, 255, .75);
    --story-radius: 10px;
}

/* --------------------------------------------------------------------------
   Media frame
   A fixed 16:9 frame for both the skeleton and the real image, so swapping
   one for the other doesn't move anything below it.
   -------------------------------------------------------------------------- */
#blog-posts-container .story_media,
#blog-posts-container .skeleton-img {
    position: relative;
    display: block;
    aspect-ratio: 16 / 9;
    overflow: hidden;
    border-radius: var(--story-radius) var(--story-radius) 0 0;
    background-color: var(--skeleton-base);
}

/* Safari < 15 and other browsers without aspect-ratio */
@supports not (aspect-ratio: 1 / 1) {
    #blog-posts-container .story_media,
    #blog-posts-container .skeleton-img {
        height: 0;
        padding-top: 56.25%;
    }
}

#blog-posts-container .story_media img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    max-width: none;
    object-fit: cover;
}

/* Post without a featured image (or one that failed to load) */
#blog-posts-container .story_media--fallback {
    background-image: linear-gradient(135deg, var(--light-purple, #F6F4FE) 0%, var(--light-bg, #DFDAF3) 100%);
}

#blog-posts-container .story_media--fallback::before {
    content: "";
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    background: url("/assets/img/logo.svg") center / 22% auto no-repeat;
    opacity: .5;
}

/* The date badge is white for photos; on the light fallback it needs ink */
#blog-posts-container .story_media--fallback + span {
    color: var(--dark-purple, #32236F);
    text-shadow: none;
}

/* --------------------------------------------------------------------------
   Skeleton shimmer
   -------------------------------------------------------------------------- */
.skeleton-box {
    position: relative;
    overflow: hidden;
    background-color: var(--skeleton-base, #EEEBFA);
    border-radius: 6px;
}

.skeleton-box::after {
    content: "";
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    transform: translateX(-100%);
    background-image: linear-gradient(90deg, transparent 0%, var(--skeleton-shine, rgba(255, 255, 255, .75)) 50%, transparent 100%);
    animation: skeleton-shimmer 1.6s ease-in-out infinite;
}

/* The sweep follows reading direction */
[dir="rtl"] .skeleton-box::after {
    transform: translateX(100%);
    animation-name: skeleton-shimmer-rtl;
}

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

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

/* Bars sit on the real card's line boxes (h3 20px / 1.2, p 16px / 2,
   link 14px / 2), sized for a 3-line title and a 3-line excerpt, so the
   row keeps its height when the posts arrive. */
.skeleton-title {
    width: 85%;
    height: 18px;
    margin: 0 auto 6px;
}

.skeleton-title:first-child {
    margin-top: 28px;
}

.skeleton-title + .skeleton-title {
    width: 75%;
}

.skeleton-title + .skeleton-title + .skeleton-title {
    width: 50%;
}

.skeleton-text {
    width: 100%;
    height: 14px;
    margin: 9px auto 18px;
}

.skeleton-title + .skeleton-text {
    margin-top: 25px;
}

.skeleton-text + .skeleton-text {
    width: 94%;
    margin-top: 0;
}

.skeleton-text + .skeleton-text + .skeleton-text {
    width: 68%;
}

.skeleton-link {
    width: 90px;
    height: 14px;
    margin: 42px auto 18px;
}

/* Nunito (en) sets the excerpt and link on shorter line boxes */
html[lang="en"] .skeleton-text {
    height: 12px;
    margin-bottom: 15px;
}

html[lang="en"] .skeleton-link {
    margin: 38px auto 15px;
}

/* --------------------------------------------------------------------------
   Real cards: short fade as they replace the skeletons
   -------------------------------------------------------------------------- */
#blog-posts-container .story_box--enter {
    animation: story-fade-in .35s ease-out both;
}

@keyframes story-fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* --------------------------------------------------------------------------
   Error / empty state
   -------------------------------------------------------------------------- */
#blog-posts-container .blog-status {
    padding: 40px 24px;
    text-align: center;
    color: var(--body-text-purple, #3E3F66);
    background-color: var(--light-purple, #F6F4FE);
    border-radius: var(--story-radius);
}

#blog-posts-container .blog-status p {
    margin: 0;
}

#blog-posts-container .blog-retry {
    margin-top: 12px;
    padding: 4px 8px;
    font: inherit;
    font-size: 15px;
    font-weight: 600;
    color: var(--purple, #6A49F2);
    background: none;
    border: 0;
    border-radius: 4px;
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 4px;
}

#blog-posts-container .blog-retry:hover {
    color: var(--dark-purple, #32236F);
}

#blog-posts-container .blog-retry:focus-visible {
    outline: 2px solid var(--purple, #6A49F2);
    outline-offset: 2px;
}

/* --------------------------------------------------------------------------
   Reduced motion
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
    .skeleton-box::after {
        display: none;
        animation: none;
    }

    #blog-posts-container .story_box--enter {
        animation: none;
    }
}
