/* chatbot.css — styles for the site-wide chatbot widget.
   Created 2026-06-03.

   All selectors are namespaced under #cb-root or .cb-*; nothing here
   should leak into host-page styles.

   z-index: bubble + panel = 9000–9100 (above sticky nav, below modals).
*/

#cb-root, #cb-root * { box-sizing: border-box; }

#cb-root {
    position: fixed;
    inset: 0;
    pointer-events: none;      /* root passes clicks through; children re-enable */
    z-index: 9000;
    font-family: Arial, sans-serif;
    color: #222;
}

/* ─── Splash (home page only) ─────────────────────────────────────────── */
.cb-splash {
    position: fixed;
    left: 50%;
    top: 38%;
    transform: translate(-50%, -50%);
    width: 240px;
    height: 240px;
    pointer-events: none;
    z-index: 9100;
    animation: cb-splash-in 0.65s cubic-bezier(.34,1.56,.64,1) forwards;
    filter: drop-shadow(0 10px 24px rgba(0,0,0,.28));
}
.cb-splash img {
    width: 100%;
    height: 100%;
    display: block;
    animation: cb-bob 1.4s ease-in-out infinite;
}
.cb-splash.cb-splash-out {
    animation: cb-splash-out 0.55s cubic-bezier(.5,0,.75,0) forwards;
}
@keyframes cb-splash-in {
    0%   { transform: translate(-50%, calc(100vh)) scale(.6); opacity: 0; }
    70%  { transform: translate(-50%, -52%) scale(1.05); opacity: 1; }
    100% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}
@keyframes cb-splash-out {
    0%   { transform: translate(-50%, -50%) scale(1); opacity: 1; }
    100% { transform: translate(-50%, calc(-100vh)) scale(.4); opacity: 0; }
}
@keyframes cb-bob {
    0%, 100% { transform: translateY(0)    rotate(-2deg); }
    50%      { transform: translateY(-8px) rotate(2deg);  }
}

/* ─── Persistent bubble (all public pages) ────────────────────────────── */
.cb-bubble {
    position: fixed;
    right: 18px;
    bottom: 18px;
    width: 72px;
    height: 72px;
    border: 0;
    padding: 0;
    background: transparent;
    cursor: pointer;
    pointer-events: auto;
    z-index: 9050;
    filter: drop-shadow(0 4px 10px rgba(0,0,0,.25));
    transition: transform .18s ease, filter .18s ease;
    animation: cb-bubble-in .42s cubic-bezier(.34,1.56,.64,1) backwards;
}
.cb-bubble:hover,
.cb-bubble:focus-visible {
    transform: scale(1.08) rotate(-4deg);
    filter: drop-shadow(0 6px 14px rgba(0,0,0,.35));
    outline: none;
}
.cb-bubble img { width: 100%; height: 100%; display: block; }
.cb-bubble[hidden] { display: none; }
@keyframes cb-bubble-in {
    0%   { transform: scale(0) rotate(-90deg); opacity: 0; }
    100% { transform: scale(1) rotate(0);      opacity: 1; }
}

/* Pulse dot on the bubble to draw the eye on first appearance. */
.cb-bubble::after {
    content: '';
    position: absolute;
    top: 4px; right: 4px;
    width: 12px; height: 12px;
    background: #ff4b6e;
    border: 2px solid #fff;
    border-radius: 50%;
    box-shadow: 0 0 0 0 rgba(255,75,110,.7);
    animation: cb-pulse 1.6s ease-out infinite;
}
.cb-bubble.cb-bubble-seen::after { display: none; }
@keyframes cb-pulse {
    0%   { box-shadow: 0 0 0 0   rgba(255,75,110,.7); }
    70%  { box-shadow: 0 0 0 14px rgba(255,75,110,0); }
    100% { box-shadow: 0 0 0 0   rgba(255,75,110,0); }
}

/* ─── Panel ───────────────────────────────────────────────────────────── */
.cb-panel {
    position: fixed;
    right: 18px;
    bottom: 100px;
    width: 340px;
    max-width: calc(100vw - 24px);
    max-height: calc(100vh - 140px);
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 12px 36px rgba(0,0,0,.25), 0 2px 6px rgba(0,0,0,.1);
    pointer-events: auto;
    z-index: 9060;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transform-origin: bottom right;
    animation: cb-panel-in .22s ease-out;
}
.cb-panel[hidden] { display: none; }
@keyframes cb-panel-in {
    0%   { transform: scale(.7) translateY(20px); opacity: 0; }
    100% { transform: scale(1)  translateY(0);    opacity: 1; }
}

