:host {
  /**
   * @prop --bar-background: Background of the range bar
   * @prop --bar-background-active: Background of the active range bar
   * @prop --bar-height: Height of the range bar
   * @prop --bar-border-radius: Border radius of the range bar
   * @prop --height: Height of the range
   * @prop --knob-background: Background of the range knob
   * @prop --knob-border-radius: Border radius of the range knob
   * @prop --knob-box-shadow: Box shadow of the range knob
   * @prop --knob-size: Size of the range knob
   * @prop --pin-background: Background of the range pin (only available in MD mode)
   * @prop --pin-color: Color of the range pin (only available in MD mode)
   */
  --knob-handle-size: calc(var(--knob-size) * 2);
  display: flex;
  position: relative;
  flex: 3;
  align-items: center;
  font-family: var(--ion-font-family, inherit);
  user-select: none;
  z-index: 2;
}

:host(.range-disabled) {
  pointer-events: none;
}

::slotted(ion-label) {
  flex: initial;
}

::slotted(ion-icon[slot]) {
  font-size: 24px;
}

.range-slider {
  position: relative;
  flex: 1;
  width: 100%;
  height: var(--height);
  contain: size layout style;
  cursor: grab;
  touch-action: pan-y;
}

:host(.range-pressed) .range-slider {
  cursor: grabbing;
}

.range-pin {
  position: absolute;
  background: var(--ion-color-base);
  color: var(--ion-color-contrast);
  text-align: center;
  box-sizing: border-box;
}

.range-knob-handle {
  top: calc((var(--height) - var(--knob-handle-size)) / 2);
  -webkit-margin-start: calc(0px - var(--knob-handle-size) / 2);
  margin-inline-start: calc(0px - var(--knob-handle-size) / 2);
  position: absolute;
  width: var(--knob-handle-size);
  height: var(--knob-handle-size);
  text-align: center;
}
@supports (inset-inline-start: 0) {
  .range-knob-handle {
    inset-inline-start: 0;
  }
}
@supports not (inset-inline-start: 0) {
  .range-knob-handle {
    left: 0;
  }
  :host-context([dir=rtl]) .range-knob-handle {
    left: unset;
    right: unset;
    right: 0;
  }
  [dir=rtl] .range-knob-handle {
    left: unset;
    right: unset;
    right: 0;
  }
  @supports selector(:dir(rtl)) {
    .range-knob-handle:dir(rtl) {
      left: unset;
      right: unset;
      right: 0;
    }
  }
}
:host-context([dir=rtl]) .range-knob-handle {
  /* stylelint-disable-next-line property-disallowed-list */
  left: unset;
}

[dir=rtl] .range-knob-handle {
  /* stylelint-disable-next-line property-disallowed-list */
  left: unset;
}

@supports selector(:dir(rtl)) {
  .range-knob-handle:dir(rtl) {
    /* stylelint-disable-next-line property-disallowed-list */
    left: unset;
  }
}
.range-knob-handle:active, .range-knob-handle:focus {
  outline: none;
}

.range-bar-container {
  border-radius: var(--bar-border-radius);
  top: calc((var(--height) - var(--bar-height)) / 2);
  position: absolute;
  width: 100%;
  height: var(--bar-height);
}
@supports (inset-inline-start: 0) {
  .range-bar-container {
    inset-inline-start: 0;
  }
}
@supports not (inset-inline-start: 0) {
  .range-bar-container {
    left: 0;
  }
  :host-context([dir=rtl]) .range-bar-container {
    left: unset;
    right: unset;
    right: 0;
  }
  [dir=rtl] .range-bar-container {
    left: unset;
    right: unset;
    right: 0;
  }
  @supports selector(:dir(rtl)) {
    .range-bar-container:dir(rtl) {
      left: unset;
      right: unset;
      right: 0;
    }
  }
}
:host-context([dir=rtl]) .range-bar-container {
  /* stylelint-disable-next-line property-disallowed-list */
  left: unset;
}

