/*
 * Header of a "List of works" element (components/views/contributions_list_item.php):
 * result count | pager | sort.
 *
 * The layout follows the width the list actually gets (container query), not the
 * screen width, since the profile sidebar changes it:
 *  - wide:        count, pager (centred), sort on one line;
 *  - narrower:    count + sort on one line, the pager centred on its own line below;
 *  - very narrow: count, sort and pager stacked, left-aligned.
 * The pager itself never wraps.
 */
.works-list-header-wrap {
    container-type: inline-size;
    margin: 5px 0 12px;
}

.works-list-header {
    display: grid;
    grid-template-columns: minmax(max-content, 1fr) auto minmax(max-content, 1fr);
    grid-template-areas: "count pager sort";
    align-items: center;
    gap: 10px 16px;
}

.works-list-header-count {
    grid-area: count;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 12px;
    min-width: 0;
    margin: 0;
}

.works-list-count {
    white-space: nowrap;
}

.works-list-header-pager {
    grid-area: pager;
    justify-self: center;
}

.works-list-header .pagination {
    display: flex;
    flex-wrap: nowrap;
    margin: 0;
}

.works-list-header-sort {
    grid-area: sort;
    justify-self: end;
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}

.works-list-header-sort .finder-ordering-control {
    flex-shrink: 0;
}

/* Summarize next to "List of works" — longer label than Finder's default */
.works-list-title-actions {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    margin-top: 2px;
}

.works-list-title-actions .bip-toolbar-btn-wrap:hover .finder-toolbar-expand-btn,
.works-list-title-actions .bip-toolbar-btn-wrap:focus-within .finder-toolbar-expand-btn,
.works-list-title-actions .finder-toolbar-expand-btn:hover,
.works-list-title-actions .finder-toolbar-expand-btn:focus {
    max-width: 280px;
}

.works-list-title-actions .bip-toolbar-btn-wrap:hover .finder-toolbar-btn-label,
.works-list-title-actions .bip-toolbar-btn-wrap:focus-within .finder-toolbar-btn-label,
.works-list-title-actions .finder-toolbar-expand-btn:hover .finder-toolbar-btn-label,
.works-list-title-actions .finder-toolbar-expand-btn:focus .finder-toolbar-btn-label {
    max-width: 230px;
}

/* Not enough room for one line: pager on its own line, below count and sort */
@container (max-width: 720px) {
    .works-list-header {
        grid-template-columns: minmax(0, 1fr) auto;
        grid-template-areas:
            "count sort"
            "pager pager";
    }

    .works-list-count {
        white-space: normal;
    }
}

/* Very narrow: everything stacked, left-aligned */
@container (max-width: 420px) {
    .works-list-header {
        grid-template-columns: minmax(0, 1fr);
        grid-template-areas:
            "count"
            "sort"
            "pager";
    }

    .works-list-header-sort,
    .works-list-header-pager {
        justify-self: start;
    }
}
