/* Contenu RH — the rich-text HTML as the reader draws it (.rich-text: the text blocks of a page, the builder's
   previews) and as the editor draws it too (Features/RichText/WordgardEditor.razor.css mirrors these rules inside
   its wg-content, so a text looks in the editor as it will on the page). What the HTML may hold is the sanitizer's
   allow-list (HtmlSanitizerService.cs). Linked globally by App.razor; the tokens (--nrc-*, --radius-*) are
   portal.css's. */

/* ---- Text ---- */
.rich-text > :last-child { margin-bottom: 0; }
.rich-text p { margin: 0 0 0.75rem; }
/* Section headings: h2 to h4 — the page's title is its h1 — at sizes that sit under it rather than beside it. */
.rich-text :is(h2, h3, h4) { margin: 1.25rem 0 0.5rem; font-weight: 600; line-height: 1.25; }
.rich-text h2 { font-size: 1.5rem; }
.rich-text h3 { font-size: 1.25rem; }
.rich-text h4 { font-size: 1.1rem; }
.rich-text :is(h2, h3, h4):first-child { margin-top: 0; }
.rich-text :is(ul, ol) { padding-left: 1.5rem; margin: 0 0 0.75rem; }
.rich-text ol[type="a"] { list-style-type: lower-alpha; } /* the editor's lettered list */
.rich-text blockquote { margin: 0.5rem 0 0.75rem; padding-left: 0.75rem; border-left: 3px solid var(--nrc-gris-300); color: var(--bs-secondary-color); }
.rich-text pre { margin: 0.5rem 0 0.75rem; padding: 0.4rem 0.6rem; border-radius: 0.25rem; background: var(--bs-tertiary-bg); font-size: 0.9em; white-space: pre-wrap; }
.rich-text hr { margin: 0.75rem 0; border: 0; border-top: 1px solid var(--bs-border-color); opacity: 1; }
.rich-text a { color: var(--bs-link-color); text-decoration: underline; }

/* ---- Tables (Bootstrap-like borders; a cell's last block carries no margin) ---- */
.rich-text table { width: 100%; border-collapse: collapse; margin: 0.5rem 0 0.75rem; font-size: 0.9em; }
.rich-text th, .rich-text td { border: 1px solid var(--bs-border-color); padding: 0.25rem 0.4rem; vertical-align: top; }
.rich-text th { background: var(--nrc-gris-100); font-weight: 600; }
.rich-text th > :last-child, .rich-text td > :last-child { margin-bottom: 0; }

/* ---- Pictures: at the size their width and height attributes say (the browser keeps their ratio from those
   attributes, so height: auto follows a narrowed width), never wider than the text. ---- */
.rich-text img { max-width: 100%; height: auto; }
.rich-text figure { margin: 0 0 0.75rem; }
.rich-text figcaption { margin-top: 0.25rem; font-size: 0.875em; color: var(--bs-secondary-color); }

/* ---- Callouts (Note / Important / Avertissement / Attention / Danger / Avis) in the rich-text HTML, in the editor
   included: a box with a coloured left border, its icon (Bootstrap Icons) in the top-left corner and its label
   before the text. Two pseudo-elements: ::after is the glyph, ::before the label, so the label keeps the body font
   and its weight while the glyph keeps the icon font's. --callout-color is the kind's colour, in the portal palette. ---- */