.cb-panel-head {
    background: linear-gradient(135deg, #4169E1 0%, #6a4bdb 50%, #b94bdb 100%);
    color: #fff;
    padding: 12px 14px;
    display: flex;
    align-items: center;
    gap: 10px;
}
.cb-panel-head .cb-mascot-mini {
    width: 36px; height: 36px;
    flex: 0 0 36px;
}
.cb-panel-head .cb-mascot-mini img { width: 100%; height: 100%; display: block; }
.cb-panel-head .cb-title {
    flex: 1 1 auto;
    font-size: 1.02em;
    font-weight: 600;
    letter-spacing: .01em;
    line-height: 1.2;
}
.cb-panel-head .cb-sub {
    font-size: .78em;
    font-weight: 400;
    opacity: .82;
    margin-top: 2px;
}
.cb-panel-head .cb-close {
    background: rgba(255,255,255,.18);
    color: #fff;
    border: 0;
    width: 28px; height: 28px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}
.cb-panel-head .cb-close:hover { background: rgba(255,255,255,.32); }

.cb-panel-body {
    padding: 14px;
    overflow-y: auto;
    flex: 1 1 auto;
    background: #fafafa;
    font-size: .94em;
    line-height: 1.45;
}
.cb-panel-body p { margin: 0 0 10px 0; }
.cb-panel-body .cb-context-badge {
    display: inline-block;
    background: #eef2ff;
    color: #3744a8;
    border: 1px solid #c8d2f5;
    padding: 3px 8px;
    border-radius: 10px;
    font-size: .8em;
    margin-bottom: 8px;
}

.cb-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 6px; }
.cb-btn {
    display: block;
    width: 100%;
    padding: 11px 14px;
    border: 1px solid transparent;
    border-radius: 10px;
    background: #4169E1;
    color: #fff;
    font-size: .96em;
    font-weight: 500;
    cursor: pointer;
    text-align: left;
    transition: background .15s, transform .08s;
}
.cb-btn:hover    { background: #2f54c7; }
.cb-btn:active   { transform: translateY(1px); }
.cb-btn-secondary {
    background: #fff;
    color: #333;
    border-color: #d4d4d4;
}
.cb-btn-secondary:hover { background: #f1f1f1; }
.cb-btn-back {
    background: none;
    color: #4169E1;
    padding: 4px 0;
    text-align: left;
    font-size: .88em;
    cursor: pointer;
    border: 0;
    margin-top: 4px;
}
.cb-btn-back:hover { text-decoration: underline; }
.cb-btn:disabled, .cb-btn[disabled] {
    background: #c9c9c9;
    color: #fff;
    cursor: not-allowed;
}

.cb-input,
.cb-textarea {
    width: 100%;
    padding: 10px 12px;
    margin: 0 0 8px 0;       /* breathing room between stacked anonymous-form inputs */
    border: 1px solid #ccc;
    border-radius: 8px;
    font-family: inherit;
    font-size: .95em;
    resize: vertical;
    background: #fff;
}
.cb-textarea { min-height: 92px; }
.cb-input:focus, .cb-textarea:focus {
    border-color: #4169E1;
    outline: 2px solid rgba(65,105,225,.18);
}

/* Cloudflare Turnstile widget container — the iframe inside is 300x65
   by default. Center it inside the panel column. */
.cb-turnstile-wrap {
    margin: 4px 0 10px 0;
    display: flex;
    justify-content: center;
    min-height: 65px;
}

.cb-hint {
    font-size: .8em;
    color: #888;
    margin: 4px 0 10px 0;
}
.cb-error {
    background: #fff0f0;
    border: 1px solid #ffb3b3;
    color: #a23030;
    padding: 8px 10px;
    border-radius: 6px;
    font-size: .88em;
    margin-bottom: 8px;
}
.cb-success {
    background: #ecfff0;
    border: 1px solid #9adfae;
    color: #1f7a3a;
    padding: 8px 10px;
    border-radius: 6px;
    font-size: .9em;
    margin-bottom: 8px;
}
.cb-spinner {
    width: 18px; height: 18px;
    border: 3px solid #d0d8f5;
    border-top-color: #4169E1;
    border-radius: 50%;
    animation: cb-spin .8s linear infinite;
    display: inline-block;
    vertical-align: middle;
    margin-right: 6px;
}
@keyframes cb-spin { to { transform: rotate(360deg); } }

/* Host pages on this site set their own <a> colour rules with varying
   specificity (some via #id selectors that beat a plain .class). We bump
   our scope to #cb-root .cb-loginlink and add !important on the visible
   properties so no host stylesheet can render this link invisible — the
   reported white-on-white case was a host rule overriding plain
   .cb-loginlink. Also force underline by default so the link is
   self-evidently clickable, and pin :link / :visited / :hover so a
   "purple visited" state doesn't appear on a panel background. */
#cb-root .cb-loginlink,
#cb-root .cb-loginlink:link,
#cb-root .cb-loginlink:visited {
    color: #4169E1 !important;
    background: transparent !important;
    text-decoration: underline !important;
    font-weight: 600 !important;
}
#cb-root .cb-loginlink:hover,
#cb-root .cb-loginlink:focus {
    color: #2942a0 !important;
    text-decoration: underline !important;
}

