/* Aide (js/support.js) : bouton rond en bas à droite, étiquette manuscrite avec flèche (même style que le site vitrine),
   fenêtre pour poser une question ou signaler un bug, et lire les réponses. S'appuie sur les variables de css/style.css. */

/* Caveat, police manuscrite de l'étiquette (SIL Open Font License 1.1), la même que sur le site vitrine. */
@font-face {
  font-family: 'Caveat';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url(fonts/caveat-600-latin.woff2) format('woff2');
}

.aide {
  position: fixed; right: 20px; bottom: 20px; z-index: 60;
  display: flex; flex-direction: column; align-items: flex-end; gap: 12px;
  pointer-events: none;
}
.aide > * { pointer-events: auto; }
@media print { .aide { display: none !important; } }

/* ── Étiquette manuscrite + flèche, tant que la personne n'a pas ouvert l'aide une première fois. */
.aide-indice {
  position: absolute; right: 0; bottom: 0; width: 0; height: 0;
  pointer-events: none;
  display: none;
}
/* Seulement sur la liste des chantiers, et jamais par-dessus la fenêtre d'aide. Ailleurs, le bouton rond seul, plus petit. */
body[data-page="accueil"] .aide:not(.est-ouvert) .aide-indice { display: block; }
body:not([data-page="accueil"]) .aide-bouton { width: 44px; height: 44px; box-shadow: 0 3px 10px rgba(16, 32, 58, 0.22); }
body:not([data-page="accueil"]) .aide-bouton svg { width: 22px; height: 22px; }
.aide-etiquette {
  position: absolute; right: 36px; bottom: 90px;
  padding: 7px 20px 9px; white-space: nowrap;
  background: var(--surface); border: 1px solid var(--border); border-radius: 18px;
  box-shadow: 0 4px 18px rgba(10, 11, 36, 0.1);
  font-family: 'Caveat', 'Segoe Print', 'Bradley Hand', cursive; font-weight: 600; font-size: 1.5rem; line-height: 1.1;
  color: var(--text); transform: rotate(-4deg); transform-origin: right bottom;
}
.aide-fleche {
  position: absolute; right: 54px; bottom: 20px; width: 64px; height: 67px; overflow: visible;
  fill: none; stroke: var(--text); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round;
}

/* ── Bouton rond. */
.aide-bouton {
  position: relative; width: 56px; height: 56px; padding: 0; border: 0; border-radius: 50%;
  display: grid; place-items: center; cursor: pointer;
  background: var(--primary); color: var(--on-primary);
  box-shadow: 0 6px 20px rgba(16, 32, 58, 0.3), 0 1px 3px rgba(16, 32, 58, 0.2);
  transition: transform 0.15s ease, background 0.15s ease;
}
.aide-bouton:hover { background: var(--primary-hover); transform: translateY(-2px); }
.aide-bouton:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
.aide-bouton svg { width: 28px; height: 28px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
/* Réponse non lue. */
.aide-pastille {
  position: absolute; top: -4px; right: -4px; min-width: 22px; height: 22px; padding: 0 6px;
  display: grid; place-items: center; box-sizing: border-box;
  border-radius: 999px; border: 2px solid var(--bg); background: var(--danger); color: var(--surface);
  font-size: 0.74rem; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1;
}
.aide-pastille[hidden] { display: none; }

/* ── Fenêtre : un titre, du contenu, rien d'autre. */
.aide-panneau {
  width: min(304px, calc(100vw - 40px)); max-height: min(500px, calc(100vh - 110px));
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: 0 14px 44px rgba(16, 32, 58, 0.24), 0 2px 6px rgba(16, 32, 58, 0.1);
}
.aide-panneau[hidden] { display: none; }
.aide-tete { flex: none; display: flex; align-items: center; gap: 4px; padding: 8px 8px 4px 14px; }
.aide-tete h2 { flex: 1; min-width: 0; margin: 0; font-size: 0.95rem; font-weight: 650; }
.aide-tete .aide-icone:first-child { margin-left: -10px; }
.aide-tete .aide-icone:first-child + h2 { margin-left: 4px; }
.aide-icone { width: 30px; height: 30px; padding: 0; flex: none; display: grid; place-items: center; border: 0; border-radius: 50%; background: none; color: var(--text-2); cursor: pointer; }
.aide-icone:hover { background: var(--surface-3); color: var(--text); }
.aide-icone svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.aide-corps { display: flex; flex-direction: column; gap: 8px; padding: 6px 14px 14px; overflow-y: auto; }
.aide-erreur { margin: 0 14px 10px; padding: 6px 8px; border-radius: var(--radius-sm); background: var(--danger-soft); color: var(--danger); font-size: 0.82rem; }
.aide-corps .aide-erreur { margin: 0; }
.aide-erreur[hidden] { display: none; }

/* Accueil : deux gros boutons, puis les échanges. */
.aide-choix {
  display: flex; align-items: center; gap: 11px; width: 100%; padding: 11px 13px; text-align: left; cursor: pointer;
  font: inherit; font-size: 0.9rem; font-weight: 600; color: var(--text);
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius);
}
.aide-choix:hover { background: var(--surface-2); border-color: var(--primary); }
.aide-choix:focus-visible, .aide-fil:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.aide-choix-picto { flex: none; width: 32px; height: 32px; display: grid; place-items: center; border-radius: 8px; background: var(--primary-soft); color: var(--primary); }
.aide-choix[data-type="bug"] .aide-choix-picto { background: var(--danger-soft); color: var(--danger); }
.aide-choix-picto svg, .aide-fil-picto svg, .aide-fil-etat svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }

