/* Shared authored Markdown presentation for site, embed, and print surfaces. */

/* Native disclosures retain their browser keyboard and accessibility behavior. */
.qm-markdown-content details {
    margin-block: 0.75rem;
    padding: 0.75rem 1rem;
    border: 1px solid currentColor;
    border-radius: 0.375rem;
}
.qm-markdown-content details > summary {
    cursor: pointer;
    font-weight: 600;
    list-style-type: disclosure-closed;
}
.qm-markdown-content details[open] > summary {
    margin-block-end: 0.75rem;
    list-style-type: disclosure-open;
}
.qm-markdown-content details > summary:focus-visible {
    outline: 2px solid currentColor;
    outline-offset: 3px;
    border-radius: 0.125rem;
}

/* Paper has no interactive disclosure state. The print lifecycle hook temporarily opens every
   disclosure; these print-only rules remove the now-misleading interactive marker. */
@media print {
    .qm-markdown-content details > summary {
        cursor: default;
        list-style-type: none;
    }

    .qm-markdown-content details > summary::-webkit-details-marker {
        display: none;
    }
}

/* Rendered bodies are often flex items sharing a row with a badge or actions. A flex item's
   automatic minimum size is its content's, so one long source line would keep the item as wide as
   that line and push the row out of the card instead of scrolling inside the block (issue #1532).
   Harmless everywhere else: min-width is already 0 for an ordinary block box. */
.qm-markdown-content {
    min-width: 0;
    /* Issue #1633: authored prose must move a whole word to the next line rather than splitting it
       at the card edge. Keep natural language-aware breaking (`normal`, rather than `keep-all`,
       which would prevent normal CJK wrapping), disable emergency mid-word breaks, and do not let
       browser hyphenation turn one authored word into two visual fragments. Code blocks retain
       their dedicated horizontal scrolling rule below. */
    word-break: normal;
    overflow-wrap: normal;
    hyphens: none;
}
.qm-markdown-content pre {
    margin: 0.75rem 0;
    border: 1px solid var(--qm-code-border, #30363d);
    border-radius: 0.375rem;
    background: var(--qm-code-background, #0d1117);
    /* The foreground belongs on the <pre> itself, not only on a <code> child: a code block that
       reaches a page as a bare <pre> would otherwise keep this dark background while inheriting the
       page's dark body colour, leaving the code unreadable (issue #1415). Token-driven so the print
       surface keeps overriding it to dark-on-light. */
    color: var(--qm-code-foreground, #f0f6fc);
    overflow-x: auto;
}
.qm-markdown-content pre code {
    display: block;
    padding: var(--qm-code-padding, 1rem);
    color: var(--qm-code-foreground, #f0f6fc);
    background: transparent;
    white-space: pre;
}
.qm-markdown-content pre code.hljs {
    padding: var(--qm-code-padding, 1rem);
}

/* GitHub-style Markdown callouts (issue #2162). Labels/icons convey type without color. */
.markdown-alert {
    color: var(--bs-body-color);
    background-color: var(--qm-callout-bg, var(--bs-secondary-bg));
    border: 1px solid var(--qm-callout-border, var(--bs-border-color));
    border-inline-start-width: .3rem;
    border-radius: .375rem;
    padding: .75rem 1rem;
    margin-block: 1rem;
}
.markdown-alert > :last-child { margin-bottom: 0; }
.markdown-alert-title { margin-bottom: .5rem; }
.markdown-alert-note { --qm-callout-bg: var(--bs-info-bg-subtle); --qm-callout-border: var(--bs-info-border-subtle); }
.markdown-alert-tip { --qm-callout-bg: var(--bs-success-bg-subtle); --qm-callout-border: var(--bs-success-border-subtle); }
.markdown-alert-important { --qm-callout-bg: var(--bs-primary-bg-subtle); --qm-callout-border: var(--bs-primary-border-subtle); }
.markdown-alert-warning { --qm-callout-bg: var(--bs-warning-bg-subtle); --qm-callout-border: var(--bs-warning-border-subtle); }
.markdown-alert-caution { --qm-callout-bg: var(--bs-danger-bg-subtle); --qm-callout-border: var(--bs-danger-border-subtle); }
