/* Where the AI router sits (assets/js/router-dock.js). On the homepage the
   router stays where it is in the page and becomes position: fixed when it
   docks to the bottom or opens as the chat window; the hero keeps its place
   and height meanwhile. Every other page has the chat box: the same window,
   opened from the square. */

/* The hero is a stacking context (z-index 1, from the liquid-crystal host)
   under the sections after it; lifted above them while the router is away,
   so the bar and the window aren't painted under the page. */
.wp-block-uagb-container.alignfull.has-router-away {
    z-index: 3;
}

/* Conversations live in the chat window now, so the hero keeps its own layout
   while chatting (assistant.css used to make it one screen tall around the
   thread). These are Spectra's values for block 444da24a and its bar block. */
@supports selector(:has(*)) {
    .wp-block-uagb-container.uagb-block-444da24a:has(> .wp-block-uagb-container > .aurify-ai-router.is-chatting) {
        height: auto;
        min-height: 100vh;
        padding-top: 0;
        padding-bottom: 0;
        flex-wrap: nowrap;
    }

    .wp-block-uagb-container.uagb-block-444da24a:has(> .wp-block-uagb-container > .aurify-ai-router.is-chatting) > .wp-block-uagb-container {
        flex-shrink: 1;
        min-height: auto;
    }

    @media (min-width: 768px) and (max-width: 976px) {
        .wp-block-uagb-container.uagb-block-444da24a:has(> .wp-block-uagb-container > .aurify-ai-router.is-chatting) {
            padding-top: 100px;
        }
    }

    @media (max-width: 767px) {
        .wp-block-uagb-container.uagb-block-444da24a:has(> .wp-block-uagb-container > .aurify-ai-router.is-chatting),
        .wp-block-uagb-container.uagb-block-444da24a:has(> .wp-block-uagb-container > .aurify-ai-router.is-chatting) > .uagb-block-d79991cf {
            flex-wrap: wrap;
        }
    }
}

.aurify-ai-router:not(.is-window) > .aurify-assistant {
    display: none !important;
}

/* Nothing under the bar once it has left the hero: the empty paragraph
   WordPress leaves in the form, and the character count (it would push the
   bar up as typing starts). */
.aurify-ai-router:is(.is-docked, .is-window) .aurify-ai-router__form > p:empty,
.aurify-ai-router:is(.is-docked, .is-window) .aurify-ai-router__count {
    display: none;
}

/* ==========================================================
   DOCKED: the bar at the bottom of the screen
========================================================== */

.aurify-ai-router.is-docked {
    position: fixed !important; /* Spectra's container children rule says relative, with a long selector */
    left: 0;
    right: 0;
    bottom: calc(18px + env(safe-area-inset-bottom, 0px));
    z-index: 40;
    box-sizing: border-box;
    width: min(600px, calc(100% - 32px)) !important;
    max-width: none !important;
    margin: 0 auto !important;
    transform-origin: 50% 100%;
    will-change: transform;
    /* Rides on the on-screen keyboard while typing on a phone. */
    translate: 0 calc(-1 * var(--aurify-dock-lift, 0px));
}

/* ==========================================================
   THE CHAT WINDOW: bottom right, the bar at its bottom
========================================================== */

.aurify-ai-router.is-window {
    position: fixed !important;
    top: auto;
    left: auto;
    right: 24px;
    bottom: calc(24px + env(safe-area-inset-bottom, 0px));
    z-index: 40;
    box-sizing: border-box;
    display: flex !important;
    flex-direction: column;
    width: min(440px, calc(100% - 48px)) !important;
    max-width: none !important;
    height: min(680px, calc(100vh - var(--aurify-chat-top, 98px) - 24px));
    height: min(680px, calc(100dvh - var(--aurify-chat-top, 98px) - 24px));
    margin: 0 !important;
    padding: 12px;
    border-radius: 22px;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, .075), rgba(255, 255, 255, .015) 40%, rgba(255, 255, 255, .035)),
        rgba(8, 10, 14, .78);
    -webkit-backdrop-filter: blur(18px) saturate(150%);
    backdrop-filter: blur(18px) saturate(150%);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, .26),
        inset 0 -1px 0 rgba(255, 255, 255, .07),
        inset 0 22px 34px -26px rgba(255, 255, 255, .22),
        0 24px 60px rgba(0, 0, 0, .5);
    overscroll-behavior: contain;
    transform-origin: 100% 100%;
    will-change: transform;
}

