/* Aide du site (todo #40) : bouton « i », calque de grisage, bulles, mode « Modifier l'aide ».
   Scripts : public/assets/legacy/Scripts/Help/. */

.topbar-side {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.help-toggle {
  box-sizing: content-box;
  width: 24px;
  height: 24px;
  padding: 0;
  flex: 0 0 auto;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  font: italic 700 14px/1 Georgia, 'Times New Roman', serif;
  cursor: pointer;
}

.help-toggle:hover,
.help-toggle:focus-visible,
.help-toggle[aria-pressed="true"] {
  border-color: var(--accent);
  color: var(--accent);
  outline: none;
}

.help-toggle[aria-pressed="true"] {
  background: color-mix(in srgb, var(--accent) 16%, transparent);
}

.help-toggle[hidden],
.help-ui [hidden] {
  display: none;
}

.help-modal-toggle {
  position: fixed;
  z-index: 2147483004;
  background: #171322;
  border-color: var(--accent);
  color: var(--accent);
}

.help-layer {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 2147483000;
  pointer-events: none;
}

.help-dim {
  fill: rgba(5, 4, 9, .82);
}

.help-dim.is-edit {
  fill: rgba(5, 4, 9, .3);
}

.help-frame {
  fill: none;
  stroke: color-mix(in srgb, var(--accent) 75%, transparent);
  stroke-width: 1;
  stroke-dasharray: 5 4;
}

.help-frame.is-hot {
  stroke: var(--accent);
  stroke-width: 2;
  stroke-dasharray: none;
}

.help-dim.is-edit ~ g .help-frame {
  stroke: var(--accent);
  stroke-width: 2;
  stroke-dasharray: none;
}

.help-dim.is-edit ~ g .help-frame.is-candidate {
  stroke: var(--accent-2);
  stroke-dasharray: 4 3;
}

.help-dim.is-edit ~ g .help-frame.is-hot {
  stroke: var(--accent-2);
}

.help-arrow {
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.5;
  stroke-dasharray: 5 4;
}

.help-arrow-head {
  fill: var(--accent);
}

.help-bubble,
.help-bar,
.help-editor {
  box-sizing: border-box;
  color: var(--text);
  font: 14px/1.45 var(--font-body);
  text-align: left;
}

.help-bubble {
  position: fixed;
  z-index: 2147483001;
  width: min(320px, calc(100vw - 24px));
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 12px;
  border: 1px dashed var(--accent);
  border-radius: 10px;
  background: #171322;
  box-shadow: var(--shadow-card);
  pointer-events: none;
}

.help-bubble h4 {
  margin: 0;
  font-size: 12px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--accent);
}

.help-bubble p {
  margin: 0;
  white-space: pre-line;
}

.help-bubble ul {
  margin: 0;
  padding-left: 16px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 13.5px;
}

.help-bubble kbd {
  padding: 0 5px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: color-mix(in srgb, var(--accent-2) 8%, transparent);
  color: var(--accent-2);
  font: 12px var(--font-mono);
}

.help-media {
  max-width: 100%;
  border-radius: 6px;
}

.help-demo {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
}

