/****** Filtres catégories ******/

/* Structure générale */

.bloc-filtres-categories {
  display: block;
  max-width: 900px;
  margin: 0 auto;
  border-radius: 20px;
  background: var(--bleu-fonce);
  color: var(--blanc);
  font-family: 'Poppins', sans-serif;
}

.bloc-filtres-categories .filtre-ligne {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 45px;
}

.bloc-filtres-categories .filtre-ligne.langues {
  margin-top: 0;
  margin-bottom: 0;
}

.bloc-filtres-categories .filtre-ligne:not(.langues) {
  margin-top: 20px;
}

.bloc-filtres-categories .filtre-ligne:last-child {
  margin-bottom: 20px;
}

/* Titres et labels */

.bloc-filtres-categories .titre-ligne {
  width: 200px;
  text-align: right;
}

.bloc-filtres-categories .label-filtre {
  margin: 0;
  color: var(--blanc);
  font-size: 18px;
  line-height: 22px;
}

.bloc-filtres-categories .contenu-ligne {
  flex: 1;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
}

.bloc-filtres-categories .contenu-ligne.selects {
  gap: 20px;
}

/* Langues */

.bloc-filtres-categories .langue-switch {
  display: flex;
  align-items: center;
  gap: 20px;
}

.bloc-filtres-categories .langue-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  width: 200px;
  padding: 10px 40px 10px 20px;
  border: none;
  border-radius: 40px;
  background: var(--blanc);
  color: var(--bleu-fonce);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  overflow: hidden;
  transition: color 0.3s ease;
}

.bloc-filtres-categories .langue-btn .texte {
  position: relative;
  z-index: 2;
  white-space: nowrap;
  transition: transform 0.45s ease, color 0.3s ease;
}

.bloc-filtres-categories .langue-btn .toggle {
  position: absolute;
  top: 50%;
  right: 10px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--bleu-fonce);
  transform: translate(0, -50%);
  box-shadow: 0 0 6px rgba(0, 0, 0, 0.2);
  transition: transform 0.5s cubic-bezier(0.25, 1, 0.5, 1), background 0.3s ease;
}

.bloc-filtres-categories .langue-btn.active .toggle {
  transform: translate(-155px, -50%);
  background: var(--jaune-principal);
}

.bloc-filtres-categories .langue-btn.active .texte {
  transform: translateX(25px);
  color: var(--jaune-principal);
}

/* Lien toggle filtres */

.bloc-filtres-categories .toggle-filtres {
  margin-left: 30px;
  color: var(--blanc);
  text-decoration: underline;
  transition: color 0.3s ease, opacity 0.2s;
}

.bloc-filtres-categories .toggle-filtres:hover {
  opacity: 0.8;
}

/* Bloc repliable */

.bloc-filtres-categories #filtres-supplementaires {
  height: 0;
  overflow-y: hidden;
  overflow-x: visible;
  transition: height 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.bloc-filtres-categories #filtres-supplementaires.open {
  height: 170px;
}

/* Thèmes */

.bloc-filtres-categories .themes-liste {
  display: flex;
  flex-wrap: nowrap;
  gap: 20px;
  min-width: 100%;
  padding-bottom: 8px;
}

.bloc-filtres-categories .theme {
  display: inline-block;
  width: auto;
  flex: 0 0 auto;
  padding: 8px 15px;
  border: 1px solid var(--blanc);
  border-radius: 16px;
  background: transparent;
  color: var(--blanc);
  text-transform: uppercase;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s ease;
}

.bloc-filtres-categories .theme.active {
  border-color: var(--jaune-principal);
  color: var(--jaune-principal);
}

/* Scroll horizontal des thèmes */

.bloc-filtres-categories .filtre-ligne.themes .contenu-ligne {
  overflow-x: visible;
  overflow-y: hidden;
  scrollbar-width: thin;
  scrollbar-color: var(--jaune-principal) transparent;
}

.bloc-filtres-categories .filtre-ligne.themes .contenu-ligne::-webkit-scrollbar {
  height: 6px;
}

.bloc-filtres-categories .filtre-ligne.themes .contenu-ligne::-webkit-scrollbar-thumb {
  background: var(--jaune-principal);
  border-radius: 4px;
}

.bloc-filtres-categories .filtre-ligne.themes .contenu-ligne::-webkit-scrollbar-track {
  background: transparent;
}

/* Sélecteurs personnalisés */

.bloc-filtres-categories .custom-select {
  position: relative;
  width: 130px;
  user-select: none;
  font-size: 14px;
  z-index: 2;
}

.bloc-filtres-categories .custom-select .selected {
  position: relative;
  display: flex;
  align-items: center;
  height: 35px;
  line-height: 30px;
  padding-left: 20px;
  border-radius: 16px;
  background: var(--blanc);
  color: var(--bleu-fonce);
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  transition: 0.3s;
  z-index: 3;
}

.bloc-filtres-categories .custom-select .selected::after {
  content: "";
  position: absolute;
  top: 50%;
  right: 10px;
  width: 6px;
  height: 6px;
  border-left: 2px solid var(--bleu-fonce);
  border-bottom: 2px solid var(--bleu-fonce);
  transform: translateY(-50%) rotate(-45deg);
  transition: transform 0.2s ease;
}

.bloc-filtres-categories .custom-select.active .selected {
  border-radius: 16px 16px 0 0;
}

