/* ============================================================
   COWMA V3
   Editorial assistant for fassidesouza.com
   ============================================================ */

:root {
    --cowma-accent: var(--ghost-accent-color, #0033FF);

    --cowma-text: var(--color-font-one, #080b12);
    --cowma-body: var(--color-body, #ffffff);
    --cowma-soft: var(--color-one, #f1f1f3);
    --cowma-border: var(--color-border-one, #dfe2e6);

    --cowma-heading-font:
        var(--font-family-one, "Fraunces", serif);

    --cowma-body-font:
        var(
            --font-family-three,
            -apple-system,
            BlinkMacSystemFont,
            "Segoe UI",
            sans-serif
        );

    --cowma-radius: var(--border-radius, 22px);

    --cowma-glass:
        rgba(255, 255, 255, .76);

    --cowma-glass-strong:
        rgba(255, 255, 255, .92);

    --cowma-shadow:
        0 4px 14px rgba(0, 0, 0, .05),
        0 20px 60px rgba(0, 0, 0, .14);
}


/* ============================================================
   Scope
   ============================================================ */

#cowma-launcher,
#cowma-panel,
#cowma-panel * {
    box-sizing: border-box;
}


/* ============================================================
   Launcher
   ============================================================ */

#cowma-launcher {
    position: fixed;

    right: 22px;
    bottom: 22px;

    z-index: 2147483000;

    display: flex;
    align-items: center;

    gap: 8px;

    padding: 0;

    appearance: none;

    border: 0;
    outline: 0;

    background: transparent;
    color: var(--cowma-text);

    font-family: var(--cowma-body-font);

    cursor: pointer;
}

#cowma-launcher[hidden] {
    display: none;
}


/* Label */

.cowma-launcher-label {
    display: flex;
    align-items: center;

    min-height: 38px;

    padding: 0 13px;

    border: 1px solid rgba(255, 255, 255, .68);
    border-radius: 999px;

    background: rgba(255, 255, 255, .68);

    box-shadow:
        0 4px 14px rgba(0, 0, 0, .055),
        inset 0 1px 0 rgba(255, 255, 255, .7);

    -webkit-backdrop-filter:
        blur(13px) saturate(125%);

    backdrop-filter:
        blur(13px) saturate(125%);

    font-size: 1.05rem;
    font-weight: 500;
    line-height: 1;

    transition:
        color .18s ease,
        background-color .18s ease,
        transform .18s ease;
}


/* Bubble */

.cowma-launcher-bubble {
    flex: 0 0 auto;

    display: grid;
    place-items: center;

    width: 50px;
    height: 50px;

    border: 1px solid rgba(255, 255, 255, .72);
    border-radius: 999px;

    background: var(--cowma-glass);

    box-shadow:
        0 5px 18px rgba(0, 0, 0, .09),
        inset 0 1px 0 rgba(255, 255, 255, .7);

    -webkit-backdrop-filter:
        blur(14px) saturate(130%);

    backdrop-filter:
        blur(14px) saturate(130%);

    transition:
        transform .18s ease,
        color .18s ease,
        background-color .18s ease,
        box-shadow .18s ease;
}

.cowma-launcher-bubble svg {
    width: 22px;
    height: 22px;
}

#cowma-launcher:hover
.cowma-launcher-label {
    color: var(--cowma-accent);

    background: rgba(255, 255, 255, .88);

    transform: translateY(-1px);
}

#cowma-launcher:hover
.cowma-launcher-bubble {
    color: var(--cowma-accent);

    background: rgba(255, 255, 255, .94);

    transform: translateY(-2px);

    box-shadow:
        0 8px 24px rgba(0, 0, 0, .12),
        inset 0 1px 0 rgba(255, 255, 255, .8);
}

#cowma-launcher:focus-visible
.cowma-launcher-bubble {
    outline: 2px solid var(--cowma-accent);
    outline-offset: 3px;
}


/* ============================================================
   Panel
   ============================================================ */

#cowma-panel {
    position: fixed;

    right: 18px;
    bottom: 18px;

    z-index: 2147483001;

    display: none;
    flex-direction: column;

    width:
        min(
            520px,
            calc(100vw - 36px)
        );

    height:
        min(
            760px,
            calc(100vh - 36px)
        );

    overflow: hidden;

    color: var(--cowma-text);

    border:
        1px solid
        rgba(255, 255, 255, .7);

    border-radius:
        var(--cowma-radius);

    background:
        color-mix(
            in srgb,
            var(--cowma-body) 96%,
            transparent
        );

    box-shadow:
        var(--cowma-shadow);

    -webkit-backdrop-filter:
        blur(18px);

    backdrop-filter:
        blur(18px);

    font-family:
        var(--cowma-body-font);

    transition:
        width .22s ease,
        height .22s ease,
        right .22s ease,
        bottom .22s ease;
}

#cowma-panel.is-open {
    display: flex;
}

