/* ============================================================
   Edes.MarkdownEditor Demo – rendered Markdown styles
   Targets HTML produced by MarkdownRenderer (Markdig).
   Apply by wrapping the output in <article class="rendered-md">.
   ============================================================ */

.rendered-md {
    --rmd-fg: #0f172a;
    --rmd-muted: #475569;
    --rmd-border: #e2e8f0;
    --rmd-accent: #6366f1;
    --rmd-accent-soft: #eef2ff;
    --rmd-code-bg: #0f172a;
    --rmd-code-fg: #e2e8f0;
    --rmd-inline-code-bg: #f1f5f9;
    --rmd-inline-code-fg: #db2777;
    --rmd-quote-bg: #f8fafc;
    --rmd-table-header-bg: #f8fafc;
    --rmd-table-row-alt: #fafbfc;

    margin: 0;
    padding: 0;
    border: none;
    min-height: 500px;
    background: #ffffff;
    color: var(--rmd-fg);
    border-radius: 14px;
    box-shadow: 0 6px 24px -12px rgb(15 23 42 / 0.15);
    font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 1rem;
    line-height: 1.7;
    letter-spacing: -0.003em;
    word-wrap: break-word;
}

/* Ensure article element has no margins, borders, or padding */
article.rendered-md {
    margin: 0 !important;
    border: none !important;
    padding: 0 !important;
}

/* Fragment variant – tighter, card-like slide */
.rendered-md--fragment {
    padding: 1.75rem 2rem;
    min-height: 320px;
}

/* -------- Headings -------- */
.rendered-md h1,
.rendered-md h2,
.rendered-md h3,
.rendered-md h4,
.rendered-md h5,
.rendered-md h6 {
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.25;
    margin: 2.2rem 0 .8rem;
    scroll-margin-top: 1rem;
}

.rendered-md h1:first-child,
.rendered-md h2:first-child,
.rendered-md h3:first-child { margin-top: 0; }

