/*
 * Media picker fields (form field type "mediapicker"): the picked images under the field,
 * and the grid of tiles in the library modal. Apps draw the tiles; `ab-mp-grid` and
 * `ab-mp-tile` give them the standard look, and mediapicker.js adds `ab-mp-picked` to the
 * picked ones.
 */

.ab-mp-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin: 0 0 0.5rem;
}

.ab-mp-chip {
    position: relative;
    width: 96px;
    height: 96px;
    border: 1px solid var(--bs-border-color);
    border-radius: var(--bs-border-radius);
    background: var(--bs-tertiary-bg);
    overflow: hidden;
}

.ab-mp-chip[draggable="true"] {
    cursor: grab;
}

.ab-mp-chip:focus-visible {
    outline: 2px solid var(--bs-primary);
    outline-offset: 2px;
}

.ab-mp-chip-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.ab-mp-chip-remove {
    position: absolute;
    top: 4px;
    right: 4px;
    padding: 0 0.3rem;
    line-height: 1.4;
    box-shadow: 0 1px 2px rgb(0 0 0 / 25%);
}

.ab-mp-dragging {
    opacity: 0.5;
}

.ab-mp.is-invalid .ab-mp-choose {
    border-color: var(--bs-form-invalid-border-color);
}

.ab-mp-drop .filepond--root {
    margin-bottom: 0;
}

.ab-mp-results[aria-busy="true"] {
    opacity: 0.6;
}

.ab-mp-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 0.75rem;
}

.ab-mp-tile {
    position: relative;
    display: flex;
    flex-direction: column;
    width: 100%;
    padding: 0;
    border: 2px solid transparent;
    border-radius: var(--bs-border-radius);
    background: var(--bs-tertiary-bg);
    color: inherit;
    text-align: left;
    overflow: hidden;
}

.ab-mp-tile:hover {
    border-color: var(--bs-border-color);
}

.ab-mp-tile:focus-visible {
    outline: 2px solid var(--bs-primary);
    outline-offset: 2px;
}

.ab-mp-tile img {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    display: block;
}

.ab-mp-tile-label {
    padding: 0.25rem 0.5rem;
    font-size: 0.8125rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ab-mp-tile.ab-mp-picked {
    border-color: var(--bs-primary);
}

.ab-mp-tile.ab-mp-picked::after {
    content: "\2713";
    position: absolute;
    top: 6px;
    right: 6px;
    width: 1.5rem;
    height: 1.5rem;
    border-radius: 50%;
    background: var(--bs-primary);
    color: #fff;
    font-weight: 700;
    line-height: 1.5rem;
    text-align: center;
}
