/**
 * Melanin Stories — assets/css/components/search-button.css
 * Bouton flottant droite/centré verticalement, qui se transforme
 * sur place en champ de recherche. Indépendant du header.
 */

.ms-search-float {
  position: fixed;
  right: 20px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 60;
  display: flex;
  align-items: center;
}

/* --- État replié : juste le bouton rond --- */
.ms-search-float__toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--ms-ink);
  color: var(--ms-paper);
  border-radius: 999px;
  padding: 14px;
  box-shadow: 0 6px 18px rgba(26, 20, 16, 0.25);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.ms-search-float__toggle:hover {
  background: var(--ms-red);
}

.ms-search-float__label {
  font-family: var(--ms-font-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
  max-width: 0;
  overflow: hidden;
  transition: max-width 0.25s ease;
}

/* Sur les écrans larges, le libellé "Rechercher" apparaît au survol */
@media (hover: hover) and (min-width: 780px) {
  .ms-search-float__toggle:hover .ms-search-float__label {
    max-width: 120px;
  }
}

/* --- État déplié : le champ de recherche --- */
.ms-search-float__form {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--ms-paper);
  border: 1px solid var(--ms-ink);
  border-radius: 999px;
  padding: 6px 6px 6px 18px;
  box-shadow: 0 6px 18px rgba(26, 20, 16, 0.18);

  max-width: 0;
  opacity: 0;
  overflow: hidden;
  pointer-events: none;
  transition: max-width 0.3s ease, opacity 0.2s ease;
}

.ms-search-float__input {
  border: none;
  background: transparent;
  font-family: var(--ms-font-body);
  font-size: 14px;
  width: 220px;
  max-width: calc(100vw - 140px);
  color: var(--ms-ink);
}

.ms-search-float__input:focus {
  outline: none;
}

.ms-search-float__submit,
.ms-search-float__close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  color: var(--ms-ink);
  flex-shrink: 0;
}

.ms-search-float__submit:hover,
.ms-search-float__close:hover {
  background: rgba(26, 20, 16, 0.08);
}

.ms-search-float__close {
  font-size: 20px;
  line-height: 1;
}

/* --- Bascule d'état (classe ajoutée en JS) --- */
.ms-search-float.is-open .ms-search-float__toggle {
  opacity: 0;
  transform: scale(0.8);
  pointer-events: none;
  position: absolute; /* sort du flux pour laisser toute la place au form */
}

.ms-search-float.is-open .ms-search-float__form {
  max-width: 320px;
  opacity: 1;
  pointer-events: auto;
}

/* ==========================================================================
   TABLETTE / MOBILE — le bouton reste à droite, centré verticalement,
   mais se fait plus compact et le champ ne dépasse jamais l'écran.
   ========================================================================== */
@media (max-width: 780px) {
  .ms-search-float {
    right: 14px;
  }

  .ms-search-float__toggle {
    padding: 12px;
  }

  .ms-search-float.is-open .ms-search-float__form {
    max-width: calc(100vw - 28px);
  }

  .ms-search-float__input {
    width: 160px;
  }
}
