/* Paragon RAG Chatbot (front-end) */

/* Safety: ensure hidden behaves */
[hidden] {
    display: none !important;
}

/* =========================================================
   PARAGON TOKENS BINDING
   - Uses your theme tokens from _tokens.scss:
     --teal, --orange, --bg, --border, --text, --muted, --shadow,
     --chip-border, --chip-bg, --ask-btn, --ask-btn-text
   ========================================================= */

:root {
    /* fallback if theme tokens ever missing */
    --teal: #1aa6b8;
    --orange: #E87B13;

    /* rag-specific derived tokens */
    --rag-accent: var(--teal);
    --rag-accent-2: var(--orange);

    --rag-radius-lg: 18px;
    --rag-radius-md: 16px;
    --rag-radius-sm: 14px;
    --rag-pill: 999px;

    /* defaults (overridden per theme below) */
    --rag-surface: rgba(0, 0, 0, .45);
    --rag-surface-2: rgba(255, 255, 255, .06);
    --rag-border: rgba(255, 255, 255, .14);
    --rag-border-strong: rgba(255, 255, 255, .22);
    --rag-text: rgba(255, 255, 255, .92);
    --rag-muted: rgba(255, 255, 255, .72);
    --rag-shadow: 0 18px 52px rgba(0, 0, 0, .36);
    --rag-shadow-soft: 0 12px 30px rgba(0, 0, 0, .22);

    --rag-input-bg: rgba(255, 255, 255, .06);
    --rag-input-border: rgba(255, 255, 255, .14);

    /* button inherits hero behaviour via --ask-btn */
    --rag-cta-bg: var(--ask-btn, var(--rag-accent-2));
    --rag-cta-text: var(--ask-btn-text, #fff);

    /* hero tighten */
    --rag-hero-max: 980px;
    --rag-hero-gap: 12px;
}

/* Theme-aware mapping (matches _tokens.scss) */
html[data-theme="dark"] {
    --rag-surface: rgba(6, 10, 16, 0.72);
    --rag-surface-2: rgba(0, 0, 0, .22);
    --rag-border: rgba(255, 255, 255, 0.10);
    --rag-border-strong: rgba(255, 255, 255, 0.16);
    --rag-text: rgba(255, 255, 255, 0.92);
    --rag-muted: rgba(255, 255, 255, 0.70);
    --rag-shadow: 0 18px 56px rgba(0, 0, 0, 0.45);
    --rag-shadow-soft: 0 12px 30px rgba(0, 0, 0, 0.30);
    --rag-input-bg: rgba(0, 0, 0, 0.18);
    --rag-input-border: rgba(255, 255, 255, 0.10);

    /* your theme sets ask button to teal in dark */
    --rag-cta-bg: var(--ask-btn);
    --rag-cta-text: var(--ask-btn-text);
}

html[data-theme="light"] {
    --rag-surface: rgba(246, 247, 248, 0.80);
    --rag-surface-2: rgba(255, 255, 255, 0.55);
    --rag-border: rgba(16, 24, 40, 0.10);
    --rag-border-strong: rgba(16, 24, 40, 0.14);
    --rag-text: rgba(14, 20, 30, 0.92);
    --rag-muted: rgba(14, 20, 30, 0.62);
    --rag-shadow: 0 20px 60px rgba(16, 24, 40, 0.16);
    --rag-shadow-soft: 0 12px 30px rgba(16, 24, 40, 0.12);
    --rag-input-bg: rgba(255, 255, 255, 0.72);
    --rag-input-border: rgba(16, 24, 40, 0.10);

    /* your theme sets ask button to orange in light */
    --rag-cta-bg: var(--ask-btn);
    --rag-cta-text: var(--ask-btn-text);
}

/* =========================================================
   MICRO ANIMATIONS
   ========================================================= */

.rag-pulse {
    animation: paragon-rag-pulse 420ms ease-out;
}

@keyframes paragon-rag-pulse {
    0% {
        transform: translateY(0) scale(1);
    }

    35% {
        transform: translateY(-1px) scale(1.06);
    }

    100% {
        transform: translateY(0) scale(1);
    }
}

@keyframes ragSheen {
    0% {
        transform: translateX(-18%) skewX(-18deg);
        opacity: 0;
    }

    20% {
        opacity: .55;
    }

    55% {
        opacity: .12;
    }

    100% {
        transform: translateX(118%) skewX(-18deg);
        opacity: 0;
    }
}

@keyframes paragon-rag-in {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* =========================================================
   HERO INLINE CHAT
   ========================================================= */

.hero-chat {
    margin-top: 18px;
}

/* Thread */
.rag-thread {
    display: grid;
    gap: 10px;
    padding: 14px;
    border: 1px solid var(--rag-border);
    border-radius: var(--rag-radius-lg);
    background: color-mix(in srgb, var(--rag-surface) 55%, transparent);
    min-height: 160px;
    max-height: 360px;
    overflow: auto;
    box-shadow: var(--rag-shadow-soft);
    -webkit-overflow-scrolling: touch;
}

html[data-theme="light"] .rag-thread {
    background: rgba(255, 255, 255, 0.55);
}

/* Float variant */
.rag-thread--float {
    border: 0;
    border-radius: 0;
    background: transparent;
    padding: 12px 12px 8px;
    max-height: 360px;
    box-shadow: none;
}

/* Bubbles */
.rag-bubble {
    width: fit-content;
    max-width: 88%;
    padding: 10px 12px;
    border-radius: 16px;
    line-height: 1.35;
    font-size: 15px;
    word-break: break-word;
    box-shadow: 0 10px 28px rgba(0, 0, 0, .10);
    color: var(--rag-text);
}

.rag-bubble.is-new {
    animation: paragon-rag-in 260ms ease-out both;
}

/* Bot meta badge */
.rag-bubble__meta {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: -2px 0 6px;
    opacity: .9;
}

.rag-badge {
    font-size: 11px;
    font-weight: 800;
    letter-spacing: -0.01em;
    padding: 4px 8px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, .14);
    background: rgba(255, 255, 255, .06);
    color: var(--rag-text);
}

html[data-theme="light"] .rag-badge {
    border-color: rgba(16, 24, 40, .12);
    background: rgba(255, 255, 255, .65);
}

.rag-spark {
    font-size: 12px;
    opacity: .85;
    filter: drop-shadow(0 6px 16px rgba(0, 0, 0, .18));
}

.rag-bubble__content {
    display: block;
    text-align: left;
    line-height: 1.6;
}

/* User bubble = accent-outline glass */
.rag-bubble--user {
    justify-self: end;
    background:
        linear-gradient(180deg,
            color-mix(in srgb, var(--rag-accent) 18%, rgba(255, 255, 255, .06)),
            rgba(255, 255, 255, .06));
    border: 1px solid color-mix(in srgb, var(--rag-accent) 52%, var(--rag-border));
}

/* Bot bubble = clean surface */
.rag-bubble--bot {
    justify-self: start;
    background: color-mix(in srgb, var(--rag-surface-2) 80%, transparent);
    border: 1px solid var(--rag-border);
    color: var(--rag-text);
}

html[data-theme="light"] .rag-bubble--bot {
    background: rgba(255, 255, 255, 0.74);
}

/* Typing */
.rag-typing {
    opacity: .9;
    font-size: 13px;
    padding: 6px 2px;
    color: var(--rag-muted);
    font-weight: 700;
}

/* =========================================================
   LEAD CARD
   ========================================================= */

.rag-leadcard {
    margin-top: 12px;
    padding: 14px;
    border-radius: var(--rag-radius-lg);
    border: 1px solid var(--rag-border);
    background:
        radial-gradient(700px 260px at 10% 0%, rgba(255, 255, 255, .10), transparent 55%),
        color-mix(in srgb, var(--rag-surface-2) 70%, transparent);
    box-shadow: var(--rag-shadow-soft);
}

html[data-theme="light"] .rag-leadcard {
    background:
        radial-gradient(700px 260px at 10% 0%, rgba(255, 255, 255, .55), transparent 60%),
        rgba(255, 255, 255, 0.70);
}

.rag-leadcard__copy {
    margin-bottom: 10px;
    opacity: .96;
    font-size: 14px;
    font-weight: 800;
    letter-spacing: -0.01em;
    color: var(--rag-text);
}

.rag-leadform {
    display: grid;
    gap: 12px;
}

.rag-leadform__row {
    text-align: left;
}

.rag-leadform__row label {
    display: block;
    font-size: 12px;
    opacity: .85;
    margin-bottom: 4px;
    font-weight: 800;
    color: var(--rag-muted);
}

.rag-leadform__row input {
    width: 100%;
    padding: 10px 12px;
    border-radius: 14px;
    border: 1px solid var(--rag-input-border);
    background: var(--rag-input-bg);
    color: var(--rag-text);
    outline: none;
    transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}

.rag-leadform__row input:focus {
    border-color: color-mix(in srgb, var(--rag-accent) 45%, var(--rag-border));
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--rag-accent) 14%, transparent);
    background: color-mix(in srgb, var(--rag-input-bg) 90%, rgba(255, 255, 255, .06));
}

