/* ==========================================================================
   Tirto Weekly Widget — Tirto.id Clone
   Features: Magazine Cover Layout, Full Background Image, Gradient Overlay
   ========================================================================== */

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

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

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

/* ==========================================================================
   HEADER
   ========================================================================== */
.weekly-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 14px;
    padding-bottom: 12px;
    margin-bottom: 18px;
    border-top: 1px solid #2d2d2d;
    border-bottom: 1px dashed #dcdcdc;
    width: 100%;
}

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

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

/* ==========================================================================
   MAGAZINE COVER STYLE (COMMON)
   ========================================================================== */
.weekly-item {
    display: block;
    width: 100%;
}

.weekly-link {
    display: block;
    text-decoration: none;
    position: relative;
    width: 100%;
}

.weekly-cover {
    margin: 0;
    padding: 0;
    position: relative;
    aspect-ratio: 3 / 4;
    border-radius: 2px;
    overflow: hidden;
    background: #222;
}

.weekly-thumb-wrapper {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

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

/* Hover Effect: Zoom Thumbnail only */
.weekly-item:hover .weekly-img {
    transform: scale(1.03);
}

/* Gradient Overlay */
.weekly-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2;
    background: linear-gradient(180deg, rgba(0,0,0,0) 30%, rgba(0,0,0,0.78) 100%);
    pointer-events: none;
}

/* Content Text */
.weekly-content {
    position: absolute;
    left: 18px;
    right: 18px;
    bottom: 18px;
    z-index: 3;
    pointer-events: none;
}

.weekly-title {
    font-size: 15.5px;
    font-weight: 600;
    color: #ffffff;
    line-height: 1.32;
    letter-spacing: -0.15px;
    margin: 0 0 8px 0;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    min-height: 54px; /* Target area */
}

/* Pointer events auto so links can be hovered if needed, but here whole card is link */
.weekly-item:hover .weekly-title {
    text-decoration: underline;
    color: #ffffff;
}

.weekly-period {
    font-size: 13px;
    font-weight: 600;
    color: #ffffff;
    opacity: 0.92;
    line-height: 1.3;
}
.weekly-brand {
    display: inline-block;
    margin-bottom: 2px;
}

/* ==========================================================================
   LAYOUT VARIATIONS
   ========================================================================== */

/* Layout A: Default Grid & Layout B */
.weekly-grid-layout-a,
.weekly-grid-layout-b,
.weekly-grid-layout-d {
    display: grid;
    row-gap: 24px;
    column-gap: 34px;
}

.weekly-wrapper.cols-2 { grid-template-columns: repeat(2, 1fr); }
.weekly-wrapper.cols-3 { grid-template-columns: repeat(3, 1fr); }
.weekly-wrapper.cols-4 { grid-template-columns: repeat(4, 1fr); }

/* Layout C: Slider */
.weekly-grid-layout-c {
    display: flex;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    padding-bottom: 10px;
    scrollbar-width: thin;
    gap: 24px;
}
.weekly-grid-layout-c .weekly-item {
    flex: 0 0 calc((100% - 48px) / 3); /* Assume 3 items, 2 gaps of 24px */
    scroll-snap-align: start;
}
.weekly-wrapper.cols-2.weekly-grid-layout-c .weekly-item { flex: 0 0 calc((100% - 24px) / 2); }
.weekly-wrapper.cols-4.weekly-grid-layout-c .weekly-item { flex: 0 0 calc((100% - 72px) / 4); }


/* Layout D: Large Cover + Small Covers */
.weekly-grid-layout-d.cols-3 {
    grid-template-columns: 2fr 1fr 1fr;
}
.weekly-grid-layout-d .weekly-item:first-child .weekly-title {
    font-size: 22px;
    line-height: 1.4;
}
.weekly-grid-layout-d .weekly-item:first-child .weekly-period {
    font-size: 14px;
}

/* Layout E: Masonry */
.weekly-grid-layout-e {
    column-count: 3;
    column-gap: 24px;
}
.weekly-wrapper.cols-2.weekly-grid-layout-e { column-count: 2; }
.weekly-wrapper.cols-4.weekly-grid-layout-e { column-count: 4; }

.weekly-grid-layout-e .weekly-item {
    break-inside: avoid;
    margin-bottom: 24px;
}

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

@media (max-width: 1024px) {
    .weekly-wrapper.cols-3,
    .weekly-wrapper.cols-4 {
        grid-template-columns: repeat(2, 1fr);
        column-gap: 24px;
    }
    .weekly-grid-layout-c .weekly-item {
        flex: 0 0 calc((100% - 24px) / 2);
    }
    .weekly-grid-layout-d.cols-3 {
        grid-template-columns: repeat(2, 1fr);
    }
    .weekly-grid-layout-d .weekly-item:first-child {
        grid-column: span 2;
    }
    .weekly-grid-layout-e {
        column-count: 2;
    }
}

@media (max-width: 768px) {
    /* Hilangkan garis atas/bawah judul di mobile */
    .weekly-header {
        border-top: none !important;
        border-bottom: none !important;
        padding-top: 0;
        margin-top: 12px;
    }

    /* Margin Widget & Pemisah antar widget (Abu-abu tebal) */
    .weekly-widget {
        margin-top: 8px !important;
        margin-bottom: 8px !important;
        padding-bottom: 16px !important;
        border-bottom: 8px solid #f5f5f5 !important;
    }

    /* Container Slider */
    .weekly-wrapper.cols-2,
    .weekly-wrapper.cols-3,
    .weekly-wrapper.cols-4,
    .weekly-grid-layout-a,
    .weekly-grid-layout-b,
    .weekly-grid-layout-c,
    .weekly-grid-layout-d,
    .weekly-grid-layout-e {
        display: grid !important;
        grid-template-columns: none !important;
        grid-auto-flow: column !important;
        grid-auto-columns: 85% !important; /* Lebar kartu slider */
        overflow-x: auto !important;
        scroll-snap-type: x mandatory;
        gap: 16px !important;
        padding-bottom: 16px !important;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }
    
    .weekly-wrapper::-webkit-scrollbar {
        display: none;
    }

    /* Reset Item */
    .weekly-wrapper .weekly-item {
        scroll-snap-align: start;
        margin: 0 !important;
        padding: 0 !important;
        border: none !important;
        width: 100%;
        display: block !important;
    }

    /* Thumbnail Cover & Lengkungan Kartu */
    .weekly-wrapper .weekly-cover {
        border-radius: 8px !important;
        overflow: hidden;
        aspect-ratio: 3 / 4 !important; /* Bentuk potret sampul majalah */
        background: #111;
        width: 100%;
        height: auto;
    }

    .weekly-wrapper .weekly-title {
        font-size: 16px;
        min-height: 0; /* Bebas min-height */
    }
}
