/* ==========================================================================
   Codenbrand Chatbot — inherits the theme's design tokens (with fallbacks)
   ========================================================================== */
.cnb {
    --c-bg: #0e0e13;
    --c-surface: var(--color-surface, #16161c);
    --c-surface-2: var(--color-surface-2, #1d1d24);
    --c-border: var(--color-border, rgba(255, 255, 255, .08));
    --c-border-strong: var(--color-border-strong, rgba(255, 255, 255, .16));
    --c-text: var(--color-text, #f5f5f7);
    --c-muted: var(--color-text-muted, #9c9ca8);
    --c-faint: var(--color-text-faint, #6d6d78);
    --c-primary: var(--color-primary, #ff3346);
    --c-primary-dark: var(--color-primary-dark, #d81f31);
    --c-primary-soft: var(--color-primary-soft, rgba(255, 51, 70, .12));
    --c-green: var(--color-accent-green, #3ddc84);
    --c-ease: cubic-bezier(.22, .9, .25, 1);
    font-family: var(--font-base, 'Outfit', sans-serif);
    color: var(--c-text);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

.cnb *,
.cnb *::before,
.cnb *::after {
    box-sizing: border-box;
}

.cnb button,
.cnb input,
.cnb textarea {
    font-family: inherit;
}

.cnb-wa-hidden .whatsapp-float {
    display: none !important;
}

/* ---------- Launcher ---------- */
.cnb-launcher {
    position: fixed;
    right: 1.75rem;
    bottom: 1.75rem;
    z-index: 1000;
    width: 60px;
    height: 60px;
    border: 0;
    border-radius: 50%;
    cursor: pointer;
    color: #fff;
    background: linear-gradient(145deg, #ff4d5e 0%, var(--c-primary) 45%, var(--c-primary-dark) 100%);
    box-shadow: 0 14px 34px rgba(255, 51, 70, .38), 0 0 0 1px rgba(255, 255, 255, .12) inset;
    display: grid;
    place-items: center;
    transition: transform .3s var(--c-ease), box-shadow .3s var(--c-ease);
}

.cnb-launcher:hover {
    transform: translateY(-2px) scale(1.05);
    box-shadow: 0 18px 40px rgba(255, 51, 70, .5), 0 0 0 1px rgba(255, 255, 255, .18) inset;
}

.cnb .cnb-input:focus,
.cnb .cnb-input:focus-visible {
    outline: none;
    box-shadow: none;
}

.cnb-launcher:focus-visible,
.cnb button:focus-visible,
.cnb a:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 2px;
}

.cnb-launcher::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 2px solid var(--c-primary);
    opacity: 0;
    animation: cnb-ring 3.2s ease-out 2s 3;
    pointer-events: none;
}

@keyframes cnb-ring {
    0% { transform: scale(1); opacity: .6; }
    100% { transform: scale(1.7); opacity: 0; }
}

.cnb-launcher svg {
    width: 26px;
    height: 26px;
    grid-area: 1 / 1;
    transition: transform .35s var(--c-ease), opacity .25s;
}

.cnb-launcher .cnb-i-close {
    opacity: 0;
    transform: rotate(-90deg) scale(.6);
}

.cnb--open .cnb-launcher .cnb-i-chat {
    opacity: 0;
    transform: rotate(90deg) scale(.6);
}

.cnb--open .cnb-launcher .cnb-i-close {
    opacity: 1;
    transform: none;
}

.cnb-dot {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--c-green);
    border: 2px solid var(--c-bg);
}

.cnb--open .cnb-dot,
.cnb--seen .cnb-dot {
    display: none;
}

/* ---------- Teaser bubble ---------- */
.cnb-teaser {
    position: fixed;
    right: 1.75rem;
    bottom: calc(1.75rem + 74px);
    z-index: 1000;
    max-width: 260px;
    padding: .85rem 2rem .85rem 1rem;
    border-radius: 16px 16px 4px 16px;
    background: var(--c-surface-2);
    border: 1px solid var(--c-border-strong);
    box-shadow: 0 18px 44px rgba(0, 0, 0, .45);
    font-size: .92rem;
    cursor: pointer;
    opacity: 0;
    transform: translateY(8px) scale(.97);
    pointer-events: none;
    transition: opacity .35s var(--c-ease), transform .35s var(--c-ease);
}

.cnb-teaser--show {
    opacity: 1;
    transform: none;
    pointer-events: auto;
}

.cnb-teaser button {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 22px;
    height: 22px;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--c-muted);
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
}

.cnb-teaser button:hover {
    color: #fff;
}

/* ---------- Panel ---------- */
.cnb-panel {
    position: fixed;
    right: 1.75rem;
    bottom: calc(1.75rem + 74px);
    z-index: 1000;
    width: 410px;
    max-width: calc(100vw - 2rem);
    height: min(640px, calc(100vh - 8.5rem));
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-radius: 24px;
    background:
        radial-gradient(90% 40% at 100% 0%, rgba(255, 51, 70, .14), transparent 70%),
        radial-gradient(70% 40% at 0% 100%, rgba(91, 140, 255, .09), transparent 70%),
        rgba(14, 14, 19, .94);
    -webkit-backdrop-filter: blur(22px) saturate(140%);
    backdrop-filter: blur(22px) saturate(140%);
    border: 1px solid var(--c-border-strong);
    box-shadow: 0 40px 90px rgba(0, 0, 0, .6), 0 0 0 1px rgba(0, 0, 0, .4);
    transform-origin: bottom right;
    opacity: 0;
    visibility: hidden;
    transform: translateY(16px) scale(.96);
    transition: opacity .28s var(--c-ease), transform .32s var(--c-ease), visibility .28s;
}

.cnb--open .cnb-panel {
    opacity: 1;
    visibility: visible;
    transform: none;
}

/* Header */
.cnb-head {
    display: flex;
    align-items: center;
    gap: .8rem;
    padding: 1rem 1rem .9rem 1.1rem;
    border-bottom: 1px solid var(--c-border);
    background: linear-gradient(180deg, rgba(255, 255, 255, .04), transparent);
    position: relative;
}

.cnb-avatar {
    position: relative;
    flex: none;
    width: 42px;
    height: 42px;
    border-radius: 14px;
    display: grid;
    place-items: center;
    font-weight: 700;
    font-size: 1.15rem;
    color: #fff;
    background: linear-gradient(145deg, #ff4d5e, var(--c-primary-dark));
    box-shadow: 0 8px 20px rgba(255, 51, 70, .35);
}

.cnb-avatar::after {
    content: '';
    position: absolute;
    right: -3px;
    bottom: -3px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--c-green);
    border: 2px solid #0e0e13;
}

.cnb-title {
    flex: 1;
    min-width: 0;
}

.cnb-title strong {
    display: block;
    font-size: 1.02rem;
    font-weight: 600;
    letter-spacing: -.01em;
}

.cnb-title span {
    display: block;
    font-size: .78rem;
    color: var(--c-muted);
}

.cnb-iconbtn {
    flex: none;
    width: 34px;
    height: 34px;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: var(--c-muted);
    cursor: pointer;
    display: grid;
    place-items: center;
    transition: background .2s, color .2s;
}

.cnb-iconbtn:hover {
    background: rgba(255, 255, 255, .08);
    color: #fff;
}

.cnb-iconbtn svg {
    width: 18px;
    height: 18px;
}

/* Progress */
.cnb-progress {
    height: 2px;
    background: transparent;
}

.cnb-progress i {
    display: block;
    height: 100%;
    width: 0;
    background: linear-gradient(90deg, var(--c-primary), #ff8a5c);
    transition: width .6s var(--c-ease);
}

/* Menu */
.cnb-menu {
    position: absolute;
    top: 58px;
    right: 12px;
    z-index: 5;
    min-width: 210px;
    padding: .4rem;
    border-radius: 14px;
    background: var(--c-surface-2);
    border: 1px solid var(--c-border-strong);
    box-shadow: 0 20px 50px rgba(0, 0, 0, .55);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-6px);
    transition: opacity .2s, transform .2s, visibility .2s;
}

.cnb-menu--open {
    opacity: 1;
    visibility: visible;
    transform: none;
}

.cnb-menu a,
.cnb-menu button {
    display: flex;
    width: 100%;
    align-items: center;
    gap: .65rem;
    padding: .6rem .7rem;
    border: 0;
    border-radius: 9px;
    background: transparent;
    color: var(--c-text);
    font-size: .92rem;
    text-align: left;
    cursor: pointer;
    text-decoration: none;
}

.cnb-menu a:hover,
.cnb-menu button:hover {
    background: rgba(255, 255, 255, .07);
}

.cnb-menu svg {
    width: 17px;
    height: 17px;
    color: var(--c-muted);
}

/* Log */
.cnb-log {
    flex: 1;
    overflow-y: auto;
    padding: 1.1rem 1rem .5rem;
    display: flex;
    flex-direction: column;
    gap: .55rem;
    scroll-behavior: smooth;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, .18) transparent;
}

.cnb-msg {
    max-width: 86%;
    padding: .65rem .95rem;
    border-radius: 18px;
    font-size: .95rem;
    word-wrap: break-word;
    overflow-wrap: anywhere;
    animation: cnb-in .38s var(--c-ease) both;
}

.cnb-msg a {
    color: #ff7a88;
    text-decoration: underline;
}

.cnb-msg--bot {
    align-self: flex-start;
    background: var(--c-surface-2);
    border: 1px solid var(--c-border);
    border-bottom-left-radius: 6px;
}

.cnb-msg--user {
    align-self: flex-end;
    color: #fff;
    background: linear-gradient(145deg, #ff4d5e, var(--c-primary-dark));
    border-bottom-right-radius: 6px;
    box-shadow: 0 8px 22px rgba(255, 51, 70, .25);
}

.cnb-msg small {
    display: block;
    margin-top: .35rem;
    color: var(--c-muted);
    font-size: .76rem;
    line-height: 1.4;
}

@keyframes cnb-in {
    from { opacity: 0; transform: translateY(10px) scale(.98); }
    to { opacity: 1; transform: none; }
}

/* Typing */
.cnb-typing {
    align-self: flex-start;
    display: flex;
    gap: 5px;
    padding: .85rem 1rem;
    border-radius: 18px;
    border-bottom-left-radius: 6px;
    background: var(--c-surface-2);
    border: 1px solid var(--c-border);
    animation: cnb-in .3s var(--c-ease) both;
}

.cnb-typing i {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--c-muted);
    animation: cnb-bounce 1.1s infinite ease-in-out;
}

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

@keyframes cnb-bounce {
    0%, 60%, 100% { transform: translateY(0); opacity: .5; }
    30% { transform: translateY(-5px); opacity: 1; }
}

/* Chips */
.cnb-chips {
    display: flex;
    flex-wrap: wrap;
    gap: .45rem;
    padding: .15rem 0 .4rem;
    animation: cnb-in .4s var(--c-ease) both;
}

.cnb-chip {
    padding: .5rem .95rem;
    border-radius: 999px;
    border: 1px solid var(--c-border-strong);
    background: rgba(255, 255, 255, .03);
    color: var(--c-text);
    font-size: .88rem;
    cursor: pointer;
    transition: background .2s, border-color .2s, transform .2s, color .2s;
}

.cnb-chip:hover {
    background: var(--c-primary-soft);
    border-color: var(--c-primary);
    transform: translateY(-1px);
}

.cnb-chip:active {
    transform: scale(.97);
}

.cnb-chip--primary {
    background: var(--c-primary);
    border-color: var(--c-primary);
    color: #fff;
    font-weight: 500;
}

.cnb-chip--primary:hover {
    background: var(--c-primary-dark);
}

/* Cards */
.cnb-rail {
    display: flex;
    gap: .65rem;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    margin: 0 -1rem;
    padding: .1rem 1rem .5rem;
    scrollbar-width: none;
    animation: cnb-in .45s var(--c-ease) both;
}

.cnb-rail::-webkit-scrollbar {
    display: none;
}

.cnb-card {
    flex: none;
    width: 232px;
    scroll-snap-align: start;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-radius: 16px;
    background: var(--c-surface);
    border: 1px solid var(--c-border-strong);
    color: inherit;
    text-decoration: none;
    transition: transform .3s var(--c-ease), border-color .3s;
}

.cnb-card--solo {
    width: 100%;
    max-width: 290px;
    align-self: flex-start;
    animation: cnb-in .45s var(--c-ease) both;
}

.cnb-card:hover {
    transform: translateY(-3px);
    border-color: var(--c-primary);
}

.cnb-card__img {
    aspect-ratio: 16 / 9;
    background: linear-gradient(135deg, #24242d, #15151b) center / cover no-repeat;
}

.cnb-card__body {
    padding: .75rem .85rem .85rem;
}

.cnb-card__tag {
    font-size: .68rem;
    letter-spacing: .09em;
    text-transform: uppercase;
    color: var(--c-primary);
    font-weight: 600;
}

.cnb-card__title {
    margin: .15rem 0 .25rem;
    font-size: .97rem;
    font-weight: 600;
    line-height: 1.3;
}

.cnb-card__text {
    font-size: .8rem;
    color: var(--c-muted);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.cnb-card__cta {
    margin-top: .55rem;
    font-size: .82rem;
    font-weight: 500;
    color: #fff;
}

/* Summary */
.cnb-summary {
    align-self: stretch;
    border-radius: 16px;
    border: 1px solid var(--c-border-strong);
    background: var(--c-surface);
    padding: .85rem 1rem;
    animation: cnb-in .45s var(--c-ease) both;
}

.cnb-summary h4 {
    margin: 0 0 .5rem;
    font-size: .72rem;
    letter-spacing: .1em;
    text-transform: uppercase;
    color: var(--c-primary);
    font-weight: 600;
}

.cnb-summary dl {
    margin: 0;
    display: grid;
    grid-template-columns: 82px 1fr;
    gap: .3rem .6rem;
    font-size: .86rem;
}

.cnb-summary dt {
    color: var(--c-muted);
}

.cnb-summary dd {
    margin: 0;
    overflow-wrap: anywhere;
}

/* Composer */
.cnb-compose {
    padding: .65rem .85rem .35rem;
    border-top: 1px solid var(--c-border);
}

.cnb-compose form {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .3rem .3rem .3rem 1rem;
    border-radius: 999px;
    background: var(--c-surface);
    border: 1px solid var(--c-border-strong);
    transition: border-color .2s;
}

.cnb-compose form:focus-within {
    border-color: var(--c-primary);
}

.cnb-input {
    flex: 1;
    min-width: 0;
    border: 0;
    outline: 0;
    background: transparent;
    color: var(--c-text);
    font-size: .95rem;
    padding: .45rem 0;
}

.cnb-input::placeholder {
    color: var(--c-faint);
}

.cnb-send {
    flex: none;
    width: 38px;
    height: 38px;
    border: 0;
    border-radius: 50%;
    background: var(--c-primary);
    color: #fff;
    cursor: pointer;
    display: grid;
    place-items: center;
    transition: background .2s, transform .2s;
}

.cnb-send:hover {
    background: var(--c-primary-dark);
    transform: scale(1.06);
}

.cnb-send svg {
    width: 17px;
    height: 17px;
}

.cnb-foot {
    padding: .1rem 1rem .6rem;
    text-align: center;
    font-size: .7rem;
    color: var(--c-faint);
}

.cnb-hp {
    position: absolute;
    left: -9999px;
    width: 1px;
    height: 1px;
    opacity: 0;
}

/* ---------- Mobile: full-screen sheet ---------- */
@media (max-width: 520px) {
    .cnb-launcher,
    .cnb-teaser {
        right: 1rem;
    }

    .cnb-launcher {
        bottom: 1rem;
        width: 56px;
        height: 56px;
    }

    .cnb-teaser {
        bottom: calc(1rem + 68px);
    }

    .cnb-panel {
        inset: 0;
        width: 100%;
        max-width: none;
        height: 100%;
        height: 100dvh;
        border-radius: 0;
        border: 0;
        transform: translateY(24px);
    }

    .cnb--open .cnb-launcher {
        display: none;
    }

    .cnb-head {
        padding-top: max(1rem, env(safe-area-inset-top));
    }

    .cnb-compose {
        padding-bottom: max(.35rem, env(safe-area-inset-bottom));
    }

    .cnb-input {
        font-size: 16px; /* stops iOS zoom on focus */
    }
}

@media (prefers-reduced-motion: reduce) {
    .cnb *,
    .cnb *::before,
    .cnb *::after {
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
    }
}

/* ---------- Quick-action pills (top of conversation) ---------- */
.cnb-quick {
    display: flex;
    flex-wrap: wrap;
    gap: .4rem;
    margin-bottom: .35rem;
    animation: cnb-in .45s var(--c-ease) both;
}

.cnb a.cnb-pill {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .38rem .8rem;
    border-radius: 999px;
    border: 1px solid var(--c-border-strong);
    background: rgba(255, 255, 255, .04);
    color: var(--c-text);
    font-size: .8rem;
    font-weight: 500;
    line-height: 1.2;
    text-decoration: none;
    transition: background .2s, border-color .2s, transform .2s;
}

.cnb a.cnb-pill svg {
    width: 14px;
    height: 14px;
    color: var(--c-primary);
}

.cnb a.cnb-pill:hover {
    background: var(--c-primary-soft);
    border-color: var(--c-primary);
    transform: translateY(-1px);
}

/* Log children must never shrink (this was cropping the project thumbnails) */
.cnb-log > * {
    flex-shrink: 0;
}

/* 2 x 2 grid of cards (used for "Show me your work") */
.cnb-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: .6rem;
    animation: cnb-in .45s var(--c-ease) both;
}

.cnb-grid .cnb-card {
    width: auto;
}

.cnb-grid .cnb-card__body {
    padding: .6rem .7rem .7rem;
}

.cnb-grid .cnb-card__title {
    font-size: .88rem;
}

.cnb-grid .cnb-card__text {
    display: none;
}

/* No entrance animation when a conversation is restored on a new page */
.cnb-restored > *,
.cnb-restored .cnb-msg,
.cnb-restored .cnb-chips {
    animation: none !important;
}

/* ---------- Technologies box ---------- */
.cnb-tech {
    align-self: stretch;
    padding: .85rem 1rem .4rem;
    border-radius: 16px;
    border: 1px solid var(--c-border-strong);
    background: var(--c-surface);
    animation: cnb-in .45s var(--c-ease) both;
}

.cnb-tech__group {
    margin-bottom: .65rem;
}

.cnb-tech h4 {
    margin: 0 0 .35rem;
    font-size: .68rem;
    letter-spacing: .1em;
    text-transform: uppercase;
    color: var(--c-primary);
    font-weight: 600;
}

.cnb-tech__tags {
    display: flex;
    flex-wrap: wrap;
    gap: .35rem;
}

.cnb-tech__tags span {
    padding: .22rem .65rem;
    border-radius: 999px;
    border: 1px solid var(--c-border-strong);
    background: rgba(255, 255, 255, .04);
    font-size: .8rem;
}
