/*
 * board.css — a list as lanes of cards: orders by where they stand.
 *
 * <div class="app-board" role="group" aria-label="Aufträge nach Status">
 *   <section class="app-board-column" data-column="neu" aria-labelledby="id-title" data-drop="allowed | refused" data-over>
 *     <header class="app-board-column-header">
 *       <h2 class="app-board-column-title" id="id-title">Neu</h2>
 *       <span class="app-badge" data-tone="neutral">12</span>
 *       <p class="app-board-column-states">Offen, Angefragt</p>
 *     </header>
 *     <ul class="app-board-cards" role="list">                (with cards; an empty lane has the line below instead)
 *       <li class="app-board-card" data-card="A-2026-0142" data-moves="geplant fertig" data-dragging>
 *         <a class="app-board-card-link" href="…" draggable="false">Kompressor tauschen</a>
 *         <span class="app-board-card-detail">Kaltwassersatz KWS 2 · Gasthof Berger</span>
 *         <span class="app-board-card-meta">seit 14.11.</span>                    (optional)
 *         <div class="app-board-card-foot">[step chip] [avatar] … [menu: the step's commands]</div>  (optional)
 *       </li>
 *     </ul>
 *     <p class="app-board-column-empty">Nichts hier</p>        (an empty lane, in place of the list)
 *     [load more]
 *   </section>
 * </div>
 *
 * A lane holds one or more steps (In Arbeit: In Arbeit and Pausiert), named under its title;
 * each card carries its own step, as a lane may hold several. Which steps go into which lane is
 * the tenant's (a setting); a step in no lane is not on the board. A card is one link, its title; the whole
 * card takes the click, and its menu (above the link) holds the step's commands, for the keyboard,
 * for a hand that cannot drag, and for the moves that stay within a lane. Dragged (fsm-ui.js: at once with a mouse, after a long press on touch), the
 * card leaves a dashed place behind and follows the pointer; the lanes it may go to are marked,
 * the others are left as they are and refuse it, and the one under the pointer is lit. Which lanes a card may go to is
 * the screen's to say (data-moves): a lane holding a step one command takes it to. Dropped, the
 * screen runs that command; where two would do, it asks which.
 *
 * Lanes stand side by side, at least 240 wide, and the board scrolls sideways when they do not
 * fit. On a phone one lane at a time fills the screen but for the next one peeking in, and the
 * board snaps from lane to lane. A lane pages its cards itself (load more), as each is its own
 * query.
 */
