/* Sticky positioning must use the page viewport, not <main> as a clipped
   scroll container. This mirrors the Blog category rail behavior. */
body[data-route^="/medical-references"] main.site-main,
body[data-route^="/nonmedical-references"] main.site-main {
    overflow: clip;
}

.references-filter {
    position: sticky;
    top: var(--references-stick, calc(var(--ds-nav-h, 68px) + 1px));
    z-index: 40;
    margin: 22px -28px 30px;
    padding: 0 28px;
    background: rgba(255, 255, 255, 0.97);
    -webkit-backdrop-filter: blur(14px) saturate(150%);
    backdrop-filter: blur(14px) saturate(150%);
    border-top: 1px solid #e4e9ef;
    border-bottom: 1px solid #dce3ea;
    box-shadow: 0 10px 24px rgba(7, 34, 59, 0.05);
}

.references-filter-track {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    padding: 12px 0;
}

.references-filter-total {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    margin-right: 8px;
    padding-right: 18px;
    color: #667585;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.13em;
    text-transform: uppercase;
    border-right: 1px solid #dce3ea;
}

.references-filter-total strong {
    color: #21364a;
}

.references-filter-button {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 38px;
    padding: 8px 13px;
    color: #42505f;
    font: inherit;
    font-size: 0.84rem;
    font-weight: 650;
    white-space: nowrap;
    cursor: pointer;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 999px;
    transition: color 160ms ease, background 160ms ease, border-color 160ms ease, transform 160ms ease;
}

.references-filter-button:hover {
    color: #0d3658;
    background: #f0f5f9;
}

.references-filter-button:focus-visible {
    outline: 3px solid rgba(15, 116, 181, 0.28);
    outline-offset: 2px;
}

.references-filter-button.is-active {
    color: #fff;
    background: #092d4d;
    border-color: #092d4d;
    box-shadow: 0 6px 14px rgba(9, 45, 77, 0.18);
}

.references-filter-count {
    display: inline-grid;
    place-items: center;
    min-width: 22px;
    height: 22px;
    padding: 0 6px;
    color: #576675;
    font-size: 0.72rem;
    font-weight: 800;
    line-height: 1;
    background: #e9edf1;
    border-radius: 999px;
}

.references-filter-button.is-active .references-filter-count {
    color: #092d4d;
    background: #fff;
}

.reference-category {
    display: inline-flex;
    align-items: center;
    width: fit-content;
    margin: 0 0 8px;
    padding: 4px 9px;
    color: #0b6294;
    font-size: 0.68rem;
    font-weight: 800;
    letter-spacing: 0.075em;
    line-height: 1.25;
    text-transform: uppercase;
    background: #eaf5fa;
    border: 1px solid #cde5f0;
    border-radius: 999px;
}

[data-reference-item][hidden] {
    display: none !important;
}

[data-reference-item].reference-is-entering {
    animation: referenceReveal 220ms ease both;
}

.references-visually-hidden {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

@keyframes referenceReveal {
    from {
        opacity: 0;
        transform: translateY(5px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (max-width: 760px) {
    .references-filter {
        margin-right: -18px;
        margin-left: -18px;
        padding-right: 18px;
        padding-left: 18px;
    }

    .references-filter-total {
        width: 100%;
        margin-right: 0;
        padding-right: 13px;
        padding-bottom: 8px;
        border-right: 0;
        border-bottom: 1px solid #dce3ea;
    }

    .references-filter-button {
        min-height: 34px;
        padding: 6px 10px;
        font-size: 0.78rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    .references-filter-button {
        transition: none;
    }

    [data-reference-item].reference-is-entering {
        animation: none;
    }
}
