/*
 * In-app user manual — the "workshop service manual". A two-column reading experience (contents rail
 * + reading column) that lives inside the authenticated app shell and reuses the brand tokens from
 * app.css (ink / hi-vis / paper, Bebas display, Archivo body, mono micro-labels). The one bold move is
 * the manual metaphor: chapters carry a mono section code + number, and screenshots read as captioned
 * "plates". Everything else stays quiet — hairlines, generous measure, calm rhythm.
 *
 * Light + dark both handled: structural rules use the shared --bs-* tokens; a dark block at the end
 * re-tones the surfaces using the same --surface* vars the rest of the app uses.
 */

/* Give the manual room to breathe — wider than the default centred column, and no outer padding so the
   rail can sit flush. (Overrides .app__main's 1200px/2.25rem.) */
.app__main.help-shell {
    max-width: 1400px;
    padding: 1.5rem;
}

.help {
    --help-rail-w: 15rem;
    --help-measure: 68ch;
    display: grid;
    grid-template-columns: var(--help-rail-w) minmax(0, 1fr);
    gap: 2rem;
    align-items: start;
}

/* ---- Contents rail ---------------------------------------------------------------------------- */

.help-rail {
    position: sticky;
    top: 1.5rem;
    align-self: start;
    max-height: calc(100vh - 3rem);
    overflow-y: auto;
    background: var(--bs-paper);
    border: 1px solid var(--bs-line);
    border-radius: 14px;
    padding: 0.5rem;
}

.help-rail__home {
    display: block;
    text-decoration: none;
    padding: 0.7rem 0.75rem;
    border-radius: 10px;
    color: var(--bs-text);
}
.help-rail__home:hover { background: rgba(0, 0, 0, 0.03); }
.help-rail__home.is-active { background: var(--bs-ink); }
.help-rail__home.is-active .eyebrow,
.help-rail__home.is-active .help-rail__hometitle { color: #fff; }
.help-rail__hometitle {
    display: block;
    font-family: var(--bs-font-display);
    font-size: 1.5rem;
    line-height: 1;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    margin-top: 0.2rem;
}

.help-rail__search { padding: 0.5rem 0.5rem 0.75rem; }
.help-rail__input {
    width: 100%;
    font-family: var(--bs-font-ui);
    font-size: 0.85rem;
    padding: 0.5rem 0.7rem;
    border: 1.5px solid var(--bs-line);
    border-radius: 9px;
    background: #fff;
    color: var(--bs-text);
}
.help-rail__input:focus-visible {
    outline: 2px solid var(--bs-hi-vis);
    outline-offset: 1px;
    border-color: transparent;
}

.help-rail__chapter { padding: 0.4rem 0.5rem 0.7rem; }
.help-rail__chaptertitle {
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    color: var(--bs-text);
    margin: 0 0 0.4rem;
}
.help-rail__topics { list-style: none; margin: 0; padding: 0; }
.help-rail__topics a {
    display: block;
    padding: 0.32rem 0.6rem;
    border-radius: 8px;
    font-size: 0.9rem;
    line-height: 1.3;
    color: var(--bs-muted);
    text-decoration: none;
    border-inline-start: 2px solid transparent;
}
.help-rail__topics a:hover { color: var(--bs-text); background: rgba(0, 0, 0, 0.03); }
.help-rail__topics a.is-active {
    color: var(--bs-text);
    font-weight: 600;
    border-inline-start-color: var(--bs-hi-vis);
    background: rgba(0, 222, 145, 0.08);
}
.help-rail__empty {
    padding: 0.75rem;
    font-size: 0.85rem;
    color: var(--bs-muted);
}

/* Mobile-only "Contents" toggle. */
.help-railtoggle {
    display: none;
    font-family: var(--bs-font-mono);
    font-size: 0.7rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    padding: 0.6rem 0.9rem;
    border: 1.5px solid var(--bs-line);
    border-radius: 9px;
    background: var(--bs-paper);
    color: var(--bs-text);
    cursor: pointer;
}

/* ---- Contents index (landing) ---------------------------------------------------------------- */

.help-lede { margin-bottom: 1.75rem; }
.help-lede__text {
    max-width: 60ch;
    color: var(--bs-muted);
    font-size: 1.02rem;
    line-height: 1.6;
    margin: 0;
}

.help-contents {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
    gap: 1rem;
}

.help-card {
    position: relative;
    background: var(--bs-paper);
    border: 1px solid var(--bs-line);
    border-radius: 14px;
    padding: 1.1rem 1.2rem 1.2rem;
    overflow: hidden;
    transition: border-color 0.15s ease, transform 0.15s ease;
}
/* The binder-tab spine — the signature detail. */
.help-card::before {
    content: "";
    position: absolute;
    inset-block: 0;
    inset-inline-start: 0;
    width: 4px;
    background: var(--bs-hi-vis);
    opacity: 0.5;
    transition: opacity 0.15s ease;
}
.help-card:hover { border-color: var(--bs-ink); transform: translateY(-2px); }
.help-card:hover::before { opacity: 1; }
.help-card__title {
    font-family: var(--bs-font-display);
    font-size: 1.6rem;
    line-height: 1.02;
    letter-spacing: 0.01em;
    text-transform: uppercase;
    color: var(--bs-ink);
    margin: 0 0 0.7rem;
}
.help-card__topics { list-style: none; margin: 0; padding: 0; }
.help-card__topics li { border-top: 1px solid var(--bs-line); }
.help-card__topics li:first-child { border-top: none; }
.help-card__topics a {
    display: block;
    padding: 0.4rem 0;
    font-size: 0.9rem;
    color: var(--bs-text);
    text-decoration: none;
}
.help-card__topics a:hover { color: var(--bs-hi-vis-press); }

/* ---- Topic page ------------------------------------------------------------------------------ */

.help-crumbs {
    font-family: var(--bs-font-mono);
    font-size: 0.68rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--bs-muted);
    margin-bottom: 0.75rem;
}
.help-crumbs a { color: var(--bs-muted); text-decoration: none; }
.help-crumbs a:hover { color: var(--bs-text); }
.help-crumbs__sep { margin: 0 0.5rem; }
.help-crumbs__here { color: var(--bs-text); }

