/*
 * Peekopals web app: the whole signed-in app in one page (web-app-screens.js; see
 * htmx/webApp/layout/AGENTS.md, home/AGENTS.md and chats/AGENTS.md).
 * - Every page is a screen in main; only the one on view is drawn.
 * - Phones (under 900 px): the phone's frame. The three tabs have the top bar (coin pill, logo,
 *   bell) and the bottom tab bar; any other screen is a full screen without them.
 * - Wide screens (900 px and up): one block centred in the window like X's, with the tabs as a
 *   rail on the left of every screen (its look is in web-app.css). The top bar (the coin pill and
 *   the light/dark switch) shows on the tabs only. The window itself scrolls, so the scrollbar is at the browser's
 *   edge and the rail and top bar stay put; only the Chats tab keeps its two panes scrolling on
 *   their own, like X's chat.
 * - No motion between screens (like X): the rail and the frame stay put and the content area swaps
 *   in place. A screen still being read after a moment shows an empty content area and a thin line.
 * Loaded on every signed-in page after web-app.css and web-app-pal-activity.css.
 */

.wa-app-screen {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}
/* a kept screen that isn't on view (live updates still land in a kept Chats tab) */
.wa-app-screen[hidden] { display: none; }
.wa-app[data-home-tab="none"] > .wa-top-bar,
.wa-app[data-home-tab="none"] > [data-web-apply-response] { display: none; }

/* phones: a screen that isn't a tab is a full screen, without the tab bar */
@media (max-width: 899px) {
    .wa-app[data-home-tab="none"] > .wa-tab-bar { display: none; }
}

/* "Get the app" sits above the home tabs on a phone, until this browser dismisses it.
   A wide screen, a full screen, and an open chat leave it out. */
.wa-get-app-bar { display: none; }
@media (max-width: 899px) {
    .wa-app[data-home-tab="chats"] > .wa-get-app-bar,
    .wa-app[data-home-tab="feed"] > .wa-get-app-bar,
    .wa-app[data-home-tab="me"] > .wa-get-app-bar {
        display: flex;
        align-items: center;
        gap: 4px;
        margin: 0 12px 8px;
        padding: 4px 4px 4px 16px;
        border-radius: 999px;
        background: var(--md-primary);
        color: var(--md-on-primary);
    }
    .wa-app:has(.wa-home-tab-screen:not([hidden]) .wa-chat-pane--open) > .wa-get-app-bar { display: none; }
}
.wa-get-app-bar-link {
    flex: 1;
    padding: 8px 0;
    color: inherit;
    font-size: calc(14px * var(--wa-text-scale, 1));
    line-height: calc(20px * var(--wa-text-scale, 1));
    font-weight: 600;
    text-align: center;
    text-decoration: none;
}
.wa-get-app-bar-dismiss {
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 999px;
    background: transparent;
    color: inherit;
    cursor: pointer;
}
.wa-get-app-bar-dismiss svg { width: 18px; height: 18px; }

/* ==================== wide screens: the rail beside every screen ==================== */

/* the rail's look and the centred frame are in web-app.css (its rules cover every screen); here,
   how screens sit beside it in the one page */
@media (min-width: 900px) {
    /* a screen that isn't a tab has no top bar: it starts at the top */
    .wa-app[data-home-tab="none"] > .wa-screen { grid-row: 1 / -1; }
    /* a screen a rail row opens (Notifications) looks like a tab: under the top bar with the coin
       pill, without its own back arrow and title (Anudeep, 2026-10-28); phones keep its header */
    .wa-app[data-home-tab="none"]:has(> .wa-screen > .wa-app-screen[data-web-rail-screen]:not([hidden])) > .wa-top-bar { display: grid; }
    .wa-app[data-home-tab="none"]:has(> .wa-screen > .wa-app-screen[data-web-rail-screen]:not([hidden])) > .wa-screen { grid-row: 2; }
    .wa-app-screen[data-web-rail-screen] > .wa-page > .wa-page-header { display: none; }
    /* a rail row shows the focus ring only when Tab brought it there, never after a click or a script's focus */
    html:not([data-last-input="keyboard"]) .wa-tab-bar-item:focus-visible { box-shadow: none; }
    /* the rail and the top bar stay put while the window scrolls */
    .wa-app > .wa-tab-bar {
        position: sticky;
        top: 0;
        align-self: start;
        height: 100dvh;
        overflow-y: auto;
    }
    .wa-app > .wa-top-bar {
        position: sticky;
        top: 0;
        z-index: 20;
    }
}

