:host {
  touch-action: manipulation;
}

:host-context(.item) {
  /**
   * @prop --color: Color of the label
   */
  --color: initial;
  display: block;
  color: var(--color);
  font-family: var(--bkkr-font-family);
  font-size: inherit;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
  box-sizing: border-box;
}

:host(.label-color) {
  color: var(--color-base);
}

:host(.label-text-wrap),
:host([text-wrap]) {
  white-space: normal;
}

:host-context(.item-interactive-disabled:not(.item-multiple-inputs)) {
  pointer-events: none;
  cursor: default;
  opacity: 0.3;
}

:host-context(.item-input) {
  flex: initial;
  max-width: 200px;
  pointer-events: none;
}

:host-context(.item-textarea) {
  align-self: baseline;
}

:host(.label-fixed) {
  flex: 0 0 100px;
  width: 100px;
  min-width: 100px;
  max-width: 200px;
}

:host(.label-stacked),
:host(.label-floating) {
  margin-left: 0;
  margin-right: 0;
  margin-top: 0;
  margin-bottom: 0;
  align-self: stretch;
  width: auto;
  max-width: 100%;
  /* stylelint-disable property-disallowed-list */
  transform-origin: top left;
  /* stylelint-enable property-disallowed-list */
}

:host(.label-stacked.label-rtl),
:host(.label-floating.label-rtl) {
  /* stylelint-disable property-disallowed-list */
  transform-origin: top right;
  /* stylelint-enable property-disallowed-list */
}

:host(.label-stacked) {
  transform: translateY(50%) scale(0.75);
  transition: color 0.2s cubic-bezier(0.32, 0.72, 0, 1), transform 0.2s cubic-bezier(0.32, 0.72, 0, 1);
}

:host(.label-floating) {
  transform: translateY(1.2rem);
  transition: color 0.2s cubic-bezier(0.32, 0.72, 0, 1), transform 0.2s cubic-bezier(0.32, 0.72, 0, 1);
}

:host(.label-no-animate.label-floating),
:host(.label-no-animate.label-stacked) {
  transition: none;
}

:host-context(.item-has-focus).label-floating,
:host-context(.item-has-focus).label-stacked {
  color: var(--color-base, var(--color-primary, #3880ff));
}

:host-context(.state-focused).label-floating,
:host-context(.item-has-focus).label-floating,
:host-context(.item-has-placeholder:not(.item-input)).label-floating,
:host-context(.item-has-value).label-floating {
  transform: translateY(50%) scale(0.75);
}

:host-context(.item-has-value:not(.item-has-focus)).label-floating,
:host-context(.item-has-value:not(.item-has-focus)).label-stacked {
  opacity: 0.92;
}

/**
 * When translating the label inside of an bkkr-item with `fill="outline"`,
 * add pseudo-elements to imitate fieldset-like padding without shifting the label
 */
:host-context(.item-fill-outline.item-has-focus).label-floating,
:host-context(.item-fill-outline.item-has-placeholder:not(.item-input)).label-floating,
:host-context(.item-fill-outline.item-has-value).label-floating {
  transform: translateY(-6px) scale(0.75);
  position: relative;
  max-width: min-content;
  background-color: var(--background, var(--bkkr-item-background, var(--bkkr-background-color, transparent)));
  overflow: visible;
  z-index: 3;
}
:host-context(.item-fill-outline.item-has-focus).label-floating::before, :host-context(.item-fill-outline.item-has-focus).label-floating::after,
:host-context(.item-fill-outline.item-has-placeholder:not(.item-input)).label-floating::before,
:host-context(.item-fill-outline.item-has-placeholder:not(.item-input)).label-floating::after,
:host-context(.item-fill-outline.item-has-value).label-floating::before,
:host-context(.item-fill-outline.item-has-value).label-floating::after {
  position: absolute;
  width: 4px;
  height: 100%;
  background-color: var(--background, var(--bkkr-item-background, var(--bkkr-background-color, transparent)));
  content: "";
}
:host-context(.item-fill-outline.item-has-focus).label-floating::before,
:host-context(.item-fill-outline.item-has-placeholder:not(.item-input)).label-floating::before,
:host-context(.item-fill-outline.item-has-value).label-floating::before {
  /* stylelint-disable property-disallowed-list */
  left: calc(-1 * 4px);
  /* stylelint-enable property-disallowed-list */
}
:host-context(.item-fill-outline.item-has-focus).label-floating::after,
:host-context(.item-fill-outline.item-has-placeholder:not(.item-input)).label-floating::after,
:host-context(.item-fill-outline.item-has-value).label-floating::after {
  /* stylelint-disable property-disallowed-list */
  right: calc(-1 * 4px);
  /* stylelint-enable property-disallowed-list */
}

:host-context(.item-fill-solid.item-has-focus.state-color).label-stacked:not(.state-color),
:host-context(.item-fill-solid.item-has-focus.state-color).label-floating:not(.state-color),
:host-context(.item-fill-outline.item-has-focus.state-color).label-stacked:not(.state-color),
:host-context(.item-fill-outline.item-has-focus.state-color).label-floating:not(.state-color) {
  color: current-color(base);
}

:host-context(.state-touched.state-invalid) {
  color: var(--highlight-color-invalid);
}

:host-context(.item-fill-outline.item-has-focus.item-has-start-slot).label-floating,
:host-context(.item-fill-outline.item-has-placeholder:not(.item-input).item-has-start-slot).label-floating,
:host-context(.item-fill-outline.item-has-value.item-has-start-slot).label-floating {
  transform: translateX(-32px) translateY(-6px) scale(0.75);
}

:host-context(.item-fill-outline.item-has-focus.item-has-start-slot).label-floating.label-rtl,
:host-context(.item-fill-outline.item-has-placeholder:not(.item-input).item-has-start-slot).label-floating.label-rtl,
:host-context(.item-fill-outline.item-has-value.item-has-start-slot).label-floating.label-rtl {
  transform: translateX(calc(-1 * -32px)) translateY(-6px) scale(0.75);
}

::slotted(*) h1,
::slotted(*) h2,
::slotted(*) h3,
::slotted(*) h4,
::slotted(*) h5,
::slotted(*) h6 {
  text-overflow: inherit;
  overflow: inherit;
}

::slotted(*) h2:last-child,
::slotted(*) h3:last-child,
::slotted(*) h4:last-child,
::slotted(*) h5:last-child,
::slotted(*) h6:last-child,
::slotted(*) p:last-child {
  margin-bottom: 0;
}
:host-context(.label-color)::slotted(p) {
  color: inherit;
}