/* Recherche au fil de la frappe (public/assets/recherche-globale.js, docs/RECHERCHE.md). Panneau posé sous le champ,
   plein écran au téléphone. Couleurs prises du style en place : teintes (Boîtes vivantes, Minimaliste, tableau, pages
   de sujet), Terminal (body.ad) et Éditorial (body.ae) ont leurs propres rôles. Icônes au trait. */

.rg-p, .rg-fantome, .rg-annonce, .rg-place, .rg-place-boite, .af-place-rg {
  --rg-fond: var(--carte, #ffffff);
  --rg-texte: var(--encre, var(--texte, #22303a));
  --rg-doux: var(--texte-doux, var(--doux, #66727d));
  --rg-trait: var(--trait, var(--bord, #e2e6ea));
  --rg-accent: var(--accent, #2f6f94);
  --rg-actif: var(--accent-doux, #e6eef4);
  --rg-rayon: 10px;
  --rg-police: inherit;
  --rg-ombre: 0 14px 38px rgba(20, 30, 45, .16), 0 2px 8px rgba(20, 30, 45, .08);
}
body.ad .rg-p, body.ad .rg-fantome, body.ad .rg-annonce,
body.ad .rg-place, body.ad .rg-place-boite {
  --rg-fond: var(--fond-2, #12151b);
  --rg-texte: var(--texte, #e1e5ec);
  --rg-doux: var(--texte-2, #a9b1bd);
  --rg-trait: var(--trait-2, #2f3541);
  --rg-accent: var(--accent, #82b1ff);
  --rg-actif: var(--accent-fond, rgba(130, 177, 255, .12));
  --rg-rayon: 6px;
  --rg-police: var(--mono, ui-monospace, Menlo, monospace);
  --rg-ombre: 0 14px 38px rgba(0, 0, 0, .5);
}
body.ae .rg-p, body.ae .rg-fantome, body.ae .rg-annonce,
body.ae .rg-place, body.ae .rg-place-boite {
  --rg-fond: var(--papier, #ffffff);
  --rg-texte: var(--encre, #0b0b0b);
  --rg-doux: var(--gris, #555555);
  --rg-trait: var(--filet-l, #e2e2e0);
  --rg-accent: var(--encre, #0b0b0b);
  --rg-actif: var(--survol, #f4f4f2);
  --rg-rayon: 0;
  --rg-police: var(--police, "Helvetica Neue", Helvetica, Arial, sans-serif);
  --rg-ombre: 0 10px 30px rgba(0, 0, 0, .12);
}

/* ---------------------------------------------------------------- Panneau */
.rg-p {
  position: fixed; z-index: 1200; display: flex; flex-direction: column; box-sizing: border-box; overflow: hidden;
  background: var(--rg-fond); color: var(--rg-texte); font-family: var(--rg-police); font-size: 14px; line-height: 1.3;
  border: 1px solid var(--rg-trait); border-radius: var(--rg-rayon); box-shadow: var(--rg-ombre);
  text-align: left; letter-spacing: normal; text-transform: none;
}
.rg-p[hidden] { display: none; }
.rg-p *, .rg-p *::before, .rg-p *::after { box-sizing: border-box; }
.rg-tete { display: none; }
.rg-barre { position: absolute; top: 0; left: 0; right: 0; height: 2px; overflow: hidden; pointer-events: none; }
.rg-charge .rg-barre::after {
  content: ""; position: absolute; top: 0; left: -40%; width: 40%; height: 100%; background: var(--rg-accent); opacity: .7;
  animation: rg-barre 0.9s ease-in-out infinite;
}
@keyframes rg-barre { to { left: 100%; } }
.rg-corps { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 4px 0 6px; }
.rg-sans .rg-corps { display: none; }
.rg-vide { margin: 0; padding: 14px 16px; color: var(--rg-doux); }
.rg-pied {
  display: flex; flex-wrap: wrap; gap: 4px 12px; white-space: nowrap; margin: 0; padding: 7px 12px; border-top: 1px solid var(--rg-trait);
  color: var(--rg-doux); font-size: 11.5px;
}
.rg-pied kbd {
  display: inline-block; min-width: 18px; margin-right: 2px; padding: 0 4px; border: 1px solid var(--rg-trait); border-radius: 4px;
  font: inherit; font-size: 11px; line-height: 16px; text-align: center; color: var(--rg-texte); background: transparent;
}
@media (hover: none) { .rg-pied { display: none; } }

/* Groupes */
.rg-g + .rg-g { margin-top: 2px; border-top: 1px solid var(--rg-trait); padding-top: 2px; }
.rg-gt {
  position: sticky; top: -4px; z-index: 1; padding: 7px 14px 3px; background: var(--rg-fond); color: var(--rg-doux);
  font-size: 11.5px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase;
}
body.ad .rg-gt::before { content: "# "; color: var(--rg-accent); }

/* Lignes */
.rg-o {
  position: relative; display: flex; align-items: center; gap: 10px; min-height: 40px; margin: 0 6px; padding: 5px 8px;
  border-radius: calc(var(--rg-rayon) - 3px); color: inherit; text-decoration: none; cursor: pointer;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
}
.rg-o:hover, .rg-o:focus { text-decoration: none; color: inherit; }
.rg-o.rg-actif { background: var(--rg-actif); }
body.ae .rg-o.rg-actif { box-shadow: inset 3px 0 0 var(--rg-accent); }
.rg-o[data-glisse] { cursor: grab; }
.rg-ico {
  position: relative; flex: 0 0 20px; width: 20px; height: 20px; display: inline-flex; align-items: center; justify-content: center;
  color: var(--rg-doux);
}
.rg-ico img { position: absolute; inset: 2px; width: 16px; height: 16px; object-fit: contain; }
.rg-ico > svg { position: relative; }
.rg-lettre { display: none; }
.rg-site .rg-lettre, .rg-web .rg-lettre, .rg-lien .rg-lettre {
  display: inline-flex; align-items: center; justify-content: center; width: 18px; height: 18px; border-radius: 4px;
  background: var(--rg-actif); color: var(--rg-doux); font-size: 11px; font-weight: 600;
}
.rg-site .rg-ico > svg, .rg-web .rg-ico > svg, .rg-lien .rg-ico > svg { display: none; }
.rg-ico-ok .rg-lettre { visibility: hidden; }
.rg-txt { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.rg-t, .rg-s { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.rg-t { color: var(--rg-texte); }
.rg-s { margin-top: 1px; color: var(--rg-doux); font-size: 12.5px; }
.rg-d { flex: 0 0 auto; max-width: 40%; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; color: var(--rg-doux); font-size: 12.5px; }
.rg-p mark { background: none; color: inherit; font-weight: 700; }
body.ad .rg-p mark { color: var(--rg-accent); font-weight: inherit; }

/* « Ajouter à… » et poignée : visibles sur la ligne choisie, au survol, ou toujours au doigt. */
.rg-aj {
  flex: 0 0 auto; display: inline-flex; align-items: center; gap: 4px; height: 28px; padding: 0 9px; margin: 0;
  border: 1px solid var(--rg-trait); border-radius: 999px; background: var(--rg-fond); color: var(--rg-accent);
  font: inherit; font-size: 12.5px; cursor: pointer; display: none;
}
body.ae .rg-aj, body.ad .rg-aj { border-radius: var(--rg-rayon); }
/* Sur la ligne choisie, « Ajouter à… » prend la place de l'adresse (pas de ligne qui change de hauteur). */
.rg-o.rg-actif .rg-aj, .rg-aj:focus, .rg-aj[aria-expanded="true"] { display: inline-flex; }
.rg-o.rg-ajoutable.rg-actif .rg-d { display: none; }
.rg-aj:hover { border-color: var(--rg-accent); }
.rg-aj:focus-visible { outline: 2px solid var(--rg-accent); outline-offset: 1px; }
.rg-poi {
  flex: 0 0 auto; display: none; align-items: center; justify-content: center; width: 40px; height: 40px; margin: -5px -8px -5px -6px;
  color: var(--rg-doux); cursor: grab; touch-action: none;
}
@media (hover: none), (pointer: coarse) {
  .rg-aj { display: inline-flex; padding: 0 8px; }
  .rg-o.rg-ajoutable.rg-actif .rg-d { display: block; }
  .rg-aj span { display: none; }
  .rg-poi { display: inline-flex; }
  .rg-o { min-height: 48px; }
}
@media (hover: hover) and (pointer: fine) {
  .rg-o[data-glisse]:hover .rg-ico { color: var(--rg-accent); }
}

/* Choix de la boîte */
.rg-choix {
  margin: 2px 14px 8px 40px; padding: 6px; border: 1px solid var(--rg-trait); border-radius: calc(var(--rg-rayon) - 2px);
  background: var(--rg-fond);
}
.rg-choix-t { margin: 2px 6px 6px; color: var(--rg-doux); font-size: 12.5px; }
.rg-choix-vide { margin: 4px 6px; color: var(--rg-doux); }
.rg-choix ul { list-style: none; margin: 0; padding: 0; max-height: 240px; overflow-y: auto; }
.rg-choix button {
  display: flex; align-items: center; gap: 8px; width: 100%; min-height: 34px; padding: 5px 8px; border: 0;
  border-radius: calc(var(--rg-rayon) - 4px); background: none; color: var(--rg-texte); font: inherit; text-align: left; cursor: pointer;
}
.rg-choix button svg { flex: 0 0 auto; color: var(--rg-doux); }
.rg-choix button span { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.rg-choix button:hover, .rg-choix button:focus { background: var(--rg-actif); outline: none; }
.rg-choix button:focus-visible { box-shadow: inset 0 0 0 2px var(--rg-accent); }
/* Visiteur sans tableau sur la page (accueils Terminal et Éditorial) : invitation à créer un compte. */
.rg-invite-t { display: flex; align-items: flex-start; gap: 8px; margin: 4px 6px 8px; color: var(--rg-texte); font-size: 13px; line-height: 1.4; }
.rg-invite-t svg { flex: 0 0 auto; margin-top: 1px; color: var(--rg-doux); }
.rg-invite-a { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; margin: 0 6px 4px; }
.rg-invite-a a { color: var(--rg-accent); font-size: 13px; text-decoration: underline; text-underline-offset: 2px; }
.rg-invite-a a.rg-invite-fort {
  padding: 5px 12px; border: 1px solid var(--rg-accent); border-radius: 999px; text-decoration: none; font-weight: 600;
}
body.ae .rg-invite-a a.rg-invite-fort, body.ad .rg-invite-a a.rg-invite-fort { border-radius: var(--rg-rayon); }
.rg-invite-a a:focus-visible { outline: 2px solid var(--rg-accent); outline-offset: 2px; }

/* ---------------------------------------------------------------- Plein écran (téléphone) */
.rg-p.rg-plein {
  inset: 0 !important; width: auto !important; max-height: none !important; border: 0; border-radius: 0; box-shadow: none;
  font-size: 15px; padding-bottom: env(safe-area-inset-bottom, 0);
}
.rg-plein .rg-tete {
  display: flex; align-items: center; gap: 4px; flex: 0 0 auto; padding: 8px 10px 8px 4px; padding-top: max(8px, env(safe-area-inset-top, 0));
  border-bottom: 1px solid var(--rg-trait);
}
.rg-retour {
  flex: 0 0 auto; display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; padding: 0;
  border: 0; background: none; color: var(--rg-texte); cursor: pointer;
}
.rg-q2 {
  flex: 1 1 auto; display: flex; align-items: center; gap: 8px; min-width: 0; height: 42px; padding: 0 12px;
  border: 1px solid var(--rg-trait); border-radius: calc(var(--rg-rayon) - 2px); background: var(--rg-actif); color: var(--rg-doux);
}
.rg-q2:focus-within { border-color: var(--rg-accent); }
.rg-q2 input {
  flex: 1 1 auto; min-width: 0; height: 100%; padding: 0; border: 0; outline: none; background: none; color: var(--rg-texte);
  font: inherit; font-size: 16px; /* 16 px : pas de zoom automatique sur iPhone */
}
.rg-q2 input::-webkit-search-cancel-button { -webkit-appearance: none; }
.rg-q2 input:focus, .rg-q2 input:focus-visible { outline: none !important; box-shadow: none !important; border: 0 !important; }
/* Au téléphone, l'adresse d'un site ou d'un lien laisse la place au nom (la ligne du dessous dit ce qu'il est). */
.rg-plein .rg-site .rg-d, .rg-plein .rg-lien .rg-d { display: none !important; }
.rg-plein .rg-corps { padding-bottom: 24px; }
.rg-plein .rg-barre { top: auto; }
.rg-plein .rg-choix { margin-left: 14px; }
html.rg-plein-ouvert, html.rg-plein-ouvert body { overflow: hidden !important; }

/* ---------------------------------------------------------------- Glisser */
html.rg-glisse, html.rg-glisse * { cursor: grabbing !important; -webkit-user-select: none !important; user-select: none !important; }
.rg-p.rg-p-glisse { opacity: 0; pointer-events: none; transition: opacity .15s; }
.rg-fantome {
  position: fixed; top: 0; left: 0; z-index: 1300; display: inline-flex; align-items: center; gap: 8px; max-width: 280px;
  padding: 7px 12px 7px 9px; border: 1px solid var(--rg-accent); border-radius: var(--rg-rayon); background: var(--rg-fond);
  color: var(--rg-texte); font-family: var(--rg-police); font-size: 13.5px; box-shadow: var(--rg-ombre); pointer-events: none;
  will-change: transform;
}
.rg-fantome span:last-child { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.rg-fantome .rg-ico { flex: 0 0 20px; }
li.rg-place {
  display: block !important; list-style: none; box-sizing: border-box; min-height: 30px; margin: 2px 0 !important; padding: 0 !important;
  border: 1.5px dashed var(--rg-accent) !important; border-radius: calc(var(--rg-rayon) - 2px); background: var(--rg-actif);
}
li.rg-place.rg-envoi { animation: rg-pulse 1s ease-in-out infinite; }
.box.rg-place-boite {
  min-height: 64px; border: 1.5px dashed var(--rg-accent) !important; background: var(--rg-actif) !important; box-shadow: none !important;
  opacity: .9;
}
.box.rg-place-boite header { padding: 8px 10px; color: var(--rg-doux); font-size: 13px; }
.box.rg-place-boite.rg-envoi { animation: rg-pulse 1s ease-in-out infinite; }
/* Boîte trouvée glissée sur le tableau de l'accueil (accueil-f) : cadre en pointillé à la place qu'elle prendra. */
.af-place-rg.rg-place-boite {
  display: block; box-sizing: border-box; min-height: 72px; margin: 0 0 14px; border: 1.5px dashed var(--rg-accent);
  border-radius: var(--rg-rayon); background: var(--rg-actif); break-inside: avoid;
}
.af-place-rg.rg-place-boite header { padding: 10px 12px; color: var(--rg-doux); font-size: 13px; }
.af-place-rg.rg-place-boite.rg-envoi { animation: rg-pulse 1s ease-in-out infinite; }
@keyframes rg-pulse { 50% { opacity: .5; } }
.rg-onglet-survol { outline: 2px dashed var(--accent, #2f6f94); outline-offset: 2px; }

/* Lien ou boîte qui vient d'arriver */
.rg-nouveau { animation: rg-arrive 2.2s ease-out; }
@keyframes rg-arrive {
  0%, 30% { background-color: var(--accent-doux, var(--accent-fond, var(--survol, #e6eef4))); box-shadow: 0 0 0 2px var(--accent, var(--encre, #2f6f94)); }
  100% { background-color: transparent; box-shadow: 0 0 0 2px transparent; }
}
@media (prefers-reduced-motion: reduce) {
  .rg-nouveau, li.rg-place.rg-envoi, .box.rg-place-boite.rg-envoi, .af-place-rg.rg-envoi, .rg-charge .rg-barre::after { animation: none; }
  .rg-nouveau { box-shadow: 0 0 0 2px var(--accent, #2f6f94); }
}

/* Lien ajouté sur cet appareil : son × de retrait suit les règles des × des boîtes (mode d'édition). */
li[data-rg-ajout] { position: relative; }

/* Annonce brève (et lue par les lecteurs d'écran) */
.rg-annonce {
  position: fixed; left: 50%; bottom: 18px; z-index: 1300; max-width: min(92vw, 520px); padding: 9px 14px;
  border-radius: var(--rg-rayon); background: var(--rg-texte); color: var(--rg-fond); font-family: var(--rg-police); font-size: 13.5px;
  box-shadow: var(--rg-ombre); transform: translate(-50%, 12px); opacity: 0; pointer-events: none; transition: opacity .18s, transform .18s;
}
.rg-annonce.rg-annonce-vue { opacity: 1; transform: translate(-50%, 0); }
.rg-annonce:empty { visibility: hidden; }

/* Images masquées (témoin alpha_images) : texte seul. */
html[data-images="non"] .rg-site .rg-ico, html[data-images="non"] .rg-web .rg-ico, html[data-images="non"] .rg-lien .rg-ico,
html[data-images="non"] .rg-fantome .rg-ico { display: none; }

/* Bouton loupe (ouvre la recherche là où le champ n'a pas de place) */
.rg-ouvrir {
  display: none; align-items: center; justify-content: center; width: 40px; height: 40px; padding: 0; border: 0; border-radius: 8px;
  background: none; color: inherit; cursor: pointer;
}
.rg-ouvrir:focus-visible { outline: 2px solid currentColor; outline-offset: 1px; }

/* Champ de l'accueil Éditorial (public/accueil-e.php) : filet sous le texte, comme la typographie du style. */
.ae-cherche {
  display: flex; align-items: center; gap: 6px; width: 210px; height: 30px; padding: 0 2px; border-bottom: 1px solid var(--encre, #0b0b0b);
  color: var(--gris, #555555); cursor: text;
}
.ae-cherche input {
  flex: 1 1 auto; min-width: 0; height: 100%; padding: 0; border: 0; border-radius: 0; outline: 0; background: none;
  color: var(--encre, #0b0b0b); font: inherit; font-size: 13px; -webkit-appearance: none; appearance: none;
}
.ae-cherche input::placeholder { color: var(--gris-2, #6f6f6f); }
.ae-cherche:focus-within { color: var(--encre, #0b0b0b); box-shadow: 0 1px 0 0 var(--encre, #0b0b0b); }
.ae-cherche .ae-vh { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
@media (max-width: 899px) { .ae-cherche { width: 150px; } }
@media (max-width: 599px) {
  .ae-cherche { width: 34px; justify-content: center; border-bottom: 0; padding: 0; }
  .ae-cherche input { position: absolute; inset: 0; opacity: 0; font-size: 16px; }
  .ae-cherche { position: relative; }
}

/* Tableau du membre (public/index.php) : champ plus large dans la barre ; au téléphone, la loupe ouvre la recherche. */
.entete .recherche { width: 190px; }
.entete .recherche:focus { width: 250px; }
.entete .rg-ouvrir { color: #ccd6e0; }
.entete .rg-ouvrir:hover { color: #ffffff; }
@media (max-width: 900px) { .entete .recherche { width: 150px; } .entete .recherche:focus { width: 190px; } }
@media (max-width: 600px) { .entete .rg-ouvrir { display: inline-flex; } }
html:not([data-scheme="dark"]) body:not(.theme-sombre):not(.theme-ardoise):not(.theme-contraste) .entete .rg-ouvrir { color: #5b6b77; }
html:not([data-scheme="dark"]) body:not(.theme-sombre):not(.theme-ardoise):not(.theme-contraste) .entete .rg-ouvrir:hover { color: #1f2a33; background: #f0f2f4; }
/* Affichage « Simple » (affichage.css masque le champ) : la loupe seule ; un clic ou « / » montre le champ et ouvre le panneau,
   le champ se replie quand il est vide et quitté. */
body.aff-simple .entete .rg-ouvrir { display: inline-flex; }
@media (min-width: 601px) {
  body.aff-simple.rg-champ-vu .entete .recherche { display: inline-block !important; }
  body.aff-simple.rg-champ-vu .entete .rg-ouvrir { display: none; }
}
