/* ---------------------------------------------------------------- the AI assistant (js/Common/AiChat.js) */

/* on the pages of _Layout the buttons [data-ai-chat] open it : its floating button is out of the screen. While the chat is opened but its page
   is not shown yet (loading, or failed) its button and its message come back (body.ai-chat-open); mobile-nav.css puts them over the bottom bar.
   Its shadow root sets everything with !important, only its --rw-edge variable (bottom and right) can be set from the page */
body.ai-chat-inline [data-rag-widget]:not([data-open]) {
    --rw-edge: -200px;
}

body.ai-chat-inline.ai-chat-open [data-rag-widget]:not([data-open]) {
    --rw-edge: 24px;
}

.ai-chat-icon {
    flex: 0 0 auto;
    width: 24px;
    height: 24px;
    color: #3699FF;
    overflow: visible;
}

.ai-chat-twinkle {
    fill: #FFA800;
    transform-box: fill-box;
    transform-origin: center;
    animation: aii-twinkle 2.4s ease-in-out infinite;
}

.vnav-tool .ai-chat-icon {
    width: 22px;
    height: 22px;
}

@keyframes aii-twinkle {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: .55; transform: scale(.8); }
}

/* ---------------------------------------------------------------- its introduction (js/Common/AiIntro.js, Views/Shared/common/_AiIntro.cshtml)
   --x, --y : the middle of the button of the assistant; data-step : dark, beat, tense, boom, card */
body.ai-intro-on {
    overflow: hidden;
}

.ai-intro {
    position: fixed;
    inset: 0;
    z-index: 1070;
    --accent: #3699FF;
}

.ai-intro.is-closing {
    animation: aii-fade-out .3s ease forwards;
}

.ai-intro-spot {
    position: absolute;
    left: calc(var(--x) - 38px);
    top: calc(var(--y) - 38px);
    width: 76px;
    height: 76px;
    border-radius: 50%;
    box-shadow: 0 0 0 200vmax rgba(10, 12, 26, .78);
    pointer-events: none;
    animation: aii-spot-in 1.2s cubic-bezier(.3, .8, .3, 1) both;
}

.ai-intro[data-step="tense"] .ai-intro-spot {
    animation: aii-spot-tight .9s ease-in both;
}

.ai-intro[data-step="boom"] .ai-intro-spot,
.ai-intro[data-step="card"] .ai-intro-spot {
    animation: aii-spot-release .9s cubic-bezier(.2, 1.6, .4, 1) both;
}

.ai-intro-ring {
    position: absolute;
    left: calc(var(--x) - 34px);
    top: calc(var(--y) - 34px);
    width: 68px;
    height: 68px;
    border-radius: 50%;
    border: 2px solid var(--accent);
    pointer-events: none;
    animation: aii-ring 1.8s ease-out infinite;
}

.ai-intro[data-step="tense"] .ai-intro-ring {
    display: none;
}

/* the old icon of the support chat, over the button (its own icon is hidden) */
.ai-intro-ghost {
    display: none;
    position: absolute;
    left: calc(var(--x) - 22px);
    top: calc(var(--y) - 22px);
    width: 44px;
    height: 44px;
    align-items: center;
    justify-content: center;
    color: #3699FF;
    pointer-events: none;
}

.ai-intro.is-existing:not([data-step="card"]) .ai-intro-ghost {
    display: flex;
}

.ai-intro-ghost svg {
    width: 26px;
    height: 26px;
}

.ai-intro-target.ai-intro-hide .ai-chat-icon {
    visibility: hidden;
}

.ai-intro-target.ai-intro-in .ai-chat-icon {
    animation: aii-new-in .8s cubic-bezier(.2, 1.6, .4, 1) both;
}

.ai-intro-target.ai-intro-live .ai-chat-icon {
    animation: aii-lubdub 1.6s ease-in-out infinite;
}

.ai-intro-beat {
    animation: aii-beat 2s ease-in-out both;
}

.ai-intro-shake {
    animation: aii-shake .9s linear both;
}

