﻿/* =========================================================
   Knowledge Hub — cards, toolbar, grid & list views
   ========================================================= */

/* ---------- Toolbar ---------- */
.kh-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .75rem 1rem;
    margin-bottom: 1.5rem;
}

.kh-view-toggle .btn.active {
    background-color: #0d6efd;
    color: #fff;
    border-color: #0d6efd;
}

.ajax-filters {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
}

.ajax-filters .filter-btn.active {
    background-color: #0d6efd;
    color: #fff;
    border-color: #0d6efd;
}

.kh-tag-filter {
    margin-left: auto;
}

.kh-tag-filter .form-select {
    min-width: 200px;
}

/* ---------- Grid / List containers ---------- */
#ajax-article-container.view-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1.25rem;
}

#ajax-article-container.view-list {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

@media (max-width: 991.98px) {
    #ajax-article-container.view-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 575.98px) {
    #ajax-article-container.view-grid {
        grid-template-columns: 1fr;
    }
}

/* ---------- Card ---------- */
.knowledgehub-card {
    display: flex;
    flex-direction: row;
    align-items: stretch;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: .5rem;
    overflow: hidden;
    height: 100%;
    transition: box-shadow .2s ease, transform .2s ease;
}

.knowledgehub-card:hover {
    box-shadow: 0 .5rem 1rem rgba(0,0,0,.08);
    transform: translateY(-2px);
}

/* Cover — portrait thumbnail */
.kh-cover {
    flex: 0 0 110px;
    max-width: 140px;
    background: #f5f5f5;
    overflow: hidden;
}

.view-list .kh-cover {
    flex: 0 0 180px;
    max-width: 200px;
}

.kh-cover a {
    display: block;
    width: 100%;
    height: 100%;
}

