/* =============================================================================
   Tigre Bois — css/filtres.css
   Habillage de la barre de filtres à deux visages rendue par js/filtres.js.
   Chargée par les deux pages qui filtrent : « Les tournois » et « L'effectif ».

   Grand écran : contrôles segmentés, tout visible d'un coup d'œil.
   Téléphone   : une ligne de pastilles qui n'affichent que le choix courant,
                 et une feuille ancrée en bas pour choisir au pouce.

   Le basculement est purement CSS : les deux variantes sont dans le DOM, celle
   qui ne sert pas est en display:none — donc absente aussi de l'arbre
   d'accessibilité, sans double annonce du même groupe radio.

   Aucune couleur en dur : uniquement les variables de css/tokens.css.
   ============================================================================= */

.tb-fbarre { min-width: 0; }


/* ─────────────────────────────────────────────────────────────────────────────
   1. VARIANTE TÉLÉPHONE — pastilles compactes
   ───────────────────────────────────────────────────────────────────────────── */

.tb-fbarre__compact {
  display: flex;
  align-items: center;
  gap: var(--tb-e3);
  min-width: 0;
  /* Un troisième critère (page Joueurs) déborde plutôt que de créer une
     deuxième ligne : la barre garde sa hauteur quoi qu'il arrive. */
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
  padding-block: 2px;
}
.tb-fbarre__compact::-webkit-scrollbar { display: none; }

.tb-fchip {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: var(--tb-e2);
  min-height: 44px;
  max-width: 62vw;
  padding: 0 var(--tb-e3) 0 var(--tb-e4);
  border: 1px solid var(--tb-ligne-forte);
  border-radius: var(--tb-rond);
  background: var(--tb-blanc);
  color: var(--tb-encre);
  font-family: var(--tb-font-texte);
  font-size: var(--tb-t-petit);
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  transition:
    background-color var(--tb-d0) var(--tb-ease),
    border-color var(--tb-d0) var(--tb-ease),
    color var(--tb-d0) var(--tb-ease);
}

.tb-fchip__valeur {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tb-fchip__chevron {
  flex: 0 0 auto;
  width: 16px;
  height: 16px;
  color: var(--tb-encre-45);
  transition: transform var(--tb-d1) var(--tb-ease);
}

.tb-fchip:hover { border-color: var(--tb-vert-clair); color: var(--tb-vert); }
.tb-fchip:hover .tb-fchip__chevron { color: var(--tb-vert); }

.tb-fchip[aria-expanded='true'] {
  background: var(--tb-vert);
  border-color: var(--tb-vert);
  color: var(--tb-creme);
}
.tb-fchip[aria-expanded='true'] .tb-fchip__chevron {
  color: var(--tb-creme);
  transform: rotate(180deg);
}


/* ─────────────────────────────────────────────────────────────────────────────
   2. VARIANTE GRAND ÉCRAN — contrôle segmenté
   ───────────────────────────────────────────────────────────────────────────── */

.tb-fbarre__large { display: none; }

.tb-segments {
  display: flex;
  align-items: center;
  gap: var(--tb-e4);
  min-width: 0;
}

.tb-segments__libelle {
  flex: 0 0 auto;
  font-size: var(--tb-t-micro);
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--tb-encre-45);
}

.tb-segments__piste {
  position: relative;
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 4px;
  max-width: 100%;
  border-radius: var(--tb-rond);
  border: 1px solid var(--tb-ligne);
  background: color-mix(in srgb, var(--tb-ivoire-alt) 80%, var(--tb-blanc));
  box-shadow: inset 0 1px 2px rgba(var(--tb-encre-rvb) / .05);
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
}
.tb-segments__piste::-webkit-scrollbar { display: none; }

.tb-segments__option {
  flex: 0 0 auto;
  min-height: 44px;
  padding: 0 var(--tb-e4);
  border: 0;
  border-radius: var(--tb-rond);
  background: transparent;
  color: var(--tb-encre-70);
  font-family: var(--tb-font-texte);
  font-size: var(--tb-t-petit);
  font-weight: 600;
  letter-spacing: .01em;
  white-space: nowrap;
  cursor: pointer;
  transition:
    background-color var(--tb-d1) var(--tb-ease),
    color var(--tb-d1) var(--tb-ease);
}

.tb-segments__option:hover { color: var(--tb-vert); }

.tb-segments__option[data-actif] {
  background: var(--tb-vert);
  color: var(--tb-creme);
}
.tb-segments__option[data-actif]:hover { color: var(--tb-creme); }

/* Au-dessus de 860px, les pistes tiennent sur une seule ligne : on repasse au
   contrôle segmenté, plus rapide quand la place ne manque pas. */
