/* ===================================================================
   The Chat page (src/pages/chat.html, scripts/chat.js): small HTML recreations of the app's Chat screen, so they can move.
   Shared look (frame, chips, dots, sections, FAQ, call to action): style/pages.css.

   big animation .... .ch-live > .app-body.ch-body: .ch-bar (filters) and .ch-cols (list | conversation | visitor activity)
   small ones ....... .ch-demo (a card in a split row): the list, the conversation, the activity, the customer's site (.ch-demo-site)
   pieces ........... .ch-box .ch-list > .ch-row (.is-out folds it away, .is-on = open) .ch-msgs > .ch-msg (.is-team|.is-visitor)
                      .ch-act > .ch-facts + .ch-tl > .ch-step .ch-cursor (.is-press)
   =================================================================== */

.ch-sprite {
    position: absolute;
    width: 0;
    height: 0;
    overflow: hidden;
}

/* ---------- the big animation ---------- */

.ch-body {
    display: grid;
    gap: 12px;
    padding: clamp(12px, 1.6vw, 20px);
}

.ch-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    min-height: 34px;
}

.ch-add {
    display: inline-flex;
    align-items: center;
    gap: 5px;

    min-height: 30px;
    padding-inline: 12px;

    border: 1px dashed var(--color-border);
    border-radius: 999px;
    background: var(--color-bg);

    font-size: 13px;
    font-weight: 700;
    color: var(--color-text-soft);
    white-space: nowrap;
}

:root[data-theme="dark"] .ch-add {
    background: var(--color-bg-soft);
}

.ch-add.is-hover {
    border-color: color-mix(in srgb, var(--color-green) 55%, var(--color-border));
    color: var(--color-text);
}

/* a filter chip appears when it is set */
.ch-fchip {
    display: none;
}

.ch-fchip.is-set {
    display: inline-flex;
    animation: ch-in .32s var(--ease) both;
}

.ch-fchip-k {
    font-weight: 600;
    color: var(--color-text-quiet);
}

/* a website chip: on = the website's visitors are in the list */
.ch-wchip {
    cursor: default;
}

.ch-wchip:not(.is-on) {
    color: var(--color-text-quiet);
}

.ch-wchip:not(.is-on) .site-dot {
    opacity: .4;
}

.ch-cols {
    display: grid;
    grid-template-columns: minmax(200px, .95fr) minmax(0, 1.5fr) minmax(190px, 1fr);
    gap: 12px;
    height: 372px;
}

.ch-box {
    position: relative;
    min-width: 0;
    overflow: hidden;

    border: 1px solid var(--color-border-soft);
    border-radius: 14px;
    background: var(--color-bg);
    box-shadow: var(--shadow-sm);
}

:root[data-theme="dark"] .ch-box {
    border-color: var(--color-border);
    background: var(--color-bg-soft);
}

/* ---------- the list of visitors ---------- */

.ch-side {
    display: flex;
    flex-direction: column;
}

.ch-tabs {
    display: flex;
    gap: 4px;
    padding: 8px 10px 0;

    border-bottom: 1px solid var(--color-border-soft);

    font-size: 13px;
    font-weight: 700;
    color: var(--color-text-quiet);
}

:root[data-theme="dark"] .ch-tabs {
    border-bottom-color: var(--color-border);
}

.ch-tab {
    margin-bottom: -1px;
    padding: 6px 8px 8px;
    border-bottom: 2px solid transparent;
    white-space: nowrap;
}

.ch-tab.is-on {
    color: var(--color-text);
    border-bottom-color: var(--color-green);
}

.ch-tab-n {
    display: inline-block;
    margin-inline-start: 4px;
    padding: 1px 7px;

    border-radius: 999px;
    background: var(--color-green-soft);

    font-size: 11.5px;
    font-variant-numeric: tabular-nums;
    color: var(--green-text);
}

.ch-list {
    flex: 1;
    min-height: 0;
    overflow: hidden;
    list-style: none;
}