.help-topic__head { margin-bottom: 1.5rem; }

.help-topic__cols {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 12rem;
    gap: 2.5rem;
    align-items: start;
}

.help-topic__body { max-width: var(--help-measure); }

/* Reading typography — the calm part. */
.help-topic__body h2 {
    font-size: 1.28rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    margin: 2.2rem 0 0.6rem;
    padding-top: 0.4rem;
    scroll-margin-top: 1.5rem;
}
.help-topic__body h2:first-child { margin-top: 0; }
.help-topic__body h3 {
    font-size: 1.02rem;
    font-weight: 700;
    margin: 1.5rem 0 0.4rem;
    scroll-margin-top: 1.5rem;
}
.help-topic__body p { line-height: 1.68; margin: 0 0 1rem; color: var(--bs-text); }
.help-topic__body ul,
.help-topic__body ol { line-height: 1.6; margin: 0 0 1.1rem; padding-inline-start: 1.3rem; }
.help-topic__body li { margin-bottom: 0.4rem; }
.help-topic__body li::marker { color: var(--bs-muted); }
.help-topic__body a { color: var(--bs-hi-vis-press); text-underline-offset: 2px; }
.help-topic__body strong { font-weight: 700; }
.help-topic__body code {
    font-family: var(--bs-font-mono);
    font-size: 0.86em;
    background: rgba(0, 0, 0, 0.05);
    padding: 0.1em 0.36em;
    border-radius: 5px;
    color: var(--bs-text);
}

/* Numbered procedure — the "do this, then this" spine of most guides. */
.help-topic__body ol.help-steps { counter-reset: step; list-style: none; padding-inline-start: 0; }
.help-topic__body ol.help-steps > li {
    position: relative;
    counter-increment: step;
    padding-inline-start: 2.6rem;
    margin-bottom: 0.9rem;
    min-height: 1.9rem;
}
.help-topic__body ol.help-steps > li::before {
    content: counter(step, decimal-leading-zero);
    position: absolute;
    inset-inline-start: 0;
    top: -0.05rem;
    font-family: var(--bs-font-mono);
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--bs-ink);
    background: var(--bs-hi-vis);
    width: 1.9rem;
    height: 1.9rem;
    display: grid;
    place-items: center;
    border-radius: 8px;
}

