/*
    The guided tour: the dim, the hole cut in it, and the card that explains what is in the hole.

    A plain stylesheet rather than a scoped one. The elements it dresses are built by guidedTour.js and
    appended to the body, so they never carry the b-xxxx attribute a Blazor scoped stylesheet matches on.

    The colours are MudBlazor's own custom properties, so the tour follows the theme - light, dark and
    whatever a tenant sets - without knowing anything about it. Only the dim itself is a literal, because
    there is no palette entry for "the page, turned down".
*/

.ddi-tour {
    position: fixed;
    inset: 0;
    z-index: 2000;
    pointer-events: none;
}

.ddi-tour--closing { opacity: 0; transition: opacity .15s ease; }

/*
    The layer that makes the page read only while the tour runs. Transparent by default - the dim comes
    from the spotlight's shadow - and it takes the dim itself only on the steps that have no element to
    point at.
*/
.ddi-tour__backdrop {
    position: fixed;
    inset: 0;
    pointer-events: auto;
    background-color: transparent;
    transition: background-color .2s ease;
}

.ddi-tour__backdrop--dim { background-color: rgba(15, 21, 31, .62); }

/*
    The hole. The element is not covered at all; everything around it is, by a shadow spread far enough
    to reach the corner of any screen. The ring is a second shadow in front of the dim, which is why it
    is listed first - shadows paint in the order they are written, nearest first.

    Animating the box lets the light travel from one element to the next, which is what makes a tour read
    as one walk rather than as a series of jumps.
*/
.ddi-tour__spotlight {
    position: fixed;
    top: 0;
    left: 0;
    width: 0;
    height: 0;
    border-radius: 6px;
    pointer-events: none;
    box-shadow:
        0 0 0 3px var(--mud-palette-primary),
        0 0 0 9999px rgba(15, 21, 31, .62);
    transition: top .3s cubic-bezier(.4, 0, .2, 1),
                left .3s cubic-bezier(.4, 0, .2, 1),
                width .3s cubic-bezier(.4, 0, .2, 1),
                height .3s cubic-bezier(.4, 0, .2, 1),
                opacity .2s ease;
}

/* A slow breath on the ring, so the eye finds the element without the ring shouting at it. */
.ddi-tour__spotlight::after {
    content: "";
    position: absolute;
    inset: -3px;
    border-radius: 8px;
    box-shadow: 0 0 0 3px var(--mud-palette-primary);
    opacity: .55;
    animation: ddi-tour-pulse 2.2s ease-out infinite;
}

