/* Chat widget styles. Colours come from the site variables in website/custom_css/main.css, and the chat
   defines no colours of its own. The panel and launcher use glass, as on the navbar. */

.chat-widget {
    position: fixed;
    right: 1.5rem;
    bottom: calc(1rem + env(safe-area-inset-bottom));
    z-index: 150;
}

/* The launcher is the walker robot (chat/_launcher_icon.html). It animates itself, and its own CSS stops
   the animation under reduced motion. Its outlines use the text colour, so they show in both modes. */
.chat-launcher[hidden] {
    display: none;
}

.chat-launcher {
    display: block;
    min-width: 44px;
    min-height: 44px;
    padding: 0;
    border: 0;
    background: transparent;
    cursor: pointer;
    line-height: 0;
    /* A halo in the page colour, so text behind the robot doesn't show through its outlines. */
    filter: drop-shadow(0 0 2px var(--color-page)) drop-shadow(0 0 2px var(--color-page));
}

/* The legs and arms swing only while the robot walks. While he waits, they stand at rest. */
.chat-launcher.is-still .legA,
.chat-launcher.is-still .legB,
.chat-launcher.is-still .armA,
.chat-launcher.is-still .armB {
    animation: none;
}

/* While he runs back to his spot, every movement runs five times faster. */
.chat-launcher.is-running .legA,
.chat-launcher.is-running .legB,
.chat-launcher.is-running .armA,
.chat-launcher.is-running .armB {
    animation-duration: 0.14s;
}

.chat-launcher.is-running .head {
    animation-duration: 0.56s;
}

.chat-launcher.is-running .pulse {
    animation-duration: 0.32s;
}

.chat-launcher.is-running .blink {
    animation-duration: 0.8s;
}

.chat-launcher.is-running .led {
    animation-duration: 0.24s;
}

.chat-launcher.is-running .led2 {
    animation-delay: 0.08s;
}

.chat-launcher.is-running .led3 {
    animation-delay: 0.16s;
}

.chat-launcher svg {
    display: block;
    height: 86.4px;
    width: auto;
    color: var(--color-text);
}

/* Desktop: the panel opens above the launcher, 380px wide, and never taller than 80% of the window. */
.chat-panel[hidden] {
    display: none;
}

.chat-panel {
    position: absolute;
    right: 0;
    bottom: calc(100% + 0.75rem);
    display: flex;
    flex-direction: column;
    width: min(380px, calc(100vw - 3rem));
    max-height: 80vh;
    max-height: 80dvh;
    border: 1px solid var(--color-border);
    border-radius: 14px;
    background: color-mix(in srgb, var(--color-page) 90%, transparent);
    -webkit-backdrop-filter: blur(16px);
    backdrop-filter: blur(16px);
    color: var(--color-text);
    overflow: hidden;
}

.chat {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
}

.chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 12px 12px 16px;
    border-bottom: 1px solid var(--color-border);
}

.chat-title {
    margin: 0;
    font-size: 1.05rem;
    line-height: 1.3;
}

.chat-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    flex: none;
    border: 1px solid var(--color-border-strong);
    border-radius: var(--radius);
    background: transparent;
    color: var(--color-text);
    cursor: pointer;
}

.chat-box {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
}

.chat-toolbar {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
    padding: 10px 12px;
}

.chat-book,
.chat-new {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    padding: 0 14px;
    border: 1px solid var(--color-accent);
    border-radius: var(--radius);
    font: 600 0.95rem/1.2 var(--font-sans);
    text-decoration: none;
    cursor: pointer;
}

.chat-book {
    background: var(--color-accent);
    color: var(--color-on-accent);
}

.chat-new {
    background: transparent;
    border-color: var(--color-border-strong);
    color: var(--color-text);
}

.chat-book:hover {
    background: var(--color-accent-hover);
    border-color: var(--color-accent-hover);
    color: var(--color-on-accent);
}

.chat-new:not(:disabled):hover {
    background: var(--color-surface);
    border-color: var(--color-text);
}

