/* ===========================================
   Meet Your AI Executive — the answer side

   The same phone as The Reality, resolved: instead of a lockscreen filling up
   with things nobody has handled, a conversation where each one comes back
   answered. It reuses .phone / .phone-shell / .phone-screen from scrolly.css
   so the two read as one device across the page.

   The conversation is driven by scroll position (chat.js), not a timeline —
   the reader sets the pace, and it runs backwards.
   Loaded after scrolly.css.
   =========================================== */
/* Phone and cards side by side, because they are one instrument: the card you
   are on is the state, the phone is the readout. Stacked, they read as two
   unrelated visuals no matter how they are styled. */
.capabilities {
    display: grid;
    /* The deck is capped rather than filling the column: a card that spans
       800px reads as a panel, not as something you'd flick off a pile. */
    grid-template-columns: 17.5rem minmax(0, 30rem);
    justify-content: center;
    gap: 3.5rem;
    /* Centre again: the deck is one card tall and stays put, so there is no
       scroll run for the phone to pin against — it sits beside the pile. */
    align-items: center;
}

.chat { display: flex; justify-content: center; }

.chat-phone { height: 34rem; }

/* --- header ---------------------------------------------------------------- */
.chat-header {
    position: absolute;
    top: 2.6rem;
    left: 0;
    right: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.5rem 0.7rem;
    border-bottom: 1px solid var(--phone-card-border);
    z-index: 2;
}

/* The real topbar, from public/chat.html: the wordmark on the left, the
   account controls on the right, a hairline under it. What was here before was
   a messaging-app contact row — avatar, the name "Exhale" set in serif italic,
   and a "● LIVE" pill. None of that exists; this does.

   The wordmark is `.brand-mark` over there: Cormorant 300, uppercase, tracked
   out 0.32em with a matching left pad so the tracking on the final E doesn't
   push it off centre. The account email sits between these two on a wide
   screen and is dropped here, which is what a narrow viewport does with it
   anyway — Settings and Sign out are what survive at this width. */
.chat-brand {
    font-family: var(--font-serif);
    font-weight: 300;
    font-size: 0.78rem;
    letter-spacing: 0.32em;
    padding-left: 0.32em;
    text-transform: uppercase;
    line-height: 1;
    color: var(--phone-ink);
}

/* Just the accent and a soft halo — not the hero's `.logo-e`, which stacks
   four text-shadows for a 5rem headline and would bloom at this size. */
.chat-brand-e {
    color: var(--cyan-glow);
    text-shadow: 0 0 12px rgba(173, 251, 246, 0.4);
}

body.light-mode .chat-brand-e {
    color: var(--cyan-deep);
    text-shadow: none;
}

.chat-topbar-meta {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    font-size: 0.5rem;
    letter-spacing: 0.01em;
    white-space: nowrap;
    color: var(--phone-ink-dim);
}

/* --- conversation ---------------------------------------------------------- */
.chat-body {
    position: absolute;
    left: 0;
    right: 0;
    top: 5.4rem;
    bottom: 4.4rem;
    padding: 0 0.7rem;
    display: flex;
    flex-direction: column;
    /* Bottom-anchored like a real thread: the newest turn sits at the bottom
       and pushes the older ones up under the fade. */
    justify-content: flex-end;
    overflow: hidden;
    mask-image: linear-gradient(to bottom, transparent 0, #000 2.5rem);
    -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 2.5rem);
    z-index: 2;
}

/* Same 0fr -> 1fr disclosure as the notification stack and the FAQ: the row
   makes room for itself without JS measuring, and reverses on scroll-up. Each
   one wraps its contents in a single overflow child — a grid row can only
   collapse what sits in that one row. */
.chat-turn,
.chat-reply {
    display: grid;
    grid-template-rows: 0fr;
    transition: grid-template-rows 520ms var(--ease-drawer);
}

.chat-turn.is-in { grid-template-rows: 1fr; }
.chat-turn.has-reply .chat-reply { grid-template-rows: 1fr; }

.chat-turn-inner,
.chat-reply-inner { overflow: hidden; }

.chat-turn-inner { display: flex; flex-direction: column; }

/* The question, in the reader's own voice. */
.chat-ask {
    align-self: flex-end;
    max-width: 84%;
    margin-top: 0.5rem;
    padding: 0.45rem 0.7rem;
    border-radius: 16px 16px 4px 16px;
    background: var(--cyan-light);
    color: #0a0a0a;
    font-size: 0.66rem;
    font-weight: 500;
    line-height: 1.35;
    opacity: 0;
    transform: translateY(6px) scale(0.94);
    transform-origin: 100% 50%;
    transition: opacity 300ms var(--ease-out), transform 420ms var(--ease-out);
}

