/* ============================================================================
   NEWCAUSE_STYLE.CSS
   Suit exactement l'ordre des sections du fichier newcause.html.

   Sommaire :
     0. Variables globales (couleurs, thème clair/sombre) & réinitialisation
     1. Barre supérieure (topbar)
     2. Structure générale de la page (shell)
     3. Menu latéral (sidebar)
     4. Contenu principal — conteneur général + en-tête de page
     5. Étape 1 — description de la cause
     6. Étape 2 — résultats de recherche
     7. Séparateur entre l'étape 2 et l'étape 3
     8. Étape 3 — formulaire de création de cause
     9. États techniques communs (chargement)
     10. Version mobile / tablette (responsive)
   ============================================================================ */


/* ============================================================================
   0. VARIABLES GLOBALES & RÉINITIALISATION
   → Désormais défini une seule fois dans /assets/commun/commun_style.css (palette claire/sombre,
     base de la page, barre du haut) : ne pas le redéfinir ici.
   ============================================================================ */


h1, h2, h3 {
  font-family: 'Fraunces', Georgia, serif;
  color: var(--ink);
  margin: 0;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font-family: inherit;
  cursor: pointer;
}

textarea, input, select {
  font-family: inherit;
}


/* ============================================================================
   1. BARRE SUPÉRIEURE (TOPBAR)
   → Désormais défini une seule fois dans /assets/commun/commun_style.css (palette claire/sombre,
     base de la page, barre du haut) : ne pas le redéfinir ici.
   ============================================================================ */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
}


.btn {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink-soft);
  padding: 8px 16px;
  border-radius: 3px;
  font-size: calc(13.5px * var(--echelle-texte, 1));
  font-weight: 500;
  transition: border-color .15s ease, color .15s ease;
}
.btn:hover {
  border-color: var(--ink-soft);
  color: var(--ink);
}


/* ============================================================================
   2. STRUCTURE GÉNÉRALE DE LA PAGE (SHELL)
   ============================================================================ */
.shell {
  display: grid;
  grid-template-columns: 232px 1fr;
  max-width: 1180px;
  margin: 0 auto;
}


/* ============================================================================
   3. MENU LATÉRAL (SIDEBAR)
   ============================================================================ */
.sidebar {
  padding: 26px 20px 40px;
  border-right: 1px solid var(--line);
  min-height: calc(100vh - 68px);
}

.nav-group {
  margin-bottom: 26px;
}

.nav-label {
  font-size: calc(12px * var(--echelle-texte, 1));
  color: var(--muted);
  margin: 0 0 10px 10px;
  font-weight: 500;
}

.followed-causes {
  list-style: none;
  margin: 4px 0 0;
  padding: 0;
}
.followed-causes li {
  padding: 7px 10px 7px 20px;
  font-size: calc(13.5px * var(--echelle-texte, 1));
  color: var(--ink-soft);
  display: flex;
  justify-content: space-between;
  border-radius: 3px;
}
.followed-causes li:hover {
  background: var(--paper-raised);
  color: var(--ink);
}
.followed-causes li a {
  display: flex;
  justify-content: space-between;
  width: 100%;
  color: inherit;
}
.followed-causes .count {
  color: var(--muted);
  font-size: calc(12px * var(--echelle-texte, 1));
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 3px;
  color: var(--ink-soft);
  font-size: calc(14px * var(--echelle-texte, 1));
  font-weight: 500;
  border-left: 2px solid transparent;
}
.nav-link:hover {
  background: var(--paper-raised);
  color: var(--ink);
}
.nav-link.active {
  color: var(--ink);
  border-left: 2px solid var(--clay);
  background: var(--paper-raised);
}
.nav-link .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  opacity: .55;
  flex-shrink: 0;
}


/* ============================================================================
   4. CONTENU PRINCIPAL — CONTENEUR GÉNÉRAL + EN-TÊTE DE PAGE
   ============================================================================ */
