/*
 * chip.css — status chip and toggle chip.
 *
 * Status, read only:
 * <span class="app-chip" data-tone="neutral | info | success | warning | danger | accent">
 *   <span class="app-chip-icon" aria-hidden="true">[icon]</span>
 *   <span class="app-chip-label">Offen</span>
 * </span>
 *
 * A status is neutral, info, success, warning or danger, and carries an icon as well, so it
 * reads without its colour (in sunlight, to a colour-blind eye, in a contrast theme). The screen
 * keeps one map from each status to its tone, icon and label. Accent is not a status: it marks
 * what is selected or a label that is not a state (DESIGN.md, the One Accent Rule).
 *
 * Count, a number beside a label:
 * <span class="app-badge" data-tone="neutral | accent | danger">12</span>
 *
 * Toggle, a filter that is on or off:
 * <button class="app-chip" type="button" aria-pressed disabled>
 *   <span class="app-chip-icon" aria-hidden="true">[icon]</span>
 *   <span class="app-chip-label">Heute</span>
 * </button>
 */
@layer components {
    .app-chip {
        position: relative;
        display: inline-flex;
        align-items: center;
        gap: var(--app-space-chip-gap);
        min-block-size: var(--app-chip-height);
        padding: var(--app-space-chip-y) var(--app-space-chip-x);
        border: var(--app-border-width) solid transparent;
        border-radius: var(--app-radius-chip);
        background: var(--app-color-surface-muted);
        color: var(--app-color-text-muted);
        font-family: var(--app-font-text);
        font-size: var(--app-text-chip-size);
        font-weight: var(--app-text-chip-weight);
        line-height: var(--app-text-control-leading);
        white-space: nowrap;
    }

    .app-chip-icon {
        display: inline-flex;
        flex: none;
    }

    .app-chip-icon:empty {
        display: none;
    }

    .app-chip[data-tone="accent"] {
        background: var(--app-color-accent-soft);
        color: var(--app-color-accent-text);
    }

    .app-chip[data-tone="info"] {
        background: var(--app-color-info-soft);
        color: var(--app-color-info-text);
    }

    .app-chip[data-tone="success"] {
        background: var(--app-color-success-soft);
        color: var(--app-color-success-text);
    }

    .app-chip[data-tone="warning"] {
        background: var(--app-color-warning-soft);
        color: var(--app-color-warning-text);
    }

    .app-chip[data-tone="danger"] {
        background: var(--app-color-danger-soft);
        color: var(--app-color-danger-text);
    }

    /* Toggle */
    button.app-chip {
        border-color: var(--app-color-line-control);
        background: var(--app-color-surface);
        color: var(--app-color-text);
        cursor: pointer;
        transition:
            background-color var(--app-duration-hover) var(--app-easing),
            border-color var(--app-duration-hover) var(--app-easing);
    }

    button.app-chip[aria-pressed="true"] {
        border-color: var(--app-color-accent);
        background: var(--app-color-accent-soft);
        color: var(--app-color-accent-text);
    }

    @media (hover: hover) {
        button.app-chip:hover:not(:disabled, [aria-pressed="true"]) {
            border-color: var(--app-color-line-hover);
            background: var(--app-color-surface-hover);
        }
    }

    button.app-chip:focus-visible {
        outline: var(--app-focus-ring-width) solid var(--app-color-focus);
        outline-offset: var(--app-focus-ring-offset);
    }

    button.app-chip:disabled {
        border-color: var(--app-color-line);
        background: var(--app-color-surface-disabled);
        color: var(--app-color-text-disabled);
        cursor: not-allowed;
    }

    @media (pointer: coarse) {
        button.app-chip::after {
            position: absolute;
            inset: calc((var(--app-chip-height) - var(--app-touch-target)) / 2) 0;
            content: "";
        }
    }

    .app-badge {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        min-inline-size: var(--app-badge-size);
        block-size: var(--app-badge-size);
        padding: 0 var(--app-space-badge-x);
        border-radius: var(--app-radius-chip);
        background: var(--app-color-surface-muted);
        color: var(--app-color-text-muted);
        font-size: var(--app-text-count-size);
        font-variant-numeric: tabular-nums;
        font-weight: var(--app-text-chip-weight);
        line-height: var(--app-text-help-leading);
    }

    .app-badge[data-tone="accent"] {
        background: var(--app-color-accent);
        color: var(--app-color-text-on-accent);
    }

    .app-badge[data-tone="danger"] {
        background: var(--app-color-danger);
        color: var(--app-color-text-on-accent);
    }

    /* Forced colours (a Windows contrast theme): shadows and backgrounds are gone, so frames
       are outlines and a chosen state is the system highlight. */
    @media (forced-colors: active) {
        button.app-chip[aria-pressed="true"] {
            forced-color-adjust: none;
            background: var(--app-color-forced-current);
            color: var(--app-color-forced-current-text);
        }
    }
}