/* The glass edge: brighter at the top left and bottom right, as on the page's glass panels. */
.aurify-ai-router.is-window::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 3;
    padding: 1.25px;
    border-radius: inherit;
    background: linear-gradient(135deg, rgba(255, 255, 255, .5), rgba(255, 255, 255, .08) 26%, rgba(255, 255, 255, .03) 52%, rgba(255, 255, 255, .08) 76%, rgba(255, 255, 255, .34));
    -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
    -webkit-mask-composite: xor;
    mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0);
    pointer-events: none;
}

.aurify-ai-router.is-window > .aurify-assistant:not([hidden]),
.aurify-ai-router--chat.is-window > .aurify-assistant {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
    margin: 0 0 10px;
}

.aurify-ai-router.is-window > .aurify-ai-router__form {
    flex: 0 0 auto;
}

/* Messages gather at the bottom, just above the bar, like any chat; once the
   log is full the margin is gone and it scrolls as before. */
.aurify-ai-router.is-window .aurify-assistant__log {
    flex: 1 1 auto;
    min-height: 0;
    max-height: none !important;
    padding: 2px 4px 2px 0;
}

.aurify-ai-router.is-window .aurify-assistant__log > :first-child {
    margin-top: auto;
}

/* Scrolled, the older lines fade out under the head instead of being cut.
   (A mask makes the log a backdrop root; in the window the panel already is
   one, so the bubbles lose nothing.) */
.aurify-ai-router.is-window .aurify-assistant__log {
    -webkit-mask-image: linear-gradient(180deg, transparent, #000 16px);
    mask-image: linear-gradient(180deg, transparent, #000 16px);
}

/* The head: logo and name on the left, then "New chat", expand and minimize. */
.aurify-ai-router.is-window .aurify-assistant__head {
    justify-content: flex-start;
    align-items: center;
    gap: 8px;
    margin: 0 0 12px;
    padding: 2px 2px 12px;
    border-bottom: 1px solid rgba(255, 255, 255, .08);
}

.aurify-chat-logo {
    display: none;
}

.aurify-ai-router.is-window .aurify-chat-logo {
    display: block;
    width: 22px;
    height: 22px;
}

.aurify-ai-router.is-window .aurify-assistant__title {
    padding: 0;
    color: #fff;
    background: none;
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
    font-size: 15px;
    font-weight: 600;
    letter-spacing: 0;
    text-transform: none;
}

.aurify-ai-router.is-window .aurify-assistant__new,
.aurify-chat-controls button {
    color: rgba(255, 255, 255, .82);
    background: rgba(255, 255, 255, .06);
    border: 0;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .09);
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
    transition: color 160ms ease, background-color 160ms ease;
}

.aurify-ai-router.is-window .aurify-assistant__new {
    margin-left: auto;
    padding: 6px 12px;
    font-size: 13px;
    line-height: 18px;
}

.aurify-ai-router.is-window .aurify-assistant__new:hover,
.aurify-chat-controls button:hover {
    color: #fff;
    background: rgba(255, 255, 255, .12);
}

/* Expand and minimize, beside "New chat". */
.aurify-chat-controls {
    display: flex;
    gap: 6px;
}

.aurify-chat-controls button {
    display: grid;
    place-items: center;
    width: 30px;
    height: 30px;
    padding: 0;
    border-radius: 999px;
    cursor: pointer;
}

/* Beats stack in a column (a grid when expanded) instead of a sideways row
   that the window's edge would cut. */
.aurify-ai-router.is-window .aurify-assistant__beats {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    margin: 10px 0 0;
    padding: 0;
    overflow: visible;
    scroll-snap-type: none;
    -webkit-mask-image: none;
    mask-image: none;
}

/* In the window the bar and the cards are plain fields on the dark glass:
   refraction there only bends the panel's own dark fill, and its highlight
   showed as a stray streak. The window itself is the glass. */
.aurify-ai-router.is-window :is(.aurify-ai-router__bar, .aurify-ai-router__product-card, .aurify-ai-router__field-shell, .aurify-ai-router__song) {
    background: rgba(255, 255, 255, .05) !important;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .1) !important;
    -webkit-backdrop-filter: none !important;
    backdrop-filter: none !important;
}

