/* The survey invitation (js/survey-invite.js): a chat-style card that slides
   up in the bottom-right corner, or a slim bar along the bottom on a phone.
   Loaded by index.html and rehab.html, which keep different token sets, so
   the card carries its own colours — the landing page's, like the rest of
   the app (one light theme since #469: no dark mode, as in styles.css) —
   and sizes in px (rehab.html's root font is 15px, index.html's 16px). Its
   title is the landing serif and its text the page's Plex Sans, both from
   css/fonts.css, which each page links before this file.

   Layering: under the sticky headers (z-index 100) and so under the
   Notifications list, which lives inside index.html's header and paints
   at the header's level, whatever its own 200 says; under every dialog and
   the listing slide-over (1000 and up), so anything that holds the page
   covers it; over what the pages raise inside their content (cards' 1 and
   2, rehab.html's tooltips at 10). The card sits at the bottom and the
   headers at the top, so the headers only win where a short window makes
   them meet. */

.nc-si {
    --nc-si-bg: #ffffff;
    --nc-si-text: #111827;
    --nc-si-muted: #4b5563;
    --nc-si-border: #e5e7eb;
    --nc-si-accent: #0f766e;         /* the app's teal (--color-primary); white on it 5.5:1 */
    --nc-si-accent-hover: #134e4a;   /* the deep teal (--color-primary-dark) */
    --nc-si-bar: #134e4a;            /* the app's header colour (--color-header-bg) */
    --nc-si-on-accent: #ffffff;
    --nc-si-icon-bg: #ccfbf1;
    --nc-si-icon-fg: #0f766e;
    --nc-si-focus: #0d9488;
    --nc-si-hover-wash: rgba(15, 23, 42, 0.06);
    --nc-si-shadow: 0 14px 36px rgba(15, 23, 42, 0.18), 0 2px 6px rgba(15, 23, 42, 0.08);

    position: fixed;
    right: calc(20px + env(safe-area-inset-right, 0px));
    bottom: calc(20px + env(safe-area-inset-bottom, 0px));
    z-index: 90;
    width: 340px;
    max-width: calc(100vw - 32px);
    margin: 0;
    padding: 0;
    font-family: inherit;
    font-size: 14px;
    line-height: 1.5;
    color: var(--nc-si-text);
    text-align: left;
    /* Waits below the edge; slides up slowly when js adds .nc-si-open. */
    transform: translateY(calc(100% + 40px));
    opacity: 0;
    visibility: hidden;
    transition: transform 0.7s cubic-bezier(0.22, 1, 0.36, 1),
                opacity 0.5s ease,
                visibility 0s linear 0.7s;
}

.nc-si.nc-si-open {
    transform: none;
    opacity: 1;
    visibility: visible;
    transition: transform 0.7s cubic-bezier(0.22, 1, 0.36, 1),
                opacity 0.5s ease,
                visibility 0s;
}

/* ---------- the card (desktop and tablet) ---------- */

.nc-si-card {
    background: var(--nc-si-bg);
    border: 1px solid var(--nc-si-border);
    border-radius: 16px 16px 4px 16px;     /* a chat bubble's corner */
    box-shadow: var(--nc-si-shadow);
    padding: 16px 18px 14px;
}

.nc-si-head {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0 0 8px;
}

/* A small speech bubble drawn in CSS: no image, nothing for the CSP. */
.nc-si-icon {
    position: relative;
    flex: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--nc-si-icon-bg);
}

.nc-si-icon::before {
    content: "";
    position: absolute;
    left: 8px;
    top: 9px;
    width: 16px;
    height: 11px;
    border-radius: 4px;
    background: var(--nc-si-icon-fg);
}

.nc-si-icon::after {
    content: "";
    position: absolute;
    left: 11px;
    top: 19px;
    border-style: solid;
    border-width: 5px 5px 0 0;
    border-color: var(--nc-si-icon-fg) transparent transparent transparent;
}

