/*
 * state.css — what a list, a table or a card shows instead of its content: nothing there yet,
 * something went wrong, or still loading. Busy is a step that takes a moment and has nothing to
 * show yet (signing in): its icon turns, and stands still under reduced motion.
 *
 * <div class="app-state" data-tone="empty | error | busy" role="alert (error) | status (busy)">
 *   <span class="app-state-icon" aria-hidden="true">[icon 24]</span>
 *   <p class="app-state-title">Keine Aufträge</p>
 *   <p class="app-state-text">Für diesen Filter gibt es nichts.</p>
 *   <div class="app-state-actions">[buttons]</div>
 * </div>
 *
 * <span class="app-skeleton" aria-hidden="true"></span>
 *
 * The skeleton is a bar the height of a small text line that stands in for a value while it
 * loads. The box around it carries aria-busy; the bar itself says nothing. It pulses, unless
 * motion is reduced.
 */
@layer components {
    .app-state {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: var(--app-space-state-gap);
        padding: var(--app-space-state-y) var(--app-space-state-x);
        color: var(--app-color-text-muted);
        font-size: var(--app-text-body-size);
        line-height: var(--app-text-body-leading);
        text-align: center;
        white-space: normal;
    }

    /* The trace ID for support: a 20-tall text line the mono face sits inside, wrapping
       anywhere on a narrow screen, selectable as one word. */
    .app-state-reference {
        font-size: var(--app-text-label-size);
        line-height: var(--app-text-body-leading);
    }

    .app-state-reference > .app-code {
        white-space: normal;
        overflow-wrap: anywhere;
        user-select: all;
    }

    .app-state-icon {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        inline-size: var(--app-state-icon-size);
        block-size: var(--app-state-icon-size);
        border-radius: var(--app-radius-round);
        background: var(--app-color-surface-muted);
        color: var(--app-color-text-subtle);
    }

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

    .app-state[data-tone="busy"] .app-state-icon {
        background: var(--app-color-accent-subtle);
        color: var(--app-color-accent-text);
    }

    .app-state[data-tone="busy"] .app-state-icon .app-icon {
        animation: app-sync-turn var(--app-duration-busy) var(--app-easing-busy) infinite;
    }

    @media (prefers-reduced-motion: reduce) {
        .app-state[data-tone="busy"] .app-state-icon .app-icon {
            animation: none;
        }
    }

    .app-state-title {
        color: var(--app-color-text);
        font-weight: var(--app-text-strong-weight);
    }

    .app-state-text:empty,
    .app-state-actions:empty {
        display: none;
    }

    .app-state-actions {
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
        gap: var(--app-space-actions);
    }

    .app-skeleton {
        display: block;
        inline-size: 100%;
        block-size: var(--app-skeleton-height);
        border-radius: var(--app-radius-option);
        background: var(--app-color-skeleton);
        animation: app-pulse var(--app-duration-skeleton) var(--app-easing) infinite alternate;
    }

    @keyframes app-pulse {
        to {
            opacity: 0.4;
        }
    }

    /* 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) {
        .app-skeleton {
            outline: var(--app-border-width) solid var(--app-color-forced-line);
            outline-offset: calc(-1 * var(--app-border-width));
        }
    }
}
