.job-filters-toolbar,
.job-filters__header,
.job-filters__footer,
.job-filters-backdrop[hidden] {
    display: none;
}

@media (max-width: 1024px) {
    html:has(body.job-filters-open) {
        overflow: hidden;
    }

    body.job-filters-open {
        overflow: hidden;
    }

    body.job-filters-ready .job-filters-toolbar {
        display: flex;
        flex-direction: column;
        gap: 12px;
        margin: 0 0 20px;
    }

    .job-filters-active {
        display: flex;
        flex-wrap: wrap;
        gap: 6px;
    }

    .job-filters-chip {
        display: inline-flex;
        align-items: center;
        gap: 6px;
        min-width: 0;
        max-width: 100%;
        min-height: 28px;
        padding: 3px 7px;
        box-sizing: border-box;
        border: 1px solid #d6e2eb;
        border-radius: 3px;
        background: #edf3f7;
        color: #082a4d;
        font-size: 14px;
        font-weight: 400;
        line-height: 20px;
    }

    .job-filters-chip__label {
        min-width: 0;
        overflow-wrap: anywhere;
    }

    .job-filters-chip svg {
        flex-shrink: 0;
        width: 14px;
        height: 14px;
    }

    .job-filters-chip:hover {
        border-color: #147e77;
        background: #e2f0ee;
    }

    .job-filters-trigger {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 10px;
        min-height: 48px;
        width: 100%;
        padding: 10px 18px;
        border: 1px solid #cbd8e2;
        border-radius: 8px;
        background: #fff;
        color: #082a4d;
        font: inherit;
        font-size: 16px;
        font-weight: 700;
        line-height: 1.5;
        cursor: pointer;
    }

    .job-filters-trigger:hover {
        border-color: #082a4d;
        background: #f1f6f9;
    }

    .job-filters-trigger__count {
        display: inline-grid;
        place-items: center;
        min-width: 24px;
        height: 24px;
        padding: 0 6px;
        border-radius: 12px;
        background: #082a4d;
        color: #fff;
        font-size: 12px;
    }

    /* Keep the drawer offscreen before the async search form initializes. */
    #wrap #main .job-listing > #sidebar[data-job-filters] {
        position: fixed;
        inset: 0 0 0 auto;
        z-index: 1201;
        display: flex;
        flex-direction: column;
        float: none;
        width: 100%;
        max-width: none;
        height: 100vh;
        height: 100dvh;
        margin: 0;
        padding: 0;
        box-sizing: border-box;
        background: #fff;
        color: #082a4d;
        box-shadow: -8px 0 28px rgba(8, 42, 77, .16);
        visibility: hidden;
        transform: translateX(105%);
    }

    body.job-filters-ready #wrap #main .job-listing > #sidebar[data-job-filters] {
        transition: transform 220ms cubic-bezier(.2, .8, .2, 1), visibility 220ms;
    }

    body.job-filters-ready #wrap #main .job-listing > #sidebar[data-job-filters].is-open {
        visibility: visible;
        transform: translateX(0);
    }

    body.job-filters-ready .job-filters__header {
        display: flex;
        flex-shrink: 0;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
        min-height: 72px;
        padding: 12px 16px;
        border-bottom: 1px solid #e2e9ef;
        box-sizing: border-box;
    }

    #wrap #main #sidebar .job-filters__header h2 {
        margin: 0;
        color: #082a4d;
        font-size: 20px;
        font-weight: 700;
        line-height: 1.3;
    }

    .job-filters__close {
        display: grid;
        place-items: center;
        flex-shrink: 0;
        width: 44px;
        height: 44px;
        padding: 10px;
        border: 0;
        border-radius: 6px;
        background: transparent;
        color: #082a4d;
        cursor: pointer;
    }

    .job-filters__close:hover {
        background: #f1f6f9;
    }

    .job-filters__content {
        flex: 1;
        min-height: 0;
        overflow-y: auto;
        overscroll-behavior: contain;
        padding: 16px;
        scrollbar-width: none;
        -webkit-overflow-scrolling: touch;
    }

    .job-filters__content::-webkit-scrollbar {
        display: none;
    }

    #wrap #main #sidebar[data-job-filters] #categories > div {
        margin: 0 0 16px;
        padding: 12px 16px;
        border-color: #e2e9ef;
        border-radius: 8px;
        background: #f5f7f9;
    }

    #wrap #main #sidebar[data-job-filters] #categories > div > h2 {
        margin: 0 0 6px;
        color: #082a4d;
        font-size: 14px;
        line-height: 1.5;
    }

    #wrap #main #sidebar[data-job-filters] #categories > div > a {
        display: flex;
        align-items: baseline;
        justify-content: space-between;
        gap: 12px;
        min-height: 44px;
        padding: 10px 0;
        border-bottom: 1px solid #e2e9ef;
        box-sizing: border-box;
        font-size: 14px;
        line-height: 1.5;
    }

    #wrap #main #sidebar[data-job-filters] #categories > div > a:last-child {
        border-bottom: 0;
    }

    #wrap #main #sidebar[data-job-filters] #categories > div > a > span {
        flex-shrink: 0;
        float: none;
        color: #596e7e;
    }

    #wrap #main #sidebar[data-job-filters] #filter {
        margin-bottom: 16px;
        border-radius: 8px;
    }

    #wrap #main #sidebar[data-job-filters] #filter > a {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
        min-height: 44px;
        font-size: 14px;
        line-height: 1.5;
    }

    body.job-filters-ready .job-filters__footer {
        display: block;
        flex-shrink: 0;
        padding: 12px 16px;
        padding-bottom: max(12px, env(safe-area-inset-bottom));
        border-top: 1px solid #e2e9ef;
        background: #fff;
    }

    .job-filters__footer button {
        min-height: 48px;
        width: 100%;
        padding: 10px 16px;
        border: 0;
        border-radius: 6px;
        background: #082a4d;
        color: #fff;
        font: inherit;
        font-size: 16px;
        font-weight: 700;
        line-height: 1.5;
        cursor: pointer;
    }

    .job-filters__footer button:hover {
        background: #125a97;
    }

    .job-filters-backdrop {
        position: fixed;
        inset: 0;
        z-index: 1200;
        display: block;
        width: 100%;
        height: 100%;
        margin: 0;
        padding: 0;
        border: 0;
        background: rgba(8, 25, 42, .42);
        opacity: 0;
        transition: opacity 220ms ease-out;
        cursor: pointer;
    }

    .job-filters-backdrop.is-open {
        opacity: 1;
    }

    .job-filters-trigger:focus-visible,
    .job-filters-chip:focus-visible,
    .job-filters__close:focus-visible,
    .job-filters__footer button:focus-visible {
        outline: 2px solid #147e77;
        outline-offset: 3px;
    }
}

@media (prefers-reduced-motion: reduce) {
    body.job-filters-ready #wrap #main .job-listing > #sidebar[data-job-filters],
    .job-filters-backdrop {
        transition: none;
    }
}