.nc-si-title {
    margin: 0;
    padding: 0;
    /* The landing serif on both pages (styles.css gives index.html's h2
       this face; rehab.html's own sheet does not). Newsreader ships
       400-600, so 600, never a faked bold. */
    font-family: "Newsreader", Georgia, "Times New Roman", serif;
    font-size: 17px;
    font-weight: 600;
    letter-spacing: -0.01em;
    line-height: 1.3;
    color: var(--nc-si-text);
}

.nc-si-lede {
    margin: 0 0 6px;
    font-size: 14px;
    color: var(--nc-si-text);
}

.nc-si-offer {
    margin: 0 0 14px;
    font-size: 13px;
    line-height: 1.5;
    color: var(--nc-si-muted);
}

.nc-si-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.nc-si-go {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    padding: 8px 16px;
    border-radius: 8px;
    background: var(--nc-si-accent);
    color: var(--nc-si-on-accent);
    font-size: 14px;
    font-weight: 600;
    line-height: 1.2;
    text-decoration: none;
}

.nc-si-go:hover {
    background: var(--nc-si-accent-hover);
    color: var(--nc-si-on-accent);
    text-decoration: none;
}

.nc-si-later {
    min-height: 40px;
    margin: 0;
    padding: 8px 12px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--nc-si-muted);
    font: inherit;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.2;
    cursor: pointer;
}

.nc-si-later:hover {
    background: var(--nc-si-hover-wash);
    color: var(--nc-si-text);
}

.nc-si a:focus-visible,
.nc-si button:focus-visible {
    outline: 3px solid var(--nc-si-focus);
    outline-offset: 2px;
}

/* ---------- the slim bar (phones) ---------- */

.nc-si-bar,
.nc-si-spacer {
    display: none;
}

@media (max-width: 600px) {
    .nc-si {
        left: 0;
        right: 0;
        bottom: 0;
        width: auto;
        max-width: none;
    }

    .nc-si-card {
        display: none;
    }

    .nc-si-bar {
        display: flex;
        align-items: center;
        gap: 4px;
        min-height: 48px;
        /* Both pages draw under the notch (viewport-fit=cover). */
        padding: 0 calc(4px + env(safe-area-inset-right, 0px))
                 env(safe-area-inset-bottom, 0px)
                 calc(16px + env(safe-area-inset-left, 0px));
        background: var(--nc-si-bar);
        color: var(--nc-si-on-accent);
        box-shadow: 0 -4px 16px rgba(15, 23, 42, 0.18);
    }

    .nc-si-bar-go {
        flex: 1;
        min-width: 0;
        padding: 12px 0;
        color: inherit;
        font-size: 13px;
        line-height: 1.35;
        text-decoration: none;
    }

    .nc-si-bar-go:hover {
        color: inherit;
    }

    .nc-si-bar-go strong {
        font-weight: 700;
    }

    /* On a narrow phone the line breaks before the action, never inside it. */
    .nc-si-bar-action {
        white-space: nowrap;
        text-decoration: underline;
        text-underline-offset: 2px;
    }

    .nc-si-bar-close {
        flex: none;
        width: 44px;
        height: 44px;
        margin: 0;
        padding: 0;
        border: 0;
        border-radius: 8px;
        background: transparent;
        color: inherit;
        font: inherit;
        font-size: 18px;
        line-height: 1;
        cursor: pointer;
    }

    .nc-si-bar a:focus-visible,
    .nc-si-bar button:focus-visible {
        outline-color: var(--nc-si-on-accent);
        outline-offset: -3px;
    }

    /* Room at the end of the page, so the bar never covers its last line. */
    .nc-si-spacer {
        display: block;
        flex: none;
        height: calc(56px + env(safe-area-inset-bottom, 0px));
    }
}

/* ---------- the status line screen readers hear ---------- */

.nc-si-sr {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    border: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    white-space: nowrap;
}

@media (prefers-reduced-motion: reduce) {
    .nc-si,
    .nc-si.nc-si-open {
        transform: none;
        transition: none;
    }
}

@media print {
    .nc-si,
    .nc-si-spacer {
        display: none;
    }
}
