/* =====================================================================
 * help.css  —  DesignCV Module 8 (Système d'aide contextuelle)
 * ---------------------------------------------------------------------
 * OVERLAY : ne modifie pas style.css. Réutilise les tokens Phase 1.
 * ===================================================================== */

/* =====================================================================
 * 1. Icônes ⓘ dans les titres de section
 * ===================================================================== */

.help-info-btn {
  appearance: none;
  -webkit-appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  margin-left: 8px;
  padding: 0;
  border: 1px solid color-mix(in srgb, var(--primary) 35%, var(--border));
  background: color-mix(in srgb, var(--primary) 8%, var(--surface));
  color: var(--primary);
  border-radius: 50%;
  font-size: 0.72rem;
  font-weight: 700;
  cursor: pointer;
  vertical-align: middle;
  transition: var(--transition);
  flex-shrink: 0;
  line-height: 1;
}

.help-info-btn:hover {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  transform: scale(1.1);
}

.help-info-btn:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.help-info-btn[aria-expanded="true"] {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

/* =====================================================================
 * 2. Tooltip
 * ===================================================================== */

.help-tooltip {
  position: fixed;
  z-index: 9500;
  max-width: 320px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 12px 32px -8px rgba(15, 23, 42, 0.25),
              0 2px 8px rgba(15, 23, 42, 0.08);
  padding: 12px 14px;
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity 0.18s ease, transform 0.18s ease;
  pointer-events: auto;
  font-family: 'Inter', sans-serif;
}

.help-tooltip.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.help-tooltip-title {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid color-mix(in srgb, var(--border) 60%, transparent);
  display: flex;
  align-items: center;
  gap: 6px;
}

.help-tooltip-title::before {
  content: '💡';
  font-size: 0.9rem;
}

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

.help-tooltip-list li {
  font-size: 0.76rem;
  line-height: 1.5;
  color: var(--text-secondary);
  padding: 4px 0 4px 16px;
  position: relative;
}

.help-tooltip-list li::before {
  content: '›';
  position: absolute;
  left: 4px;
  top: 4px;
  color: var(--primary);
  font-weight: 700;
}

/* =====================================================================
 * 3. Panneau d'aide latéral (slide-in)
 * ===================================================================== */

.help-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(2px);
  z-index: 9600;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.help-overlay.is-visible {
  opacity: 1;
  pointer-events: auto;
}

.help-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 420px;
  max-width: 90vw;
  background: var(--surface);
  border-left: 1px solid var(--border);
  box-shadow: -12px 0 32px -8px rgba(15, 23, 42, 0.2);
  z-index: 9700;
  transform: translateX(100%);
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  font-family: 'Inter', sans-serif;
}

.help-panel.is-open {
  transform: translateX(0);
}

/* --- En-tête du panneau ------------------------------------------------ */
.help-panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 20px 24px 16px;
  border-bottom: 1px solid color-mix(in srgb, var(--border) 60%, transparent);
  background: linear-gradient(135deg,
    color-mix(in srgb, var(--primary) 6%, var(--surface)),
    var(--surface));
}

.help-panel-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text);
  margin: 0;
  font-family: 'Playfair Display', serif;
}

.help-panel-subtitle {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin: 2px 0 0;
}

.help-panel-close {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  width: 32px;
  height: 32px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 1rem;
  transition: var(--transition);
  flex-shrink: 0;
}

.help-panel-close:hover {
  background: color-mix(in srgb, var(--text-muted) 10%, transparent);
  color: var(--text);
  border-color: var(--text-muted);
}

.help-panel-close:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* --- Corps du panneau (scrollable) ------------------------------------ */
.help-panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px 32px;
}

.help-panel-body::-webkit-scrollbar {
  width: 6px;
}

.help-panel-body::-webkit-scrollbar-track {
  background: transparent;
}

.help-panel-body::-webkit-scrollbar-thumb {
  background: color-mix(in srgb, var(--text-muted) 30%, var(--border));
  border-radius: 3px;
}

.help-panel-body::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* --- Sections du panneau ----------------------------------------------- */
.help-section {
  margin-bottom: 24px;
}

.help-section:last-child {
  margin-bottom: 0;
}

.help-section-title {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 10px;
  letter-spacing: 0.01em;
}