@layer components {
    .app-board {
        display: grid;
        grid-auto-columns: minmax(var(--app-board-column-min), 1fr);
        grid-auto-flow: column;
        gap: var(--app-space-board);
        align-items: start;
        overflow-x: auto;
        overscroll-behavior-x: contain;
        scrollbar-width: thin;
    }

    .app-board-column {
        display: flex;
        flex-direction: column;
        gap: var(--app-space-board-lane);
        min-inline-size: 0;
        padding: var(--app-space-board-lane);
        border-radius: var(--app-radius-board-lane);
        background: var(--app-color-surface-muted);
        transition:
            background-color var(--app-duration-hover) var(--app-easing),
            box-shadow var(--app-duration-hover) var(--app-easing);
    }

    .app-board-column-header {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        align-items: center;
        column-gap: var(--app-space-inline);
        padding: 0 var(--app-space-board-card-text);
    }

    .app-board-column-title {
        overflow: hidden;
        color: var(--app-color-text);
        font-family: var(--app-font-display);
        font-size: var(--app-text-heading-size);
        font-weight: var(--app-text-heading-weight);
        line-height: var(--app-text-heading-leading);
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .app-board-column-states {
        grid-column: 1 / -1;
        overflow: hidden;
        color: var(--app-color-text-subtle);
        font-size: var(--app-text-help-size);
        line-height: var(--app-text-help-leading);
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .app-board-cards {
        display: flex;
        flex-direction: column;
        gap: var(--app-space-board-cards);
    }

    .app-board-column-empty {
        padding: var(--app-space-board-card);
        color: var(--app-color-text-subtle);
        font-size: var(--app-text-body-size);
        line-height: var(--app-text-body-leading);
        text-align: center;
    }

    .app-board-card {
        position: relative;
        display: flex;
        flex-direction: column;
        gap: var(--app-space-board-card-text);
        min-inline-size: 0;
        padding: var(--app-space-board-card);
        border-radius: var(--app-radius-board-card);
        background: var(--app-color-surface);
        box-shadow:
            0 0 0 var(--app-border-width) var(--app-color-line),
            var(--app-shadow-card);
        cursor: grab;
        user-select: none;
        -webkit-touch-callout: none;
        transition: box-shadow var(--app-duration-hover) var(--app-easing);
    }

    .app-board-card-link {
        display: -webkit-box;
        overflow: hidden;
        color: var(--app-color-text);
        font-size: var(--app-text-body-size);
        font-weight: var(--app-text-link-weight);
        line-height: var(--app-text-body-leading);
        text-decoration: none;
        overflow-wrap: anywhere;
        -webkit-box-orient: vertical;
        -webkit-line-clamp: 2;
        -webkit-user-drag: none;
    }

    .app-board-card-link::after {
        position: absolute;
        inset: 0;
        border-radius: var(--app-radius-board-card);
        content: "";
    }

    .app-board-card-link:focus-visible {
        outline: none;
    }

    .app-board-card-link:focus-visible::after {
        outline: var(--app-focus-ring-width) solid var(--app-color-focus);
        outline-offset: var(--app-focus-ring-offset);
    }

    .app-board-card-detail,
    .app-board-card-meta {
        overflow: hidden;
        font-size: var(--app-text-help-size);
        line-height: var(--app-text-help-leading);
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .app-board-card-detail {
        color: var(--app-color-text-muted);
    }

    .app-board-card-meta {
        color: var(--app-color-text-subtle);
        font-variant-numeric: tabular-nums;
    }

    /* The status and the person first; the menu at the end, above the card's link. */
    .app-board-card-foot {
        display: grid;
        grid-template-columns: auto auto minmax(0, 1fr) auto;
        align-items: center;
        gap: var(--app-space-inline);
        min-block-size: calc(var(--app-control-height-compact) + var(--app-space-board-card-text));
        padding-block: var(--app-space-board-card-text) 0;
    }

    .app-board-card-foot > .app-menu {
        position: relative;
        grid-column: -2 / -1;
    }

    @media (hover: hover) {
        .app-board-card:hover {
            box-shadow:
                0 0 0 var(--app-border-width) var(--app-color-line-hover),
                var(--app-shadow-card);
        }
    }

    /* ---------------------------------------------------------------- dragging */

    /* The place it left: a dashed frame, the card faded in it. */
    .app-board-card[data-dragging] {
        box-shadow: none;
        outline: var(--app-border-width) dashed var(--app-color-line-strong);
        outline-offset: calc(-1 * var(--app-border-width));
        background: none;
    }

    .app-board-card[data-dragging] > * {
        visibility: hidden;
    }

    /* What follows the pointer: the card, lifted (fsm-ui.js places it). */
    .app-board-card[data-ghost] {
        position: fixed;
        z-index: var(--app-z-modal);
        box-shadow:
            0 0 0 var(--app-border-width) var(--app-color-line),
            var(--app-shadow-board-lifted);
        cursor: grabbing;
        pointer-events: none;
    }

    .app-board-column[data-drop="allowed"] {
        box-shadow: inset 0 0 0 var(--app-border-width) var(--app-color-accent);
    }

    .app-board-column[data-drop="allowed"][data-over] {
        background: var(--app-color-accent-soft);
        box-shadow: inset 0 0 0 var(--app-focus-ring-width) var(--app-color-accent);
    }

    /* On the wash the subtle line would fade below contrast; it takes the muted text. */
    .app-board-column[data-drop="allowed"][data-over] .app-board-column-states {
        color: var(--app-color-text-muted);
    }

    /* A lane that refuses the card is left as it is, framed in nothing, its text at full
       contrast: the blue frames say where it may go. */
    .app-board-column[data-drop="refused"][data-over] {
        cursor: no-drop;
    }

    /* Dragging, the board scrolls under the card at its edges (fsm-ui.js), lane by lane snapping
       would fight it. */
    .app-board[data-dragging] {
        scroll-snap-type: none;
    }

    /* A phone: one lane and the next one peeking in, snapping lane to lane. */
    @container app-region (width < 560px) {
        .app-board:not([data-dragging]) {
            scroll-snap-type: x mandatory;
        }

        .app-board {
            grid-auto-columns: calc(100% - var(--app-space-board-peek));
        }

        .app-board-column {
            scroll-snap-align: start;
        }
    }

    @media (prefers-reduced-motion: reduce) {
        .app-board-column,
        .app-board-card {
            transition: none;
        }
    }

    @media (forced-colors: active) {
        .app-board-column,
        .app-board-card {
            outline: var(--app-border-width) solid var(--app-color-forced-line);
            outline-offset: calc(-1 * var(--app-border-width));
        }

        .app-board-column[data-drop="allowed"] {
            outline: var(--app-focus-ring-width) solid var(--app-color-forced-current);
        }
    }
}
