/*
 * Page-level rules for the phone chat fix. static/js/mobile-viewport.js has the
 * full story. These are plain CSS rather than Tailwind utilities for the reason
 * components/chatbot_widget.html records: the standalone CLI only emits classes
 * it saw at build time, and a missing utility fails silently.
 */

/* The app shell (base.html). `h-screen` is 100vh, which on a phone counts the
   browser's collapsing URL bar, so the shell was taller than the screen and the
   document itself could scroll by that much. dvh is the height actually visible.
   The 100vh line is the fallback for browsers without dvh. */
.bossi-app-shell {
    height: 100vh;
    height: 100dvh;
}

/* Set by mobileViewport.lockScroll() while a full-screen chat is open on a
   phone. <main> is included because base.html scrolls the page there, not on
   the window. */
html.bossi-scroll-locked,
html.bossi-scroll-locked body,
html.bossi-scroll-locked main {
    overflow: hidden !important;
    overscroll-behavior: none;
}

/* The /chatbot/ pages (chat_home.html, chat_session.html). They fill <main>
   rather than computing `100vh - 65px`: that literal assumed the navbar's height,
   ignored the "Powered by" footer under <main>, and counted the URL bar, so the
   page scrolled a little on every phone. The negative margin cancels <main>'s
   padding, as the old `-m-4 sm:-m-6` did. */
.bossi-chat-main {
    display: flex;
    flex-direction: column;
    overflow: hidden !important;
    overscroll-behavior: none;
}
.bossi-chat-shell {
    display: flex;
    flex: 1 1 auto;
    min-height: 0;
    margin: -1rem;
}
@media (min-width: 640px) {
    .bossi-chat-shell { margin: -1.5rem; }
}
/* On a phone the app shell follows the visual viewport while a chat page is
   open, so the composer rests on the keyboard instead of underneath it. It is
   fixed and offset like the widget panel, not merely resized: iOS can pan the
   visual viewport down (offsetTop > 0) instead of scrolling the window, and an
   in-flow shell cannot follow that. mobileViewport.track() sets both variables
   on <html>. The 100vh line is the fallback for browsers without dvh. */
@media (max-width: 639px) {
    html.bossi-chat-page .bossi-app-shell {
        position: fixed;
        left: 0;
        right: 0;
        top: var(--chat-vv-top, 0px);
        height: 100vh;
        height: var(--chat-vv-height, 100dvh);
    }
    html.bossi-chat-page,
    html.bossi-chat-page body {
        overflow: hidden;
        overscroll-behavior: none;
    }
}
