/**
 * Tour step must sit above all other UI components.
 * The backdrop is the lowest point in the tour.
 * Everything else is in the container, and the target background should be at the same z-index.
 * ----- moodle
 *  ---- step backdrop
 *   --- step container
 *   --- step target background
 */
@flexitour-base-zindex: 4030;

// The backdrop is the backdrop used in 'modal' step display.
div[data-flexitour="backdrop"] {
    .modal-backdrop();
    opacity: 0.5;
    // The backdrop needs to have a lower z-index than everything else in the tour, but higher than everything else in Moodle.
    z-index: @flexitour-base-zindex;
}

// The step-background is used to highlight the region targetted in the step.
div[data-flexitour="step-background-fader"],
div[data-flexitour="step-background"] {
    border-radius: @border-radius-base;

    // The step target background should be above the base.
    z-index: (@flexitour-base-zindex + 1);
}

span[data-flexitour="container"],
div[data-flexitour="step-background-fader"],
[data-flexitour="step-backdrop"] > td,
[data-flexitour="step-backdrop"] {
    // The step target background should be above the base.
    z-index: (@flexitour-base-zindex + 2);
}

span[data-flexitour="container"] {
    .modal-dialog {
        /**
         * Remove all margins to:
         * 1) ensure that the arrow touches the target; and
         * 2) ensure that the focus border touches the modal.
         */
        margin: 0;
    }
    div[data-role="flexitour-step"] {
        background-color: #fff;
        border-radius: 6px;
        border: 1px solid rgba(0, 0, 0, .2);
        box-shadow: 0 5px 10px rgba(0, 0, 0, .2);

        > div {
            // When targetting some regions, the selectors override the modal ones.
            display: block;
            margin: 0;
        }
    }

    div[data-role="arrow"] {
        border-width: @popover-arrow-outer-width;
    }

    div[data-role="arrow"]:after {
        content: " ";
    }

    div[data-role="arrow"],
    div[data-role="arrow"]:after {
        position: absolute;
        display: block;
        width: 0;
        height: 0;
        border-color: transparent;
        border-style: solid;
        border-width: @popover-arrow-width;
    }

    &[x-placement="top"],
    &[x-placement="top-start"] {
        margin-bottom: @popover-arrow-width;
        div[data-role="arrow"] {
            bottom: -@popover-arrow-width;
            left: 50%;
            margin-left: -@popover-arrow-outer-width;
            border-bottom-width: 0;
            border-top-color: @popover-arrow-outer-color;
        }
        div[data-role="arrow"]:after {
            bottom: 1px;
            margin-left: -@popover-arrow-width;
            border-bottom-width: 0;
            border-top-color: @popover-arrow-color;
        }
    }

    &[x-placement="bottom"],
    &[x-placement="bottom-start"] {
        margin-top: @popover-arrow-width;
        div[data-role="arrow"] {
            top: -@popover-arrow-width;
            left: 50%;
            margin-left: -@popover-arrow-outer-width;
            border-top-width: 0;
            border-bottom-color: @popover-arrow-outer-color;
        }
        div[data-role="arrow"]:after {
            top: 1px;
            margin-left: -@popover-arrow-width;
            border-top-width: 0;
            border-bottom-color: @popover-arrow-color;
        }
    }

    &[x-placement="left"],
    &[x-placement="left-start"] {
        margin-right: @popover-arrow-width;
        div[data-role="arrow"] {
            right: -@popover-arrow-width;
            top: 50%;
            margin-top: -@popover-arrow-outer-width;
            border-right-width: 0;
            border-left-color: @popover-arrow-outer-color;
        }
        div[data-role="arrow"]:after {
            right: 1px;
            margin-top: -@popover-arrow-width;
            border-right-width: 0;
            border-left-color: @popover-arrow-color;
        }
    }

    &[x-placement="right"],
    &[x-placement="right-start"] {
        margin-left: @popover-arrow-width;
        div[data-role="arrow"] {
            left: -@popover-arrow-width;
            top: 50%;
            margin-top: -@popover-arrow-outer-width;
            border-left-width: 0;
            border-right-color: @popover-arrow-outer-color;
        }
        div[data-role="arrow"]:after {
            left: 1px;
            margin-top: -@popover-arrow-width;
            border-left-width: 0;
            border-right-color: @popover-arrow-color;
        }
    }
}
