/* ============================================================
   STEADIDAY ASSISTANT
   On-page answer finder. No backend, no API key, no network
   call — it searches a knowledge base compiled into
   steadiday-assistant.js and links out to the real page.

   Every surface here is built from the Layer 2 semantic roles
   in steadiday-shared.css, so it inherits the site's verified
   contrast. The two values worth stating explicitly:

     * The launcher and send button fill with --green-700
       (#3A7B63), not --color-brand (#4A9D7E). White text needs
       4.5:1 and the brand sage only reaches 3.27:1.
     * Muted copy uses --color-text-muted (7.56:1), never
       --color-text-subtle, because most of it sits on a tint
       rather than on white.

   The whole widget is built by JS at runtime. With JS off
   nothing renders, so there is no dead button to click.
   ============================================================ */

.sd-assistant-launcher {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 1800;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    min-height: 56px;
    padding: 0 1.4rem 0 1.15rem;
    border: none;
    border-radius: 28px;
    background: var(--green-700);
    color: var(--neutral-0);
    font-family: var(--font-body);
    font-size: var(--text-sm);
    font-weight: 600;
    line-height: 1;
    cursor: pointer;
    box-shadow: var(--shadow-medium);
    transition: background 0.2s ease, transform 0.2s ease;
}

.sd-assistant-launcher:hover {
    background: var(--green-800);
    transform: translateY(-2px);
}

.sd-assistant-launcher svg {
    flex: none;
    width: 24px;
    height: 24px;
}

/* Hidden while the panel is open so the two never overlap */
.sd-assistant-launcher[hidden] { display: none; }

/* ---------- Panel ---------- */

.sd-assistant-panel {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 1900;
    display: flex;
    flex-direction: column;
    width: 400px;
    max-width: calc(100vw - 40px);
    max-height: min(620px, calc(100vh - 40px));
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    background: var(--color-surface);
    box-shadow: 0 12px 48px rgba(31, 41, 55, 0.22);
    overflow: hidden;
}

.sd-assistant-panel[hidden] { display: none; }

.sd-assistant-head {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 1.1rem 1.25rem;
    border-bottom: 1px solid var(--color-border);
    background: var(--color-brand-bg);
}

.sd-assistant-title {
    flex: 1;
    min-width: 0;
}

.sd-assistant-title h2 {
    font-family: var(--font-heading);
    font-size: var(--text-md);
    font-weight: 700;
    color: var(--color-text-strong);
}

.sd-assistant-title p {
    margin-top: 0.15rem;
    font-size: var(--text-xs);
    line-height: 1.45;
    color: var(--color-text-muted);
}

.sd-assistant-close {
    flex: none;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    margin: -0.35rem -0.5rem -0.35rem 0;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: var(--color-text);
    cursor: pointer;
    transition: background 0.2s ease;
}

.sd-assistant-close:hover { background: rgba(31, 41, 55, 0.08); }
.sd-assistant-close svg { width: 22px; height: 22px; }

/* ---------- Search form ---------- */

.sd-assistant-form {
    display: flex;
    gap: 0.5rem;
    padding: 0.9rem 1.25rem;
    border-bottom: 1px solid var(--color-border);
}

.sd-assistant-input {
    flex: 1;
    min-width: 0;
    min-height: 48px;
    padding: 0.5rem 0.9rem;
    border: 2px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: var(--color-surface);
    font-family: var(--font-body);
    font-size: var(--text-sm);
    color: var(--color-text);
}

.sd-assistant-input::placeholder { color: var(--color-text-muted); }
.sd-assistant-input:focus { border-color: var(--green-700); }

.sd-assistant-send {
    flex: none;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    min-height: 48px;
    border: none;
    border-radius: var(--radius-sm);
    background: var(--green-700);
    color: var(--neutral-0);
    cursor: pointer;
    transition: background 0.2s ease;
}

.sd-assistant-send:hover { background: var(--green-800); }
.sd-assistant-send svg { width: 22px; height: 22px; }

/* ---------- Results ---------- */

.sd-assistant-body {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 1.1rem 1.25rem 1.4rem;
}

.sd-assistant-intro {
    font-size: var(--text-xs);
    font-weight: 600;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.sd-assistant-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.75rem;
    padding: 0;
    list-style: none;
}