#cowma-panel.is-expanded {
    width:
        min(
            900px,
            calc(100vw - 36px)
        );

    height:
        calc(100vh - 36px);
}


/* ============================================================
   Header
   ============================================================ */

.cowma-header {
    flex: 0 0 auto;

    display: flex;
    align-items: center;
    justify-content: space-between;

    gap: 18px;

    min-height: 72px;

    padding: 13px 16px;

    border-bottom:
        1px solid
        var(--cowma-border);

    background:
        var(--cowma-glass-strong);

    -webkit-backdrop-filter:
        blur(18px) saturate(120%);

    backdrop-filter:
        blur(18px) saturate(120%);
}

.cowma-identity {
    display: flex;
    align-items: center;

    min-width: 0;

    gap: 11px;
}

.cowma-header-icon {
    flex: 0 0 auto;

    display: grid;
    place-items: center;

    width: 36px;
    height: 36px;

    color: var(--cowma-accent);

    border:
        1px solid
        var(--cowma-border);

    border-radius: 999px;

    background:
        rgba(255, 255, 255, .56);
}

.cowma-header-icon svg {
    width: 19px;
    height: 19px;
}

.cowma-header-copy {
    min-width: 0;
}

.cowma-name {
    font-family:
        var(--cowma-heading-font);

    font-size: 2rem;
    font-weight: 700;
    line-height: 1.05;
}

.cowma-tagline {
    margin-top: 4px;

    overflow: hidden;

    opacity: .63;

    font-size: 1.1rem;
    line-height: 1.3;

    white-space: nowrap;
    text-overflow: ellipsis;
}

.cowma-header-actions {
    flex: 0 0 auto;

    display: flex;
    align-items: center;

    gap: 4px;
}

.cowma-icon-button,
.cowma-text-button {
    appearance: none;

    border: 0;
    outline: 0;

    background: transparent;
    color: var(--cowma-text);

    font-family:
        var(--cowma-body-font);

    cursor: pointer;

    transition:
        background-color .16s ease,
        color .16s ease;
}

.cowma-icon-button {
    display: grid;
    place-items: center;

    width: 34px;
    height: 34px;

    padding: 0;

    border-radius: 999px;

    font-size: 1.8rem;
}

.cowma-text-button {
    padding: 8px 9px;

    border-radius: 999px;

    opacity: .58;

    font-size: 1rem;
}

.cowma-icon-button:hover,
.cowma-text-button:hover {
    color: var(--cowma-accent);

    background:
        var(--cowma-soft);
}


/* ============================================================
   Messages area
   ============================================================ */

#cowma-messages {
    flex: 1 1 auto;

    display: flex;
    flex-direction: column;

    overflow-y: auto;
    overscroll-behavior: contain;

    min-height: 0;

    padding:
        25px 18px 34px;

    scroll-behavior: smooth;

    scrollbar-width: thin;

    scrollbar-color:
        rgba(0, 0, 0, .2)
        transparent;
}


/*
 * Empty state:
 * introduction and suggestions live
 * immediately above the composer.
 */
#cowma-messages.is-empty {
    justify-content: flex-end;
}


.cowma-message-row {
    display: flex;

    flex: 0 0 auto;

    width: 100%;

    margin-bottom: 25px;
}