.aide-fils { list-style: none; margin: 4px 0 0; padding: 10px 0 0; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 2px; }
.aide-fil {
  position: relative; display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px; text-align: left; cursor: pointer;
  font: inherit; font-size: 0.86rem; color: var(--text); background: none; border: 0; border-radius: var(--radius-sm);
}
.aide-fil:hover { background: var(--surface-3); }
.aide-fil-picto { flex: none; display: grid; place-items: center; color: var(--text-3); }
.aide-fil-picto svg { width: 16px; height: 16px; }
.aide-fil-texte { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.aide-fil-etat { flex: none; display: grid; place-items: center; color: var(--success); }
.aide-fil-etat svg { width: 15px; height: 15px; }
.aide-fil.est-resolu { color: var(--text-2); }
.aide-fil.est-non-lu { font-weight: 650; }
.aide-fil.est-non-lu::after { content: ''; flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--primary); }

/* Écrire. */
.aide-texte { min-height: 120px; font-size: 0.88rem; }
.aide-envoi { width: 100%; height: 36px; font-size: 0.88rem; }
.aide-capture { display: flex; align-items: flex-start; gap: 6px; font-size: 0.82rem; line-height: 1.35; cursor: pointer; }
.aide-capture input { flex: none; margin-top: 2px; accent-color: var(--primary); }
/* Trombone à gauche du bouton Envoyer. */
.aide-actions { display: flex; align-items: center; gap: 6px; }
.aide-actions .aide-envoi { flex: 1; }
.aide-actions .aide-icone { width: 36px; height: 36px; }
.aide-icone.pj-joindre svg { width: 19px; height: 19px; }

/* Message envoyé. */
.aide-merci { align-items: center; text-align: center; gap: 11px; padding-top: 14px; padding-bottom: 18px; }
.aide-merci-picto { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 50%; background: var(--success-soft); color: var(--success); }
.aide-merci-picto svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.aide-merci strong { font-size: 0.95rem; }

/* Conversation : des bulles, une ligne pour répondre. */
.aide-messages { flex: 1; min-height: 100px; gap: 6px; }
.aide-bulle {
  max-width: 85%; padding: 8px 12px; border-radius: 14px; background: var(--surface-3); color: var(--text);
  font-size: 0.86rem; line-height: 1.45; white-space: pre-wrap; overflow-wrap: anywhere;
}
.aide-bulle.est-moi { align-self: flex-end; background: var(--primary); color: var(--on-primary); border-bottom-right-radius: 4px; }
.aide-bulle.est-equipe { align-self: flex-start; border-bottom-left-radius: 4px; }
.aide-bulle .pj-mini img { max-height: 130px; }
.aide-pied { flex: none; display: flex; flex-wrap: wrap; align-items: flex-end; gap: 6px; padding: 8px 10px 10px 8px; border-top: 1px solid var(--border); }
.aide-pied .pj-vignettes { flex-basis: 100%; padding: 6px 0 2px 6px; }
.aide-pied .aide-icone { width: 34px; height: 34px; }
.aide-pied .input { flex: 1; min-height: 34px; max-height: 100px; padding: 7px 12px; border-radius: 17px; resize: none; font-size: 0.86rem; line-height: 1.35; }
.aide-envoi-rond { flex: none; width: 34px; height: 34px; padding: 0; display: grid; place-items: center; border: 0; border-radius: 50%; background: var(--primary); color: var(--on-primary); cursor: pointer; }
.aide-envoi-rond:hover:not(:disabled) { background: var(--primary-hover); }
.aide-envoi-rond:disabled { background: var(--surface-3); color: var(--text-3); cursor: not-allowed; }
.aide-envoi-rond svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }

@media (max-width: 560px) {
  .aide { right: 12px; bottom: 12px; }
  .aide-panneau { width: calc(100vw - 24px); max-height: calc(100vh - 90px); }
  .aide-etiquette { font-size: 1.3rem; padding: 5px 16px 7px; right: 30px; }
}
