/**
 * KFM CATE - related posts grid.
 * Fallback colours are injected inline by the plugin and shared with the
 * listing layout.
 */

:root {
    --kfmc-accent: var(--nv-primary-accent, #1a4fa0);
    --kfmc-fallback-bg: #000000;
    --kfmc-fallback-color: #2ecc71;
}

.rp-related-posts-section {
    margin: 40px 0 60px;
    padding: 0;
    font-family: inherit;
    clear: both;
}

.rp-section-title {
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #111;
    margin: 0 0 24px;
    padding-bottom: 0;
    border: none;
}

/* ---------- Grid ---------- */
.rp-grid {
    display: grid;
    gap: 32px 24px;
}

.rp-grid.rp-col-1 { grid-template-columns: 1fr; }
.rp-grid.rp-col-2 { grid-template-columns: repeat(2, 1fr); }
.rp-grid.rp-col-3 { grid-template-columns: repeat(3, 1fr); }
.rp-grid.rp-col-4 { grid-template-columns: repeat(4, 1fr); }

/* ---------- Card ---------- */
.rp-card {
    display: flex;
    flex-direction: column;
    border-bottom: 1px solid #e0e0e0;
    padding-bottom: 28px;
}

.rp-card-image-link {
    display: block;
    text-decoration: none;
}

.rp-card-image {
    width: 100%;
    aspect-ratio: 16 / 9;
    overflow: hidden;
    border-radius: 4px;
    background: #e8edf2;
    margin-bottom: 16px;
    position: relative;
}

.rp-card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.35s ease;
}

.rp-card-image-link:hover .rp-card-image img {
    transform: scale(1.04);
}

/* ---------- No featured image: title on a solid panel ---------- */
.rp-card-image-empty {
    background: var(--kfmc-fallback-bg, #000);
}

.rp-card-image-empty .kfmc-fallback-inner {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    padding: 14px;
    box-sizing: border-box;
    text-align: center;
}

.rp-card-image-empty .kfmc-fallback-text {
    display: -webkit-box;
    -webkit-line-clamp: 4;
    line-clamp: 4;
    -webkit-box-orient: vertical;
    overflow: hidden;
    color: var(--kfmc-fallback-color, #2ecc71);
    font-size: 15px;
    font-weight: 700;
    line-height: 1.25;
    letter-spacing: .2px;
    word-break: break-word;
}

/* ---------- Card body ---------- */
.rp-card-body {
    display: flex;
    flex-direction: column;
    flex: 1;
}

.rp-card-title {
    font-size: 17px;
    font-weight: 700;
    line-height: 1.35;
    margin: 0 0 10px;
    border: none;
    padding: 0;
}

.rp-card-title a {
    color: var(--kfmc-accent, #1a4fa0);
    text-decoration: none;
}

.rp-card-title a:hover {
    color: #0d3070;
    text-decoration: underline;
}

.rp-card-excerpt {
    font-size: 14px;
    line-height: 1.6;
    color: #444;
    margin: 0 0 16px;
    flex: 1;
}

.rp-card-button {
    display: inline-block;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--kfmc-accent, #1a4fa0);
    text-decoration: none;
    margin-top: auto;
    padding: 0;
    border: none;
    background: none;
    cursor: pointer;
    transition: color 0.2s ease;
}

.rp-card-button:hover {
    color: #0d3070;
    text-decoration: underline;
}

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
    .rp-grid.rp-col-3,
    .rp-grid.rp-col-4 {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 560px) {
    .rp-grid.rp-col-2,
    .rp-grid.rp-col-3,
    .rp-grid.rp-col-4 {
        grid-template-columns: 1fr;
    }

    .rp-card-image-empty .kfmc-fallback-text {
        -webkit-line-clamp: 3;
        line-clamp: 3;
        font-size: 13px;
    }
}