#cowma-messages.is-empty
.cowma-message-row {
    margin-bottom: 0;
}

.cowma-message-row.user {
    justify-content: flex-end;
}

.cowma-message-row.assistant {
    justify-content: flex-start;
}


/* ============================================================
   User message
   ============================================================ */

.cowma-message-row.user
.cowma-message {
    max-width: 78%;

    padding:
        11px 16px;

    color: #fff;

    border-radius:
        20px 20px 5px 20px;

    background:
        var(--cowma-accent);

    font-size: 1.3rem;
    line-height: 1.45;
}


/* ============================================================
   Assistant message
   ============================================================ */

.cowma-message-row.assistant
.cowma-message {
    width: 100%;
    max-width: 100%;
}

.cowma-assistant-label {
    margin-bottom: 8px;

    opacity: .55;

    font-size: 1.05rem;
    font-weight: 500;
}


/* ============================================================
   Markdown
   ============================================================ */

.cowma-markdown {
    font-size: 1.35rem;
    line-height: 1.63;
}

.cowma-markdown > :first-child {
    margin-top: 0;
}

.cowma-markdown > :last-child {
    margin-bottom: 0;
}

.cowma-markdown p {
    margin:
        0 0 1.15em;
}

.cowma-markdown h1,
.cowma-markdown h2,
.cowma-markdown h3,
.cowma-markdown h4 {
    width: auto;

    margin:
        1.6em 0 .55em;

    color:
        var(--cowma-text);

    font-family:
        var(--cowma-heading-font);

    font-weight: 700;
    line-height: 1.15;
}

.cowma-markdown h1 {
    font-size: 2.4rem;
}

.cowma-markdown h2 {
    font-size: 2rem;
}

.cowma-markdown h3 {
    font-size: 1.65rem;
}

.cowma-markdown h4 {
    font-size: 1.45rem;
}

.cowma-markdown strong {
    font-weight: 700;
}

.cowma-markdown em {
    font-style: italic;
}

.cowma-markdown a {
    color:
        var(--cowma-accent);

    text-decoration: underline;

    text-decoration-thickness:
        1px;

    text-underline-offset:
        3px;
}

.cowma-markdown a:hover {
    text-decoration-thickness:
        2px;
}

.cowma-markdown ul,
.cowma-markdown ol {
    margin:
        .5em 0 1.3em;

    padding-left:
        1.55em;
}

.cowma-markdown li {
    margin: .35em 0;

    padding-left: .15em;
}

.cowma-markdown blockquote {
    margin:
        1.4em 0;

    padding:
        .15em 0
        .15em 1.1em;

    opacity: .82;

    border-left:
        2px solid
        var(--cowma-accent);

    font-family:
        var(--cowma-heading-font);

    font-size: 1.45rem;
    line-height: 1.55;
}

.cowma-markdown code {
    padding:
        .15em .38em;

    border-radius: 5px;

    background:
        var(--cowma-soft);

    font-family:
        ui-monospace,
        SFMono-Regular,
        Menlo,
        Monaco,
        Consolas,
        monospace;

    font-size: .9em;
}

.cowma-markdown pre {
    overflow-x: auto;

    margin:
        1.3em 0;

    padding: 14px;

    border-radius:
        calc(
            var(--cowma-radius) / 2
        );

    background:
        var(--cowma-soft);
}

.cowma-markdown pre code {
    padding: 0;

    background: transparent;
}


/* ============================================================
   Sources
   ============================================================ */

.cowma-sources {
    margin-top: 22px;
    padding-top: 15px;

    border-top:
        1px solid
        var(--cowma-border);
}

.cowma-sources-title {
    margin-bottom: 10px;

    opacity: .5;

    font-family:
        var(--cowma-body-font);

    font-size: .95rem;
    font-weight: 600;

    letter-spacing: .05em;
    text-transform: uppercase;
}

.cowma-source-list {
    display: flex;
    flex-direction: column;

    gap: 5px;
}

