/**
 * Archive Posts Styles
 * Based on News and Alerts module design with AJAX pagination
 * 
 * @package Clayutility
 * @version 1.0
 */

/* Layout containment */
.page-template-page-posts {
    overflow-x: hidden;
}

/* ===== Archive Posts Container ===== */
.archive-posts,
.featured-posts-grid {
    padding: 80px 0;
}

.archive-posts .news-and-alerts__title,
.featured-posts-grid .news-and-alerts__title {
    font-weight: 700;
    margin: 0 0 100px;
    color: var(--color-black);
    text-align: center;
}

.archive-posts .news-and-alerts__title--centered {
    text-align: center;
}

.news-and-alerts.featured-posts-grid {
    background: var(--color-white);
}

/* ===== Posts Grid ===== */
.archive-posts .news-cards,
.featured-posts-grid .news-cards {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 50px 16px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.archive-posts .news-card,
.featured-posts-grid .news-card {
    display: block;
}

.archive-posts .news-card__article,
.featured-posts-grid .news-card__article {
    background: var(--color-white);
    overflow: visible;
    height: 100%;
    display: flex;
    flex-direction: column;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    border-radius: 20px;
}

.archive-posts .news-card__article:hover,
.featured-posts-grid .news-card__article:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md, 0 4px 8px rgba(0, 0, 0, 0.15));
}

/* ===== Media and Images ===== */
.archive-posts .news-card__media,
.featured-posts-grid .news-card__media {
    position: relative;
}

.archive-posts .news-card__media img,
.featured-posts-grid .news-card__media img {
    width: 100%;
    height: auto;
    display: block;
    border-radius: 20px 20px 0 0;
}

/* Date element - only for archive-posts, not featured-posts-grid */
.archive-posts .news-card__date {
    position: absolute;
    left: 0px;
    top: -30px;
    background: var(--color-magenta);
    color: var(--color-white);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 80px;
    height: auto;
    border-radius: 12px;
    box-shadow: var(--shadow-sm, 0 2px 4px rgba(0, 0, 0, 0.1));
    margin-top: 5px;
    font-weight: 800;
}

.archive-posts .news-card__date strong {
    display: block;
    font-size: 2.5rem;
    line-height: 1.2;
    margin-top: 5px;
}

.archive-posts .news-card__date small {
    display: block;
    font-weight: 700;
    letter-spacing: .3px;
    font-size: 1rem;
    text-transform: uppercase;
    margin-bottom: 5px;
}

/* ===== Card Body ===== */
.archive-posts .news-card__body,
.featured-posts-grid .news-card__body {
    padding: 14px 16px 18px;
    display: grid;
    gap: 8px;
    flex: 1;
}

.archive-posts .news-card__title,
.featured-posts-grid .news-card__title {
    margin: 0;
    font-size: 1.02rem;
    color: var(--color-blue);
    overflow-wrap: anywhere;
    word-break: break-word;
}

.archive-posts .news-card__title a,
.featured-posts-grid .news-card__title a {
    color: inherit;
    text-decoration: none;
    transition: color 0.2s ease;
}

.archive-posts .news-card__title a:hover,
.featured-posts-grid .news-card__title a:hover {
    color: var(--color-magenta);
}

.archive-posts .news-card__excerpt,
.featured-posts-grid .news-card__excerpt {
    margin: 0;
    color: var(--color-gray-600);
    font-size: 0.9rem;
    line-height: 1.4;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.archive-posts .news-card__link,
.featured-posts-grid .news-card__link {
    font-weight: 700;
    color: var(--color-blue);
    text-decoration: none;
    transition: color 0.2s ease;
}

.archive-posts .news-card__link:hover,
.featured-posts-grid .news-card__link:hover {
    color: var(--color-magenta);
}

/* ===== Load More Button ===== */
.archive-posts .news-and-alerts__actions,
.featured-posts-grid .news-and-alerts__actions {
    display: flex;
    justify-content: center;
    margin-top: 80px;
}

.archive-posts .btn,
.featured-posts-grid .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 24px;
    border: none;
    border-radius: 50px;
    font-weight: 700;
    font-size: 1rem;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 160px;
    height: 48px;
}

.archive-posts .btn--primary,
.featured-posts-grid .btn--primary {
    background: var(--color-blue);
    color: var(--color-white);
}

.archive-posts .btn--primary:hover,
.featured-posts-grid .btn--primary:hover {
    background: var(--color-magenta);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md, 0 4px 8px rgba(0, 0, 0, 0.15));
}

.archive-posts .btn--primary:disabled,
.featured-posts-grid .btn--primary:disabled {
    background: var(--color-gray-600);
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.archive-posts .btn-loading,
.featured-posts-grid .btn-loading {
    display: none;
}

.archive-posts .btn.loading .btn-text,
.featured-posts-grid .btn.loading .btn-text {
    display: none;
}

.archive-posts .btn.loading .btn-loading,
.featured-posts-grid .btn.loading .btn-loading {
    display: inline;
}

/* ===== No Posts Found ===== */
.no-posts-found {
    padding: 80px 0;
    text-align: center;
    background: #f8f9fa;
}

.no-posts-found h2 {
    margin: 0 0 16px;
    font-size: 2rem;
    color: var(--ink-900);
}

.no-posts-found p {
    margin: 0;
    font-size: 1.1rem;
    color: var(--ink-500);
}

/* ===== Responsive Design ===== */
@media (max-width: 1366px) {

    .archive-posts .news-cards,
    .featured-posts-grid .news-cards {
        gap: 40px;
    }
}

@media (max-width: 1100px) {

    .archive-posts .news-cards,
    .featured-posts-grid .news-cards {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 680px) {

    .archive-posts .news-cards,
    .featured-posts-grid .news-cards {
        grid-template-columns: 1fr 1fr;
        gap: 40px;
    }
}

@media (max-width: 480px) {

    .archive-posts .news-cards,
    .featured-posts-grid .news-cards {
        grid-template-columns: 1fr;
        gap: 40px;
    }

    .archive-posts,
    .featured-posts-grid {
        padding: 40px 0;
    }

    .archive-posts .news-and-alerts__actions,
    .featured-posts-grid .news-and-alerts__actions {
        margin-top: 30px;
    }
}

/* ===== Loading Animation ===== */
@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

.archive-posts .btn.loading::before,
.featured-posts-grid .btn.loading::before {
    content: '';
    display: inline-block;
    width: 16px;
    height: 16px;
    margin-right: 8px;
    border: 2px solid #fff;
    border-top: 2px solid transparent;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* ===== Fade In Animation for New Posts ===== */
.archive-posts .news-card.fade-in,
.featured-posts-grid .news-card.fade-in {
    animation: fadeInUp 0.5s ease-out;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}