[dir=rtl] .range-bar-container {
  /* stylelint-disable-next-line property-disallowed-list */
  left: unset;
}

@supports selector(:dir(rtl)) {
  .range-bar-container:dir(rtl) {
    /* stylelint-disable-next-line property-disallowed-list */
    left: unset;
  }
}

.range-bar {
  border-radius: var(--bar-border-radius);
  position: absolute;
  width: 100%;
  height: var(--bar-height);
  background: var(--bar-background);
  pointer-events: none;
}

.range-knob {
  border-radius: var(--knob-border-radius);
  top: calc(50% - var(--knob-size) / 2);
  position: absolute;
  width: var(--knob-size);
  height: var(--knob-size);
  background: var(--knob-background);
  box-shadow: var(--knob-box-shadow);
  z-index: 2;
  pointer-events: none;
}
@supports (inset-inline-start: 0) {
  .range-knob {
    inset-inline-start: calc(50% - var(--knob-size) / 2);
  }
}
@supports not (inset-inline-start: 0) {
  .range-knob {
    left: calc(50% - var(--knob-size) / 2);
  }
  :host-context([dir=rtl]) .range-knob {
    left: unset;
    right: unset;
    right: calc(50% - var(--knob-size) / 2);
  }
  [dir=rtl] .range-knob {
    left: unset;
    right: unset;
    right: calc(50% - var(--knob-size) / 2);
  }
  @supports selector(:dir(rtl)) {
    .range-knob:dir(rtl) {
      left: unset;
      right: unset;
      right: calc(50% - var(--knob-size) / 2);
    }
  }
}
:host-context([dir=rtl]) .range-knob {
  /* stylelint-disable-next-line property-disallowed-list */
  left: unset;
}

[dir=rtl] .range-knob {
  /* stylelint-disable-next-line property-disallowed-list */
  left: unset;
}

@supports selector(:dir(rtl)) {
  .range-knob:dir(rtl) {
    /* stylelint-disable-next-line property-disallowed-list */
    left: unset;
  }
}

:host(.range-pressed) .range-bar-active {
  will-change: left, right;
}

:host(.in-item) {
  width: 100%;
}

/**
 * Range can be slotted
 * in components such as item and
 * toolbar which is why we do not
 * limit the below behavior to just ion-item.
 */
:host([slot=start]),
:host([slot=end]) {
  width: auto;
}

:host(.in-item) ::slotted(ion-label) {
  align-self: center;
}

.range-wrapper {
  display: flex;
  position: relative;
  flex-grow: 1;
  align-items: center;
  height: inherit;
}

::slotted([slot=label]) {
  /**
   * Label text should not extend
   * beyond the bounds of the range.
   * However, we do not set the max
   * width to 100% because then
   * only the label would show and users
   * would not be able to see the range.
   */
  max-width: 200px;
  /**
   * This ensures that double tapping this text
   * clicks the <label> and focuses the range
   * when a screen reader is enabled.
   */
  pointer-events: none;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
}

/**
 * If no label text is placed into the slot
 * then the element should be hidden otherwise
 * there will be additional margins added.
 */
.label-text-wrapper-hidden {
  display: none;
}

.native-wrapper {
  display: flex;
  flex-grow: 1;
  align-items: center;
}

/**
 * Label is on the left of the range in LTR and
 * on the right in RTL.
 */
:host(.range-label-placement-start) .range-wrapper {
  flex-direction: row;
}

:host(.range-label-placement-start) .label-text-wrapper {
  /**
   * The margin between the label and
   * the range should be on the end
   * when the label sits at the start.
   */
  -webkit-margin-start: 0;
  margin-inline-start: 0;
  -webkit-margin-end: 16px;
  margin-inline-end: 16px;
  margin-top: 0;
  margin-bottom: 0;
}

/**
 * Label is on the right of the range in LTR and
 * on the left in RTL.
 */
:host(.range-label-placement-end) .range-wrapper {
  flex-direction: row-reverse;
}