.kh-cover-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* ---------- Cover placeholder (no image → title on orange gradient) ---------- */
.kh-cover-placeholder {
    /* fills the exact same box as a real cover image */
    width: 100%;
    height: 100%;
    min-height: 140px;

    /* centring of the title */
    display: flex;
    align-items: center;
    justify-content: center;
    padding: .65rem;
    text-align: center;

    position: relative;
    overflow: hidden;

    /* warm gradient with #f58220 dominant, plus soft highlights for depth */
    background:
        radial-gradient(circle at 22% 18%,
            rgba(255, 255, 255, .28) 0%,
            rgba(255, 255, 255, 0) 55%),
        radial-gradient(circle at 82% 88%,
            rgba(0, 0, 0, .20) 0%,
            rgba(0, 0, 0, 0) 55%),
        linear-gradient(135deg,
            #f58220 0%,
            #ef760f 35%,
            #e36a0a 65%,
            #c44a00 100%);

    transition: filter .25s ease;
}

/* thin inner frame for a slightly more "designed" look */
.kh-cover-placeholder::after {
    content: "";
    position: absolute;
    inset: 8px;
    border: 1px solid rgba(255, 255, 255, .22);
    border-radius: .25rem;
    pointer-events: none;
}

/* The article title inside the placeholder */
.kh-cover-placeholder .kh-cover-title {
    position: relative;
    z-index: 1;

    color: #fff;
    font-weight: 700;
    font-size: .78rem;
    line-height: 1.25;
    letter-spacing: .01em;

    /* centred both ways */
    text-align: center;

    /* long titles look good on any width */
    overflow-wrap: break-word;
    word-break: break-word;
    hyphens: auto;

    /* cap at 5 lines so it never spills out of the cover box */
    display: -webkit-box;
    -webkit-line-clamp: 5;
    -webkit-box-orient: vertical;
    overflow: hidden;

    /* keeps text readable on the brightest part of the gradient */
    text-shadow: 0 1px 2px rgba(0, 0, 0, .28);
}

/* Larger placeholder title in list view (cover is wider there) */
.view-list .kh-cover-placeholder .kh-cover-title {
    font-size: .95rem;
    -webkit-line-clamp: 6;
}

/* Match the image hover behaviour */
.knowledgehub-card:hover .kh-cover-placeholder {
    filter: brightness(1.06) saturate(1.05);
}






/* Card body */
.kh-body {
    flex: 1;
    min-width: 0;
    padding: .85rem 1rem;
    display: flex;
    flex-direction: column;
    gap: .35rem;
}

.kh-category {
    font-size: .72rem;
    font-weight: 600;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: #0d6efd;
}

.kh-title {
    font-size: 1rem;
    font-weight: 600;
    line-height: 1.3;
    margin: 0;
}

.kh-title a {
    color: #212529;
    text-decoration: none;
}

.kh-title a:hover,
.kh-title a:focus {
    color: #0d6efd;
    text-decoration: underline;
}

.kh-date {
    font-size: .8rem;
    color: #6c757d;
}

.kh-desc {
    font-size: .875rem;
    color: #495057;
    line-height: 1.45;
    flex: 1;             /* pushes download & tags down */
    margin-bottom: 0;
}

.kh-download {
    margin-top: .5rem;
}

.kh-tags {
    display: flex;
    flex-wrap: wrap;
    gap: .25rem;
    margin-top: .25rem;
}

.kh-tags .badge {
    font-size: .7rem;
    font-weight: 500;
    background: #eef2ff;
    color: #3730a3;
}

/* ---------- AJAX loading / pagination ---------- */
.ajax-loading { color: #6c757d; }

#ajax-article-container .pagination {
    margin-top: 1.5rem;
}

/* ---------- Small screens ---------- */
@media (max-width: 575.98px) {
    .knowledgehub-card { flex-direction: row; }
    .kh-cover { flex-basis: 90px; max-width: 90px; }
    .view-list .kh-cover { flex-basis: 110px; max-width: 110px; }
    .kh-tag-filter { margin-left: 0; width: 100%; }
    .kh-tag-filter .form-select { width: 100%; }
}

/* Featured Badge */
.kh-featured-badge {
    display: inline-block;
    background-color: #ffc107; /* Bootstrap warning yellow */
    color: #000;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.15rem 0.4rem;
    border-radius: 0.25rem;
    margin-bottom: 0.25rem;
    align-self: flex-start;
}


/* ---------- CKM: grid view = full first page left, text right, one box ---------- */
#ajax-article-container.view-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1.5rem;
}
#ajax-article-container.view-grid .knowledgehub-card,
#ajax-article-container.view-list .knowledgehub-card {
    flex-direction: row;
    align-items: stretch;
}
#ajax-article-container .kh-cover {
    flex: 0 0 42%;
    max-width: 42%;
    background: #f4f4f4;
    padding: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}
#ajax-article-container.view-list .kh-cover {
    flex: 0 0 220px;
    max-width: 220px;
}
#ajax-article-container .kh-cover a {
    display: block;
    width: 100%;
    height: auto;
}
#ajax-article-container .kh-cover-img {
    width: 100%;
    height: auto;
    aspect-ratio: auto;
    object-fit: contain;
    box-shadow: 0 2px 8px rgba(0,0,0,.18);
    transition: transform .3s ease;
}
#ajax-article-container .knowledgehub-card:hover .kh-cover-img {
    transform: scale(1.02);
}
#ajax-article-container .kh-cover-placeholder {
    aspect-ratio: 1 / 1.414;
}
#ajax-article-container .kh-body {
    padding: 1.1rem 1.25rem;
}
#ajax-article-container .kh-desc {
    display: -webkit-box;
    -webkit-line-clamp: 6;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
@media (max-width: 991.98px) {
    #ajax-article-container.view-grid { grid-template-columns: 1fr; }
}
@media (max-width: 575.98px) {
    #ajax-article-container .knowledgehub-card { flex-direction: row; }
    #ajax-article-container .kh-cover,
    #ajax-article-container.view-list .kh-cover { flex: 0 0 40%; max-width: 40%; padding: 8px; }
}
