/**
 * Knowledge base overview + letter archive (0.14.0).
 *
 * The search field (replaces Ajax Search Lite), the sticky A–Z bar (replaces the
 * Elementor Taxonomy Filter), the results, pagination and the empty state. The
 * filter bar and pagination look the same as on the case studies overview.
 * Hero and cards: kb-base.css.
 *
 * Breakpoints: ≤1280 (A–Z bar scrolls), mobile ≤767.
 */

/* ── Search (in the hero) ─────────────────────────────────────────────── */
.r4y-template .r4y-kb-search {
    display: flex;
    align-items: stretch;
    width: 100%;
    max-width: 640px;
    min-height: 64px;
    margin-top: 40px;
    border: 1px solid var(--r4y-color-field-border);
    background-color: var(--r4y-kit-white);
    transition: border-color var(--r4y-transition), box-shadow var(--r4y-transition);
}
.r4y-template .r4y-kb-search:hover { border-color: var(--r4y-color-field-hover); }
.r4y-template .r4y-kb-search:focus-within {
    border-color: var(--r4y-kit-secondary);
    box-shadow: 0 0 0 4px var(--r4y-color-focus-ring);
}
.r4y-template .r4y-kb-search__icon {
    display: flex;
    align-items: center;
    padding-left: 22px;
    color: var(--r4y-kit-secondary);
}
.r4y-template .r4y-kb-search__icon .r4y-icon { width: 22px; height: 22px; }
/* .r4y-kb … beats the Elementor Kit and the theme input styles. */
.r4y-template .r4y-kb input.r4y-kb-search__input {
    flex: 1 1 auto;
    min-width: 0;
    height: auto;
    margin: 0;
    padding: 0 16px;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    font-family: var(--r4y-font-body);
    font-size: var(--r4y-fs-md);
    font-weight: var(--r4y-fw-regular);
    color: var(--r4y-kit-primary);
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}
.r4y-template .r4y-kb input.r4y-kb-search__input::placeholder {
    color: var(--r4y-color-muted);
    opacity: 1;
}
.r4y-template .r4y-kb input.r4y-kb-search__input::-webkit-search-cancel-button {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    background: linear-gradient(45deg, transparent 46%, currentColor 46%, currentColor 54%, transparent 54%),
                linear-gradient(-45deg, transparent 46%, currentColor 46%, currentColor 54%, transparent 54%);
    color: var(--r4y-color-muted);
    cursor: pointer;
}
.r4y-template .r4y-kb button.r4y-kb-search__submit {
    flex: none;
    margin: 6px;
    padding: 0 26px;
    border: 0;
    border-radius: 0;
    background-color: var(--r4y-kit-primary);
    font-family: var(--r4y-font-body);
    font-size: var(--r4y-fs-sm);
    font-weight: var(--r4y-fw-medium);
    letter-spacing: 0.02em;
    color: var(--r4y-kit-white);
    cursor: pointer;
    transition: background-color var(--r4y-transition), color var(--r4y-transition);
}
.r4y-template .r4y-kb button.r4y-kb-search__submit:hover,
.r4y-template .r4y-kb button.r4y-kb-search__submit:focus-visible {
    background-color: var(--r4y-kit-secondary);
    color: var(--r4y-kit-white);
}
.r4y-template .r4y-kb button.r4y-kb-search__submit:focus-visible {
    outline: 2px solid var(--r4y-kit-primary);
    outline-offset: 2px;
}

