/* VeraChat's header on the product page: one conversation in VeraChat's own colours on the light
   ground of the flow further down the page, its question carried to VeraChat at Veratech and the answer
   carried back. verachat-hero.js plays it; without the script it stands as the finished answer. */

.vch {
    --vch-text: #1A1A1A;
    --vch-panel: #EDF4F5;
    --vch-user: #C6DCE9;
    --vch-primary: #3E7CA2;
    --vch-orange: #F18C34;
    /* The light palette of the flow further down (verachat-flow.css). */
    --vch-bg: #f7f5f2;
    --vch-line: #d9d4cd;
    --vch-muted: #7a746c;
    --vch-orange-soft: #fff1e4;
    --vch-orange-line: #f5c79c;
    --vch-green: #3d7a45;
    container-type: inline-size;
    position: relative;
    aspect-ratio: 1840 / 620;
    overflow: hidden;
    background: var(--vch-bg);
    display: flex;
    align-items: center;
    gap: 0;
    /* The top 18px or so sits under the site's fixed menu, as the other product headers' tops do. */
    padding: calc(1.6cqw + 18px) 2.5cqw 1.6cqw;
    font-family: "Open Sans", "Segoe UI", Arial, sans-serif;
    text-align: left;
}

/* Between the chat and VeraChat: the question going out above, the answer coming back below. */
.vch-wire {
    flex: 1 1 0;
    min-width: 6cqw;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 3.2cqw;
    padding: 0 1.2cqw;
}

/* Drawn as a border rather than a 2px background: border widths snap to whole device pixels, so the
   two lines come out equally thick even where they land on half pixels (e.g. 125 % display scaling). */
.vch-line {
    position: relative;
    height: 0;
    border-top: 2px solid var(--vch-line);
    transition: border-color .3s;
}

    .vch-line span {
        position: absolute;
        bottom: 0.7cqw;
        left: 0;
        right: 0;
        text-align: center;
        font-size: 1.05cqw;
        letter-spacing: .08em;
        text-transform: uppercase;
        color: var(--vch-muted);
        transition: color .3s;
    }

.vch-line i {
    position: absolute;
    top: calc(-0.45cqw - 1px); /* centred on the 2px border above the box */
    width: 0.9cqw;
    height: 0.9cqw;
    border-radius: 50%;
    background: var(--vch-orange);
    box-shadow: 0 0 0 0.3cqw var(--vch-orange-soft);
    opacity: 0;
}

.vch-line.is-active {
    border-top-color: var(--vch-orange);
}

    .vch-line.is-active span {
        color: var(--vch-orange);
    }

.vch-line--out.is-active i { animation: vch-out .7s ease-in-out forwards; }
.vch-line--back.is-active i { animation: vch-back .7s ease-in-out forwards; }

@keyframes vch-out {
    from { left: 0; opacity: 1; }
    to { left: calc(100% - 0.9cqw); opacity: 1; }
}

@keyframes vch-back {
    from { left: calc(100% - 0.9cqw); opacity: 1; }
    to { left: 0; opacity: 1; }
}

/* VeraChat at Veratech, with the documentation the answer is looked up in. */
.vch-server {
    flex: 0 0 24cqw;
    align-self: stretch;
    display: flex;
    flex-direction: column;
    gap: 0.75cqw;
    border: 2px solid var(--vch-line);
    border-radius: 1cqw;
    background: #fff;
    padding: 1.1cqw 1.3cqw;
    color: #333;
    transition: border-color .4s, box-shadow .4s;
}

    .vch-server.is-working {
        border-color: var(--vch-orange);
        background: var(--vch-orange-soft);
        --vch-corner: var(--vch-orange-soft);
        box-shadow: 0 0 0 0.35cqw rgba(241, 140, 52, .15), 0 0.4cqw 1.5cqw rgba(241, 140, 52, .2);
    }

.vch-server-head {
    font-size: 1.5cqw;
    font-weight: 600;
    line-height: 1.2;
}