.cowma-source {
    display: flex;
    align-items: baseline;

    gap: 5px;

    width: fit-content;
    max-width: 100%;

    padding: 2px 0;

    color:
        var(--cowma-text);

    border: 0;
    border-radius: 0;

    background: transparent;

    font-family:
        var(--cowma-body-font);

    text-decoration: none;

    transition:
        color .15s ease;
}

.cowma-source::before {
    content: "•";

    flex: 0 0 auto;

    opacity: .45;

    color:
        var(--cowma-text);
}

.cowma-source:hover {
    color:
        var(--cowma-accent);

    background: transparent;

    transform: none;
}

.cowma-source-title {
    overflow: hidden;

    max-width: 100%;

    font-family:
        var(--cowma-body-font);

    font-size: 1.15rem;
    font-weight: 400;
    line-height: 1.45;

    white-space: nowrap;
    text-overflow: ellipsis;
}

.cowma-source:hover
.cowma-source-title {
    text-decoration: underline;

    text-decoration-thickness: 1px;
    text-underline-offset: 3px;
}

.cowma-source-arrow {
    flex: 0 0 auto;

    color:
        var(--cowma-accent);

    font-size: 1.05rem;
}


/* ============================================================
   Loading
   ============================================================ */

.cowma-loading {
    display: inline-flex;
    align-items: center;

    gap: 5px;

    opacity: .6;

    font-size: 1.25rem;
}

.cowma-loading-dot {
    width: 5px;
    height: 5px;

    border-radius: 50%;

    background: currentColor;

    animation:
        cowma-pulse
        1.1s
        infinite;
}

.cowma-loading-dot:nth-child(2) {
    animation-delay: .15s;
}

.cowma-loading-dot:nth-child(3) {
    animation-delay: .3s;
}

@keyframes cowma-pulse {

    0%,
    80%,
    100% {
        opacity: .2;
    }

    40% {
        opacity: 1;
    }

}


/* ============================================================
   Suggestions
   ============================================================ */

.cowma-suggestions {
    display: flex;
    flex-wrap: wrap;

    gap: 7px;

    margin-top: 17px;
}

.cowma-suggestion {
    appearance: none;

    padding:
        8px 11px;

    color:
        var(--cowma-text);

    border:
        1px solid
        var(--cowma-border);

    border-radius: 999px;

    background: transparent;

    font-family:
        var(--cowma-body-font);

    font-size: 1.05rem;
    line-height: 1.25;

    cursor: pointer;

    transition:
        color .16s ease,
        border-color .16s ease,
        background-color .16s ease;
}

.cowma-suggestion:hover {
    color:
        var(--cowma-accent);

    border-color:
        color-mix(
            in srgb,
            var(--cowma-accent) 40%,
            var(--cowma-border)
        );

    background:
        color-mix(
            in srgb,
            var(--cowma-accent) 4%,
            transparent
        );
}


/* ============================================================
   Composer
   ============================================================ */

.cowma-composer-wrap {
    flex: 0 0 auto;

    padding:
        12px 12px 9px;

    border-top:
        1px solid
        var(--cowma-border);

    background:
        var(--cowma-glass-strong);

    -webkit-backdrop-filter:
        blur(18px);

    backdrop-filter:
        blur(18px);
}

#cowma-form {
    display: flex;
    align-items: flex-end;

    gap: 8px;

    padding:
        5px 5px
        5px 15px;

    border:
        1px solid
        color-mix(
            in srgb,
            var(--cowma-text) 32%,
            transparent
        );

    border-radius: 999px;

    background:
        color-mix(
            in srgb,
            var(--cowma-body) 84%,
            transparent
        );

    transition:
        border-color .16s ease,
        box-shadow .16s ease;
}

#cowma-form:focus-within {
    border-color:
        var(--cowma-accent);

    box-shadow:
        0 0 0 2px
        color-mix(
            in srgb,
            var(--cowma-accent) 10%,
            transparent
        );
}

#cowma-input {
    flex: 1 1 auto;

    min-width: 0;
    max-height: 120px;

    resize: none;

    padding: 8px 0;

    border: 0;
    outline: 0;

    background: transparent;

    color:
        var(--cowma-text);

    font-family:
        var(--cowma-body-font);

    font-size: 1.2rem;
    line-height: 1.4;
}

