/* ============================================================================
   INDEX_STYLE.CSS
   Feuille de style unique de CausesConnect.
   Organisation du fichier : elle suit exactement l'ordre des sections du
   fichier index.html, pour s'y retrouver facilement d'un fichier à l'autre.

   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) — causes suivies + navigation
     4. Contenu principal — conteneur général
     5. Barre de recherche
     6. Nouveautés des causes suivies (feed)
     7. Causes tendances (grille de cartes)
     7b. Sondage du site (avis des utilisateurs)
     8. États techniques communs (chargement, etc.)
     9. Version mobile / tablette (responsive)
   ============================================================================ */


/* ============================================================================
   0. VARIABLES GLOBALES & RÉINITIALISATION
   Les couleurs sont centralisées ici en variables CSS pour pouvoir changer
   le thème du site en un seul endroit. Un jeu de variables clair et un jeu
   de variables sombre sont fournis (le sombre s'active automatiquement
   selon le thème du système, ou manuellement via [data-theme="dark"]).
   → 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.
   ============================================================================ */


/* -- Palette sombre : suit le thème du système -- */


/* -- Palette sombre : activation manuelle (ex. bouton de thème futur) -- */


/* -- Réinitialisation minimale -- */


h1, h2, h3 {
  font-family: 'Fraunces', Georgia, serif; /* police "affichage" pour les titres */
  color: var(--ink);
  margin: 0;
}

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

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


/* ============================================================================
   1. BARRE SUPÉRIEURE (TOPBAR)
   Correspond à <header class="topbar"> dans index.html.
   Titre du site à gauche, connexion + paramètres à droite.
   → 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: 10;
}


.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)
   Correspond à <div class="shell"> : place le menu latéral à gauche et le
   contenu principal à droite, sur deux colonnes.
   ============================================================================ */
.shell {
  display: grid;
  grid-template-columns: 232px 1fr;
  max-width: 1180px;
  margin: 0 auto;
}


/* ============================================================================
   3. MENU LATÉRAL (SIDEBAR)
   Correspond à <nav class="sidebar"> : liste des causes suivies (3.1)
   puis navigation secondaire (3.2).
   ============================================================================ */
.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;
}

/* -- 3.1 Liste des causes suivies (remplie dynamiquement en JS) -- */
.followed-causes {
  list-style: none;
  margin: 4px 0 0;
  padding: 0;
}

.followed-causes li {
  font-size: calc(13.5px * var(--echelle-texte, 1));
  color: var(--ink-soft);
  border-radius: 3px;
}
/* Lien couvrant toute la ligne : nom de la cause à gauche, nombre d'adhérents à droite */
.followed-causes .followed-link {
  padding: 7px 10px 7px 20px;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: inherit;
  text-decoration: none;
  border-radius: 3px;
}
.followed-causes li:hover {
  background: var(--paper-raised);
  color: var(--ink);
}

/* Nombre d'adhérents affiché à droite de chaque cause suivie
   (généré par la fonction formatNombreAdherents() en JS) */
.followed-causes .count {
  color: var(--muted);
  font-size: calc(12px * var(--echelle-texte, 1));
}

/* -- 3.2 Navigation secondaire (Nouvelle cause, Législation, etc.) -- */
.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
   Correspond à <main class="main">.
   ============================================================================ */
.main {
  padding: 26px 30px 60px;
  min-width: 0;
}

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 4px;
}
.section-head h2 {
  font-size: calc(22px * var(--echelle-texte, 1));
  font-weight: 500;
}

.section-sub {
  color: var(--muted);
  font-size: calc(13px * var(--echelle-texte, 1));
  margin: 4px 0 18px;
}

.see-all {
  font-size: calc(13px * var(--echelle-texte, 1));
  color: var(--leaf);
  font-weight: 500;
}
.see-all:hover {
  text-decoration: underline;
}


