/*
 * Bilder im Guden Draht (Issue #392) – Knopf am Eingabefeld, Auswahl,
 * Vorschau vor dem Senden, kleine Vorschau im Verlauf, große Ansicht und die
 * Kameraansicht am Rechner. Skript: `chat-bild.js`. Gemeinsam für
 * Hörerfläche, Redaktion und Studio.
 *
 * Die Oberflächen des Guden Drahts sind durchgehend dunkel; große Ansicht und
 * Kamera hängen am `<body>` und tragen ihre Farben deshalb selbst – lesbar
 * im Hell- wie im Dunkelmodus des Geräts.
 */

/* Die Zeile mit dem Eingabefeld trägt das Auswahlmenü. */
.rgc-form__zeile,
.chatk-ansage { position: relative; }

/* In der Konsole liegt die Vorschau als Fläche **über** der Ansagezeile, wie
   das Emoji-Fenster: Die Zeile selbst (Feld mit `width: 100%`, Knöpfe) bleibt
   unverändert in ihrer Reihe und bricht nicht um. */
.chatk-ansage > .rgb-vorschau {
    position: absolute;
    left: 12px;
    right: 12px;
    bottom: calc(100% + 6px);
    z-index: 25;
    margin: 0;
    background: #1e1e25;
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.5);
}

.rgb-knopf {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 40px;
    padding: 0 14px;
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.07);
    color: #f5f5f7;
    font: inherit;
    font-size: 14px;
    cursor: pointer;
}
.rgb-knopf svg { width: 20px; height: 20px; fill: currentColor; }
.rgb-knopf:hover { background: rgba(255, 255, 255, 0.13); }
.rgb-knopf:disabled { opacity: 0.5; cursor: default; }
.rgb-knopf:focus-visible,
.rgb-menue__eintrag:focus-visible,
.rgb-bild:focus-visible,
.rgb-gross__zu:focus-visible { outline: 2px solid #ff3b30; outline-offset: 2px; }

.rgb-knopf--haupt { background: #da0000; border-color: #da0000; color: #fff; }
.rgb-knopf--haupt:hover { background: #b80000; }

/* Der runde Knopf links vom Feld – dieselbe Tippfläche wie der Emoji-Knopf. */
.rgb-knopf--rund {
    flex: 0 0 auto;
    width: 44px;
    height: 44px;
    min-height: 44px;
    padding: 0;
    border-radius: 50%;
}
.rgb-knopf--rund svg { width: 22px; height: 22px; }
.rgb-anhang[data-belegt="1"] { border-color: #ff3b30; color: #ff6b61; }
.rgb-anhang[aria-busy="true"] { opacity: 0.6; }

/* Die Dateifelder sind unsichtbar, aber nicht `display: none` – manche
   mobilen Browser öffnen die Auswahl eines ganz ausgeblendeten Feldes nicht. */
.rgb-datei {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    overflow: hidden;
    pointer-events: none;
}

.rgb-menue {
    position: absolute;
    left: 0;
    bottom: calc(100% + 6px);
    z-index: 30;
    display: flex;
    flex-direction: column;
    min-width: 200px;
    padding: 6px;
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 14px;
    background: #1e1e25;
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.5);
}
.rgb-menue[hidden] { display: none; }
.rgb-menue__eintrag {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 44px;
    padding: 0 12px;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: #f5f5f7;
    font: inherit;
    font-size: 15px;
    text-align: left;
    cursor: pointer;
}
.rgb-menue__eintrag svg { width: 22px; height: 22px; fill: currentColor; }
.rgb-menue__eintrag:hover { background: rgba(255, 255, 255, 0.1); }

/* ── Die Vorschau vor dem Senden ──────────────────────────────────────── */
.rgb-vorschau {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin: 0 0 8px;
    padding: 8px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.05);
    color: #f5f5f7;
}
.rgb-vorschau[hidden] { display: none; }
.rgb-vorschau__rahmen {
    flex: 0 0 auto;
    width: 96px;
    max-height: 128px;
    overflow: hidden;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.08);
}
.rgb-vorschau__bild { display: block; width: 100%; height: 100%; object-fit: cover; }
.rgb-vorschau__seite {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.rgb-vorschau__angabe,
.rgb-vorschau__lage { margin: 0; font-size: 13px; line-height: 1.35; }
.rgb-vorschau__angabe { color: rgba(245, 245, 247, 0.75); }
.rgb-vorschau__lage[data-fehler="1"] { color: #ff8a80; }
.rgb-vorschau__balken { width: 100%; height: 6px; accent-color: #da0000; }
.rgb-vorschau__balken[hidden] { display: none; }
.rgb-vorschau__knoepfe { display: flex; flex-wrap: wrap; gap: 8px; }

/* ── Das Bild in einer Chatzeile ──────────────────────────────────────── */
/* Breite und Seitenverhältnis stehen fest, bevor das Bild geladen ist – der
   Verlauf springt nicht, wenn es ankommt. */
/* `flex: none`: In einer Spaltenliste (App-Ansicht) würde die Fläche mit
   `overflow: hidden` sonst bis auf ihren Rahmen gestaucht, solange das Bild
   fehlt. */
.rgb-bild {
    display: block;
    flex: none;
    width: min(240px, 100%);
    max-height: 320px;
    margin: 4px 0 6px;
    padding: 0;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.06);
    cursor: zoom-in;
}
.rgb-bild__klein {
    display: block;
    width: 100%;
    height: 100%;
    max-height: 320px;
    object-fit: cover;
}
.rgb-bild[data-fehlt="1"] { cursor: default; opacity: 0.5; }

/* ── Die große Ansicht ───────────────────────────────────────────────── */
.rgb-gross,
.rgb-kamera {
    position: fixed;
    inset: 0;
    z-index: 2100;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
    background: rgba(0, 0, 0, 0.92);
    color: #f5f5f7;
    overscroll-behavior: contain;
}
.rgb-gross[hidden],
.rgb-kamera[hidden] { display: none; }
.rgb-gross__bild {
    max-width: 100%;
    max-height: calc(100% - 64px);
    object-fit: contain;
    border-radius: 6px;
}
.rgb-gross__satz { margin: 0; font-size: 15px; }
.rgb-gross__zu {
    position: absolute;
    top: max(12px, env(safe-area-inset-top));
    right: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.14);
    color: #fff;
    cursor: pointer;
}
.rgb-gross__zu svg { width: 24px; height: 24px; fill: currentColor; }

/* ── Die Kameraansicht am Rechner ────────────────────────────────────── */
.rgb-kamera__bild {
    max-width: min(100%, 960px);
    max-height: calc(100% - 120px);
    border-radius: 10px;
    background: #000;
}
.rgb-kamera__satz { margin: 0; font-size: 15px; text-align: center; }
.rgb-kamera__leiste { display: flex; gap: 12px; }
