/**
 * SmartCMS Block: News Feed - Frontend CSS
 *
 * CSS class structure:
 * .scmsb-news-feed          — wrapper toàn block
 *   .scmsb-chunk            — mỗi cụm theo pattern
 *     .scmsb-item--large    — tin to (L)
 *     .scmsb-item--small    — tin nhỏ (S)
 *       .scmsb-item__thumb  — wrapper ảnh
 *       .scmsb-item__body   — wrapper text (chỉ tin nhỏ)
 *       .scmsb-item__title  — tiêu đề
 *       .scmsb-item__excerpt — tóm tắt
 *       .scmsb-item__meta   — ngày, chuyên mục
 *       .scmsb-item__date   — ngày đăng
 *       .scmsb-item__cat    — tên chuyên mục
 *   .scmsb-sentinel         — trigger lazy load
 *   .scmsb-loader           — spinner khi đang load
 *
 * @package SmartCMS_Post_Organizer
 * @since 2.1.0
 */

/* ─── WRAPPER ──────────────────────────────────────── */

.scmsb-news-feed {
    max-width: 100%;
}

/* ─── CHUNK ────────────────────────────────────────── */

.scmsb-chunk {
    margin-bottom: 0;
}

/* ─── ITEM COMMON ──────────────────────────────────── */

.scmsb-item {
    margin-bottom: 0;
}

.scmsb-item a {
    text-decoration: none;
    color: inherit;
}

.scmsb-item a:hover {
    text-decoration: underline;
}

.scmsb-item__thumb img {
    display: block;
    width: 100%;
    height: auto;
    object-fit: cover;
}

.scmsb-item__title {
    margin: 0;
    padding: 0;
    line-height: 1.4;
}

.scmsb-item__title a {
    color: #1a1a1a;
    font-weight: 700;
}

/* @since 2.2.10 - Force clamp 3 dòng với !important + specificity boost
 * Clamp đặt trên <a> (element chứa text) để không vỡ khi theme set <h3>/<h4> display khác.
 * Selector ghép .scmsb-news-feed ... = specificity cao, khó bị theme override. */
.scmsb-news-feed .scmsb-item__title a,
.scmsb-item__title a.scmsb-item__title-link,
.scmsb-item .scmsb-item__title a {
    display: -webkit-box !important;
    -webkit-box-orient: vertical !important;
    -webkit-line-clamp: 3 !important;
    line-clamp: 3 !important;
    overflow: hidden !important;
    max-height: calc(1.4em * 3) !important;
    text-overflow: ellipsis;
    word-break: break-word;
    overflow-wrap: break-word;
}

.scmsb-item__title a:hover {
    color: #0066cc;
}

