@use './focus';
@use './state';

// In-field controls sit as close to the border as the field's own block inset, so the gap around
// an action button reads the same on all four sides instead of being twice as wide on the end.
$ods-input-actions-padding-right: var(--ods-semantic-size-space-inset-block-compact);
$ods-input-field-height: var(--ods-semantic-size-block-size-md);
$ods-input-field-width: var(--ods-semantic-size-inline-size-field);
$ods-input-placeholder-color: var(--ods-semantic-color-content-placeholder);
$ods-input-icon-color: var(--ods-semantic-color-content-text);

// Every form field ships the same default width, addons included, so mixed fields line up in a
// form out of the box — themable through the width token behind `$ods-input-field-width`.
// Capped by the container so narrow layouts never overflow; consumers resize through the field root.
@mixin ods-input-width() {
  width: $ods-input-field-width;
  max-width: 100%;
}

@mixin ods-input() {
  box-sizing: border-box;
  border: var(--ods-semantic-border-thickness) solid var(--ods-semantic-color-border-control);
  border-radius: var(--ods-semantic-size-radius-control);
  box-shadow: var(--ods-semantic-shadow-control);
  background-color: var(--ods-semantic-color-surface-control);
  padding: var(--ods-semantic-size-space-inset-block-compact) var(--ods-semantic-size-space-inset-inline);
  min-height: $ods-input-field-height;
  color: var(--ods-semantic-color-content-text);
  font-family: inherit;
  font-size: 1rem;
}

@mixin ods-input-error() {
  border-color: var(--ods-semantic-color-border-critical);
}

@mixin ods-input-state() {
  &:focus {
    @include focus.ods-focus();
  }

  &:disabled {
    @include state.ods-is-disabled();
  }

  &:not(:disabled):read-only {
    @include state.ods-is-readonly();
  }
}
