/*
 * rich-content.css — rendu des formats de l'éditeur Quill (palette, images,
 * encadrés, séparateur), partagé par l'éditeur admin (.ql-editor) et les
 * conteneurs publics (.rich-content). Configuration JS : quill-setup.js.
 *
 * Hors @layer, et chargé APRÈS quill.snow.css côté admin : Quill définit déjà
 * .ql-editor .ql-color-white / .ql-bg-black à spécificité égale.
 *
 * Palette sémantique : « foncé » = fort contraste avec le fond, « clair » =
 * teinte douce. En mode sombre (site public uniquement, l'admin reste clair),
 * les rôles s'inversent pour que rien de ce qui est lisible en clair ne
 * devienne illisible : Noir ↔ Blanc, foncé et clair échangent leur luminosité.
 */

:root {
    /* ── Texte ── */
    --rc-fg-black:       #111111;
    --rc-fg-gray:        #6b7785;
    --rc-fg-white:       #ffffff;
    --rc-fg-bluedark:    #004d82;
    --rc-fg-bluelight:   #5aa9dc;
    --rc-fg-orangedark:  #b5450f;
    --rc-fg-orangelight: #f0904f;
    --rc-fg-reddark:     #a8231a;
    --rc-fg-redlight:    #e8655a;
    --rc-fg-greendark:   #1a6b35;
    --rc-fg-greenlight:  #5cb978;

    /* ── Fond ── */
    --rc-bg-black:       #111111;
    --rc-bg-gray:        #e6eaef;
    --rc-bg-white:       #ffffff;
    --rc-bg-bluedark:    #004d82;
    --rc-bg-bluelight:   #dcecf8;
    --rc-bg-orangedark:  #b5450f;
    --rc-bg-orangelight: #fde5d4;
    --rc-bg-reddark:     #a8231a;
    --rc-bg-redlight:    #fadcd9;
    --rc-bg-greendark:   #1a6b35;
    --rc-bg-greenlight:  #d8f0df;

    --rc-border:         #dde3ea;
}

@media (prefers-color-scheme: dark) {
    .rich-content {
        --rc-fg-black:       #f2f6fa;
        --rc-fg-gray:        #9aa8b8;
        --rc-fg-white:       #0f1923;
        --rc-fg-bluedark:    #8cc8ee;
        --rc-fg-bluelight:   #2f7fb3;
        --rc-fg-orangedark:  #ffb07f;
        --rc-fg-orangelight: #c7602a;
        --rc-fg-reddark:     #ff9a90;
        --rc-fg-redlight:    #c84238;
        --rc-fg-greendark:   #8fdca6;
        --rc-fg-greenlight:  #3d9a5b;

        --rc-bg-black:       #f2f6fa;
        --rc-bg-gray:        #2e3a4a;
        --rc-bg-white:       #0f1923;
        --rc-bg-bluedark:    #8cc8ee;
        --rc-bg-bluelight:   #1b3a52;
        --rc-bg-orangedark:  #ffb07f;
        --rc-bg-orangelight: #4a2d1c;
        --rc-bg-reddark:     #ff9a90;
        --rc-bg-redlight:    #4d2220;
        --rc-bg-greendark:   #8fdca6;
        --rc-bg-greenlight:  #1e3d28;

        --rc-border:         #2e3f54;
    }
}

/* Contient les images flottantes en fin de contenu. */
.rich-content::after { content: ""; display: table; clear: both; }

/* ── Couleur du texte ── */
:is(.rich-content, .ql-editor) .ql-color-black       { color: var(--rc-fg-black); }
:is(.rich-content, .ql-editor) .ql-color-gray        { color: var(--rc-fg-gray); }
:is(.rich-content, .ql-editor) .ql-color-white       { color: var(--rc-fg-white); }
:is(.rich-content, .ql-editor) .ql-color-bluedark    { color: var(--rc-fg-bluedark); }
:is(.rich-content, .ql-editor) .ql-color-bluelight   { color: var(--rc-fg-bluelight); }
:is(.rich-content, .ql-editor) .ql-color-orangedark  { color: var(--rc-fg-orangedark); }
:is(.rich-content, .ql-editor) .ql-color-orangelight { color: var(--rc-fg-orangelight); }
:is(.rich-content, .ql-editor) .ql-color-reddark     { color: var(--rc-fg-reddark); }
:is(.rich-content, .ql-editor) .ql-color-redlight    { color: var(--rc-fg-redlight); }
:is(.rich-content, .ql-editor) .ql-color-greendark   { color: var(--rc-fg-greendark); }
:is(.rich-content, .ql-editor) .ql-color-greenlight  { color: var(--rc-fg-greenlight); }