@keyframes ddi-tour-pulse {
    0%   { transform: scale(1);    opacity: .55; }
    70%  { transform: scale(1.04); opacity: 0; }
    100% { transform: scale(1.04); opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
    .ddi-tour__spotlight { transition: opacity .2s ease; }
    .ddi-tour__spotlight::after { animation: none; }
}

/* ------------------------------------------------------------------ the card */

.ddi-tour__card {
    position: fixed;
    width: 380px;
    max-width: calc(100vw - 24px);
    pointer-events: auto;
    display: flex;
    flex-direction: column;
    padding: 14px 16px 12px 16px;
    border-radius: var(--mud-default-borderradius);
    border: 1px solid var(--mud-palette-lines-default);
    background-color: var(--mud-palette-surface);
    color: var(--mud-palette-text-primary);
    box-shadow: 0 12px 32px rgba(15, 21, 31, .28);
    font-family: var(--mud-typography-body1-family, inherit);
    animation: ddi-tour-appear .18s ease-out;
}

.ddi-tour__card:focus { outline: none; }

@keyframes ddi-tour-appear {
    from { opacity: 0; transform: translateY(4px); }
    to   { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
    .ddi-tour__card { animation: none; }
}

/* The arrow is the card's own corner turned 45 degrees, so its two visible sides carry the card's border. */
.ddi-tour__arrow {
    position: absolute;
    width: 12px;
    height: 12px;
    background-color: var(--mud-palette-surface);
    border: 1px solid var(--mud-palette-lines-default);
    transform: rotate(45deg);
}

.ddi-tour__card--bottom .ddi-tour__arrow { top: -7px; margin-left: -6px; border-right: none; border-bottom: none; }
.ddi-tour__card--top    .ddi-tour__arrow { bottom: -7px; margin-left: -6px; border-left: none; border-top: none; }
.ddi-tour__card--right  .ddi-tour__arrow { left: -7px; margin-top: -6px; border-right: none; border-top: none; }
.ddi-tour__card--left   .ddi-tour__arrow { right: -7px; margin-top: -6px; border-left: none; border-bottom: none; }

/* A step about the screen as a whole reads as an introduction, so it is given the room to. */
.ddi-tour__card--centred { width: 460px; }

.ddi-tour__head {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

/* Which chapter of the tour this is. */
.ddi-tour__section {
    flex: 0 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    padding: 2px 8px;
    border-radius: 999px;
    background-color: var(--mud-palette-primary-hover);
    color: var(--mud-palette-primary);
    font-size: .6875rem;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
}

.ddi-tour__count {
    margin-left: auto;
    font-size: .6875rem;
    font-variant-numeric: tabular-nums;
    color: var(--mud-palette-text-secondary);
}

.ddi-tour__close {
    flex: 0 0 auto;
    width: 22px;
    height: 22px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: var(--mud-palette-text-secondary);
    font-size: 1.15rem;
    line-height: 1;
    cursor: pointer;
}

.ddi-tour__close:hover { background-color: var(--mud-palette-action-default-hover); }

.ddi-tour__progress {
    height: 3px;
    border-radius: 2px;
    background-color: var(--mud-palette-lines-default);
    overflow: hidden;
}

.ddi-tour__progress-bar {
    height: 100%;
    border-radius: 2px;
    background-color: var(--mud-palette-primary);
    transition: width .25s ease;
}

.ddi-tour__title {
    margin: 10px 0 6px 0;
    font-size: 1.0625rem;
    font-weight: 600;
    line-height: 1.3;
}

/*
    Capped and scrollable. A step that runs long on a laptop screen must not push its own buttons off the
    bottom of the viewport - the reader would have no way to move on but the keyboard.
*/
.ddi-tour__body {
    max-height: min(46vh, 420px);
    overflow-y: auto;
    font-size: .8125rem;
    line-height: 1.5;
    color: var(--mud-palette-text-primary);
}

.ddi-tour__body p { margin: 0 0 8px 0; }
.ddi-tour__body p:last-child { margin-bottom: 0; }

.ddi-tour__list {
    margin: 0 0 8px 0;
    padding-left: 18px;
}

.ddi-tour__list li { margin-bottom: 3px; }

/*
    The two standing questions of every step - why this exists, and what to do with it - set apart from
    the description so they can be found without reading the paragraph again.
*/
.ddi-tour__note {
    margin: 0 0 8px 0;
    padding: 7px 10px;
    border-left: 3px solid var(--mud-palette-primary);
    border-radius: 0 4px 4px 0;
    background-color: var(--mud-palette-background-gray);
}

.ddi-tour__note--how { border-left-color: var(--mud-palette-success); }

.ddi-tour__note-label {
    display: block;
    margin-bottom: 2px;
    font-size: .625rem;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--mud-palette-text-secondary);
}

.ddi-tour__note p { margin: 0; }

.ddi-tour__foot {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 12px;
}

.ddi-tour__spacer { flex: 1 1 auto; }

.ddi-tour__btn {
    padding: 5px 14px;
    border-radius: var(--mud-default-borderradius);
    border: 1px solid var(--mud-palette-lines-default);
    background-color: transparent;
    color: var(--mud-palette-text-primary);
    font-family: inherit;
    font-size: .8125rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color .15s ease, border-color .15s ease;
}

.ddi-tour__btn:hover { background-color: var(--mud-palette-action-default-hover); }

.ddi-tour__btn--primary {
    border-color: var(--mud-palette-primary);
    background-color: var(--mud-palette-primary);
    color: var(--mud-palette-primary-text);
}

.ddi-tour__btn--primary:hover {
    background-color: var(--mud-palette-primary-darken);
    border-color: var(--mud-palette-primary-darken);
}

.ddi-tour__btn--quiet {
    border-color: transparent;
    color: var(--mud-palette-text-secondary);
    font-weight: 500;
}

.ddi-tour__hint {
    margin-top: 8px;
    font-size: .6875rem;
    color: var(--mud-palette-text-disabled);
}

.ddi-tour__hint kbd {
    display: inline-block;
    min-width: 16px;
    padding: 0 4px;
    margin-right: 2px;
    border: 1px solid var(--mud-palette-lines-default);
    border-radius: 3px;
    font-family: inherit;
    font-size: .625rem;
    text-align: center;
}

/* ------------------------------------------------------------------ the button that opens it */

/*
    The mark on the button while the reader has never been through the tour. A dot rather than a word:
    the button already says what it is, and the only thing left to say is that it is worth one click.
*/
.ddi-tour-launch { position: relative; }

.ddi-tour-launch--unseen::after {
    content: "";
    position: absolute;
    top: 2px;
    right: 2px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--mud-palette-error);
    box-shadow: 0 0 0 0 var(--mud-palette-error);
    animation: ddi-tour-dot 2s ease-out infinite;
}

@keyframes ddi-tour-dot {
    0%   { box-shadow: 0 0 0 0 rgba(244, 67, 54, .6); }
    70%  { box-shadow: 0 0 0 7px rgba(244, 67, 54, 0); }
    100% { box-shadow: 0 0 0 0 rgba(244, 67, 54, 0); }
}

@media (prefers-reduced-motion: reduce) {
    .ddi-tour-launch--unseen::after { animation: none; }
}
