/*
 * Shared search palette and floating search / scroll buttons, used by every website
 * template (resources/views/website/partials/palette.blade.php). Neutral surfaces with the
 * organization's primary colour as the accent; a template can restyle it through the
 * --wsp-* custom properties on #ws-root, and lift the floating stack above its own bottom
 * UI with --ws-float-bottom.
 */
#ws-root .wsp {
    --wsp-surface: #ffffff;
    --wsp-ink: #111827;
    --wsp-muted: #5b6474;
    --wsp-line: rgba(17, 24, 39, 0.1);
    --wsp-accent: var(--ws-primary, #2563eb);
    --wsp-accent-ink: #ffffff;
    --wsp-scrim: rgba(15, 23, 42, 0.45);
    --wsp-radius: 14px;
    --wsp-font: inherit;
    font-family: var(--wsp-font);
}
#ws-root.ws-dark .wsp {
    --wsp-surface: #161b26;
    --wsp-ink: #e8ecf3;
    --wsp-muted: #9aa4b6;
    --wsp-line: rgba(232, 236, 243, 0.12);
    --wsp-scrim: rgba(0, 0, 0, 0.6);
}
html.wsp-locked { overflow: hidden; }

#ws-root .wsp .ws-np { display: none; }
#ws-root .wsp[data-lang="np"] .ws-np { display: inline; }
#ws-root .wsp[data-lang="np"] .ws-en { display: none; }
#ws-root .wsp-sr {
    position: absolute; width: 1px; height: 1px; overflow: hidden;
    clip: rect(0 0 0 0); white-space: nowrap;
}

/* ── Palette ─────────────────────────────────────────────────────────── */
#ws-root .wsp-dialog {
    position: fixed; inset: 0; z-index: 59;
    display: flex; align-items: flex-start; justify-content: center;
    padding: 0;
    background: var(--wsp-scrim);
    -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
}
#ws-root .wsp-box {
    display: flex; flex-direction: column;
    width: 100%; height: 100%;
    background: var(--wsp-surface); color: var(--wsp-ink);
    box-shadow: 0 30px 80px -20px rgba(0, 0, 0, 0.45);
    overflow: hidden;
}
@media (min-width: 48rem) {
    #ws-root .wsp-dialog { padding: 12vh 1rem 1rem; }
    #ws-root .wsp-box {
        width: min(40rem, 100%); height: auto; max-height: 72vh;
        border: 1px solid var(--wsp-line); border-radius: var(--wsp-radius);
    }
}
#ws-root .wsp--in { transition: opacity 0.18s ease; }
#ws-root .wsp--in .wsp-box { transition: transform 0.22s cubic-bezier(0.2, 0.8, 0.2, 1); }
#ws-root .wsp--from { opacity: 0; }
#ws-root .wsp--from .wsp-box { transform: translateY(-10px) scale(0.98); }
#ws-root .wsp--to { opacity: 1; }

#ws-root .wsp-field {
    display: flex; align-items: center; gap: 0.75rem;
    padding: 0.9rem 1rem; border-bottom: 1px solid var(--wsp-line);
}
#ws-root .wsp-field > svg { flex: none; width: 1.3rem; height: 1.3rem; color: var(--wsp-accent); }
#ws-root.ws-dark .wsp-field > svg { color: color-mix(in srgb, var(--wsp-accent) 55%, #ffffff); }
#ws-root .wsp-field input {
    flex: 1; min-width: 0; height: 2.4rem; padding: 0;
    border: 0; outline: 0; background: transparent; color: var(--wsp-ink);
    font: inherit; font-size: 1.1rem;
}
#ws-root .wsp-field input::placeholder { color: var(--wsp-muted); }
#ws-root .wsp-esc {
    flex: none; display: grid; place-items: center; min-width: 2.4rem; height: 2.2rem; padding: 0 0.5rem;
    border: 1px solid var(--wsp-line); border-radius: 8px;
    background: transparent; color: var(--wsp-muted); font: inherit; font-size: 0.8rem; font-weight: 600; cursor: pointer;
}
#ws-root .wsp-esc:hover { color: var(--wsp-ink); }
#ws-root .wsp-esc__x { display: none; width: 1.1rem; height: 1.1rem; }
@media (max-width: 47.99rem) {
    #ws-root .wsp-esc__key { display: none; }
    #ws-root .wsp-esc__x { display: block; }
}
#ws-root .wsp :focus-visible { outline: 2px solid var(--wsp-accent); outline-offset: 2px; }
#ws-root .wsp-field input:focus-visible { outline: 0; }

