/* Slide-to-verify slider component (BEM) */
.slider {
  margin: 30px auto 10px;
  /* Themes can change the width, e.g. to 100% to fill the container. */
  max-width: var(--notabot-slider-max-width, 480px);
  touch-action: none;
}

.slider__track {
  position: relative;
  /* The same size in every theme: 50px inside the border. */
  box-sizing: content-box;
  height: 50px;
  border: 2px solid #ddd;
  border-radius: 25px;
  background: #f0f0f0;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

.slider__fill {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, #e3f2fd, #90caf9);
  border-radius: 25px;
  transition: none;
  pointer-events: none;
}

.slider__handle {
  position: absolute;
  /* Centred vertically, whatever the track height. */
  top: 0;
  bottom: 0;
  left: 0;
  box-sizing: border-box;
  width: 44px;
  height: 44px;
  margin-block: auto;
  border-radius: 50%;
  background: #007cba;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: bold;
  cursor: grab;
  box-shadow: 0 2px 6px rgb(0, 0, 0, 0.2);
  transition: background-color 0.2s;
  z-index: 2;
  margin-inline: 3px;
  touch-action: none;
}

.slider__handle:hover {
  background: #005a8a;
}

/*
 * The range input covers the track for assistive technology, but is
 * invisible and lets the pointer through to the track and handle.
 */
.slider__input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  pointer-events: none;
  z-index: 3;
}

/* The focus ring of the invisible input is shown on the handle. */
.slider__input:focus-visible ~ .slider__handle {
  outline: 3px solid #005a8a;
  outline-offset: 2px;
}

/* Steps by keyboard or tap move the handle smoothly; a drag follows the
 * pointer directly. */
.slider__track:not(.slider__track--active) .slider__handle {
  transition:
    background-color 0.2s,
    left 0.15s ease-out;
}

.slider__track:not(.slider__track--active) .slider__fill {
  transition: width 0.15s ease-out;
}

@media (prefers-reduced-motion: reduce) {
  .slider__track .slider__handle,
  .slider__track .slider__fill {
    transition: none;
  }
}

.slider__label {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  /* #595959 on #f0f0f0: contrast 6.1:1 (WCAG AA). */
  color: #595959;
  font-size: 14px;
  pointer-events: none;
  white-space: nowrap;
  z-index: 1;
}

/* Active state (while dragging) */
.slider__track--active .slider__handle {
  cursor: grabbing;
  background: #005a8a;
}

.slider__track--active .slider__fill {
  background: linear-gradient(90deg, #bbdefb, #64b5f6);
}

/* Complete state */
.slider__track--complete .slider__fill {
  background: linear-gradient(90deg, #c8e6c9, #66bb6a);
  width: 100%;
}

.slider__track--complete .slider__handle {
  background: #2e7d32;
  cursor: default;
  font-size: 20px;
}

/* Disabled state (no attempts left) */
.slider__track--disabled {
  opacity: 0.6;
}

.slider__track--disabled .slider__handle,
.slider__track--disabled .slider__handle:hover {
  /* #595959 on #f0f0f0: contrast 6.1:1, like the label. */
  background: #595959;
  cursor: not-allowed;
}

/* Instructions for screen readers only. */
.slider__hint {
  position: absolute !important;
  overflow: hidden;
  clip: rect(1px, 1px, 1px, 1px);
  width: 1px;
  height: 1px;
  word-wrap: normal;
}
