/* Scanny, the free scan chat of the A/B test blog_scan_chat_v1 (js/scan-chat.js): a message thread with a robot.
   Plain CSS, loaded only on posts that run the test, so it needs no Sass build and goes away with the test. */
.scanny-launcher,
.scanny-preview,
.scanny-thread {
    --scanny-ink: #111b21;
    --scanny-muted: #667781;
    --scanny-line: #e9edef;
    --scanny-them: #f0f2f5;
    --scanny-me: #0081ba;
    --scanny-online: #25d366;
    --scanny-glow: #3ce0c0;
    --scanny-navy: #0a2430;
    box-sizing: border-box;
    font-family: 'Plus Jakarta Sans', 'Helvetica Neue', Arial, sans-serif;
    color: var(--scanny-ink);
    -webkit-font-smoothing: antialiased;
}

.scanny-launcher *,
.scanny-preview *,
.scanny-thread * {
    box-sizing: border-box;
}

.scanny-thread [hidden],
.scanny-thread[hidden] {
    display: none !important;
}

/* ---------- Scanny's face ---------- */
.scanny-avatar {
    position: relative;
    display: grid;
    flex: none;
    place-items: center;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 30%, #f3fbfd, #d3ecf4 75%);
}

.scanny-avatar .scanny-bot {
    width: 100%;
    height: 100%;
    margin-top: 10%;
}

.scanny-avatar.is-online::after {
    position: absolute;
    right: 0;
    bottom: 0;
    width: 26%;
    height: 26%;
    border: 2px solid #fff;
    border-radius: 50%;
    background: var(--scanny-online);
    content: '';
}

button.scanny-avatar,
.scanny-row .scanny-avatar {
    cursor: pointer;
}

.scanny-bot {
    display: block;
    overflow: visible;
}