#ws-root .wsp-list { flex: 1; margin: 0; padding: 0.4rem 0.5rem 0.6rem; list-style: none; overflow-y: auto; overscroll-behavior: contain; }
#ws-root .wsp-group { margin: 0.6rem 0.6rem 0.25rem; font-size: 0.78rem; font-weight: 700; color: var(--wsp-muted); }
#ws-root .wsp-opt {
    display: flex; align-items: center; gap: 0.75rem;
    padding: 0.55rem 0.65rem; border-radius: 10px; cursor: pointer;
}
#ws-root .wsp-opt.is-active { background: var(--wsp-accent); color: var(--wsp-accent-ink); }
#ws-root .wsp-icon {
    flex: none; display: grid; place-items: center; width: 2rem; height: 2rem; border-radius: 8px;
    background: color-mix(in srgb, var(--wsp-accent) 12%, transparent); color: var(--wsp-accent);
}
#ws-root.ws-dark .wsp-icon { color: color-mix(in srgb, var(--wsp-accent) 55%, #ffffff); }
#ws-root .wsp-opt.is-active .wsp-icon { background: rgba(255, 255, 255, 0.18); color: inherit; }
#ws-root .wsp-icon svg { width: 1.05rem; height: 1.05rem; }
#ws-root .wsp-text { flex: 1; min-width: 0; display: grid; }
#ws-root .wsp-label { font-weight: 600; line-height: 1.35; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#ws-root .wsp-trail { font-size: 0.82rem; color: var(--wsp-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#ws-root .wsp-opt.is-active .wsp-trail { color: inherit; opacity: 0.8; }
#ws-root .wsp-go { flex: none; width: 1rem; height: 1rem; opacity: 0; transform: translateX(-4px); transition: opacity 0.12s ease, transform 0.12s ease; }
#ws-root .wsp-opt.is-active .wsp-go { opacity: 1; transform: none; }
#ws-root .wsp-none { margin: 0; padding: 1.5rem 1.25rem; color: var(--wsp-muted); }
#ws-root .wsp-help {
    display: none; gap: 1.25rem; margin: 0; padding: 0.6rem 1rem;
    border-top: 1px solid var(--wsp-line); font-size: 0.8rem; color: var(--wsp-muted);
}
#ws-root .wsp-help kbd {
    display: inline-block; min-width: 1.4rem; margin-right: 0.15rem; padding: 0.05rem 0.35rem;
    border: 1px solid var(--wsp-line); border-radius: 5px; font: inherit; font-size: 0.75rem; text-align: center;
}
@media (min-width: 48rem) { #ws-root .wsp-help { display: flex; } }

/* ── Floating stack, bottom left ─────────────────────────────────────── */
#ws-root .wsp-float {
    position: fixed; z-index: 55;
    left: calc(var(--ws-float-left, 1.25rem) + env(safe-area-inset-left));
    bottom: calc(var(--ws-float-bottom, 1.5rem) + env(safe-area-inset-bottom));
    display: flex; flex-direction: column; gap: 0.5rem;
}
/* Hidden, not just inert, while a full-screen menu or the palette is open (Mandala's menu sits below it) */
#ws-root .wsp-float[inert] { visibility: hidden; }
#ws-root .wsp-box:focus { outline: 0; }
#ws-root .wsp-fab {
    display: grid; place-items: center; width: 2.9rem; height: 2.9rem; padding: 0;
    border: 1px solid var(--wsp-line); border-radius: 999px;
    background: var(--wsp-surface); color: var(--wsp-ink);
    box-shadow: 0 10px 24px -10px rgba(15, 23, 42, 0.45);
    cursor: pointer;
    transition: transform 0.15s ease, background-color 0.15s ease;
}
#ws-root .wsp-fab:hover { transform: translateY(-2px); }
#ws-root .wsp-fab svg { width: 1.25rem; height: 1.25rem; }
#ws-root .wsp-fab--search { background: var(--wsp-accent); border-color: transparent; color: var(--wsp-accent-ink); }

@media (prefers-reduced-motion: reduce) {
    #ws-root .wsp--in, #ws-root .wsp--in .wsp-box, #ws-root .wsp-fab, #ws-root .wsp-go { transition: none; }
}

/* ── Visitor theme picker (when the organization switched it on) ─────── */
#ws-root .wsp-themes { position: relative; }
#ws-root .wsp-themes__panel {
    position: absolute; left: 0; bottom: calc(100% + 0.6rem);
    width: min(19rem, calc(100vw - 2.5rem)); max-height: min(60vh, 26rem); overflow-y: auto; overscroll-behavior: contain;
    padding: 0.75rem; border: 1px solid var(--wsp-line); border-radius: var(--wsp-radius);
    background: var(--wsp-surface); color: var(--wsp-ink);
    box-shadow: 0 24px 60px -20px rgba(0, 0, 0, 0.45);
}
#ws-root .wsp-themes__title { margin: 0 0.25rem 0.5rem; font-size: 0.85rem; font-weight: 700; color: var(--wsp-muted); }
#ws-root .wsp-themes__list { margin: 0; padding: 0; list-style: none; display: grid; gap: 0.15rem; }
#ws-root .wsp-themes__list a {
    display: flex; align-items: center; gap: 0.65rem; padding: 0.5rem 0.6rem; border-radius: 10px;
    color: var(--wsp-ink); text-decoration: none; font-size: 0.92rem;
}
#ws-root .wsp-themes__list a:hover { background: color-mix(in srgb, var(--wsp-accent) 10%, transparent); }
#ws-root .wsp-themes__list a.is-on { background: var(--wsp-accent); color: var(--wsp-accent-ink); font-weight: 600; }
#ws-root .wsp-themes__sw { display: inline-flex; flex: none; }
#ws-root .wsp-themes__sw i { display: block; width: 0.85rem; height: 0.85rem; margin-left: -0.25rem; border-radius: 50%; box-shadow: 0 0 0 2px var(--wsp-surface); }
#ws-root .wsp-themes__sw i:first-child { margin-left: 0; }
#ws-root .wsp-themes__name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#ws-root .wsp-themes__list small { flex: none; font-size: 0.72rem; opacity: 0.75; }
