/*
  Form field system — persistent labels (never placeholder-only), a
  44px minimum control height, a visible 2px border, and an explicit
  focus ring on every input/select/textarea.

  Why persistent labels specifically: the source project's audit found
  a contact form whose "labels" were placeholder text inside the
  input — which disappears the instant a user starts typing, so
  anyone who gets interrupted mid-form (or is using a screen reader,
  which may not announce placeholder text as a label at all) loses
  the field's meaning. A real <label> above the field, always visible,
  fixes both problems at once. See README lessons-learned checklist.
*/

.field {
  display: grid;
  gap: var(--space-2);
}

.field__label {
  color: var(--color-text-primary);
  font-size: var(--font-small);
  font-weight: 700;
}

.field__hint {
  color: var(--color-text-secondary);
  font-size: var(--font-small);
}

.field input,
.field select,
.field textarea {
  width: 100%;
  min-width: 0;
  min-height: 44px; /* matches the button min-height — consistent tap targets across the whole UI */
  padding: var(--space-3);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface-default);
  color: var(--color-text-primary);
  font-family: var(--font-family-body);
  font-size: var(--font-base); /* keep >=16px — smaller triggers iOS Safari's auto-zoom-on-focus */
}

.field textarea {
  min-height: 140px;
  resize: vertical;
}

.field input:focus-visible,
.field select:focus-visible,
.field textarea:focus-visible {
  outline: 3px solid var(--color-focus);
  outline-offset: 1px;
  border-color: var(--color-focus);
}

.field input:disabled,
.field select:disabled,
.field textarea:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Invalid/error state — pair with an associated <p class="field__error">
   referenced from the input via aria-describedby, and toggle
   aria-invalid="true" on the input in JS/server-side validation. */
.field--invalid input,
.field--invalid select,
.field--invalid textarea {
  border-color: var(--color-error);
}

.field__error {
  color: var(--color-error);
  font-size: var(--font-small);
  font-weight: 700;
}

/* Form-level status region (submit success/failure). Give this
   element aria-live="polite" in markup so screen-reader users hear
   the outcome without focus having to move to it — see example.html.
   Reserve the min-height so the layout doesn't jump when the message
   appears. */
.form-status {
  min-height: 1.4em;
  font-size: var(--font-small);
  font-weight: 700;
}

.form-status.is-success {
  color: var(--color-success);
}

.form-status.is-error {
  color: var(--color-error);
}

/* Layout helper: two-column field grid that collapses to one column
   on narrow screens, with the message field spanning full width. */
.field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-3);
}

.field-grid .field--full,
.field-grid .btn {
  grid-column: 1 / -1;
}

@media (max-width: 640px) {
  .field-grid {
    grid-template-columns: 1fr;
  }
}