@media (min-width: 860px) {
  .tb-fbarre__compact { display: none; }
  .tb-fbarre__large {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--tb-e3) var(--tb-e7);
  }

  /* À deux critères (Tournois), libellé et piste tiennent côte à côte et la
     barre reste sur une ligne basse. À trois (Joueurs), la même disposition
     réclamerait 1241 px pour 1104 disponibles et passerait à deux lignes :
     on empile alors le libellé au-dessus de sa piste, ce qui fait rentrer
     l'ensemble sur une seule ligne, plus courte de moitié. */
  .tb-fbarre__large:has(.tb-segments:nth-child(3)) .tb-segments {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--tb-e2);
  }
}

/* Navigateur sans <dialog> modale : les pastilles ne sont jamais rendues et le
   segmenté prend le relais à toutes les tailles. */
.tb-fbarre[data-sans-feuille] .tb-fbarre__large {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--tb-e4) var(--tb-e7);
}

.tb-fbarre :focus-visible {
  outline: var(--tb-focus-trait) solid var(--tb-focus-couleur);
  outline-offset: var(--tb-focus-ecart);
  border-radius: var(--tb-rond);
}


/* ─────────────────────────────────────────────────────────────────────────────
   3. LA FEUILLE ANCRÉE EN BAS
   ───────────────────────────────────────────────────────────────────────────── */

.tb-feuille {
  position: fixed;
  inset: auto 0 0 0;
  width: 100%;
  max-width: 34rem;
  max-height: min(78vh, 34rem);
  margin: 0 auto;
  padding: var(--tb-e4) var(--tb-e5)
           max(var(--tb-e6), env(safe-area-inset-bottom));
  border: 0;
  border-radius: var(--tb-r4) var(--tb-r4) 0 0;
  background: var(--tb-blanc);
  color: var(--tb-encre);
  box-shadow: var(--tb-ombre3);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.tb-feuille::backdrop { background: rgba(var(--tb-encre-rvb) / .48); }

.tb-feuille__poignee {
  width: 40px;
  height: 4px;
  margin: 0 auto var(--tb-e4);
  border-radius: var(--tb-rond);
  background: var(--tb-ligne-forte);
}

.tb-feuille__titre {
  margin: 0 0 var(--tb-e4);
  font-family: var(--tb-font-texte);
  font-size: var(--tb-t-micro);
  font-weight: 600;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--tb-encre-45);
}

.tb-feuille__liste {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.tb-feuille__option {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 20px;
  align-items: center;
  gap: 2px var(--tb-e4);
  width: 100%;
  min-height: 52px;
  padding: var(--tb-e3) var(--tb-e4);
  border: 0;
  border-radius: var(--tb-r2);
  background: transparent;
  color: var(--tb-encre);
  font-family: var(--tb-font-texte);
  font-size: var(--tb-t-corps);
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  transition: background-color var(--tb-d0) var(--tb-ease);
}

.tb-feuille__option:hover { background: var(--tb-ivoire); }

.tb-feuille__option[data-actif] {
  background: var(--tb-vert-pale);
  color: var(--tb-vert);
}

.tb-feuille__texte { min-width: 0; }

.tb-feuille__aide {
  grid-column: 1;
  font-size: var(--tb-t-petit);
  font-weight: 400;
  line-height: 1.35;
  color: var(--tb-encre-70);
}

.tb-feuille__coche {
  grid-column: 2;
  grid-row: 1 / -1;
  width: 20px;
  height: 20px;
  color: var(--tb-vert);
  opacity: 0;
}
.tb-feuille__option[data-actif] .tb-feuille__coche { opacity: 1; }

.tb-feuille :focus-visible {
  outline: var(--tb-focus-trait) solid var(--tb-focus-couleur);
  outline-offset: -2px;
  border-radius: var(--tb-r2);
}

/* Montée depuis le bas. transition-behavior:allow-discrete permet d'animer
   l'apparition d'un élément qui passe de display:none à display:block ; les
   navigateurs qui l'ignorent affichent la feuille d'un coup, sans casse. */
@media (prefers-reduced-motion: no-preference) {
  .tb-feuille {
    transform: translateY(0);
    opacity: 1;
    transition:
      transform var(--tb-d2) var(--tb-ease-sort),
      opacity var(--tb-d1) var(--tb-ease),
      overlay var(--tb-d2) allow-discrete,
      display var(--tb-d2) allow-discrete;
  }
  .tb-feuille:not([open]) { transform: translateY(100%); opacity: 0; }

  @starting-style {
    .tb-feuille[open] { transform: translateY(100%); opacity: 0; }
  }

  .tb-feuille::backdrop {
    opacity: 1;
    transition:
      opacity var(--tb-d2) var(--tb-ease),
      overlay var(--tb-d2) allow-discrete,
      display var(--tb-d2) allow-discrete;
  }
  .tb-feuille:not([open])::backdrop { opacity: 0; }

  @starting-style {
    .tb-feuille[open]::backdrop { opacity: 0; }
  }
}

@media print { .tb-feuille { display: none !important; } }