.bloc-filtres-categories .custom-select.active .selected::after {
  transform: translateY(-50%) rotate(135deg);
}

.bloc-filtres-categories .custom-select .options {
  display: none;
  position: fixed;
  background: var(--blanc);
  border-radius: 0 0 16px 16px;
  list-style: none;
  padding: 6px 0;
  margin: 0;
  width: 130px;
  max-height: 150px;
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 1000;
  box-shadow: 0 4px 8px rgba(0,0,0,0.15);
  scrollbar-width: thin;
  scrollbar-color: var(--jaune-principal) transparent;
}

.bloc-filtres-categories .custom-select.active .options {
  display: block;
  animation: dropdownFade 0.25s ease forwards;
}

.bloc-filtres-categories .custom-select .options li {
  padding: 6px 10px;
  color: var(--bleu-fonce);
  cursor: pointer;
  transition: background 0.2s ease;
}

.bloc-filtres-categories .custom-select .options li:hover {
  background: var(--jaune-principal);
}

.bloc-filtres-categories .custom-select .options li[data-value=""] {
  display: none;
}

@keyframes dropdownFade {
  from {
    opacity: 0;
    transform: translateY(-5px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Formats */

.bloc-filtres-categories .formats-liste {
  display: flex;
  gap: 20px;
}

.bloc-filtres-categories .format-item {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--blanc);
  font-weight: 500;
}

/* Radios personnalisés */

.bloc-filtres-categories .format-item input[type="radio"] {
  appearance: none;
  -webkit-appearance: none;
  display: inline-block;
  width: 16px;
  height: 16px;
  padding: 0px;
  border: 1px solid var(--blanc);
  border-radius: 50%;
  background: transparent;
  position: relative;
  cursor: pointer;
  transition: border-color 0.2s ease-in-out, background 0.2s ease-in-out;
}

.bloc-filtres-categories .format-item input[type="radio"]::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--jaune-principal);
  transform: translate(-50%, -50%) scale(0);
  transition: transform 0.25s ease-in-out;
}

.bloc-filtres-categories .format-item.active input[type="radio"]::after {
  transform: translate(-50%, -50%) scale(1);
}

/* Boutons toggle PC & mobile */

.bloc-filtres-categories .toggle-filtres-mobile {
  display: none;
}

.bloc-filtres-categories .toggle-filtres-mobile a {
  color: var(--blanc);
  text-decoration: underline;
  transition: color 0.3s ease;
}

.toggle-filtres.desktop-only.active,
.toggle-filtres.mobile-only.active {
  color: var(--jaune-principal);
}

.desktop-only {
  display: block;
}

.mobile-only {
  display: none !important;
}

/* SPÉCIAL : Cache la section "first post" dès qu'un filtre est actif */

.is-filtering .categorie-premiere-section {
  display: none !important;
}

@media (max-width: 1000px) {

  /* Filtres catégories */

  .desktop-only {
    display: none !important;
  }

  .mobile-only {
    display: block !important;
  }

  .bloc-filtres-categories .entete-langues {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
  }

  .bloc-filtres-categories .entete-langues .label-filtre {
    font-size: 18px;
    line-height: 22px;
  }

  .bloc-filtres-categories .toggle-filtres-mobile {
    display: flex;
    justify-content: center;
    width: 100%;
  }

  .bloc-filtres-categories .toggle-filtres.desktop-only {
    display: none;
  }

  .bloc-filtres-categories .toggle-filtres.mobile-only {
    display: flex;
    justify-content: flex-end;
    margin: 0px;
  }

  .bloc-filtres-categories .entete-langues .titre-ligne {
    width: 200px;
    text-align: center;
  }

  .bloc-filtres-categories .titre-ligne {
    width: 100%;
    text-align: left;
  }

  .bloc-filtres-categories .filtre-ligne {
    flex-direction: column;
    align-items: flex-start;
    gap: 20px;
  }

  .bloc-filtres-categories .contenu-ligne {
    width: 100%;
    justify-content: center;
  }

  .bloc-filtres-categories .label-filtre {
    font-size: 16px;
    line-height: 18px;
  }

  .bloc-filtres-categories .langue-switch {
    flex-direction: column;
  }

  .bloc-filtres-categories .themes-liste {
    padding-bottom: 15px;
  }

  .bloc-filtres-categories .theme {
    padding: 5px 8px;
    font-size: 12px;
  }

  .bloc-filtres-categories #filtres-supplementaires.open {
    height: 270px;
  }

  /* 2 colonnes -> Année et mois (en mobile) */

  .bloc-filtres-categories .filtre-ligne.date-format-mobile .contenu-ligne.selects-mobile {
    display: grid;
    grid-template-columns: 1fr 1fr !important;
    gap: 15px 20px;
    align-items: start;
  }

  .bloc-filtres-categories .filtre-ligne.date-format-mobile .bloc-select {
    display: flex;
    flex-direction: column;
    width: 100%;
  }

  .bloc-filtres-categories .filtre-ligne.date-format-mobile .label-filtre {
    margin-bottom: 6px;
  }

  .bloc-filtres-categories .filtre-ligne.date-format-mobile .custom-select {
    width: 100%;
  }

  .bloc-filtres-categories .toggle-filtres-mobile {
    display: flex;
    justify-content: center;
    width: 100%;
    margin-top: 20px;
  }
}