.callout {
    --callout-color: var(--nrc-gris-500);
    position: relative; margin: 0.75rem 0; padding: 0.6rem 0.9rem 0.6rem 2.5rem;
    border: 1px solid var(--nrc-gris-200); border-left: 5px solid var(--callout-color); border-radius: var(--radius-sm);
    background: var(--nrc-gris-50);
}
.callout::before { content: attr(data-callout); text-transform: uppercase; font-weight: 700; margin-right: 0.4rem; letter-spacing: 0.03em; }
.callout::after {
    content: "\f431"; position: absolute; left: 0.8rem; top: 0.6rem; line-height: 1.2;
    font-family: bootstrap-icons; font-weight: normal; font-style: normal; font-size: 1.1em; color: var(--callout-color);
}
.callout-note::before { content: "NOTE"; }
.callout-important { --callout-color: var(--nrc-gris-800); }
.callout-important::before { content: "IMPORTANT"; }
.callout-important::after { content: "\f333"; }
.callout-warning { --callout-color: var(--bs-orange); }
.callout-warning::before { content: "AVERTISSEMENT"; }
.callout-warning::after { content: "\f33b"; }
.callout-caution { --callout-color: var(--nrc-jaune); }
.callout-caution::before { content: "ATTENTION"; }
.callout-caution::after { content: "\f335"; color: #b8950a; } /* the yellow itself is too pale on the box */
.callout-danger { --callout-color: var(--nrc-rouge); }
.callout-danger::before { content: "DANGER"; color: var(--nrc-rouge); }
.callout-danger::after { content: "\f337"; }
.callout-notice { --callout-color: var(--nrc-bleu); }
.callout-notice::before { content: "AVIS"; }
.callout-notice::after { content: "\f484"; }

/* ---- Search highlights ----
   The words typed are CSS custom highlights over the text nodes themselves, not <mark> elements (the markup is
   Blazor's to re-sync, never rewritten). The name is page-global, so the rule is too, and it is the name
   Procedures' filter script registers. Bootstrap's mark colours. */
::highlight(menu-filter) { background-color: var(--bs-highlight-bg); color: var(--bs-highlight-color); }

/* ---- Editor chrome, global by necessity: script-built by js/richtext/*.js — the tools and the resize frame are
   appended to the editor's wrapper, the drag thumbnail to the body — so no component's isolated stylesheet owns
   them. ---- */
/* Tools overlaid in the top-right corner of a picture (js/richtext/picture-tools.js). */
.tile-overlay { position: absolute; top: 0.35rem; right: 0.35rem; z-index: 2; display: flex; align-items: center; gap: 0.25rem; }
.tile-overlay .btn { opacity: 0.9; }
/* Picture resize handles (js/richtext/resize-frame.js): around the selected picture. The frame lets clicks through,
   the handles take the pointer; a corner keeps the proportions, a side moves one dimension. */
.resize-frame { position: absolute; z-index: 2; pointer-events: none; }
.resize-handle { position: absolute; width: 10px; height: 10px; margin: -5px; border: 1px solid var(--bs-body-bg); border-radius: 2px; background: var(--bs-primary); pointer-events: auto; touch-action: none; }
.resize-frame.resizing .resize-handle { background: var(--bs-primary-text-emphasis); }
/* While a handle is dragged: a shade over the original's box, and the picture again in the frame at the size
   being tried. */
.resize-frame .resize-shade { position: absolute; top: 0; left: 0; background: var(--bs-body-bg); opacity: 0.65; pointer-events: none; }
.resize-frame .resize-preview { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: fill; pointer-events: none; }
.resize-handle[data-dir="nw"] { top: 0; left: 0; cursor: nwse-resize; }
.resize-handle[data-dir="n"] { top: 0; left: 50%; cursor: ns-resize; }
.resize-handle[data-dir="ne"] { top: 0; right: 0; margin-right: -5px; cursor: nesw-resize; }
.resize-handle[data-dir="e"] { top: 50%; right: 0; margin-right: -5px; cursor: ew-resize; }
.resize-handle[data-dir="se"] { bottom: 0; right: 0; margin-right: -5px; margin-bottom: -5px; cursor: nwse-resize; }
.resize-handle[data-dir="s"] { bottom: 0; left: 50%; margin-bottom: -5px; cursor: ns-resize; }
.resize-handle[data-dir="sw"] { bottom: 0; left: 0; margin-bottom: -5px; cursor: nesw-resize; }
.resize-handle[data-dir="w"] { top: 50%; left: 0; cursor: ew-resize; }
/* A picture dragged to another spot (js/richtext/picture-tools.js): a small copy beside the pointer as the drag
   image, in place of the browser's full-size ghost, so the drop spot stays in view. Built off-screen for the snapshot. */
.rte-drag-thumb { position: fixed; top: -1000px; left: -1000px; padding: 2px; background: var(--bs-body-bg); border: 1px solid var(--bs-border-color); border-radius: 0.25rem; box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25); }
.rte-drag-thumb img { display: block; max-width: 64px; max-height: 64px; }

@media print {
    .callout { break-inside: avoid; }
    .rich-text :is(h2, h3, h4) { break-after: avoid; }
    .rich-text p, .rich-text li { orphans: 3; widows: 3; }
}