/* What VeraChat does with the question, one stage after the other while it works. */
.vch-pipeline {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.45cqw;
    font-size: 1.1cqw;
    line-height: 1.3;
}

    .vch-pipeline li {
        display: flex;
        align-items: center;
        gap: 0.6cqw;
        color: var(--vch-muted);
        transition: color .3s;
    }

        .vch-pipeline li::before {
            content: "";
            flex: none;
            box-sizing: border-box;
            width: 1.1cqw;
            height: 1.1cqw;
            border-radius: 50%;
            border: 2px solid var(--vch-line);
            display: grid;
            place-items: center;
            font-size: 0.75cqw;
            font-weight: 700;
            line-height: 1;
        }

        .vch-pipeline li.is-active {
            color: #c9661a;
        }

            .vch-pipeline li.is-active::before {
                border-color: var(--vch-orange);
                border-top-color: transparent;
                animation: vch-spin .7s linear infinite;
            }

        .vch-pipeline li.is-done {
            color: #333;
        }

            .vch-pipeline li.is-done::before {
                content: "✓";
                border-color: var(--vch-green);
                background: var(--vch-green);
                color: #fff;
            }

@keyframes vch-spin {
    to { transform: rotate(360deg); }
}

/* The knowledge base as many small documents: while the search runs a sweep goes over all of them,
   then the few the answer rests on are lit. */
.vch-kb-label {
    margin-top: auto;
    font-size: 0.9cqw;
    letter-spacing: .1em;
    text-transform: uppercase;
    color: var(--vch-muted);
}

.vch-kb {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 0.55cqw 0.6cqw;
}