/* Honeypot — visually hidden but still focusable so accessibility tools
   can see it; bots filling all inputs will fill it; humans never see it. */
.cb-honeypot {
    position: absolute !important;
    left: -10000px;
    top: auto;
    width: 1px;
    height: 1px;
    overflow: hidden;
    opacity: 0;
}

/* ─── Daily-Opal slide-in toast (home only, once / session) ───────────── */
.cb-toast {
    position: fixed;
    right: 100px;       /* sit to the left of the 72px bubble */
    bottom: 30px;
    display: flex;
    align-items: center;
    background: #ffffff;
    color: #333;
    border-radius: 26px;
    box-shadow: 0 6px 18px rgba(0,0,0,.18), 0 1px 3px rgba(0,0,0,.08);
    pointer-events: auto;
    z-index: 9055;
    overflow: hidden;
    animation: cb-toast-in .42s cubic-bezier(.34,1.56,.64,1);
    max-width: calc(100vw - 130px);
}
.cb-toast-body {
    background: none;
    border: 0;
    padding: 12px 6px 12px 18px;
    font-family: inherit;
    font-size: .92em;
    color: #2c3a78;
    cursor: pointer;
    text-align: left;
    line-height: 1.25;
}
.cb-toast-body:hover { color: #4169E1; }
.cb-toast-close {
    background: none;
    border: 0;
    width: 36px; height: 36px;
    color: #888;
    font-size: 18px;
    cursor: pointer;
    align-self: stretch;
}
.cb-toast-close:hover { color: #333; }
.cb-toast.cb-toast-out {
    animation: cb-toast-out .35s ease-in forwards;
}
@keyframes cb-toast-in {
    0%   { transform: translate(40px, 0) scale(.85); opacity: 0; }
    100% { transform: translate(0, 0)    scale(1);   opacity: 1; }
}
@keyframes cb-toast-out {
    0%   { transform: translate(0, 0)    scale(1);   opacity: 1; }
    100% { transform: translate(40px, 0) scale(.85); opacity: 0; }
}

/* Mobile: keep the panel a proper compact popover anchored to the
   bubble — NOT a near-full-screen sheet. Earlier rule expanded the
   panel to ~full viewport width on phones, which felt overwhelming.
   We now cap it at ~330 px (still fits an iPhone SE comfortably) and
   shrink the chrome (mascot, header padding, body padding, fonts,
   textarea min-height) so the same flows take less vertical space.
   safe-area-inset-bottom keeps the bubble + toast clear of the home
   indicator on notch / Dynamic-Island iPhones. dvh units track the
   *visible* viewport, so when iOS Safari hides its toolbar the panel
   doesn't end up taller than the screen. */
@media (max-width: 480px) {
    .cb-panel {
        right: 12px;
        left: auto;
        bottom: calc(78px + env(safe-area-inset-bottom, 0px));
        width: min(330px, calc(100vw - 24px));
        max-height: min(72dvh, calc(100dvh - 110px));
        border-radius: 14px;
    }
    .cb-panel-head {
        padding: 9px 12px;
        gap: 8px;
    }
    .cb-panel-head .cb-mascot-mini {
        width: 28px; height: 28px;
        flex: 0 0 28px;
    }
    .cb-panel-head .cb-title { font-size: .94em; }
    .cb-panel-head .cb-sub   { font-size: .74em; margin-top: 1px; }
    .cb-panel-head .cb-close {
        width: 24px; height: 24px;
        font-size: 16px;
    }
    .cb-panel-body {
        padding: 10px 12px;
        font-size: .9em;
        line-height: 1.4;
    }
    .cb-textarea { min-height: 70px; }
    .cb-btn      { padding: 9px 12px; font-size: .92em; }
    .cb-input,
    .cb-textarea { padding: 8px 10px; margin-bottom: 7px; }

    .cb-bubble {
        width: 56px; height: 56px;
        right: 12px;
        bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    }
    .cb-splash { width: 180px; height: 180px; }
    .cb-toast {
        right: 76px;
        bottom: calc(16px + env(safe-area-inset-bottom, 0px));
        max-width: calc(100vw - 90px);
        font-size: .82em;
        border-radius: 22px;
    }
    .cb-toast-body  { padding: 10px 4px 10px 14px; }
    .cb-toast-close { width: 30px; height: 30px; font-size: 16px; }
}

/* Respect motion preferences. */
@media (prefers-reduced-motion: reduce) {
    .cb-splash, .cb-splash img, .cb-bubble, .cb-panel, .cb-toast { animation: none !important; }
    .cb-bubble::after { animation: none; }
}
