/* Help widget, bottom right.
 *
 * Theme variables only, so it follows the brand palette. The back-to-top
 * button now lives bottom left, so the two do not collide.
 */

.assistant {
    position: fixed;
    right: 30px;
    bottom: 30px;
    z-index: 1000000;
    font-family: var(--thm-font);
}

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

.assistant-launcher {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-left: auto;
    padding: 14px 22px;
    border: 0;
    border-radius: 40px;
    background-color: var(--thm-primary);
    color: #fff;
    font-size: 15px;
    font-weight: 600;
    box-shadow: 0 10px 30px rgb(0 0 0 / 18%);
    transition: background-color 400ms ease;
    animation: assistantPulse 2.4s infinite ease-out;
}

.assistant-launcher:hover {
    background-color: var(--thm-black);
    /* It has your attention -- stop asking for it. */
    animation-play-state: paused;
}

/* A ring spreading out from the button and fading.
 *
 * Done with box-shadow rather than a pseudo-element: the spread follows the
 * button's own border-radius, so it stays a pill on desktop and a circle on
 * a phone without a second rule. The drop shadow is repeated in every
 * keyframe because animating box-shadow replaces the whole property.
 */
@keyframes assistantPulse {
    0% {
        box-shadow: 0 10px 30px rgb(0 0 0 / 18%),
                    0 0 0 0 rgba(var(--thm-primary-rgb), 0.5);
    }
    70% {
        box-shadow: 0 10px 30px rgb(0 0 0 / 18%),
                    0 0 0 20px rgba(var(--thm-primary-rgb), 0);
    }
    100% {
        box-shadow: 0 10px 30px rgb(0 0 0 / 18%),
                    0 0 0 0 rgba(var(--thm-primary-rgb), 0);
    }
}

.assistant-launcher i {
    font-size: 18px;
}

/* Once the panel is open the button has nothing left to say. */
.assistant.is-open .assistant-launcher {
    display: none;
}

/* --- the panel --- */

.assistant-panel {
    display: flex;
    flex-direction: column;
    width: 370px;
    max-width: calc(100vw - 40px);
    height: 520px;
    max-height: calc(100vh - 120px);
    background-color: #fff;
    box-shadow: 0 20px 60px rgb(0 0 0 / 22%);
    overflow: hidden;
}

.assistant-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 20px;
    background-color: var(--thm-black);
    color: #fff;
}

/* body sets line-height in em, which computes at the body's font size and
 * inherits as a fixed 24px -- leaving the 12px subtitle floating in a line
 * box twice its height. Both need their own line-height to sit together.
 */
.assistant-header strong {
    display: block;
    font-size: 16px;
    line-height: 1.2;
}

.assistant-header span {
    display: block;
    margin-top: 2px;
    font-size: 12px;
    line-height: 1.3;
    opacity: 0.7;
}

.assistant-close {
    flex-shrink: 0;
    padding: 4px 8px;
    border: 0;
    background: none;
    color: #fff;
    font-size: 18px;
    opacity: 0.8;
}

.assistant-close:hover {
    opacity: 1;
}

/* --- the conversation --- */

.assistant-log {
    flex: 1;
    padding: 18px 20px;
    overflow-y: auto;
    background-color: var(--thm-light-bg);
}

.assistant-message {
    margin-bottom: 14px;
    padding: 12px 15px;
    font-size: 14px;
    line-height: 1.6;
}

.assistant-message p {
    margin: 0;
    font-size: 14px;
    line-height: 1.6;
}

.assistant-message-bot {
    background-color: #fff;
    color: var(--thm-gray);
    border-left: 3px solid var(--thm-primary);
}

.assistant-message-user {
    margin-left: auto;
    max-width: 85%;
    background-color: var(--thm-primary);
    color: #fff;
}

.assistant-message-user p {
    color: #fff;
}

/* Links to the pages an answer points at. */
.assistant-links {
    margin: 10px 0 0;
    padding: 0;
    list-style: none;
}

.assistant-links li + li {
    margin-top: 6px;
}

.assistant-links a {
    display: flex;
    align-items: baseline;
    gap: 8px;
    font-size: 14px;
    font-weight: 600;
    color: var(--thm-black);
}

.assistant-links a:hover {
    color: var(--thm-primary);
}

.assistant-links a i {
    flex-shrink: 0;
    font-size: 11px;
    color: var(--thm-primary);
}

/* --- starter questions --- */

.assistant-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 14px;
}

.assistant-suggestion {
    padding: 8px 14px;
    border: 1px solid var(--thm-border);
    border-radius: 30px;
    background-color: #fff;
    color: var(--thm-black);
    font-size: 13px;
    font-weight: 600;
    transition: all 300ms ease;
}

.assistant-suggestion:hover {
    background-color: var(--thm-primary);
    border-color: var(--thm-primary);
    color: #fff;
}

/* --- asking --- */

.assistant-form {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    border-top: 1px solid var(--thm-border);
    background-color: #fff;
}

.assistant-form input {
    flex: 1;
    min-width: 0;
    padding: 10px 14px;
    border: 1px solid var(--thm-border);
    background-color: #fff;
    color: var(--thm-black);
    font-size: 14px;
}

.assistant-form input:focus {
    border-color: var(--thm-primary);
    outline: none;
}

.assistant-form button {
    flex-shrink: 0;
    width: 42px;
    height: 42px;
    border: 0;
    background-color: var(--thm-primary);
    color: #fff;
    transition: background-color 300ms ease;
}

.assistant-form button:hover {
    background-color: var(--thm-black);
}

.assistant-form button:disabled {
    opacity: 0.5;
    cursor: progress;
}

/* The three dots while an answer is on its way. */
.assistant-typing span {
    display: inline-block;
    width: 6px;
    height: 6px;
    margin-right: 3px;
    border-radius: 50%;
    background-color: var(--thm-primary);
    animation: assistantBlink 1.2s infinite ease-in-out both;
}

.assistant-typing span:nth-child(2) { animation-delay: 0.15s; }
.assistant-typing span:nth-child(3) { animation-delay: 0.3s; }

@keyframes assistantBlink {
    0%, 80%, 100% { opacity: 0.25; }
    40% { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
    .assistant-typing span {
        animation: none;
        opacity: 0.6;
    }

    .assistant-launcher {
        animation: none;
    }
}

/* The mobile menu takes over the screen; the widget should not sit on top
 * of it. `locked` is on <body> whenever that drawer is open.
 */
body.locked .assistant {
    display: none;
}

@media (max-width: 575px) {
    .assistant {
        right: 15px;
        bottom: 15px;
    }

    /* On a phone the label costs more room than it earns. */
    .assistant-launcher-label {
        display: none;
    }

    .assistant-launcher {
        padding: 16px 18px;
        border-radius: 50%;
    }
}
