/*
 * Die Tag-Eingabe.
 *
 * Eine Datei fuer alle drei Stellen - Hochladen geteilt, Hochladen
 * kommerziell, Bearbeiten. Die Farben kommen aus den Variablen der jeweiligen
 * Seite; steht dort keine, greift der Ersatzwert. So sieht das Feld im
 * Nutzerbereich und auf der Detailseite gleich aus, ohne dass eine der beiden
 * Seiten die Variablen der anderen kennen muss.
 *
 * Durchgehend logische Eigenschaften (padding-inline, margin-inline-start):
 * damit steht das Kreuz im Arabischen links vom Wort, ohne zweite Regel.
 */

.awu-tags {
    display: block;
    margin-block-end: 18px;
}

.awu-tags__label {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin-block-end: 7px;
    font-size: 14px;
    font-weight: 600;
    color: var(--d-ink-2, #2b2b3a);
}

.awu-tags__optional {
    font-weight: 400;
    font-size: 12px;
    color: var(--d-muted, #77778a);
}

/* Der Zaehler sitzt am Ende der Zeile - im Arabischen also links. */
.awu-tags__count {
    margin-inline-start: auto;
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    font-size: 12px;
    color: var(--d-muted, #77778a);
}

.awu-tags.is-full .awu-tags__count {
    color: var(--d-v, #6b4df6);
}

.awu-tags__box {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 7px;
    min-height: 48px;
    padding: 7px;
    border: 1px solid var(--d-line-soft, #d9d9e3);
    border-radius: var(--d-radius-sm, 10px);
    background: hsl(0 0% 100% / 0.92);
}

.awu-tags__box:focus-within {
    border-color: var(--d-v, #6b4df6);
    box-shadow: 0 0 0 3px var(--d-v-a10, rgba(107, 77, 246, 0.12));
    background: #fff;
}

.awu-tags.has-error .awu-tags__box {
    border-color: #b3261e;
}

.awu-tags__chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding-block: 5px;
    padding-inline: 11px 6px;
    border: 1px solid var(--d-v-a16, rgba(107, 77, 246, 0.18));
    border-radius: 999px;
    background: var(--d-v-a06, rgba(107, 77, 246, 0.07));
    color: var(--d-ink-2, #2b2b3a);
    font-size: 13px;
    font-weight: 550;
    max-width: 100%;
}

/* Ein langer Begriff bricht die Zeile nicht auf - er kuerzt sich. */
.awu-tags__chip-text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 22ch;
}

.awu-tags__chip-x {
    display: grid;
    place-items: center;
    width: 24px;
    height: 24px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: none;
    color: var(--d-muted, #77778a);
    cursor: pointer;
    line-height: 1;
}

.awu-tags__chip-x:hover {
    background: var(--d-v-a10, rgba(107, 77, 246, 0.12));
    color: var(--d-ink-2, #2b2b3a);
}

.awu-tags__chip-x:focus-visible {
    outline: 2px solid var(--d-v, #6b4df6);
    outline-offset: 2px;
}

.awu-tags__input {
    flex: 1 1 9ch;
    min-width: 9ch;
    min-height: 32px;
    border: 0;
    outline: 0;
    padding: 0 4px;
    background: transparent;
    color: inherit;
    font: inherit;
}

.awu-tags__add {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    /* 44px hoch: mit dem Daumen zu treffen, nicht nur mit der Maus. */
    min-height: 44px;
    margin-block-start: 8px;
    padding-inline: 16px;
    border: 1px solid var(--d-line-soft, #d9d9e3);
    border-radius: 999px;
    background: #fff;
    color: var(--d-ink-2, #2b2b3a);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}

.awu-tags__add span[aria-hidden] {
    font-size: 18px;
    line-height: 1;
}

.awu-tags__add:hover {
    border-color: var(--d-v, #6b4df6);
    color: var(--d-v, #6b4df6);
}

.awu-tags__add:focus-visible {
    outline: 2px solid var(--d-v, #6b4df6);
    outline-offset: 2px;
}

.awu-tags__hint {
    margin-block: 7px 0;
    font-size: 12.5px;
    line-height: 1.45;
    color: var(--d-muted, #77778a);
}

.awu-tags__error {
    display: block;
    margin-block-start: 5px;
    font-size: 12.5px;
    color: #b3261e;
}

.awu-tags__error:empty {
    display: none;
}

@media (max-width: 480px) {
    .awu-tags__add {
        width: 100%;
    }

    .awu-tags__chip-text {
        max-width: 16ch;
    }
}

/*
 * Mit dem Daumen statt mit der Maus.
 *
 * 24 Pixel reichen einem Zeiger und sind die Untergrenze der Richtlinie -
 * einem Daumen reichen sie nicht. Wo grob gezeigt wird, waechst die
 * Trefferflaeche des Kreuzes; die Chips bleiben dabei so hoch, dass eine
 * Zeile mit zehn Begriffen noch lesbar umbricht.
 */
@media (pointer: coarse) {
    .awu-tags__chip-x {
        width: 36px;
        height: 36px;
    }

    .awu-tags__chip {
        padding-inline: 14px 4px;
    }
}
