/* In-app help: header Help menu, side panel, Help Center and topic pages. */

:root {
    --help-accent: #0077b0;
    --help-accent-soft: rgba(0, 151, 214, 0.1);
    --help-border: var(--bs-border-color, #e1e4e8);
}

/* ---------- Header Help menu ---------- */
.help-menu {
    position: relative;
}

.help-menu-btn {
    background: none;
    border: none;
    cursor: pointer;
}

.help-menu-btn.active {
    background: var(--bs-tertiary-bg);
    color: var(--help-accent);
}

.help-menu-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1040;
}

.help-menu-dropdown {
    position: absolute;
    right: 0;
    top: calc(100% + 6px);
    min-width: 260px;
    background: var(--bs-body-bg);
    border: 1px solid var(--help-border);
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    padding: 0.4rem;
    z-index: 1041;
}

.help-menu-item {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    width: 100%;
    padding: 0.55rem 0.7rem;
    border: none;
    background: none;
    border-radius: 6px;
    color: var(--bs-body-color);
    text-decoration: none;
    text-align: left;
    font-size: 0.9rem;
    cursor: pointer;
}

.help-menu-item > .fas {
    width: 1.1rem;
    margin-top: 0.15rem;
    color: var(--help-accent);
    text-align: center;
}

.help-menu-item:hover,
.help-menu-item:focus-visible {
    background: var(--bs-tertiary-bg);
    color: var(--bs-body-color);
}

.help-menu-item-title {
    display: block;
    font-weight: 500;
}

.help-menu-item-hint {
    display: block;
    font-size: 0.78rem;
    color: var(--bs-secondary-color);
}

.help-menu-divider {
    height: 1px;
    margin: 0.3rem 0.4rem;
    background: var(--help-border);
}

/* ---------- Side panel ---------- */

/* The panel is rendered inside the sticky header, whose z-index (100) caps everything in it. While the panel is
   open, lift the header above the other fixed overlays (dark-mode toggle 1000, messaging dock 1030-1032). */
.app-header:has(.help-panel.open) {
    z-index: 1060;
}

.help-panel-backdrop {
    display: none;
}

.help-panel {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 440px;
    max-width: 100vw;
    background: var(--bs-body-bg);
    border-left: 1px solid var(--help-border);
    box-shadow: -6px 0 24px rgba(0, 0, 0, 0.12);
    z-index: 1060;
    display: flex;
    flex-direction: column;
    transform: translateX(105%);
    transition: transform 0.25s ease;
    visibility: hidden;
}

.help-panel.open {
    transform: translateX(0);
    visibility: visible;
}

.help-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--help-border);
}

.help-panel-title {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
}

.help-panel-title .fas {
    color: var(--help-accent);
}

.help-panel-close {
    width: 34px;
    height: 34px;
    border: none;
    border-radius: 6px;
    background: none;
    color: var(--bs-body-color);
    font-size: 1.1rem;
    cursor: pointer;
}

.help-panel-close:hover {
    background: var(--bs-tertiary-bg);
}

.help-panel-search {
    position: relative;
    padding: 0.75rem 1.25rem;
    border-bottom: 1px solid var(--help-border);
}

.help-panel-search .fas,
.help-search-box .fas {
    position: absolute;
    left: 2.05rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--bs-secondary-color);
    pointer-events: none;
}

.help-panel-search input,
.help-search-box input {
    width: 100%;
    padding: 0.55rem 0.9rem 0.55rem 2.3rem;
    border: 1px solid var(--help-border);
    border-radius: 8px;
    background: var(--bs-body-bg);
    color: var(--bs-body-color);
    font-size: 0.9rem;
}

.help-panel-search input:focus,
.help-search-box input:focus {
    outline: none;
    border-color: #0097d6;
    box-shadow: 0 0 0 3px var(--help-accent-soft);
}

.help-panel-body {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 1.25rem 1.5rem;
}

.help-panel-footer {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    border-top: 1px solid var(--help-border);
}

.help-panel-empty {
    color: var(--bs-secondary-color);
    font-size: 0.9rem;
}

.help-panel-back {
    border: none;
    background: none;
    padding: 0;
    margin-bottom: 0.75rem;
    color: var(--help-accent);
    font-size: 0.85rem;
    cursor: pointer;
}

.help-panel-link {
    display: inline-block;
    margin-top: 0.75rem;
    font-size: 0.85rem;
    color: var(--help-accent);
    text-decoration: none;
}