.rag-leadform__reveal {
    width: 100%;
    text-align: center;
    padding: 10px 12px;
    border-radius: 14px;
    border: 1px solid var(--rag-border);
    background: color-mix(in srgb, var(--rag-surface-2) 70%, transparent);
    color: var(--rag-text);
    cursor: pointer;
    font-weight: 900;
    letter-spacing: -0.01em;
    transition: transform 160ms ease, filter 160ms ease, border-color 160ms ease, background 160ms ease;
}

html[data-theme="light"] .rag-leadform__reveal {
    background: rgba(255, 255, 255, .72);
}

.rag-leadform__reveal:hover {
    transform: translateY(-1px);
    filter: brightness(1.04);
    border-color: var(--rag-border-strong);
}

.rag-leadform__more {
    display: grid;
    gap: 10px;
    padding-top: 6px;
}

.rag-leadform__consent {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    font-size: 12px;
    opacity: .98;
    color: var(--rag-muted);
    padding: 10px 12px;
    border-radius: 14px;
    border: 1px solid var(--rag-border);
    background: color-mix(in srgb, var(--rag-surface-2) 70%, transparent);
}

.rag-leadform__submit {
    padding: 10px 12px;
    border-radius: 999px;
    border: 0;
    cursor: pointer;
    font-weight: 900;
    letter-spacing: -0.01em;
    color: var(--rag-cta-text);
    background: var(--rag-cta-bg);
    box-shadow: var(--rag-shadow-soft);
    transition: transform .16s ease, filter .16s ease, box-shadow .16s ease;
}