/* ==================== wide screens: the window scrolls ==================== */

/* every screen but the Chats tab: the page grows with the screen and the window scrolls, like X;
   the screens' own scrolled areas let their content run on (web-app-screens.js keeps each
   screen's place in the window) */
@media (min-width: 900px) {
    body.wa-body:has(> .wa-app:not([data-home-tab="chats"])) { overflow: visible; }
    .wa-app:not([data-home-tab="chats"]) { height: auto; min-height: 100dvh; }
    .wa-app:not([data-home-tab="chats"]) > .wa-screen { min-height: 0; }
    .wa-app:not([data-home-tab="chats"]) > .wa-screen > .wa-app-screen { flex: 1 0 auto; min-height: auto; }
    .wa-app:not([data-home-tab="chats"]) > .wa-screen > .wa-app-screen :is(
        .wa-page,
        .wa-tab-screen-scroller,
        .wa-pal-profile-panels,
        .wa-pal-profile-panel,
        .wa-profile-screen-body--editor,
        .wa-quiz-pages,
        .wa-quiz-results
    ) {
        flex: 1 0 auto;
        min-height: auto;
        overflow: visible;
    }
    .wa-app:not([data-home-tab="chats"]) > .wa-screen > .wa-app-screen .wa-pal-profile-panel { position: static; }
    .wa-app:not([data-home-tab="chats"]) > .wa-screen > .wa-app-screen .wa-page.wa-profile-editor { overflow: visible; }
}

/* ==================== a screen on the way ==================== */

/* a screen still being read: a thin line moving along the top */
@keyframes wa-screen-loading-line { from { transform: translateX(-100%); } to { transform: translateX(100%); } }
html[data-screen-loading] body::after {
    content: "";
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 2000;
    height: 3px;
    background: var(--md-primary);
    animation: wa-screen-loading-line 1s ease-in-out infinite;
}

/* the content area while a screen that isn't kept is read (web-app-screens.js): empty, the frame and rail stay */
.wa-empty-content-area { min-height: 100dvh; }
@media (prefers-reduced-motion: reduce) {
    html[data-screen-loading] body::after { animation: none; }
}

/* a screen that can't be read without a connection and has no kept copy */
.wa-offline-screen {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    text-align: center;
    color: var(--md-on-surface-variant);
}
.wa-offline-screen p { margin: 0; font-size: calc(16px * var(--wa-text-scale, 1)); line-height: calc(24px * var(--wa-text-scale, 1)); }

/* ==================== the Chats tab: the list and the conversation ==================== */

.wa-chats-tab {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}
.wa-chats-two-pane {
    flex: 1;
    min-height: 0;
    display: flex;
}
.wa-chats-list-pane {
    flex: 1;
    min-width: 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
}
.wa-chat-pane {
    flex: 1;
    min-width: 0;
    min-height: 0;
    display: none;
    flex-direction: column;
    background: var(--md-background);
}

/* phones: an open chat fills the screen (no list, top bar or tabs), like the phone's chat screen */
@media (max-width: 899px) {
    .wa-chat-pane--open { display: flex; }
    .wa-chats-two-pane:has(.wa-chat-pane--open) .wa-chats-list-pane { display: none; }
    .wa-app:has(.wa-home-tab-screen:not([hidden]) .wa-chat-pane--open) > .wa-top-bar,
    .wa-app:has(.wa-home-tab-screen:not([hidden]) .wa-chat-pane--open) > .wa-tab-bar { display: none; }
}

