/* Sélecteur — composant canonique ; son emploi : canon_select.md. */

@layer components {
    .select-list {
        --popover-offset: var(--select-list-offset, 0px);
    }

    .select-source[aria-hidden="true"] {
        position: absolute;
        width: 1px;
        height: 1px;
        padding: 0;
        overflow: hidden;
    }
    .select-trigger {
        display: flex;
        align-items: center;
        gap: var(--canon-space-2);
        padding: var(--select-trigger-padding, var(--canon-space-2) var(--canon-space-3));
    }
    .select-trigger::before,
    .select-trigger::after {
        flex: none;
        order: 1;
        width: var(--select-arrow-size, 0.4em);
        aspect-ratio: 1;
    }
    .select-trigger::before {
        margin-inline-end: calc(-1 * var(--select-arrow-size, 0.4em) - var(--canon-space-2));
        transform: translateY(-30%) rotate(-135deg);
    }
    .select-trigger::after {
        margin-inline-end: 0.3em;
        transform: translateY(30%) rotate(45deg);
    }
    .select-value {
        flex: 1;
        min-width: 0;
        overflow: hidden;
    }
    .select-trigger.field-control--compact {
        display: inline-flex;
        width: auto;
        padding: 4px 12px;
    }
    .select-trigger.field-control--compact .select-value {
        flex: auto;
    }
    .select-list {
        display: flex;
        flex-direction: column;
        padding: var(--select-list-padding, var(--canon-space-2));
    }
    .select-title {
        padding: var(--canon-space-2) var(--canon-space-3) var(--canon-space-1);
    }
    .select-option {
        display: flex;
        align-items: center;
        gap: var(--canon-space-3);
        padding: var(--select-option-padding, var(--canon-space-2) var(--canon-space-3));
    }
    .select-option::after {
        flex: none;
        width: 0.35em;
        height: 0.7em;
        margin-inline-start: auto;
        visibility: hidden;
        transform: translateY(-10%) rotate(45deg);
    }
    .select-option[aria-selected="true"]::after {
        visibility: var(--select-check, visible);
    }

    .select-source[aria-hidden="true"] {
        border: 0;
        clip-path: inset(50%);
    }
    .select-source:focus-visible + .select-trigger {
        outline: var(--canon-focus-width) var(--canon-focus-style) var(--canon-theme-focus);
        outline-offset: var(--canon-focus-offset);
        box-shadow: var(--select-trigger-shadow, 0 0 #0000), var(--canon-focus-halo);
    }
    .select-trigger {
        border-width: var(--select-trigger-line-width, var(--field-line-width, var(--canon-line-width)));
        border-radius: var(--select-trigger-radius, var(--field-radius, var(--canon-radius-control)));
        background-color: var(--select-trigger-surface, var(--canon-theme-field));
        box-shadow: var(--select-trigger-shadow, none);
    }
    .select-trigger[aria-expanded="true"] {
        border-color: var(--canon-theme-action);
    }
    .select-trigger[aria-disabled="true"] {
        border-color: var(--canon-theme-line);
    }
    .select-trigger.field-control--compact {
        border-width: var(--button-line-width, var(--canon-line-width));
        border-radius: var(--button-radius, var(--canon-radius-control));
        background-color: var(--canon-theme-surface);
    }
    .select-trigger::before,
    .select-trigger::after {
        border-block-end: var(--select-arrow-width, 2px) solid var(--select-arrow-color, currentColor);
        border-inline-end: var(--select-arrow-width, 2px) solid var(--select-arrow-color, currentColor);
        border-end-end-radius: var(--select-arrow-radius, 0);
        border-start-end-radius: var(--select-arrow-round, 0);
        border-end-start-radius: var(--select-arrow-round, 0);
    }
    .select-list {
        border-color: var(--select-list-line, var(--canon-theme-line));
        border-radius: var(--select-list-radius, var(--canon-radius-control));
        background-color: var(--select-list-surface, var(--canon-theme-raised));
        box-shadow: var(--select-list-shadow, var(--canon-shadow-overlay, none));
        backdrop-filter: var(--select-list-blur, none);
    }
    .select-option {
        border-radius: var(--select-option-radius, var(--canon-radius-control));
        box-shadow: inset 0 -1px 0 var(--select-option-line, #0000);
    }
    .select-option[aria-selected="true"] {
        background-color: var(--select-option-selected, transparent);
    }
    .select-option:hover,
    .select-option[data-select-current] {
        background-color: var(--select-option-hover, var(--canon-theme-highlight));
    }
    .select-option[aria-selected="true"]:hover,
    .select-option[aria-selected="true"][data-select-current] {
        background-color: var(--select-option-selected-hover, var(--select-option-hover, var(--canon-theme-highlight)));
    }
    .select-option[aria-disabled="true"] {
        background-color: transparent;
    }
    .select-option::after {
        border-block-end: 2px solid currentColor;
        border-inline-end: 2px solid currentColor;
    }
    @media (forced-colors: active) {
        .select-option[data-select-current] {
            outline: 2px solid currentColor;
            outline-offset: -2px;
        }
    }

    .select-source[aria-hidden="true"] {
        white-space: nowrap;
    }
    .select-trigger {
        font-family: var(--select-font, inherit);
        font-size: var(--select-size, var(--canon-size-field));
        font-weight: var(--select-trigger-weight, var(--canon-weight-body));
        color: var(--select-ink, var(--canon-theme-ink));
    }
    .select-trigger:hover {
        font-weight: var(--select-trigger-weight-hover, var(--select-trigger-weight, var(--canon-weight-body)));
    }
    .select-trigger::before,
    .select-trigger::after {
        content: "";
    }
    .select-trigger[aria-disabled="true"] {
        color: var(--canon-theme-faint);
    }
    .select-trigger.field-control--compact {
        font-size: var(--button-size, var(--canon-size-control));
        font-weight: var(--button-weight-quiet, var(--canon-weight-quiet));
        line-height: inherit;
    }
    .select-value {
        white-space: nowrap;
        text-overflow: ellipsis;
    }
    .select-list {
        font-family: var(--select-font, inherit);
        font-size: var(--select-size, var(--canon-size-field));
    }
    .select-title {
        font-size: var(--canon-size-note);
        font-weight: var(--canon-weight-label);
        color: var(--canon-theme-muted);
    }
    .select-option {
        color: var(--select-ink, var(--canon-theme-ink));
    }
    .select-option[aria-selected="true"] {
        font-weight: var(--select-option-selected-weight, var(--canon-weight-label));
        color: var(--select-option-selected-ink, var(--select-ink, var(--canon-theme-ink)));
    }
    .select-option[aria-disabled="true"] {
        color: var(--canon-theme-faint);
    }
    .select-option::after {
        content: "";
    }

    .select-source[aria-hidden="true"] {
        pointer-events: none;
    }
    .select-trigger {
        cursor: pointer;
        user-select: none;
    }
    .select-trigger[aria-disabled="true"] {
        cursor: default;
    }
    .select-option {
        cursor: pointer;
        user-select: none;
    }
    .select-option[aria-disabled="true"] {
        cursor: default;
    }
}
