/* Corps d'un article (ADR 0023), identique dans l'éditeur du back-office et sur la page publique.
   Seules les classes de la liste blanche (RichTextClassSanitizer) existent : palette du design system,
   encadrés, largeur des images. */

.rich-text {
    font: var(--type-body-lg);
    color: var(--text-primary);
    overflow-wrap: break-word;
}

.rich-text > * + * {
    margin-top: var(--space-5);
}

.rich-text h2 {
    margin-top: var(--space-12);
    font: var(--type-h2);
    font-size: clamp(var(--text-xl), 1.4vw + 1rem, var(--text-2xl));
}

.rich-text h3 {
    margin-top: var(--space-8);
    font: var(--type-h3);
}

.rich-text :is(h2, h3) + * {
    margin-top: var(--space-3);
}

.rich-text > :first-child {
    margin-top: 0;
}

.rich-text strong {
    font-weight: var(--weight-semibold);
}

.rich-text a {
    color: var(--text-link);
    text-decoration-color: var(--red-500);
    text-decoration-thickness: 1px;
}

.rich-text a:hover {
    color: var(--text-link-hover);
}

.rich-text :is(ul, ol) {
    padding-left: var(--space-6);
}

.rich-text ul {
    list-style: square;
}

.rich-text ol {
    list-style: decimal;
}

.rich-text li::marker {
    color: var(--red-500);
}

.rich-text li + li {
    margin-top: var(--space-2);
}

.rich-text li > p + * {
    margin-top: var(--space-2);
}

.rich-text blockquote {
    margin-inline: 0;
    padding: var(--space-1) 0 var(--space-1) var(--space-5);
    border-left: 3px solid var(--red-500);
    font-size: var(--text-lg);
    color: var(--text-secondary);
}

.rich-text hr {
    margin-block: var(--space-10);
    border: 0;
    border-top: var(--border-width) solid var(--border-strong);
}

/* Images, avec légende facultative ; « moyenne » centrée sur ordinateur, pleine largeur sur téléphone */
.rich-figure {
    margin: var(--space-8) 0;
}

.rich-figure img {
    width: 100%;
    height: auto;
    border-radius: var(--radius-lg);
    background: var(--surface-muted);
}

.rich-figure figcaption {
    margin-top: var(--space-2);
    font: var(--type-body-sm);
    color: var(--text-secondary);
}

@media (min-width: 720px) {
    .rich-figure--medium {
        max-width: 66%;
        margin-inline: auto;
    }
}

/* Tableaux : zone qui défile horizontalement quand l'écran est plus étroit que le tableau */
.rich-text__table,
.rich-text .tableWrapper {
    overflow-x: auto;
    border: var(--border-width) solid var(--border-default);
    border-radius: var(--radius-md);
}

.rich-text__table:focus-visible {
    box-shadow: var(--shadow-focus);
}

.rich-text table {
    width: 100%;
    min-width: 28rem;
    border-collapse: collapse;
    font: var(--type-body);
    font-variant-numeric: tabular-nums;
}

.rich-text :is(th, td) {
    padding: var(--space-3) var(--space-4);
    border-bottom: var(--border-width) solid var(--border-default);
    text-align: left;
    vertical-align: top;
}

.rich-text :is(th, td) + :is(th, td) {
    border-left: var(--border-width) solid var(--border-default);
}

.rich-text tr:last-child > :is(th, td) {
    border-bottom: 0;
}

.rich-text th {
    background: var(--surface-subtle);
    font-weight: var(--weight-semibold);
}

.rich-text :is(th, td) > p {
    margin: 0;
}

/* Encadrés : un libellé, un fond et un filet de couleur selon leur nature */
.callout {
    padding: var(--space-5) var(--space-6);
    border-left: 4px solid var(--blue-500);
    border-radius: var(--radius-md);
    background: var(--blue-100);
}

.callout::before {
    content: "Bon à savoir";
    display: block;
    margin-bottom: var(--space-2);
    font: var(--type-overline);
    letter-spacing: var(--tracking-caps);
    text-transform: uppercase;
    color: var(--blue-500);
}

.callout > * + * {
    margin-top: var(--space-3);
}

.callout--warning {
    border-left-color: var(--red-500);
    background: var(--red-50);
}

.callout--warning::before {
    content: "Attention";
    color: var(--red-600);
}

.callout--tip {
    border-left-color: var(--green-500);
    background: var(--green-100);
}

.callout--tip::before {
    content: "Astuce";
    color: var(--green-500);
}

/* Palette : couleurs de texte et surlignages, contrastes AA sur fond blanc */
.has-color-red { color: var(--red-600); }
.has-color-anthracite { color: var(--steel-800); }
.has-color-grey { color: var(--steel-600); }
.has-color-green { color: var(--green-500); }
.has-color-blue { color: var(--blue-500); }

.rich-text mark {
    padding: 0 0.15em;
    border-radius: var(--radius-xs);
    color: inherit;
}

.has-background-amber { background: var(--amber-100); }
.has-background-red { background: var(--red-100); }
.has-background-green { background: var(--green-100); }
.has-background-blue { background: var(--blue-100); }
.has-background-grey { background: var(--steel-100); }

/* Téléphone : texte un peu plus serré, tableaux plus compacts */
@media (max-width: 599px) {
    .rich-text {
        font-size: var(--text-base);
    }

    .rich-text h2 {
        margin-top: var(--space-10);
    }

    .rich-text :is(th, td) {
        padding: var(--space-2) var(--space-3);
    }

    .callout {
        padding: var(--space-4) var(--space-5);
    }
}