.ch-row {
    display: grid;
    grid-template-columns: 10px minmax(0, 1fr) auto;
    gap: 10px;
    align-items: center;

    height: 52px;
    padding: 0 12px;
    overflow: hidden;

    border-bottom: 1px solid var(--color-border-soft);

    transition: height .45s var(--ease), opacity .3s ease, background-color .2s ease, border-color .45s ease;
}

:root[data-theme="dark"] .ch-row {
    border-bottom-color: var(--color-border);
}

.ch-row.is-out {
    height: 0;
    opacity: 0;
    border-bottom-width: 0;
}

.ch-row.is-on {
    background: var(--color-green-soft);
}

.ch-row-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--site, var(--color-green));
}

.ch-row-main {
    min-width: 0;
}

.ch-row-place {
    display: flex;
    align-items: center;
    gap: 6px;

    font-size: 13px;
    font-weight: 700;
    line-height: 1.3;
}

.ch-row-what {
    display: block;
    margin-top: 1px;
    overflow: hidden;

    font-size: 12px;
    line-height: 1.3;
    color: var(--color-text-quiet);
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ch-row-meta {
    text-align: end;
    font-size: 12px;
    line-height: 1.3;
    color: var(--color-text-quiet);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.ch-row-meta b {
    display: block;
    font-size: 12.5px;
    font-weight: 700;
    color: var(--color-text);
}

.ch-cc {
    flex: none;
    padding: 1px 5px;

    border: 1px solid var(--color-border);
    border-radius: 5px;
    background: var(--color-bg-soft);

    font-size: 10.5px;
    font-weight: 800;
    letter-spacing: .04em;
    line-height: 1.35;
    color: var(--color-text-soft);
}

.is-bump {
    animation: ch-bump .4s var(--ease);
}

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

.ch-detail {
    display: flex;
    flex-direction: column;
}

.ch-empty {
    margin: auto;
    padding: 24px;
    max-width: 30ch;

    text-align: center;
    font-size: 14px;
    line-height: 1.5;
    color: var(--color-text-quiet);
}

.ch-empty-ico {
    display: grid;
    place-items: center;

    width: 44px;
    height: 44px;
    margin: 0 auto 10px;

    border-radius: 50%;
    background: var(--color-green-soft);
    color: var(--green-text);
}

.ch-empty-ico svg {
    width: 22px;
    height: 22px;
}

.ch-open {
    display: flex;
    flex: 1;
    flex-direction: column;
    min-height: 0;
}

.ch-detail:not(.is-open) .ch-open,
.ch-detail.is-open .ch-empty {
    display: none;
}

.ch-who {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;

    border-bottom: 1px solid var(--color-border-soft);

    font-size: 14px;
}

:root[data-theme="dark"] .ch-who {
    border-bottom-color: var(--color-border);
}

.ch-online {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-inline-start: auto;

    font-size: 12px;
    font-weight: 700;
    color: var(--green-text);
}

.ch-msgs {
    display: flex;
    flex: 1;
    flex-direction: column;
    justify-content: flex-end;
    gap: 8px;
    min-height: 0;
    padding: 12px 14px;
    overflow: hidden;
}

.ch-msg {
    display: flex;
    flex-direction: column;
    gap: 2px;
    max-width: 86%;

    animation: ch-pop .32s var(--ease) both;
}

.ch-msg.is-team {
    align-self: flex-end;
    align-items: flex-end;
}

.ch-msg.is-visitor {
    align-self: flex-start;
    align-items: flex-start;
}

.ch-msg-by {
    font-size: 11px;
    font-weight: 700;
    color: var(--color-text-quiet);
}

.ch-bub {
    padding: 8px 12px;
    border-radius: 14px;

    font-size: 13.5px;
    line-height: 1.4;
    overflow-wrap: anywhere;
}

.is-team .ch-bub {
    border-end-end-radius: 4px;
    background: var(--color-green);
    color: var(--color-green-ink);
}

.is-visitor .ch-bub {
    border: 1px solid var(--color-border-soft);
    border-end-start-radius: 4px;
    background: var(--color-bg-soft);
}

:root[data-theme="dark"] .is-visitor .ch-bub {
    border-color: var(--color-border);
    background: var(--color-bg);
}

/* the three dots of "writing…" */
.ch-typing .ch-bub {
    display: inline-flex;
    gap: 4px;
    padding: 12px 14px;
}

.ch-typing i {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--color-text-muted);
    animation: ch-dot 1.1s ease-in-out infinite;
}

.ch-typing i:nth-child(2) { animation-delay: .15s; }
.ch-typing i:nth-child(3) { animation-delay: .3s; }

.ch-compose {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;

    border-top: 1px solid var(--color-border-soft);
}

:root[data-theme="dark"] .ch-compose {
    border-top-color: var(--color-border);
}

.ch-field {
    display: flex;
    align-items: center;
    flex: 1;
    min-width: 0;
    min-height: 34px;
    padding-inline: 12px;
    overflow: hidden;

    border: 1px solid var(--color-border);
    border-radius: 10px;

    font-size: 13px;
    color: var(--color-text-quiet);
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ch-field.is-text {
    color: var(--color-text);
}

.ch-send {
    display: inline-flex;
    align-items: center;
    gap: 6px;

    min-height: 34px;
    padding-inline: 12px;

    border-radius: 10px;
    background: var(--color-green);

    font-size: 13px;
    font-weight: 800;
    color: var(--color-green-ink);
    transition: transform .15s ease;
}

.ch-send svg {
    width: 15px;
    height: 15px;
}

.ch-send.is-hover,
.ch-tplbtn.is-hover {
    transform: scale(.94);
}

.ch-tplbtn {
    display: grid;
    flex: none;
    place-items: center;

    width: 34px;
    height: 34px;

    border: 1px solid var(--color-border);
    border-radius: 10px;
    color: var(--color-text-soft);
    transition: border-color .2s ease, transform .15s ease;
}

.ch-tplbtn.is-hover {
    border-color: color-mix(in srgb, var(--color-green) 55%, var(--color-border));
}

.ch-tplbtn svg {
    width: 17px;
    height: 17px;
}

/* the saved sentences: they open above the field */
.ch-tpls {
    position: absolute;
    z-index: 2;
    inset-inline: 12px;
    bottom: 58px;

    display: grid;
    gap: 6px;
    padding: 8px;

    border: 1px solid var(--color-border);
    border-radius: 12px;
    background: var(--color-bg);
    box-shadow: var(--shadow-md);

    opacity: 0;
    transform: translateY(8px);
    pointer-events: none;
    transition: opacity .2s ease, transform .25s var(--ease);
}

:root[data-theme="dark"] .ch-tpls {
    background: var(--color-bg-soft);
}

.ch-tpls.is-open {
    opacity: 1;
    transform: none;
}

.ch-tpl {
    padding: 7px 10px;

    border: 1px solid transparent;
    border-radius: 8px;
    background: var(--color-bg-soft);

    font-size: 13px;
    line-height: 1.35;
    transition: background-color .2s ease, border-color .2s ease;
}

:root[data-theme="dark"] .ch-tpl {
    background: var(--color-bg);
}

.ch-tpl.is-hover {
    border-color: color-mix(in srgb, var(--color-green) 55%, var(--color-border));
    background: var(--color-green-soft);
}

/* ---------- what the visitor did ---------- */

.ch-act {
    display: flex;
    flex-direction: column;
    padding: 12px 14px;
}

/* with nobody open the panel only waits: its title shows, the rest comes in when a visitor is picked */
.ch-act > :not(.ch-act-t) {
    opacity: 0;
    transition: opacity .4s ease;
}

.ch-act.is-shown > :not(.ch-act-t),
.ch-demo .ch-act > * {
    opacity: 1;
}

.ch-act-t {
    margin-bottom: 10px;

    font-size: 13px;
    font-weight: 800;
}

.ch-facts {
    display: grid;
    gap: 7px;
    padding-bottom: 10px;
    list-style: none;

    border-bottom: 1px solid var(--color-border-soft);

    font-size: 12.5px;
    line-height: 1.3;
}

:root[data-theme="dark"] .ch-facts {
    border-bottom-color: var(--color-border);
}

.ch-facts li {
    display: flex;
    justify-content: space-between;
    gap: 10px;
}

.ch-facts span {
    flex: none;
    color: var(--color-text-quiet);
}

.ch-facts b {
    min-width: 0;
    overflow: hidden;

    font-weight: 700;
    text-align: end;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ch-ret {
    align-self: flex-start;
    margin-top: 10px;
    padding: 3px 10px;

    border-radius: 999px;
    background: var(--color-green-soft);

    font-size: 12px;
    font-weight: 700;
    color: var(--green-text);
}

.ch-tl {
    display: flex;
    flex: 1;
    flex-direction: column;
    min-height: 0;
    margin-top: 12px;
    overflow: hidden;
    list-style: none;
}

.ch-step {
    position: relative;
    padding: 0 0 12px;
    padding-inline-start: 20px;

    font-size: 12.5px;
    line-height: 1.35;

    animation: ch-in .4s var(--ease) both;
}

.ch-step::before {
    content: "";
    position: absolute;
    inset-inline-start: 0;
    top: 3px;

    width: 10px;
    height: 10px;

    border-radius: 50%;
    background: var(--color-green);
    box-shadow: 0 0 0 3px var(--color-green-soft);
}

.ch-step::after {
    content: "";
    position: absolute;
    inset-inline-start: 4.5px;
    top: 17px;
    bottom: -3px;

    width: 1px;
    background: var(--color-border);
}

.ch-step:last-child::after {
    display: none;
}

.ch-step b {
    display: block;
    overflow: hidden;

    font-weight: 700;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ch-step span {
    display: block;
    font-size: 12px;
    color: var(--color-text-quiet);
}

/* paths, file names and values such as "/pricing" keep their own direction inside a right-to-left page (a path would read "pricing/") */
.ch-row-what,
.ch-fchip b,
.ch-step b,
.ch-step span,
.ch-facts b {
    unicode-bidi: plaintext;
}

/* ---------- the pointer ---------- */

.ch-cursor {
    position: absolute;
    z-index: 5;
    left: 60%;
    top: 100%;

    width: 22px;
    height: 22px;
    margin: -3px 0 0 -4px;

    color: #0b1120;
    pointer-events: none;
    filter: drop-shadow(0 2px 3px rgba(0, 0, 0, .3));

    transition: left .9s var(--ease), top .9s var(--ease), transform .15s ease;
}

.ch-cursor.is-press {
    transform: scale(.85);
}

/* ---------- the small animations in the split rows ---------- */

.ch-demo {
    position: relative;
    display: grid;
    gap: 10px;
    align-content: start;
    padding: clamp(12px, 1.6vw, 18px);
    overflow: hidden;

    border: 1px solid var(--color-border);
    border-radius: clamp(14px, 1.6vw, 20px);
    background: var(--color-bg-soft);
    box-shadow:
        0 28px 60px -32px rgba(5, 46, 22, .4),
        0 10px 24px -14px rgba(15, 23, 42, .18);
}

:root[data-theme="dark"] .ch-demo {
    background: var(--color-bg);
    box-shadow:
        0 28px 60px -28px rgba(0, 0, 0, .75),
        0 0 0 1px rgba(255, 255, 255, .03);
}

.ch-demo .ch-list {
    flex: none;
    height: 312px;
}

.ch-talk .ch-detail {
    height: 372px;
}

.ch-demo-act .ch-act {
    height: 352px;
}

/* the customer's site, with the chat window sliding up in the corner */
.ch-demo-site {
    padding: 0;
    gap: 0;
}

.ch-page {
    position: relative;
    height: 340px;
    padding: 16px 18px;
    overflow: hidden;
    background: var(--color-bg);
}

.ch-page-nav {
    display: flex;
    align-items: center;
    gap: 10px;
}

.ch-page-nav b {
    margin-inline-end: auto;
    font-size: 14px;
    font-weight: 800;
    color: var(--site-bluelake);
}

.ch-page-nav i {
    width: 34px;
    height: 8px;
    border-radius: 4px;
    background: var(--color-border);
}

.ch-page-hero {
    display: grid;
    align-content: center;
    gap: 9px;
    height: 104px;
    margin-top: 16px;
    padding: 0 16px;

    border-radius: 12px;
    background: color-mix(in srgb, var(--site-bluelake) 14%, var(--color-bg));
}

.ch-page-hero i {
    height: 10px;
    border-radius: 5px;
    background: color-mix(in srgb, var(--site-bluelake) 42%, var(--color-bg));
}

.ch-page-hero i:nth-child(1) { width: 62%; }
.ch-page-hero i:nth-child(2) { width: 40%; }
.ch-page-hero i:nth-child(3) { width: 24%; height: 18px; background: var(--site-bluelake); }

.ch-page-cards {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    margin-top: 14px;
}

.ch-page-cards i {
    height: 74px;
    border: 1px solid var(--color-border-soft);
    border-radius: 10px;
    background: var(--color-bg-soft);
}

.ch-win {
    position: absolute;
    z-index: 2;
    inset-inline-end: 14px;
    bottom: 14px;

    display: flex;
    flex-direction: column;
    width: min(260px, 66%);
    overflow: hidden;

    border: 1px solid var(--color-border);
    border-radius: 14px;
    background: var(--color-bg);
    box-shadow: var(--shadow-lg);

    opacity: 0;
    transform: translateY(115%);
    transition: transform .6s var(--ease), opacity .4s ease;
}

.ch-win.is-open {
    opacity: 1;
    transform: none;
}

.ch-win .ch-msgs {
    flex: none;
    height: 142px;
}

.ch-win-head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;

    background: var(--color-green);
    color: var(--color-green-ink);
}

.ch-avatar {
    display: grid;
    flex: none;
    place-items: center;

    width: 30px;
    height: 30px;

    border-radius: 50%;
    background: rgba(255, 255, 255, .55);

    font-size: 14px;
    font-weight: 800;
}

.ch-win-who b {
    display: block;
    font-size: 13.5px;
    line-height: 1.2;
}

.ch-win-who .ch-online {
    margin: 0;
    font-size: 11.5px;
    color: inherit;
}

.ch-win-who .live-dot {
    background: var(--color-green-ink);
}

.ch-win-who .live-dot::after {
    border-color: var(--color-green-ink);
}

/* the link under the list of good-to-know points */
.know-more {
    max-width: 820px;
    margin: 22px auto 0;
    text-align: center;
}

/* ---------- keyframes ---------- */

@keyframes ch-in {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: none; }
}

@keyframes ch-pop {
    from { opacity: 0; transform: translateY(8px) scale(.96); }
    to { opacity: 1; transform: none; }
}

@keyframes ch-dot {
    0%, 70%, 100% { opacity: .35; transform: translateY(0); }
    35% { opacity: 1; transform: translateY(-3px); }
}

@keyframes ch-bump {
    0% { transform: scale(1); }
    40% { transform: scale(1.18); }
    100% { transform: scale(1); }
}

/* ---------- narrow screens ---------- */

@media (max-width: 980px) {

    .ch-cols {
        grid-template-columns: minmax(180px, .9fr) minmax(0, 1.4fr);
    }

    .ch-live .ch-act {
        display: none;
    }
}

@media (max-width: 640px) {

    .ch-cols {
        grid-template-columns: minmax(0, 1fr);
        height: auto;
    }

    .ch-live .ch-side {
        height: 214px;
    }

    .ch-live .ch-detail {
        height: 300px;
    }

    .ch-talk .ch-detail {
        height: 340px;
    }
}

/* the calm picture (reduce motion, or "Pause animations" before it ever played): nothing moves, nothing is half-drawn */
.ch-still *,
.ch-still *::before,
.ch-still *::after {
    animation: none !important;
    transition: none !important;
}

.ch-still .ch-cursor {
    display: none;
}

@media (prefers-reduced-motion: reduce) {

    .ch-live *,
    .ch-demo * {
        animation: none !important;
        transition: none !important;
    }

    .ch-cursor {
        display: none;
    }
}