.help-panel-topic-title {
    font-size: 1.2rem;
    font-weight: 600;
    margin: 0.4rem 0 0.25rem;
}

.help-panel-topic-summary {
    color: var(--bs-secondary-color);
    font-size: 0.9rem;
}

.help-category-badge {
    display: inline-block;
    padding: 0.15rem 0.55rem;
    border-radius: 999px;
    background: var(--help-accent-soft);
    color: var(--help-accent);
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    text-decoration: none;
}

/* Search results (panel and Help Center) */
.help-results {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.help-result {
    display: block;
    width: 100%;
    text-align: left;
    padding: 0.7rem 0.85rem;
    border: 1px solid var(--help-border);
    border-radius: 8px;
    background: var(--bs-body-bg);
    color: var(--bs-body-color);
    text-decoration: none;
    cursor: pointer;
}

.help-result:hover {
    border-color: #0097d6;
    color: var(--bs-body-color);
}

.help-result-title {
    display: block;
    font-weight: 600;
    color: var(--help-accent);
}

.help-result-category {
    display: block;
    font-size: 0.75rem;
    color: var(--bs-secondary-color);
    margin-bottom: 0.25rem;
}

.help-result-snippet {
    display: block;
    font-size: 0.85rem;
    color: var(--bs-body-color);
}

.help-results mark,
.help-result mark {
    padding: 0 0.1em;
    background: rgba(255, 196, 0, 0.35);
    color: inherit;
    border-radius: 2px;
}

/* ---------- Rendered topic Markdown ---------- */
.help-article-body {
    font-size: 0.92rem;
    line-height: 1.6;
    overflow-wrap: anywhere;
}

.help-article-body h2 {
    font-size: 1.15rem;
    font-weight: 600;
    margin: 1.5rem 0 0.6rem;
    padding-bottom: 0.3rem;
    border-bottom: 1px solid var(--help-border);
    scroll-margin-top: 80px;
}

.help-article-body h3 {
    font-size: 1rem;
    font-weight: 600;
    margin: 1.2rem 0 0.5rem;
    scroll-margin-top: 80px;
}

.help-article-body ul,
.help-article-body ol {
    padding-left: 1.4rem;
}

.help-article-body li {
    margin-bottom: 0.3rem;
}

.help-article-body a {
    color: var(--help-accent);
}

.help-article-body code {
    padding: 0.1em 0.35em;
    border-radius: 4px;
    background: var(--bs-tertiary-bg);
    color: var(--bs-body-color);
    font-size: 0.85em;
}

.help-article-body blockquote {
    margin: 1rem 0;
    padding: 0.6rem 0.9rem;
    border-left: 4px solid #0097d6;
    border-radius: 0 6px 6px 0;
    background: var(--help-accent-soft);
}

.help-article-body blockquote p:last-child {
    margin-bottom: 0;
}

.help-article-body table {
    width: 100%;
    margin: 1rem 0;
    border-collapse: collapse;
    font-size: 0.88rem;
    display: block;
    overflow-x: auto;
}

.help-article-body th,
.help-article-body td {
    padding: 0.45rem 0.6rem;
    border: 1px solid var(--help-border);
    vertical-align: top;
}

.help-article-body th {
    background: var(--bs-tertiary-bg);
    font-weight: 600;
}

/* ---------- Help Center (/help) ---------- */
.help-center-hero {
    padding: 2rem 1.5rem;
    margin-bottom: 1.75rem;
    border-radius: 14px;
    background: linear-gradient(135deg, rgba(0, 151, 214, 0.12), rgba(0, 119, 176, 0.04));
    border: 1px solid var(--help-border);
    text-align: center;
}

.help-center-hero h1 {
    font-size: 1.8rem;
    font-weight: 700;
    margin-bottom: 0.4rem;
}

.help-center-hero p {
    color: var(--bs-secondary-color);
    margin-bottom: 1.25rem;
}

.help-search-box {
    position: relative;
    max-width: 640px;
    margin: 0 auto;
}

.help-search-box .fas {
    left: 1rem;
}

.help-search-box input {
    padding: 0.8rem 1rem 0.8rem 2.6rem;
    font-size: 1rem;
    border-radius: 10px;
}

.help-quick-links {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 1rem;
    font-size: 0.85rem;
}

.help-quick-links a {
    padding: 0.25rem 0.75rem;
    border-radius: 999px;
    border: 1px solid var(--help-border);
    background: var(--bs-body-bg);
    color: var(--bs-body-color);
    text-decoration: none;
}

.help-quick-links a:hover {
    border-color: #0097d6;
    color: var(--help-accent);
}

.help-category-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
}