.aurify-ai-router.is-window .aurify-ai-router__bar::before,
.aurify-ai-router.is-window .aurify-ai-router__bar::after,
.aurify-ai-router.is-window .aurify-glass-rim {
    display: none !important;
}

.aurify-chat-controls svg {
    width: 15px;
    height: 15px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.aurify-chat-controls__fold,
.aurify-ai-router.is-expanded .aurify-chat-controls__grow {
    display: none;
}

.aurify-ai-router.is-expanded .aurify-chat-controls__fold {
    display: inline;
}

.aurify-ai-router:not(.is-window) .aurify-chat-controls {
    display: none;
}

/* Expanded: the window fills the page below the header; the chat keeps a reading width. */
@media (min-width: 783px) {
    .aurify-ai-router.is-window.is-expanded {
        top: var(--aurify-chat-top, 98px);
        left: 24px;
        right: 24px;
        bottom: calc(24px + env(safe-area-inset-bottom, 0px));
        width: auto !important;
        height: auto;
        padding: 16px;
    }

    .aurify-ai-router.is-window.is-expanded > .aurify-assistant,
    .aurify-ai-router.is-window.is-expanded > .aurify-ai-router__form {
        width: 100%;
        max-width: 860px;
        margin-left: auto !important;
        margin-right: auto !important;
    }
}

/* ==========================================================
   THE CHAT BOX: the router on the pages without the hero's
   bar (chat-box-functions.php). Only its window ever shows;
   until a conversation starts, its thread holds a greeting.
========================================================== */

.aurify-ai-router--chat:not(.is-window),
.aurify-ai-router--chat .aurify-ai-router__typewriter {
    display: none !important;
}

.aurify-ai-router--chat .aurify-ai-router__input::placeholder {
    color: rgba(255, 255, 255, .45);
    opacity: 1;
}

.aurify-ai-router--chat:not(.is-chatting) .aurify-assistant__new {
    display: none;
}

.aurify-ai-router--chat:not(.is-chatting) .aurify-chat-controls {
    margin-left: auto;
}

/* Where the first answer will be, just above the bar. */
.aurify-chat-hello {
    display: flex;
    flex: 0 0 auto;
    flex-direction: column;
    align-items: flex-start;
    padding: 0 4px 2px 0;
}

.aurify-ai-router.is-chatting .aurify-chat-hello {
    display: none;
}

/* ==========================================================
   THE SQUARE: the minimized chat
========================================================== */

.aurify-chat-square {
    position: fixed;
    right: 24px;
    /* --aurify-chat-clear: the height of a page's own bar along the bottom (router-dock.js). */
    bottom: max(calc(24px + env(safe-area-inset-bottom, 0px)), calc(var(--aurify-chat-clear, 0px) + 12px));
    z-index: 60;
    display: grid;
    place-items: center;
    width: 60px;
    height: 60px;
    padding: 0;
    border: 0;
    border-radius: 18px;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, .16), rgba(255, 255, 255, .03) 46%, rgba(255, 255, 255, .08)),
        rgba(12, 15, 20, .4);
    -webkit-backdrop-filter: blur(14px) saturate(170%) brightness(1.08);
    backdrop-filter: blur(14px) saturate(170%) brightness(1.08);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, .5),
        inset 0 -1px 0 rgba(255, 255, 255, .12),
        inset 0 14px 22px -14px rgba(255, 255, 255, .42),
        inset 0 -12px 18px -14px rgba(255, 255, 255, .18),
        0 10px 30px rgba(0, 0, 0, .4);
    cursor: pointer;
    transform-origin: 100% 100%;
    will-change: transform;
    -webkit-tap-highlight-color: transparent;
    transition: scale 220ms cubic-bezier(.34, 1.56, .64, 1), translate 480ms cubic-bezier(.34, 1.4, .64, 1);
}

.aurify-chat-square[hidden] {
    display: none;
}

.aurify-chat-square::after {
    content: "";
    position: absolute;
    inset: 0;
    padding: 1.25px;
    border-radius: inherit;
    background: linear-gradient(135deg, rgba(255, 255, 255, .75), rgba(255, 255, 255, .12) 30%, rgba(255, 255, 255, .04) 55%, rgba(255, 255, 255, .14) 78%, rgba(255, 255, 255, .5));
    -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
    -webkit-mask-composite: xor;
    mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0);
    pointer-events: none;
}

