/* Champ de texte enrichi : même cadre que les autres champs, barre de mise en forme en tête. */

.rich-text { display: grid; gap: 6px; }
.rich-text-label { color: var(--text-secondary); font-size: var(--text-s); font-weight: 500; }

.rich-text-box {
  overflow: hidden; border: 1px solid var(--border-strong); border-radius: var(--radius-m); background-color: var(--bg-surface);
  transition: border-color 0.15s ease-out, box-shadow 0.15s ease-out;
}
.rich-text-box:hover { border-color: var(--text-muted); }
.rich-text-box:focus-within { border-color: var(--lake); box-shadow: 0 0 0 3px var(--lake-soft); }

.rich-text-toolbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 4px 5px; padding: 5px 6px;
  border-bottom: 1px solid var(--border); background-color: var(--bg-sunken);
}
.rich-text-group { display: inline-flex; align-items: center; gap: 2px; }
.rich-text-group + .rich-text-group { padding-left: 5px; border-left: 1px solid var(--border-strong); }
.rich-text-tool {
  display: grid; place-items: center; width: 32px; height: 32px; padding: 0; border: 0; border-radius: 8px;
  background: none; color: var(--text-primary); font: 600 16px/1 var(--font-sans); cursor: pointer;
  transition: background-color 0.15s ease-out, color 0.15s ease-out;
}
.rich-text-tool:hover { background-color: var(--bg-surface); }
.rich-text-tool[aria-pressed="true"] { background-color: var(--primary-soft); color: var(--primary); }
.rich-text-tool:focus-visible { outline: 2px solid var(--lake); outline-offset: 1px; }
.rich-text-tool .icon { width: 18px; height: 18px; }
.rich-text-tool[data-action="rich-text-color"] { width: 26px; }
.rich-text-tool b { font-weight: 800; }
.rich-text-tool i { font-family: var(--font-display); font-size: 18px; font-weight: 400; }
.rich-text-tool u { font-weight: 500; text-underline-offset: 3px; }

/* Pastilles de couleur, aux mêmes noms que les couleurs du texte. */
.rich-text-swatch {
  width: 18px; height: 18px; border-radius: 50%; background-color: var(--rich-text-color, var(--text-primary));
  box-shadow: inset 0 0 0 1px oklch(0 0 0 / 0.16);
}
.rich-text [data-color="or"] { --rich-text-color: #c8922f; }
.rich-text [data-color="prune"] { --rich-text-color: #a4457e; }
.rich-text [data-color="bleu"] { --rich-text-color: #3b77b5; }
.rich-text [data-color="vert"] { --rich-text-color: #3f8a5a; }
.rich-text [data-color="rouge"] { --rich-text-color: #c4493a; }

.rich-text-area {
  min-height: 120px; max-height: 280px; overflow-y: auto; padding: 10px var(--space-3);
  color: var(--text-primary); font-size: 16px; line-height: 1.5; overflow-wrap: break-word; outline: none;
}
.rich-text-area:empty::before { content: attr(data-placeholder); color: var(--text-muted); pointer-events: none; }
.rich-text-area :is(p, ul, ol) { margin: 0 0 0.5em; }
.rich-text-area :is(p, ul, ol):last-child { margin-bottom: 0; }
.rich-text-area :is(ul, ol) { padding-left: 1.4em; }
.rich-text-area ul { list-style: disc; }
.rich-text-area ol { list-style: decimal; }
.rich-text-area [data-color] { color: var(--rich-text-color); }

.rich-text-count { margin: 0; justify-self: end; color: var(--text-muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.rich-text-count.is-over { color: var(--color-error); font-weight: 600; }

@media (prefers-reduced-motion: reduce) {
  .rich-text-box, .rich-text-tool { transition: none; }
}