.ai-intro-pop {
    animation: aii-pop .8s cubic-bezier(.2, 1.8, .4, 1) both;
}

.ai-intro-out {
    animation: aii-old-out .5s ease-in forwards;
}

/* the burst : a flash, two shock waves and the dots */
.ai-intro-fx {
    position: absolute;
    left: var(--x);
    top: var(--y);
    width: 0;
    height: 0;
    pointer-events: none;
}

.ai-intro-flash {
    position: absolute;
    left: -60px;
    top: -60px;
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: radial-gradient(circle, #FFFFFF 0%, rgba(255, 255, 255, 0) 70%);
    animation: aii-flash .6s ease-out both;
}

.ai-intro-shock {
    position: absolute;
    left: -27px;
    top: -27px;
    width: 54px;
    height: 54px;
    border-radius: 50%;
    border: 3px solid #FFFFFF;
    box-sizing: border-box;
    animation: aii-shock .9s cubic-bezier(.1, .8, .3, 1) both;
}

.ai-intro-shock-2 {
    border-color: var(--accent);
    animation-delay: .18s;
}

.ai-intro-ray {
    position: absolute;
    left: 0;
    top: 0;
}

.ai-intro-dot {
    position: absolute;
    width: 7px;
    height: 7px;
    margin: -3.5px;
    border-radius: 50%;
    animation: aii-ray .9s ease-out both;
}

.ai-intro-dot.is-far {
    width: 5px;
    height: 5px;
    margin: -2.5px;
    animation-name: aii-ray-far;
    animation-duration: 1.2s;
}

.ai-intro-caption {
    position: absolute;
    left: 16px;
    right: 16px;
    top: calc(var(--y) + 56px);
    text-align: center;
    color: #FFFFFF;
    font-size: 20px;
    font-weight: 800;
    pointer-events: none;
    animation: aii-fade-in .5s ease .3s both;
}

.ai-intro[data-step="boom"] .ai-intro-caption,
.ai-intro[data-step="card"] .ai-intro-caption {
    display: none;
}

.ai-intro-cap-dot {
    animation: aii-cap-dot 1.2s ease-in-out infinite;
}

.ai-intro-cap-dot:nth-child(3) { animation-delay: .2s; }
.ai-intro-cap-dot:nth-child(4) { animation-delay: .4s; }

.ai-intro-skip {
    position: absolute;
    bottom: calc(24px + env(safe-area-inset-bottom));
    left: 50%;
    transform: translateX(-50%);
    height: 44px;
    padding: 0 20px;
    border: 1px solid rgba(255, 255, 255, .35);
    border-radius: 22px;
    background: transparent;
    color: #FFFFFF;
    font-size: 14px;
    cursor: pointer;
    opacity: .8;
}

.ai-intro-skip:hover,
.ai-intro-skip:focus-visible {
    opacity: 1;
    background: rgba(255, 255, 255, .12);
}

.ai-intro[data-step="card"] .ai-intro-skip {
    display: none;
}

/* the card : under the button, or a sheet at the bottom on the phones */
.ai-intro-card {
    position: absolute;
    width: min(420px, calc(100vw - 32px));
    box-sizing: border-box;
    padding: 24px;
    border-radius: 18px;
    background: #FFFFFF;
    color: #181C32;
    box-shadow: 0 24px 60px rgba(0, 0, 0, .35);
    display: flex;
    flex-direction: column;
    gap: 14px;
    animation: aii-card-in .55s cubic-bezier(.2, 1.25, .4, 1) both;
}

.ai-intro-card[hidden] {
    display: none;
}

.ai-intro-arrow {
    position: absolute;
    left: var(--arrow, 72px);
    top: -8px;
    width: 18px;
    height: 18px;
    border-radius: 3px;
    background: inherit;
    transform: rotate(45deg);
}

.ai-intro.is-sheet .ai-intro-card {
    left: 0 !important;
    right: 0;
    bottom: 0;
    top: auto !important;
    width: auto;
    max-height: calc(100% - var(--y) - 40px);
    overflow-y: auto;
    padding: 22px 20px calc(22px + env(safe-area-inset-bottom));
    border-radius: 24px 24px 0 0;
    animation: aii-sheet-up .55s cubic-bezier(.2, 1.15, .4, 1) both;
}

.ai-intro.is-sheet .ai-intro-arrow {
    display: none;
}

.ai-intro-head {
    display: flex;
    align-items: center;
    gap: 12px;
}

.ai-intro-logo {
    width: 46px;
    height: 46px;
    border-radius: 14px;
    background: var(--accent);
    color: #FFFFFF;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ai-intro-logo .ai-chat-twinkle {
    fill: #FFE2A8;
}

.ai-intro-badge {
    padding: 4px 12px;
    border-radius: 20px;
    background: #FFF4DE;
    color: #8A5A00;
    font-size: 13px;
    font-weight: 700;
}

.ai-intro-text h2 {
    margin: 0 0 6px;
    font-size: 22px;
    font-weight: 800;
    line-height: 1.5;
    color: inherit;
}

.ai-intro-text p {
    margin: 0;
    font-size: 14.5px;
    line-height: 1.95;
    color: #3F4254;
}

.ai-intro-demo {
    min-height: 132px;
    box-sizing: border-box;
    padding: 12px;
    border-radius: 14px;
    background: #F3F6F9;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.ai-intro-q,
.ai-intro-a,
.ai-intro-dots {
    max-width: 88%;
    padding: 8px 14px;
    font-size: 13.5px;
    line-height: 1.8;
}

.ai-intro-q {
    align-self: flex-start;
    border-radius: 14px 14px 4px 14px;
    background: var(--accent);
    color: #FFFFFF;
}

.ai-intro-a,
.ai-intro-dots {
    align-self: flex-end;
    border-radius: 14px 14px 14px 4px;
    background: #FFFFFF;
    color: #181C32;
}

.ai-intro-dots {
    display: flex;
    gap: 5px;
    padding: 12px 16px;
}

.ai-intro-dots[hidden],
.ai-intro-q[hidden],
.ai-intro-a[hidden] {
    display: none;
}

.ai-intro-dots span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #A1A5B7;
    animation: aii-bounce 1s ease-in-out infinite;
}

.ai-intro-dots span:nth-child(2) { animation-delay: .15s; }
.ai-intro-dots span:nth-child(3) { animation-delay: .3s; }

.ai-intro-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.ai-intro-cta {
    flex: 1 1 auto;
    height: 48px;
    border: 0;
    border-radius: 12px;
    background: var(--accent);
    color: #FFFFFF;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    transition: transform .15s ease, box-shadow .15s ease;
}

.ai-intro-cta:hover,
.ai-intro-cta:focus-visible {
    transform: translateY(-1px);
    box-shadow: 0 10px 24px rgba(54, 153, 255, .35);
}

.ai-intro-later {
    height: 48px;
    padding: 0 18px;
    border: 0;
    border-radius: 12px;
    background: transparent;
    color: #5E6278;
    font-size: 15px;
    cursor: pointer;
}

.ai-intro-later:hover,
.ai-intro-later:focus-visible {
    background: #F3F6F9;
}

.ai-intro-note {
    font-size: 12.5px;
    color: #5E6278;
    text-align: center;
}

html[data-theme="dark"] .ai-intro-card { background: #1E1E2D; color: #FFFFFF; }
html[data-theme="dark"] .ai-intro-text p,
html[data-theme="dark"] .ai-intro-note,
html[data-theme="dark"] .ai-intro-later { color: #B5B5C3; }
html[data-theme="dark"] .ai-intro-demo { background: #151521; }
html[data-theme="dark"] .ai-intro-a,
html[data-theme="dark"] .ai-intro-dots { background: #2B2B40; color: #FFFFFF; }
html[data-theme="dark"] .ai-intro-later:hover { background: #2B2B40; }

@media (prefers-reduced-motion: reduce) {
    .ai-intro *,
    .ai-intro-target,
    .ai-intro-target .ai-chat-icon,
    .ai-chat-twinkle {
        animation-duration: .01s !important;
        animation-iteration-count: 1 !important;
        animation-delay: 0s !important;
    }
}

@keyframes aii-spot-in { from { transform: scale(5); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes aii-spot-tight { from { transform: scale(1); } to { transform: scale(.78); } }
@keyframes aii-spot-release { 0% { transform: scale(.78); } 40% { transform: scale(1.35); } 100% { transform: scale(1.1); } }
@keyframes aii-ring { 0% { transform: scale(.9); opacity: .9; } 100% { transform: scale(1.9); opacity: 0; } }
@keyframes aii-beat {
    0%, 100% { transform: scale(1); }
    7% { transform: scale(1.16); }
    12% { transform: scale(1); }
    18% { transform: scale(1.1); }
    25%, 42% { transform: scale(1); }
    49% { transform: scale(1.24); }
    54% { transform: scale(1); }
    60% { transform: scale(1.16); }
    66%, 78% { transform: scale(1); }
    83% { transform: scale(1.34); }
    87% { transform: scale(1.02); }
    91% { transform: scale(1.26); }
    96% { transform: scale(1); }
}
@keyframes aii-shake {
    0% { transform: none; }
    10% { transform: translateX(-1px) rotate(-2deg); }
    20% { transform: translateX(1px) rotate(2deg); }
    30% { transform: translateX(-2px) rotate(-4deg); }
    40% { transform: translateX(2px) rotate(4deg); }
    50% { transform: translateX(-3px) rotate(-6deg) scale(1.05); }
    60% { transform: translateX(3px) rotate(6deg) scale(1.08); }
    70% { transform: translateX(-4px) rotate(-9deg) scale(1.1); }
    80% { transform: translateX(4px) rotate(9deg) scale(1.14); }
    90% { transform: translateX(-4px) rotate(-11deg) scale(1.18); }
    100% { transform: scale(1.2); }
}
@keyframes aii-pop { 0% { transform: scale(1.2); } 35% { transform: scale(1.6) rotate(25deg); } 100% { transform: none; } }
@keyframes aii-old-out { from { transform: scale(1.2); } to { transform: scale(0) rotate(-120deg); opacity: 0; } }
@keyframes aii-new-in { from { transform: scale(0) rotate(120deg); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes aii-lubdub { 0%, 40%, 100% { transform: scale(1); } 10% { transform: scale(1.14); } 20% { transform: scale(1); } 30% { transform: scale(1.08); } }
@keyframes aii-flash { 0% { transform: scale(.2); opacity: 0; } 25% { transform: scale(1); opacity: 1; } 100% { transform: scale(1.6); opacity: 0; } }
@keyframes aii-shock { from { transform: scale(.3); opacity: 1; } to { transform: scale(5); opacity: 0; border-width: 1px; } }
@keyframes aii-ray { 0% { transform: translateY(0) scale(.3); opacity: 0; } 25% { opacity: 1; } 100% { transform: translateY(-54px) scale(1); opacity: 0; } }
@keyframes aii-ray-far { 0% { transform: translateY(0) scale(.3); opacity: 0; } 20% { opacity: 1; } 100% { transform: translateY(-110px) scale(.8); opacity: 0; } }
@keyframes aii-fade-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes aii-fade-out { to { opacity: 0; } }
@keyframes aii-cap-dot { 0%, 100% { opacity: .2; } 50% { opacity: 1; } }
@keyframes aii-card-in { from { opacity: 0; transform: translateY(-14px) scale(.95); } to { opacity: 1; transform: none; } }
@keyframes aii-sheet-up { from { transform: translateY(100%); } to { transform: none; } }
@keyframes aii-bounce { 0%, 80%, 100% { transform: translateY(0); opacity: .5; } 40% { transform: translateY(-5px); opacity: 1; } }
