/* ============================================================
   RowFold — help system: topbar button, context drawer, /Help center.
   Tokens come from tokens.css; layering sits between the peek stack (41)
   and the ⌘K scrim (60) so search always wins and peek stays reachable.
   ============================================================ */

/* ─── Topbar help button ───────────────────────────────────── */
.help-btn {
    display: grid; place-items: center; width: 34px; height: 34px; flex-shrink: 0;
    background: #fff; border: 1px solid var(--border); border-radius: 10px;
    color: var(--text-muted); cursor: pointer; transition: 0.14s; position: relative;
}
.help-btn:hover { border-color: var(--border-2); background: var(--card-2); color: var(--text); }
.help-btn.active { background: var(--ink-900); border-color: var(--ink-900); color: var(--accent); }
/* First-run nudge: a soft accent dot until help is opened once */
.help-btn.unseen::after {
    content: ''; position: absolute; top: -3px; right: -3px; width: 9px; height: 9px;
    border-radius: 50%; background: var(--accent-deep); border: 2px solid var(--paper);
    animation: help-pulse 2s ease-in-out infinite;
}
@keyframes help-pulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.35); opacity: 0.65; }
}

/* Inline "learn more" pill used in page headers (opens the drawer to a topic) */
.help-link {
    display: inline-flex; align-items: center; gap: 6px; margin-top: 10px;
    background: none; border: 1px dashed var(--border); border-radius: 999px;
    padding: 4px 11px; font-size: 12px; font-weight: 600; color: var(--text-muted);
    cursor: pointer; font-family: inherit; transition: 0.14s;
}
.help-link:hover { color: var(--accent-ink); border-color: var(--accent-deep); background: var(--accent-tint-2); }
.help-link svg { flex-shrink: 0; }

/* ─── Drawer shell ─────────────────────────────────────────── */
.help-drawer {
    position: fixed; top: 0; right: 0; bottom: 0; width: 400px; max-width: 100vw;
    background: var(--paper); border-left: 1px solid var(--border-2);
    box-shadow: var(--shadow-lg); z-index: 50;
    display: flex; flex-direction: column;
    transform: translateX(calc(100% + 12px)); transition: transform 0.28s cubic-bezier(.2,.8,.2,1);
}
.help-drawer.open { transform: translateX(0); }

.help-head {
    display: flex; align-items: center; gap: 10px; padding: 14px 16px 12px;
    border-bottom: 1px solid var(--border);
}
.help-head-ic {
    display: grid; place-items: center; width: 28px; height: 28px; border-radius: 9px;
    background: var(--accent); color: var(--ink-900); flex-shrink: 0;
}
.help-head-t { font-family: var(--font-display); font-size: 19px; font-weight: 700; color: var(--text); flex: 1; }
.help-center-link {
    display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 650;
    color: var(--accent-ink); text-decoration: none; padding: 5px 9px; border-radius: 8px;
    background: var(--accent-tint);
}
.help-center-link:hover { background: var(--accent-tint-2); color: var(--accent-ink); }
.help-x {
    display: grid; place-items: center; width: 28px; height: 28px; border-radius: 8px;
    background: none; border: none; color: var(--text-muted); cursor: pointer;
}
.help-x:hover { background: var(--paper-2); color: var(--text); }

.help-search {
    display: flex; align-items: center; gap: 9px; margin: 12px 16px 0;
    background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 8px 11px;
    color: var(--text-muted);
}
.help-search:focus-within { border-color: var(--accent-deep); }
.help-search input {
    flex: 1; border: none; outline: none; background: none; font-size: 13px;
    color: var(--text); font-family: var(--font-sans);
}
.help-search input::placeholder { color: var(--text-faint); }

.help-tabs { display: flex; gap: 4px; padding: 12px 16px 0; border-bottom: 1px solid var(--border); }
.help-tab {
    background: none; border: none; border-bottom: 2px solid transparent;
    padding: 7px 10px 9px; font-size: 12.5px; font-weight: 650; color: var(--text-muted);
    cursor: pointer; font-family: inherit; margin-bottom: -1px;
}
.help-tab:hover { color: var(--text); }
.help-tab.active { color: var(--text); border-bottom-color: var(--accent-deep); }

