/* Case — composant canonique ; son emploi : canon_check.md. */

@layer components {
    .check-group {
        display: grid;
        gap: var(--check-group-space, var(--canon-space-2));
    }
    .check-label {
        display: inline-flex;
        align-items: center;
        gap: var(--canon-space-2);
    }
    .check {
        flex: none;
        display: inline-grid;
        place-content: center;
        width: var(--check-side, 1.125em);
        aspect-ratio: 1;
    }
    .check::before {
        width: calc(var(--check-side, 1.125em) - 2 * var(--canon-line-width));
        aspect-ratio: 1;
        visibility: hidden;
    }
    .check[type="radio"]::before {
        width: 0;
    }
    .check:checked::before,
    .check:where([type="checkbox"]):indeterminate::before {
        visibility: visible;
    }

    .check {
        appearance: none;
        border: var(--canon-line-width) solid var(--check-line, var(--canon-theme-control-boundary));
        border-radius: var(--canon-radius-control);
        background-color: var(--check-surface, var(--canon-theme-field));
    }
    .check[type="radio"] {
        border-radius: var(--canon-radius-pill);
    }
    .check:checked,
    .check[type="checkbox"]:indeterminate {
        border-color: var(--check-selected, var(--canon-theme-action));
        background-color: var(--check-selected, var(--canon-theme-action));
    }
    .check:hover {
        border-color: var(--check-line-hover, var(--canon-theme-ink));
    }
    .check:checked:hover,
    .check:where([type="checkbox"]):indeterminate:hover {
        border-color: var(--check-selected-hover, var(--canon-theme-action-hover));
        background-color: var(--check-selected-hover, var(--canon-theme-action-hover));
    }
    .check:disabled {
        border-color: var(--canon-theme-line);
        background-color: var(--canon-theme-disabled);
    }
    .check[aria-invalid="true"] {
        border-color: var(--canon-theme-danger);
    }
    .check::before {
        background-color: currentColor;
        clip-path: polygon(13.72% 52.95%, 12.5% 50%, 13.72% 47.05%, 16.67% 45.83%, 19.61% 47.05%, 37.5% 64.94%, 37.5% 64.94%, 37.5% 64.94%, 80.39% 22.05%, 83.33% 20.83%, 86.28% 22.05%, 87.5% 25%, 86.28% 27.95%, 40.45% 73.78%, 37.5% 75%, 34.55% 73.78%);
    }
    .check:where([type="checkbox"]):indeterminate::before {
        clip-path: inset(45.83% 16.67% round 4.17%);
    }
    .check[type="radio"]::before {
        border: 0.25em solid currentColor;
        border-radius: var(--canon-radius-pill);
        clip-path: none;
    }
    @media (forced-colors: active) {
        .check {
            appearance: auto;
        }
    }

    .check {
        color: var(--check-mark, var(--canon-theme-on-action));
    }
    .check::before {
        content: "";
    }
    @media (forced-colors: active) {
        .check::before {
            content: none;
        }
    }

    .check-label,
    .check {
        cursor: pointer;
    }
    .check {
        transition: border-color var(--canon-duration-state), background-color var(--canon-duration-state);
    }
    .check:disabled {
        cursor: default;
    }
}