.rag-leadform__submit:hover {
    transform: translateY(-1px);
    filter: brightness(1.04);
    box-shadow: var(--rag-shadow);
}

.rag-leadform__thanks {
    margin-top: 8px;
    font-size: 14px;
    opacity: .95;
}

.rag-leadform__error {
    margin-top: 8px;
    font-size: 13px;
    opacity: .9;
}

/* =========================================================
   FLOATING BUTTON + PANEL
   ========================================================= */

.rag-fab {
    position: fixed;
    right: 18px;
    bottom: 18px;
    z-index: 9999;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    border-radius: var(--rag-pill);
    border: 1px solid var(--rag-border-strong);
    background: color-mix(in srgb, var(--rag-surface) 72%, transparent);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    color: var(--rag-text);
    cursor: pointer;
    box-shadow: var(--rag-shadow-soft);
    transition: transform .18s ease, filter .18s ease, box-shadow .18s ease;
}

.rag-fab:hover {
    transform: translateY(-2px);
    filter: brightness(1.03);
    box-shadow: var(--rag-shadow);
}

.rag-fab__dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--rag-accent);
    box-shadow: 0 0 0 6px color-mix(in srgb, var(--rag-accent) 22%, transparent);
    opacity: .95;
}

/* Panel */
.rag-float {
    position: fixed;
    right: 18px;
    bottom: 76px;
    z-index: 9999;
    width: min(380px, calc(100vw - 36px));
    border-radius: var(--rag-radius-lg);
    border: 1px solid var(--rag-border-strong);
    background:
        radial-gradient(900px 420px at 16% 0%,
            color-mix(in srgb, var(--rag-accent) 18%, transparent) 0%,
            transparent 58%),
        radial-gradient(900px 420px at 90% 12%,
            color-mix(in srgb, var(--rag-accent-2) 12%, transparent) 0%,
            transparent 62%),
        color-mix(in srgb, var(--rag-surface) 78%, transparent);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    overflow: hidden;
    color: var(--rag-text);
    box-shadow: var(--rag-shadow);
}