.chat-turn.is-in .chat-ask {
    opacity: 1;
    transform: none;
    transition-delay: 60ms;
}

/* The wait, as the product actually renders it: the word "thinking…" in muted
   italic, with no bubble around it. This was three pulsing dots in a bordered
   pill, which is the messaging-app convention and not what /chat does.
   Removed from flow once the reply lands so the thread doesn't keep a gap. */
.chat-typing {
    width: max-content;
    margin-top: 0.5rem;
    padding: 0.25rem 0.45rem;
    font-size: 0.58rem;
    font-style: italic;
    line-height: 1.4;
    color: var(--phone-ink-dim);
    opacity: 0;
    transform: translateY(4px);
    transition: opacity 220ms var(--ease-out), transform 220ms var(--ease-out);
}

.chat-turn.is-thinking .chat-typing { opacity: 1; transform: none; }
.chat-turn.has-reply .chat-typing { display: none; }

.chat-reply-card {
    margin-top: 0.5rem;
    padding: 0.55rem 0.7rem;
    border-radius: 16px 16px 16px 4px;
    background: var(--phone-card);
    border: 1px solid var(--phone-card-border);
    opacity: 0;
    transform: translateY(6px);
    transition: opacity 320ms var(--ease-out), transform 420ms var(--ease-out);
}

.chat-turn.has-reply .chat-reply-card {
    opacity: 1;
    transform: none;
    /* The words arrive after the bubble has made room for them. */
    transition-delay: 110ms;
}

.chat-reply-intro {
    font-size: 0.66rem;
    line-height: 1.35;
    color: var(--phone-ink);
    margin-bottom: 0.3rem;
}

.chat-item {
    font-size: 0.66rem;
    line-height: 1.4;
    color: var(--phone-ink);
}

.chat-item + .chat-item { margin-top: 0.25rem; }

.chat-arrow {
    color: var(--cyan-glow);
    font-weight: 600;
    margin-right: 0.2rem;
}

/* The specifics — a name, a time, a number — are what the assistant actually
   resolved, so they carry the accent and nothing else does. */
.chat-item b,
.chat-reply-intro b {
    font-weight: 600;
    color: var(--cyan-glow);
}

body.light-mode .chat-arrow,
body.light-mode .chat-item b,
body.light-mode .chat-reply-intro b { color: var(--cyan-deep); }

/* --- input bar ------------------------------------------------------------- */
/* The real composer is a bar, not a pill: a hairline across the top, then a
   bordered textarea and a separate Send button sitting beside it. What was
   here was one rounded capsule with an icon tucked inside — the messaging-app
   shape again, where /chat has a form. */
.chat-input {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 1.1rem;
    display: flex;
    align-items: flex-end;
    gap: 0.4rem;
    padding: 0.55rem 0.7rem;
    border-top: 1px solid var(--phone-card-border);
    z-index: 2;
}

/* The real placeholder — "Ask about an email, schedule, or PDF…" — is longer
   than the invented one it replaced, and at the old size it wrapped to two
   lines and pushed the bar up over the last message. A composer is one line,
   always, so it stays one line: slightly smaller, and with an ellipsis as the
   backstop for a width where even that won't fit. */
.chat-input-text {
    flex: 1;
    min-width: 0;   /* a flex item won't shrink below its text without this */
    padding: 0.4rem 0.45rem;
    border-radius: 7px;
    background: var(--phone-card);
    border: 1px solid var(--phone-card-border);
    font-size: 0.6rem;
    font-weight: 300;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--phone-ink-dim);
}

/* A labelled button, the way /chat ships it — accent fill, dark text,
   weight 600. Not a paper-plane glyph. */
.chat-send {
    flex: none;
    display: grid;
    place-items: center;
    padding: 0 0.6rem;
    height: 1.72rem;
    border-radius: 7px;
    background: var(--cyan-light);
    color: #0a0a0a;
    font-size: 0.58rem;
    font-weight: 600;
    letter-spacing: 0.01em;
}

