/* quiz-bubble.css
 * Styles for the floating Quilt Advisor chat bubble.
 * Extracted from quiz-bubble.php — linked from head.php.
 * Self-contained. Uses site design tokens from bundle.css.
 */
/* ── Quiz Bubble Styles ───────────────────────────────────────
   Self-contained. Uses site design tokens from main.css.
   All values fall back gracefully if CSS vars are missing.
───────────────────────────────────────────────────────────── */

#bw-bubble {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 500;
    font-family: 'Montserrat', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* ── Trigger button ─────────────────────────────────────────── */
.bw-bubble__trigger {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background-color: #2C4A3E;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    box-shadow: 0 4px 20px rgba(0,0,0,0.22), 0 2px 8px rgba(0,0,0,0.14);
    transition: transform 150ms ease, box-shadow 150ms ease, background-color 150ms ease;
    position: relative;
    -webkit-tap-highlight-color: transparent;
}

.bw-bubble__trigger:hover {
    background-color: #1E3329;
    transform: scale(1.06);
    box-shadow: 0 6px 28px rgba(0,0,0,0.28), 0 2px 8px rgba(0,0,0,0.14);
}

.bw-bubble__trigger:focus-visible {
    outline: 2px solid #C86B3A;
    outline-offset: 3px;
}

.bw-bubble__trigger:active {
    transform: scale(0.97);
}

/* Pulse dot */
.bw-bubble__pulse {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 12px;
    height: 12px;
    background-color: #C86B3A;
    border-radius: 50%;
    border: 2px solid #fff;
}

.bw-bubble__pulse::before {
    content: '';
    position: absolute;
    inset: -4px;
    border-radius: 50%;
    background-color: rgba(200, 107, 58, 0.4);
    animation: bw-pulse 2s ease-out infinite;
}

@keyframes bw-pulse {
    0%   { transform: scale(0.8); opacity: 1; }
    70%  { transform: scale(1.8); opacity: 0; }
    100% { transform: scale(0.8); opacity: 0; }
}

/* Pulse dot hidden when panel open */
#bw-bubble.is-open .bw-bubble__pulse { display: none; }


/* ── Tooltip ────────────────────────────────────────────────── */
.bw-bubble__tooltip {
    position: absolute;
    bottom: 50%;
    right: calc(100% + 12px);
    transform: translateY(50%);
    background-color: #fff;
    color: #383838;
    font-size: 0.8rem;
    font-weight: 600;
    white-space: nowrap;
    padding: 8px 14px;
    border-radius: 100px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.14);
    pointer-events: none;
    opacity: 0;
    transition: opacity 200ms ease;
    border: 1px solid #DDD8CC;
}

.bw-bubble__tooltip::after {
    content: '';
    position: absolute;
    top: 50%;
    right: -6px;
    transform: translateY(-50%) rotate(45deg);
    width: 10px;
    height: 10px;
    background: #fff;
    border-right: 1px solid #DDD8CC;
    border-top: 1px solid #DDD8CC;
}

.bw-bubble__tooltip.is-visible {
    opacity: 1;
    pointer-events: auto;
}


/* ── Panel ──────────────────────────────────────────────────── */
.bw-bubble__panel {
    position: absolute;
    bottom: calc(100% + 16px);
    right: 0;
    width: 360px;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 8px 40px rgba(0,0,0,0.18), 0 2px 12px rgba(0,0,0,0.10);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid #DDD8CC;
    animation: bw-panel-in 200ms ease;
    max-height: 500px;
}

