/**
 * Floating field label - shared by the Pure, Minimal and GlassUI templates.
 *
 * Markup (one real <label>, associated with the input through for/id):
 *
 *   <div class="pym-auth__input-wrap pym-fl">
 *     <input class="pym-auth__input" id="x" placeholder=" ">
 *     [optional icon / password toggle]
 *     <label class="pym-auth__label" for="x">Label</label>
 *   </div>
 *
 * The label rests inside the field like a placeholder and moves onto the top
 * border (inline-end, i.e. the right in RTL) whenever the field is focused, has
 * a value or is autofilled. State is pure CSS: :focus / :placeholder-shown / autofill.
 * The input needs a non-empty placeholder (a single space is enough) for
 * :placeholder-shown to work; any real hint text is only revealed while focused.
 *
 * Each template colours and positions it through these custom properties
 * (set on the template root or on the field wrapper):
 *
 *   --pym-fl-color          label colour
 *   --pym-fl-color-active   label colour while the field has focus
 *   --pym-fl-hint           colour of the hint text shown on focus
 *   --pym-fl-bg-top         surface behind the upper half of the notch (card)
 *   --pym-fl-bg-bottom      surface behind the lower half of the notch (field)
 *   --pym-fl-size           resting font size (matches the input text)
 *   --pym-fl-size-float     floated font size
 *   --pym-fl-rest-end       resting distance from the right edge
 *   --pym-fl-float-end      floated distance from the right edge
 *
 * @package OTPex
 * @since   1.4.14
 */

.pym-auth .pym-auth__input-wrap.pym-fl {
  position: relative;
}

/* Label: resting state (inside the field, vertically centred). */
.pym-auth .pym-fl > .pym-auth__label {
  position: absolute;
  z-index: 2;
  top: 50%;
  right: var(--pym-fl-rest-end, 14px);
  left: auto;
  translate: 0 -50%;
  display: block;
  box-sizing: border-box;
  max-width: calc(100% - 24px);
  margin: 0 !important;
  padding: 2px 4px !important;
  overflow: hidden;
  isolation: isolate;
  color: var(--pym-fl-color, #6b7280);
  font-size: var(--pym-fl-size, 15px);
  font-weight: 400;
  line-height: 1.3;
  letter-spacing: normal;
  direction: rtl;
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
  pointer-events: none;
  cursor: text;
  transition: top 0.18s ease, right 0.18s ease, font-size 0.18s ease, color 0.18s ease;
}

/* Notch: hides the field border behind the floated label. Fades in with the move. */
.pym-auth .pym-fl > .pym-auth__label::before {
  content: "";
  position: absolute;
  z-index: -1;
  inset: 0;
  background: linear-gradient(to bottom, var(--pym-fl-bg-top, #fff) 50%, var(--pym-fl-bg-bottom, #fff) 50%);
  opacity: 0;
  transition: opacity 0.18s ease;
}

/* Floated: focus, has a value, or autofilled (unsupported autofill selectors are dropped by :is()). */
.pym-auth .pym-fl > .pym-auth__input:is(:focus, :not(:placeholder-shown), :-webkit-autofill, :autofill) ~ .pym-auth__label {
  top: 0;
  right: var(--pym-fl-float-end, 12px);
  font-size: var(--pym-fl-size-float, 12px);
}

.pym-auth .pym-fl > .pym-auth__input:is(:focus, :not(:placeholder-shown), :-webkit-autofill, :autofill) ~ .pym-auth__label::before {
  opacity: 1;
}

.pym-auth .pym-fl > .pym-auth__input:focus ~ .pym-auth__label {
  color: var(--pym-fl-color-active, var(--pym-fl-color, #111827));
}

/* Hint text (real placeholder) is invisible while the label rests inside the field. */
.pym-auth .pym-auth__input-wrap.pym-fl > input.pym-auth__input::placeholder {
  color: transparent !important;
  -webkit-text-fill-color: transparent !important;
  opacity: 1 !important;
  transition: color 0.18s ease;
}

.pym-auth .pym-auth__input-wrap.pym-fl > input.pym-auth__input:focus::placeholder {
  color: var(--pym-fl-hint, #9ca3af) !important;
  -webkit-text-fill-color: var(--pym-fl-hint, #9ca3af) !important;
}

@media (prefers-reduced-motion: reduce) {
  .pym-auth .pym-fl > .pym-auth__label,
  .pym-auth .pym-fl > .pym-auth__label::before {
    transition: none;
  }
}