.chat-new:disabled {
    opacity: 0.5;
    cursor: default;
}

.chat-book:focus-visible,
.chat-new:focus-visible,
.chat-close:focus-visible,
.chat-launcher:focus-visible,
.chat-send:focus-visible {
    outline: 3px solid var(--color-accent);
    outline-offset: 3px;
}

/* The message history grows and scrolls inside the panel. */
.chat-log {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 120px;
    overflow-y: auto;
    padding: 4px 16px 12px;
}

.chat-message {
    max-width: 85%;
    margin: 8px 0;
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 0.95rem;
    line-height: 1.5;
    overflow-wrap: anywhere;
}

.chat-message p,
.chat-message ul {
    margin: 0 0 8px;
}

.chat-message p:last-child,
.chat-message ul:last-child {
    margin-bottom: 0;
}

.chat-message ul {
    padding-left: 1.2rem;
}

.chat-message a {
    color: var(--color-accent);
    text-underline-offset: 0.2em;
}

.chat-message a[data-booking] {
    font-weight: 600;
}

.chat-message--user {
    align-self: flex-end;
    background: var(--color-accent);
    color: var(--color-on-accent);
}

.chat-message--user a {
    color: var(--color-on-accent);
}

.chat-message--assistant {
    align-self: flex-start;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
}

.chat-typing {
    display: inline-block;
    letter-spacing: 3px;
}

/* Limit notices sit where a reply would go, in the same neutral tone as assistant replies. */
.chat-notice {
    align-self: stretch;
    max-width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--color-border);
    border-radius: 14px;
    background: var(--color-surface);
    color: var(--color-text);
    line-height: 1.5;
    overflow-wrap: anywhere;
}

.chat-notice p {
    margin: 0 0 8px;
}

.chat-notice .chat-book {
    margin-right: 8px;
}

.chat-form {
    flex: 0 0 auto;
    padding: 12px 12px 0;
}

/* Visually hidden, but still announced to screen readers. The placeholder shows the purpose on screen. */
.chat-label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

.chat-input-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 4px 4px 16px;
    border: 1px solid var(--color-border-strong);
    border-radius: 24px;
    background: var(--color-page);
}

.chat-input-row:focus-within {
    border-color: var(--color-accent);
}

/* The site's textarea rules are overridden here, so the input stays one line until it needs more. */
.chat-input,
.chat-input:focus {
    flex: 1 1 auto;
    min-width: 0;
    height: auto;
    min-height: 0;
    margin: 0;
    padding: 8px 0;
    border: 0;
    outline: 0;
    box-shadow: none;
    background: transparent;
    color: var(--color-text);
    font-size: 16px; /* stops iOS zooming in on focus */
    line-height: 1.5;
    resize: none;
}

.chat-send {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: var(--color-accent);
    color: var(--color-on-accent);
    cursor: pointer;
    position: relative;
}

.chat-send:hover {
    background: var(--color-accent-hover);
}

/* The label is hidden on screen, so the icon's text is hidden too. Screen readers still read "Send". */
.chat-send-text {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

.chat-send-icon {
    width: 18px;
    height: 18px;
}

.chat-send:disabled {
    opacity: 0.6;
    cursor: default;
}

.chat-disclosure {
    margin: 0;
    padding: 10px 16px 14px;
    font-size: 0.8rem;
    color: var(--color-muted);
}

/* Phone: the panel spans the width above the launcher and stops at 70% of the screen height, so the page stays
   visible above it. */
@media (max-width: 768px) {
    .chat-panel {
        position: fixed;
        left: 1rem;
        right: 1rem;
        bottom: calc(1rem + env(safe-area-inset-bottom) + 86.4px + 0.75rem);
        width: auto;
        max-height: 70vh;
        max-height: 70dvh;
    }

    .chat-input-row {
        margin-bottom: 0;
    }
}

html.chat-sheet-open {
    overflow: hidden;
}
