/* ==========================================================================
   110 — Float Label
   Champ texte premium : le label repose en position placeholder puis flotte
   vers le haut (translate + scale) au focus OU quand le champ est rempli
   (:not(:placeholder-shown)). Une barre de focus en gradient se déploie du
   centre (scaleX) et l'icône se teinte en synchro. CSS only.
   ========================================================================== */

.float-label {
  --fl-accent: var(--ml-accent, #7c8cff);
  --fl-accent-2: var(--ml-accent-2, #2dd4bf);
  --fl-ease: cubic-bezier(0.22, 1, 0.36, 1);

  position: relative;
  width: min(280px, 100%);
  border-radius: 12px;
  background-color: var(--ml-surface, #151a24);
  border: 1px solid color-mix(in srgb, var(--ml-muted, #8b91a3) 28%, transparent);
  transition: border-color 0.3s var(--fl-ease);
}

.float-label:hover {
  border-color: color-mix(in srgb, var(--ml-muted, #8b91a3) 55%, transparent);
}

.float-label:focus-within {
  border-color: color-mix(in srgb, var(--fl-accent) 60%, transparent);
}

/* anneau clavier : uniquement quand le focus vient du clavier */
.float-label:has(.float-label__input:focus-visible) {
  outline: 2px solid var(--fl-accent);
  outline-offset: 3px;
}

/* --- Input ---------------------------------------------------------------- */

.float-label__input {
  width: 100%;
  padding: 25px 16px 9px 46px;
  border: 0;
  border-radius: inherit;
  background: none;
  color: var(--ml-fg, #e8eaf2);
  font: inherit;
  font-size: 0.95rem;
  line-height: 1.3;
  outline: none; /* le focus est porté par la bordure, la barre et le :has ci-dessus */
  caret-color: var(--fl-accent);
}

/* placeholder=" " requis pour :placeholder-shown — jamais affiché */
.float-label__input::placeholder {
  color: transparent;
}

/* --- Label flottant --------------------------------------------------------- */

.float-label__label {
  position: absolute;
  left: 46px;
  top: 50%;
  max-width: calc(100% - 62px);
  overflow: hidden;
  white-space: nowrap;
  color: var(--ml-muted, #8b91a3);
  font-size: 0.95rem;
  line-height: 1.3;
  transform: translateY(-50%);
  transform-origin: left center;
  transition:
    transform 0.32s var(--fl-ease),
    color 0.32s var(--fl-ease),
    letter-spacing 0.32s var(--fl-ease);
  pointer-events: none;
  will-change: transform;
}

/* état flotté : focus OU champ rempli */
.float-label__input:focus ~ .float-label__label,
.float-label__input:not(:placeholder-shown) ~ .float-label__label {
  transform: translateY(-50%) translateY(-12px) scale(0.74);
  letter-spacing: 0.04em;
}

/* au focus le label prend l'accent ; rempli sans focus, il reste discret */
.float-label__input:focus ~ .float-label__label {
  color: var(--fl-accent);
}

/* --- Icône ------------------------------------------------------------------ */

.float-label__icon {
  position: absolute;
  left: 14px;
  top: 50%;
  width: 20px;
  height: 20px;
  color: var(--ml-muted, #8b91a3);
  transform: translateY(-50%);
  transition:
    color 0.32s var(--fl-ease),
    transform 0.32s var(--fl-ease);
  pointer-events: none;
}

.float-label__svg {
  display: block;
  width: 100%;
  height: 100%;
}

/* teinte en synchro avec le déploiement de la barre */
.float-label__input:focus ~ .float-label__icon {
  color: var(--fl-accent);
  transform: translateY(-50%) scale(1.1);
}

.float-label__input:not(:placeholder-shown) ~ .float-label__icon {
  color: color-mix(in srgb, var(--ml-fg, #e8eaf2) 75%, var(--ml-muted, #8b91a3));
}

.float-label__input:focus ~ .float-label__icon,
.float-label__input:focus:not(:placeholder-shown) ~ .float-label__icon {
  color: var(--fl-accent);
}

/* --- Barre de focus ----------------------------------------------------------
   Se déploie du centre sous le champ, gradient accent → accent-2. Insérée
   dans les coins arrondis (left/right) pour ne pas dépasser du radius. */

.float-label__bar {
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: -1px; /* recouvre la bordure basse du conteneur */
  height: 2px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--fl-accent), var(--fl-accent-2));
  transform: scaleX(0);
  transform-origin: center;
  transition: transform 0.38s var(--fl-ease);
}

.float-label__input:focus ~ .float-label__bar {
  transform: scaleX(1);
}

/* --- Wrapper de démo galerie ------------------------------------------------ */

.float-label-demo {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  width: min(280px, 100%);
}

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

@media (prefers-reduced-motion: reduce) {
  .float-label,
  .float-label__label,
  .float-label__icon,
  .float-label__bar {
    transition-duration: 0.01s;
  }
}