@keyframes bw-panel-in {
    from { opacity: 0; transform: translateY(12px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.bw-bubble__panel[hidden] {
    display: none;
}


/* ── Panel header ───────────────────────────────────────────── */
.bw-bubble__header {
    background-color: #2C4A3E;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.bw-bubble__header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.bw-bubble__avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background-color: rgba(255,255,255,0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    flex-shrink: 0;
}

.bw-bubble__panel-title {
    font-size: 0.875rem;
    font-weight: 700;
    color: #fff;
    margin: 0;
    line-height: 1.3;
}

.bw-bubble__panel-sub {
    font-size: 0.7rem;
    color: rgba(255,255,255,0.65);
    margin: 0;
    line-height: 1.3;
    font-weight: 500;
    letter-spacing: 0.03em;
}

.bw-bubble__close {
    background: none;
    border: none;
    cursor: pointer;
    color: rgba(255,255,255,0.75);
    padding: 4px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    transition: color 150ms ease, background-color 150ms ease;
    -webkit-tap-highlight-color: transparent;
}

.bw-bubble__close:hover {
    color: #fff;
    background-color: rgba(255,255,255,0.12);
}

.bw-bubble__close:focus-visible {
    outline: 2px solid #C86B3A;
    outline-offset: 2px;
}


/* ── Messages area ──────────────────────────────────────────── */
.bw-bubble__messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    scroll-behavior: smooth;
    min-height: 200px;
}

/* Scrollbar styling */
.bw-bubble__messages::-webkit-scrollbar { width: 4px; }
.bw-bubble__messages::-webkit-scrollbar-track { background: transparent; }
.bw-bubble__messages::-webkit-scrollbar-thumb { background: #DDD8CC; border-radius: 4px; }

/* Individual messages */
.bw-bubble__msg {
    max-width: 88%;
    font-size: 0.84rem;
    line-height: 1.55;
    padding: 10px 13px;
    border-radius: 12px;
    animation: bw-msg-in 200ms ease;
    word-break: break-word;
}

@keyframes bw-msg-in {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Advisor messages (left-aligned) */
.bw-bubble__msg--advisor {
    background-color: #F4F0E9;
    color: #383838;
    border-bottom-left-radius: 4px;
    align-self: flex-start;
}

/* User messages (right-aligned) */
.bw-bubble__msg--user {
    background-color: #2C4A3E;
    color: #fff;
    border-bottom-right-radius: 4px;
    align-self: flex-end;
}

/* CTA block inside advisor messages */
.bw-bubble__msg--advisor .bw-bubble__cta {
    margin-top: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: flex-start;
}

.bw-bubble__cta-btn {
    display: inline-flex;
    align-items: center;
    padding: 9px 16px;
    background-color: #C86B3A;
    color: #fff !important;
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 700;
    text-decoration: none;
    transition: background-color 150ms ease;
    white-space: nowrap;
}

.bw-bubble__cta-btn:hover {
    background-color: #A5562E;
    text-decoration: none;
}

.bw-bubble__cta > span {
    font-size: 0.75rem;
    color: #666;
}

.bw-bubble__cta-link {
    color: #2C4A3E;
    font-weight: 600;
    text-decoration: underline;
}

.bw-bubble__cta-link:hover {
    color: #1E3329;
}


/* ── Typing indicator ───────────────────────────────────────── */
.bw-bubble__typing {
    padding: 10px 16px 4px;
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

.bw-bubble__typing[hidden] { display: none; }

.bw-bubble__typing span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background-color: #C5BFB0;
    animation: bw-bounce 1.1s ease-in-out infinite;
}

.bw-bubble__typing span:nth-child(2) { animation-delay: 0.15s; }
.bw-bubble__typing span:nth-child(3) { animation-delay: 0.30s; }

@keyframes bw-bounce {
    0%, 60%, 100% { transform: translateY(0); background-color: #C5BFB0; }
    30%            { transform: translateY(-5px); background-color: #2C4A3E; }
}


/* ── Input area ─────────────────────────────────────────────── */
.bw-bubble__input-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 14px;
    border-top: 1px solid #DDD8CC;
    background: #fff;
    flex-shrink: 0;
}

.bw-bubble__input {
    flex: 1;
    border: 1px solid #DDD8CC;
    border-radius: 100px;
    padding: 9px 14px;
    font-size: 0.84rem;
    font-family: inherit;
    color: #383838;
    background: #F4F0E9;
    outline: none;
    transition: border-color 150ms ease, box-shadow 150ms ease;
    min-width: 0;
}

.bw-bubble__input:focus {
    border-color: #2C4A3E;
    box-shadow: 0 0 0 3px rgba(44,74,62,0.12);
    background: #fff;
}

.bw-bubble__input::placeholder { color: #999; }

.bw-bubble__send {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background-color: #2C4A3E;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    flex-shrink: 0;
    transition: background-color 150ms ease, transform 150ms ease;
    -webkit-tap-highlight-color: transparent;
}

.bw-bubble__send:hover { background-color: #1E3329; }
.bw-bubble__send:active { transform: scale(0.93); }
.bw-bubble__send:disabled { background-color: #C5BFB0; cursor: not-allowed; }
.bw-bubble__send:focus-visible { outline: 2px solid #C86B3A; outline-offset: 2px; }


/* ── Mobile ─────────────────────────────────────────────────── */
@media (max-width: 480px) {
    #bw-bubble {
        bottom: 16px;
        right: 16px;
    }
    .bw-bubble__panel {
        width: calc(100vw - 32px);
        right: 0;
        max-height: 420px;
    }
    .bw-bubble__tooltip {
        display: none; /* Hide tooltip on mobile, use tap */
    }
}
