/* Citra Journal | Category banner image & containment fix v1
   Applies ONLY to the homepage specialist category section.
   Intended to load after existing journal CSS and card-layout-unified.css.
   Each source category poster is ~3:2 (not the very wide old banner ratio).
*/

/* Keep the entire category section, its grid, and inner sliders in bounds. */
.cj-categories-section > .container {
    width: min(1440px, calc(100% - 32px)) !important;
    max-width: 1440px !important;
    box-sizing: border-box;
    margin-inline: auto !important;
}

.cj-categories-section .cj-category-grid {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    align-items: stretch;
    width: 100%;
    min-width: 0;
    max-width: 100%;
    gap: 26px !important;
}

.cj-categories-section .cj-category-block {
    box-sizing: border-box;
    min-width: 0;
    width: 100%;
    max-width: 100%;
    padding: 16px;
    overflow: hidden; /* protect against older 96vw-sized nested sliders */
}

/* Original images are nearly 3:2; preserve the complete image instead of cropping it.
   Use a separate title strip because some image files contain printed lettering. */
.cj-categories-section .cj-category-banner {
    display: flex !important;
    flex-direction: column !important;
    width: 100%;
    min-width: 0;
    max-width: 100%;
    height: auto !important;
    min-height: 0 !important;
    margin-bottom: 16px;
    border-radius: 20px;
    overflow: hidden;
    text-decoration: none;
    background: #e6eef1;
    box-shadow: 0 12px 28px rgba(8, 53, 74, 0.12);
}

.cj-categories-section .cj-category-banner > img {
    display: block !important;
    flex: 0 0 auto;
    width: 100% !important;
    height: auto !important;
    aspect-ratio: 3 / 2;
    object-fit: contain !important;
    object-position: center center !important;
    background: #e6eef1;
    max-width: 100%;
    transform: none !important;
}

/* Remove full-image dark cover: the poster artwork and its own text stay readable. */
.cj-categories-section .cj-category-shade {
    display: none !important;
}

.cj-categories-section .cj-category-content {
    position: relative !important;
    inset: auto !important;
    right: auto !important;
    bottom: auto !important;
    z-index: 1;
    display: flex;
    flex: 0 0 auto;
    flex-wrap: wrap;
    justify-content: flex-start;
    align-items: center;
    gap: 10px 14px;
    box-sizing: border-box;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    min-height: 72px;
    padding: 13px 18px;
    color: #ffffff;
    background: linear-gradient(110deg, #073449, #0e4b5d);
    direction: rtl;
    text-align: right;
}

.cj-categories-section .cj-category-content > span {
    flex: 0 0 auto;
    margin: 0;
    line-height: 1.55;
}

.cj-categories-section .cj-category-content > h3 {
    flex: 1 1 150px;
    min-width: 0;
    margin: 0;
    font-size: clamp(17px, 1.45vw, 23px) !important;
    line-height: 1.65;
    color: #ffffff !important;
    overflow-wrap: anywhere;
}

/* Important: home.css sets .cj-mini-slider-wrap to width:96vw with !important.
   It must fit inside its own category card, not size itself to the viewport. */
.cj-categories-section .cj-category-block .cj-mini-slider-wrap,
.cj-categories-section .cj-category-block .cj-category-post-slider,
.cj-categories-section .cj-category-block .cj-empty-box {
    box-sizing: border-box;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0;
    margin-inline: 0 !important;
}

.cj-categories-section .cj-category-post-slider {
    display: flex;
    gap: 16px !important;
    overflow-x: auto;
    padding: 10px 4px 24px !important;
    scroll-snap-type: x mandatory;
    overscroll-behavior-x: contain;
}

.cj-categories-section .cj-category-post-slider > .cj-post-card {
    flex: 0 0 calc((100% - 16px) / 2) !important;
    min-width: 0;
    max-width: calc((100% - 16px) / 2);
    box-sizing: border-box;
}

.cj-categories-section .cj-category-block .cj-empty-box {
    white-space: normal;
    overflow-wrap: anywhere;
}

/* One-column cards at tablet/mobile sizes, without horizontal overflow. */
@media (max-width: 900px) {
    .cj-categories-section .cj-category-grid {
        grid-template-columns: minmax(0, 1fr) !important;
        gap: 22px !important;
    }
    .cj-categories-section .cj-category-banner {
        margin-bottom: 14px;
    }
    .cj-categories-section .cj-category-content > h3 {
        font-size: clamp(18px, 3vw, 23px) !important;
    }
}

@media (max-width: 520px) {
    .cj-categories-section > .container {
        width: calc(100% - 20px) !important;
    }
    .cj-categories-section .cj-category-block {
        padding: 10px !important;
        border-radius: 18px;
    }
    .cj-categories-section .cj-category-banner {
        border-radius: 14px;
    }
    .cj-categories-section .cj-category-content {
        padding: 10px 12px;
        gap: 6px 10px;
        min-height: 58px;
    }
    .cj-categories-section .cj-category-content > h3 {
        flex-basis: 90px;
        font-size: 18px !important;
    }
    .cj-categories-section .cj-category-post-slider > .cj-post-card {
        flex: 0 0 88% !important;
        max-width: 88%;
    }
}
