/* ==========================================================================
   News Plus Widget — Tirto.id Clone
   Layout: 40:60 Split Desktop
   ========================================================================== */

.newsplus-widget {
    background: #fff;
    padding-top: 14px;
    padding-bottom: 10px;
    margin-top: 22px;
    margin-bottom: 22px;
    font-family: 'Inter', Arial, Roboto, sans-serif;
    box-sizing: border-box;
}

.newsplus-widget *,
.newsplus-widget *::before,
.newsplus-widget *::after {
    box-sizing: border-box;
}

.newsplus-widget-inner {
    max-width: 1033px;
    margin: 0 auto;
    padding: 0 24px;
    width: 100%;
}

/* Header Kiri Kanan */
.newsplus-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 14px;
    padding-bottom: 14px;
    margin-bottom: 20px;
    border-top: 1px solid #2f2f2f;
    border-bottom: 1px dotted #ccc;
}

.newsplus-title-main {
    font-size: 20px;
    font-weight: 700;
    color: #111;
    margin: 0;
    line-height: 1.2;
}

.newsplus-more {
    font-size: 14px;
    color: #2d5bd1;
    text-decoration: none;
    font-weight: 500;
}
.newsplus-more:hover {
    text-decoration: underline;
}

/* ==========================================================================
   LAYOUT GRID UTAMA (Kiri vs Kanan)
   ========================================================================== */
.newsplus-layout {
    display: grid;
    grid-template-columns: minmax(380px, 420px) 1fr;
    gap: 30px;
    align-items: start;
}

/* ==========================================================================
   KIRI: HEADLINE BESAR
   ========================================================================== */
.newsplus-main {
    display: flex;
    flex-direction: column;
    padding-right: 20px; /* Spasi sebelum separator vertikal */
    border-right: 1px solid #f2f2f2; /* Separator Vertikal antara Kiri & Kanan */
}

.newsplus-main-article {
    display: flex;
    flex-direction: column;
}

.newsplus-main-imglink {
    display: block;
    margin-bottom: 12px;
    border-radius: 4px;
    overflow: hidden;
}

.newsplus-main-thumb {
    margin: 0;
    padding: 0;
    line-height: 0;
    background: #f0f0f0;
    aspect-ratio: 16 / 10;
}
.newsplus-main-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.25s ease;
}
.newsplus-main-article:hover .newsplus-main-thumb img {
    transform: scale(1.03);
}

.newsplus-main-content {
    display: flex;
    flex-direction: column;
}

.newsplus-meta {
    display: flex;
    align-items: center;
    margin-bottom: 6px;
    line-height: 1;
}

.newsplus-category {
    font-size: 13px;
    color: #2c5bd0;
    font-weight: 600;
    text-decoration: none;
}
.newsplus-category:hover {
    text-decoration: underline;
}

.newsplus-meta-sep {
    margin: 0 6px;
    color: #ccc;
    font-size: 11px;
}

.newsplus-time {
    font-size: 12px;
    color: #777;
    margin-left: 2px;
}

