/* ═══════════════════════════════════════════════════
   Top Stories — Front-End Styles
═══════════════════════════════════════════════════ */

/* ── Variables (injected inline per section) ── */
.ts-section {
    --ts-bg:      #f8f8f8;
    --ts-card:    #ffffff;
    --ts-text:    #111111;
    --ts-meta:    #6b7280;
    --ts-border:  rgba(0,0,0,0.06);
    --ts-accent:  #e11d2e;
    --ts-radius:  12px;
    --ts-imgH:    200px;

    background: var(--ts-bg);
    padding: 32px 0 40px;
    width: 100%;
    box-sizing: border-box;
}

/* ─────────────────────────────────────────
   Header row
───────────────────────────────────────── */
.ts-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    gap: 12px;
}

.ts-heading {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0;
    font-size: 22px;
    font-weight: 800;
    color: var(--ts-text);
    letter-spacing: -0.4px;
    line-height: 1.2;
}

.ts-heading-bar {
    display: inline-block;
    width: 4px;
    height: 1.1em;
    background: var(--ts-accent);
    border-radius: 3px;
    flex-shrink: 0;
}

.ts-view-all {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 13px;
    font-weight: 600;
    color: var(--ts-accent);
    text-decoration: none;
    white-space: nowrap;
    transition: gap 0.2s;
}
.ts-view-all:hover { gap: 8px; }
.ts-view-all svg   { width: 14px; height: 14px; }

/* ─────────────────────────────────────────
   Grid — adapts 1 / 2 / 3 / 4 columns
───────────────────────────────────────── */
.ts-grid {
    display: grid;
    gap: 20px;
    width: 100%;
}

/* 4 columns (default / 4 posts) */
.ts-grid-4 { grid-template-columns: repeat(4, 1fr); }

/* 3 posts: 3 equal columns */
.ts-grid-3 { grid-template-columns: repeat(3, 1fr); }

/* 2 posts: 2 equal columns */
.ts-grid-2 { grid-template-columns: repeat(2, 1fr); }

/* 1 post: single column, max width centred */
.ts-grid-1 {
    grid-template-columns: minmax(0, 480px);
    justify-content: center;
}

/* ─────────────────────────────────────────
   Card
───────────────────────────────────────── */
.ts-card {
    background: var(--ts-card);
    border-radius: var(--ts-radius);
    overflow: hidden;
    border: 1px solid var(--ts-border);
    transition: transform 0.22s ease, box-shadow 0.22s ease;
    display: flex;
    flex-direction: column;
}

.ts-shadow { box-shadow: 0 2px 12px rgba(0,0,0,0.08); }

.ts-hover-lift:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 28px rgba(0,0,0,0.13);
}

.ts-card-link {
    display: flex;
    flex-direction: column;
    height: 100%;
    text-decoration: none;
    color: inherit;
}

/* ─────────────────────────────────────────
   Card image
───────────────────────────────────────── */
.ts-card-image {
    position: relative;
    width: 100%;
    height: var(--ts-imgH);
    overflow: hidden;
    background: #d1d5db;
    flex-shrink: 0;
}

.ts-card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.4s ease;
}
.ts-hover-lift:hover .ts-card-image img { transform: scale(1.04); }

.ts-card-no-image {
    width: 100%; height: 100%;
    display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, #e5e7eb, #d1d5db);
}
.ts-card-no-image svg { width: 40px; height: 40px; color: #9ca3af; opacity: 0.6; }

/* Dark theme placeholder */
.ts-theme-dark .ts-card-no-image {
    background: linear-gradient(135deg, #2d2d2d, #1a1a1a);
}

/* Category badge */
.ts-cat-badge {
    position: absolute;
    top: 12px; left: 12px;
    background: var(--ts-accent);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.8px;
    padding: 3px 8px;
    border-radius: 4px;
    text-transform: uppercase;
    line-height: 1.5;
    pointer-events: none;
}

/* ─────────────────────────────────────────
   Card body
───────────────────────────────────────── */
.ts-card-body {
    padding: 14px 16px 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
}

.ts-card-title {
    margin: 0;
    font-size: 15px;
    font-weight: 700;
    color: var(--ts-text);
    line-height: 1.4;
    /* Clamp to 3 lines */
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.ts-card-excerpt {
    margin: 0;
    font-size: 13px;
    color: var(--ts-meta);
    line-height: 1.55;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.ts-card-date {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    color: var(--ts-meta);
    margin-top: auto;
}
.ts-card-date svg { width: 13px; height: 13px; flex-shrink: 0; }

/* ─────────────────────────────────────────
   No-posts notice
───────────────────────────────────────── */
.ts-no-posts {
    color: #6b7280;
    font-style: italic;
    padding: 16px 0;
}

/* ─────────────────────────────────────────
   Dark theme overrides
───────────────────────────────────────── */
.ts-theme-dark .ts-card {
    border-color: rgba(255,255,255,0.08);
}

/* ─────────────────────────────────────────
   Responsive breakpoints
───────────────────────────────────────── */

/* ≤ 1024px: max 3 columns */
@media (max-width: 1024px) {
    .ts-grid-4 { grid-template-columns: repeat(2, 1fr); }
}

/* ≤ 768px: max 2 columns */
@media (max-width: 768px) {
    .ts-grid-4,
    .ts-grid-3 { grid-template-columns: repeat(2, 1fr); }

    .ts-heading { font-size: 18px; }
}

/* ≤ 540px: single column for all */
@media (max-width: 540px) {
    .ts-grid-4,
    .ts-grid-3,
    .ts-grid-2 { grid-template-columns: 1fr; }

    .ts-card-image { height: 180px; }

    .ts-heading { font-size: 16px; }
    .ts-view-all { font-size: 12px; }
}