.rendered-md h1 {
    font-size: 2.1rem;
    padding-bottom: .5rem;
    border-bottom: 1px solid var(--rmd-border);
    background: linear-gradient(90deg, var(--rmd-accent), #8b5cf6);
    -webkit-background-clip: text;
            background-clip: text;
    color: transparent;
}

.rendered-md h2 {
    font-size: 1.55rem;
    padding-bottom: .35rem;
    border-bottom: 1px solid var(--rmd-border);
}

.rendered-md h3 { font-size: 1.25rem; }
.rendered-md h4 { font-size: 1.05rem; color: var(--rmd-muted); }

/* -------- Text -------- */
.rendered-md p { margin: 0 0 1rem; }
.rendered-md strong { font-weight: 700; color: #111827; }
.rendered-md em { color: #334155; }
.rendered-md del { color: var(--rmd-muted); }

.rendered-md a {
    color: var(--rmd-accent);
    text-decoration: none;
    border-bottom: 1px dashed transparent;
    transition: border-color .15s ease, color .15s ease;
}

.rendered-md a:hover {
    color: #4338ca;
    border-bottom-color: currentColor;
}

/* -------- Inline / block code -------- */
.rendered-md code {
    font-family: "JetBrains Mono", "Fira Code", ui-monospace, SFMono-Regular, Consolas, monospace;
    font-size: .9em;
    padding: .15em .4em;
    background: var(--rmd-inline-code-bg);
    color: var(--rmd-inline-code-fg);
    border-radius: 6px;
    font-weight: 500;
}

.rendered-md pre {
    position: relative;
    margin: 1.25rem 0;
    padding: 1.1rem 1.25rem;
    background: var(--rmd-code-bg);
    color: var(--rmd-code-fg);
    border-radius: 12px;
    overflow: auto;
    box-shadow: 0 6px 20px -12px rgb(15 23 42 / 0.4);
    font-family: "JetBrains Mono", "Fira Code", ui-monospace, SFMono-Regular, Consolas, monospace;
    font-size: .9rem;
    line-height: 1.55;
}

.rendered-md pre code {
    padding: 0;
    background: transparent;
    color: inherit;
    font-size: inherit;
    font-weight: 400;
    border-radius: 0;
}

/* Highlight.js color overrides for highlighted blocks */
.rendered-md pre code.hljs {
    background: transparent;
    color: var(--rmd-code-fg);
    padding: 0;
}

/* Ensure Highlight.js token colors are visible */
.rendered-md .hljs-string { color: #85e89d; }
.rendered-md .hljs-number { color: #79b8ff; }
.rendered-md .hljs-literal { color: #79b8ff; }
.rendered-md .hljs-attr { color: #85e89d; }
.rendered-md .hljs-variable { color: #e1e4e8; }
.rendered-md .hljs-function { color: #b392f0; }
.rendered-md .hljs-keyword { color: #f97583; }
.rendered-md .hljs-type { color: #79b8ff; }
.rendered-md .hljs-class { color: #79b8ff; }
.rendered-md .hljs-comment { color: #6a737d; }
.rendered-md .hljs-title { color: #b392f0; }


/* Little colored dots to mimic a code editor titlebar */
.rendered-md pre::before {
    content: "";
    position: absolute;
    top: 12px;
    left: 14px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #ef4444;
    box-shadow: 16px 0 0 #f59e0b, 32px 0 0 #22c55e;
    opacity: .8;
}

.rendered-md pre > code { display: block; padding-top: 1.1rem; }

/* -------- Blockquote -------- */
.rendered-md blockquote {
    margin: 1.25rem 0;
    padding: .9rem 1.15rem;
    color: var(--rmd-muted);
    background: var(--rmd-quote-bg);
    border-left: 4px solid var(--rmd-accent);
    border-radius: 0 10px 10px 0;
    font-style: italic;
}

.rendered-md blockquote > :last-child { margin-bottom: 0; }

/* -------- Lists -------- */
.rendered-md ul,
.rendered-md ol {
    margin: 0 0 1rem;
    padding-left: 1.5rem;
}

.rendered-md li + li { margin-top: .3rem; }
.rendered-md li::marker { color: var(--rmd-accent); }

/* Task lists (Markdig GFM) */
.rendered-md ul.contains-task-list,
.rendered-md .contains-task-list ul {
    list-style: none;
    padding-left: .5rem;
}

.rendered-md .task-list-item { display: flex; align-items: baseline; gap: .55rem; }

.rendered-md .task-list-item input[type="checkbox"] {
    width: 1rem;
    height: 1rem;
    accent-color: var(--rmd-accent);
    margin: 0;
}

/* -------- Tables -------- */
.rendered-md table {
    width: 100%;
    margin: 1.25rem 0;
    border-collapse: separate;
    border-spacing: 0;
    border: 1px solid var(--rmd-border);
    border-radius: 10px;
    overflow: hidden;
    font-size: .95rem;
}

.rendered-md th,
.rendered-md td {
    padding: .65rem .9rem;
    text-align: left;
    border-bottom: 1px solid var(--rmd-border);
}

.rendered-md th {
    background: var(--rmd-table-header-bg);
    font-weight: 600;
    color: #334155;
}

.rendered-md tbody tr:nth-child(2n) { background: var(--rmd-table-row-alt); }
.rendered-md tbody tr:last-child td { border-bottom: none; }

/* -------- Media / misc -------- */
.rendered-md img {
    max-width: 100%;
    height: auto;
    border-radius: 10px;
    box-shadow: 0 6px 24px -14px rgb(15 23 42 / 0.4);
    margin: 1rem 0;
}

/* Markdown image style presets emitted by editor as {style="..."}. */
.rendered-md img:is([style="Background"], [style="Background;"], [style*="Background"]) {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    max-width: none;
    object-fit: cover;
    opacity: 0.12;
    z-index: 0;
    pointer-events: none;
    user-select: none;
}

.rendered-md:has(img:is([style="Background"], [style="Background;"], [style*="Background"])) {
    position: relative;
    isolation: isolate;
    overflow: hidden;
}

.rendered-md:has(> img:is([style="Background"], [style="Background;"], [style*="Background"])) > :not(img:is([style="Background"], [style="Background;"], [style*="Background"])) {
    position: relative;
    z-index: 1;
}

.rendered-md img:is([style="TopRight"], [style="TopRight;"], [style*="TopRight"]) {
    float: right;
    clear: right;
    width: 38%;
    max-width: 320px;
    height: auto;
    margin: 0 0 1rem 1rem;
    shape-outside: margin-box;
}

/* Keep TopRightSmall more specific so it wins over TopRight contains-match. */
.rendered-md img:is([style="TopRightSmall"], [style="TopRightSmall;"], [style*="TopRightSmall"]) {
    float: right;
    clear: right;
    width: 20%;
    max-width: 160px;
    height: auto;
    margin: 0 0 .5rem .5rem;
    shape-outside: margin-box;
}

@media (max-width: 640px) {
    .rendered-md img:is([style="TopRight"], [style="TopRight;"], [style*="TopRight"], [style="TopRightSmall"], [style="TopRightSmall;"], [style*="TopRightSmall"]) {
        float: none;
        width: 100%;
        max-width: 100%;
        margin: .75rem 0;
    }
}

.rendered-md hr {
    border: none;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--rmd-border), transparent);
    margin: 2rem 0;
}

.rendered-md kbd {
    display: inline-block;
    padding: .1rem .45rem;
    font-family: inherit;
    font-size: .85em;
    color: #334155;
    background: #f8fafc;
    border: 1px solid var(--rmd-border);
    border-bottom-width: 2px;
    border-radius: 6px;
}

/* -------- Dark theme opt-in -------- */
.rendered-md.rendered-md--dark {
    --rmd-fg: #e2e8f0;
    --rmd-muted: #94a3b8;
    --rmd-border: #1e293b;
    --rmd-accent: #a5b4fc;
    --rmd-accent-soft: #312e81;
    --rmd-inline-code-bg: #1e293b;
    --rmd-inline-code-fg: #f472b6;
    --rmd-quote-bg: #0f172a;
    --rmd-table-header-bg: #0f172a;
    --rmd-table-row-alt: #0b1120;

    background: #0b1120;
    border-color: var(--rmd-border);
}

.rendered-md.rendered-md--dark strong { color: #f1f5f9; }
.rendered-md.rendered-md--dark em { color: #cbd5e1; }
.rendered-md.rendered-md--dark th { color: #cbd5e1; }