.sd-assistant-chip {
    min-height: 44px;
    padding: 0.5rem 0.9rem;
    border: 1px solid var(--color-success-border);
    border-radius: 22px;
    background: var(--color-brand-bg);
    font-family: var(--font-body);
    font-size: var(--text-xs);
    font-weight: 600;
    color: var(--color-brand-text);
    text-align: left;
    cursor: pointer;
    transition: background 0.2s ease;
}

.sd-assistant-chip:hover { background: var(--green-100); }

.sd-assistant-result {
    padding: 1rem 0;
    border-bottom: 1px solid var(--color-border);
}

.sd-assistant-result:last-child { border-bottom: none; }

.sd-assistant-result h3 {
    font-family: var(--font-heading);
    font-size: var(--text-sm);
    font-weight: 700;
    color: var(--color-text-strong);
}

.sd-assistant-result p {
    margin-top: 0.4rem;
    font-size: var(--text-sm);
    line-height: 1.6;
    color: var(--color-text);
}

.sd-assistant-result a {
    display: inline-block;
    margin-top: 0.6rem;
    font-size: var(--text-xs);
    font-weight: 600;
    color: var(--color-brand-text);
    text-decoration: underline;
    text-underline-offset: 0.15em;
}

/* The question echoed back above the answers, so a long thread
   stays readable about what was asked. */
.sd-assistant-asked {
    margin-bottom: 0.25rem;
    font-size: var(--text-xs);
    color: var(--color-text-muted);
}

.sd-assistant-asked strong { color: var(--color-text-strong); }

/* Health questions and no-match answers both land in a notice
   card. Colour is never the only signal — each carries a label. */
.sd-assistant-notice {
    margin-top: 0.4rem;
    padding: 0.9rem 1rem;
    border: 1px solid var(--color-info-border);
    border-radius: var(--radius-md);
    background: var(--color-info-bg);
}

.sd-assistant-notice h3 {
    font-family: var(--font-heading);
    font-size: var(--text-sm);
    font-weight: 700;
    color: var(--color-text-strong);
}

.sd-assistant-notice p {
    margin-top: 0.35rem;
    font-size: var(--text-xs);
    line-height: 1.6;
    color: var(--color-text);
}

.sd-assistant-notice a {
    color: var(--color-info-text);
    text-decoration: underline;
    text-underline-offset: 0.15em;
}

.sd-assistant-more {
    margin-top: 1.1rem;
    padding-top: 0.9rem;
    border-top: 1px solid var(--color-border);
}

/* The launcher floats over the bottom-right of the page, which
   is exactly where the footer keeps its legal links. Reserving
   the strip it occupies stops it covering them — the padding
   goes inside the footer so it inherits the footer's own
   background rather than opening a gap beneath it.

   Both footer shapes on the site are covered: 56 pages use
   .footer, the 9 policy pages use a bare <footer>.

   Qualified with `body` on purpose. Blog posts carry an inline
   <style> that sets `.footer { padding: 2rem }` and it loads
   after this file, so an unqualified `.footer` here loses the
   cascade on 57 pages and the links stay covered. */
body .footer,
body > footer {
    padding-bottom: 92px;
}

@media (min-width: 561px) {
    /* Wider than the launcher, so only the right-hand end of the
       footer is at risk. The reserve can be smaller. */
    body .footer,
    body > footer {
        padding-bottom: 84px;
    }
}

/* Announcement target for screen readers. The site has no
   visually-hidden utility of its own, so one is defined here
   rather than reaching for a class that does not exist. */
.sd-assistant-live {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

/* ---------- Mobile: full-height sheet ---------- */

@media (max-width: 560px) {
    .sd-assistant-launcher {
        right: 16px;
        bottom: 16px;
    }

    .sd-assistant-panel {
        right: 0;
        bottom: 0;
        left: 0;
        width: auto;
        max-width: none;
        max-height: 100vh;
        height: 100%;
        border: none;
        border-radius: 0;
    }
}

@media (prefers-reduced-motion: reduce) {
    .sd-assistant-launcher,
    .sd-assistant-close,
    .sd-assistant-send,
    .sd-assistant-chip,
    .sd-assistant-input {
        transition: none;
    }

    .sd-assistant-launcher:hover { transform: none; }
}
