/* =========================================================================
   FAQ — Knowledge Hub
   -------------------------------------------------------------------------
   Layout mirrors the Trust Center (public/trust_center.css): a sticky left
   category rail + a content column that starts IMMEDIATELY with a compact,
   left-aligned page title — no oversized centered hero. Questions are a
   hairline-divided list (no cards). Same token system → themes light + dark.

   CSP: all styling here (PUBLIC_CSP strips inline <style>); behavior in
   js/public/faq/faq.js.
   ========================================================================= */

html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

/* Sticky fix — `.body-wrap` has overflow:hidden which kills position:sticky
   for the rail; `overflow: clip` clips identically without a scroll container.
   (Same fix the Trust Center + v6 home use.) Must be external CSS. */
.body-wrap { overflow: clip !important; overflow-x: clip !important; overflow-y: clip !important; }

/* ---- Shell (copied proportions from .tc-shell / .tc-shell-inner) ------- */

.faqx {
    background: var(--main-bg-color);
    color: var(--inv-bg-color);
    padding: 5rem 0 7rem;
    min-height: 100vh;
    position: relative;
    overflow-x: clip;
}

.faqx-shell-inner {
    max-width: 1140px;
    margin: 0 auto;
    padding: 0 2rem;
    display: grid;
    grid-template-columns: 210px minmax(0, 1fr);
    gap: 5rem;
    align-items: start;
}

/* ---- Sticky rail (copied from .tc-nav) -------------------------------- */

.faqx-rail {
    position: sticky;
    top: 6rem;
    align-self: start;
    max-height: calc(100vh - 7rem);
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0.5rem 0.25rem 1rem 0;
    scrollbar-width: none;
}
.faqx-rail::-webkit-scrollbar { display: none; }

.faqx-rail-title {
    font-size: 0.6rem;
    font-weight: 700;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--inv-bg-color);
    opacity: 0.4;
    margin: 0 0 0.7rem 0.75rem;
}

.faqx-rail-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; }

.faqx-rail-link {
    display: block;
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--inv-bg-color);
    opacity: 0.72;
    text-decoration: none !important;
    border-left: 2px solid transparent;
    margin-left: -2px;
    border-radius: 0 6px 6px 0;
    cursor: pointer;
    transition: opacity 0.15s ease, color 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}
.faqx-rail-link:hover { opacity: 1; background: rgba(127, 127, 127, 0.05); }
.faqx-rail-link.is-active {
    opacity: 1;
    font-weight: 600;
    color: var(--purple);
    background: rgba(120, 115, 245, 0.09);
    border-left-color: var(--purple);
}
.faqx-rail-link.is-empty { opacity: 0.25; pointer-events: none; }

/* ---- Main column (copied from .tc-main / .tc-page) -------------------- */

.faqx-main { min-width: 0; padding-top: 0.25rem; max-width: 720px; }

/* ---- Head: compact left-aligned title + lede + search ----------------- */

.faqx-head { margin: 0 0 2.75rem; }

.faqx-h1 {
    font-size: 2.2rem;
    font-weight: 700;
    letter-spacing: -0.025em;
    line-height: 1.15;
    margin: 0 0 0.8rem;
    color: var(--inv-bg-color);
}

.faqx-lede {
    font-size: 1.02rem;
    line-height: 1.55;
    color: var(--inv-bg-color);
    opacity: 0.68;
    margin: 0 0 1.6rem;
    max-width: 560px;
}

.faqx-search { position: relative; max-width: 460px; }

.faqx-search-icon {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    color: var(--inv-bg-color);
    opacity: 0.4;
    pointer-events: none;
}

.faqx-search-input {
    width: 100%;
    box-sizing: border-box;
    padding: 0.7rem 2.6rem;
    font-family: var(--font-main);
    font-size: 0.92rem;
    color: var(--inv-bg-color);
    background: var(--off-bg-color);
    border: 1px solid var(--grey-accent-color);
    border-radius: 10px;
    outline: none;
    transition: border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}
.faqx-search-input::placeholder { color: var(--inv-bg-color); opacity: 0.4; }
.faqx-search-input:focus {
    border-color: var(--purple);
    background: var(--main-bg-color);
    box-shadow: 0 0 0 4px rgba(120, 115, 245, 0.12);
}

.faqx-search-clear {
    position: absolute;
    right: 0.5rem;
    top: 50%;
    transform: translateY(-50%);
    width: 26px;
    height: 26px;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: var(--inv-bg-color);
    opacity: 0.5;
    cursor: pointer;
    transition: opacity 0.15s ease, background 0.15s ease;
}
.faqx-search-clear:hover { opacity: 1; background: rgba(127, 127, 127, 0.1); }
.faqx.is-searching .faqx-search-clear { display: inline-flex; }

.faqx-searchmeta {
    min-height: 0.9rem;
    margin: 0.75rem 0 0;
    font-size: 0.8rem;
    color: var(--inv-bg-color);
    opacity: 0.55;
}
.faqx-searchmeta b { color: var(--purple); font-weight: 700; }

/* ---- Categories + hairline Q&A list ----------------------------------- */

.faqx-cat { margin: 0 0 2.75rem; scroll-margin-top: 6rem; }
.faqx-cat:last-of-type { margin-bottom: 0; }
.faqx-cat.is-empty { display: none; }

.faqx-cat-title {
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--purple);
    opacity: 0.9;
    margin: 0 0 0.35rem;
}

.faqx-list { list-style: none; padding: 0; margin: 0; }

