/*
 * Formatierter Text (Portal\RichText, seit 1.72.0) und Zeichenzähler – seit 1.80.0 eine eigene Datei, damit auch öffentliche
 * Seiten mit Schlüssel (ohne den Rahmen des Portals) den Editor bekommen: PublicContext::richTextAssets(). Im Portal lädt sie
 * das Layout nach app.css. Farben über die Variablen des Kerns, mit Ersatzwerten, wo es sie nicht gibt.
 */
/* ---------- Formatierter Text (seit 1.72.0): Portal\RichText::field(), Editor in app.js ----------
   Ohne JavaScript bleibt das Textfeld. Mit JavaScript: Knopfleiste mit Text (keine reinen Symbole), darunter der Text so,
   wie er aussieht. Plugins können den Text im Editor wie in ihrem Medium setzen: .mein-plugin .richtext__editor h2 { … } */
.richtext { min-width: 0; }
.richtext.is-bereit { border: 1px solid var(--line, #d6dde2); border-radius: var(--radius, 4px); background: var(--surface, #ffffff); }
.richtext.is-bereit.is-fokus { outline: 2px solid var(--accent, #235d70); outline-offset: 1px; }
.richtext__leiste { display: flex; flex-wrap: wrap; gap: 0.25rem; padding: 0.35rem 0.4rem; border-bottom: 1px solid var(--line-soft, #edf1f3); background: var(--surface-alt, #f6f8f9); border-radius: var(--radius, 4px) var(--radius, 4px) 0 0; }
.richtext__knopf {
  font: inherit; font-size: 0.82rem; line-height: 1.2; padding: 0.3rem 0.55rem; border: 1px solid var(--line, #d6dde2); border-radius: var(--radius, 4px);
  background: var(--surface, #ffffff); color: var(--ink, #1f2b33); cursor: pointer;
}
.richtext__knopf:hover { border-color: var(--accent, #235d70); color: var(--accent-strong, #184554); }
.richtext__knopf[aria-pressed="true"] { background: var(--accent-tint, rgba(35, 93, 112, 0.10)); border-color: var(--accent, #235d70); color: var(--accent-strong, #184554); }
.richtext__knopf--fett { font-weight: 700; }
.richtext__knopf--kursiv { font-style: italic; }
.richtext__link { display: flex; flex-wrap: wrap; align-items: end; gap: 0.4rem 0.6rem; padding: 0.5rem 0.6rem; border-bottom: 1px solid var(--line-soft, #edf1f3); background: var(--surface-alt, #f6f8f9); }
.richtext__link[hidden] { display: none; }
.richtext__link-bez { display: flex; flex-direction: column; gap: 0.2rem; flex: 1 1 16rem; font-size: 0.82rem; color: var(--muted, #58666f); }
.richtext__link-bez .input { max-width: none; }
.richtext__link-knoepfe { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.richtext__editor { padding: 0.6rem 0.75rem; line-height: 1.55; outline: none; overflow-wrap: anywhere; cursor: text; }
.richtext__editor > :first-child { margin-top: 0; }
.richtext__editor > :last-child { margin-bottom: 0; }
.richtext__editor p { margin: 0 0 0.75em; }
.richtext__editor h2 { font-size: 1.3em; line-height: 1.25; margin: 1em 0 0.4em; }
.richtext__editor h3 { font-size: 1.1em; line-height: 1.3; margin: 0.9em 0 0.35em; }
.richtext__editor ul, .richtext__editor ol { margin: 0 0 0.75em; padding-left: 1.5em; }
.richtext__editor blockquote { margin: 0 0 0.75em; padding: 0.1em 0 0.1em 0.9em; border-left: 3px solid var(--accent-line-strong, rgba(35, 93, 112, 0.45)); color: var(--ink, #1f2b33); }
.richtext__editor a { color: var(--accent, #235d70); }
.richtext__editor { position: relative; }
.richtext.is-leer .richtext__editor[data-placeholder]::before { content: attr(data-placeholder); position: absolute; left: 0.75rem; top: 0.6rem; color: #9aa5ad; pointer-events: none; }

/* Seit 1.80.0: wahlweise Unterstrichen und Hervorheben (Option 'extras'), Werkzeuge unter dem Feld (Option 'tools') */
.richtext__knopf--unter { text-decoration: underline; }
.richtext__knopf--markiert { background: linear-gradient(transparent 55%, #fde68a 55%); }
.richtext__knopf--markiert[aria-pressed="true"] { background: linear-gradient(transparent 55%, #fcd34d 55%), var(--accent-tint, rgba(35, 93, 112, 0.10)); }
.richtext__editor u { text-decoration-thickness: 1px; text-underline-offset: 0.15em; }
.richtext__editor mark { background: #fde68a; color: inherit; padding: 0 0.1em; border-radius: 2px; }
.richtext__werkzeuge { display: flex; flex-wrap: wrap; align-items: center; gap: 0.35rem 0.5rem; padding: 0.4rem 0.6rem; border-top: 1px solid var(--line-soft, #edf1f3); background: var(--surface-alt, #f6f8f9); border-radius: 0 0 var(--radius, 4px) var(--radius, 4px); }
.richtext__werkzeug-stand { font-size: 0.82rem; color: var(--muted, #58666f); }
.richtext:not(.is-bereit) .richtext__werkzeuge { display: none; }

/* Zähler (Portal-Felder mit data-count data-max) – auf Seiten ohne app.css; im Portal gelten die Regeln dort */
:where(.field__count) { font-size: 0.78rem; line-height: 1.3; color: var(--muted, #58666f); white-space: nowrap; visibility: hidden; pointer-events: none; }
:where(.field__count.is-visible) { visibility: visible; }
:where(.field__count.is-full) { color: var(--warn, #85560a); font-weight: 600; }
:where(.field__count.is-over) { color: var(--danger, #9a2d2d); font-weight: 700; }
:where(.field__count--under) { display: none; max-width: 100%; margin: 0.2rem auto 0 0; text-align: right; visibility: visible; }
:where(.field__count--under.is-visible) { display: block; }

/* Knöpfe und Eingabefeld der Linkzeile und der Werkzeuge – nur, wo app.css fehlt (keine Spezifität) */
:where(.richtext) :where(.btn-mini) { display: inline-flex; align-items: center; justify-content: center; gap: 0.3rem; font: inherit; font-size: 0.85rem; font-weight: 600; line-height: 1.5; padding: 0.25rem 0.55rem; border: 1px solid var(--line, #d6dde2); border-radius: var(--radius, 4px); background: var(--surface, #fff); color: var(--accent, #235d70); cursor: pointer; }
:where(.richtext) :where(.btn-mini--primary) { background: var(--accent, #235d70); border-color: var(--accent, #235d70); color: #fff; }
:where(.richtext) :where(.btn-mini[hidden]) { display: none; }
:where(.richtext) :where(.input) { font: inherit; width: 100%; padding: 0.45rem 0.6rem; border: 1px solid var(--line, #d6dde2); border-radius: var(--radius, 4px); background: var(--surface, #fff); color: var(--ink, #1f2b33); box-sizing: border-box; }
