/* ==========================================================================
   Rich content — shared styling for everything RichContent renders.

   One stylesheet for forum posts, feed posts, comments, profile bios and the
   editor's preview pane, so a post looks the same everywhere it appears.
   All class names are prefixed rc- and are emitted only by the server-side
   renderer; user content can never produce one, because the renderer strips
   class attributes from anything it did not build itself.
   ========================================================================== */

.rc {
    font-family: var(--font-sans, 'Inter', system-ui, sans-serif);
    font-size: 15px;
    line-height: 1.65;
    color: var(--text-primary, #f8fafc);
    word-break: break-word;
    overflow-wrap: anywhere;
}

/* ---- Paragraphs & spacing ------------------------------------------------ */
.rc .rc-p { margin: 0 0 0.85em; }
.rc > .rc-p:last-child,
.rc > *:last-child { margin-bottom: 0; }

/* ---- Headings ------------------------------------------------------------ */
.rc .rc-h {
    font-family: var(--font-display, inherit);
    font-weight: 700;
    line-height: 1.3;
    margin: 1.4em 0 0.55em;
    color: var(--text-primary, #f8fafc);
}
.rc > .rc-h:first-child { margin-top: 0; }
.rc .rc-h1 { font-size: 1.7em; letter-spacing: -0.02em; }
.rc .rc-h2 { font-size: 1.42em; letter-spacing: -0.015em; }
.rc .rc-h3 { font-size: 1.22em; }
.rc .rc-h4 { font-size: 1.08em; }
.rc .rc-h5 { font-size: 1em; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-secondary, #94a3b8); }
.rc .rc-h6 { font-size: 0.92em; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-tertiary, #64748b); }
.rc .rc-h1, .rc .rc-h2 {
    padding-bottom: 0.28em;
    border-bottom: 1px solid rgba(148, 163, 184, 0.18);
}

/* ---- Inline emphasis ----------------------------------------------------- */
.rc strong { font-weight: 700; color: var(--text-primary, #f8fafc); }
.rc em     { font-style: italic; }
.rc del    { opacity: 0.65; }
.rc .rc-mark, .rc mark {
    background: rgba(245, 158, 11, 0.25);
    color: inherit;
    padding: 0.05em 0.28em;
    border-radius: 4px;
}
.rc sup, .rc sub { font-size: 0.72em; line-height: 0; }

/* ---- Links, mentions, hashtags ------------------------------------------ */
.rc .rc-link {
    color: var(--accent, #3b82f6);
    text-decoration: none;
    border-bottom: 1px solid rgba(59, 130, 246, 0.35);
    transition: color .15s ease, border-color .15s ease;
}
.rc .rc-link:hover { color: var(--accent-hover, #60a5fa); border-bottom-color: currentColor; }
.rc .rc-mention {
    color: var(--accent, #3b82f6);
    font-weight: 600;
    text-decoration: none;
    padding: 0.05em 0.2em;
    margin: 0 -0.2em;
    border-radius: 5px;
    transition: background .15s ease;
}
.rc .rc-mention:hover { background: var(--accent-soft, rgba(59,130,246,0.15)); }
.rc .rc-hashtag {
    color: var(--purple, #a855f7);
    font-weight: 500;
    text-decoration: none;
}
.rc .rc-hashtag:hover { text-decoration: underline; }

/* ---- Images & embeds ----------------------------------------------------- */
.rc .rc-img {
    max-width: 100%;
    height: auto;
    border-radius: var(--radius-sm, 10px);
    display: block;
    margin: 0.6em 0;
}
.rc .rc-embed {
    position: relative;
    width: 100%;
    max-width: 680px;
    aspect-ratio: 16 / 9;
    margin: 1em 0;
    border-radius: var(--radius-md, 16px);
    overflow: hidden;
    background: #000;
}
.rc .rc-embed iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }

/* ---- Lists --------------------------------------------------------------- */
.rc .rc-list { margin: 0 0 0.9em; padding-left: 1.6em; }
.rc .rc-list li { margin: 0.28em 0; }
.rc .rc-list .rc-list { margin-bottom: 0.2em; }
.rc ul.rc-list { list-style: disc; }
.rc ul.rc-list ul.rc-list { list-style: circle; }
.rc ol.rc-list { list-style: decimal; }
.rc .rc-list-task { list-style: none; padding-left: 0.3em; }
.rc .rc-task { display: flex; align-items: flex-start; gap: 0.55em; }
.rc .rc-task-box {
    margin-top: 0.36em;
    accent-color: var(--accent, #3b82f6);
    cursor: default;
    flex: 0 0 auto;
}

/* ---- Quotes -------------------------------------------------------------- */
.rc .rc-quote {
    margin: 0.9em 0;
    padding: 0;
    border: 1px solid rgba(148, 163, 184, 0.18);
    border-left: 3px solid var(--accent, #3b82f6);
    border-radius: var(--radius-sm, 10px);
    background: rgba(59, 130, 246, 0.06);
    overflow: hidden;
}
.rc .rc-quote-head {
    font-size: 12.5px;
    font-weight: 600;
    color: var(--text-secondary, #94a3b8);
    padding: 8px 14px;
    background: rgba(148, 163, 184, 0.07);
}
.rc .rc-quote-head i { color: var(--accent, #3b82f6); margin-right: 4px; }
.rc .rc-quote-body { padding: 12px 14px; }
.rc .rc-quote-body > *:last-child { margin-bottom: 0; }

/* ---- Code ---------------------------------------------------------------- */
.rc .rc-icode {
    font-family: var(--font-mono, 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace);
    font-size: 0.88em;
    background: rgba(148, 163, 184, 0.16);
    color: #f0abfc;
    padding: 0.15em 0.42em;
    border-radius: 5px;
    border: 1px solid rgba(148, 163, 184, 0.14);
    white-space: break-spaces;
}
.rc .rc-code {
    margin: 1em 0;
    border-radius: var(--radius-sm, 10px);
    overflow: hidden;
    border: 1px solid rgba(148, 163, 184, 0.2);
    background: #0d1117;
    box-shadow: var(--shadow-sm, 0 4px 14px rgba(0,0,0,.25));
}
.rc .rc-code-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 7px 12px;
    background: rgba(148, 163, 184, 0.09);
    border-bottom: 1px solid rgba(148, 163, 184, 0.16);
}
.rc .rc-code-lang {
    font-family: var(--font-mono, ui-monospace, monospace);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-secondary, #94a3b8);
}
.rc .rc-code-lang i { margin-right: 5px; opacity: 0.7; }
.rc .rc-code-copy {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font: inherit;
    font-size: 11.5px;
    font-weight: 600;
    color: var(--text-secondary, #94a3b8);
    background: transparent;
    border: 1px solid rgba(148, 163, 184, 0.25);
    border-radius: 6px;
    padding: 3px 9px;
    cursor: pointer;
    transition: all .15s ease;
}
.rc .rc-code-copy:hover { color: var(--text-primary, #fff); border-color: var(--accent, #3b82f6); background: var(--accent-soft, rgba(59,130,246,.15)); }
.rc .rc-code-copy.is-copied { color: var(--success, #10b981); border-color: var(--success, #10b981); }
.rc .rc-code-pre {
    margin: 0;
    padding: 14px 16px;
    overflow-x: auto;
    background: transparent;
    /* A very long single line must scroll the block, never the page. */
    max-width: 100%;
}
.rc .rc-code-pre code {
    font-family: var(--font-mono, 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace);
    font-size: 13px;
    line-height: 1.6;
    color: #d4d4d4;
    background: none;
    border: 0;
    padding: 0;
    white-space: pre;
    tab-size: 4;
    display: block;
}
/* Keep syntax tokens readable even when a page/theme ships a broader text rule.
   In particular, highlight.js marks C# `using` as .hljs-keyword; inheriting a
   dark or transparent colour made that directive appear missing and also made
   selection/copy behavior confusing. */
.rc .rc-code-pre code.hljs { color: #d4d4d4 !important; background: transparent !important; }
.rc .rc-code-pre .hljs-keyword,
.rc .rc-code-pre .hljs-selector-tag,
.rc .rc-code-pre .hljs-literal,
.rc .rc-code-pre .hljs-section,
.rc .rc-code-pre .hljs-link { color: #c678dd !important; }
.rc .rc-code-pre .hljs-title,
.rc .rc-code-pre .hljs-function { color: #61afef !important; }
.rc .rc-code-pre .hljs-type,
.rc .rc-code-pre .hljs-class,
.rc .rc-code-pre .hljs-built_in { color: #e5c07b !important; }
.rc .rc-code-pre .hljs-string,
.rc .rc-code-pre .hljs-attr { color: #98c379 !important; }
.rc .rc-code-pre .hljs-number { color: #d19a66 !important; }
.rc .rc-code-pre .hljs-comment,
.rc .rc-code-pre .hljs-quote { color: #7f8c98 !important; font-style: italic; }
.rc .rc-code-pre .hljs-variable,
.rc .rc-code-pre .hljs-template-variable { color: #e06c75 !important; }

/* ---- Tables -------------------------------------------------------------- */
.rc .rc-table-wrap {
    margin: 1em 0;
    /* Wide tables scroll inside their own box so the page never scrolls sideways. */
    overflow-x: auto;
    border: 1px solid rgba(148, 163, 184, 0.18);
    border-radius: var(--radius-sm, 10px);
}
.rc .rc-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.rc .rc-table th,
.rc .rc-table td { padding: 9px 13px; border-bottom: 1px solid rgba(148, 163, 184, 0.14); text-align: left; }
.rc .rc-table th { background: rgba(148, 163, 184, 0.09); font-weight: 700; white-space: nowrap; }
.rc .rc-table tbody tr:last-child td { border-bottom: 0; }
.rc .rc-table tbody tr:hover { background: rgba(148, 163, 184, 0.05); }

/* ---- Rules --------------------------------------------------------------- */
.rc .rc-hr {
    border: 0;
    height: 1px;
    background: rgba(148, 163, 184, 0.22);
    margin: 1.5em 0;
}

/* ---- Spoilers, details, hidden content ----------------------------------- */
.rc .rc-spoiler,
.rc .rc-details {
    margin: 0.9em 0;
    border: 1px solid rgba(148, 163, 184, 0.2);
    border-radius: var(--radius-sm, 10px);
    background: rgba(148, 163, 184, 0.05);
    overflow: hidden;
}
.rc .rc-spoiler > summary,
.rc .rc-details > summary {
    cursor: pointer;
    padding: 9px 14px;
    font-size: 13.5px;
    font-weight: 600;
    color: var(--text-secondary, #94a3b8);
    background: rgba(148, 163, 184, 0.07);
    list-style: none;
    user-select: none;
    transition: color .15s ease;
}
.rc .rc-spoiler > summary::-webkit-details-marker,
.rc .rc-details > summary::-webkit-details-marker { display: none; }
.rc .rc-spoiler > summary::before,
.rc .rc-details > summary::before {
    content: '\25B8';
    display: inline-block;
    margin-right: 8px;
    transition: transform .18s ease;
}
.rc .rc-spoiler[open] > summary::before,
.rc .rc-details[open] > summary::before { transform: rotate(90deg); }
.rc .rc-spoiler > summary:hover,
.rc .rc-details > summary:hover { color: var(--text-primary, #f8fafc); }
.rc .rc-spoiler-body,
.rc .rc-details-body { padding: 12px 14px; }
.rc .rc-spoiler-body > *:last-child,
.rc .rc-details-body > *:last-child { margin-bottom: 0; }

.rc .rc-hide {
    margin: 0.9em 0;
    border-radius: var(--radius-sm, 10px);
    padding: 12px 14px;
    font-size: 14px;
}
.rc .rc-hide-locked {
    border: 1px dashed rgba(244, 63, 94, 0.45);
    background: var(--danger-soft, rgba(244, 63, 94, 0.14));
    color: var(--text-secondary, #94a3b8);
    text-align: center;
}
.rc .rc-hide-locked i { color: var(--danger, #f43f5e); margin-right: 6px; }
.rc .rc-hide-open {
    border: 1px solid rgba(16, 185, 129, 0.4);
    background: var(--success-soft, rgba(16, 185, 129, 0.14));
    padding: 0;
}
.rc .rc-hide-head {
    padding: 8px 14px;
    font-size: 12.5px;
    font-weight: 700;
    color: var(--success, #10b981);
    border-bottom: 1px solid rgba(16, 185, 129, 0.25);
}
.rc .rc-hide-body { padding: 12px 14px; }
.rc .rc-hide-body > *:last-child { margin-bottom: 0; }

/* ---- Alignment / indent -------------------------------------------------- */
.rc .rc-indent { padding-left: 2em; border-left: 2px solid rgba(148, 163, 184, 0.18); margin: 0.6em 0; }
.rc .rc-align { margin: 0.4em 0; }

/* ---- Compact variant: comments, chat bubbles, list previews -------------- */
.rc-compact { font-size: 14px; line-height: 1.55; }
.rc-compact .rc-p { margin-bottom: 0.5em; }
.rc-compact .rc-h { margin: 0.7em 0 0.35em; }
.rc-compact .rc-h1 { font-size: 1.28em; }
.rc-compact .rc-h2 { font-size: 1.18em; }
.rc-compact .rc-h3 { font-size: 1.08em; }
.rc-compact .rc-h1, .rc-compact .rc-h2 { border-bottom: 0; padding-bottom: 0; }
.rc-compact .rc-code { margin: 0.6em 0; }
.rc-compact .rc-code-pre { padding: 10px 12px; }
.rc-compact .rc-code-pre code { font-size: 12.5px; }
.rc-compact .rc-embed { max-width: 460px; }

/* ---- Small screens ------------------------------------------------------- */
@media (max-width: 640px) {
    .rc { font-size: 14.5px; }
    .rc .rc-h1 { font-size: 1.45em; }
    .rc .rc-h2 { font-size: 1.28em; }
    .rc .rc-code-pre code { font-size: 12px; }
    .rc .rc-indent { padding-left: 1.1em; }
    .rc .rc-list { padding-left: 1.35em; }
}

/* ---- Light theme --------------------------------------------------------- */
[data-theme="light"] .rc .rc-icode { background: rgba(15, 23, 42, 0.07); color: #a21caf; }
[data-theme="light"] .rc .rc-code { background: #f6f8fa; border-color: rgba(15, 23, 42, 0.12); }
[data-theme="light"] .rc .rc-code-pre code { color: #24292f; }
[data-theme="light"] .rc .rc-h1,
[data-theme="light"] .rc .rc-h2 { border-bottom-color: rgba(15, 23, 42, 0.12); }
