/*
 * link.css — a text link that does something on the spot: call, find the way, write, open.
 *
 * <a class="app-link" href="tel:+43732123456">
 *   <span class="app-link-icon" aria-hidden="true">[phone | map-pin | …]</span>
 *   <span class="app-link-label">+43 732 123456</span>
 * </a>
 *
 * In the accent text colour, always underlined (a touch screen has no hover to reveal it), at
 * the weight of a label so it holds up in sunlight. The icon sits on the first line when the
 * label wraps, as an address does. On a touch screen the hit area is at least the touch target
 * high, whatever the line height; the link keeps its own width. It takes the size of the text
 * around it, so in a description value (form.css) it is body text. Where the link leads is the
 * screen's: tel:, mailto:, a maps address, a route.
 */
@layer components {
    .app-link {
        position: relative;
        display: inline-flex;
        align-items: flex-start;
        gap: var(--app-space-link-gap);
        max-inline-size: 100%;
        border-radius: var(--app-radius-option);
        color: var(--app-color-accent-text);
        font-weight: var(--app-text-link-weight);
        text-decoration-line: underline;
        text-decoration-thickness: var(--app-link-underline-width);
        text-underline-offset: var(--app-link-underline-offset);
        /* On the baseline an inline flex box adds the descent below it; on top it is exactly
           its lines tall, so the line keeps its height. */
        vertical-align: top;
    }

    .app-link-icon {
        display: inline-flex;
        flex: none;
        align-items: center;
        block-size: var(--app-text-body-leading);
    }

    .app-link-icon:empty {
        display: none;
    }

    .app-link-label {
        min-inline-size: 0;
    }

    @media (hover: hover) {
        .app-link:hover {
            color: var(--app-color-text);
        }
    }

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

    /* Touch: the hit area reaches the touch target high. */
    @media (pointer: coarse) {
        .app-link::after {
            position: absolute;
            inset-block-start: 50%;
            inset-inline: 0;
            block-size: max(100%, var(--app-touch-target));
            translate: 0 -50%;
            content: "";
        }
    }
}