/* A page with a folded corner and three lines of text. */
.vch-doc {
    position: relative;
    aspect-ratio: 3 / 4;
    border: 1.5px solid var(--vch-line);
    border-radius: 0.2cqw 0.55cqw 0.2cqw 0.2cqw;
    background:
        linear-gradient(var(--vch-line), var(--vch-line)) 22% 38% / 56% 1.5px no-repeat,
        linear-gradient(var(--vch-line), var(--vch-line)) 22% 56% / 56% 1.5px no-repeat,
        linear-gradient(var(--vch-line), var(--vch-line)) 22% 74% / 36% 1.5px no-repeat,
        #fff;
    transition: border-color .4s, background-color .4s, transform .4s;
}

    .vch-doc::after {
        content: "";
        position: absolute;
        top: -1.5px;
        right: -1.5px;
        border-style: solid;
        border-width: 0 0.55cqw 0.55cqw 0;
        border-color: transparent var(--vch-corner, #fff) var(--vch-line) transparent;
        transition: border-color .4s;
    }

.vch-kb.is-scanning .vch-doc {
    animation: vch-scan .9s ease-in-out infinite;
}

    .vch-kb.is-scanning .vch-doc:nth-child(8n+2), .vch-kb.is-scanning .vch-doc:nth-child(8n+6) { animation-delay: .15s; }
    .vch-kb.is-scanning .vch-doc:nth-child(8n+3), .vch-kb.is-scanning .vch-doc:nth-child(8n+7) { animation-delay: .3s; }
    .vch-kb.is-scanning .vch-doc:nth-child(8n+4), .vch-kb.is-scanning .vch-doc:nth-child(8n) { animation-delay: .45s; }

.vch-doc.is-source {
    border-color: var(--vch-orange);
    background-color: var(--vch-orange-soft);
    transform: scale(1.12);
}

    .vch-doc.is-source::after {
        border-color: transparent var(--vch-corner, #fff) var(--vch-orange) transparent;
    }

@keyframes vch-scan {
    0%, 100% { border-color: var(--vch-line); }
    50% { border-color: var(--vch-orange-line); }
}

/* The chat itself, as VeraChat looks inside the customer's system. */
.vch-chat {
    flex: 0 1 52cqw;
    min-width: 0; /* or the typed question, kept on one line, sets the width on a phone */
    align-self: stretch;
    display: flex;
    flex-direction: column;
    background: var(--vch-panel);
    border-radius: 1cqw;
    overflow: hidden;
    border: 1px solid var(--vch-line);
    box-shadow: 0 0.6cqw 2cqw rgba(0, 0, 0, .08);
    font-size: 1.5cqw;
    line-height: 1.6;
    color: var(--vch-text);
}

.vch-head {
    background: #34808A;
    color: #fff;
    font-weight: 600;
    padding: 0.55cqw 1.3cqw;
}

.vch-msgs {
    flex: 1;
    min-height: 0;
    padding: 1.2cqw 1.5cqw 0.4cqw;
    display: flex;
    flex-direction: column;
    /* From the top, as in VeraChat: the question first, the answer under it. */
    justify-content: flex-start;
    transition: opacity .4s;
}

    .vch-msgs.is-clearing {
        opacity: 0;
    }

.vch-user {
    align-self: flex-end;
    max-width: 80%;
    background: var(--vch-user);
    border-radius: 1.2cqw 1.2cqw 0.3cqw 1.2cqw;
    padding: 0.45cqw 1cqw;
    margin-bottom: 0.8cqw;
    animation: vch-in .35s ease-out both;
}

.vch-bot p {
    margin: 0 0 0.4cqw;
    font-family: inherit;
}

.vch-link {
    color: var(--vch-primary);
    text-decoration: underline;
}

.vch-caret::after {
    content: "";
    display: inline-block;
    width: 0.12cqw;
    height: 1.1em;
    margin-left: 1px;
    vertical-align: -0.2em;
    background: currentColor;
    animation: vch-blink 1s steps(1) infinite;
}

.vch-thinking {
    align-self: flex-start;
    font-style: italic;
    background: linear-gradient(90deg, var(--vch-primary) 25%, #fff 50%, var(--vch-primary) 75%);
    background-size: 200% auto;
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: vch-shine 1.6s linear infinite;
    margin-bottom: 0.4cqw;
}

/* Under the answer as in VeraChat (_siteVerachat.scss), scaled from its 15px base to the chat's:
   the thumbs first, then the sources as a link. */
.vch-feedback {
    display: flex;
    align-items: center;
    gap: 0.35em;
    margin-bottom: 0.45em;
    animation: vch-in .35s ease-out both;
}

    .vch-feedback span {
        display: inline-flex;
        align-items: center;
        border: 1px solid rgba(0, 0, 0, .18);
        border-radius: 4px;
        padding: 0.22em 0.47em;
        color: rgba(0, 0, 0, .3);
        font-size: 0.85em;
    }

    .vch-feedback svg {
        width: 1em;
        height: 1em;
        fill: currentColor;
    }

.vch-sources {
    align-self: flex-start;
    font-size: 0.83em;
    color: var(--vch-primary);
    text-decoration: underline;
    text-underline-offset: 2px;
    margin-bottom: 0.6em;
    animation: vch-in .35s ease-out both;
}

.vch-foot {
    display: flex;
    gap: 0.6cqw;
    padding: 0.7cqw 1.2cqw 0.9cqw;
    border-top: 1px solid rgba(0, 0, 0, .07);
}

.vch-input {
    flex: 1;
    min-width: 0;
    background: #fff;
    border: 1px solid rgba(0, 0, 0, .14);
    border-radius: 2cqw;
    padding: 0.35cqw 1.1cqw;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

    .vch-input:empty::before {
        content: attr(data-placeholder);
        color: #A8BFCA;
    }

.vch-send {
    background: var(--vch-primary);
    color: #fff;
    border-radius: 2cqw;
    padding: 0.35cqw 1.4cqw;
    transition: transform .12s, background-color .12s;
}

    .vch-send.is-pressed {
        transform: scale(.92);
        background: #2f6283;
    }

@keyframes vch-in {
    from { opacity: 0; transform: translateY(0.6cqw); }
    to { opacity: 1; transform: none; }
}

@keyframes vch-blink {
    50% { opacity: 0; }
}

@keyframes vch-shine {
    0% { background-position: 200% center; }
    100% { background-position: -200% center; }
}

/* Too narrow for the documents and for text at the banner's own scale: the chat alone, in px. */
@media (max-width: 767px) {
    .vch {
        aspect-ratio: auto;
        height: 260px;
        padding: 14px;
    }

    .vch-wire, .vch-server {
        display: none;
    }

    .vch-chat {
        flex-basis: 100%;
        font-size: 13px;
        border-radius: 8px;
    }

    .vch-head, .vch-msgs, .vch-foot { padding-left: 12px; padding-right: 12px; }
    .vch-user { border-radius: 12px 12px 3px 12px; padding: 4px 10px; margin-bottom: 8px; }
    .vch-input, .vch-send { border-radius: 18px; padding: 3px 12px; }
}

@media (prefers-reduced-motion: reduce) {
    .vch *, .vch *::after { animation: none !important; transition: none !important; }
}
