/* Formatierter Text aus dem Editor (TSP-Trainings, News) und der Editor selbst (rich-editor.js) */

.rich-text {
    font-family: "Exo 2", system-ui, sans-serif;
    line-height: 1.75;
    margin: 1rem 0;
    word-break: break-word;
}
.rich-text > * + * { margin-top: 0.85rem; }
.rich-text h2, .rich-text h3, .rich-text h4 { line-height: 1.3; margin-top: 1.8rem; }
.rich-text > :first-child { margin-top: 0; }
.rich-text h2 { font-size: 1.45rem; color: var(--font); }
.rich-text h3 { font-family: "Exo 2", system-ui, sans-serif; font-size: 1.2rem; font-weight: 700; }
.rich-text h4 { font-family: "Exo 2", system-ui, sans-serif; font-size: 1.02rem; font-weight: 700; color: var(--brand-neon-lime); }
.rich-text ul, .rich-text ol { padding-left: 1.5rem; }
.rich-text li + li { margin-top: 0.25rem; }
.rich-text li > p { margin: 0; }
.rich-text a { color: #8f74ff; }
.rich-text blockquote {
    border-left: 3px solid var(--brand-night-sky-blue);
    padding: 0.2rem 0 0.2rem 1rem;
    color: var(--font-secundary);
}
.rich-text code {
    font-family: ui-monospace, Consolas, monospace;
    font-size: 0.9em;
    background: var(--bg-elevated);
    padding: 0.1rem 0.35rem;
    border-radius: 5px;
}
.rich-text pre {
    background: var(--background);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.8rem 1rem;
    overflow-x: auto;
}
.rich-text pre code { background: none; padding: 0; }
.rich-text hr { border: none; border-top: 1px solid var(--border); margin: 1.5rem 0; }
.rich-text img {
    display: block;
    max-width: 100%;
    height: auto;
    border-radius: 10px;
    border: 1px solid var(--border);
}

/* Editor (TipTap/ProseMirror). Die Grundstyles setzt TipTap sonst inline -- die CSP verbietet das */
.rte {
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--background);
    margin-bottom: 1rem;
}
.rte:focus-within { border-color: #4D21EB; box-shadow: 0 0 0 3px rgba(77, 33, 235, 0.25); }
.rte-toolbar {
    position: sticky;
    top: 0;
    z-index: 2;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.2rem;
    padding: 0.4rem;
    border-bottom: 1px solid var(--border);
    background: var(--bg-card);
    border-radius: 10px 10px 0 0;
}
.rte-btn {
    min-width: 2.1rem;
    height: 2.1rem;
    padding: 0 0.5rem;
    border: 1px solid transparent;
    border-radius: 6px;
    background: none;
    color: var(--font-secundary);
    font: 600 0.85rem "Exo 2", system-ui, sans-serif;
    cursor: pointer;
}
.rte-btn:hover { background: var(--bg-elevated); color: var(--font); }
.rte-btn.is-active { background: rgba(77, 33, 235, 0.25); border-color: #4D21EB; color: var(--font); }
.rte-sep { width: 1px; height: 1.4rem; background: var(--border); margin: 0 0.25rem; }
.rte-surface { padding: 1rem 1.2rem; cursor: text; }
.rte .rich-text { min-height: 18rem; margin: 0; outline: none; }
.rte .ProseMirror { white-space: pre-wrap; word-wrap: break-word; font-variant-ligatures: none; }
.rte .ProseMirror-selectednode { outline: 2px solid #8f74ff; }
.rte img.ProseMirror-selectednode { outline-offset: 2px; }
.rte .ProseMirror-gapcursor { display: none; pointer-events: none; position: absolute; }
.rte .ProseMirror-gapcursor:after { content: ""; display: block; position: absolute; top: -2px; width: 20px; border-top: 1px solid var(--font); }
.rte .ProseMirror-focused .ProseMirror-gapcursor { display: block; }
.rte .ProseMirror-hideselection *::selection { background: transparent; }
.rte .is-editor-empty:first-child::before {
    content: attr(data-placeholder);
    float: left;
    height: 0;
    pointer-events: none;
    color: var(--muted);
}
.rte-status { min-height: 1.2rem; margin: 0; padding: 0 1.2rem 0.5rem; font-size: 0.85rem; color: var(--font-secundary); }
.rte-status.is-error { color: var(--brand-bright-red); }

.rte-slash {
    position: absolute;
    z-index: 50;
    width: 260px;
    max-height: 320px;
    overflow-y: auto;
    padding: 0.35rem;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.45);
}
.rte-slash-item {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    width: 100%;
    padding: 0.45rem 0.6rem;
    border: none;
    border-radius: 6px;
    background: none;
    color: var(--font);
    font: 0.9rem "Exo 2", system-ui, sans-serif;
    text-align: left;
    cursor: pointer;
}
.rte-slash-item span { font-size: 0.78rem; color: var(--font-secundary); }
.rte-slash-item.is-selected, .rte-slash-item:hover { background: rgba(77, 33, 235, 0.3); }
.rte-slash-empty { padding: 0.5rem 0.6rem; color: var(--font-secundary); font-size: 0.85rem; }

/* Handy: Werkzeugleiste in einer Zeile, waagerecht wischbar statt dreizeilig */
@media (max-width: 600px) {
    .rte-toolbar { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
    .rte-toolbar::-webkit-scrollbar { display: none; }
    .rte-btn { flex-shrink: 0; }
    .rte-sep { flex-shrink: 0; }
    .rte-surface { padding: 0.85rem 0.9rem; }
    .rte .rich-text { min-height: 14rem; }
}
