/**
 * Archive Isotope Filter v2 — CSS
 *
 * Conçu pour s'intégrer parfaitement avec le thème Codilight Lite.
 * Reprend la structure .block1.block1_grid > .row > article.col-md-6.col-sm-12
 *
 * Sections :
 *  1. Variables CSS (personnalisables)
 *  2. Barre de filtres
 *  3. Boutons de filtre (3 styles : pill / square / underline)
 *  4. Sous-filtres hiérarchiques
 *  5. Grille Isotope
 *  6. Animations d'entrée
 *  7. Load More
 *  8. Message "aucun résultat"
 *  9. Responsive
 */

/* ═══════════════════════════════════════════════════════════
   1. Variables CSS — personnalisez ici sans toucher au reste
═══════════════════════════════════════════════════════════ */
:root {
  --aif-primary:        #0073aa;
  --aif-primary-dark:   #005177;
  --aif-accent:         #f0f6fb;

  --aif-btn-bg:         #f4f4f4;
  --aif-btn-color:      #333;
  --aif-btn-border:     #ddd;
  --aif-btn-radius:     999px;      /* style pill */

  --aif-active-bg:      #0073aa;
  --aif-active-color:   #ffffff;

  --aif-card-gap:       16px;
  --aif-transition:     .28s ease;
  --aif-filter-mb:      28px;       /* espace sous la barre de filtres */
}

/* ═══════════════════════════════════════════════════════════
   2. Barre de filtres
═══════════════════════════════════════════════════════════ */
.aif-filter-wrapper {
  margin-bottom: var(--aif-filter-mb);
}

/* Rangée de boutons (principale ou secondaire) */
.aif-filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.aif-filter-primary {
  /* rangée principale */
}

.aif-filter-secondary {
  /* rangée sous-catégories — masquée par défaut (géré par JS + slideDown) */
  margin-top: 8px;
  padding: 10px 14px;
  background: var(--aif-accent);
  border-left: 3px solid var(--aif-primary);
  border-radius: 0 6px 6px 0;
  width: 100%;
}

/* ═══════════════════════════════════════════════════════════
   3. Boutons de filtre
═══════════════════════════════════════════════════════════ */
.aif-filter-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 7px 16px;
  font-size: .875rem;
  font-weight: 500;
  line-height: 1;
  color: var(--aif-btn-color);
  background: var(--aif-btn-bg);
  border: 1px solid var(--aif-btn-border);
  border-radius: var(--aif-btn-radius);
  cursor: pointer;
  transition:
    background var(--aif-transition),
    color var(--aif-transition),
    border-color var(--aif-transition),
    transform .15s ease;
  user-select: none;
  white-space: nowrap;
  outline: none;
}
.aif-filter-btn:hover {
  background: var(--aif-primary);
  color: #fff;
  border-color: var(--aif-primary);
  transform: translateY(-1px);
}
.aif-filter-btn:focus-visible {
  outline: 2px solid var(--aif-primary);
  outline-offset: 2px;
}
.aif-filter-btn.aif-active {
  background: var(--aif-active-bg);
  color: var(--aif-active-color);
  border-color: var(--aif-active-bg);
}

/* Count badge */
.aif-count {
  display: inline-block;
  font-size: .7rem;
  font-weight: 600;
  background: rgba(0,0,0,.08);
  border-radius: 999px;
  padding: 1px 6px;
  line-height: 1.5;
  min-width: 20px;
  text-align: center;
}
.aif-filter-btn.aif-active .aif-count {
  background: rgba(255,255,255,.25);
}

/* Chevron */
.aif-chevron {
  font-size: .7rem;
  transition: transform .2s ease;
}
.aif-filter-btn.aif-active .aif-chevron {
  transform: rotate(180deg);
}

/* ── Style : pill (défaut) ── */
/* var(--aif-btn-radius) = 999px, pas besoin d'override */

/* ── Style : square ── */
.aif-btn-style-square .aif-filter-btn {
  border-radius: 4px;
}

/* ── Style : underline (tab) ── */
.aif-btn-style-underline .aif-filter-wrapper {
  border-bottom: 2px solid #e5e5e5;
  padding-bottom: 0;
}
.aif-btn-style-underline .aif-filter-btn {
  background: transparent;
  border: none;
  border-bottom: 3px solid transparent;
  border-radius: 0;
  padding: 8px 10px;
  margin-bottom: -2px;
  color: #555;
}
.aif-btn-style-underline .aif-filter-btn:hover {
  background: transparent;
  color: var(--aif-primary);
  border-bottom-color: var(--aif-primary);
  transform: none;
}
.aif-btn-style-underline .aif-filter-btn.aif-active {
  background: transparent;
  color: var(--aif-primary);
  border-bottom-color: var(--aif-primary);
}
.aif-btn-style-underline .aif-filter-secondary {
  border-left: none;
  background: transparent;
  padding-left: 0;
}