.scmsb-item__excerpt {
    margin: 6px 0 0;
    padding: 0;
    color: #555;
    font-size: 14px;
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.scmsb-item__meta {
    margin-top: 6px;
    font-size: 13px;
    color: #888;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.scmsb-item__cat a {
    color: #0066cc;
    font-size: 13px;
}

/* ─── ITEM LARGE (L) ──────────────────────────────── */

.scmsb-item--large {
    margin-bottom: 16px;
}

.scmsb-item--large .scmsb-item__thumb {
    margin-bottom: 10px;
    overflow: hidden;
}

.scmsb-item--large .scmsb-item__thumb img {
    aspect-ratio: 16 / 9;
    transition: transform 0.3s ease;
}

.scmsb-item--large .scmsb-item__thumb:hover img {
    transform: scale(1.03);
}

.scmsb-item--large .scmsb-item__title {
    font-size: 18px;
}

.scmsb-item--large .scmsb-item__excerpt {
    margin: 8px 0 0;
    font-size: 15px;
    -webkit-line-clamp: 2;
    color: #444;
}

/* ─── ITEM SMALL (S) ──────────────────────────────── */

.scmsb-item--small {
    display: flex;
    gap: 14px;
    padding: 14px 0;
    border-top: 1px solid #eee;
    align-items: flex-start;
}

.scmsb-item--small .scmsb-item__thumb {
    flex: 0 0 35%;
    max-width: 35%;
    overflow: hidden;
}

.scmsb-item--small .scmsb-item__thumb img {
    aspect-ratio: 16 / 10;
    border-radius: 4px;
    transition: transform 0.3s ease;
}

.scmsb-item--small .scmsb-item__thumb:hover img {
    transform: scale(1.03);
}

.scmsb-item--small .scmsb-item__body {
    flex: 1;
    min-width: 0;
}

.scmsb-item--small .scmsb-item__title {
    font-size: 15px;
}

/* ─── LAZY LOAD ────────────────────────────────────── */

.scmsb-sentinel {
    height: 1px;
}

/* Sentinel: invisible trigger point for IntersectionObserver */
.scmsb-sentinel {
    height: 1px;
    margin: 0;
    padding: 0;
    border: 0;
    overflow: hidden;
    visibility: hidden;
    pointer-events: none;
}

.scmsb-loader {
    padding: 20px;
    text-align: center;
}

/* Prevent theme adding icons/arrows to these elements */
.scmsb-loader::before,
.scmsb-loader::after,
.scmsb-sentinel::before,
.scmsb-sentinel::after,
.scmsb-load-more-btn::after {
    display: none !important;
    content: none !important;
}

/* Hide Flatsome theme "scroll for more" arrow inside/near news feed */
.scmsb-news-feed .scroll-for-more,
.scmsb-news-feed ~ .scroll-for-more,
.has-scmsb-news-feed .scroll-for-more,
.scroll-for-more {
    display: none !important;
}

.scmsb-spinner {
    display: inline-block;
    width: 24px;
    height: 24px;
    border: 3px solid #eee;
    border-top-color: #0066cc;
    border-radius: 50%;
    animation: scmsb-spin 0.7s linear infinite;
}

@keyframes scmsb-spin {
    to { transform: rotate(360deg); }
}

/* ─── RESPONSIVE ───────────────────────────────────── */

@media (max-width: 480px) {
    .scmsb-item--small .scmsb-item__thumb {
        flex: 0 0 30%;
        max-width: 30%;
    }

    .scmsb-item--large .scmsb-item__title {
        font-size: 16px;
    }

    .scmsb-item--small .scmsb-item__title {
        font-size: 14px;
    }

    .scmsb-item__excerpt {
        font-size: 13px;
        -webkit-line-clamp: 2;
    }
}

/* "Xem thêm" button */
.scmsb-load-more-btn {
    display: block;
    width: 100%;
    max-width: 300px;
    margin: 20px auto;
    padding: 12px 24px;
    font-size: 15px;
    font-weight: 500;
    color: #333;
    background: #f7f7f7;
    border: 1px solid #ddd;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
    text-align: center;
}

.scmsb-load-more-btn:hover {
    background: #eee;
    border-color: #bbb;
}

.scmsb-load-more-btn:active {
    background: #e0e0e0;
}

/* Sentinel + Loader: disable scroll anchoring to prevent jump after lazy load */
.scmsb-sentinel,
.scmsb-loader,
.scmsb-load-more-btn {
    overflow-anchor: none;
}

/* Chunk fade-in animation for lazy-loaded content */
@keyframes scmsb-fade-in {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.scmsb-news-feed > .scmsb-chunk + .scmsb-chunk {
    animation: scmsb-fade-in 0.4s ease both;
}

/* ═══════════════════════════════════════════════════════
   BLOCK: TOP POSTS — Tin Đọc Nhiều
   ═══════════════════════════════════════════════════════ */

.scmsb-top-posts {
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid #122C4B;
    background: #EFF5FC;
    width: 100%;
    height: fit-content;
}

/* Header */
.scmsb-tp__header {
    padding: 10px 16px;
    display: flex;
    align-items: center;
    min-height: 40px;
}

.scmsb-tp__title {
    font-family: 'Oswald', 'Roboto', sans-serif;
    font-weight: 500;
    font-size: 18px;
    line-height: 28px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* List */
.scmsb-tp__list {
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Item */
.scmsb-tp__item {
    display: flex;
    align-items: flex-start;
    gap: 8px;
}

/* Bullet */
.scmsb-tp__bullet {
    flex-shrink: 0;
    color: #0A3161;
    font-size: 10px;
    line-height: 19px;
    width: 14px;
}

/* Number */
.scmsb-tp__number {
    flex-shrink: 0;
    width: 22px;
    height: 22px;
    border-radius: 4px;
    background: #0A3161;
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

/* Link */
.scmsb-tp__link {
    text-decoration: none;
    color: inherit;
    display: block;
}

.scmsb-tp__link:hover .scmsb-tp__item-title {
    color: #0066cc;
}

/* Item title */
.scmsb-tp__item-title {
    font-family: 'Roboto', sans-serif;
    font-weight: 500;
    font-size: 14px;
    line-height: 20px;
    color: #1f2937;
    margin: 0;
    transition: color 0.15s ease;
}

/* @since 2.2.10 - Force clamp 3 dòng với !important + specificity boost
 * để override Flatsome/theme CSS (screenshot cho thấy theme thắng font-family,
 * nên cũng thắng display nếu không !important).
 * Selector ghép .scmsb-top-posts .scmsb-tp__list .scmsb-tp__item-title = specificity 0,3,1 */
.scmsb-top-posts .scmsb-tp__list .scmsb-tp__item-title,
.scmsb-tp__item-title.scmsb-tp__item-title {
    display: -webkit-box !important;
    -webkit-box-orient: vertical !important;
    -webkit-line-clamp: 3 !important;
    line-clamp: 3 !important;
    overflow: hidden !important;
    max-height: calc(20px * 3) !important; /* 60px - fallback nếu -webkit-box bị theme reset */
    text-overflow: ellipsis;
    word-break: break-word;
    overflow-wrap: break-word;
}

/* ─── TOP POSTS RESPONSIVE ──────────────── */
@media (max-width: 480px) {
    .scmsb-tp__item-title {
        font-size: 13px;
        line-height: 18px;
    }
    /* @since 2.2.10 - Responsive max-height override với !important */
    .scmsb-top-posts .scmsb-tp__list .scmsb-tp__item-title,
    .scmsb-tp__item-title.scmsb-tp__item-title {
        max-height: calc(18px * 3) !important; /* 54px */
    }
}