#cowma-input::placeholder {
    opacity: .45;

    color:
        var(--cowma-text);
}

#cowma-send {
    flex: 0 0 auto;

    display: grid;
    place-items: center;

    width: 36px;
    height: 36px;

    padding: 0;

    color: #fff;

    border: 0;
    border-radius: 999px;

    background:
        var(--cowma-accent);

    font-size: 1.8rem;
    line-height: 1;

    cursor: pointer;

    transition:
        transform .16s ease,
        opacity .16s ease;
}

#cowma-send:hover:not(:disabled) {
    transform:
        translateY(-1px);
}

#cowma-send:disabled {
    opacity: .35;

    cursor: default;
}

.cowma-disclaimer {
    padding:
        7px 6px 0;

    opacity: .42;

    text-align: center;

    font-size: .85rem;
    line-height: 1.35;
}


/* ============================================================
   Tablet
   ============================================================ */

@media (max-width: 768px) {

    #cowma-panel {
        right: 12px;
        bottom: 12px;

        width:
            min(
                560px,
                calc(100vw - 24px)
            );

        height:
            min(
                82dvh,
                720px
            );
    }

    #cowma-panel.is-expanded {
        width:
            calc(100vw - 24px);

        height:
            88dvh;
    }

}


/* ============================================================
   Mobile
   ============================================================ */

@media (max-width: 640px) {

    #cowma-launcher {
        right: 14px;
        bottom: 14px;

        gap: 7px;
    }

    .cowma-launcher-label {
        min-height: 36px;

        padding:
            0 11px;

        font-size: 1rem;
    }

    .cowma-launcher-bubble {
        width: 48px;
        height: 48px;
    }


    /*
     * Cowma no longer takes over
     * the whole mobile viewport.
     */
    #cowma-panel,
    #cowma-panel.is-expanded {
        top: auto;

        right: 10px;
        bottom:
            max(
                10px,
                env(safe-area-inset-bottom)
            );

        left: 10px;

        width:
            calc(100vw - 20px);

        height:
            min(
                88dvh,
                720px
            );

        border:
            1px solid
            rgba(255, 255, 255, .72);

        border-radius:
            calc(
                var(--cowma-radius) * .9
            );
    }

    .cowma-header {
        min-height: 65px;

        padding:
            11px 12px;
    }

    .cowma-header-icon {
        width: 32px;
        height: 32px;
    }

    .cowma-header-icon svg {
        width: 17px;
        height: 17px;
    }

    .cowma-name {
        font-size: 1.75rem;
    }

    .cowma-tagline {
        max-width: 205px;

        font-size: .95rem;
    }

    .cowma-text-button {
    display: inline-flex;
    align-items: center;

    padding: 7px 8px;

    font-size: .95rem;
    opacity: .58;
}

#cowma-expand {
    display: none;
}
  @media (max-width: 480px) {

    .cowma-tagline {
        display: none;
    }

}

    #cowma-messages {
        padding:
            18px 13px 25px;
    }

    .cowma-message-row.user
    .cowma-message {
        max-width: 88%;
    }

    .cowma-markdown {
        font-size: 1.28rem;
    }

    .cowma-suggestions {
        gap: 6px;

        margin-top: 14px;
    }

    .cowma-suggestion {
        padding:
            7px 9px;

        font-size: .98rem;
    }

    .cowma-composer-wrap {
        padding:
            10px 9px
            calc(
                8px +
                env(safe-area-inset-bottom)
            );
    }

}


/* ============================================================
   Small phones
   ============================================================ */

@media (max-width: 430px) {

    /*
     * On narrow phones the bubble remains identifiable,
     * while the label disappears to preserve room.
     */
    .cowma-launcher-label {
        display: none;
    }

    #cowma-panel,
    #cowma-panel.is-expanded {
        height: 86dvh;
    }

    .cowma-tagline {
        max-width: 175px;
    }

}