.main {
  padding: 34px 30px 70px;
  min-width: 0;
}

.page-wrap {
  max-width: 720px;
  margin: 0 auto;
}

.page-eyebrow {
  font-size: calc(12.5px * var(--echelle-texte, 1));
  color: var(--muted);
  margin-bottom: 8px;
}

.page-title {
  font-size: calc(30px * var(--echelle-texte, 1));
  font-weight: 600;
  margin-bottom: 10px;
}

.page-lede {
  font-size: calc(14.5px * var(--echelle-texte, 1));
  color: var(--ink-soft);
  max-width: 58ch;
  margin-bottom: 30px;
}

.step {
  margin-bottom: 40px;
}

.step-label {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.step-num {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--ink);
  color: var(--paper);
  font-size: calc(11.5px * var(--echelle-texte, 1));
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.step-num.done {
  background: var(--leaf);
}

.step-title {
  font-size: calc(15px * var(--echelle-texte, 1));
  font-weight: 600;
}


/* ============================================================================
   5. ÉTAPE 1 — DESCRIPTION DE LA CAUSE
   Correspond à #step-description : zone de texte écoutée par
   initDescriptionCause() dans newcause_java.js.
   ============================================================================ */
.desc-box {
  border: 1px solid var(--line);
  background: var(--paper-raised);
  border-radius: 4px;
  padding: 4px;
}
.desc-box:focus-within {
  border-color: var(--leaf);
}

.desc-box textarea {
  width: 100%;
  min-height: 110px;
  border: none;
  background: transparent;
  outline: none;
  resize: vertical;
  padding: 12px 14px;
  font-size: calc(14.5px * var(--echelle-texte, 1));
  color: var(--ink);
  line-height: 1.55;
}
.desc-box textarea::placeholder {
  color: var(--muted);
}

.desc-box-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 10px 8px 14px;
  border-top: 1px solid var(--line);
}

.char-count {
  font-size: calc(12px * var(--echelle-texte, 1));
  color: var(--muted);
}

.search-btn {
  background: var(--ink);
  color: var(--paper);
  border: none;
  padding: 9px 18px;
  border-radius: 3px;
  font-size: calc(13.5px * var(--echelle-texte, 1));
  font-weight: 500;
}
.search-btn:hover:not(:disabled) {
  background: var(--leaf);
}
.search-btn:disabled {
  opacity: .4;
  cursor: not-allowed;
}


/* ============================================================================
   6. ÉTAPE 2 — RÉSULTATS DE RECHERCHE
   Correspond à #step-resultats : #resultats-note (nombre de résultats) et
   #resultats-liste (cartes des causes correspondantes).
   ============================================================================ */
.results-note {
  font-size: calc(13.5px * var(--echelle-texte, 1));
  color: var(--ink-soft);
  margin-bottom: 18px;
}
.results-note strong {
  color: var(--ink);
}

.match-card {
  display: flex;
  gap: 16px;
  border: 1px solid var(--line);
  background: var(--paper-raised);
  border-radius: 4px;
  padding: 16px 18px;
  margin-bottom: 12px;
  align-items: flex-start;
}

.match-score {
  flex-shrink: 0;
  width: 54px;
  text-align: center;
}
.match-score .pct {
  font-family: 'Fraunces', serif;
  font-size: calc(20px * var(--echelle-texte, 1));
  font-weight: 600;
  color: var(--leaf);
}
.match-score .lbl {
  font-size: calc(10.5px * var(--echelle-texte, 1));
  color: var(--muted);
}
.match-score.low .pct {
  color: var(--muted);
}

