/* ==========================================================================
   Knowledge Center page
   Colour badge, topic pills, search, compact filters, results row + sort.
   Loaded via phi/knowledge-center (attached from the knowledge_center view,
   bubbles page-wide so it also styles the facet + search blocks that sit
   alongside the view in the layout). Mirrors css/news.css.
   ========================================================================== */

/* --- Colour-coded category badge (top-left of each card image) ------------ */
.view-id-knowledge_center .views-row {
    position: relative;
}
.kc-cat-badge {
    position: absolute;
    top: 12px;
    left: 12px;
    z-index: 3;
    display: inline-block;
    padding: 4px 10px;
    border-radius: 6px;
    font-family: var(--display-font);
    font-size: 0.75rem;
    font-weight: 400;
    line-height: 1.2;
    color: #fff;
    letter-spacing: 0.01em;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.18);
    white-space: nowrap;
}
.kc-cat-badge a,
.kc-cat-badge a:hover {
    color: #fff;
    border-bottom: none;
    text-decoration: none;
}

/* ==========================================================================
   Filter bar — search (left) + topic pills + compact Filters (right)
   ========================================================================== */
.kc-filter-bar {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 12px 16px;
    padding: 0.25rem 0;
}

/* Search sits first in the mockup, then the pills take the remaining room. */
.kc-filter-bar .views-exposed-form {
    order: 0;
    flex: 0 0 auto;
    margin: 0;
    padding: 0;
    background: none;
}
.kc-filter-bar .views-exposed-form .form--inline,
.kc-filter-bar .views-exposed-form form {
    display: flex;
    align-items: center;
    gap: 0;
    margin: 0;
}
.kc-filter-bar .views-exposed-form label,
.kc-filter-bar .views-exposed-form .block-title {
    display: none;
}
.kc-filter-bar .views-exposed-form .form-item {
    margin: 0;
    position: relative;
}
.kc-filter-bar .views-exposed-form input[type="text"],
.kc-filter-bar .views-exposed-form input.form-text {
    height: 44px;
    padding: 0 14px 0 40px;
    border: 1px solid var(--phi-gray-200);
    border-radius: 999px;
    background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%23a0a3a7' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'/%3E%3C/svg%3E") no-repeat 14px center;
    font-size: 0.9375rem;
    color: var(--phi-dark);
}
/* Fixed width so the pills keep to one row. Higher specificity than the
   theme's `.filterssearch ... input[type="text"] {width:100%}` in global.css
   (same-specificity rule that loads later). */
/* Collapsed by default: just the magnifier. Expands on click, and stays
   expanded whenever the box holds a term so the user can see what they
   searched for (.is-open is set by knowledge-center.js). */
.kc-filter-bar .views-exposed-form input.form-text.form-control {
    width: 44px;
    max-width: 34vw;
    padding-left: 40px;
    cursor: pointer;
    transition: width 0.28s var(--ease);
}
.kc-filter-bar .views-exposed-form.is-open input.form-text.form-control {
    width: 260px;
    cursor: text;
}
.kc-filter-bar .views-exposed-form input[type="text"]:focus {
    outline: none;
    border-color: var(--phi-orange);
    box-shadow: 0 0 0 3px rgba(245, 120, 32, 0.15);
}
/* The exposed form's submit is redundant (Enter / auto-submit). */
.kc-filter-bar .views-exposed-form .form-actions,
.kc-filter-bar .views-exposed-form button[type="submit"],
.kc-filter-bar .views-exposed-form input[type="submit"] {
    display: none;
}

/* Topic pills. */
.kc-filter-bar .kc-cat-pills {
    order: 1;
    flex: 1 1 auto;
    min-width: 0;
    margin: 0;
}
.kc-filter-bar .kc-cat-pills h2,
.kc-filter-bar .kc-cat-pills h3,
.kc-filter-bar .kc-cat-pills .facets-widget__title {
    display: none;
}
.kc-cat-pills ul {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 0;
    padding: 0;
    list-style: none;
}
.kc-cat-pills li {
    margin: 0;
    list-style: none;
}
.kc-cat-pills li a {
    display: inline-block;
    padding: 8px 18px;
    border: 1px solid var(--phi-gray-200);
    border-radius: 999px;
    background: #fff;
    color: var(--phi-gray-800);
    font-family: var(--display-font);
    font-size: 0.875rem;
    font-weight: 600;
    line-height: 1.2;
    text-decoration: none;
    border-bottom: 1px solid var(--phi-gray-200);
    transition: all 0.15s var(--ease);
    white-space: nowrap;
}
.kc-cat-pills li a:hover {
    border-color: var(--phi-orange);
    color: var(--phi-orange);
}
.kc-cat-pills li.facet-item--active a,
.kc-cat-pills li a.is-active,
.kc-cat-pills li.is-active a,
.kc-cat-pills li a.facet-item--active {
    background: var(--phi-orange);
    border-color: var(--phi-orange);
    color: #fff;
}
.kc-cat-pills li a .facet-item__count,
.kc-cat-pills li a .facet-item__status {
    display: none;
}