/* ── A–Z bar: sticky under the fixed header ───────────────────────────── */
.r4y-template .r4y-kb-filter {
    position: sticky;
    top: calc(var(--wp-admin--admin-bar--height, 0px) + var(--r4y-kb-header));
    z-index: 5; /* under the header (10) */
    padding-inline: var(--r4y-gutter);
    border-block: 1px solid var(--r4y-color-field-border);
    background-color: rgba(255, 255, 255, 0.92);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
}
.r4y-template .r4y-kb-filter__inner {
    display: flex;
    align-items: center;
    gap: 24px;
    min-height: 72px;
    padding-block: 14px;
}
.r4y-template .r4y-kb .r4y-kb-filter__label {
    flex: none;
    font-family: var(--r4y-font-body);
    font-size: 13px;
    font-weight: var(--r4y-fw-semibold);
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--r4y-kit-secondary);
}
.r4y-template .r4y-kb-filter__nav {
    flex: 1 1 auto;
    min-width: 0;
}
.r4y-template .r4y-main .r4y-kb-filter__letters {
    display: flex;
    flex-wrap: wrap;
    gap: 2px;
    margin: 0;
    padding: 0;
    list-style: none;
}
.r4y-template .r4y-kb-filter__all,
.r4y-template .r4y-kb-filter__letter {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 34px;
    height: 38px;
    border: 1px solid transparent;
    font-family: var(--r4y-font-body);
    font-size: var(--r4y-fs-sm);
    font-weight: var(--r4y-fw-medium);
    line-height: 1;
    color: var(--r4y-kit-primary);
    text-decoration: none;
    transition: border-color var(--r4y-transition), background-color var(--r4y-transition), color var(--r4y-transition);
}
.r4y-template .r4y-kb-filter__all {
    margin-right: 8px;
    padding: 0 16px;
    border-color: var(--r4y-color-field-border);
    background-color: var(--r4y-kit-white);
}
.r4y-template a.r4y-kb-filter__all:hover,
.r4y-template a.r4y-kb-filter__letter:hover {
    border-color: var(--r4y-kit-secondary);
    color: var(--r4y-kit-primary);
}
.r4y-template a.r4y-kb-filter__all:focus-visible,
.r4y-template a.r4y-kb-filter__letter:focus-visible {
    outline: 2px solid var(--r4y-kit-secondary);
    outline-offset: 2px;
}
.r4y-template a.r4y-kb-filter__all.is-active,
.r4y-template a.r4y-kb-filter__letter.is-active,
.r4y-template a.r4y-kb-filter__all.is-active:hover,
.r4y-template a.r4y-kb-filter__letter.is-active:hover {
    border-color: var(--r4y-kit-primary);
    background-color: var(--r4y-kit-primary);
    color: var(--r4y-kit-white);
}
/* A letter without articles: in the index, but not a link. */
.r4y-template .r4y-kb-filter__letter.is-empty {
    color: var(--r4y-color-field-hover);
    cursor: default;
}
.r4y-template .r4y-kb .r4y-kb-filter__status {
    flex: none;
    font-size: var(--r4y-fs-sm);
    font-weight: var(--r4y-fw-light);
    color: var(--r4y-color-muted);
}

/* ── Results ──────────────────────────────────────────────────────────── */
.r4y-template .r4y-kb__list {
    padding-block: 48px var(--r4y-kb-space);
}
.r4y-template .r4y-kb__results {
    scroll-margin-top: calc(var(--r4y-kb-header) + 96px);
    transition: opacity var(--r4y-transition);
}
.r4y-template .r4y-kb__results.is-loading {
    opacity: 0.4;
    pointer-events: none;
}
.r4y-template .r4y-kb__results:focus { outline: none; }