/* --- smaller screens ------------------------------------------------------- */
/* --- phones and small tablets ---------------------------------------------
   No phone here, and no deck.

   The pinned readout and a whole card could never both fit: 328px of the
   screen went to the device, leaving ~339px for a card that wants 315-403px.
   With no slack, every rounding error showed up as an overlap — the arriving
   card clipped the thread, the last card rode up behind it, and on a 667px
   screen the stack collapsed outright.

   So the card answers for itself. A picture of a phone inside a phone was the
   weakest thing on the page anyway; the reply belongs under the question that
   asked for it. Two sticky layers, two JS-measured offsets, a scrim and four
   height tiers all go with it — overlap is now impossible rather than tuned
   against. Desktop is untouched.
   -------------------------------------------------------------------------- */
@media (max-width: 900px) {
    .capabilities {
        display: block;
    }

    /* The readout moves inside the cards (see .card-answer below). */
    .chat { display: none; }

    /* A list, not a pile: nothing sticks, nothing covers anything. */
    .gallery-stack {
        display: flex;
        flex-direction: column;
        gap: 1.25rem;
        padding-bottom: 0;
    }

    .gallery .feature-card {
        position: static;
        /* The deck is off at this width — gallery.js drops `.is-deck` and takes
           its depths back off — and these keep a stale one from dimming a card
           if the reader narrows the window mid-flick. */
        transform: none;
        opacity: 1;
        cursor: auto;
    }

    /* Nothing to step through: the cards are all here, one after another. */
    .deck-nav,
    .deck-hint { display: none; }

    /* Every card is its own height now, so the prompts sit under the text
       rather than being pushed to the foot of an equalised box. */
    .gallery .feature-list { margin-top: 1.25rem; }
}
@media (prefers-reduced-motion: reduce) {
    /* No sliding, but the thread still fills in as you reach it. */
    .chat-ask,
    .chat-reply-card { transform: none; }
}

/* ===========================================
   Capability cards on a phone

   At full size a card ran 630px — three quarters of a 844px screen, so a
   single card filled the viewport and the row read as one item rather than a
   set you swipe. Every measurement below is proportional: the card keeps its
   structure, it just stops shouting.
   =========================================== */
@media (max-width: 640px) {
    .gallery .feature-card { padding: 1.5rem 1.375rem; }

    .feature-icon {
        width: 42px;
        height: 42px;
        border-radius: 12px;
        margin-bottom: 1rem;
    }

    .feature-icon svg { width: 24px; height: 24px; }

    .gallery .feature-card h3 {
        font-size: 1.15rem;
        margin-bottom: 0.5rem;
        padding-bottom: 0.5rem;
    }

    .gallery .feature-card > p {
        font-size: 0.875rem;
        line-height: 1.55;
    }

    .gallery .feature-list {
        padding-top: 1rem;
        gap: 0.375rem;
    }

    .gallery .feature-list li {
        padding: 0.5rem 0.75rem;
        font-size: 0.8125rem;
        line-height: 1.4;
    }
}

/* ===========================================
   The cards as controls

   The example prompts were always written as things you would type. Making
   them real buttons costs nothing in layout and turns the card from a
   description of the product into the remote control for it.
   =========================================== */
.feature-prompt {
    display: block;
    width: 100%;
    padding: 0;
    border: 0;
    background: none;
    font: inherit;
    color: inherit;
    text-align: left;
    cursor: pointer;
    transition: color 200ms var(--ease-out);
}

.gallery .feature-list li {
    padding: 0;
    transition: background-color 240ms var(--ease-out),
                border-color 240ms var(--ease-out),
                transform 220ms var(--ease-out);
}

.gallery .feature-list li:has(.feature-prompt) { padding: 0; }

.gallery .feature-list li .feature-prompt {
    padding: 0.625rem 0.9375rem;
}

/* The prompt currently on screen in the phone. */
.gallery .feature-list li.is-asking {
    background: rgba(173, 251, 246, 0.2);
    border-color: rgba(173, 251, 246, 0.4);
}

body.light-mode .gallery .feature-list li.is-asking {
    background: rgba(13, 115, 119, 0.14);
    border-color: rgba(13, 115, 119, 0.3);
}

@media (hover: hover) and (pointer: fine) {
    .gallery .feature-list li:hover {
        border-color: rgba(173, 251, 246, 0.35);
        transform: translateX(-2px);
    }
    body.light-mode .gallery .feature-list li:hover {
        border-color: rgba(13, 115, 119, 0.28);
    }
}

.feature-prompt:focus-visible {
    outline: 2px solid var(--cyan-glow);
    outline-offset: 3px;
    border-radius: 12px;
}


