/*
 * agenda.css — a person's own plan: today, then the days after, one list per day.
 *
 * <div class="app-agenda" aria-busy>
 *   <section class="app-agenda-day" aria-labelledby="id-2026-11-18" data-today>
 *     <header class="app-agenda-day-head">
 *       <h2 class="app-agenda-day-title" id="id-2026-11-18">Heute</h2>
 *       <p class="app-agenda-day-date">Mittwoch, 18. November</p>
 *     </header>
 *     <ol class="app-agenda-list">
 *       <li class="app-agenda-item" data-state="planned | progress | done | cancelled" data-kind="absence | on-call" data-allday data-next data-late>
 *         <a class="app-agenda-row" href>   (a div on the next one, which holds its own links)
 *           <span class="app-agenda-travel">35 Min. Fahrt</span>   (the drive there, if any)
 *           <span class="app-agenda-time">10:30</span>
 *           <span class="app-agenda-body">
 *             <span class="app-agenda-title">Gasthof Berger</span>   (an a on the next one)
 *             <span class="app-agenda-detail"><span class="app-agenda-status">in 25 Min.</span> · Wartung Klimaanlage · <span class="app-agenda-place">Linz, Hauptstraße 12</span></span>
 *               (the status and the place only where there is one, never the place of a done or cancelled one; joined by a middle dot)
 *           </span>
 *           <span class="app-agenda-actions">[button links: Navigation, Anrufen; the next one]</span>
 *         </a>
 *       </li>
 *       <li class="app-agenda-none"><span>Keine Termine</span></li>
 *       <li class="app-agenda-loading"><span>[skeleton][skeleton]</span></li>   (aria-busy on the list)
 *     </ol>
 *   </section>
 * </div>
 *
 * Two lines a row and one left edge: when it begins, then who; under it, in one muted line, the
 * status where there is one, the job and the place. The times share a column (subgrid), so the
 * day reads down by the clock. What is next is told by size: the customer in heading size, and
 * under it the two things a technician does next, find the way and call. Planned says nothing;
 * done and cancelled turn muted and say so first. Late is the one coloured word, in the warning
 * text. The drive to an appointment is a quiet line just above it. On call is a row at its own
 * time. On a phone the two actions share the width and are 48 tall, for a gloved thumb.
 */