/* ============================================================================
   5. BARRE DE RECHERCHE
   Correspond à <div class="search-wrap"> tout en haut du contenu principal.
   La saisie est écoutée par initRecherche() dans index_java.js.
   ============================================================================ */
.search-wrap {
  margin-bottom: 34px;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  background: var(--paper-raised);
  border-radius: 4px;
  padding: 12px 16px;
}

.search-box input {
  border: none;
  background: transparent;
  outline: none;
  font-size: calc(14.5px * var(--echelle-texte, 1));
  color: var(--ink);
  width: 100%;
  font-family: inherit;
}
.search-box input::placeholder {
  color: var(--muted);
}


/* ============================================================================
   6. NOUVEAUTÉS DES CAUSES SUIVIES (FEED)
   Correspond à <section id="section-nouveautes"> / <div id="feed-nouveautes">.
   Chaque élément est généré par afficherNouveautes() en JS et affiche un
   compteur de réactions et un compteur de commentaires.
   ============================================================================ */
.feed {
  border-top: 1px solid var(--line);
  margin-bottom: 48px;
}

.feed-item {
  display: flex;
  gap: 16px;
  padding: 18px 4px;
  border-bottom: 1px solid var(--line);
}

/* Pastille colorée avec les initiales de la cause */
.feed-badge {
  width: 40px;
  height: 40px;
  border-radius: 4px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Fraunces', serif;
  font-weight: 600;
  font-size: calc(16px * var(--echelle-texte, 1));
}
.feed-badge.theme-leaf { background: var(--leaf-tint); color: var(--leaf); }
.feed-badge.theme-clay { background: var(--clay-tint); color: var(--clay); }

.feed-body {
  flex: 1;
  min-width: 0;
}

/* Ligne principale : nom de la cause en avant, puis l'heure en plus discret */
.feed-meta {
  font-size: calc(12.5px * var(--echelle-texte, 1));
  color: var(--muted);
}
.feed-meta .cause-tag {
  color: var(--leaf);
  font-weight: 600;
  font-size: calc(16px * var(--echelle-texte, 1));
  text-decoration: none;
}
.feed-meta .cause-tag:hover {
  text-decoration: underline;
}

/* Auteur du message : petit, juste avant le texte */
.feed-auteur {
  font-size: calc(12px * var(--echelle-texte, 1));
  color: var(--muted);
  margin-top: 2px;
}

.feed-excerpt {
  /* Le message est maintenant le seul texte de la nouveauté (plus de titre) */
  font-size: calc(14.5px * var(--echelle-texte, 1));
  color: var(--ink);
  max-width: 62ch;
  margin: 6px 0 0;
  white-space: pre-line;   /* respecte les retours à la ligne du message */
  overflow-wrap: anywhere;
}

/* Ligne des compteurs (réactions / commentaires) sous chaque nouveauté */
.feed-stats {
  display: flex;
  gap: 14px;
  margin-top: 8px;
  font-size: calc(12.5px * var(--echelle-texte, 1));
  color: var(--muted);
}


/* ============================================================================
   7. CAUSES TENDANCES (GRILLE DE CARTES)
   Correspond à <section id="section-tendances"> / <div id="tendances-grid">.
   Chaque carte est générée par afficherTendances() en JS.
   ============================================================================ */
.trend-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}

.trend-card {
  background: var(--paper-raised);
  border: 1px solid var(--line);
  border-left: 3px solid var(--clay);
  border-radius: 3px;
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.trend-card.theme-leaf {
  border-left-color: var(--leaf);
}

.trend-rank {
  font-family: 'Fraunces', serif;
  font-size: calc(13px * var(--echelle-texte, 1));
  color: var(--muted);
}

.trend-name {
  font-size: calc(16px * var(--echelle-texte, 1));
  font-weight: 600;
  color: inherit;
  text-decoration: none;
}
.trend-name:hover {
  text-decoration: underline;
}

.trend-desc {
  font-size: calc(13px * var(--echelle-texte, 1));
  color: var(--ink-soft);
  flex: 1;
}

/* Activité de la semaine (nouveaux membres, messages) : seulement quand il y en a */
.trend-activity {
  margin: 0;
  font-size: calc(12px * var(--echelle-texte, 1));
  color: var(--leaf);
  font-weight: 600;
}

/* Nombre d'adhérents + bouton "Suivre" en bas de chaque carte tendance */
.trend-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: calc(12.5px * var(--echelle-texte, 1));
  color: var(--muted);
  padding-top: 6px;
  border-top: 1px solid var(--line);
}