.scanny-bot__head { fill: #fff; stroke: var(--scanny-navy); stroke-width: 4; }
.scanny-bot__visor { fill: var(--scanny-navy); }
.scanny-bot__eyes { animation: scanny-blink 4.2s infinite; transform-box: fill-box; transform-origin: center; }
.scanny-bot__eyes ellipse { fill: var(--scanny-glow); }
.scanny-bot__look { transition: transform 0.18s ease-out; }
.scanny-bot__mouth { fill: none; stroke: var(--scanny-navy); stroke-width: 4; stroke-linecap: round; }
.scanny-bot__cheek { fill: #ff8fa3; opacity: 0.5; }
.scanny-bot__bulb { fill: #ffd166; }
.scanny-bot__stalk { stroke: var(--scanny-navy); stroke-width: 4; stroke-linecap: round; }
.scanny-bot__arm { fill: #fff; stroke: var(--scanny-navy); stroke-width: 3.5; }
.scanny-bot__arm--right { transform-box: fill-box; transform-origin: 50% 0%; }
.scanny-bot__happy { display: none; fill: none; stroke: var(--scanny-glow); stroke-width: 5; stroke-linecap: round; }
.scanny-bot__glass { display: none; }
.scanny-bot__glass circle { fill: rgba(255, 255, 255, 0.3); stroke: #ffb703; stroke-width: 5; }
.scanny-bot__glass line { stroke: #ffb703; stroke-width: 6; stroke-linecap: round; }

.scanny-bot.is-happy .scanny-bot__eyes { display: none; }
.scanny-bot.is-happy .scanny-bot__happy { display: inline; }
.scanny-bot.is-search .scanny-bot__glass { display: inline; animation: scanny-search 1.2s ease-in-out infinite; }
.scanny-bot.is-waving .scanny-bot__arm--right { animation: scanny-wave 0.5s ease-in-out 4; }
.scanny-bot.is-wiggling { animation: scanny-wiggle 0.45s ease 2; }
.scanny-bot.is-dancing { animation: scanny-dance 0.6s ease-in-out 5; }

@keyframes scanny-blink { 0%, 46%, 50%, 100% { transform: scaleY(1); } 48% { transform: scaleY(0.1); } }
@keyframes scanny-wave { 0%, 100% { transform: rotate(0); } 50% { transform: rotate(-40deg); } }
@keyframes scanny-wiggle { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(-9deg); } 75% { transform: rotate(9deg); } }
@keyframes scanny-dance { 0%, 100% { transform: translateY(0) rotate(0); } 25% { transform: translateY(-14%) rotate(-10deg); } 75% { transform: translateY(-14%) rotate(10deg); } }
@keyframes scanny-search { 0%, 100% { transform: translate(0, 0); } 50% { transform: translate(-22px, -4px); } }

/* ---------- The button and the notification ---------- */
.scanny-launcher {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 10010;
    width: 60px;
    height: 60px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: none;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.18);
    cursor: pointer;
    transform: scale(0);
    transition: transform 0.25s cubic-bezier(0.3, 1.4, 0.6, 1);
}

.scanny-launcher.is-in { transform: scale(1); }
.scanny-launcher .scanny-avatar { width: 60px; height: 60px; box-shadow: inset 0 0 0 2px #fff; }

.scanny-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    display: none;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border: 2px solid #fff;
    border-radius: 10px;
    background: #e53935;
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    line-height: 16px;
}

.scanny-launcher.has-unread .scanny-badge { display: block; }

.scanny-preview {
    position: fixed;
    right: 20px;
    bottom: 92px;
    z-index: 10010;
    display: flex;
    width: 300px;
    border-radius: 16px;
    background: #fff;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.16);
    opacity: 0;
    pointer-events: none;
    transform: translateY(12px);
    /* Hidden from keyboard and screen readers too, once it has faded out. */
    visibility: hidden;
    transition: opacity 0.25s, transform 0.25s, visibility 0s 0.25s;
}

.scanny-preview.is-in { opacity: 1; pointer-events: auto; transform: none; visibility: visible; transition-delay: 0s; }

.scanny-preview__open {
    display: flex;
    flex: 1;
    gap: 10px;
    padding: 12px 8px 12px 14px;
    border: 0;
    border-radius: 16px;
    background: none;
    color: inherit;
    font: inherit;
    text-align: left;
    cursor: pointer;
}

.scanny-preview__open .scanny-avatar { width: 40px; height: 40px; }
.scanny-preview__words strong { display: block; font-size: 14px; }
.scanny-preview__text { display: block; margin-top: 2px; color: #3b4a54; font-size: 14px; line-height: 1.4; }

.scanny-preview__close {
    align-self: flex-start;
    padding: 6px 10px;
    border: 0;
    background: none;
    color: var(--scanny-muted);
    font-size: 18px;
    cursor: pointer;
}

/* ---------- The thread ---------- */
.scanny-thread {
    position: fixed;
    right: 20px;
    bottom: 92px;
    z-index: 10011;
    display: flex;
    flex-direction: column;
    width: 370px;
    height: min(580px, calc(100vh - 120px));
    overflow: hidden;
    border-radius: 18px;
    background: #fff;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.2);
    font-size: 14.5px;
    line-height: 1.42;
    opacity: 0;
    pointer-events: none;
    transform: translateY(16px) scale(0.98);
    transform-origin: bottom right;
    transition: opacity 0.2s, transform 0.2s;
}

.scanny-thread.is-open { opacity: 1; pointer-events: auto; transform: none; }

.scanny-head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 12px 12px 14px;
    border-bottom: 1px solid var(--scanny-line);
}

.scanny-head .scanny-avatar { width: 46px; height: 46px; }
.scanny-who { flex: 1; min-width: 0; }
.scanny-who strong { display: block; font-size: 15px; }
.scanny-who span { color: var(--scanny-muted); font-size: 12px; }

.scanny-min {
    width: 32px;
    height: 32px;
    border: 0;
    border-radius: 50%;
    background: none;
    color: var(--scanny-muted);
    font-size: 20px;
    cursor: pointer;
}

.scanny-min:hover { background: var(--scanny-them); }

.scanny-body {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: 2px;
    overflow-y: auto;
    padding: 14px 12px 6px;
}

.scanny-day { align-self: center; margin: auto 0 10px; color: var(--scanny-muted); font-size: 11px; }

.scanny-row { display: flex; align-items: flex-end; gap: 6px; }
.scanny-row.is-first { margin-top: 8px; }
.scanny-row--me { justify-content: flex-end; }
.scanny-row .scanny-avatar { width: 32px; height: 32px; visibility: hidden; }
.scanny-row.is-last .scanny-avatar { visibility: visible; }

.scanny-bubble {
    max-width: 76%;
    padding: 8px 12px;
    border-radius: 18px;
    overflow-wrap: anywhere;
    animation: scanny-pop 0.18s ease-out;
}

.scanny-row--them .scanny-bubble { border-top-left-radius: 6px; border-bottom-left-radius: 6px; background: var(--scanny-them); }
.scanny-row--them.is-first .scanny-bubble { border-top-left-radius: 18px; }
.scanny-row--them.is-last .scanny-bubble { border-bottom-left-radius: 18px; }
.scanny-row--me .scanny-bubble { border-top-right-radius: 6px; border-bottom-right-radius: 6px; background: var(--scanny-me); color: #fff; }
.scanny-row--me.is-first .scanny-bubble { border-top-right-radius: 18px; }
.scanny-row--me.is-last .scanny-bubble { border-bottom-right-radius: 18px; }

.scanny-seen { align-self: flex-end; margin: 2px 2px 0; color: var(--scanny-muted); font-size: 11px; }

@keyframes scanny-pop { from { opacity: 0; transform: translateY(6px) scale(0.97); } to { opacity: 1; transform: none; } }

.scanny-typing { display: inline-flex; gap: 4px; padding: 4px 2px; }
.scanny-typing i { width: 7px; height: 7px; border-radius: 50%; background: #8696a0; animation: scanny-dot 1.2s infinite; }
.scanny-typing i:nth-child(2) { animation-delay: 0.15s; }
.scanny-typing i:nth-child(3) { animation-delay: 0.3s; }

@keyframes scanny-dot { 0%, 60%, 100% { opacity: 0.35; transform: none; } 30% { opacity: 1; transform: translateY(-3px); } }

/* Store search results, inside a bubble from Scanny. */
.scanny-row--them .scanny-bubble:has(.scanny-apps) { padding: 4px; }
.scanny-apps { min-width: 230px; max-height: 280px; overflow-y: auto; }

.scanny-app {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 7px 8px;
    border: 0;
    border-radius: 12px;
    background: none;
    color: inherit;
    font: inherit;
    text-align: left;
    cursor: pointer;
}

.scanny-app:hover:not(:disabled) { background: #fff; }
.scanny-app:disabled { cursor: not-allowed; opacity: 0.5; }
.scanny-app__text { min-width: 0; }
.scanny-app__text strong,
.scanny-app__text small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.scanny-app__text strong { font-size: 14px; font-weight: 600; }
.scanny-app__text small { color: var(--scanny-muted); font-size: 12px; }

.scanny-icon { flex: none; width: 34px; height: 34px; border-radius: 9px; background: #c5d3da; object-fit: cover; }
img.scanny-icon { background: #fff; }

.scanny-paid {
    margin-left: auto;
    padding: 1px 6px;
    border: 1px solid #cfd6da;
    border-radius: 6px;
    color: var(--scanny-muted);
    font-size: 11px;
}

.scanny-hint { margin: 0; padding: 6px 8px; color: var(--scanny-muted); font-size: 13px; }

.scanny-picked { display: inline-flex; align-items: center; gap: 8px; }
.scanny-picked .scanny-icon { width: 22px; height: 22px; border: 1.5px solid rgba(255, 255, 255, 0.7); border-radius: 6px; }
.scanny-picked small { font-size: 12px; opacity: 0.8; }

/* Answers: buttons above the composer. */
.scanny-quick { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; padding: 4px 12px 10px; }
.scanny-quick:empty { display: none; }

.scanny-quick button {
    padding: 7px 14px;
    border: 1.5px solid var(--scanny-me);
    border-radius: 18px;
    background: #fff;
    color: var(--scanny-me);
    font: inherit;
    font-size: 14px;
    cursor: pointer;
    animation: scanny-pop 0.2s ease-out both;
}

.scanny-quick button:nth-child(2) { animation-delay: 0.06s; }
.scanny-quick button:hover,
.scanny-quick button:focus-visible { background: var(--scanny-me); color: #fff; outline: none; }
.scanny-file-input { display: none; }

/* The composer, only while Scanny waits for typed text. */
.scanny-compose { display: flex; align-items: center; gap: 8px; padding: 8px 10px 10px; border-top: 1px solid var(--scanny-line); }

.scanny-compose { position: relative; }

.scanny-country {
    display: inline-flex;
    flex: none;
    align-items: center;
    gap: 2px;
    height: 40px;
    padding: 0 10px;
    border: 0;
    border-radius: 20px;
    background: var(--scanny-them);
    font: inherit;
    font-size: 20px;
    cursor: pointer;
}

.scanny-country[hidden] { display: none; }
.scanny-country::after { color: var(--scanny-muted); font-size: 10px; content: '▾'; }
.scanny-country:focus-visible,
.scanny-country[aria-expanded='true'] { outline: none; box-shadow: 0 0 0 2px rgba(0, 129, 186, 0.35); }

/* The country list opens above the composer, with a search filter on top. */
.scanny-countries {
    position: absolute;
    right: 10px;
    bottom: calc(100% + 6px);
    left: 10px;
    z-index: 2;
    display: flex;
    flex-direction: column;
    max-height: 280px;
    border: 1px solid var(--scanny-line);
    border-radius: 14px;
    background: #fff;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.16);
    overflow: hidden;
    animation: scanny-pop 0.15s ease-out both;
}

.scanny-countries[hidden] { display: none; }

.scanny-countries__filter {
    flex: none;
    margin: 8px;
    padding: 9px 12px;
    border: 0;
    border-radius: 10px;
    background: var(--scanny-them);
    color: var(--scanny-ink);
    font: inherit;
    font-size: 16px;
    outline: none;
}

.scanny-countries__filter:focus { box-shadow: 0 0 0 2px rgba(0, 129, 186, 0.35); }
.scanny-countries__list { flex: 1; min-height: 0; margin: 0; padding: 0 6px 6px; overflow-y: auto; list-style: none; overscroll-behavior: contain; }

.scanny-countries__item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 8px;
    color: var(--scanny-ink);
    font-size: 14px;
    cursor: pointer;
}

.scanny-countries__item[hidden] { display: none; }
.scanny-countries__item:hover,
.scanny-countries__item.is-active { background: var(--scanny-them); }
.scanny-countries__flag { font-size: 18px; }
.scanny-countries__empty { margin: 0; padding: 4px 16px 14px; color: var(--scanny-muted); font-size: 14px; }
.scanny-countries__empty[hidden] { display: none; }

.scanny-input {
    flex: 1;
    min-width: 0;
    padding: 10px 14px;
    border: 0;
    border-radius: 20px;
    background: var(--scanny-them);
    color: var(--scanny-ink);
    font: inherit;
    font-size: 16px;
    outline: none;
}

.scanny-input:focus { box-shadow: 0 0 0 2px rgba(0, 129, 186, 0.35); }

.scanny-send {
    display: grid;
    flex: none;
    place-items: center;
    width: 38px;
    height: 38px;
    border: 0;
    border-radius: 50%;
    background: var(--scanny-me);
    color: #fff;
    cursor: pointer;
}

.scanny-send:disabled { background: #c5d3da; cursor: default; }

.scanny-legal { margin: 0; padding: 0 12px 8px; color: var(--scanny-muted); font-size: 11px; text-align: center; }
.scanny-legal a { color: inherit; text-decoration: underline; }

/* Phones: the thread takes the whole screen. */
@media (max-width: 520px) {
    .scanny-thread { right: 0; bottom: 0; width: 100%; height: 100%; border-radius: 0; }
    .scanny-preview { right: 16px; left: 16px; width: auto; }
    .scanny-launcher { right: 16px; bottom: 16px; }
}

/* Below 720px the post's reading bar (include/article_contents.html, centered at the bottom) reaches the corner:
   while it shows, Scanny's button and notification sit above it. */
.scanny-launcher { transition: transform 0.25s cubic-bezier(0.3, 1.4, 0.6, 1), bottom 0.28s ease; }

@media (max-width: 719px) {
    body:has(.ac__bar.is-visible) .scanny-launcher { bottom: 84px; }
    body:has(.ac__bar.is-visible) .scanny-preview { bottom: 156px; }
}

@media (prefers-reduced-motion: reduce) {
    .scanny-bubble,
    .scanny-quick button,
    .scanny-typing i,
    .scanny-bot,
    .scanny-bot * { animation: none !important; }
}
