/* ============================================================================
   FIELDS
   Not the older ".form-field"/".form-input"/".form-label" in forms.css.
   ============================================================================ */

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field + .field {
  margin-top: var(--sp-4);
}

.field-label {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--sp-2);
  font: var(--fw-bold) 14px/18px var(--font);
  color: var(--tx);
}

.field-label--dense {
  font-weight: var(--fw-semibold);
}

.field-label-optional {
  font: var(--fw-regular) 13px/18px var(--font);
  color: var(--tx3);
}

.field-hint {
  font: var(--fw-regular) 13px/18px var(--font);
  color: var(--tx3);
}

.field-input,
.field-select,
.field-textarea {
  width: 100%;
  height: 44px;
  padding: 0 14px;
  border-radius: var(--r-field);
  border: var(--bw) solid var(--line);
  background: var(--field);
  color: var(--tx);
  font: var(--fw-regular) 15px/1.3 var(--font);
  transition: border-color 80ms ease-out, box-shadow 80ms ease-out;
}

.field-input::placeholder,
.field-textarea::placeholder {
  color: var(--tx3);
}

.field-textarea {
  height: auto;
  min-height: 88px;
  padding: 11px 14px;
  line-height: 22px;
  resize: vertical;
}

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

/* One line to start, growing as they type or drag (homework, next time) */
.field-textarea--short {
  min-height: 44px;
}

/* iOS Safari gives date and time fields a width of their own and centres the
   value, so a field in a narrow sheet runs past its edge */
.field-input[type="date"],
.field-input[type="time"] {
  display: block;
  min-inline-size: 0;
  max-inline-size: 100%;
  -webkit-appearance: none;
  appearance: none;
  text-align: start;
}

.field-input::-webkit-date-and-time-value {
  text-align: start;
}

/* A pop-up button, as Apple draws a select: the up-and-down chevron says a
   list of choices opens here; the system's own menu does the rest */
.field-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='%236B746E'%3E%3Cpath fill-rule='evenodd' d='M10.5303 3.46967C10.2374 3.17678 9.76256 3.17678 9.46967 3.46967L6.21967 6.71967C5.92678 7.01256 5.92678 7.48744 6.21967 7.78033C6.51256 8.07322 6.98744 8.07322 7.28033 7.78033L10 5.06066L12.7197 7.78033C13.0126 8.07322 13.4874 8.07322 13.7803 7.78033C14.0732 7.48744 14.0732 7.01256 13.7803 6.71967L10.5303 3.46967ZM6.21967 13.2803L9.46967 16.5303C9.76256 16.8232 10.2374 16.8232 10.5303 16.5303L13.7803 13.2803C14.0732 12.9874 14.0732 12.5126 13.7803 12.2197C13.4874 11.9268 13.0126 11.9268 12.7197 12.2197L10 14.9393L7.28033 12.2197C6.98744 11.9268 6.51256 11.9268 6.21967 12.2197C5.92678 12.5126 5.92678 12.9874 6.21967 13.2803Z' clip-rule='evenodd'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 16px;
  padding-right: 38px;
  cursor: pointer;
}

.field-input:focus-visible,
.field-select:focus-visible,
.field-textarea:focus-visible {
  outline: none;
  border-color: var(--ac);
  box-shadow: var(--focus-ring);
}

.field--error .field-input,
.field--error .field-select,
.field--error .field-textarea {
  border-color: var(--dan);
}

.field-error-message {
  font: var(--fw-regular) 13px/18px var(--font);
  color: var(--dan);
}

/* Password field with an eye toggle */
.field-password {
  position: relative;
}

.field-password .field-input {
  padding-right: 44px;
}

.field-password-toggle {
  position: absolute;
  top: 0;
  right: 0;
  height: 44px;
  width: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--tx3);
  cursor: pointer;
  background: transparent;
  border: none;
}

.field-password-toggle .icon {
  width: 18px;
  height: 18px;
}

/* The eye and eye-slash (Heroicons 20 solid), one shown at a time */
.field-password-icon {
  display: inline-flex;
}

.field-password-icon[hidden],
.field-password-toggle[hidden] {
  display: none;
}

.field-password-toggle:hover {
  color: var(--tx2);
}

.field-password-toggle:focus-visible {
  outline: none;
  border-radius: var(--r-field);
  box-shadow: var(--focus-ring);
}