/* Compact "Filters" dropdown (Category + Date). */
.kc-filters-dd {
    order: 2;
    position: relative;
    flex: 0 0 auto;
}
.kc-filters-toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 44px;
    padding: 0 16px;
    border: 1px solid var(--phi-gray-200);
    border-radius: 999px;
    background: #fff;
    color: var(--phi-gray-800);
    font-family: var(--display-font);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
}
.kc-filters-toggle:hover {
    border-color: var(--phi-orange);
    color: var(--phi-orange);
}
.kc-filters-caret {
    width: 0;
    height: 0;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-top: 5px solid currentColor;
}
.kc-filters-panel {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    z-index: 20;
    /* Explicit width: the selects inside are width:100%, and a percentage
       width inside a shrink-to-fit absolutely-positioned box makes it expand
       to the whole containing block. */
    width: 260px;
    padding: 1rem;
    background: #fff;
    border: 1px solid var(--phi-gray-200);
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.10);
}
.kc-filters-panel .block {
    margin: 0 0 0.85rem;
}
.kc-filters-panel .block:last-child {
    margin-bottom: 0;
}
.kc-filters-panel select {
    width: 100%;
    height: 40px;
    border: 1px solid var(--phi-gray-200);
    border-radius: 8px;
    padding: 0 10px;
    background: #fff;
}

/* ==========================================================================
   Results row — "Showing N Articles" + Sort by
   ========================================================================== */
.view-knowledge-center .view-header.kc-results-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin: 0 0 1.5rem;
    font-size: 0.9375rem;
    color: var(--phi-gray-600);
}
.view-knowledge-center .view-header.kc-results-row strong {
    color: var(--phi-dark);
    font-weight: 700;
}
/* Plain text flow — NOT a flex container. Views renders the summary as bare
   text nodes around a <strong>, and flex would make each one its own item,
   spacing out "Showing / 12 / Articles". */
.kc-results-summary {
    display: block;
}

/* "Reset Filters" — mirrors .products-reset, and sits in the filter bar after
   the Filters button. Uses .orange-link for the colour and type; this only
   drops that class's trailing arrow and sizes the leading icon. !important
   because .orange-link's ::after rule lives in custom-classes.css, which loads
   later and would win the specificity tie. */
.kc-filter-bar .kc-reset {
    order: 3;
    flex: 0 0 auto;
}
.kc-reset::after { content: none !important; }
.kc-reset svg {
    width: 1em;
    height: 1em;
    flex-shrink: 0;
}
.kc-reset[hidden] { display: none; }
.kc-sort {
    display: flex;
    align-items: center;
    gap: 10px;
}
.kc-sort__label {
    color: var(--phi-gray-600);
    white-space: nowrap;
}
.kc-sort .form-item {
    margin: 0;
}
.kc-sort label {
    display: none;
}
/* Only one sort field is exposed, so its "Sort by" select offers a single
   choice and is noise — the direction select carries the real labels
   ("Most Recent" / "Oldest First"). */
.kc-sort .form-item-sort-by {
    display: none;
}
.kc-sort select {
    height: 40px;
    padding: 0 32px 0 12px;
    border: 1px solid var(--phi-gray-200);
    border-radius: 8px;
    background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%235f6368' stroke-width='2.5' stroke-linecap='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E") no-repeat right 12px center;
    -webkit-appearance: none;
    appearance: none;
    font-family: var(--display-font);
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--phi-dark);
    cursor: pointer;
}
.kc-sort select:focus {
    outline: none;
    border-color: var(--phi-orange);
}

/* ==========================================================================
   Responsive
   ========================================================================== */
@media (max-width: 992px) {
    .kc-filter-bar {
        flex-wrap: wrap;
    }
    .kc-filter-bar .views-exposed-form {
        order: 0;
        flex: 1 1 100%;
    }
    .kc-filter-bar .views-exposed-form input.form-text.form-control,
    .kc-filter-bar .views-exposed-form.is-open input.form-text.form-control {
        width: 100%;
        max-width: none;
        cursor: text;
    }
    .kc-filter-bar .kc-cat-pills {
        order: 1;
        flex: 1 1 100%;
    }
    .kc-filters-dd {
        order: 2;
    }
}

@media (max-width: 650px) {
    .kc-cat-pills ul {
        flex-wrap: wrap;
    }
    .kc-cat-pills li a {
        padding: 7px 14px;
        font-size: 0.8125rem;
    }
    .view-knowledge-center .view-header.kc-results-row {
        justify-content: flex-start;
    }
    .kc-sort {
        width: 100%;
        justify-content: space-between;
    }
}
