// A feature tour: a box that points to an element on the page and shows one step of a guided tour
// (title, text, a step indicator and buttons). A script places the box, e.g. with floating-ui.
// Use .theme--magenta.theme--dark on the box. The box is magenta (--color-theme), and the buttons and the
// step indicator in it use the darker secondary magenta.
// Around the box, .feature-tour-spotlight dims the page and keeps the clicks away from it. The script sets a
// clip-path on __blocker and __overlay with a hole for each element that the student can still use.
.feature-tour {
  $width: 22rem;
  $arrow-size: spacing(-2);

  @include set-colors("theme", $rewrite-css-vars: true);
  //the script offsets the arrow by half of this size, so the arrow sticks out of the box
  --feature-tour-arrow-size: #{$arrow-size};
  position: absolute;
  z-index: $z-index-page-overlay + 2;
  width: min(#{$width}, calc(100vw - #{spacing(-5, $times: 2)}));
  padding: spacing(-1);
  box-shadow: $shadow-style-front color("shadow");

  //the box gets the focus when a step opens, but it is not a control
  &:focus {
    outline: none;
  }

  &:focus-visible {
    outline: $outline-width solid color("utility-focus");
  }

  //a step without an element is shown in the middle of the screen
  &--centered {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
  }

  &__arrow {
    position: absolute;
    width: var(--feature-tour-arrow-size);
    height: var(--feature-tour-arrow-size);
    background-color: inherit;
    transform: rotate(45deg);
  }

  &__title {
    @include set-font(1, "single", $weight: "bold");
    margin: 0 0 spacing(-4) 0;
  }

  &__body p {
    margin: 0 0 spacing(-3) 0;
  }

  &__actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: spacing(-4) spacing(-2);
    margin-top: spacing(-2);
  }

  .button:not(.button--text) {
    @include set-colors("theme-secondary");

    &:hover {
      background-color: color("theme-secondary-hover");
    }
  }

  .button--text {
    color: color("foreground");
  }

  //the step indicator is a .stepper. It only shows the circles in the box
  .stepper {
    margin: spacing(-2) 0 0 0;

    &__item::before {
      @include set-colors("theme-secondary");
    }

    //the steps that are still to come: a light circle with a magenta number
    &__item--active:not(.stepper__item--final) ~ .stepper__item::before {
      background-color: color("foreground-theme");
      color: color("theme");
    }

    .stepper__item .stepper__item__label {
      display: none;
    }
  }

  @media (prefers-reduced-motion: no-preference) {
    animation: animation-feature-tour-in 150ms $easing-in;
  }

  @keyframes animation-feature-tour-in {
    from {
      opacity: 0;
    }

    to {
      opacity: 1;
    }
  }
}

.feature-tour-spotlight {
  display: contents;

  &__blocker,
  &__overlay {
    position: fixed;
    inset: 0;
  }

  //takes the clicks on the page. The holes in the clip-path get no pointer events
  &__blocker {
    z-index: $z-index-page-overlay;
  }

  &__overlay {
    z-index: $z-index-page-overlay + 1;
    background-color: color("overlay");
    pointer-events: none;
  }
}