/* Aside callout — a note or a heads-up, in the interface's own voice. */
.help-topic__body .help-note {
    border-inline-start: 3px solid var(--bs-hi-vis);
    background: rgba(0, 222, 145, 0.07);
    padding: 0.8rem 1rem;
    border-radius: 0 10px 10px 0;
    margin: 0 0 1.2rem;
    font-size: 0.95rem;
    line-height: 1.55;
}
.help-topic__body .help-note--warn {
    border-inline-start-color: var(--due-amber);
    background: rgba(154, 103, 0, 0.08);
}
.help-topic__body .help-note p:last-child { margin-bottom: 0; }
.help-topic__body .help-note__label {
    display: block;
    font-family: var(--bs-font-mono);
    font-size: 0.64rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--bs-muted);
    margin-bottom: 0.25rem;
}

/* Screenshot "plate" — a framed figure with a mono caption, like a manual's numbered illustration. */
.help-topic__body .help-plate { margin: 1.4rem 0; }
.help-topic__body .help-plate img {
    display: block;
    width: 100%;
    height: auto;
    border: 1px solid var(--bs-line);
    border-radius: 10px;
    box-shadow: 0 1px 3px rgba(16, 24, 40, 0.08);
}
.help-topic__body .help-plate figcaption {
    font-family: var(--bs-font-mono);
    font-size: 0.66rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--bs-muted);
    margin-top: 0.5rem;
}

/* On this page — sticky mini-TOC. */
.help-onthispage { position: sticky; top: 1.5rem; }
.help-onthispage__label {
    font-family: var(--bs-font-mono);
    font-size: 0.62rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--bs-muted);
    margin: 0 0 0.6rem;
}
.help-onthispage__list { list-style: none; margin: 0; padding: 0; border-inline-start: 1px solid var(--bs-line); }
.help-onthispage__list a {
    display: block;
    padding: 0.28rem 0 0.28rem 0.8rem;
    margin-inline-start: -1px;
    border-inline-start: 2px solid transparent;
    font-size: 0.82rem;
    line-height: 1.35;
    color: var(--bs-muted);
    text-decoration: none;
}
.help-onthispage__list a.is-sub { padding-inline-start: 1.5rem; font-size: 0.78rem; }
.help-onthispage__list a:hover { color: var(--bs-text); }
.help-onthispage__list a.is-active {
    color: var(--bs-text);
    border-inline-start-color: var(--bs-hi-vis);
    font-weight: 600;
}

/* Prev / next pager — "turn the page". */
.help-pager {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-top: 2.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--bs-line);
    max-width: var(--help-measure);
}
.help-pager__link {
    display: block;
    padding: 0.9rem 1.1rem;
    border: 1px solid var(--bs-line);
    border-radius: 12px;
    text-decoration: none;
    transition: border-color 0.15s ease;
}
.help-pager__link:hover { border-color: var(--bs-ink); }
.help-pager__next { text-align: end; }
.help-pager__dir {
    display: block;
    font-family: var(--bs-font-mono);
    font-size: 0.62rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--bs-muted);
    margin-bottom: 0.2rem;
}
.help-pager__title { font-size: 0.95rem; color: var(--bs-text); }

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

@media (max-width: 1080px) {
    .help-topic__cols { grid-template-columns: minmax(0, 1fr); }
    .help-onthispage { display: none; }
}

@media (max-width: 860px) {
    .help { grid-template-columns: minmax(0, 1fr); gap: 1rem; }
    .help-railtoggle { display: inline-block; }
    .help-rail {
        position: static;
        max-height: none;
        display: none;
    }
    .help-rail.is-open { display: block; }
}

/* ---- Dark mode -------------------------------------------------------------------------------- */

[data-bs-theme="dark"] .help-rail,
[data-bs-theme="dark"] .help-card,
[data-bs-theme="dark"] .help-railtoggle { background: var(--surface); }
[data-bs-theme="dark"] .help-rail__input { background: var(--surface-3); }
[data-bs-theme="dark"] .help-rail__home:hover,
[data-bs-theme="dark"] .help-rail__topics a:hover { background: rgba(255, 255, 255, 0.05); }
[data-bs-theme="dark"] .help-card__title { color: var(--heading); }
[data-bs-theme="dark"] .help-topic__body code { background: rgba(255, 255, 255, 0.08); }
[data-bs-theme="dark"] .help-topic__body ol.help-steps > li::before { color: var(--bs-ink-2); }

@media (prefers-reduced-motion: reduce) {
    .help-card,
    .help-card::before,
    .help-pager__link { transition: none; }
    .help-card:hover { transform: none; }
}
