/*
 * map.css — where the people are now: a quiet map, their pins, one person's route and card.
 *
 * <div class="app-map">
 *   <svg class="app-map-canvas" viewBox preserveAspectRatio="xMidYMid slice" role="img" aria-label="Karte">
 *     <path class="app-map-area" />                      (a town)
 *     <polyline class="app-map-road" data-kind="major | minor" />
 *     <text class="app-map-place">Linz</text>
 *     <polyline class="app-map-route" data-leg="driven | ahead" />   (the chosen person's day)
 *     <g class="app-map-stop" data-state="done | current | todo"><circle /><text>2</text></g>
 *     <g class="app-map-pin" data-late data-chosen><circle class="app-map-halo" /><circle /><text>MH</text></g>
 *   </svg>
 *   <div class="app-map-tools">[icon buttons: zoom in, zoom out]</div>
 * </div>
 *
 * <section class="app-map-card" aria-labelledby="id-title">   (the chosen person, over the map's end)
 *   <header class="app-map-card-head">
 *     [avatar] <span class="app-map-card-text"><h2 class="app-map-card-title" id="id-title">Markus Hofer</h2><span class="app-map-card-late">+20 Min.</span></span> [close]
 *   </header>
 *   <div class="app-map-card-actions">[Anrufen (primary link), Nachricht]</div>
 *   <ol class="app-map-tour" role="list">
 *     <li class="app-map-tour-stop" data-state="done | current | todo" aria-current="step">
 *       <span class="app-map-tour-marker" aria-hidden="true">1</span>
 *       <time class="app-map-tour-time">09:15</time>
 *       <span class="app-map-tour-place">Sparkasse</span>
 *       <span class="app-map-tour-late">+20 Min.</span>   (optional)
 *     </li>
 *   </ol>
 * </section>
 *
 * The map is a placeholder until the tiles come: the land a shade off the page, the roads
 * white with a faint casing, the places in subtle grey. Nothing on it has a colour but what is
 * chosen (the accent: the person's pin, their route, their stops) and who is late (the warning
 * tone, as a ring around the pin). The route already driven is solid, the rest dashed, the
 * stops numbered in the order of the day. The card of the chosen person floats over the map's
 * end from a region of 960; under it, it stands below the map.
 */