.newsplus-main-title {
    font-size: 18px;
    font-weight: 700;
    line-height: 1.35;
    color: #111;
    margin: 0 0 8px;
}
.newsplus-main-title a {
    color: inherit;
    text-decoration: none;
    transition: color 0.2s;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.newsplus-main-article:hover .newsplus-main-title a {
    color: #0d47a1;
}

.newsplus-excerpt {
    font-size: 15px;
    color: #444;
    line-height: 1.6;
    margin: 0;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ==========================================================================
   KANAN: GRID BERITA KECIL
   ========================================================================== */
.newsplus-side {
    display: grid;
    row-gap: 20px;
    column-gap: 0;
}

/* Konfigurasi Kolom Dinamis via Class */
.newsplus-side.cols-1 { grid-template-columns: 1fr; }
.newsplus-side.cols-2 { grid-template-columns: 1fr 1fr; }
.newsplus-side.cols-3 { grid-template-columns: 1fr 1fr 1fr; }

/* 
   Border & Gap Simulation untuk Grid Kolom
   Untuk membuat garis pemisah lurus antar kolom seperti tabel
*/

/* --- 2 Kolom --- */
.newsplus-side.cols-2 .newsplus-item:nth-child(even) {
    border-left: 1px solid #f2f2f2;
    padding-left: 12px;
}
.newsplus-side.cols-2 .newsplus-item:nth-child(odd) {
    padding-right: 12px;
}

/* --- 3 Kolom --- */
.newsplus-side.cols-3 .newsplus-item:not(:nth-child(3n+1)) {
    border-left: 1px solid #f2f2f2;
    padding-left: 12px;
}
.newsplus-side.cols-3 .newsplus-item:not(:nth-child(3n)) {
    padding-right: 12px;
}

.newsplus-item {
    display: flex;
    flex-direction: column;
    padding-bottom: 20px;
    border-bottom: 1px solid #f2f2f2;
}

/* Hapus border bawah di baris terakhir agar bersih */
.newsplus-item:last-child {
    border-bottom: none;
    padding-bottom: 0;
}
.newsplus-side.cols-2 .newsplus-item:nth-last-child(-n+2) {
    border-bottom: none;
    padding-bottom: 0;
}
.newsplus-side.cols-3 .newsplus-item:nth-last-child(-n+3) {
    border-bottom: none;
    padding-bottom: 0;
}

.newsplus-item-imglink {
    display: block;
    margin-bottom: 10px;
    border-radius: 4px;
    overflow: hidden;
}

.newsplus-item-thumb {
    margin: 0;
    padding: 0;
    line-height: 0;
    background: #f0f0f0;
    aspect-ratio: 16 / 9;
}
.newsplus-item-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.25s ease;
}
.newsplus-item:hover .newsplus-item-thumb img {
    transform: scale(1.03);
}

.newsplus-item-title {
    font-size: 16px;
    font-weight: 600;
    line-height: 1.35;
    margin: 0 0 6px;
}
.newsplus-item-title a {
    color: #111;
    text-decoration: none;
    transition: color 0.2s;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.newsplus-item:hover .newsplus-item-title a {
    color: #0d47a1;
}

/* ==========================================================================
   RESPONSIVE
   ========================================================================== */

/* Tablet: Layout Vertikal */
@media (max-width: 1024px) {
    .newsplus-layout {
        grid-template-columns: 1fr;
        gap: 30px;
    }
    
    .newsplus-main {
        padding-right: 0;
        border-right: none;
        border-bottom: 1px solid #f2f2f2;
        padding-bottom: 24px;
    }
    
    .newsplus-side.cols-1,
    .newsplus-side.cols-2,
    .newsplus-side.cols-3 {
        grid-template-columns: 1fr 1fr; /* Paksa 2 kolom di tablet */
    }
    
    /* Timpa aturan 3 kolom menjadi 2 kolom untuk border di tablet */
    .newsplus-side.cols-3 .newsplus-item:not(:nth-child(3n+1)) {
        border-left: none;
        padding-left: 0;
    }
    .newsplus-side.cols-3 .newsplus-item:not(:nth-child(3n)) {
        padding-right: 0;
    }
    .newsplus-side.cols-3 .newsplus-item:nth-child(even) {
        border-left: 1px solid #f2f2f2;
        padding-left: 12px;
    }
    .newsplus-side.cols-3 .newsplus-item:nth-child(odd) {
        padding-right: 12px;
    }
}

/* Mobile: Tirto.id Style / Reference Photo Style */
@media (max-width: 768px) {
    /* Thick gray separator for widget */
    .newsplus-widget {
        border-top: 10px solid #f5f5f5 !important;
        border-bottom: 10px solid #f5f5f5 !important;
        margin-top: 0 !important;
        margin-bottom: 0 !important;
        padding-top: 20px !important;
        padding-bottom: 20px !important;
    }
    /* Header & Excerpt Updates */
    .newsplus-header {
        border-top: none !important;
        border-bottom: none !important;
        padding-top: 0;
        margin-bottom: 12px;
    }
    .newsplus-excerpt {
        display: none !important;
    }
    .newsplus-main-title {
        font-size: 16px;
    }
    .newsplus-item-title {
        font-size: 14px;
    }
    
    /* Reduce Gap between Main Post and Grid */
    .newsplus-layout {
        gap: 16px !important;
    }
    .newsplus-main {
        padding-bottom: 12px !important;
        border-bottom: none !important;
    }
    
    /* 2-Row Horizontal Scroll Grid */
    .newsplus-side.cols-1,
    .newsplus-side.cols-2,
    .newsplus-side.cols-3 {
        display: grid !important;
        grid-template-columns: none !important;
        grid-template-rows: repeat(2, auto) !important;
        grid-auto-flow: column !important;
        grid-auto-columns: 88% !important; /* Lebar sesuai foto agar card berikutnya mengintip */
        overflow-x: auto !important;
        scroll-snap-type: x mandatory;
        gap: 12px !important;
        padding-bottom: 10px;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }
    /* Override tablet border/padding rules */
    .newsplus-side.cols-3 .newsplus-item:nth-child(even),
    .newsplus-side.cols-3 .newsplus-item:nth-child(odd),
    .newsplus-side.cols-2 .newsplus-item:nth-child(even),
    .newsplus-side.cols-2 .newsplus-item:nth-child(odd) {
        border-left: none !important;
        padding-left: 0 !important;
        padding-right: 0 !important;
    }
    .newsplus-side::-webkit-scrollbar,
    .newsplus-side.cols-1::-webkit-scrollbar,
    .newsplus-side.cols-2::-webkit-scrollbar,
    .newsplus-side.cols-3::-webkit-scrollbar {
        display: none;
    }
    
    /* Small Cards: Boxed design, image right, text left */
    .newsplus-side .newsplus-item {
        width: 100% !important;
        max-width: none !important;
        scroll-snap-align: start;
        border: 1px solid #e0e0e0 !important;
        border-radius: 8px !important;
        padding: 10px !important;
        display: flex !important;
        flex-direction: row-reverse !important; /* Image on right */
        align-items: flex-start !important; /* Align top for neatness */
        margin: 0 !important;
        box-shadow: 0 2px 4px rgba(0,0,0,0.04) !important;
        height: 100%;
        box-sizing: border-box;
    }
    .newsplus-side .newsplus-item:last-child {
        border-bottom: 1px solid #e0e0e0 !important;
    }
    
    /* Image on the right (square thumbnail) */
    .newsplus-side .newsplus-item-imglink {
        width: 80px;
        height: 80px;
        flex-shrink: 0;
        margin-bottom: 0;
        margin-left: 10px;
    }
    .newsplus-side .newsplus-item-thumb {
        height: 100%;
        border-radius: 6px;
        aspect-ratio: auto;
    }
    .newsplus-side .newsplus-item-thumb img {
        width: 80px;
        height: 80px;
        object-fit: cover;
        border-radius: 6px;
    }
    
    /* Text content on the left */
    .newsplus-side .newsplus-item-content {
        flex: 1;
        display: flex;
        flex-direction: column;
    }
    
    .newsplus-side .newsplus-meta {
        order: -1; /* Pindah kategori & waktu ke atas judul */
        margin-bottom: 4px;
    }
    
    .newsplus-side .newsplus-item-title {
        font-size: 14px;
        font-weight: 700;
        line-height: 1.35;
        margin: 0;
    }
    .newsplus-side .newsplus-item-title a {
        -webkit-line-clamp: 3;
    }
}