/* Dot texture overlay */
.rag-float::before {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    opacity: .22;
    background:
        radial-gradient(circle at 1px 1px, rgba(255, 255, 255, .18) 1px, transparent 1.6px) 0 0 / 14px 14px;
    mask-image: radial-gradient(closest-side at 50% 30%, rgba(0, 0, 0, 1), transparent 78%);
}

html[data-theme="light"] .rag-float::before {
    opacity: .14;
    background:
        radial-gradient(circle at 1px 1px, rgba(14, 20, 30, .16) 1px, transparent 1.6px) 0 0 / 14px 14px;
}

/* Head */
.rag-float__head {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    border-bottom: 1px solid var(--rag-border);
    background: color-mix(in srgb, var(--rag-surface) 55%, transparent);
}

.rag-float__title {
    font-weight: 900;
    font-size: 14px;
    letter-spacing: -0.01em;
    color: var(--rag-text);
}

.rag-float__close {
    width: 34px;
    height: 34px;
    border-radius: 12px;
    border: 1px solid var(--rag-border);
    background: color-mix(in srgb, var(--rag-surface-2) 70%, transparent);
    color: var(--rag-text);
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    transition: transform .15s ease, filter .15s ease, background .15s ease, border-color .15s ease;
}

.rag-float__close:hover {
    transform: translateY(-1px);
    filter: brightness(1.05);
    border-color: var(--rag-border-strong);
}

/* =========================================================
   FLOATING QUICK PILLS
   ========================================================= */

.rag-pills {
    display: flex;
    gap: 8px;
    padding: 10px 12px;
    overflow-x: auto;
    white-space: nowrap;
    border-top: 1px solid var(--rag-border);
    border-bottom: 1px solid var(--rag-border);
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;

    position: sticky;
    bottom: 0;
    background: color-mix(in srgb, var(--rag-surface) 62%, transparent);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.rag-pills::-webkit-scrollbar {
    display: none;
}

.rag-pill {
    border: 1px solid var(--chip-border, var(--rag-border-strong));
    background: var(--chip-bg, color-mix(in srgb, var(--rag-surface-2) 70%, transparent));
    color: var(--rag-text);
    padding: 9px 12px;
    border-radius: var(--rag-pill);
    cursor: pointer;
    font-size: 12px;
    line-height: 1;
    font-weight: 900;
    letter-spacing: -0.01em;
    opacity: .96;
    transition: transform 160ms ease, background 160ms ease, border-color 160ms ease, opacity 160ms ease, box-shadow 160ms ease;
}

.rag-pill:hover {
    transform: translateY(-1px);
    opacity: 1;
    background: color-mix(in srgb, var(--chip-bg, rgba(255, 255, 255, .06)) 85%, rgba(255, 255, 255, .06));
    border-color: color-mix(in srgb, var(--rag-accent) 42%, var(--rag-border-strong));
    box-shadow: 0 12px 26px rgba(0, 0, 0, .16);
}

/* =========================================================
   INPUT ROW
   ========================================================= */

.rag-form {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 10px;
    padding: 12px;
    border-top: 1px solid var(--rag-border);
    background: color-mix(in srgb, var(--rag-surface) 58%, transparent);
}

.rag-input {
    width: 100%;
    padding: 10px 12px;
    border-radius: var(--rag-pill);
    border: 1px solid var(--rag-input-border);
    background: var(--rag-input-bg);
    color: var(--rag-text);
    outline: none;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .06);
    transition: border-color .15s ease, background .15s ease, box-shadow .15s ease;
}