/* At the narrowest widths the fan takes 28px off the card and the two longer
   capability blurbs gain a line each. Tighten rather than grow the deck — the
   whole section is already competing for a 568px-tall screen. */
@media (max-width: 400px) {
    .gallery .feature-card { padding: 1.25rem 1.125rem; }
    .gallery .feature-card > p { font-size: 0.8125rem; line-height: 1.5; }
    .gallery .feature-list { padding-top: 0.5rem; margin-top: 0.5rem; gap: 0.3rem; }
    .gallery .feature-list li .feature-prompt { padding: 0.4rem 0.6rem; }
    .gallery .feature-list li { font-size: 0.75rem; }
    .feature-icon { width: 38px; height: 38px; margin-bottom: 0.75rem; }
    .feature-icon svg { width: 21px; height: 21px; }
}

/* ===========================================
   The answer, inside the card

   On a phone the prompts stop being a remote control for a device across the
   page and become the thing itself: tap a question, Exhale answers underneath
   it. Same disclosure as the FAQ two sections down — one grammar for "there is
   more here" across the whole page — and the same bubble, accent and typography
   as the thread on desktop, so it still reads as the assistant talking.
   =========================================== */
.card-answer {
    display: grid;
    grid-template-rows: 0fr;
    transition: grid-template-rows 460ms var(--ease-drawer);
}

/* A grid row can only collapse what sits in that one row, so everything the
   panel holds goes through this single overflow child. */
.card-answer-inner { overflow: hidden; }

.gallery .feature-list li.is-open .card-answer { grid-template-rows: 1fr; }

.card-answer .chat-reply-card {
    margin: 0.625rem 0.9375rem 0.875rem;
    padding: 0.75rem 0.875rem;
    border-radius: 16px 16px 16px 4px;
    /* Its own surface, not the phone's. --phone-card and friends are declared
       on .phone, so inside a feature card they don't resolve: the bubble came
       out with no background and a currentColor border — a heavy grey box. */
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-secondary);
    /* Overrides the thread's entrance state: in the phone the bubble waits for
       .has-reply, here it waits for the row to open. */
    opacity: 0;
    transform: translateY(6px);
}

body.light-mode .card-answer .chat-reply-card {
    background: rgba(0, 0, 0, 0.035);
    border-color: rgba(0, 0, 0, 0.08);
}

.card-answer .chat-reply-intro,
.card-answer .chat-item { color: var(--text-secondary); }

.gallery .feature-list li.is-open .card-answer .chat-reply-card {
    opacity: 1;
    transform: none;
    /* The words arrive after the row has made room for them. */
    transition-delay: 120ms;
}

.card-answer .chat-reply-intro,
.card-answer .chat-item {
    font-size: 0.8125rem;
    line-height: 1.5;
}

.card-answer .chat-reply-intro { margin-bottom: 0.4rem; }
.card-answer .chat-item + .chat-item { margin-top: 0.4rem; }

/* The prompt is a disclosure now, so it says so. */
.gallery .feature-list li:has(.card-answer) .feature-prompt {
    display: flex;
    align-items: flex-start;
    gap: 0.625rem;
}

/* Only shown where the prompt actually opens something. Beside the phone it
   is a question you send, not a row you expand. */
.feature-prompt-caret {
    display: none;
    flex: none;
    width: 14px;
    height: 14px;
    margin-top: 0.15em;
    color: var(--cyan-glow);
    transition: transform 320ms var(--ease-out);
}

body.light-mode .feature-prompt-caret { color: var(--cyan-deep); }

.gallery .feature-list li.is-open .feature-prompt-caret { transform: rotate(90deg); }

@media (max-width: 900px) {
    .feature-prompt-caret { display: block; margin-top: 0; }

    /* Tapping is the whole interaction here, not a bonus on top of a phone
       that answers by itself — so the target has to be a real one. A one-line
       prompt came out at 30px. */
    .gallery .feature-list li .feature-prompt {
        min-height: 44px;
        align-items: center;
    }
}

.gallery .feature-list li.is-open {
    background: rgba(173, 251, 246, 0.12);
    border-color: rgba(173, 251, 246, 0.3);
}

body.light-mode .gallery .feature-list li.is-open {
    background: rgba(13, 115, 119, 0.08);
    border-color: rgba(13, 115, 119, 0.24);
}

@media (prefers-reduced-motion: reduce) {
    .card-answer { transition: none; }
    .card-answer .chat-reply-card { transform: none; }
    .feature-prompt-caret { transition: none; }
}
