/*
 * InTraTool - aide contextuelle.
 *
 * Habillage du declencheur "?" et du panneau lateral poses par
 * templates/element/help_panel.php, plus la mise en forme du Markdown rendu
 * par App\Utility\HelpMarkdown.
 *
 * Reprend les jetons de theme.css : aucune couleur n'est redefinie ici.
 *
 * Les tailles sont en rem, et theme.css pose html { font-size: 62.5% } :
 * 1rem vaut donc 10px, pas 16px. Les valeurs ci-dessous sont exprimees
 * dans cette echelle -- le corps du panneau est a 13.5px, juste sous les
 * 14px du texte de l'application.
 */

/* Declencheur, ancre en bas a droite, au-dessus du contenu. */
.help-trigger {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 900;
  width: 46px;
  height: 46px;
  padding: 0;
  margin: 0;
  border: 1px solid var(--itt-border-strong);
  border-radius: 50%;
  background: var(--itt-surface);
  color: var(--itt-accent-dark);
  font-family: var(--itt-font);
  font-size: 2rem;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  box-shadow: var(--itt-shadow-lg);
  transition: background .15s ease, color .15s ease, transform .15s ease;
}

.help-trigger:hover,
.help-trigger:focus {
  background: var(--itt-accent);
  border-color: var(--itt-accent);
  color: #fff;
  transform: translateY(-1px);
}

.help-trigger:focus-visible {
  outline: none;
  box-shadow: var(--itt-shadow-lg), var(--itt-focus);
}

.help-trigger[aria-expanded="true"] {
  background: var(--itt-accent);
  border-color: var(--itt-accent);
  color: #fff;
}

/* Panneau lateral. */
.help-panel {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 901;
  display: flex;
  flex-direction: column;
  width: min(430px, 100vw);
  height: 100vh;
  background: var(--itt-surface);
  border-left: 1px solid var(--itt-border);
  box-shadow: var(--itt-shadow-lg);
  font-family: var(--itt-font);
  color: var(--itt-text);
}

.help-panel[hidden] {
  display: none;
}

.help-panel-header {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--itt-border);
  background: var(--itt-surface-alt);
}

.help-panel-header h2 {
  flex: 1;
  margin: 0;
  font-size: 1.6rem;
  font-weight: 600;
  line-height: 1.35;
  color: var(--itt-text);
}

.help-panel-eyebrow {
  display: block;
  margin-bottom: 3px;
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--itt-text-faint);
}

.help-close {
  padding: 0;
  width: 28px;
  height: 28px;
  border: none;
  background: none;
  color: var(--itt-text-muted);
  font-size: 2.2rem;
  line-height: 1;
  cursor: pointer;
}

.help-close:hover {
  color: var(--itt-text);
}

.help-panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px 24px;
  font-size: 1.35rem;
  line-height: 1.6;
}

.help-panel-body h3,
.help-panel-body h4,
.help-panel-body h5 {
  margin: 20px 0 6px;
  font-weight: 600;
  line-height: 1.35;
  color: var(--itt-text);
}

.help-panel-body h3 { font-size: 1.5rem; }
.help-panel-body h4 { font-size: 1.4rem; }
.help-panel-body h5 { font-size: 1.3rem; color: var(--itt-text-muted); }

.help-panel-body > :first-child {
  margin-top: 0;
}

.help-panel-body p,
.help-panel-body ul,
.help-panel-body ol {
  margin: 0 0 10px;
}

.help-panel-body ul,
.help-panel-body ol {
  padding-left: 20px;
}

.help-panel-body li {
  margin-bottom: 4px;
}

.help-panel-body a {
  color: var(--itt-accent-dark);
}

.help-panel-body code {
  padding: 1px 5px;
  border-radius: var(--itt-radius-sm);
  background: var(--itt-accent-soft);
  font-size: .84em;
  color: var(--itt-accent-dark);
}

.help-panel-body img {
  display: block;
  max-width: 100%;
  margin: 10px 0;
  border: 1px solid var(--itt-border);
  border-radius: var(--itt-radius-sm);
}

.help-panel-body hr {
  margin: 16px 0;
  border: none;
  border-top: 1px solid var(--itt-border);
}

/* Encadre "bon a savoir" : les citations Markdown. */
.help-note {
  margin: 12px 0;
  padding: 10px 14px;
  border-left: 3px solid var(--itt-accent);
  border-radius: 0 var(--itt-radius-sm) var(--itt-radius-sm) 0;
  background: var(--itt-accent-soft);
}

.help-note p {
  margin: 0;
}

.help-code {
  margin: 10px 0;
  padding: 10px 12px;
  overflow-x: auto;
  border-radius: var(--itt-radius-sm);
  background: var(--itt-surface-alt);
  border: 1px solid var(--itt-border);
  font-size: 1.25rem;
}

.help-panel-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  padding: 12px 20px;
  border-top: 1px solid var(--itt-border);
  background: var(--itt-surface-alt);
  font-size: 1.2rem;
}

.help-panel-footer a {
  color: var(--itt-accent-dark);
}

/* Voile, uniquement en etroit : le panneau y couvre l'ecran. */
.help-overlay {
  position: fixed;
  inset: 0;
  z-index: 900;
  background: rgba(16, 24, 40, .35);
}

.help-overlay[hidden] {
  display: none;
}

@media (min-width: 900px) {
  .help-overlay {
    display: none;
  }
}

/* Sommaire et page pleine de l'aide. */
.help-index {
  max-width: 900px;
}

.help-section {
  margin-bottom: 26px;
  padding: 16px 20px;
  border: 1px solid var(--itt-border);
  border-radius: var(--itt-radius);
  background: var(--itt-surface);
  box-shadow: var(--itt-shadow-sm);
}

.help-section h3 {
  margin: 0 0 12px;
  font-size: 1.5rem;
  font-weight: 600;
}

.help-section ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

.help-section li {
  padding: 7px 0;
  border-top: 1px solid var(--itt-border);
}

.help-section li:first-child {
  border-top: none;
}

.help-section .help-summary {
  display: block;
  color: var(--itt-text-muted);
  font-size: 1.25rem;
}

.help-topic {
  max-width: 760px;
  padding: 22px 26px;
  border: 1px solid var(--itt-border);
  border-radius: var(--itt-radius);
  background: var(--itt-surface);
  box-shadow: var(--itt-shadow-sm);
  line-height: 1.65;
}

.help-topic .help-panel-body {
  padding: 0;
  overflow: visible;
  font-size: 1.45rem;
}

.help-empty {
  color: var(--itt-text-muted);
}