@layer components {
    .app-agenda {
        display: flex;
        flex-direction: column;
        gap: var(--app-space-section);
        min-inline-size: 0;
        max-inline-size: var(--app-agenda-width);
    }

    .app-agenda-day {
        display: flex;
        flex-direction: column;
        gap: var(--app-space-agenda-head);
        min-inline-size: 0;
    }

    /* As tall as a section's heading row (section.css), so a day beside a section, or beside
       a card's header, starts its panel on the same line. */
    .app-agenda-day-head {
        display: flex;
        flex-wrap: wrap;
        align-content: center;
        align-items: baseline;
        gap: 0 var(--app-space-inline);
        min-block-size: var(--app-control-height);
        min-inline-size: 0;
    }

    .app-agenda-day-title {
        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);
    }

    .app-agenda-day-date {
        color: var(--app-color-text-muted);
        font-size: var(--app-text-body-size);
        line-height: var(--app-text-body-leading);
    }

    /* The day's panel. Its columns are the time and the rest; every row takes them (subgrid), so
       the times of a day line up whatever size the text is. */
    .app-agenda-list {
        display: grid;
        grid-template-columns: minmax(var(--app-agenda-time), max-content) minmax(0, 1fr);
        column-gap: var(--app-space-agenda-x);
        overflow: clip;
        padding: 0;
        border-radius: var(--app-radius-card);
        background: var(--app-color-surface);
        box-shadow: 0 0 0 var(--app-border-width) var(--app-color-line);
        list-style: none;
    }

    .app-agenda-list > li {
        display: grid;
        grid-column: 1 / -1;
        grid-template-columns: subgrid;
    }

    /* The line between two rows; on the row itself as well, so its hover does not cover it. */
    .app-agenda-list > li + li,
    .app-agenda-list > li + li > .app-agenda-row {
        box-shadow: inset 0 var(--app-border-width) 0 var(--app-color-line);
    }

    .app-agenda-row {
        display: grid;
        grid-column: 1 / -1;
        grid-template-columns: subgrid;
        padding: var(--app-space-agenda-y) var(--app-space-agenda-x);
        color: var(--app-color-text);
        text-decoration: none;
    }

    a.app-agenda-row {
        transition: background-color var(--app-duration-hover) var(--app-easing);
    }

    @media (hover: hover) {
        a.app-agenda-row:hover {
            background: var(--app-color-row-hover);
        }
    }

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

    .app-agenda-time {
        font-size: var(--app-text-body-size);
        font-weight: var(--app-text-value-weight);
        line-height: var(--app-text-body-leading);
        font-variant-numeric: tabular-nums;
    }

    .app-agenda-body {
        display: flex;
        flex-direction: column;
        min-inline-size: 0;
    }

    /* The whole day has no time: it stands where the times do. */
    .app-agenda-item[data-allday] .app-agenda-time {
        display: none;
    }

    .app-agenda-item[data-allday] .app-agenda-body {
        grid-column: 1 / -1;
    }

    .app-agenda-title {
        min-inline-size: 0;
        font-size: var(--app-text-body-size);
        font-weight: var(--app-text-value-weight);
        line-height: var(--app-text-body-leading);
        overflow-wrap: anywhere;
    }

    .app-agenda-detail {
        color: var(--app-color-text-muted);
        font-size: var(--app-text-body-size);
        line-height: var(--app-text-body-leading);
    }

    .app-agenda-detail:empty {
        display: none;
    }

    .app-agenda-status {
        font-variant-numeric: tabular-nums;
    }

    /* An address goes to the next line whole rather than break after its town. */
    .app-agenda-place {
        display: inline-block;
        max-inline-size: 100%;
    }

    /* Done and cancelled: still there, out of the way. */
    .app-agenda-item:is([data-state="done"], [data-state="cancelled"]) :is(.app-agenda-time, .app-agenda-title) {
        color: var(--app-color-text-muted);
    }

    /* What is next: the customer in heading size, its link covering the row, as every other row
       is a link; the actions lie over it. */
    .app-agenda-item[data-next] .app-agenda-row {
        position: relative;
        row-gap: var(--app-space-agenda-actions);
        transition: background-color var(--app-duration-hover) var(--app-easing);
    }

    .app-agenda-item[data-next] .app-agenda-body {
        gap: var(--app-space-term);
    }

    /* The time keeps its size, so the column is one width every day; on the title's line. */
    .app-agenda-item[data-next] .app-agenda-time {
        line-height: var(--app-text-heading-leading);
    }

    .app-agenda-item[data-next] .app-agenda-title {
        border-radius: var(--app-radius-option);
        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-decoration-line: underline;
        text-decoration-thickness: var(--app-link-underline-width);
        text-underline-offset: var(--app-link-underline-offset);
    }

    .app-agenda-item[data-next] a.app-agenda-title::after {
        position: absolute;
        inset: 0;
        content: "";
    }

    @media (hover: hover) {
        .app-agenda-item[data-next] .app-agenda-row:has(a.app-agenda-title:hover) {
            background: var(--app-color-row-hover);
        }

        .app-agenda-item[data-next] a.app-agenda-title:hover {
            color: var(--app-color-accent-text);
        }
    }

    .app-agenda-item[data-next] a.app-agenda-title:focus-visible {
        outline: var(--app-focus-ring-width) solid var(--app-color-focus);
        outline-offset: var(--app-focus-ring-offset);
    }

    .app-agenda-item[data-late] .app-agenda-status {
        color: var(--app-color-warning-text);
        font-weight: var(--app-text-label-weight);
    }

    .app-agenda-actions {
        position: relative;
        display: flex;
        grid-column: 2;
        flex-wrap: wrap;
        gap: var(--app-space-actions);
    }

    /* The drive there: a quiet line over the row's text, part of the row it leads to. */
    .app-agenda-row {
        row-gap: var(--app-space-agenda-band);
    }

    .app-agenda-travel {
        grid-column: 2;
        color: var(--app-color-text-subtle);
        font-size: var(--app-text-help-size);
        line-height: var(--app-text-help-leading);
        font-variant-numeric: tabular-nums;
    }

    .app-agenda-none {
        padding: var(--app-space-agenda-y) var(--app-space-agenda-x);
        color: var(--app-color-text-subtle);
        font-size: var(--app-text-body-size);
        line-height: var(--app-text-body-leading);
    }

    .app-agenda-none > span {
        grid-column: 1 / -1;
    }

    /* Loading: two bars a row, where the title and the detail will be. */
    .app-agenda-loading {
        padding: var(--app-space-agenda-y) var(--app-space-agenda-x);
    }

    .app-agenda-loading > span {
        display: flex;
        grid-column: 1 / -1;
        flex-direction: column;
        gap: var(--app-space-term);
    }

    .app-agenda-loading .app-skeleton + .app-skeleton {
        max-inline-size: var(--app-agenda-skeleton-short);
    }

    @container app-region (width < 560px) {
        .app-agenda-actions {
            grid-column: 1 / -1;
        }

        .app-agenda-actions > * {
            flex: 1 1 0;
        }
    }

    /* Forced colours (a Windows contrast theme): shadows and backgrounds are gone, so frames
       are outlines and the rows keep their lines. */
    @media (forced-colors: active) {
        .app-agenda-list {
            outline: var(--app-border-width) solid var(--app-color-forced-line);
            outline-offset: calc(-1 * var(--app-border-width));
        }

        .app-agenda-list > li + li {
            border-block-start: var(--app-border-width) solid var(--app-color-forced-line);
        }
    }
}
