/* ==========================================================================
   Populer Widget — Tirto.id Clone
   Layout: Horizontal Grid (default 5 columns)
   Each card: Thumbnail + Rank Badge + Category + Time + Title
   ========================================================================== */

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

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

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

/* ==========================================================================
   HEADER
   Garis atas dan bawah dipastikan sejajar (width 100%)
   ========================================================================== */
.popular-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 14px;
    padding-bottom: 10px;
    margin-bottom: 18px;
    border-top: 1px solid #2d2d2d;
    border-bottom: 1px dashed #d9d9d9;
    width: 100%;
}

.popular-header-title {
    font-size: 18px;
    font-weight: 700;
    color: #111;
    margin: 0;
    line-height: 1.2;
}

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

/* ==========================================================================
   GRID
   ========================================================================== */
.popular-grid {
    display: grid;
    row-gap: 24px;
    column-gap: 0;
}

/* Kolom Dinamis */
.popular-grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.popular-grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
.popular-grid.cols-5 { grid-template-columns: repeat(5, 1fr); }
.popular-grid.cols-6 { grid-template-columns: repeat(6, 1fr); }

/* ==========================================================================
   CARD ITEM
   ========================================================================== */
.popular-item {
    display: flex;
    flex-direction: column;
    padding: 0 16px;
    border-right: 1px solid #ececec;
}

/* Pertama tanpa padding kiri */
.popular-item:first-child {
    padding-left: 0;
}

/* Terakhir tanpa border kanan & padding kanan */
.popular-item:last-child {
    border-right: none;
    padding-right: 0;
}

/* ==========================================================================
   THUMBNAIL + RANK BADGE
   ========================================================================== */
.popular-item-imglink {
    display: block;
    text-decoration: none;
}

.popular-thumb {
    margin: 0;
    padding: 0;
    line-height: 0;
    position: relative;
    aspect-ratio: 16 / 9;
    border-radius: 2px;
    overflow: hidden;
    border: 1px solid #e5e5e5;
    background: #f0f0f0;
}

.popular-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.25s ease;
}

.popular-item:hover .popular-thumb img {
    transform: scale(1.03);
}

/* Ranking Badge — Di dalam gambar, kiri bawah */
.popular-rank {
    position: absolute;
    bottom: 8px;
    left: 8px;
    width: 36px;
    height: 36px;
    background: #2557d6;
    color: #ffffff;
    font-family: 'Inter', sans-serif;
    font-size: 18px;
    font-weight: 700;
    border-radius: 50%;
    border: 3px solid #ffffff;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.18);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
}

/* ==========================================================================
   CONTENT (Meta + Title)
   ========================================================================== */
.popular-item-content {
    display: flex;
    flex-direction: column;
    margin-top: 10px; /* Jarak thumbnail ke metadata */
}

.popular-meta {
    display: flex;
    align-items: center;
    line-height: 1;
    margin-bottom: 6px; /* Jarak metadata ke judul */
}

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

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

.popular-time {
    font-size: 12px;
    color: #777;
}

.popular-title {
    font-size: 14px;
    font-weight: 600;
    line-height: 1.29;
    letter-spacing: -0.15px;
    margin: 0;
    max-height: 54px;
    overflow: hidden;
}
.popular-title a {
    color: #111;
    text-decoration: none;
    transition: color 0.2s;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.popular-item:hover .popular-title a {
    color: #0d47a1;
}

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

@media (max-width: 1024px) {
    .popular-grid.cols-4,
    .popular-grid.cols-5,
    .popular-grid.cols-6 {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .popular-item:nth-child(3n) {
        border-right: none;
        padding-right: 0;
    }
}

@media (max-width: 768px) {
    .popular-widget {
        margin-top: 0;
        margin-bottom: 0;
        border-top: 8px solid #f2f2f2;
        border-bottom: 8px solid #f2f2f2;
        padding-top: 6px;
        padding-bottom: 0;
    }
    .popular-header {
        border-top: none !important;
        border-bottom: none !important;
        padding-top: 0;
        margin-bottom: 8px;
    }
    .popular-more {
        display: none !important;
    }
    .popular-widget-inner {
        padding: 0 16px 8px;
        overflow: hidden;
    }
    .popular-grid,
    .popular-grid.cols-3,
    .popular-grid.cols-4,
    .popular-grid.cols-5,
    .popular-grid.cols-6 {
        display: flex !important;
        flex-direction: row !important;
        flex-wrap: nowrap !important;
        overflow-x: auto !important;
        scroll-snap-type: x mandatory;
        gap: 12px;
        padding-bottom: 15px;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }
    .popular-grid::-webkit-scrollbar {
        display: none;
    }
    .popular-item {
        flex: 0 0 75% !important;
        width: 75% !important;
        max-width: 75% !important;
        flex-shrink: 0 !important;
        scroll-snap-align: center;
        border: 1px solid #eaeaea !important;
        border-radius: 6px;
        padding: 0 !important;
        box-shadow: 0 2px 6px rgba(0,0,0,0.05);
        display: flex !important;
        flex-direction: column !important;
    }
    .popular-item:first-child,
    .popular-item:nth-child(2n),
    .popular-item:nth-child(3n),
    .popular-item:last-child {
        padding: 0 !important;
        border-right: 1px solid #eaeaea !important;
    }
    .popular-item-content {
        padding: 10px 12px 12px;
    }
    .popular-thumb {
        border-radius: 6px 6px 0 0;
        overflow: hidden;
    }
    .popular-title {
        font-size: 14px;
        -webkit-line-clamp: 3;
    }
    .popular-header-title {
        font-size: 16px;
    }
}

@media (max-width: 480px) {
    .popular-widget-inner {
        padding: 12px 0 16px 16px;
    }
    .popular-item {
        flex: 0 0 80% !important;
        width: 80% !important;
        max-width: 80% !important;
    }
}
