/*
 * tabs.css
 *
 * <div class="app-tabs">
 *   <div class="app-tabs-list" role="tablist" aria-label>
 *     <button class="app-tab" type="button" role="tab" id aria-selected aria-controls tabindex disabled>
 *       Übersicht
 *     </button>
 *   </div>
 *   <div class="app-tabs-panel" role="tabpanel" id aria-labelledby tabindex="0">…</div>
 * </div>
 *
 * Only the selected tab's panel is in the DOM. The list scrolls sideways when it is wider than
 * the screen; it never wraps, and an edge with more tabs behind it fades out.
 */
@layer components {
    .app-tabs {
        display: flex;
        flex-direction: column;
        gap: var(--app-space-tabs);
        min-inline-size: 0;
    }

    .app-tabs-list {
        display: flex;
        overflow-x: auto;
        box-shadow: inset 0 calc(-1 * var(--app-border-width)) 0 var(--app-color-line);
        scrollbar-width: none;
        /* An edge with more tabs behind it fades (layout.css). */
        animation-name: app-scroll-fade;
        animation-timing-function: linear;
        animation-fill-mode: both;
        animation-timeline: scroll(self inline);
    }

    .app-tab {
        position: relative;
        display: inline-flex;
        flex: none;
        align-items: center;
        min-block-size: var(--app-control-height);
        padding: var(--app-space-control-y) var(--app-space-tab-x);
        border: 0;
        background: transparent;
        color: var(--app-color-text-muted);
        font-family: var(--app-font-text);
        font-size: var(--app-text-tab-size);
        font-weight: var(--app-text-tab-weight);
        line-height: var(--app-text-control-leading);
        white-space: nowrap;
        cursor: pointer;
        transition:
            color var(--app-duration-hover) var(--app-easing),
            box-shadow var(--app-duration-hover) var(--app-easing);
    }

    .app-tab[aria-selected="true"] {
        box-shadow: inset 0 calc(-1 * var(--app-border-width-strong)) 0 var(--app-color-accent);
        color: var(--app-color-text);
    }

    @media (hover: hover) {
        .app-tab:hover:not(:disabled, [aria-selected="true"]) {
            box-shadow: inset 0 calc(-1 * var(--app-border-width-strong)) 0 var(--app-color-line-control);
            color: var(--app-color-text);
        }
    }

    .app-tab:focus-visible {
        outline: var(--app-focus-ring-width) solid var(--app-color-focus);
        outline-offset: calc(-1 * var(--app-focus-ring-width));
    }

    .app-tab:disabled {
        color: var(--app-color-text-disabled);
        cursor: not-allowed;
    }

    /* What a tab holds stacks as a page's body does (a notice, then a form or a list). */
    .app-tabs-panel {
        display: flex;
        flex-direction: column;
        gap: var(--app-space-page-gap);
        min-inline-size: 0;
    }

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

    @media (pointer: coarse) {
        .app-tab {
            min-block-size: var(--app-touch-target);
        }
    }

    /* 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-tab[aria-selected="true"] {
            forced-color-adjust: none;
            background: var(--app-color-forced-current);
            color: var(--app-color-forced-current-text);
        }
        .app-tabs-list {
            border-block-end: var(--app-border-width) solid var(--app-color-forced-line);
        }
    }
}