.follow-mini {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink-soft);
  padding: 5px 12px;
  border-radius: 3px;
  font-size: calc(12px * var(--echelle-texte, 1));
  font-weight: 500;
  text-decoration: none;   /* c'est un lien (<a>) qui a l'allure d'un bouton */
  cursor: pointer;
}
.follow-mini:hover {
  border-color: var(--leaf);
  color: var(--leaf);
}
/* Cause déjà suivie : pastille discrète, sans appel à l'action */
.follow-mini.is-followed {
  border-color: var(--leaf);
  color: var(--leaf);
}


/* ============================================================================
   7b. SONDAGE DU SITE (section 2.2 de index.html)
   Mêmes codes visuels que les sondages des causes (barres de résultat).
   ============================================================================ */
.sondage-site { margin-bottom: 34px; }
.sondage-site[hidden], .sondage-site [hidden] { display: none; }

.sondage-site .lien-bouton {
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  font-size: calc(13px * var(--echelle-texte, 1));
  color: var(--clay);
  text-decoration: underline;
  cursor: pointer;
}
.sondage-site .lien-bouton:hover { color: var(--ink); }
.sondage-site .lien-bouton:focus-visible { outline: 2px solid var(--clay); outline-offset: 2px; }

.sondage-site-liste { display: grid; gap: 14px; }

.poll-card {
  border: 1px solid var(--line);
  background: var(--paper-raised);
  border-radius: 4px;
  padding: 18px 20px;
}
.poll-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: calc(11px * var(--echelle-texte, 1));
  color: var(--leaf);
  font-weight: 600;
  background: var(--leaf-tint);
  padding: 3px 8px;
  border-radius: 20px;
  margin-bottom: 10px;
}
.poll-status.termine { color: var(--muted); background: var(--line); }
.poll-status .pulse { width: 6px; height: 6px; border-radius: 50%; background: var(--leaf); }

.poll-question {
  margin: 0 0 6px;
  font-size: calc(16px * var(--echelle-texte, 1));
  font-weight: 600;
  line-height: 1.4;
  overflow-wrap: anywhere;
}
.poll-precision {
  margin: 0 0 12px;
  color: var(--ink-soft);
  font-size: calc(13px * var(--echelle-texte, 1));
  overflow-wrap: anywhere;
}
.poll-question + .poll-option { margin-top: 12px; }

.poll-option { margin-bottom: 9px; }
.poll-option-row {
  display: flex;
  justify-content: space-between;
  font-size: calc(13px * var(--echelle-texte, 1));
  margin-bottom: 4px;
  color: var(--ink-soft);
}
.poll-option-btn {
  width: 100%;
  padding: 4px 6px;
  margin: 0 0 2px -6px;
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  font: inherit;
  font-size: calc(13px * var(--echelle-texte, 1));
  color: var(--ink-soft);
  text-align: left;
  cursor: pointer;
}
.poll-option-btn:hover:not(:disabled) { border-color: var(--leaf); color: var(--ink); }
.poll-option-btn:focus-visible { outline: 2px solid var(--clay); outline-offset: 1px; }
.poll-option-btn[aria-pressed="true"] { color: var(--leaf); font-weight: 600; }
.poll-option-btn:disabled { opacity: .6; cursor: progress; }
.poll-option-texte { overflow-wrap: anywhere; padding-right: 8px; }
.poll-coche { font-weight: 700; }