.match-body {
  flex: 1;
  min-width: 0;
}
.match-name {
  font-size: calc(15.5px * var(--echelle-texte, 1));
  font-weight: 600;
  margin-bottom: 4px;
}
.match-desc {
  font-size: calc(13px * var(--echelle-texte, 1));
  color: var(--ink-soft);
  margin-bottom: 8px;
  max-width: 54ch;
}
.match-suggest {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: calc(12.5px * var(--echelle-texte, 1));
  color: var(--clay);
  background: var(--clay-tint);
  padding: 4px 10px;
  border-radius: 20px;
  font-weight: 500;
}

.match-actions {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.join-btn {
  background: var(--leaf);
  color: #fff;
  border: 1px solid var(--leaf);
  padding: 8px 16px;
  border-radius: 3px;
  font-size: calc(13px * var(--echelle-texte, 1));
  font-weight: 500;
  white-space: nowrap;
}
.join-btn:hover {
  opacity: .9;
}
.view-link {
  background: none;
  border: none;
  font-size: calc(12px * var(--echelle-texte, 1));
  color: var(--ink-soft);
  text-align: center;
  font-family: inherit;
  cursor: pointer;
}
.view-link:hover {
  color: var(--ink);
  text-decoration: underline;
}


/* ============================================================================
   7. SÉPARATEUR ENTRE L'ÉTAPE 2 ET L'ÉTAPE 3
   ============================================================================ */
.divider {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 0 0 34px;
}
.divider .line {
  flex: 1;
  height: 1px;
  background: var(--line);
}
.divider span {
  font-size: calc(12.5px * var(--echelle-texte, 1));
  color: var(--muted);
  text-align: center;
}
.divider .line {
  min-width: 12px;
}


/* ============================================================================
   8. ÉTAPE 3 — FORMULAIRE DE CRÉATION DE CAUSE
   Correspond à #step-creation / #form-creation-cause.
   ============================================================================ */
.create-panel {
  border: 1px solid var(--line);
  background: var(--paper-raised);
  border-radius: 4px;
  padding: 22px 24px;
}

.field {
  margin-bottom: 16px;
}
.field label {
  display: block;
  font-size: calc(12.5px * var(--echelle-texte, 1));
  font-weight: 600;
  color: var(--ink-soft);
  margin-bottom: 6px;
}
.field input[type="text"],
.field select {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--paper);
  border-radius: 3px;
  padding: 9px 12px;
  font-size: calc(14px * var(--echelle-texte, 1));
  color: var(--ink);
  outline: none;
}
.field input[type="text"]:focus,
.field select:focus {
  border-color: var(--leaf);
}
.field-hint {
  font-size: calc(12px * var(--echelle-texte, 1));
  color: var(--muted);
  margin-top: 8px;
  line-height: 1.5;
}
.field-hint strong {
  color: var(--ink-soft);
}

.creation-feedback {
  font-size: calc(13px * var(--echelle-texte, 1));
  padding: 10px 14px;
  border-radius: 3px;
  margin: 4px 0 0;
}
.creation-feedback.succes {
  background: var(--leaf-tint);
  color: var(--leaf);
}
.creation-feedback.erreur {
  background: var(--clay-tint);
  color: var(--clay);
}

.create-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}
.cancel-btn {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--ink-soft);
  padding: 9px 18px;
  border-radius: 3px;
  font-size: calc(13.5px * var(--echelle-texte, 1));
  font-weight: 500;
}
.create-btn {
  background: var(--clay);
  color: #fff;
  border: 1px solid var(--clay);
  padding: 9px 20px;
  border-radius: 3px;
  font-size: calc(13.5px * var(--echelle-texte, 1));
  font-weight: 500;
}
.create-btn:hover {
  opacity: .9;
}


/* ============================================================================
   9. ÉTATS TECHNIQUES COMMUNS
   ============================================================================ */
.loading-placeholder {
  font-size: calc(13px * var(--echelle-texte, 1));
  color: var(--muted);
  padding: 12px 4px;
}


/* ============================================================================
   10. VERSION MOBILE / TABLETTE (RESPONSIVE)
   ============================================================================ */