@layer components {
    .app-map {
        position: relative;
        min-block-size: var(--app-preview-height-narrow);
        overflow: hidden;
        border-radius: var(--app-radius-card);
        background: var(--app-color-surface-muted);
        box-shadow: 0 0 0 var(--app-border-width) var(--app-color-line);
    }

    .app-map-canvas {
        position: absolute;
        inset: 0;
        display: block;
        inline-size: 100%;
        block-size: 100%;
        font-family: var(--app-font-text);
    }

    .app-map-area {
        fill: var(--app-color-line);
    }

    .app-map-road {
        fill: none;
        stroke: var(--app-color-surface);
        stroke-linecap: round;
        stroke-linejoin: round;
    }

    .app-map-road[data-kind="casing"] {
        stroke: var(--app-color-line-strong);
    }

    .app-map-place {
        fill: var(--app-color-text-subtle);
        font-size: var(--app-text-count-size);
        font-weight: var(--app-text-chip-weight);
    }

    .app-map-route {
        fill: none;
        stroke: var(--app-color-accent);
        stroke-linecap: round;
        stroke-linejoin: round;
    }

    .app-map-stop circle {
        fill: var(--app-color-surface);
        stroke: var(--app-color-accent);
    }

    .app-map-stop text {
        fill: var(--app-color-accent-text);
        font-size: var(--app-text-count-size);
        font-weight: var(--app-text-strong-weight);
    }

    .app-map-stop[data-state="done"] circle {
        fill: var(--app-color-line-strong);
        stroke: var(--app-color-line-strong);
    }

    .app-map-pin circle {
        fill: var(--app-color-surface);
        stroke: var(--app-color-line-control);
    }

    .app-map-pin text {
        fill: var(--app-color-text);
        font-size: var(--app-text-count-size);
        font-weight: var(--app-text-strong-weight);
    }

    .app-map-pin[data-late] circle {
        stroke: var(--app-color-warning);
    }

    .app-map-pin[data-chosen] circle {
        fill: var(--app-color-accent);
    }

    .app-map-pin[data-chosen]:not([data-late]) circle {
        stroke: var(--app-color-accent);
    }

    .app-map-pin[data-chosen] text {
        fill: var(--app-color-text-on-accent);
    }

    .app-map-pin .app-map-halo {
        fill: var(--app-color-accent-soft);
        stroke: none;
    }

    .app-map-tools {
        position: absolute;
        inset-block-start: var(--app-space-board);
        inset-inline-start: var(--app-space-board);
        display: flex;
        flex-direction: column;
        gap: var(--app-space-list-inset);
    }

    /* ------------------------------------------------------------- the person's card */

    .app-map-card {
        display: flex;
        flex-direction: column;
        gap: var(--app-space-field);
        min-inline-size: 0;
        padding: var(--app-space-gutter-narrow);
        border-radius: var(--app-radius-card);
        background: var(--app-color-surface);
        box-shadow: 0 0 0 var(--app-border-width) var(--app-color-line);
    }

    /* From a region of 960 it floats over the map's end, so the map keeps its whole width. */
    @container app-region (width >= 960px) {
        .app-map-card {
            position: absolute;
            inset-block-start: var(--app-space-board);
            inset-inline-end: var(--app-space-board);
            inline-size: var(--app-sidebar-width);
            max-block-size: calc(100% - 2 * var(--app-space-board));
            overflow-y: auto;
            background: var(--app-color-surface-raised);
            box-shadow:
                0 0 0 var(--app-border-width) var(--app-color-line),
                var(--app-shadow-popover);
        }
    }

    .app-map-card-head {
        display: flex;
        align-items: center;
        gap: var(--app-space-choice);
    }

    /* Alone on a phone, the page's header names the person; the card keeps the rest. */
    @container app-region (width < 560px) {
        .app-map-card-head {
            display: none;
        }
    }

    .app-map-card-head > .app-avatar {
        background: var(--app-color-accent);
        color: var(--app-color-text-on-accent);
    }

    .app-map-card-text {
        display: flex;
        flex: 1 1 auto;
        flex-direction: column;
        min-inline-size: 0;
    }

    .app-map-card-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-map-card-late,
    .app-map-tour-late {
        color: var(--app-color-warning-text);
        font-size: var(--app-text-help-size);
        font-variant-numeric: tabular-nums;
        font-weight: var(--app-text-value-weight);
        line-height: var(--app-text-help-leading);
        white-space: nowrap;
    }

    .app-map-card-actions {
        display: flex;
        gap: var(--app-space-actions);
    }

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

    /* The tour: the day's stops in order, joined by a line; the one under way in the accent. */
    .app-map-tour {
        display: flex;
        flex-direction: column;
        padding: 0;
        list-style: none;
    }

    .app-map-tour-stop {
        position: relative;
        display: grid;
        grid-template-columns: var(--app-choice-size) auto minmax(0, 1fr) auto;
        align-items: center;
        gap: var(--app-space-choice);
        min-block-size: var(--app-control-height);
    }

    .app-map-tour-stop:not(:last-child)::before {
        content: "";
        position: absolute;
        inset-block: calc(50% + var(--app-choice-size) / 2) calc(-50% + var(--app-choice-size) / 2);
        inset-inline-start: calc((var(--app-choice-size) - var(--app-border-width)) / 2);
        inline-size: var(--app-border-width);
        background: var(--app-color-line-strong);
    }

    .app-map-tour-marker {
        display: flex;
        align-items: center;
        justify-content: center;
        inline-size: var(--app-choice-size);
        block-size: var(--app-choice-size);
        border-radius: var(--app-radius-round);
        background: var(--app-color-surface);
        color: var(--app-color-accent-text);
        font-size: var(--app-text-count-size);
        font-variant-numeric: tabular-nums;
        font-weight: var(--app-text-strong-weight);
        line-height: var(--app-text-help-leading);
        box-shadow: inset 0 0 0 var(--app-border-width-strong) var(--app-color-accent);
    }

    .app-map-tour-stop[data-state="done"] .app-map-tour-marker {
        background: var(--app-color-line-strong);
        box-shadow: none;
    }

    .app-map-tour-stop[data-state="current"] .app-map-tour-marker {
        background: var(--app-color-accent);
        color: var(--app-color-text-on-accent);
        box-shadow: 0 0 0 var(--app-space-list-inset) var(--app-color-accent-soft);
    }

    .app-map-tour-time {
        color: var(--app-color-text-muted);
        font-size: var(--app-text-body-size);
        font-variant-numeric: tabular-nums;
        line-height: var(--app-text-body-leading);
    }

    .app-map-tour-place {
        overflow: hidden;
        color: var(--app-color-text);
        font-size: var(--app-text-body-size);
        line-height: var(--app-text-body-leading);
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .app-map-tour-stop[data-state="done"] :is(.app-map-tour-time, .app-map-tour-place) {
        color: var(--app-color-text-subtle);
    }

    .app-map-tour-stop[data-state="current"] .app-map-tour-place {
        font-weight: var(--app-text-strong-weight);
    }

    .app-map-tour-stop[data-state="current"] .app-map-tour-time {
        color: var(--app-color-text);
        font-weight: var(--app-text-value-weight);
    }

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