/* MOTIFS DE FOND (0.8.0 ; lib/fond.js, Apparence › Fond). Un calque
   fixe sous le contenu (body::before, z-index −1 dans le contexte
   isolé de body) porte un SVG en data-URI : grille fine, points,
   circuits, topographie. Contraste ≤ 4 % : l'opacité vaut au plus
   --motif-i × 0,07 (0,07 à 100 %) sur un trait noir (clair) ou blanc
   (sombre). « Respiration » : opacité qui ondule lentement (40 s),
   coupée par prefers-reduced-motion. Aucune image lourde ; la
   mesure AA du texte est inchangée (le calque est sous le texte). */
body.motif{ position:relative; isolation:isolate; }
body.motif::before{
  content:""; position:fixed; inset:0; z-index:-1; pointer-events:none;
  opacity:calc(var(--motif-i, .5) * .07);
  background-image:var(--motif-url); background-repeat:repeat;
  background-size:var(--motif-taille, 48px 48px);
}
/* Grille fine : lignes de 1 px tous les 48 px */
body.motif-grille{ --motif-url:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='48' height='48'%3E%3Cpath d='M48 .5H0M.5 0v48' fill='none' stroke='%23000' stroke-width='1'/%3E%3C/svg%3E"); --motif-taille:48px 48px; }
:root[data-theme="dark"] body.motif-grille{ --motif-url:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='48' height='48'%3E%3Cpath d='M48 .5H0M.5 0v48' fill='none' stroke='%23fff' stroke-width='1'/%3E%3C/svg%3E"); }
/* Points : un point de 1,2 px tous les 24 px */
body.motif-points{ --motif-url:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24'%3E%3Ccircle cx='12' cy='12' r='1.2' fill='%23000'/%3E%3C/svg%3E"); --motif-taille:24px 24px; }
:root[data-theme="dark"] body.motif-points{ --motif-url:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24'%3E%3Ccircle cx='12' cy='12' r='1.2' fill='%23fff'/%3E%3C/svg%3E"); }
/* Circuits : lignes techniques orthogonales avec pastilles */
body.motif-circuits{ --motif-url:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160' fill='none' stroke='%23000' stroke-width='1'%3E%3Cpath d='M8 24h56v40h40M104 64v56h40M8 120h40V88M64 136h32v16M120 8v32h32M24 152V136h16'/%3E%3Ccircle cx='8' cy='24' r='2.5'/%3E%3Ccircle cx='104' cy='64' r='2.5'/%3E%3Ccircle cx='144' cy='120' r='2.5'/%3E%3Ccircle cx='48' cy='88' r='2.5'/%3E%3Ccircle cx='96' cy='152' r='2.5'/%3E%3Ccircle cx='152' cy='40' r='2.5'/%3E%3Ccircle cx='40' cy='136' r='2.5'/%3E%3C/svg%3E"); --motif-taille:160px 160px; }
:root[data-theme="dark"] body.motif-circuits{ --motif-url:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160' fill='none' stroke='%23fff' stroke-width='1'%3E%3Cpath d='M8 24h56v40h40M104 64v56h40M8 120h40V88M64 136h32v16M120 8v32h32M24 152V136h16'/%3E%3Ccircle cx='8' cy='24' r='2.5'/%3E%3Ccircle cx='104' cy='64' r='2.5'/%3E%3Ccircle cx='144' cy='120' r='2.5'/%3E%3Ccircle cx='48' cy='88' r='2.5'/%3E%3Ccircle cx='96' cy='152' r='2.5'/%3E%3Ccircle cx='152' cy='40' r='2.5'/%3E%3Ccircle cx='40' cy='136' r='2.5'/%3E%3C/svg%3E"); }
/* Topographie : courbes de niveau concentriques */
body.motif-topographie{ --motif-url:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240' fill='none' stroke='%23000' stroke-width='1'%3E%3Cpath d='M40 120c0-30 25-50 60-50s70 20 70 50-30 60-70 60-60-30-60-60z'/%3E%3Cpath d='M60 120c0-20 18-35 42-35s50 14 50 35-22 42-50 42-42-22-42-42z'/%3E%3Cpath d='M80 120c0-10 10-18 22-18s26 7 26 18-12 22-26 22-22-12-22-22z'/%3E%3Cpath d='M20 120c0-42 35-72 80-72s96 28 96 72-42 84-96 84S20 162 20 120z'/%3E%3Cpath d='M0 40c30-10 60-5 90 10M150 230c30 5 60 0 90-15'/%3E%3C/svg%3E"); --motif-taille:240px 240px; }
:root[data-theme="dark"] body.motif-topographie{ --motif-url:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240' fill='none' stroke='%23fff' stroke-width='1'%3E%3Cpath d='M40 120c0-30 25-50 60-50s70 20 70 50-30 60-70 60-60-30-60-60z'/%3E%3Cpath d='M60 120c0-20 18-35 42-35s50 14 50 35-22 42-50 42-42-22-42-42z'/%3E%3Cpath d='M80 120c0-10 10-18 22-18s26 7 26 18-12 22-26 22-22-12-22-22z'/%3E%3Cpath d='M20 120c0-42 35-72 80-72s96 28 96 72-42 84-96 84S20 162 20 120z'/%3E%3Cpath d='M0 40c30-10 60-5 90 10M150 230c30 5 60 0 90-15'/%3E%3C/svg%3E"); }
/* Respiration lente : l'opacité ondule entre 55 % et 100 % du réglage */
body.motif-respire::before{ animation:motifRespire 40s ease-in-out infinite; }
@keyframes motifRespire{ 0%,100%{ opacity:calc(var(--motif-i, .5) * .07); } 50%{ opacity:calc(var(--motif-i, .5) * .04); } }
@media (prefers-reduced-motion:reduce){ body.motif-respire::before{ animation:none; } }
/* Aperçus dans Apparence › Fond : la tuile reproduit le calque */
.motif-apercu{ position:relative; isolation:isolate; height:84px; border:1px solid var(--ligne); border-radius:12px; overflow:hidden; background:var(--carte); }
.motif-apercu::before{ content:""; position:absolute; inset:0; z-index:0; opacity:calc(var(--motif-i, .5) * .07); background-image:var(--motif-url); background-size:var(--motif-taille, 48px 48px); }
.motif-apercu.aucun::before{ display:none; }
.motif-apercu span{ position:relative; z-index:1; display:block; padding:10px 12px; font-size:.86rem; color:var(--encre); }