@media (max-width: 900px) {
  .shell {
    grid-template-columns: 1fr;
  }
  .sidebar {
    display: none;
  }
}

@media (max-width: 560px) {
  .match-card {
    flex-direction: column;
  }
  .match-actions {
    flex-direction: row;
    width: 100%;
  }
  .join-btn {
    flex: 1;
  }
}

/* Variantes sans marge basse (remplacent d’anciens styles inline) */
.step-sans-marge,
.field-sans-marge {
  margin-bottom: 0;
}


/* =============================================================================
   LIMITE DE CRÉATION, AIDE À LA PRÉCISION ET CAUSES TRÈS PROCHES
   ========================================================================== */

.guide-precision {
  font-size: calc(13.5px * var(--echelle-texte, 1));
  color: var(--ink-soft);
  background: var(--paper-raised);
  border: 1px solid var(--line);
  border-left: 3px solid var(--leaf);
  border-radius: 3px;
  padding: 12px 16px;
  margin-bottom: 12px;
  line-height: 1.55;
}
.guide-precision .guide-intro {
  margin: 0 0 6px;
}
.guide-precision ul {
  margin: 0;
  padding-left: 20px;
}

.limite-creation {
  font-size: calc(13.5px * var(--echelle-texte, 1));
  background: var(--clay-tint);
  color: var(--clay);
  border-radius: 3px;
  padding: 10px 14px;
  margin-bottom: 12px;
}

.jauge-precision {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 10px;
}
.jauge-barre {
  flex: 0 0 140px;
  height: 6px;
  background: var(--line);
  border-radius: 3px;
  overflow: hidden;
}
.jauge-remplie {
  height: 100%;
  width: 0;
  background: var(--clay);
  transition: width 0.2s, background 0.2s;
}
.jauge-remplie.suffisante {
  background: var(--ink-soft);
}
.jauge-remplie.precise {
  background: var(--leaf);
}
.jauge-texte {
  font-size: calc(12.5px * var(--echelle-texte, 1));
  color: var(--muted);
}

.field textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--paper);
  border-radius: 3px;
  padding: 9px 12px;
  font-family: inherit;
  font-size: calc(14px * var(--echelle-texte, 1));
  color: var(--ink);
  line-height: 1.5;
  resize: vertical;
  outline: none;
}
.field textarea:focus {
  border-color: var(--leaf);
}

.doublon-panel {
  border: 1px solid var(--clay);
  background: var(--clay-tint);
  border-radius: 3px;
  padding: 14px 16px;
  margin: 14px 0;
}
.doublon-titre {
  margin: 0 0 4px;
  font-weight: 600;
  color: var(--clay);
}
.doublon-texte {
  margin: 0 0 10px;
  font-size: calc(13.5px * var(--echelle-texte, 1));
  color: var(--ink-soft);
}
.doublon-panel .match-card {
  background: var(--paper-raised);
}
.doublon-panel .field {
  margin-top: 12px;
}
.doublon-panel .create-btn {
  margin-top: 10px;
}

/* Textes très longs (nom de 100 caractères, mot sans espace, description maximale) : retour à la ligne forcé */
.match-name,
.match-desc,
.match-suggest,
.creation-feedback,
.doublon-texte,
.guide-precision,
.limite-creation,
.jauge-texte {
  overflow-wrap: anywhere;
}

@media (max-width: 560px) {
  .jauge-precision {
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
  }
  .jauge-barre {
    flex: 0 0 6px;
    width: 100%;
  }
  .desc-box-footer {
    flex-wrap: wrap;
    gap: 8px;
  }
  .desc-box-footer .search-btn {
    width: 100%;
  }
  .doublon-panel {
    padding: 12px;
  }
  .doublon-panel .create-btn,
  .create-footer .create-btn,
  .create-footer .cancel-btn {
    width: 100%;
  }
  .create-footer {
    flex-direction: column-reverse;
  }
}
