/* The Filter's row wraps when its chips outgrow it, rather than pushing its count and steps out of the pane. */
.replay-filter-row,
.table-filter-row {
    flex-wrap: wrap;
    row-gap: 2px;
}

/* A Parquet table's Filter, between the pane bar and the rows, drawn as the replay's rows. */
.table-filter-row {
    flex: none;
    display: flex;
    align-items: center;
    min-height: 30px;
    padding: 2px 12px;
    border-bottom: 1px solid var(--lp-rule);
    background: var(--lp-canvas-raised);
    font: var(--pv-type-code-small);
    white-space: nowrap;
}

/* Filter: its chips or its text, `{ }`, ⓘ, the count and what follows it. */
.filter-bar {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    min-width: 0;
    flex-wrap: wrap;
}

/* Its controls, as the replay's rows draw theirs. */
.filter-bar button,
.filter-bar input[type="text"] {
    font: var(--pv-type-code-small);
    border: 1px solid var(--lp-rule-2);
    background: var(--lp-canvas);
    color: var(--lp-ink);
    padding: 2px 8px;
}

.filter-bar button {
    min-width: 28px;
}

.filter-bar button:hover:not(:disabled) {
    background-image: var(--pv-layer-hover);
}

.filter-bar button[aria-pressed="true"] {
    background: var(--lp-ink);
    border-color: var(--lp-ink);
    color: var(--lp-canvas);
}

.filter-bar input[type="text"] {
    min-width: 0;
}

.filter-bar input[type="text"]:focus-visible {
    border-color: var(--pv-card-focus);
    outline: none;
}

.filter-label {
    font: var(--pv-type-label-small);
    color: var(--lp-ink-2);
}

.filter-chips {
    display: inline-flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 4px;
    min-width: 0;
}

/* A chip: its condition, which opens it to edit, and × to remove it. */
.filter-chip {
    display: inline-flex;
    align-items: center;
    border: 1px solid var(--lp-rule-2);
    border-radius: 11px;
    background: var(--lp-canvas);
}

.filter-bar .filter-chip button {
    min-width: 0;
    border: none;
    background: transparent;
    padding: 1px 4px 1px 8px;
}

.filter-bar .filter-chip .filter-chip-remove {
    padding: 1px 8px 1px 2px;
    color: var(--lp-ink-3);
}

.filter-chip[data-shape="clause"] {
    border-style: dashed;
}

.filter-chip[aria-invalid="true"] {
    border-color: var(--lp-error);
    color: var(--lp-error);
}

/* The part of a chip that is refused: its field, operator or one of its values. */
.filter-part[data-refused="true"] {
    text-decoration: underline wavy;
    text-underline-offset: 3px;
}

.filter-bar .filter-add {
    border-style: dashed;
    color: var(--lp-ink-2);
}

/* A field with its completions as rows under it. */
.filter-field {
    position: relative;
    display: inline-flex;
}

.filter-bar .filter-chip-field input[type="text"] {
    width: 26ch;
}

.filter-bar .filter-clause input[type="text"] {
    width: 60ch;
}

.filter-field input[aria-invalid="true"] {
    color: var(--lp-error);
}

.filter-list {
    position: absolute;
    top: 100%;
    left: 0;
    z-index: 10;
    display: flex;
    flex-direction: column;
    min-width: 100%;
    border: 1px solid var(--lp-rule-strong);
    background: var(--lp-canvas);
    color: var(--lp-ink);
    font: var(--pv-type-code-small);
}

.filter-option {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 1px 6px;
    cursor: default;
}

.filter-option[aria-selected="true"] {
    background: var(--pv-selected);
}

.filter-of,
.filter-count {
    opacity: 0.6;
    font-variant-numeric: tabular-nums;
}

.filter-bar.failing .filter-count {
    opacity: 1;
    color: var(--lp-error);
}

/* ⓘ: the syntax as rows of a name and its value, under the button. */
.filter-help-anchor {
    position: relative;
    display: inline-flex;
}

.filter-bar .filter-help-button {
    min-width: 0;
    border: none;
    background: transparent;
    padding: 0 2px;
    color: var(--lp-ink-3);
}

.filter-bar .filter-help-button[aria-expanded="true"] {
    color: var(--lp-ink);
}

.filter-help {
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    z-index: 10;
    display: grid;
    grid-template-columns: max-content max-content;
    border: 1px solid var(--lp-rule-strong);
    background: var(--lp-canvas);
    color: var(--lp-ink);
    font: var(--pv-type-code-small);
}

.filter-help-row {
    display: contents;
}

.filter-help-name,
.filter-help-value {
    padding: 2px 8px;
    border-bottom: 1px solid var(--lp-rule);
}

.filter-help-name {
    color: var(--lp-ink-3);
}
