/* ---------------------------------------------------------------------------
   The Help Center (Pages/Help): the help home, the search, and the guide reader.

   Sober on purpose - it is documentation inside a back-office tool. Flat white
   surfaces, thin lines, the accent only for links, selection and the current
   place. Colours come from the portal kit tokens (--app-*, portal.css), which
   take the accent from the MudBlazor palette, so the help takes on each
   organization's theme; the fallbacks keep it readable without portal.css.
   --------------------------------------------------------------------------- */

:root {
    --help-accent: var(--app-accent, var(--mud-palette-primary));
    --help-accent-soft: var(--app-accent-soft, color-mix(in srgb, var(--mud-palette-primary) 10%, #fff));
    --help-accent-border: var(--app-accent-border, color-mix(in srgb, var(--mud-palette-primary) 28%, #fff));
    --help-ink: var(--app-ink, #292929);
    --help-ink-muted: var(--app-ink-muted, #787878);
    --help-surface: var(--app-surface, #FFFFFF);
    --help-surface-alt: var(--app-surface-alt, #F8F8F8);
    --help-surface-sunk: var(--app-surface-sunk, #F3F3F3);
    --help-line: var(--app-line, #E4E4E4);
    --help-line-strong: var(--app-line-strong, #D9D9D9);
    --help-good: var(--app-good, #1B7F4B);
    --help-good-soft: var(--app-good-soft, #E8F6EE);
    --help-radius-pill: var(--app-radius-pill, 999px);
    --help-shadow: var(--app-shadow-card, 0 1px 2px rgba(17, 17, 17, .05), 0 8px 24px rgba(17, 17, 17, .05));
    --help-font: var(--app-font, var(--mud-typography-default-family, system-ui, sans-serif));
    --help-font-figures: var(--app-font-figures, var(--help-font));

    /* The header bar sticks to the top of the window; whatever sticks or is jumped to sits below it.
       MainLayout measures it into --app-header-height. */
    --help-header: var(--app-header-height, 57px);
}

.help-page {
    max-width: 1100px;
    padding: 8px 4px 32px;
}

.help-title {
    margin: 4px 0 6px;
    font-size: 1.6rem;
    font-weight: 600;
    color: var(--help-ink);
}

.help-sub {
    margin: 0 0 16px;
    color: var(--help-ink-muted);
}

.help-empty {
    color: var(--help-ink-muted);
}

/* --- the help home ------------------------------------------------------- */

.help-hero {
    background: var(--help-surface-alt);
    border: 1px solid var(--help-line);
    border-radius: 10px;
    padding: 22px 24px 18px;
    margin-bottom: 18px;
}

.help-hero-title {
    font-family: var(--help-font);
    font-weight: 700;
    font-size: 24px;
    line-height: 1.2;
    margin: 0 0 4px;
    color: var(--help-ink);
}

.help-hero-sub {
    margin: 0 0 14px;
    color: var(--help-ink-muted);
    font-size: 14px;
    max-width: 70ch;
}

.help-popular {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    margin-top: 10px;
    font-size: 12px;
}

.help-popular-label {
    color: var(--help-ink-muted);
    margin-right: 2px;
}

.help-chip {
    padding: 2px 10px;
    border: 1px solid var(--help-line-strong);
    border-radius: var(--help-radius-pill);
    background: var(--help-surface);
    color: var(--help-ink);
    text-decoration: none;
    line-height: 20px;
}

.help-chip:hover,
.help-chip:focus-visible {
    border-color: var(--help-accent-border);
    color: var(--help-accent);
}

.help-eyebrow {
    display: block;
    font-family: var(--help-font-figures);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--help-accent);
    margin-bottom: 4px;
}

.help-yours {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 14px 18px;
    margin-bottom: 18px;
    border: 1px solid var(--help-accent-border);
    border-left: 3px solid var(--help-accent);
    border-radius: 8px;
    background: var(--help-surface);
    color: inherit;
    text-decoration: none;
}

.help-yours:hover,
.help-yours:focus-visible {
    background: var(--help-accent-soft);
}

.help-yours-icon {
    flex: 0 0 auto;
    width: 40px;
    height: 40px;
    border-radius: 6px;
    background: var(--help-accent-soft);
    color: var(--help-accent);
    display: flex;
    align-items: center;
    justify-content: center;
}

.help-yours-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
    flex: 1 1 auto;
}

.help-yours-title {
    font-weight: 600;
    font-size: 16px;
}

.help-yours-summary {
    font-size: 13px;
    color: var(--help-ink-muted);
}

.help-yours-go {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: var(--help-accent);
    font-weight: 600;
    font-size: 13px;
    white-space: nowrap;
}

.help-columns {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 320px;
    gap: 24px;
    align-items: start;
}

@media (max-width: 1100px) {
    .help-columns {
        grid-template-columns: minmax(0, 1fr);
    }
}

.help-group {
    margin-bottom: 20px;
}

.help-group-title {
    font-family: var(--help-font-figures);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--help-ink-muted);
    margin: 0 0 8px;
}

.help-list {
    border: 1px solid var(--help-line);
    border-radius: 8px;
    background: var(--help-surface);
    overflow: hidden;
}

.help-row {
    display: grid;
    grid-template-columns: 32px minmax(0, 1fr) auto;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    color: inherit;
    text-decoration: none;
    border-top: 1px solid var(--help-line);
}

.help-row:first-child {
    border-top: 0;
}

.help-row:hover,
.help-row:focus-visible {
    background: var(--help-accent-soft);
}

.help-row-icon {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    background: var(--help-surface-sunk);
    color: var(--help-accent);
    display: flex;
    align-items: center;
    justify-content: center;
}

.help-row-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.help-row-title {
    font-weight: 600;
    font-size: 14px;
    color: var(--help-ink);
}

.help-row:hover .help-row-title {
    color: var(--help-accent);
}

.help-row-summary {
    font-size: 12.5px;
    color: var(--help-ink-muted);
    line-height: 1.45;
}

.help-row-context,
.help-row-audience {
    font-size: 11.5px;
    color: var(--help-ink-muted);
}

.help-row-audience {
    white-space: nowrap;
}

.help-row-summary mark {
    padding: 0 1px;
    border-radius: 2px;
    background: color-mix(in srgb, var(--mud-palette-warning) 30%, transparent);
    color: inherit;
}

@media (max-width: 760px) {
    .help-row {
        grid-template-columns: 32px minmax(0, 1fr);
    }

    .help-row-audience {
        display: none;
    }
}

.help-side-card {
    border: 1px solid var(--help-line);
    border-radius: 8px;
    background: var(--help-surface);
    padding: 14px 16px;
    margin-bottom: 14px;
    font-size: 13px;
    color: var(--help-ink);
}

.help-side-card p {
    margin: 0 0 8px;
    line-height: 1.5;
}

.help-side-more {
    color: var(--help-accent);
    font-weight: 600;
    text-decoration: none;
}

.help-side-more:hover {
    text-decoration: underline;
}

.help-flow {
    margin-top: 8px;
}

/* --- the search ---------------------------------------------------------- */

.help-search {
    position: relative;
}

.help-search-box {
    position: relative;
    display: flex;
    align-items: center;
    background: var(--help-surface);
    border: 1px solid var(--help-line-strong);
    border-radius: 6px;
    transition: border-color .12s ease, box-shadow .12s ease;
}

.help-search-box:focus-within {
    border-color: var(--help-accent);
    box-shadow: 0 0 0 3px var(--help-accent-soft);
}

.help-search-icon {
    position: absolute;
    left: 12px;
    color: var(--help-ink-muted);
    pointer-events: none;
}

.help-search-input {
    flex: 1 1 auto;
    min-width: 0;
    border: 0;
    outline: 0;
    background: transparent;
    font: inherit;
    font-size: 15px;
    color: var(--help-ink);
    padding: 11px 12px 11px 42px;
}

.help-search.is-dropdown .help-search-input {
    font-size: 13px;
    padding: 7px 10px 7px 38px;
}

.help-search.is-dropdown .help-search-icon {
    left: 10px;
    font-size: 20px;
}

.help-search-input::-webkit-search-cancel-button {
    display: none;
}

.help-search-clear {
    border: 0;
    background: none;
    color: var(--help-ink-muted);
    cursor: pointer;
    padding: 4px 10px;
    display: flex;
    align-items: center;
}

.help-search-clear:hover {
    color: var(--help-ink);
}

.guide-body kbd,
.help-search-kbd {
    font-family: var(--help-font-figures);
    font-size: 11px;
    font-weight: 600;
    color: var(--help-ink-muted);
    background: var(--help-surface-sunk);
    border: 1px solid var(--help-line-strong);
    border-bottom-width: 2px;
    border-radius: 4px;
    padding: 0 6px;
    line-height: 18px;
}

.help-search-kbd {
    margin-right: 10px;
}

.help-results {
    margin-top: 12px;
}

/* Beside a guide the results drop down over the page, while the search has focus. */
.help-search.is-dropdown .help-results {
    display: none;
    position: absolute;
    z-index: 30;
    top: calc(100% + 4px);
    left: 0;
    width: min(560px, 80vw);
    max-height: 70vh;
    overflow-y: auto;
    margin: 0;
    background: var(--help-surface);
    border: 1px solid var(--help-line-strong);
    border-radius: 8px;
    box-shadow: var(--help-shadow);
    padding: 4px;
}

.help-search.is-dropdown:focus-within .help-results {
    display: block;
}

.help-results-count {
    font-size: 12px;
    color: var(--help-ink);
    font-weight: 600;
    margin: 0 0 6px 2px;
}

.help-results-count span {
    font-weight: 400;
    color: var(--help-ink-muted);
}

.help-search.is-inline .help-results {
    background: var(--help-surface);
    border: 1px solid var(--help-line);
    border-radius: 8px;
    padding: 10px 6px 6px;
}

.help-search.is-inline .help-results-count {
    margin-left: 10px;
}

.help-hit {
    display: flex;
    gap: 12px;
    padding: 9px 10px;
    border-radius: 6px;
    color: inherit;
    text-decoration: none;
}

.help-hit.is-active,
.help-hit:hover,
.help-hit:focus-visible {
    background: var(--help-accent-soft);
    outline: 0;
}

.help-hit-icon {
    flex: 0 0 auto;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--help-surface-sunk);
    color: var(--help-accent);
}

.help-hit-icon.is-screen {
    background: var(--help-good-soft);
    color: var(--help-good);
}

.help-hit-main {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.help-hit-head {
    display: flex;
    align-items: baseline;
    gap: 8px;
}

.help-hit-title {
    font-weight: 600;
    font-size: 14px;
    color: var(--help-ink);
}

.help-hit-kind {
    font-family: var(--help-font-figures);
    font-size: 10px;
    font-weight: 600;
    letter-spacing: .05em;
    text-transform: uppercase;
    color: var(--help-ink-muted);
    white-space: nowrap;
}

.help-hit-context {
    font-size: 12px;
    color: var(--help-ink-muted);
}

.help-hit-snippet {
    font-size: 12.5px;
    line-height: 1.45;
    color: var(--help-ink);
    margin-top: 2px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.help-hit-snippet mark,
.help-mark {
    background: #FFF1B8;
    color: inherit;
    border-radius: 2px;
    padding: 0 1px;
}

.help-results-empty {
    padding: 14px 12px;
    font-size: 13px;
    color: var(--help-ink-muted);
}

.help-results-empty-title {
    color: var(--help-ink);
    font-weight: 600;
    margin-bottom: 4px;
}

.help-results-all {
    display: block;
    padding: 8px 10px;
    border-top: 1px solid var(--help-line);
    margin-top: 4px;
    font-size: 13px;
    font-weight: 600;
    color: var(--help-accent);
    text-decoration: none;
}

/* --- the guide reader ------------------------------------------------------ */

/* Three columns: the guides, the guide, and "On this page". Wider than the help home. */
.help-page.help-doc-page {
    max-width: none;
}

.help-doc {
    display: grid;
    grid-template-columns: 250px minmax(0, 880px) 220px;
    justify-content: start;
    gap: 40px;
    align-items: start;
}

@media (max-width: 1400px) {
    .help-doc {
        grid-template-columns: 240px minmax(0, 880px);
    }

    .help-toc {
        display: none;
    }
}

@media (max-width: 900px) {
    .help-doc {
        grid-template-columns: minmax(0, 1fr);
    }

    .help-nav {
        position: static !important;
        max-height: none !important;
    }

    .help-nav-groups {
        display: none;
    }
}

.help-nav,
.help-toc {
    position: sticky;
    top: calc(var(--help-header) + 12px);
    max-height: calc(100vh - var(--help-header) - 24px);
    overflow-y: auto;
}

/* Room for the search results to drop down over the page rather than be clipped by the scrolling column. */
.help-nav:focus-within {
    overflow: visible;
}

.help-nav-groups {
    margin-top: 14px;
}

.help-nav-group {
    margin-bottom: 14px;
}

.help-nav-title {
    font-family: var(--help-font-figures);
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--help-ink-muted);
    margin: 0 0 4px 8px;
}

.help-nav-link {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 8px;
    border-radius: 5px;
    font-size: 13px;
    color: var(--help-ink);
    text-decoration: none;
    line-height: 1.3;
}

.help-nav-link .mud-icon-root {
    color: var(--help-ink-muted);
    font-size: 18px;
}

.help-nav-link:hover {
    background: var(--help-surface-sunk);
}

.help-nav-link.is-current {
    background: var(--help-accent-soft);
    color: var(--help-accent);
    font-weight: 600;
}

.help-nav-link.is-current .mud-icon-root {
    color: var(--help-accent);
}

.help-doc-main {
    min-width: 0;
}

.help-doc-head {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    padding-bottom: 14px;
    margin-bottom: 18px;
    border-bottom: 1px solid var(--help-line);
}

.help-doc-head > div:first-child {
    flex: 1 1 auto;
    min-width: 0;
}

.help-doc-title {
    font-family: var(--help-font);
    font-weight: 700;
    font-size: 26px;
    line-height: 1.2;
    margin: 0 0 6px;
    color: var(--help-ink);
}

.help-doc-summary {
    margin: 0;
    font-size: 15px;
    color: var(--help-ink-muted);
    max-width: 70ch;
}

.help-doc-actions {
    display: flex;
    gap: 6px;
    flex: 0 0 auto;
}

.help-doc-main .guide-figure {
    margin-bottom: 22px;
}

.help-toc {
    font-size: 12.5px;
    border-left: 1px solid var(--help-line);
    padding-left: 12px;
}

.help-toc .help-nav-title {
    margin-left: 0;
    margin-bottom: 6px;
}

.help-toc-link {
    display: block;
    padding: 4px 0 4px 10px;
    margin-left: -13px;
    border-left: 2px solid transparent;
    color: var(--help-ink-muted);
    text-decoration: none;
    line-height: 1.35;
}

.help-toc-link:hover {
    color: var(--help-accent);
}

.help-toc-link.is-active {
    color: var(--help-accent);
    border-left-color: var(--help-accent);
    font-weight: 600;
}

.help-pager {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
    margin: 36px 0 12px;
    padding-top: 18px;
    border-top: 1px solid var(--help-line);
}

.help-pager-link {
    display: flex;
    flex-direction: column;
    padding: 10px 14px;
    border: 1px solid var(--help-line);
    border-radius: 8px;
    color: var(--help-ink);
    text-decoration: none;
}

.help-pager-link:hover,
.help-pager-link:focus-visible {
    border-color: var(--help-accent-border);
    color: var(--help-accent);
}

.help-pager-link small {
    font-size: 11px;
    color: var(--help-ink-muted);
    text-transform: uppercase;
    letter-spacing: .06em;
}

.help-pager-link span {
    font-weight: 600;
}

.help-pager-link.is-next {
    text-align: right;
    grid-column: 2;
}

/* A page with no "On this page" column - an illustrated overview - gives the room to its drawings. */
.help-doc.help-doc-wide {
    grid-template-columns: 250px minmax(0, 1240px);
}

@media (max-width: 1400px) {
    .help-doc.help-doc-wide {
        grid-template-columns: 240px minmax(0, 1fr);
    }
}

@media (max-width: 900px) {
    .help-doc.help-doc-wide {
        grid-template-columns: minmax(0, 1fr);
    }
}

/* --- the guide's text ------------------------------------------------------ */

.guide-body {
    line-height: 1.6;
    color: var(--help-ink);
}

.guide-body h2 {
    margin: 28px 0 8px;
    font-size: 1.25rem;
    font-weight: 600;
    scroll-margin-top: calc(var(--help-header) + 16px);
}

.guide-body h3 {
    margin: 20px 0 6px;
    font-size: 1.05rem;
    font-weight: 600;
    scroll-margin-top: calc(var(--help-header) + 16px);
}

.guide-body p,
.guide-body ul,
.guide-body ol {
    margin: 0 0 12px;
}

.guide-body ul,
.guide-body ol {
    padding-left: 22px;
}

.guide-body ul {
    list-style: disc;
}

.guide-body ol {
    list-style: decimal;
}

.guide-body a {
    color: var(--help-accent);
}

.guide-body code {
    padding: 1px 4px;
    border-radius: 3px;
    background: var(--mud-palette-background-gray);
    font-size: 0.875em;
}

.guide-body kbd {
    color: var(--help-ink);
}

.guide-note {
    margin: 0 0 12px;
    padding: 8px 14px;
    border-left: 3px solid var(--help-accent);
    background: color-mix(in srgb, var(--help-accent) 6%, transparent);
}

.help-scroll-x {
    overflow-x: auto;
    margin: 0 0 12px;
}

.help-table {
    border-collapse: collapse;
    min-width: 50%;
}

.help-table th,
.help-table td {
    padding: 6px 12px;
    border-bottom: 1px solid var(--help-line);
    text-align: left;
    vertical-align: top;
}

.help-table th {
    font-weight: 600;
    background: var(--mud-palette-background-gray);
}

/* --- printing a guide: the guide alone ------------------------------------ */

@media print {
    .left-menu-drawer,
    .top-header,
    .sm-crumbs,
    .help-nav,
    .help-toc,
    .help-pager,
    .help-doc-actions,
    .tour-trigger {
        display: none !important;
    }

    .help-doc {
        display: block;
    }

    .guide-body h2 {
        break-after: avoid;
    }

    .guide-body table,
    .guide-body .guide-note,
    .guide-figure {
        break-inside: avoid;
    }
}

/* --- the guide reader follows the room the page actually has ------------------------------------------------
   The window-width rules above ignore the left menu: opened, it takes 300px and the three columns no longer fit.
   The page is a container, so the columns give way to the width the guide is really given. */
.help-page.help-doc-page {
    container-type: inline-size;
    container-name: helpdoc;
}

@container helpdoc (max-width: 1240px) {
    .help-doc,
    .help-doc.help-doc-wide {
        grid-template-columns: 220px minmax(0, 1fr);
        gap: 28px;
    }

    .help-toc {
        display: none;
    }
}

@container helpdoc (max-width: 760px) {
    .help-doc,
    .help-doc.help-doc-wide {
        grid-template-columns: minmax(0, 1fr);
        gap: 16px;
    }

    .help-nav {
        position: static !important;
        max-height: none !important;
    }

    .help-doc-head {
        flex-wrap: wrap;
    }
}
