/* ══════════════════════════════════════════════════════════════════════════
   Form field (§2.6) — used identically by search, coupon, checkout and
   account forms.

   The label is always visible and above the field. A placeholder-as-label
   disappears the moment a shopper types, which on a checkout address form is
   the difference between a completed order and an abandoned one. The
   placeholder here is only ever an example, never an instruction.

   The focused field lifts to --rtv-tray so the active field is the light one
   — the same light-is-editable convention the quantity stepper uses.
   ══════════════════════════════════════════════════════════════════════ */

@layer components {
  .rtv-field {
    display: block;
  }

  .rtv-field + .rtv-field {
    margin-block-start: var(--s-4);
  }

  .rtv-field__label {
    display: block;
    margin-block-end: var(--s-1);
    color: var(--rtv-ink);
    font-family: var(--rtv-font-system);
    font-size: var(--t-13);
    font-weight: 600;
    line-height: var(--lh-tight);
  }

  /* The word, not an asterisk. An asterisk is a convention a shopper has to
     already know; `(kötelező)` is not. */
  .rtv-field__required {
    margin-inline-start: var(--s-1);
    color: var(--rtv-ink-2);
    font-size: var(--t-12);
    font-weight: 400;
  }

  .rtv-field__control {
    inline-size: 100%;
    min-block-size: var(--ctl-h);
    padding-inline: var(--s-3);
    border: var(--bw-control) solid var(--rtv-line);
    border-radius: var(--r-1);
    background-color: var(--rtv-ground-sunk);
    color: var(--rtv-ink);
    font-family: var(--rtv-font-system);
    font-size: var(--t-15);
    line-height: var(--lh-prose);
  }

  .rtv-field--dense .rtv-field__control {
    min-block-size: var(--ctl-h-dense);
  }

  textarea.rtv-field__control {
    padding-block: var(--s-2);
    resize: vertical;
  }

  .rtv-field__control::placeholder {
    color: var(--rtv-ink-3);
    opacity: 1;
  }

  .rtv-field__control:hover {
    border-color: var(--rtv-ink-2);
  }

  .rtv-field__control:focus-visible {
    border-color: var(--rtv-ink);
    background-color: var(--rtv-tray);
    outline: 3px solid var(--rtv-green-action);
    outline-offset: 2px;
  }

  .rtv-field__control:disabled {
    background-color: var(--rtv-ground);
    border-color: var(--rtv-rule);
    color: var(--rtv-ink-3);
    cursor: not-allowed;
  }

  .rtv-field__help {
    display: block;
    margin-block-start: var(--s-1);
    color: var(--rtv-ink-2);
    font-family: var(--rtv-font-system);
    font-size: var(--t-13);
    line-height: var(--lh-tight);
  }

  /* ── error ──────────────────────────────────────────────────────────────
     The colour is never the only signal; the message text is mandatory and
     the component refuses to render the error state without one. */
  .rtv-field__control[aria-invalid='true'] {
    border-width: var(--bw-emph);
    border-color: var(--rtv-alert);
  }

  .rtv-field__error {
    display: block;
    margin-block-start: var(--s-1);
    color: var(--rtv-alert);
    font-family: var(--rtv-font-system);
    font-size: var(--t-13);
    font-weight: 500;
    line-height: var(--lh-tight);
  }

  @media (max-width: 640px) {
    /* Below 16px iOS zooms the viewport on focus and the shopper loses the
       form. This is a device constraint, not a type decision. */
    .rtv-field__control { font-size: var(--t-17); }
  }
}
