/* Form controls. Classes:
   .field           wrapper: label above, control, hint, then error
   .label, .field-hint, .field-error (warning icon + words, no exclamation marks)
   .input           text field / select / textarea, 48px tall, 16px text (select: no native box)
   .input--code     the one-field code box with wide letter-spacing
   .check           tick box row (44px tap target)
   .switch          switch (a checkbox with role="switch")
   .radio-pair      two radio tiles side by side
   .stepper         minus, number, plus: three 44px parts
   .file            file input with preview
   .input[aria-invalid="true"] gets an Error border. Focus ring comes from base.css. */

.field { display: flex; flex-direction: column; gap: var(--space-2); margin-bottom: var(--space-4); }
.label { font-weight: 500; color: var(--text); }
.field-hint { margin: 0; color: var(--muted); font-size: var(--text-sm); }
.field-error {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  margin: 0;
  color: var(--error);
  font-size: var(--text-sm);
}
.field-error .icon { width: 1.25rem; height: 1.25rem; }

.input {
  width: 100%;
  min-height: var(--control-h);
  padding: var(--space-2) var(--space-4);
  border: 2px solid var(--outline);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: var(--text-base);
}
textarea.input { min-height: calc(var(--control-h) * 2.5); resize: vertical; }
.input[aria-invalid="true"] { border-color: var(--error); }
.input[disabled] { background-color: var(--chip); color: var(--muted); }
/* M22: a select drops the browser's own box (WebKit drew a grey, square native control behind
   the rounded border and grew it to 51px) and draws its chevron from the Text token. */
select.input {
  -webkit-appearance: none;
  appearance: none;
  padding-inline-end: calc(var(--space-4) * 2 + 0.75rem);
  background-image:
    linear-gradient(45deg, transparent 50%, var(--text) 50%),
    linear-gradient(135deg, var(--text) 50%, transparent 50%);
  background-position:
    right calc(var(--space-4) + 0.375rem) center,
    right var(--space-4) center;
  background-size: 0.375rem 0.375rem;
  background-repeat: no-repeat;
  line-height: 1.5;
}
.input--code {
  font-size: var(--text-2xl);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.4em;
  text-align: center;
}

/* Tick box */
.check {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-height: var(--tap-min);
  cursor: pointer;
}
.check__input {
  flex: none;
  width: 1.5rem;
  height: 1.5rem;
  margin: 0;
  accent-color: var(--link);
}

/* Switch: the checkbox is visually hidden; the track draws the state. */
.switch {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-height: var(--tap-min);
  cursor: pointer;
}
.switch__input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}
.switch__track {
  position: relative;
  flex: none;
  width: 3rem;
  height: 1.75rem;
  border: 2px solid var(--outline);
  border-radius: var(--radius-pill);
  background: var(--surface);
}
.switch__track::after {
  content: "";
  position: absolute;
  inset-block-start: 2px;
  inset-inline-start: 2px;
  width: 1.25rem;
  height: 1.25rem;
  border-radius: 50%;
  background: var(--outline);
  transition: transform var(--dur-fast) var(--ease-out);
}
.switch__input:checked + .switch__track { border-color: var(--link); background: var(--link); }
.switch__input:checked + .switch__track::after { background: var(--surface); transform: translateX(1.25rem); }
.switch__input:focus-visible + .switch__track {
  outline: var(--focus-ring-width) solid var(--focus-ring);
  outline-offset: var(--focus-ring-gap);
}

/* Radio pair */
.radio-pair { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-3); margin: 0; padding: 0; border: 0; }
.radio-pair legend { padding: 0; margin-bottom: var(--space-2); font-weight: 500; }
.radio { position: relative; display: block; }
.radio__input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.radio__label {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: var(--control-h);
  padding: 0 var(--space-4);
  border: 2px solid var(--outline);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--text);
  font-weight: 500;
  cursor: pointer;
}
.radio__input:checked + .radio__label { border-color: var(--link); box-shadow: inset 0 0 0 1px var(--link); font-weight: 700; }
.radio__input:focus-visible + .radio__label {
  outline: var(--focus-ring-width) solid var(--focus-ring);
  outline-offset: var(--focus-ring-gap);
}

/* Stepper: minus, number, plus, each 44px. */
.stepper { display: inline-flex; align-items: center; gap: var(--space-2); }
.stepper__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--tap-min);
  height: var(--tap-min);
  padding: 0;
  border: 2px solid var(--outline);
  border-radius: 50%;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  cursor: pointer;
}
.stepper__btn[disabled] { color: var(--muted); cursor: not-allowed; }
.stepper__value {
  min-width: var(--tap-min);
  min-height: var(--tap-min);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-lg);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* File input with preview */
.file { display: flex; flex-direction: column; gap: var(--space-3); }
.file__input {
  width: 100%;
  min-height: var(--control-h);
  padding: var(--space-3) var(--space-4);
  border: 2px dashed var(--outline);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--text);
  font: inherit;
}
.file__input::file-selector-button {
  min-height: var(--tap-min);
  margin-inline-end: var(--space-3);
  padding: 0 var(--space-4);
  border: 2px solid var(--outline);
  border-radius: var(--radius-sm);
  background: var(--chip);
  color: var(--text);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}
.file__preview { max-width: 12rem; max-height: 12rem; border-radius: var(--radius-md); object-fit: cover; }
