/* ═══════════════════════════════════════════════════════════════════
 * Help launcher - bouton flottant + menu + modal d'aide
 * Design : picto lumineux discret qui s'anime doucement, menu glassmorphism,
 *          modal plein écran app-like sur mobile.
 * ═══════════════════════════════════════════════════════════════════ */

/* ── Bouton flottant ───────────────────────────────────────────────── */
.hd-help-launcher {
  position: fixed;
  left: max(1rem, env(safe-area-inset-left, 0px));
  bottom: max(1rem, env(safe-area-inset-bottom, 0px));
  z-index: 9200; /* > welcome-toast (9000), back-to-top (901), modals backdrop */
  width: 52px;
  height: 52px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  /* gap:0 par défaut pour centrer l'icône dans le cercle ; on l'ouvre seulement
     au hover où le label apparaît. */
  gap: 0;
  background: linear-gradient(135deg, rgba(16, 30, 60, 0.95), rgba(13, 24, 48, 0.95));
  color: var(--gold, #c9a84c);
  border: 1px solid rgba(201, 168, 76, 0.45);
  border-radius: 999px;
  cursor: pointer;
  box-shadow:
    0 6px 20px -4px rgba(0, 0, 0, 0.35),
    0 0 0 1px rgba(201, 168, 76, 0.12),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  transition: width 0.28s cubic-bezier(0.23, 1, 0.32, 1),
              transform 0.22s ease,
              box-shadow 0.22s ease,
              border-color 0.22s ease;
  overflow: hidden;
  white-space: nowrap;
}
.hd-help-launcher:hover,
.hd-help-launcher:focus-visible {
  width: 108px;
  gap: 0.4rem;
  transform: translateY(-1px);
  border-color: rgba(201, 168, 76, 0.7);
  box-shadow:
    0 10px 28px -6px rgba(0, 0, 0, 0.45),
    0 0 0 1px rgba(201, 168, 76, 0.25),
    0 0 22px rgba(201, 168, 76, 0.18);
  outline: none;
}
.hd-help-launcher__icon {
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
}
.hd-help-launcher__label {
  max-width: 0;
  opacity: 0;
  overflow: hidden;
  font-family: var(--font-heading, inherit);
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  transition: max-width 0.28s cubic-bezier(0.23, 1, 0.32, 1),
              opacity 0.2s ease;
}
.hd-help-launcher:hover .hd-help-launcher__label,
.hd-help-launcher:focus-visible .hd-help-launcher__label {
  max-width: 60px;
  opacity: 1;
}
.hd-help-launcher__halo {
  position: absolute;
  inset: -3px;
  border-radius: inherit;
  background: radial-gradient(circle at 30% 30%,
              rgba(201, 168, 76, 0.22),
              transparent 65%);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
}
.hd-help-launcher:hover .hd-help-launcher__halo { opacity: 1; }

/* Pulse subtil pour découvrabilité (3 boucles seulement, puis s'arrête) */
@keyframes hdHelpPulse {
  0%, 100% { box-shadow:
    0 6px 20px -4px rgba(0, 0, 0, 0.35),
    0 0 0 1px rgba(201, 168, 76, 0.12),
    0 0 0 0 rgba(201, 168, 76, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.06); }
  50% { box-shadow:
    0 6px 20px -4px rgba(0, 0, 0, 0.35),
    0 0 0 1px rgba(201, 168, 76, 0.12),
    0 0 0 8px rgba(201, 168, 76, 0),
    inset 0 1px 0 rgba(255, 255, 255, 0.06); }
}
.hd-help-launcher--intro {
  animation: hdHelpPulse 2.2s ease-in-out 1.2s 2;
}

.hd-help-launcher[aria-expanded="true"] {
  transform: rotate(-8deg) scale(0.95);
  border-color: rgba(201, 168, 76, 0.7);
}

/* ── Menu bubble ──────────────────────────────────────────────────── */
.hd-help-menu {
  position: fixed;
  left: max(1rem, env(safe-area-inset-left, 0px));
  bottom: max(72px, calc(env(safe-area-inset-bottom, 0px) + 72px));
  z-index: 9201;
  width: min(340px, calc(100vw - 1.5rem));
  padding: 0.8rem;
  background: linear-gradient(180deg, rgba(16, 30, 60, 0.96), rgba(13, 24, 48, 0.96));
  border: 1px solid rgba(201, 168, 76, 0.22);
  border-radius: 16px;
  box-shadow:
    0 24px 60px -16px rgba(0, 0, 0, 0.55),
    0 0 0 1px rgba(201, 168, 76, 0.08);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transform-origin: bottom left;
  animation: hdHelpMenuIn 0.22s cubic-bezier(0.23, 1, 0.32, 1);
}
@keyframes hdHelpMenuIn {
  from { opacity: 0; transform: translateY(8px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.hd-help-menu__arrow {
  position: absolute;
  left: 16px;
  bottom: -7px;
  width: 14px; height: 14px;
  background: inherit;
  border-right: 1px solid rgba(201, 168, 76, 0.22);
  border-bottom: 1px solid rgba(201, 168, 76, 0.22);
  transform: rotate(45deg);
}
.hd-help-menu__eyebrow {
  margin: 0.25rem 0.65rem 0.75rem;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: rgba(240, 238, 235, 0.6);
  font-weight: 500;
}
.hd-help-menu__item {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  width: 100%;
  padding: 0.75rem 0.85rem;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 12px;
  color: var(--text-primary, #f0eeeb);
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  font-size: 0.88rem;
  transition: background 0.16s ease, border-color 0.16s ease;
  margin-bottom: 0.3rem;
}
.hd-help-menu__item:hover,
.hd-help-menu__item:focus-visible {
  background: rgba(201, 168, 76, 0.08);
  border-color: rgba(201, 168, 76, 0.25);
  outline: none;
}
.hd-help-menu__item-icon {
  flex: 0 0 auto;
  width: 38px; height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  background: linear-gradient(135deg, rgba(201, 168, 76, 0.15), rgba(201, 168, 76, 0.05));
  border: 1px solid rgba(201, 168, 76, 0.25);
  color: var(--gold, #c9a84c);
}
.hd-help-menu__item-icon svg { width: 20px; height: 20px; }
.hd-help-menu__item-body {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.hd-help-menu__item-title {
  font-weight: 600;
  font-size: 0.92rem;
  letter-spacing: 0.02em;
  color: var(--text-primary, #f0eeeb);
}
.hd-help-menu__item-desc {
  font-size: 0.76rem;
  color: rgba(240, 238, 235, 0.68);
  line-height: 1.35;
  margin-top: 0.1rem;
}
.hd-help-menu__item-chevron {
  flex: 0 0 auto;
  color: rgba(201, 168, 76, 0.5);
  font-size: 1.15rem;
  line-height: 1;
  transition: transform 0.2s ease, color 0.2s ease;
}
.hd-help-menu__item:hover .hd-help-menu__item-chevron,
.hd-help-menu__item:focus-visible .hd-help-menu__item-chevron {
  transform: translateX(3px);
  color: var(--gold, #c9a84c);
}
.hd-help-menu__contact {
  display: block;
  text-align: center;
  margin: 0.6rem 0.35rem 0.1rem;
  padding: 0.55rem 0.65rem;
  font-size: 0.76rem;
  color: rgba(240, 238, 235, 0.6);
  text-decoration: none;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  transition: color 0.15s ease;
}
.hd-help-menu__contact:hover {
  color: var(--gold, #c9a84c);
  text-decoration: underline;
}

/* ── Modal plein écran ────────────────────────────────────────────── */
.hd-help-modal {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal, 9500);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
}
.hd-help-modal:not([hidden]) { display: flex; }
.hd-help-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(5, 12, 28, 0.7);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  animation: hdHelpFade 0.2s ease;
  cursor: pointer;
}
.hd-help-modal__dialog {
  position: relative;
  width: 100%;
  max-width: 960px;
  max-height: calc(100vh - 4rem);
  max-height: calc(100dvh - 4rem);
  background: var(--bg-primary, #050c1c);
  border: 1px solid rgba(201, 168, 76, 0.2);
  border-radius: 16px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 32px 80px -20px rgba(0, 0, 0, 0.6);
  animation: hdHelpDialogIn 0.28s cubic-bezier(0.23, 1, 0.32, 1);
}
@keyframes hdHelpFade { from { opacity: 0; } to { opacity: 1; } }
@keyframes hdHelpDialogIn {
  from { opacity: 0; transform: translateY(14px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.hd-help-modal__header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.9rem 1rem;
  border-bottom: 1px solid rgba(201, 168, 76, 0.15);
  background: linear-gradient(180deg, rgba(16, 30, 60, 0.6), transparent);
}
.hd-help-modal__back,
.hd-help-modal__close {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.5rem 0.7rem;
  min-width: 44px; min-height: 44px;
  background: transparent;
  color: var(--text-secondary, #9896a4);
  border: 1px solid transparent;
  border-radius: 10px;
  cursor: pointer;
  font: inherit;
  font-size: 0.8rem;
  transition: color 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}
.hd-help-modal__back:hover,
.hd-help-modal__back:focus-visible,
.hd-help-modal__close:hover,
.hd-help-modal__close:focus-visible {
  color: var(--gold, #c9a84c);
  background: rgba(201, 168, 76, 0.08);
  border-color: rgba(201, 168, 76, 0.25);
  outline: none;
}
.hd-help-modal__back svg,
.hd-help-modal__close svg { width: 20px; height: 20px; }
.hd-help-modal__back-label {
  font-weight: 500;
  letter-spacing: 0.02em;
}
.hd-help-modal__title {
  flex: 1 1 auto;
  margin: 0;
  font-family: var(--font-heading, inherit);
  font-size: 1rem;
  font-weight: 400;
  letter-spacing: 0.06em;
  color: var(--gold, #c9a84c);
  text-align: center;
}
.hd-help-modal__body {
  flex: 1 1 auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: 0;
  background: var(--bg-primary, #050c1c);
}
.hd-help-modal__body:focus-visible { outline: none; }

/* Loader */
.hd-help-modal__loader {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  padding: 4rem 2rem;
  color: rgba(240, 238, 235, 0.5);
  font-size: 0.85rem;
}
.hd-help-modal__spinner {
  width: 18px; height: 18px;
  border: 2px solid rgba(201, 168, 76, 0.2);
  border-top-color: var(--gold, #c9a84c);
  border-radius: 50%;
  animation: hdHelpSpin 0.9s linear infinite;
}
@keyframes hdHelpSpin { to { transform: rotate(360deg); } }

/* Quand le contenu embarqué est injecté, on neutralise les marges
   internes pour s'intégrer au modal sans double padding. */
.hd-help-modal__body .tuto-wrapper,
.hd-help-modal__body .faq-wrapper {
  margin: 0;
  padding: 1rem 1.25rem 2rem;
  max-width: 100%;
}
.hd-help-modal__body .tuto-header {
  display: none; /* titre déjà dans le header modal */
}
.hd-help-modal__body .tuto-tabs {
  position: sticky;
  top: 0;
  z-index: 2;
  background: linear-gradient(180deg, var(--bg-primary, #050c1c) 90%, transparent);
  padding: 0.75rem 0 0.6rem;
  margin-bottom: 1rem;
}

/* ── Mobile : modal plein écran + bouton plus accessible ──────────── */
@media (max-width: 640px) {
  .hd-help-launcher {
    width: 48px; height: 48px;
    right: max(0.75rem, env(safe-area-inset-right, 0px));
    bottom: max(0.75rem, env(safe-area-inset-bottom, 0px));
  }
  .hd-help-launcher:hover,
  .hd-help-launcher:focus-visible { width: 48px; }
  .hd-help-launcher__label { display: none; }
  .hd-help-menu {
    right: 0.75rem;
    bottom: calc(env(safe-area-inset-bottom, 0px) + 64px);
    width: calc(100vw - 1.5rem);
  }
  .hd-help-modal { padding: 0; align-items: stretch; }
  .hd-help-modal__dialog {
    max-width: 100%;
    max-height: 100vh;
    max-height: 100dvh;
    height: 100%;
    border-radius: 0;
    border: none;
    padding-top: env(safe-area-inset-top, 0px);
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
  .hd-help-modal__back-label { display: none; }
}

/* ── Light mode ───────────────────────────────────────────────────── */
body.light-mode .hd-help-launcher {
  background: linear-gradient(135deg, #ffffff, #faf9f5);
  color: #8b6914;
  border-color: rgba(139, 105, 20, 0.35);
  box-shadow:
    0 6px 18px -4px rgba(0, 0, 0, 0.12),
    0 0 0 1px rgba(139, 105, 20, 0.08);
}
body.light-mode .hd-help-launcher:hover,
body.light-mode .hd-help-launcher:focus-visible {
  border-color: rgba(139, 105, 20, 0.55);
  box-shadow:
    0 10px 24px -6px rgba(0, 0, 0, 0.15),
    0 0 16px rgba(139, 105, 20, 0.12);
}
body.light-mode .hd-help-menu {
  background: linear-gradient(180deg, #ffffff, #faf9f5);
  border-color: rgba(139, 105, 20, 0.2);
  box-shadow: 0 18px 46px -14px rgba(0, 0, 0, 0.18);
}
body.light-mode .hd-help-menu__arrow {
  border-right-color: rgba(139, 105, 20, 0.2);
  border-bottom-color: rgba(139, 105, 20, 0.2);
}
body.light-mode .hd-help-menu__item-icon {
  background: linear-gradient(135deg, rgba(139, 105, 20, 0.12), rgba(139, 105, 20, 0.03));
  border-color: rgba(139, 105, 20, 0.2);
  color: #8b6914;
}
body.light-mode .hd-help-menu__item:hover,
body.light-mode .hd-help-menu__item:focus-visible {
  background: rgba(139, 105, 20, 0.06);
  border-color: rgba(139, 105, 20, 0.18);
}
body.light-mode .hd-help-menu__item-title { color: #1a1a2e; }
body.light-mode .hd-help-menu__item-desc { color: #5a5666; }
body.light-mode .hd-help-menu__eyebrow { color: #7a7690; }
body.light-mode .hd-help-menu__contact {
  color: #7a7690;
  border-top-color: rgba(0, 0, 0, 0.06);
}
body.light-mode .hd-help-modal__dialog {
  background: #fdfaf2;
  border-color: rgba(139, 105, 20, 0.2);
}
body.light-mode .hd-help-modal__title { color: #8b6914; }
body.light-mode .hd-help-modal__body { background: #fdfaf2; }

/* Réduction animations si utilisateur le préfère */
@media (prefers-reduced-motion: reduce) {
  .hd-help-launcher,
  .hd-help-launcher__halo,
  .hd-help-menu,
  .hd-help-modal__backdrop,
  .hd-help-modal__dialog,
  .hd-help-menu__item-chevron {
    animation: none !important;
    transition: none !important;
  }
}