/**
 * The margin between the label and
 * the range should be on the start
 * when the label sits at the end.
 */
:host(.range-label-placement-end) .label-text-wrapper {
  -webkit-margin-start: 16px;
  margin-inline-start: 16px;
  -webkit-margin-end: 0;
  margin-inline-end: 0;
  margin-top: 0;
  margin-bottom: 0;
}

:host(.range-label-placement-fixed) .label-text-wrapper {
  /**
   * The margin between the label and
   * the range should be on the end
   * when the label sits at the start.
   */
  -webkit-margin-start: 0;
  margin-inline-start: 0;
  -webkit-margin-end: 16px;
  margin-inline-end: 16px;
  margin-top: 0;
  margin-bottom: 0;
}

/**
 * Label is on the left of the range in LTR and
 * on the right in RTL. Label also has a fixed width.
 */
:host(.range-label-placement-fixed) .label-text-wrapper {
  flex: 0 0 100px;
  width: 100px;
  min-width: 100px;
  max-width: 200px;
}

:host {
  --knob-border-radius: 50%;
  --knob-background: var(--bar-background-active);
  --knob-box-shadow: none;
  --knob-size: 18px;
  --bar-height: 2px;
  --bar-background: rgba(var(--ion-color-primary-rgb, 56, 128, 255), 0.26);
  --bar-background-active: var(--ion-color-primary, #3880ff);
  --bar-border-radius: 0;
  --height: 42px;
  --pin-background: var(--ion-color-primary, #3880ff);
  --pin-color: var(--ion-color-primary-contrast, #fff);
  font-size: 12px;
}

::slotted([slot=label]), .label-text {
  font-size: initial;
}

:host(.legacy-range) {
  -webkit-padding-start: 14px;
  padding-inline-start: 14px;
  -webkit-padding-end: 14px;
  padding-inline-end: 14px;
  padding-top: 8px;
  padding-bottom: 8px;
}

:host(.ion-color) .range-bar {
  background: rgba(var(--ion-color-base-rgb), 0.26);
}

:host(.ion-color) .range-bar-active,
:host(.ion-color) .range-knob,
:host(.ion-color) .range-knob::before,
:host(.ion-color) .range-pin,
:host(.ion-color) .range-pin::before,
:host(.ion-color) .range-tick {
  background: var(--ion-color-base);
  color: var(--ion-color-contrast);
}

::slotted([slot=start]) {
  -webkit-margin-start: 0;
  margin-inline-start: 0;
  -webkit-margin-end: 14px;
  margin-inline-end: 14px;
  margin-top: 0;
  margin-bottom: 0;
}

::slotted([slot=end]) {
  -webkit-margin-start: 14px;
  margin-inline-start: 14px;
  -webkit-margin-end: 0;
  margin-inline-end: 0;
  margin-top: 0;
  margin-bottom: 0;
}

:host(.range-has-pin) {
  padding-top: 28px;
}

.range-bar-active {
  bottom: 0;
  width: auto;
  background: var(--bar-background-active);
}

.range-knob {
  transform: scale(0.67);
  transition-duration: 120ms;
  transition-property: transform, background-color, border;
  transition-timing-function: ease;
  z-index: 2;
}
.range-knob::before {
  border-radius: 50%;
  position: absolute;
  width: var(--knob-size);
  height: var(--knob-size);
  transform: scale(1);
  transition: 0.267s cubic-bezier(0, 0, 0.58, 1);
  background: var(--knob-background);
  content: "";
  opacity: 0.13;
  pointer-events: none;
}
@supports (inset-inline-start: 0) {
  .range-knob::before {
    inset-inline-start: 0;
  }
}
@supports not (inset-inline-start: 0) {
  .range-knob::before {
    left: 0;
  }
  :host-context([dir=rtl]) .range-knob::before {
    left: unset;
    right: unset;
    right: 0;
  }
  [dir=rtl] .range-knob::before {
    left: unset;
    right: unset;
    right: 0;
  }
  @supports selector(:dir(rtl)) {
    .range-knob::before:dir(rtl) {
      left: unset;
      right: unset;
      right: 0;
    }
  }
}

.range-tick {
  position: absolute;
  top: calc((var(--height) - var(--bar-height)) / 2);
  width: var(--bar-height);
  height: var(--bar-height);
  background: var(--bar-background-active);
  z-index: 1;
  pointer-events: none;
}

.range-tick-active {
  background: transparent;
}

.range-pin {
  padding-left: 0;
  padding-right: 0;
  padding-top: 8px;
  padding-bottom: 8px;
  border-radius: 50%;
  transform: translate3d(0,  0,  0) scale(0.01);
  display: inline-block;
  position: relative;
  min-width: 28px;
  height: 28px;
  transition: transform 120ms ease, background 120ms ease;
  background: var(--pin-background);
  color: var(--pin-color);
  text-align: center;
}
.range-pin::before {
  top: 3px;
  -webkit-margin-start: -13px;
  margin-inline-start: -13px;
  /* stylelint-disable-next-line property-disallowed-list */
  border-radius: 50% 50% 50% 0;
  position: absolute;
  width: 26px;
  height: 26px;
  transform: rotate(-45deg);
  transition: background 120ms ease;
  background: var(--pin-background);
  content: "";
  z-index: -1;
}
@supports (inset-inline-start: 0) {
  .range-pin::before {
    inset-inline-start: 50%;
  }
}
@supports not (inset-inline-start: 0) {
  .range-pin::before {
    left: 50%;
  }
  :host-context([dir=rtl]) .range-pin::before {
    left: unset;
    right: unset;
    right: 50%;
  }
  [dir=rtl] .range-pin::before {
    left: unset;
    right: unset;
    right: 50%;
  }
  @supports selector(:dir(rtl)) {
    .range-pin::before:dir(rtl) {
      left: unset;
      right: unset;
      right: 50%;
    }
  }
}
:host-context([dir=rtl]) .range-pin::before {
  /* stylelint-disable-next-line property-disallowed-list */
  left: unset;
}

[dir=rtl] .range-pin::before {
  /* stylelint-disable-next-line property-disallowed-list */
  left: unset;
}

@supports selector(:dir(rtl)) {
  .range-pin::before:dir(rtl) {
    /* stylelint-disable-next-line property-disallowed-list */
    left: unset;
  }
}

.range-knob-pressed .range-pin,
.range-knob-handle.ion-focused .range-pin {
  transform: translate3d(0,  -24px,  0) scale(1);
}

@media (any-hover: hover) {
  .range-knob-handle:hover .range-knob:before {
    transform: scale(2);
    opacity: 0.13;
  }
}
.range-knob-handle.ion-activated .range-knob:before, .range-knob-handle.ion-focused .range-knob:before, .range-knob-handle.range-knob-pressed .range-knob:before {
  transform: scale(2);
}
.range-knob-handle.ion-focused .range-knob::before {
  opacity: 0.13;
}
.range-knob-handle.ion-activated .range-knob::before, .range-knob-handle.range-knob-pressed .range-knob::before {
  opacity: 0.25;
}

:host(:not(.range-has-pin)) .range-knob-pressed .range-knob,
:host(:not(.range-has-pin)) .range-knob-handle.ion-focused .range-knob {
  transform: scale(1);
}

:host(.range-disabled) .range-bar-active,
:host(.range-disabled) .range-bar,
:host(.range-disabled) .range-tick {
  background-color: var(--ion-color-step-250, #bfbfbf);
}

:host(.range-disabled) .range-knob {
  transform: scale(0.55);
  outline: 5px solid #fff;
  background-color: var(--ion-color-step-250, #bfbfbf);
}

:host(.range-disabled) .label-text-wrapper,
:host(.range-disabled) ::slotted([slot=start]),
:host(.range-disabled) ::slotted([slot=end]) {
  opacity: 0.38;
}