:host {
  display: inline-block;
  width: 100%;
}

:host([aria-readonly=true]) textarea {
  background-color: var(--pine-color-background-container-disabled);
  color: var(--pine-color-text-readonly);
}

:host([highlight]:not([disabled]):not([aria-disabled=true]):not([aria-readonly=true])) .pds-textarea__field:not(.is-invalid) {
  background-color: var(--pine-color-accent-disabled);
  border-color: var(--pine-color-accent);
  color: var(--pine-color-text-accent);
}
:host([highlight]:not([disabled]):not([aria-disabled=true]):not([aria-readonly=true])) .pds-textarea__field:not(.is-invalid):hover {
  border-color: var(--pine-color-accent-hover);
}
:host([highlight]:not([disabled]):not([aria-disabled=true]):not([aria-readonly=true])) .pds-textarea__field:not(.is-invalid):focus-visible {
  outline-color: var(--pine-color-focus-ring);
}
:host([highlight]:not([disabled]):not([aria-disabled=true]):not([aria-readonly=true])) .pds-textarea__field:not(.is-invalid) ~ .pds-textarea__character-counter {
  background: color-mix(in srgb, var(--pine-color-accent-disabled) 80%, transparent);
  color: var(--pine-color-text-accent);
}

.pds-textarea {
  display: flex;
  flex-direction: column;
}

.pds-textarea__label-wrapper {
  align-items: center;
  display: flex;
  justify-content: space-between;
}

.pds-textarea__action {
  align-items: center;
  display: flex;
  gap: var(--pine-dimension-xs);
  margin-inline-start: var(--pine-dimension-xs);
}

label {
  display: block;
  margin-block-end: var(--pine-dimension-xs);
}

.pds-textarea__label-wrapper label {
  margin-block-end: 0;
}

.pds-textarea__helper-message {
  color: var(--pine-color-text-message);
  font: var(--pine-typography-body-sm-medium);
  margin-block-start: var(--pine-dimension-2xs);
}

.pds-textarea__error-message {
  color: var(--pine-color-text-message-danger);
  display: flex;
  font: var(--pine-typography-body-sm-medium);
  gap: var(--pine-dimension-2xs);
  margin-block-start: var(--pine-dimension-2xs);
}
.pds-textarea__error-message pds-icon {
  margin-block-start: var(--pine-dimension-025);
}

.pds-textarea__field-wrapper {
  display: inline-block;
  position: relative;
  width: 100%;
}

.pds-textarea__field {
  background-color: var(--pine-color-background-container);
  border: var(--pine-border);
  border-radius: calc(var(--pine-dimension-xs) * 1.25);
  box-sizing: border-box;
  color: var(--pine-color-text);
  font: var(--pine-typography-body);
  letter-spacing: var(--pine-letter-spacing);
  min-height: calc(var(--pine-dimension-xl) * 2);
  min-width: calc(var(--pine-dimension-xl) * 2);
  padding: var(--pine-dimension-xs) var(--pine-dimension-sm);
  resize: both;
  width: 100%;
}
:host([max-length]) .pds-textarea__field {
  padding-bottom: calc(var(--pine-dimension-xs) + var(--pine-dimension-md));
}
.pds-textarea__field:hover:not(:disabled, .is-invalid) {
  border: var(--pine-border-hover);
}
.pds-textarea__field:disabled {
  background-color: var(--pine-color-background-container-disabled);
  color: var(--pine-color-text-disabled);
  cursor: not-allowed;
}
.pds-textarea__field:focus-visible {
  outline: var(--pine-outline-focus);
  outline-offset: var(--pine-border-width);
}
.pds-textarea__field::placeholder {
  color: var(--pine-color-text-placeholder);
}
.pds-textarea__field.is-invalid {
  background-color: var(--pine-input-color-background-danger);
  border-color: var(--pine-color-border-danger);
}
:host-context([data-theme=dark]) .pds-textarea__field.is-invalid {
  background-color: var(--pine-color-red-950);
}
.pds-textarea__field.is-invalid:focus-visible {
  outline-color: var(--pine-color-focus-ring-danger);
}

.pds-textarea__character-counter {
  background: color-mix(in srgb, var(--pine-color-background-container) 80%, transparent);
  border-radius: calc(var(--pine-dimension-2xs) * 0.5);
  color: var(--pine-color-text-muted);
  font: var(--pine-typography-body-sm-medium);
  padding: calc(var(--pine-dimension-2xs) * 0.5) var(--pine-dimension-2xs);
  pointer-events: none;
  position: absolute;
  user-select: none;
  white-space: nowrap;
  z-index: var(--pine-z-index);
}
:host([aria-disabled=true]) .pds-textarea__character-counter {
  background-color: var(--pine-color-background-container-disabled);
  color: var(--pine-color-text-disabled);
}
:host([aria-readonly=true]) .pds-textarea__character-counter {
  background-color: var(--pine-color-background-container-disabled);
  color: var(--pine-color-text-readonly);
}
.pds-textarea__field.is-invalid ~ .pds-textarea__character-counter {
  background-color: var(--pine-input-color-background-danger);
}
:host-context([data-theme=dark]) .pds-textarea__field.is-invalid ~ .pds-textarea__character-counter {
  background-color: var(--pine-color-red-950);
}

.visually-hidden {
  border: 0;
  clip: rect(0 0 0 0);
  clip-path: polygon(0 0, 0 0, 0 0);
  height: 1px;
  margin: -1px;
  overflow: hidden;
  padding: 0;
  position: absolute;
  white-space: nowrap;
  width: 1px;
}