/* wide screens: the list at a phone's width on the left, the conversation beside it */
@media (min-width: 900px) {
    .wa-chats-list-pane {
        flex: 0 0 clamp(360px, 30vw, 420px);
        border-right: 1px solid var(--md-outline-variant);
    }
    .wa-chat-pane { display: flex; }
    /* the list is right there, so the chat header's back button has no job */
    .wa-chat-pane .wa-thread-back { display: none; }
    /* inside the pane the chat starts at the pane's left edge, like X: header, bubbles and input bar
       share the pane's 16 px sides instead of a centred column (Anudeep, 2026-10-28) */
    .wa-chat-pane .wa-thread-page .wa-thread-header { padding-left: 16px; padding-right: 16px; }
    .wa-chat-pane .wa-thread-page .wa-thread { max-width: none; padding: 0 16px; }
    .wa-chat-pane .wa-thread-page .wa-composer { padding-left: 16px; padding-right: 16px; }
    .wa-chat-pane .wa-thread-page .wa-composer-context { margin-left: 16px; margin-right: 16px; }
    .wa-chat-pane .wa-thread-page .wa-thread-scroller { scrollbar-gutter: auto; }
}

/* the open chat's row in the list (pal rows keep a magic's tint, a shade stronger) */
.wa-chat-row.wa-chat-row--pal.wa-chat-row--open .wa-pal-row-card { background: var(--md-surface-container-high); }
.wa-chat-row.wa-chat-row--pal.wa-chat-row--open .wa-pal-row-card.wa-magic-tint--super-love {
    background: color-mix(in srgb, var(--wa-pal-celestial-blue) 24%, transparent);
}
.wa-chat-row.wa-chat-row--pal.wa-chat-row--open .wa-pal-row-card.wa-magic-tint--romantic {
    background: color-mix(in srgb, var(--wa-pal-red-300) 24%, transparent);
}
.wa-chat-row.wa-chat-row--group.wa-chat-row--open { background: var(--md-surface-container-high); }

/* the empty right pane (someone with no chats yet): the logo and one short line, centred */
.wa-chat-pane-empty {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 24px;
    text-align: center;
    color: var(--md-on-surface-variant);
}
.wa-chat-pane-empty-logo {
    width: 72px;
    height: 72px;
    border-radius: 20px;
    border: 1px solid var(--md-outline-variant);
}
.wa-chat-pane-empty-text { margin: 0; font-size: calc(16px * var(--wa-text-scale, 1)); line-height: calc(24px * var(--wa-text-scale, 1)); }

/* ==================== a tab's loading look while its screen is on the way ==================== */

/* the phone's placeholder modifier: a block that breathes between half and full strength */
@keyframes wa-loading-look-pulse { from { opacity: 0.5; } to { opacity: 1; } }
.wa-loading-look-block {
    display: block;
    background: var(--md-surface-container-highest);
    border-radius: 12px;
    animation: wa-loading-look-pulse 1s linear infinite alternate;
}

/* Chats: the phone's ChatListRowPlaceholder, on the real list's pixels: the list's padding
   (.wa-chat-list), the pal card's margin, border and padding (.wa-pal-row-card) and the real inset
   line (.wa-pal-row-divider), so the grey photo and lines sit where the real ones land */
.wa-chat-list-loading-look { padding: 6px 8px 16px; }
.wa-chat-row-loading-look-card {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 4px 8px;
    padding: 8px 16px;
    border: 1px solid transparent;
}
.wa-chat-row-loading-look-photo { flex: none; width: 56px; height: 56px; }
/* the name (title, 24px line) and one preview line (body, 20px line), 2px apart, like the real text */
.wa-chat-row-loading-look-lines { flex: 0 1 80%; height: 56px; display: flex; flex-direction: column; gap: 2px; }
.wa-chat-row-loading-look-name { width: 50%; height: 24px; }
.wa-chat-row-loading-look-preview { width: 80%; height: 20px; }
@media (min-width: 900px) {
    .wa-chat-row-loading-look-card { margin: 4px 16px; }
}
@media (prefers-reduced-motion: reduce) {
    .wa-loading-look-block { animation: none; }
}