.poll-bar-track { height: 7px; background: var(--line); border-radius: 4px; overflow: hidden; }
.poll-bar-fill { height: 100%; background: var(--leaf); border-radius: 4px; }
.poll-bar-fill.termine { background: var(--muted); }
.poll-bar-fill.choisie { background: var(--clay); }

.poll-footer {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  font-size: calc(11.5px * var(--echelle-texte, 1));
  color: var(--muted);
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}
.poll-aide { margin: 8px 0 0; color: var(--muted); font-size: calc(12px * var(--echelle-texte, 1)); }
.poll-message { margin: 8px 0 0; font-size: calc(12.5px * var(--echelle-texte, 1)); }
.poll-message.succes { color: var(--leaf); }
.poll-message.erreur { color: var(--clay); }

.poll-gestion { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-top: 8px; }
.poll-gestion .lien-bouton { font-size: calc(12px * var(--echelle-texte, 1)); color: var(--muted); }
.poll-gestion .lien-bouton:hover { color: var(--clay); }

/* Formulaire de création (administrateurs) */
.sondage-site-form {
  border: 1px solid var(--line);
  background: var(--paper-raised);
  border-radius: 4px;
  padding: 18px 20px;
  margin-bottom: 14px;
  display: grid;
  gap: 14px;
}
.sondage-site-form h3 { margin: 0; font-size: calc(16px * var(--echelle-texte, 1)); font-weight: 600; }
.sondage-site-form label,
.sondage-site-form legend { display: block; font-weight: 600; font-size: calc(13px * var(--echelle-texte, 1)); margin-bottom: 4px; padding: 0; }
.sondage-site-form input[type="text"],
.sondage-site-form textarea,
.sondage-site-form select {
  width: 100%;
  box-sizing: border-box;
  font: inherit;
  font-size: calc(14px * var(--echelle-texte, 1));
  min-height: 40px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--paper);
  color: var(--ink);
}
.sondage-site-form textarea { min-height: 64px; resize: vertical; }
.sondage-site-form select { width: auto; max-width: 100%; }
.sondage-site-form input:focus-visible,
.sondage-site-form textarea:focus-visible,
.sondage-site-form select:focus-visible,
.sondage-site-form button:focus-visible { outline: 2px solid var(--clay); outline-offset: 1px; }
.sondage-site-form fieldset { border: 0; padding: 0; margin: 0; }
.sondage-site-options { list-style: none; margin: 0 0 8px; padding: 0; display: grid; gap: 8px; }
.sondage-site-option { display: flex; gap: 6px; align-items: center; }
.sondage-site-option input { flex: 1; }
.sondage-site-aide { margin: 0; color: var(--muted); font-size: calc(12px * var(--echelle-texte, 1)); }
.sondage-site-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.sondage-site-form .bouton {
  font: inherit;
  font-size: calc(14px * var(--echelle-texte, 1));
  min-height: 40px;
  padding: 8px 16px;
  border-radius: 4px;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink);
  cursor: pointer;
}
.sondage-site-form .bouton.principal { background: var(--leaf); border-color: var(--leaf); color: #fff; }
.sondage-site-form .bouton:disabled { opacity: .6; cursor: progress; }

/* ============================================================================
   8. ÉTATS TECHNIQUES COMMUNS
   Message affiché pendant que index_java.js attend la réponse du backend
   (index_fonction.php), avant que les fonctions d'affichage ne remplacent
   ce texte par le contenu réel.
   ============================================================================ */
.loading-placeholder {
  font-size: calc(13px * var(--echelle-texte, 1));
  color: var(--muted);
  padding: 12px 4px;
}


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

@media (max-width: 560px) {
  .trend-grid {
    grid-template-columns: 1fr;
  }
  
  .main {
    padding: 20px 16px 40px;
  }
}