.help-section-text {
  font-size: 0.82rem;
  line-height: 1.55;
  color: var(--text-secondary);
  margin: 0 0 12px;
}

.help-info-inline {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  background: color-mix(in srgb, var(--primary) 12%, transparent);
  color: var(--primary);
  border-radius: 50%;
  font-size: 0.65rem;
  font-weight: 700;
  vertical-align: middle;
  margin: 0 2px;
}

/* --- Raccourcis clavier ------------------------------------------------ */
.help-shortcuts {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.help-shortcut {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 10px;
  background: color-mix(in srgb, var(--bg) 60%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--border) 50%, transparent);
  border-radius: 8px;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.help-shortcut kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 64px;
  padding: 4px 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 5px;
  font-family: 'SF Mono', 'Monaco', 'Consolas', monospace;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text);
  box-shadow: 0 1px 0 color-mix(in srgb, var(--text-muted) 20%, transparent);
  white-space: nowrap;
  flex-shrink: 0;
}

/* --- FAQ accordéon ----------------------------------------------------- */
.help-faq {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.help-faq-item {
  border: 1px solid color-mix(in srgb, var(--border) 60%, transparent);
  border-radius: 8px;
  overflow: hidden;
  transition: var(--transition);
}

.help-faq-item[open] {
  border-color: color-mix(in srgb, var(--primary) 30%, var(--border));
}

.help-faq-q {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
  padding: 10px 12px;
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  transition: background 0.15s ease;
}

.help-faq-q::-webkit-details-marker {
  display: none;
}

.help-faq-q::after {
  content: '+';
  font-size: 1.1rem;
  font-weight: 400;
  color: var(--primary);
  transition: transform 0.2s ease;
  flex-shrink: 0;
}

.help-faq-item[open] .help-faq-q::after {
  transform: rotate(45deg);
}

.help-faq-q:hover {
  background: color-mix(in srgb, var(--primary) 5%, transparent);
}

.help-faq-a {
  font-size: 0.78rem;
  line-height: 1.55;
  color: var(--text-secondary);
  padding: 0 12px 12px;
}

/* --- Section "À propos" ------------------------------------------------ */
.help-section-about {
  padding-top: 16px;
  border-top: 1px solid color-mix(in srgb, var(--border) 50%, transparent);
}

.help-section-about .help-section-title {
  font-size: 0.78rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.help-section-about .help-section-text {
  font-size: 0.76rem;
  color: var(--text-muted);
}

/* =====================================================================
 * Responsive
 * ===================================================================== */

@media (max-width: 700px) {
  .help-panel {
    width: 100vw;
    max-width: 100vw;
  }

  .help-panel-header {
    padding: 16px 16px 12px;
  }

  .help-panel-body {
    padding: 16px 16px 24px;
  }

  .help-tooltip {
    max-width: calc(100vw - 24px);
  }

  .help-shortcut {
    font-size: 0.76rem;
  }

  .help-shortcut kbd {
    min-width: 56px;
    font-size: 0.68rem;
  }
}

/* =====================================================================
 * Accessibilité
 * ===================================================================== */

@media (prefers-reduced-motion: reduce) {
  .help-panel,
  .help-overlay,
  .help-tooltip,
  .help-info-btn,
  .help-faq-q::after {
    transition: none !important;
    animation: none !important;
  }
}

/* =====================================================================
 * Dark mode
 * ===================================================================== */

@media (prefers-color-scheme: dark) {
  .help-panel {
    background: #1E293B;
    border-left-color: #334155;
  }

  .help-panel-title {
    color: #F1F5F9;
  }

  .help-section-title {
    color: #F1F5F9;
  }

  .help-section-text {
    color: #CBD5E1;
  }

  .help-shortcut {
    background: #0F172A;
    border-color: #334155;
    color: #CBD5E1;
  }

  .help-shortcut kbd {
    background: #1E293B;
    border-color: #475569;
    color: #F1F5F9;
  }

  .help-tooltip {
    background: #1E293B;
    border-color: #334155;
  }

  .help-tooltip-list li {
    color: #CBD5E1;
  }

  .help-faq-item {
    border-color: #334155;
  }

  .help-faq-q {
    color: #F1F5F9;
  }

  .help-faq-a {
    color: #CBD5E1;
  }

  .help-panel-close {
    background: #0F172A;
    color: #CBD5E1;
    border-color: #334155;
  }
}