/* ── Couleur de fond ── */
:is(.rich-content, .ql-editor) [class*="ql-bg-"] { padding: 0 .15em; border-radius: 2px; }
:is(.rich-content, .ql-editor) .ql-bg-black       { background-color: var(--rc-bg-black); }
:is(.rich-content, .ql-editor) .ql-bg-gray        { background-color: var(--rc-bg-gray); }
:is(.rich-content, .ql-editor) .ql-bg-white       { background-color: var(--rc-bg-white); }
:is(.rich-content, .ql-editor) .ql-bg-bluedark    { background-color: var(--rc-bg-bluedark); }
:is(.rich-content, .ql-editor) .ql-bg-bluelight   { background-color: var(--rc-bg-bluelight); }
:is(.rich-content, .ql-editor) .ql-bg-orangedark  { background-color: var(--rc-bg-orangedark); }
:is(.rich-content, .ql-editor) .ql-bg-orangelight { background-color: var(--rc-bg-orangelight); }
:is(.rich-content, .ql-editor) .ql-bg-reddark     { background-color: var(--rc-bg-reddark); }
:is(.rich-content, .ql-editor) .ql-bg-redlight    { background-color: var(--rc-bg-redlight); }
:is(.rich-content, .ql-editor) .ql-bg-greendark   { background-color: var(--rc-bg-greendark); }
:is(.rich-content, .ql-editor) .ql-bg-greenlight  { background-color: var(--rc-bg-greenlight); }

/* ── Images : taille relative à la colonne, alignement ──
   Sans classe = taille réelle plafonnée. Le flottement ne vaut que pour
   petite et moyenne ; grande et réelle restent en bloc. */
:is(.rich-content, .ql-editor) img { max-width: 100%; height: auto; }
:is(.rich-content, .ql-editor) img.ql-image-small  { width: 33%; }
:is(.rich-content, .ql-editor) img.ql-image-medium { width: 50%; }
:is(.rich-content, .ql-editor) img.ql-image-large  { width: 100%; display: block; margin: 1rem 0; }
:is(.rich-content, .ql-editor) img:is(.ql-image-small, .ql-image-medium) {
    display: block;
    margin: .5rem auto 1rem;
}
:is(.rich-content, .ql-editor) img:is(.ql-image-small, .ql-image-medium).ql-image-left {
    float: left;
    margin: .25rem 1.25rem .75rem 0;
}
:is(.rich-content, .ql-editor) img:is(.ql-image-small, .ql-image-medium).ql-image-right {
    float: right;
    margin: .25rem 0 .75rem 1.25rem;
}
/* Un encadré (position: relative) passerait par-dessus une image flottante. */
:is(.rich-content, .ql-editor) :is(h2, h3, hr, .ql-callout) { clear: both; }

@media (max-width: 767px) {
    :is(.rich-content, .ql-editor) img.ql-image-small  { width: 50%; }
    :is(.rich-content, .ql-editor) img.ql-image-medium { width: 100%; }
    :is(.rich-content, .ql-editor) img:is(.ql-image-small, .ql-image-medium):is(.ql-image-left, .ql-image-right) {
        float: none;
        margin: .5rem auto 1rem;
    }
}

/* ── Séparateur ── */
:is(.rich-content, .ql-editor) hr {
    border: 0;
    border-top: 1px solid var(--rc-border);
    margin: 2rem 0;
}

