@use "../../style/variables" as *;

.#{$prefix}-tour {
  position: fixed;
  inset: 0;
  pointer-events: none;

  // Mask
  &__mask {
    position: fixed;
    inset: 0;
    pointer-events: auto;
  }

  &__mask-svg {
    width: 100%;
    height: 100%;
  }

  &__mask-block {
    pointer-events: auto;
    cursor: not-allowed;
  }

  // Arrow
  &__arrow,
  &__arrow::before {
    width: calc(var(--ty-tour-arrow-size) * 2);
    height: calc(var(--ty-tour-arrow-size) * 2);
    box-sizing: border-box;
    position: absolute;
  }

  &__arrow::before {
    content: '';
    transform: rotate(45deg);
  }

  // Panel wrapper (Popper target)
  &__panel-wrapper {
    position: absolute;
    pointer-events: auto;

    &_centered {
      position: fixed;
      top: 50%;
      left: 50%;
      transform: translate(-50%, -50%);
    }
  }

  // Panel
  &__panel {
    position: relative;
    border-radius: var(--ty-tour-panel-radius);
    box-shadow: var(--ty-tour-panel-shadow);
    max-width: var(--ty-tour-panel-max-width);
    min-width: var(--ty-tour-panel-min-width);

    &_default {
      background-color: var(--ty-tour-panel-bg-default);
      color: var(--ty-tour-panel-color-default);

      .#{$prefix}-tour {
        &__arrow::before {
          background: var(--ty-tour-panel-bg-default);
          box-shadow: 2px 2px 5px var(--ty-popup-arrow-shadow);
        }

        &__description {
          color: var(--ty-tour-description-color-default);
        }
      }
    }

    &_primary {
      background-color: var(--ty-tour-panel-bg-primary);
      color: var(--ty-tour-panel-color-primary);

      .#{$prefix}-tour {
        &__arrow::before {
          background: var(--ty-tour-panel-bg-primary);
        }

        &__description {
          color: var(--ty-tour-description-color-primary);
        }

        &__indicator {
          background-color: var(--ty-tour-indicator-bg-primary);

          &_active {
            background-color: var(--ty-tour-indicator-bg-active-primary);
          }
        }

        &__close-btn {
          color: var(--ty-tour-close-color-primary);

          &:hover {
            color: var(--ty-tour-close-color-hover-primary);
            background-color: var(--ty-tour-close-bg-hover-primary);
          }
        }
      }
    }

    // Zoom transition
    &_zoom {
      &-enter {
        opacity: 0;
        transform: scale(var(--ty-tour-zoom-scale-from));
      }

      &-enter-active {
        opacity: 1;
        transform: scale(1);
        transition: opacity var(--ty-tour-zoom-duration) ease-out, transform var(--ty-tour-zoom-duration) ease-out;
      }

      &-enter-done {
        opacity: 1;
        transform: scale(1);
      }

      &-exit {
        opacity: 1;
        transform: scale(1);
      }

      &-exit-active {
        opacity: 0;
        transform: scale(var(--ty-tour-zoom-scale-from));
        transition: opacity var(--ty-tour-zoom-duration) ease-in, transform var(--ty-tour-zoom-duration) ease-in;
      }

      &-exit-done {
        opacity: 0;
        display: none;
      }
    }
  }

  // Close button
  &__close-btn {
    position: absolute;
    top: var(--ty-tour-close-offset);
    right: var(--ty-tour-close-offset);
    width: var(--ty-tour-close-size);
    height: var(--ty-tour-close-size);
    line-height: var(--ty-tour-close-size);
    text-align: center;
    cursor: pointer;
    background: none;
    border: none;
    border-radius: var(--ty-tour-close-radius);
    padding: 0;
    font-size: var(--ty-tour-close-font-size);
    color: var(--ty-tour-close-color);

    &:hover {
      background-color: var(--ty-tour-close-bg-hover);
    }
  }

  // Cover
  &__cover {
    padding: var(--ty-tour-cover-padding);
    text-align: center;

    img {
      max-width: 100%;
      border-radius: var(--ty-tour-panel-radius) var(--ty-tour-panel-radius) 0 0;
    }
  }

  // Title
  &__title {
    padding: var(--ty-tour-title-padding);
    font-weight: var(--ty-tour-title-font-weight);
    font-size: var(--ty-tour-title-font-size);
    line-height: var(--ty-tour-title-line-height);
  }

  // Description
  &__description {
    padding: var(--ty-tour-description-padding);
    font-size: var(--ty-tour-description-font-size);
    line-height: var(--ty-tour-description-line-height);
  }

  // Footer
  &__footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--ty-tour-footer-padding);
  }

  // Indicators
  &__indicators {
    display: flex;
    gap: var(--ty-tour-indicators-gap);
  }

  &__indicator {
    width: var(--ty-tour-indicator-size);
    height: var(--ty-tour-indicator-size);
    border-radius: 50%;
    background-color: var(--ty-tour-indicator-bg-default);
    transition: background-color var(--ty-tour-indicator-transition-duration);

    &_active {
      background-color: var(--ty-tour-indicator-bg-active-default);
    }
  }

  // Actions
  &__actions {
    display: flex;
    gap: var(--ty-tour-actions-gap);
    margin-left: auto;
  }

  // Arrow placement
  [data-popper-placement^='top'] > &__arrow {
    bottom: calc(var(--ty-tour-arrow-size) * -1);

    &::before {
      box-shadow: 3px 3px 7px var(--ty-popup-arrow-shadow);
    }
  }

  [data-popper-placement^='bottom'] > &__arrow {
    top: calc(var(--ty-tour-arrow-size) * -1);

    &::before {
      box-shadow: -2px -2px 5px var(--ty-popup-arrow-shadow);
    }
  }

  [data-popper-placement^='left'] > &__arrow {
    right: calc(var(--ty-tour-arrow-size) * -1);

    &::before {
      box-shadow: 3px -3px 7px var(--ty-popup-arrow-shadow);
    }
  }

  [data-popper-placement^='right'] > &__arrow {
    left: calc(var(--ty-tour-arrow-size) * -1);

    &::before {
      box-shadow: -3px 3px 7px var(--ty-popup-arrow-shadow);
    }
  }
}
