/* ==========================================================================
   024 — Tab Bar Bounce
   Tab bar mobile 4 onglets : l'icône activée rebondit (squash & stretch),
   la pastille glisse vers l'onglet actif avec overshoot, l'onglet quitté se
   désature en douceur, badge de notification qui pop (et se résorbe quand
   son onglet est visité).
   Racine : .tab-bar-bounce — le JS ne gère que .is-active + la position de
   la pastille (custom properties --tab-bar-bounce-x / --tab-bar-bounce-w).
   ========================================================================== */

.tab-bar-bounce {
  --tbb-accent: var(--ml-accent, #7c8cff);

  position: relative;
  display: flex;
  width: min(300px, 100%);
  padding: 8px 6px;
  border-radius: 20px;
  background: var(--ml-surface, #151a24);
  border: 1px solid rgba(255, 255, 255, 0.07);
  box-shadow: 0 14px 30px -16px rgba(0, 0, 0, 0.6);
}

/* --- Pastille : glisse avec overshoot vers l'onglet actif ------------------ */

.tab-bar-bounce__indicator {
  position: absolute;
  top: 6px;
  bottom: 6px;
  left: 0;
  width: var(--tab-bar-bounce-w, 64px);
  border-radius: 14px;
  background: color-mix(in srgb, var(--tbb-accent) 14%, transparent);
  border: 1px solid color-mix(in srgb, var(--tbb-accent) 22%, transparent);
  transform: translateX(var(--tab-bar-bounce-x, 0px));
  opacity: 0;
  pointer-events: none;
}

.tab-bar-bounce__indicator.is-ready {
  opacity: 1;
  transition:
    transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1),
    width 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* --- Onglets ---------------------------------------------------------------- */

.tab-bar-bounce__item {
  position: relative;
  z-index: 1;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 7px 4px 6px;
  border: 0;
  border-radius: 14px;
  background: transparent;
  color: var(--ml-muted, #8b91a3);
  font-family: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: color 0.35s ease; /* désaturation douce de l'onglet quitté */
}

.tab-bar-bounce__item:hover {
  color: color-mix(in srgb, var(--ml-fg, #e8eaf2) 80%, var(--ml-muted, #8b91a3));
}

.tab-bar-bounce__item.is-active {
  color: var(--tbb-accent);
  transition: color 0.2s ease; /* l'arrivée se teinte plus vite que le départ */
}

.tab-bar-bounce__item:focus-visible {
  outline: 2px solid var(--tbb-accent);
  outline-offset: 2px;
}

.tab-bar-bounce__label {
  font-size: 0.6rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  line-height: 1;
}

/* --- Icône : rebond squash & stretch à l'activation ------------------------ */

.tab-bar-bounce__icon {
  position: relative;
  display: block;
  width: 20px;
  height: 20px;
  transform-origin: 50% 100%;
}

.tab-bar-bounce__icon svg {
  display: block;
  width: 100%;
  height: 100%;
}

.tab-bar-bounce__item.is-active .tab-bar-bounce__icon {
  animation: tab-bar-bounce-boing 0.55s cubic-bezier(0.36, 0.07, 0.19, 0.97);
}

@keyframes tab-bar-bounce-boing {
  0%   { transform: scale(1, 1); }
  22%  { transform: scale(1.28, 0.72) translateY(1px); }  /* squash */
  48%  { transform: scale(0.82, 1.22) translateY(-3px); } /* stretch */
  70%  { transform: scale(1.1, 0.92) translateY(0); }
  86%  { transform: scale(0.97, 1.04); }
  100% { transform: scale(1, 1); }
}

/* --- Badge de notification --------------------------------------------------- */

.tab-bar-bounce__badge {
  position: absolute;
  top: -4px;
  right: -7px;
  min-width: 14px;
  height: 14px;
  padding: 0 3px;
  display: grid;
  place-items: center;
  border-radius: 7px;
  background: var(--ml-accent-2, #2dd4bf);
  color: var(--ml-bg, #0d1017);
  font-size: 0.55rem;
  font-weight: 700;
  line-height: 1;
  transform: scale(0);
  animation: tab-bar-bounce-badge-pop 0.5s cubic-bezier(0.34, 1.86, 0.64, 1) 0.55s forwards;
  transition: transform 0.25s cubic-bezier(0.55, 0, 0.55, 0.2), opacity 0.25s ease;
}

@keyframes tab-bar-bounce-badge-pop {
  0%   { transform: scale(0); }
  70%  { transform: scale(1.22); }
  100% { transform: scale(1); }
}

/* Onglet visité → notifications « lues », le badge se résorbe */
.tab-bar-bounce__item.is-active .tab-bar-bounce__badge {
  animation: none;
  transform: scale(0);
  opacity: 0;
}

/* --- Reduced motion ----------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  .tab-bar-bounce__indicator.is-ready {
    transition-duration: 0.01s;
  }

  .tab-bar-bounce__item,
  .tab-bar-bounce__item.is-active,
  .tab-bar-bounce__badge {
    transition-duration: 0.01s;
  }

  .tab-bar-bounce__item.is-active .tab-bar-bounce__icon {
    animation: none;
  }

  .tab-bar-bounce__badge {
    animation-duration: 0.01s;
    animation-delay: 0s;
  }
}