.faqx-item { border-top: 1px solid var(--grey-accent-color); scroll-margin-top: 6rem; }
.faqx-item.is-empty { display: none; }

.faqx-q {
    width: 100%;
    box-sizing: border-box;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1.25rem;
    padding: 0.95rem 0;
    text-align: left;
    background: none;
    border: none;
    font-family: var(--font-main);
    font-size: 0.98rem;
    font-weight: 600;
    line-height: 1.45;
    color: var(--inv-bg-color);
    cursor: pointer;
    transition: color 0.15s ease;
}
.faqx-q:hover { color: var(--purple); }
.faqx-q:focus-visible { outline: 2px solid var(--purple); outline-offset: 3px; border-radius: 3px; }
.faqx-item.is-open .faqx-q { color: var(--purple); }

.faqx-q-text { flex: 1; }

.faqx-q-chevron {
    flex-shrink: 0;
    width: 17px;
    height: 17px;
    margin-top: 0.15rem;
    color: currentColor;
    opacity: 0.45;
    transition: transform 0.28s ease, opacity 0.15s ease;
}
.faqx-item.is-open .faqx-q-chevron { transform: rotate(180deg); opacity: 1; }

.faqx-a { max-height: 0; overflow: hidden; transition: max-height 0.3s ease; }
@media (prefers-reduced-motion: reduce) { .faqx-a { transition: none; } }

.faqx-a-inner { padding: 0 0 1.3rem; }

.faqx-a-inner p {
    font-size: 0.94rem;
    line-height: 1.72;
    color: var(--inv-bg-color);
    opacity: 0.72;
    margin: 0 0 0.8rem;
}
.faqx-a-inner p:last-child { margin-bottom: 0; }
.faqx-a-inner strong, .faqx-a-inner b { color: var(--inv-bg-color); opacity: 1; font-weight: 700; }

.faqx-a-inner ul, .faqx-a-inner ol { margin: 0 0 0.85rem; padding-left: 1.15rem; }
.faqx-a-inner li {
    font-size: 0.94rem;
    line-height: 1.65;
    color: var(--inv-bg-color);
    opacity: 0.72;
    margin: 0 0 0.4rem;
}
.faqx-a-inner li::marker { color: var(--purple); }

.faqx-a-inner a {
    color: var(--purple);
    text-decoration: underline;
    text-decoration-color: rgba(120, 115, 245, 0.35);
    text-underline-offset: 3px;
    text-decoration-thickness: 1px;
    transition: text-decoration-color 0.18s ease;
}
.faqx-a-inner a:hover { text-decoration-color: var(--purple); }

.faqx-hl { background: rgba(120, 115, 245, 0.2); border-radius: 3px; padding: 0 1px; color: inherit; }

/* ---- Empty state ------------------------------------------------------- */

.faqx-empty { display: none; padding: 2.5rem 0; }
.faqx.is-noresults .faqx-empty { display: block; }
.faqx-empty-title { font-size: 1.02rem; font-weight: 700; color: var(--inv-bg-color); margin: 0 0 0.4rem; }
.faqx-empty-text { font-size: 0.92rem; line-height: 1.6; color: var(--inv-bg-color); opacity: 0.62; margin: 0; }
.faqx-empty-query { color: var(--purple); font-weight: 600; }
.faqx-empty-text a { color: var(--purple); text-decoration: underline; text-underline-offset: 3px; }

/* ---- Closing CTA (calm, left-aligned in the column) ------------------- */

.faqx-cta { margin: 4rem 0 0; padding-top: 2.5rem; border-top: 1px solid var(--grey-accent-color); }
.faqx-cta-title { font-size: 1.15rem; font-weight: 700; color: var(--inv-bg-color); margin: 0 0 0.45rem; }
.faqx-cta-text { font-size: 0.94rem; line-height: 1.55; color: var(--inv-bg-color); opacity: 0.62; margin: 0 0 1.4rem; max-width: 460px; }
.faqx-cta-actions { display: flex; flex-wrap: wrap; gap: 0.7rem; }

.faqx-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.68rem 1.3rem;
    border-radius: 10px;
    font-size: 0.88rem;
    font-weight: 600;
    text-decoration: none !important;
    cursor: pointer;
    transition: transform 0.18s ease, border-color 0.18s ease, color 0.18s ease, opacity 0.18s ease;
}
.faqx-btn svg { width: 15px; height: 15px; }
.faqx-btn-primary { color: #fff !important; background: linear-gradient(135deg, var(--purple), var(--indigo)); }
.faqx-btn-primary:hover { transform: translateY(-1px); opacity: 0.94; }
.faqx-btn-ghost { color: var(--inv-bg-color) !important; background: transparent; border: 1px solid var(--grey-accent-color); }
.faqx-btn-ghost:hover { border-color: var(--purple); color: var(--purple) !important; }

/* ---- Responsive -------------------------------------------------------- */

@media (max-width: 820px) {
    .faqx { padding: 3.5rem 0 5rem; }
    .faqx-shell-inner { grid-template-columns: 1fr; gap: 0; padding: 0 1.25rem; }
    .faqx-rail { display: none; } /* redundant with search + section headings on mobile */
    .faqx-main { max-width: 640px; margin: 0 auto; }
}

@media (max-width: 520px) {
    .faqx-h1 { font-size: 1.8rem; }
    .faqx-search { max-width: 100%; }
    .faqx-q { font-size: 0.95rem; }
    .faqx-cta-actions { flex-direction: column; align-items: flex-start; }
}