.help-body { flex: 1; overflow-y: auto; padding: 16px; }
.help-pane[hidden] { display: none; }
.help-loading, .help-empty { color: var(--text-muted); font-size: 13px; padding: 18px 4px; }

.help-back {
    display: inline-flex; align-items: center; gap: 6px; margin-bottom: 14px;
    background: var(--paper-2); border: 1px solid var(--border); border-radius: 8px;
    padding: 5px 10px; font-size: 12px; font-weight: 600; color: var(--text-2);
    cursor: pointer; font-family: inherit;
}
.help-back:hover { background: var(--card-2); color: var(--text); }

/* ─── Article rendering (shared: drawer + /Help) ───────────── */
.help-article .ha-cat {
    font-size: 10.5px; letter-spacing: 0.12em; text-transform: uppercase; font-weight: 700;
    color: var(--accent-ink); margin-bottom: 5px;
}
.help-article .ha-title {
    font-family: var(--font-display); font-size: 22px; font-weight: 700; color: var(--text);
    margin: 0 0 7px; line-height: 1.2;
}
.help-article .ha-purpose { font-size: 13.5px; color: var(--text-2); line-height: 1.55; margin: 0 0 18px; }

.help-article .ha-section { margin-bottom: 18px; }
.help-article .ha-section h4 {
    font-size: 13.5px; font-weight: 700; color: var(--text); margin: 0 0 7px;
}
.help-article .ha-section p { font-size: 13px; color: var(--text-2); line-height: 1.6; margin: 0 0 9px; }
.help-article .ha-section ul, .help-article .ha-section ol {
    font-size: 13px; color: var(--text-2); line-height: 1.6; margin: 0 0 9px; padding-left: 20px;
}
.help-article .ha-section li { margin-bottom: 4px; }
.help-article .ha-section li::marker { color: var(--accent-deep); }
.help-article strong { color: var(--text); font-weight: 650; }
.help-article code {
    font-family: var(--font-mono); font-size: 11.5px; background: var(--paper-2);
    border: 1px solid var(--border); border-radius: 5px; padding: 1px 5px; color: var(--text);
}
.help-article kbd {
    font-family: var(--font-mono); font-size: 10.5px; padding: 2px 6px;
    border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 5px;
    background: #fff; color: var(--text-2); white-space: nowrap;
}

.ha-keys { width: 100%; border-collapse: collapse; }
.ha-keys td { padding: 5px 0; vertical-align: top; font-size: 12.5px; }
.ha-keys .hk-keys { white-space: nowrap; padding-right: 14px; width: 1%; }
.ha-keys .hk-keys kbd { margin-right: 3px; }
.ha-keys .hk-action { color: var(--text-2); line-height: 1.5; }
.ha-keys .hk-ctx { color: var(--text-faint); font-size: 11.5px; text-align: right; white-space: nowrap; padding-left: 10px; }
.ha-keys tr + tr td { border-top: 1px solid var(--border-soft); }

.ha-box {
    border-radius: var(--radius); padding: 12px 14px; margin-bottom: 14px;
    border: 1px solid var(--border);
}
.ha-box .hb-label { font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; margin-bottom: 7px; }
.ha-box ul { margin: 0; padding-left: 18px; font-size: 12.5px; line-height: 1.55; }
.ha-box li { margin-bottom: 5px; }
.ha-box li:last-child { margin-bottom: 0; }
.ha-tips { background: var(--accent-tint-2); border-color: rgba(175,210,39,0.4); }
.ha-tips .hb-label { color: var(--accent-ink); }
.ha-tips ul { color: var(--text-2); }
.ha-perms { background: var(--relation-soft); border-color: rgba(124,92,255,0.25); }
.ha-perms .hb-label { color: var(--relation-ink); }
.ha-perms ul { color: var(--text-2); }
.ha-pitfalls { background: var(--rollup-soft); border-color: rgba(255,107,74,0.3); }
.ha-pitfalls .hb-label { color: var(--rollup-ink); }
.ha-pitfalls ul { color: var(--text-2); }

.ha-related { margin-top: 16px; }
.ha-related .hb-label { font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-faint); margin-bottom: 8px; }
.ha-related-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.ha-chip {
    background: #fff; border: 1px solid var(--border); border-radius: 999px;
    padding: 5px 12px; font-size: 12px; font-weight: 600; color: var(--text-2);
    cursor: pointer; font-family: inherit; transition: 0.14s;
}
.ha-chip:hover { border-color: var(--accent-deep); color: var(--text); background: var(--accent-tint-2); }