.rag-input::placeholder {
    color: color-mix(in srgb, var(--rag-muted) 78%, transparent);
}

.rag-input:focus {
    border-color: color-mix(in srgb, var(--rag-accent) 55%, var(--rag-border));
    box-shadow:
        0 0 0 4px color-mix(in srgb, var(--rag-accent) 18%, transparent),
        inset 0 1px 0 rgba(255, 255, 255, .06);
    background: color-mix(in srgb, var(--rag-input-bg) 88%, rgba(255, 255, 255, .08));
}

.rag-send {
    position: relative;
    padding: 10px 14px;
    border-radius: var(--rag-pill);
    border: 0;
    cursor: pointer;

    font-weight: 900;
    letter-spacing: -0.01em;

    color: var(--rag-cta-text);
    background: var(--rag-cta-bg);
    box-shadow: var(--shadow, var(--rag-shadow-soft));
    transition: transform .16s ease, filter .16s ease, box-shadow .16s ease;
    overflow: hidden;
}

.rag-send::after {
    content: "";
    position: absolute;
    top: -30%;
    left: -40%;
    width: 52%;
    height: 160%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .65), transparent);
    transform: skewX(-18deg);
    opacity: 0;
}

.rag-send:hover {
    transform: translateY(-1px);
    filter: brightness(1.05);
    box-shadow: var(--rag-shadow);
}

.rag-send:hover::after {
    animation: ragSheen 900ms ease;
}

.rag-send:disabled {
    opacity: .65;
    filter: grayscale(.1);
    box-shadow: none;
}

/* Reset button/link */
.rag-reset {
    width: 100%;
    padding: 10px 12px 14px;
    border: 0;
    background: transparent;
    cursor: pointer;

    color: color-mix(in srgb, var(--rag-muted) 92%, transparent);
    font-weight: 900;
    letter-spacing: -0.01em;
    transition: color .15s ease, opacity .15s ease;
}

.rag-reset:hover {
    color: var(--rag-text);
}

/* =========================================================
   HERO TIGHTEN LAYER (THIS IS THE FIX)
   - makes hero chat + lead form feel native + contained
   ========================================================= */

/* constrain whole hero chat stack */
.home-hero [data-paragon-rag-chat] {
    max-width: var(--rag-hero-max);
    margin: 0 auto;
}

/* make thread feel like part of hero glass */
.home-hero .rag-thread {
    padding: 14px;
    gap: var(--rag-hero-gap);
    background:
        radial-gradient(900px 420px at 18% 0%,
            color-mix(in srgb, var(--rag-accent) 10%, transparent) 0%,
            transparent 58%),
        rgba(255, 255, 255, .52);
    border-color: rgba(16, 24, 40, .10);
    box-shadow: 0 14px 40px rgba(16, 24, 40, .10);
}

html[data-theme="dark"] .home-hero .rag-thread {
    background:
        radial-gradient(900px 420px at 18% 0%,
            color-mix(in srgb, var(--rag-accent) 14%, transparent) 0%,
            transparent 58%),
        rgba(0, 0, 0, .22);
    border-color: rgba(255, 255, 255, .10);
    box-shadow: 0 18px 56px rgba(0, 0, 0, .28);
}

/* tighter bubbles in hero */
.home-hero .rag-bubble {
    font-size: 14px;
    padding: 10px 12px;
    border-radius: 16px;
    box-shadow: 0 10px 24px rgba(0, 0, 0, .08);
}

.home-hero .rag-bubble--bot {
    background: rgba(255, 255, 255, .72);
    border-color: rgba(16, 24, 40, .10);
}