.help-demo small {
  color: var(--muted);
  font-size: 11px;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.help-demo-field {
  padding: 4px 8px;
  border: 1px solid var(--input-border);
  border-radius: 6px;
  font: 13px var(--font-mono);
  white-space: nowrap;
  overflow: hidden;
}

.help-demo-typed {
  display: inline-block;
  overflow: hidden;
  vertical-align: bottom;
  border-right: 2px solid var(--accent);
  animation: help-type 3.2s steps(var(--help-chars)) infinite;
}

.help-demo-result {
  min-height: 1.4em;
  color: var(--accent-2);
  font-size: 13px;
  animation: help-result 3.2s linear infinite;
}

@keyframes help-type {
  0% { width: 0; }
  45%, 100% { width: calc(var(--help-chars) * 1ch); }
}

@keyframes help-result {
  0%, 50% { opacity: 0; }
  60%, 100% { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .help-demo-typed,
  .help-demo-result {
    animation: none;
  }
}

.help-bar {
  position: fixed;
  left: 50%;
  bottom: 14px;
  z-index: 2147483003;
  transform: translateX(-50%);
  max-width: calc(100% - 24px);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 12px;
  border: 1px solid var(--accent);
  border-radius: 14px;
  background: #171322;
  box-shadow: var(--shadow-card);
  font-size: 13px;
}

.help-bar.is-edit {
  border-color: var(--accent-2);
}

.help-bar button,
.help-editor button {
  box-sizing: border-box;
  margin: 0;
  padding: 5px 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--btn-bg);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}

.help-bar button:hover,
.help-editor button:hover {
  border-color: var(--accent);
}

.help-bar button.help-primary,
.help-editor button.help-primary {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 700;
}

.help-editor button.help-danger {
  border-color: color-mix(in srgb, var(--danger) 65%, var(--border));
  color: var(--danger);
}

.help-editor button.help-link {
  align-self: flex-start;
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent-2);
  text-decoration: underline;
}

.help-editor {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 2147483002;
  width: min(390px, 100%);
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px 16px 84px;
  overflow-y: auto;
  border-left: 1px solid var(--accent-2);
  background: #171322;
  box-shadow: -18px 0 44px rgba(0, 0, 0, .5);
}

.help-editor h3 {
  margin: 0;
  font: 700 17px var(--font-head);
}

.help-editor label,
.help-editor-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 0;
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
}

.help-editor small {
  color: var(--muted);
  font-weight: 400;
}

.help-editor input[type="text"],
.help-editor textarea {
  box-sizing: border-box;
  width: 100%;
  margin: 0;
  padding: 6px 9px;
  border: 1px solid var(--input-border);
  border-radius: 8px;
  background: var(--input-bg);
  color: var(--text);
  font: 14px/1.4 var(--font-body);
  resize: vertical;
}

.help-editor-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.help-editor-note {
  margin: 0;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 400;
}

.help-editor-status {
  margin: 0;
  min-height: 1.4em;
  color: var(--danger);
  font-size: 13px;
}

.help-orphan {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
}

/* ----- Placeholders (todo #132) ----- */

/* Valeur d'exemple : posee par-dessus un champ pendant le tuto. */
.help-sample {
  position: fixed;
  z-index: 2147483000;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  padding: 0 9px;
  overflow: hidden;
  border-radius: 7px;
  background: #0d0b15;
  color: var(--accent-2);
  font: italic 14px/1.2 var(--font-body);
  white-space: nowrap;
  text-overflow: ellipsis;
  pointer-events: none;
}

/* Element d'exemple : ajoute a la page le temps du tuto, juste apres son repere. */
help-ghost.help-ghost {
  box-sizing: border-box;
  display: block;
  margin: 6px 0;
  padding: 6px 10px;
  border: 1px dashed var(--border);
  border-radius: 8px;
  color: var(--text);
  font: 13.5px/1.4 var(--font-body);
  text-align: left;
}

help-ghost.help-ghost-alert {
  border: 1px solid var(--danger);
  background: color-mix(in srgb, var(--danger) 12%, transparent);
}

help-ghost.help-ghost-warning {
  border: 1px solid var(--warning);
  background: color-mix(in srgb, var(--warning) 12%, transparent);
}

help-ghost.help-ghost-button {
  display: inline-block;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--btn-bg);
  font-weight: 600;
}

help-ghost.help-ghost-field {
  display: grid;
  grid-template-columns: minmax(90px, 30%) minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  padding: 0;
  border: 0;
}

.help-ghost-label {
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
}

.help-ghost-input {
  min-height: 1.4em;
  padding: 6px 9px;
  border: 1px solid var(--input-border);
  border-radius: 8px;
  background: var(--input-bg);
  color: var(--muted);
}

.help-editor select {
  box-sizing: border-box;
  width: 100%;
  margin: 0;
  padding: 6px 9px;
  border: 1px solid var(--input-border);
  border-radius: 8px;
  background: #0d0b15;
  color: var(--text);
  font: 14px/1.4 var(--font-body);
}