.aurify-chat-square img {
    width: 30px;
    height: 30px;
    pointer-events: none;
    filter: drop-shadow(0 1px 6px rgba(0, 0, 0, .35));
}

.aurify-chat-square:hover {
    scale: 1.06;
}

.aurify-chat-square:active {
    scale: .96;
}

@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
    .aurify-ai-router.is-window {
        background: rgba(8, 10, 14, .95);
    }

    .aurify-chat-square {
        background: rgba(30, 34, 42, .92);
    }
}

/* ==========================================================
   GLASS RIMS: phones and Safari draw the bar's rim in WebGL
   from its on-screen box, which a stretch would distort: it
   steps out while the router moves and fades back after.
========================================================== */

.aurify-ai-router .aurify-glass-rim {
    transition: opacity .28s ease;
}

.aurify-ai-router.is-dock-moving .aurify-glass-rim {
    opacity: 0;
    transition: none;
}

/* ==========================================================
   PHONES: the hero stacks the bar in two rows; docked and in
   the window it is one slim row. The window is a sheet below
   the header.
========================================================== */

@media (max-width: 782px) {
    .aurify-ai-router.is-docked {
        bottom: calc(12px + env(safe-area-inset-bottom, 0px));
        width: calc(100% - 24px) !important;
    }

    .aurify-ai-router:is(.is-docked, .is-window) .aurify-ai-router__bar {
        flex-direction: row !important;
        align-items: center !important;
    }

    .aurify-ai-router:is(.is-docked, .is-window) .aurify-ai-router__submit {
        align-self: center !important;
    }

    .aurify-ai-router:is(.is-docked, .is-window) .aurify-ai-router__typewriter {
        width: calc(100% - 130px) !important;
    }

    /* The chat box's bar at the homepage bar's size (testimonials.css sets
       that one, and undoes router.css's phone scale). */
    .aurify-ai-router--chat .aurify-ai-router__bar {
        width: 100% !important;
        box-sizing: border-box !important;
        gap: 6px !important;
        padding: 6px !important;
        transform: none !important;
    }

    .aurify-ai-router--chat .aurify-ai-router__input {
        min-height: 44px !important;
        padding: 0 14px !important;
    }

    .aurify-ai-router--chat .aurify-ai-router__submit {
        flex: 0 0 36px !important;
        width: 36px !important;
        min-width: 36px !important;
        height: 36px !important;
        min-height: 36px !important;
        margin: 0 !important;
    }

    .aurify-ai-router.is-window {
        top: var(--aurify-chat-top, 96px);
        left: 8px;
        right: 8px;
        bottom: calc(8px + env(safe-area-inset-bottom, 0px) + var(--aurify-dock-lift, 0px));
        width: auto !important;
        height: auto;
        padding: 10px;
        border-radius: 20px;
        /* Nearly opaque and without blur: the sheet covers the screen, and a
           full-screen blur over the moving background costs every frame. */
        background:
            linear-gradient(180deg, rgba(255, 255, 255, .06), rgba(255, 255, 255, .01) 30%),
            rgba(9, 11, 15, .96);
        -webkit-backdrop-filter: none;
        backdrop-filter: none;
        transform-origin: 50% 100%;
    }

    /* On the solid sheet the bubbles' own blur has nothing to show. */
    .aurify-ai-router.is-window :is(.aurify-assistant__msg, .aurify-assistant__title, .aurify-assistant__new) {
        -webkit-backdrop-filter: none;
        backdrop-filter: none;
    }

    .aurify-chat-controls__expand {
        display: none !important;
    }

    .aurify-chat-square {
        right: 12px;
        bottom: max(calc(12px + env(safe-area-inset-bottom, 0px)), calc(var(--aurify-chat-clear, 0px) + 10px));
        width: 56px;
        height: 56px;
        border-radius: 17px;
    }

    /* Above the docked bar. */
    .aurify-chat-square.is-over-dock {
        translate: 0 -70px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .aurify-chat-square,
    .aurify-ai-router .aurify-glass-rim {
        transition: none;
    }
}