/* ── Pagination: sharp 44px squares, previous/next (as the case studies) ── */
.r4y-template .r4y-kb-pagination {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 64px;
    font-family: var(--r4y-font-body);
}
.r4y-template .r4y-main .r4y-kb-pagination__pages {
    display: flex;
    gap: 8px;
    margin: 0;
    padding: 0;
    list-style: none;
}
.r4y-template .r4y-kb-pagination__item,
.r4y-template .r4y-kb-pagination__step {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-width: 44px;
    height: 44px;
    border: 1px solid var(--r4y-color-field-border);
    background-color: var(--r4y-kit-white);
    font-size: var(--r4y-fs-sm);
    font-weight: var(--r4y-fw-medium);
    font-variant-numeric: tabular-nums;
    color: var(--r4y-kit-primary);
    text-decoration: none;
    transition: border-color var(--r4y-transition), color var(--r4y-transition);
}
.r4y-template .r4y-kb-pagination__step { padding: 0 18px; }
.r4y-template a.r4y-kb-pagination__item:hover,
.r4y-template a.r4y-kb-pagination__step:hover {
    border-color: var(--r4y-kit-secondary);
    color: var(--r4y-kit-primary);
}
.r4y-template a.r4y-kb-pagination__item:focus-visible,
.r4y-template a.r4y-kb-pagination__step:focus-visible {
    outline: 2px solid var(--r4y-kit-secondary);
    outline-offset: 2px;
}
.r4y-template .r4y-kb-pagination__item.is-current {
    border-color: var(--r4y-kit-primary);
    background-color: var(--r4y-kit-primary);
    color: var(--r4y-kit-white);
}
.r4y-template .r4y-kb-pagination__step--prev { margin-right: 8px; }
.r4y-template .r4y-kb-pagination__step--next { margin-left: 8px; }

/* ── Empty state ──────────────────────────────────────────────────────── */
.r4y-template .r4y-kb-empty {
    padding: 64px 32px;
    border-top: 2px solid var(--r4y-kit-secondary);
    background-color: var(--r4y-kit-accent);
    text-align: center;
}
.r4y-template .r4y-kb .r4y-kb-empty__title {
    margin-bottom: 12px;
    font-family: var(--r4y-font-heading);
    font-size: var(--r4y-fs-2xl);
    color: var(--r4y-kit-primary);
}
.r4y-template .r4y-kb .r4y-kb-empty__text {
    max-width: 48ch;
    margin: 0 auto 28px;
    font-weight: var(--r4y-fw-light);
    color: var(--r4y-color-muted);
}

/* ── ≤1280 (A–Z no longer fits next to label and count): one row of
   letters that scrolls sideways, so the sticky bar stays one row high ── */
@media (max-width: 1280px) {
    .r4y-template .r4y-kb .r4y-kb-filter__label { display: none; }
    .r4y-template .r4y-kb-filter { padding-inline: 0; }
    .r4y-template .r4y-kb-filter__inner { min-height: 0; padding-block: 12px; }
    .r4y-template .r4y-kb-filter__nav {
        overflow-x: auto;
        scroll-snap-type: x proximity;
        scroll-padding-inline: var(--r4y-gutter);
        scrollbar-width: none;
    }
    .r4y-template .r4y-kb-filter__nav::-webkit-scrollbar { display: none; }
    .r4y-template .r4y-main .r4y-kb-filter__letters {
        flex-wrap: nowrap;
        width: max-content;
        padding-inline: var(--r4y-gutter);
    }
    .r4y-template .r4y-kb-filter__letters > li { scroll-snap-align: start; }
    .r4y-template .r4y-kb-filter__all,
    .r4y-template .r4y-kb-filter__letter { min-width: 40px; height: 40px; }
    /* The count stays for screen readers (aria-live). */
    .r4y-template .r4y-kb .r4y-kb-filter__status {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip: rect(0, 0, 0, 0);
        white-space: nowrap;
    }
}

/* ── Mobile ≤767 ───────────────────────────────────────────────────────── */
@media (max-width: 767px) {
    .r4y-template .r4y-kb-search { min-height: 56px; margin-top: 28px; }
    .r4y-template .r4y-kb-search__icon { padding-left: 16px; }
    .r4y-template .r4y-kb input.r4y-kb-search__input { padding: 0 12px; font-size: var(--r4y-fs-base); }
    .r4y-template .r4y-kb button.r4y-kb-search__submit { padding: 0 16px; }
    .r4y-template .r4y-kb__list { padding-top: 32px; }
    .r4y-template .r4y-kb-pagination { margin-top: 40px; }
    .r4y-template .r4y-kb-pagination__step { padding: 0 14px; }
    .r4y-template .r4y-kb-empty { padding: 48px 20px; }
}

@media (prefers-reduced-motion: reduce) {
    .r4y-template .r4y-kb__results { transition: none; }
}