/* ─── Drawer: shortcuts + topics panes ─────────────────────── */
.hs-group { margin-bottom: 18px; }
.hs-ctx { font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-faint); margin-bottom: 6px; }

.ht-group { margin-bottom: 16px; }
.ht-cat { font-size: 10.5px; letter-spacing: 0.12em; text-transform: uppercase; font-weight: 700; color: var(--text-faint); margin-bottom: 6px; }
.ht-topic {
    display: block; width: 100%; text-align: left; background: none; border: 1px solid transparent;
    border-radius: 10px; padding: 8px 10px; cursor: pointer; font-family: inherit; transition: 0.13s;
}
.ht-topic:hover { background: #fff; border-color: var(--border); }
.ht-topic.current { background: var(--accent-tint-2); border-color: rgba(175,210,39,0.4); }
.ht-topic .ht-t { display: block; font-size: 13px; font-weight: 650; color: var(--text); margin-bottom: 2px; }
.ht-topic .ht-s {
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
    font-size: 12px; color: var(--text-muted); line-height: 1.45;
}
.ht-cat-chip {
    font-size: 10px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase;
    color: var(--accent-ink); background: var(--accent-tint); border-radius: 5px; padding: 1px 6px; margin-left: 6px;
}

/* On smaller screens the drawer takes the full width */
@media (max-width: 640px) {
    .help-drawer { width: 100vw; border-left: none; }
}

/* ─── First-run walk-through (tour.js) ─────────────────────── */
.tour-scrim { position: fixed; inset: 0; z-index: 70; }
.tour-spot {
    position: fixed; border-radius: 12px; pointer-events: none;
    box-shadow: 0 0 0 9999px rgba(14,20,40,0.55), 0 0 0 2px var(--accent);
    transition: top 0.25s cubic-bezier(.2,.8,.2,1), left 0.25s cubic-bezier(.2,.8,.2,1),
                width 0.25s cubic-bezier(.2,.8,.2,1), height 0.25s cubic-bezier(.2,.8,.2,1);
}
.tour-card {
    position: fixed; width: 320px; background: var(--paper);
    border: 1px solid var(--border-2); border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg); padding: 16px 18px;
    transition: top 0.25s cubic-bezier(.2,.8,.2,1), left 0.25s cubic-bezier(.2,.8,.2,1);
}
.tour-dots { display: flex; gap: 5px; margin-bottom: 10px; }
.tour-dots .td { width: 6px; height: 6px; border-radius: 50%; background: var(--border); transition: 0.2s; }
.tour-dots .td.on { background: var(--accent-deep); width: 16px; border-radius: 3px; }
.tour-title { font-family: var(--font-display); font-size: 17px; font-weight: 700; color: var(--text); margin-bottom: 6px; }
.tour-body { font-size: 13px; color: var(--text-2); line-height: 1.55; margin-bottom: 14px; }
.tour-body kbd {
    font-family: var(--font-mono); font-size: 10.5px; padding: 1px 5px;
    border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 4px; background: #fff; color: var(--text-2);
}
.tour-btns { display: flex; align-items: center; gap: 8px; }
.tour-skip { background: none; border: none; padding: 0; font-size: 12px; color: var(--text-faint); cursor: pointer; font-family: inherit; }
.tour-skip:hover { color: var(--text-muted); }
.tour-back {
    background: none; border: 1px solid var(--border); border-radius: 8px; padding: 6px 13px;
    font-size: 12.5px; font-weight: 600; color: var(--text-2); cursor: pointer; font-family: inherit;
}
.tour-next {
    background: var(--ink-900); border: none; border-radius: 8px; padding: 6px 16px;
    font-size: 12.5px; font-weight: 650; color: var(--accent); cursor: pointer; font-family: inherit;
}
.tour-next:hover { background: var(--ink-800); }

/* Help-drawer footer: tour replay */
.help-foot { border-top: 1px solid var(--border); padding: 10px 16px; }
.tour-replay {
    display: inline-flex; align-items: center; gap: 7px; background: none; border: none;
    padding: 0; font-size: 12.5px; font-weight: 600; color: var(--text-muted);
    cursor: pointer; font-family: inherit;
}
.tour-replay:hover { color: var(--accent-ink); }