.help-category-card {
    padding: 1.1rem 1.2rem;
    border: 1px solid var(--help-border);
    border-radius: 12px;
    background: var(--bs-body-bg);
}

.help-category-card h2 {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-size: 1.02rem;
    font-weight: 600;
    margin: 0 0 0.75rem;
}

.help-category-card h2 a {
    color: var(--bs-body-color);
    text-decoration: none;
}

.help-category-card h2 a:hover {
    color: var(--help-accent);
}

.help-category-icon {
    width: 2rem;
    height: 2rem;
    flex: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    background: var(--help-accent-soft);
    color: var(--help-accent);
    font-size: 0.95rem;
}

.help-category-count {
    margin-left: auto;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--bs-secondary-color);
}

.help-topic-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.help-topic-list li {
    padding: 0.2rem 0;
}

.help-topic-list a {
    color: var(--bs-body-color);
    text-decoration: none;
    font-size: 0.9rem;
}

.help-topic-list a:hover {
    color: var(--help-accent);
    text-decoration: underline;
}

.help-topic-list .help-topic-summary {
    display: block;
    font-size: 0.8rem;
    color: var(--bs-secondary-color);
}

.help-show-more {
    border: none;
    background: none;
    padding: 0.35rem 0 0;
    color: var(--help-accent);
    font-size: 0.85rem;
    cursor: pointer;
}

.help-section-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin: 0 0 1rem;
}

.help-results-meta {
    color: var(--bs-secondary-color);
    font-size: 0.9rem;
    margin-bottom: 0.75rem;
}

/* ---------- Topic page (/help/topics/{slug}) ---------- */
.help-topic-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 280px;
    gap: 2rem;
    align-items: start;
}

.help-topic-main {
    padding: 1.75rem 2rem;
    border: 1px solid var(--help-border);
    border-radius: 12px;
    background: var(--bs-body-bg);
}

.help-topic-main h1 {
    font-size: 1.7rem;
    font-weight: 700;
    margin: 0.5rem 0 0.4rem;
}

.help-topic-main .help-topic-lead {
    color: var(--bs-secondary-color);
    font-size: 1.02rem;
}

.help-topic-main .help-article-body {
    font-size: 0.97rem;
}

.help-topic-aside {
    position: sticky;
    top: 90px;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.help-aside-card {
    padding: 1rem 1.1rem;
    border: 1px solid var(--help-border);
    border-radius: 12px;
    background: var(--bs-body-bg);
}

.help-aside-card h2 {
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--bs-secondary-color);
    margin: 0 0 0.6rem;
}

.help-aside-card ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

.help-aside-card li {
    padding: 0.2rem 0;
    font-size: 0.88rem;
}

.help-aside-card li.sub {
    padding-left: 0.85rem;
    font-size: 0.83rem;
}

.help-aside-card a {
    color: var(--bs-body-color);
    text-decoration: none;
}

.help-aside-card a:hover,
.help-aside-card li.current a {
    color: var(--help-accent);
}

.help-aside-card li.current a {
    font-weight: 600;
}

.help-breadcrumb {
    font-size: 0.85rem;
    margin-bottom: 1rem;
}

.help-breadcrumb a {
    color: var(--help-accent);
    text-decoration: none;
}

.help-breadcrumb .sep {
    margin: 0 0.4rem;
    color: var(--bs-secondary-color);
}

.help-topic-search {
    max-width: none;
    margin: 0 0 1.25rem;
}

@media (max-width: 992px) {
    .help-topic-layout {
        grid-template-columns: minmax(0, 1fr);
    }

    .help-topic-aside {
        position: static;
    }

    .help-topic-main {
        padding: 1.25rem;
    }
}

@media (max-width: 576px) {
    /* Anchored to the button the menu would run off the left edge of a phone screen; pin it inside the screen. */
    .help-menu-dropdown {
        position: fixed;
        top: 60px;
        left: 0.75rem;
        right: 0.75rem;
        min-width: 0;
    }

    .help-panel-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.4);
        z-index: 1059;
    }

    .help-panel {
        width: 100vw;
    }

    .help-center-hero {
        padding: 1.5rem 1rem;
    }

    .help-center-hero h1 {
        font-size: 1.45rem;
    }
}
