/* ============================================================
   NearJobs Grid Widget — nearjobs.lk
   Thumbnail: 600×314 | CLS=0 | Mobile Responsive
   ============================================================ */

.nj-grid-section {
    margin-bottom: 2rem;
    contain: layout style;
}

/* Header */
.nj-grid-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 2px solid var(--nj-accent, #2ecc71);
    padding-bottom: 0.5rem;
    margin-bottom: 1rem;
    gap: 1rem;
}

.nj-grid-title {
    font-size: clamp(14px, 2vw, 18px);
    font-weight: 700;
    letter-spacing: 0.03em;
    margin: 0;
}

.nj-view-all {
    font-size: 12px;
    font-weight: 600;
    padding: 5px 14px;
    border-radius: 3px;
    background: var(--nj-accent, #2ecc71);
    color: #fff !important;
    text-decoration: none;
    white-space: nowrap;
    flex-shrink: 0;
    display: inline-block;
}
.nj-view-all:hover {
    opacity: 0.85;
    text-decoration: none;
}

/* Grid */
.nj-grid-posts {
    display: grid;
    gap: 16px;
    grid-template-columns: repeat(var(--nj-cols, 3), minmax(0, 1fr));
}

.nj-cols-2 { --nj-cols: 2; }
.nj-cols-3 { --nj-cols: 3; }
.nj-cols-4 { --nj-cols: 4; }

/* Card */
.nj-post-card {
    border: 1px solid #e5e5e5;
    border-radius: 6px;
    overflow: hidden;
    background: #fff;
}

/* ============================================================
   CLS FIX — 600×314 = 300:157 exact ratio
   Browser ට image load වෙන්නකලින්ම height දෙනවා
   Layout Shift = 0
   ============================================================ */
.nj-thumb-link {
    display: block;
    aspect-ratio: 300 / 157;
    overflow: hidden;
    background: #f3f3f3;
}

.nj-thumb-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    display: block;
}

.nj-thumb-placeholder {
    opacity: 0;
}

/* Post body */
.nj-post-body {
    padding: 10px 12px 12px;
}

.nj-post-title {
    font-size: 13px;
    font-weight: 600;
    line-height: 1.45;
    margin: 0 0 5px;
}

.nj-post-title a {
    color: inherit;
    text-decoration: none;
}
.nj-post-title a:hover {
    color: var(--nj-accent, #2ecc71);
    text-decoration: none;
}

.nj-post-date {
    font-size: 11px;
    color: #777;
    display: block;
}

/* ============================================================
   MOBILE RESPONSIVE
   Desktop: 3col → Tablet: 2col → Mobile: 1col
   ============================================================ */
@media ( max-width: 900px ) {
    .nj-grid-posts { --nj-cols: 2 !important; }
}

@media ( max-width: 600px ) {
    .nj-grid-posts { --nj-cols: 1 !important; }
    .nj-grid-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
}

@media print {
    .nj-view-all { display: none; }
}