html[data-theme="dark"] .home-hero .rag-bubble--bot {
    background: rgba(255, 255, 255, .08);
    border-color: rgba(255, 255, 255, .10);
}

/* lead card should NOT look like a huge separate section */
.home-hero .rag-leadcard {
    max-width: var(--rag-hero-max);
    margin: 10px auto 0;
    padding: 12px;
    border-radius: 18px;
    background: rgba(255, 255, 255, .62);
    border-color: rgba(16, 24, 40, .10);
    box-shadow: 0 12px 34px rgba(16, 24, 40, .10);
}

html[data-theme="dark"] .home-hero .rag-leadcard {
    background: rgba(0, 0, 0, .18);
    border-color: rgba(255, 255, 255, .10);
    box-shadow: 0 16px 46px rgba(0, 0, 0, .26);
}

/* tighten copy + keep it single-line-y */
.home-hero .rag-leadcard__copy {
    margin-bottom: 8px;
    font-size: 13px;
    font-weight: 900;
    text-align: center;
}

/* lead form layout: two cols on desktop, single on mobile */
.home-hero .rag-leadform {
    gap: 10px;
}

.home-hero .rag-leadform__row input {
    height: 44px;
    border-radius: 14px;
}

@media (min-width: 860px) {
    .home-hero .rag-leadform {
        grid-template-columns: 1fr 1fr;
        align-items: start;
    }

    .home-hero .rag-leadform__row {
        margin: 0;
    }

    /* Website should span full width */
    .home-hero .rag-leadform__row:has(input[name="website"]),
    .home-hero .rag-leadform__row:has(input[name="website"])+* {
        grid-column: 1 / -1;
    }
}

/* consent + buttons: tighter and aligned */
.home-hero .rag-leadform__consent {
    grid-column: 1 / -1;
    padding: 10px 12px;
}

.home-hero .rag-leadform__submit {
    grid-column: 1 / -1;
    height: 46px;
}

/* reveal button should look like a subtle chip bar */
.home-hero .rag-leadform__reveal {
    grid-column: 1 / -1;
    height: 44px;
    border-radius: 14px;
    background: rgba(255, 255, 255, .72);
}

html[data-theme="dark"] .home-hero .rag-leadform__reveal {
    background: rgba(255, 255, 255, .06);
}

/* =========================================================
   RESPONSIVE SANITY
   ========================================================= */

@media (max-width: 520px) {
    .rag-float {
        right: 12px;
        left: 12px;
        width: auto;
    }

    .rag-fab {
        right: 12px;
        bottom: 12px;
    }
}

/* =========================================================
   HERO CHAT FLOW FIX — Conversation First
   ========================================================= */

.hero-chat [data-paragon-rag-chat] {
  display: grid;
  gap: 18px;
}

.hero-chat .rag-thread {
  margin-bottom: 4px;
}

/* Input row always visually connected to conversation */
.hero-chat .rag-form {
  margin-top: 0;
  padding-top: 0;
}

/* Lead card feels secondary */
.hero-chat .rag-leadcard {
  margin-top: 8px;
  padding: 16px 18px;
  background: rgba(0,0,0,.08);
  border: 1px solid rgba(255,255,255,.14);
  backdrop-filter: blur(6px);
  transition: transform 220ms ease, opacity 220ms ease;
}

.hero-chat .rag-leadcard:hover {
  transform: translateY(-2px);
}

/* Make form tighter */
.hero-chat .rag-leadform__row input {
  background: rgba(255,255,255,.08);
}

/* Reset link subtle */
.hero-chat .rag-reset {
  margin-top: 4px;
  font-size: 13px;
  opacity: .65;
}

.hero-chat .rag-reset:hover {
  opacity: .9;
}

.rag-leadcard--float{ margin: 10px 12px 0; padding: 12px; }
.rag-leadform--float{ gap: 10px; }
.rag-leadform--float .rag-leadform__row input{ height: 42px; }