/* ═══════════════════════════════════════════════════════════
   4. Sous-filtres (la rangée .aif-filter-secondary)
   Le display est contrôlé par jQuery slideDown/slideUp
═══════════════════════════════════════════════════════════ */
.aif-btn-child {
  font-size: .82rem;
  padding: 5px 12px;
}
.aif-btn-sub-all {
  font-size: .82rem;
  font-style: italic;
  opacity: .8;
}

/* ═══════════════════════════════════════════════════════════
   5. Grille Isotope
   On ne casse pas la structure .block1.block1_grid > .row du thème.
   On ajoute juste .aif-grid sur .row.
═══════════════════════════════════════════════════════════ */
.aif-grid {
  /* Isotope travaille en position absolute, pas besoin de flex/grid */
  position: relative;
}

/* Sizer pour Isotope — même largeur que les colonnes */
.aif-grid-sizer.col-md-6 {
  width: 50%;
  padding: 0;
  height: 0;
  overflow: hidden;
}

/* Clearfix pour le float Isotope */
.aif-grid::after {
  content: '';
  display: table;
  clear: both;
}

/* Les articles utilisent les classes du thème (col-md-6 col-sm-12).
   On leur ajoute juste le box-sizing et les paddings de gouttière. */
.aif-grid .archive-post {
  box-sizing: border-box;
  /* Le padding est déjà géré par Bootstrap/.row dans le thème */
}

/* ═══════════════════════════════════════════════════════════
   6. Animations d'entrée des articles
═══════════════════════════════════════════════════════════ */
.archive-post {
  opacity: 0;
  transform: translateY(16px);
  transition:
    opacity .4s ease,
    transform .4s ease;
}
.archive-post.aif-item-visible {
  opacity: 1;
  transform: translateY(0);
}

/* Délai en cascade pour les premiers articles */
.archive-post:nth-child(2)  { transition-delay: .04s; }
.archive-post:nth-child(3)  { transition-delay: .08s; }
.archive-post:nth-child(4)  { transition-delay: .12s; }
.archive-post:nth-child(5)  { transition-delay: .16s; }
.archive-post:nth-child(6)  { transition-delay: .20s; }
.archive-post:nth-child(7)  { transition-delay: .24s; }
.archive-post:nth-child(8)  { transition-delay: .28s; }
/* Reset pour les articles chargés après (Load More) */
.aif-item-visible { transition-delay: 0s !important; }

/* Articles masqués — complètement hors du flux */
.aif-above-fold {
  display: none !important;
}

.aif-hidden-item {
  display: none !important;
  visibility: hidden !important;
}

/* Isotope hide/show state */
.isotope-hidden {
  pointer-events: none;
}

/* ═══════════════════════════════════════════════════════════
   7. Load More
═══════════════════════════════════════════════════════════ */
.aif-loadmore-wrap {
  text-align: center;
  padding: 32px 0 16px;
  clear: both;
}

.aif-loadmore-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 32px;
  font-size: .95rem;
  font-weight: 600;
  color: #fff;
  background: var(--aif-primary);
  border: none;
  border-radius: 999px;
  cursor: pointer;
  transition:
    background var(--aif-transition),
    transform .15s ease,
    box-shadow var(--aif-transition);
  box-shadow: 0 4px 14px rgba(0,115,170,.2);
}
.aif-loadmore-btn:hover {
  background: var(--aif-primary-dark);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0,115,170,.3);
}
.aif-load-counter {
  font-size: .78rem;
  font-weight: 400;
  opacity: .75;
}

.aif-loadmore-status {
  margin-top: 12px;
  font-size: .85rem;
  color: #999;
  min-height: 1.3em;
}
.aif-loadmore-status.aif-no-more {
  font-style: italic;
  color: #bbb;
}

/* Infinite scroll sentinel */
.aif-infinite-sentinel {
  height: 1px;
  pointer-events: none;
}

/* ═══════════════════════════════════════════════════════════
   8. Aucun résultat
═══════════════════════════════════════════════════════════ */
#aif-no-results {
  text-align: center;
  padding: 40px 20px;
  color: #888;
  font-size: 1rem;
}

/* ═══════════════════════════════════════════════════════════
   9. Responsive
═══════════════════════════════════════════════════════════ */
@media (max-width: 767px) {
  /* Le thème passe déjà col-sm-12 = 100%, on s'aligne */
  .aif-grid-sizer.col-md-6 {
    width: 100%;
  }

  .aif-filter-row {
    gap: 6px;
  }
  .aif-filter-btn {
    font-size: .8rem;
    padding: 6px 12px;
  }
  .aif-filter-secondary {
    padding: 8px 10px;
  }

  .aif-loadmore-btn {
    padding: 10px 24px;
    font-size: .88rem;
  }
}

@media (max-width: 480px) {
  .aif-filter-wrapper {
    margin-bottom: 18px;
  }
  .aif-filter-row {
    gap: 5px;
  }
}
