/*
 * The showcase guide (assets/js/guide.js): the main site's chat box, finding the concept sites
 * closest to a visitor's business. Mirrors the main site's public/css/assistant.css
 * (launcher, panel, bubbles, chips, composer, phone bottom sheet). Every value is a token from
 * tokens.css (--g-*, --guide-*); nothing is defined here. Input text is 16px: smaller makes iPhone
 * Safari zoom the page on focus.
 */

.sg {
    position: fixed; right: var(--guide-edge); bottom: var(--guide-edge); z-index: var(--guide-z);
    font-family: var(--g-font);
}
.sg-open { z-index: var(--guide-z-open); }
.sg-sr {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.sg-icon { width: 20px; height: 20px; flex-shrink: 0; }
/* The monogram artwork sits right of centre and high in its square image; the main chat shifts it
   back by the measured amount (its MonogramCentringTest). Same shift here. */
.sg-mark { display: block; width: 24px; height: 24px; object-fit: contain; transform: translate(-8%, 3%); }
.sg-head-mark .sg-mark { width: 28px; height: 28px; }

/* ── Launcher ── */
.sg-launcher {
    display: inline-flex; align-items: center; gap: 10px;
    padding: 8px 20px 8px 8px; border: 0; border-radius: var(--g-pill); cursor: pointer;
    background: var(--g-blue); color: var(--g-text);
    font-family: var(--g-font); font-size: 15px; font-weight: var(--g-weight-semi); line-height: var(--g-leading-solid);
    box-shadow: 0 10px 30px var(--g-blue-glow);
    transition: transform var(--g-dur-fast) ease, background var(--g-dur-fast) ease;
}
.sg-launcher:hover { background: var(--g-blue-light); transform: translateY(-2px); }
.sg-launcher-mark {
    display: inline-flex; align-items: center; justify-content: center;
    width: 38px; height: 38px; border-radius: 50%; background: var(--g-ink);
}
.sg-open .sg-launcher { display: none; }
.sg-launcher-label { display: inline-block; max-width: var(--guide-label-max); overflow: hidden; white-space: nowrap; transition: max-width var(--g-dur) var(--g-ease), opacity var(--g-dur-fast) ease; }
/* Phones: over a card's words the launcher tucks down to its monogram, so it never sits on the copy
   (guide.js toggles .sg-tucked). Same button, same name; the label returns over a gap or a window. */
.sg-tucked .sg-launcher { gap: 0; padding-right: 8px; }
.sg-tucked .sg-launcher-label { max-width: 0; opacity: 0; }

/* ── The greeting bubble above the launcher (the main site's alert bubble, assistant.css .epa-alert) ── */
.sg-nudge {
    position: absolute; right: 0; bottom: calc(100% + 14px);
    width: min(300px, calc(100vw - 24px)); padding: 14px 16px;
    background: var(--g-ink-raised); color: var(--g-text-soft);
    border: 1px solid var(--g-line); border-radius: 14px;
    box-shadow: 0 18px 40px var(--g-shadow); animation: sg-in var(--g-dur-fast) ease-out;
}
.sg-nudge[hidden] { display: none; }
.sg-nudge::after {
    content: ''; position: absolute; right: 34px; bottom: -7px; width: 12px; height: 12px;
    background: var(--g-ink-raised); border-right: 1px solid var(--g-line); border-bottom: 1px solid var(--g-line);
    transform: rotate(45deg);
}
.sg-nudge-label { margin: 0; font-size: 11px; font-weight: var(--g-weight-bold); letter-spacing: var(--guide-track); text-transform: uppercase; color: var(--g-orange); }
.sg-nudge-text { margin: 4px 0 0; font-size: 14px; font-weight: var(--g-weight-semi); line-height: var(--guide-leading-tight); color: var(--g-text); }
.sg-nudge-actions { display: flex; align-items: center; justify-content: space-between; margin-top: 10px; }
.sg-nudge-go {
    border: 0; border-radius: var(--g-pill); padding: 6px 16px; cursor: pointer;
    background: var(--g-blue); color: var(--g-text);
    font-family: var(--g-font); font-size: 13px; font-weight: var(--g-weight-semi); line-height: var(--guide-leading-chip);
}
.sg-nudge-go:hover { background: var(--g-blue-light); }
.sg-nudge-close {
    display: inline-flex; border: 0; padding: 6px; border-radius: 8px; cursor: pointer;
    background: transparent; color: var(--g-text-soft);
}
.sg-nudge-close:hover { color: var(--g-text); background: var(--g-ink-card); }
.sg-open .sg-nudge { display: none; }

/* ── Panel ── */
.sg-panel {
    display: flex; flex-direction: column;
    width: var(--guide-width); height: min(var(--guide-height), calc(100vh - 40px));
    background: var(--g-ink-raised); color: var(--g-text-soft);
    border: 1px solid var(--g-line); border-radius: var(--guide-radius);
    box-shadow: 0 24px 60px var(--g-shadow);
    overflow: hidden; animation: sg-in var(--g-dur-fast) ease-out;
}
.sg-panel[hidden] { display: none; }
@keyframes sg-in { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

.sg-head {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 14px 16px; border-bottom: 1px solid var(--g-line); background: var(--g-ink);
}
.sg-brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.sg-head-mark {
    position: relative; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
    width: 42px; height: 42px; border-radius: var(--g-radius-sm);
    background: var(--g-ink-raised); border: 1px solid var(--g-line);
}
.sg-presence {
    position: absolute; right: -3px; bottom: -3px; width: 12px; height: 12px; border-radius: 50%;
    background: var(--guide-online); box-shadow: 0 0 0 2.5px var(--g-ink);
}
.sg-title { margin: 0; font-weight: var(--g-weight-bold); font-size: 16px; color: var(--g-text); }
.sg-sub { margin: 3px 0 0; font-size: 12px; line-height: var(--guide-leading-tight); color: var(--g-text-muted); }
.sg-close {
    display: inline-flex; padding: 8px; border: 0; border-radius: 10px; cursor: pointer;
    background: transparent; color: var(--g-text-muted);
}
.sg-close:hover { color: var(--g-text); background: var(--g-ink-card); }

/* ── Conversation ── */
.sg-log {
    flex: 1; overflow-y: auto; padding: 16px 14px 8px;
    display: flex; flex-direction: column; gap: 12px; overscroll-behavior: contain;
}
.sg-msg {
    max-width: 86%; min-width: 0; padding: 11px 14px; border-radius: 14px;
    font-size: 14px; line-height: var(--guide-leading); overflow-wrap: anywhere;
}
.sg-msg p { margin: 0; }
.sg-msg p + p { margin-top: 6px; }
.sg-bot { align-self: flex-start; background: var(--g-ink-card); border-bottom-left-radius: 4px; }
.sg-user { align-self: flex-end; background: var(--g-blue); color: var(--g-text); border-bottom-right-radius: 4px; }
.sg-heading { font-weight: var(--g-weight-bold); color: var(--g-text); }
.sg-tip { font-size: 12px; color: var(--g-text-muted); }

.sg-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.sg-chip {
    padding: 7px 12px; border-radius: var(--g-pill); cursor: pointer;
    border: 1px solid var(--g-line); background: var(--g-ink); color: var(--g-text-soft);
    font-family: var(--g-font); font-size: 13px; font-weight: var(--g-weight-medium); line-height: var(--guide-leading-chip); text-align: left;
}
.sg-chip:hover { border-color: var(--g-blue); color: var(--g-text); background: var(--guide-chip-hover); }

/* A matching concept site: name, world, line, and the link to open it */
.sg-sites { display: grid; gap: 8px; margin-top: 10px; }
.sg-site {
    display: block; padding: 10px 12px; border-radius: var(--g-radius-sm); text-decoration: none;
    border: 1px solid var(--g-line); background: var(--g-ink); color: var(--g-text-soft);
}
.sg-site:hover { border-color: var(--g-blue); }
.sg-site-name { display: block; font-weight: var(--g-weight-semi); color: var(--g-text); }
.sg-site-world { display: block; font-size: 11px; letter-spacing: var(--guide-track); text-transform: uppercase; color: var(--g-text-muted); margin-top: 2px; }
.sg-site-line { display: block; font-size: 13px; margin-top: 6px; }
.sg-site-open { display: inline-block; margin-top: 6px; font-size: 13px; font-weight: var(--g-weight-semi); color: var(--g-blue-light); }

.sg-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.sg-cta {
    display: inline-flex; align-items: center; padding: 8px 14px; border-radius: var(--g-pill);
    font-weight: var(--g-weight-semi); font-size: 13px; text-decoration: none;
    border: 1px solid var(--g-blue); color: var(--g-text); background: var(--guide-chip-hover);
}
.sg-cta:hover { background: var(--g-blue); }
.sg-cta-primary { background: var(--g-orange); border-color: var(--g-orange); }
.sg-cta-primary:hover { background: var(--g-orange-light); border-color: var(--g-orange-light); }

/* ── Composer ── */
.sg-form { display: flex; align-items: center; gap: 8px; padding: 12px 14px 6px; border-top: 1px solid var(--g-line); }
.sg-form input {
    flex: 1; min-width: 0; padding: 12px 14px; border: 1px solid var(--g-line); border-radius: var(--g-radius-sm);
    background: var(--g-ink); color: var(--g-text); font-size: 16px; font-family: var(--g-font);
}
.sg-form input::placeholder { color: var(--g-text-muted); }
.sg-send {
    display: inline-flex; padding: 12px; border: 0; border-radius: var(--g-radius-sm); cursor: pointer;
    background: var(--g-blue); color: var(--g-text); font-family: var(--g-font); font-size: 14px; font-weight: var(--g-weight-semi); line-height: var(--g-leading-solid);
}
.sg-send:hover { background: var(--g-blue-light); }
.sg-note { margin: 0; padding: 0 14px 14px; font-size: 11px; color: var(--g-text-muted); }

.sg button:focus-visible, .sg a:focus-visible, .sg input:focus-visible { outline: 2px solid var(--g-blue-light); outline-offset: 2px; }

/* Phones: a bottom sheet, as on the main site */
@media (max-width: 640px) {
    .sg { right: 12px; bottom: 12px; }
    .sg-open { left: 0; right: 0; bottom: 0; }
    .sg-panel { width: 100%; height: 88vh; height: 88dvh; border-radius: var(--guide-radius) var(--guide-radius) 0 0; border-bottom: 0; }
    .sg-msg { max-width: 90%; }
}
@media (prefers-reduced-motion: reduce) {
    .sg-panel, .sg-nudge { animation: none; }
    .sg-launcher { transition: none; }
}