/* ─── /Help center ─────────────────────────────────────────── */
.hc { max-width: 1060px; margin: 0 auto; }
.hc-hero { text-align: center; padding: 34px 16px 26px; }
.hc-hero-t { font-family: var(--font-display); font-size: 40px; font-weight: 800; color: var(--text); margin: 0 0 10px; }
.hc-hero-s { font-size: 14.5px; color: var(--text-2); max-width: 560px; margin: 0 auto 22px; line-height: 1.6; }
.hc-hero-s kbd {
    font-family: var(--font-mono); font-size: 11px; padding: 2px 6px;
    border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 5px; background: #fff; color: var(--text-2);
}
.hc-search {
    position: relative; display: flex; align-items: center; gap: 11px; max-width: 560px; margin: 0 auto;
    background: #fff; border: 1px solid var(--border); border-radius: 14px; padding: 13px 17px;
    box-shadow: var(--shadow); color: var(--text-muted);
}
.hc-search:focus-within { border-color: var(--accent-deep); }
.hc-search input {
    flex: 1; border: none; outline: none; background: none; font-size: 15px;
    color: var(--text); font-family: var(--font-sans);
}
.hc-search input::placeholder { color: var(--text-faint); }
.hc-search-results {
    position: absolute; top: calc(100% + 8px); left: 0; right: 0; max-height: 380px; overflow-y: auto;
    background: #fff; border: 1px solid var(--border-2); border-radius: 14px; box-shadow: var(--shadow-lg);
    padding: 8px; z-index: 30; text-align: left;
}
.hcs-hit { display: block; padding: 10px 12px; border-radius: 10px; text-decoration: none; }
.hcs-hit:hover { background: var(--accent-tint-2); }
.hcs-hit .hcs-t { display: block; font-size: 13.5px; font-weight: 650; color: var(--text); margin-bottom: 2px; }
.hcs-hit .hcs-cat {
    font-size: 10px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase;
    color: var(--accent-ink); background: var(--accent-tint); border-radius: 5px; padding: 1px 6px; margin-left: 7px;
}
.hcs-hit .hcs-s { display: block; font-size: 12.5px; color: var(--text-muted); line-height: 1.5; }
.hcs-empty { padding: 14px; font-size: 13px; color: var(--text-muted); }

.hc-layout { display: flex; gap: 34px; align-items: flex-start; padding-bottom: 60px; }
.hc-toc {
    position: sticky; top: 18px; width: 216px; flex-shrink: 0;
    max-height: calc(100vh - 110px); overflow-y: auto; padding-right: 6px;
}
.hc-toc-cat {
    font-size: 10.5px; letter-spacing: 0.12em; text-transform: uppercase; font-weight: 700;
    color: var(--text-faint); margin: 16px 0 5px; padding-left: 10px;
}
.hc-toc-cat:first-child { margin-top: 0; }
.hc-toc-link {
    display: block; padding: 5px 10px; border-radius: 8px; font-size: 12.5px; font-weight: 550;
    color: var(--text-2); text-decoration: none; border-left: 2px solid transparent;
}
.hc-toc-link:hover { background: var(--paper-2); color: var(--text); }
.hc-toc-link.active { color: var(--accent-ink); background: var(--accent-tint-2); border-left-color: var(--accent-deep); border-radius: 0 8px 8px 0; }

.hc-main { flex: 1; min-width: 0; }
.hc-cat-head {
    font-family: var(--font-display); font-size: 15px; font-weight: 700; color: var(--text-muted);
    letter-spacing: 0.02em; border-bottom: 1px solid var(--border); padding-bottom: 7px;
    margin: 34px 0 18px; scroll-margin-top: 20px;
}
.hc-cat-head:first-child { margin-top: 0; }
.hc-article {
    background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm); padding: 26px 28px; margin-bottom: 22px; scroll-margin-top: 20px;
}
.hc-article .ha-title { font-size: 26px; }

@media (max-width: 900px) {
    .hc-toc { display: none; }
    .hc-hero-t { font-size: 30px; }
    .hc-article { padding: 20px 18px; }
}