/* ── Citation (le style de l'éditeur reste celui de Quill) ── */
.rich-content blockquote {
    border-left: 4px solid var(--color-accent, #e05c20);
    margin: 1.5rem 0;
    padding: .75rem 1.25rem;
    background: var(--color-surface-2, #eef2f7);
    color: var(--color-muted, #5c6b7a);
    font-style: italic;
}
.rich-content blockquote + blockquote { margin-top: -1.5rem; padding-top: 0; }

/* ── Encadrés (callouts) ──
   Une ligne Quill = un <p class="ql-callout ql-callout-…">. Les lignes
   consécutives d'une même variante forment un seul encadré : icône et coins du
   haut sur la première, coins du bas sur la dernière. L'icône est un masque
   SVG ; son texte alternatif CSS (`content: "" / "…"`) porte la variante pour
   les lecteurs d'écran (RGAA 3.1). Les navigateurs qui ignorent cette syntaxe
   gardent la première déclaration `content`, l'icône restant décorative. */
:is(.rich-content, .ql-editor) .ql-callout {
    position: relative;
    margin: 1.25rem 0;
    padding: .75rem 1rem .75rem 2.75rem;
    background: var(--callout-bg);
    border-left: 4px solid var(--callout-accent);
    border-radius: 0 6px 6px 0;
    font-style: normal;
}
:is(.rich-content, .ql-editor) .ql-callout::before {
    content: "";
    position: absolute;
    left: .8rem;
    top: .85rem;
    width: 1.25rem;
    height: 1.25rem;
    background-color: var(--callout-accent);
    -webkit-mask: var(--callout-icon) no-repeat center / contain;
    mask: var(--callout-icon) no-repeat center / contain;
}

:is(.rich-content, .ql-editor) .ql-callout-info {
    --callout-bg: var(--rc-bg-bluelight);
    --callout-accent: var(--rc-fg-bluedark);
    --callout-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Cpath d='M12 16v-5M12 8h.01'/%3E%3C/svg%3E");
}
:is(.rich-content, .ql-editor) .ql-callout-tip {
    --callout-bg: var(--rc-bg-greenlight);
    --callout-accent: var(--rc-fg-greendark);
    --callout-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M9 18h6M10 22h4M12 2a7 7 0 0 0-4 12.7c.6.5 1 1.3 1 2.3h6c0-1 .4-1.8 1-2.3A7 7 0 0 0 12 2z'/%3E%3C/svg%3E");
}
:is(.rich-content, .ql-editor) .ql-callout-warning {
    --callout-bg: var(--rc-bg-orangelight);
    --callout-accent: var(--rc-fg-orangedark);
    --callout-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M10.3 3.9 1.8 18a2 2 0 0 0 1.7 3h17a2 2 0 0 0 1.7-3L13.7 3.9a2 2 0 0 0-3.4 0z'/%3E%3Cpath d='M12 9v4M12 17h.01'/%3E%3C/svg%3E");
}
:is(.rich-content, .ql-editor) .ql-callout-danger {
    --callout-bg: var(--rc-bg-redlight);
    --callout-accent: var(--rc-fg-reddark);
    --callout-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M7.9 2h8.2L22 7.9v8.2L16.1 22H7.9L2 16.1V7.9z'/%3E%3Cpath d='M12 8v4M12 16h.01'/%3E%3C/svg%3E");
}

.rich-content .ql-callout-info::before    { content: ""; content: "" / "Information :"; }
.rich-content .ql-callout-tip::before     { content: ""; content: "" / "Astuce :"; }
.rich-content .ql-callout-warning::before { content: ""; content: "" / "Attention :"; }
.rich-content .ql-callout-danger::before  { content: ""; content: "" / "Danger :"; }

/* Regroupement des lignes consécutives d'une même variante. */
:is(.rich-content, .ql-editor) :is(
    .ql-callout-info + .ql-callout-info,
    .ql-callout-tip + .ql-callout-tip,
    .ql-callout-warning + .ql-callout-warning,
    .ql-callout-danger + .ql-callout-danger
) {
    margin-top: 0;
    padding-top: 0;
    border-top-right-radius: 0;
}
:is(.rich-content, .ql-editor) :is(
    .ql-callout-info + .ql-callout-info,
    .ql-callout-tip + .ql-callout-tip,
    .ql-callout-warning + .ql-callout-warning,
    .ql-callout-danger + .ql-callout-danger
)::before {
    content: none;
}
:is(.rich-content, .ql-editor) :is(
    .ql-callout-info:has(+ .ql-callout-info),
    .ql-callout-tip:has(+ .ql-callout-tip),
    .ql-callout-warning:has(+ .ql-callout-warning),
    .ql-callout-danger:has(+ .ql-callout-danger)
) {
    margin-bottom: 0;
    padding-bottom: .35rem;
    border-bottom-right-radius: 0;
}
