/* ==========================================================================
   Prose — long text that comes as plain HTML: articles, help pages, changelogs,
   terms, anything written in Markdown.

   <article class="prose"> <h2>…</h2> <p>…</p> <ul>…</ul> … </article>

   .prose-sm · .prose-lg     smaller / larger text
   max-w-none                drop the readable line length
   .not-prose                a part inside (a widget, a card) that keeps its own look
   Every rule here is zero-specificity, so any class you add inside wins.
   ========================================================================== */

.prose {
  --mo-prose-size: 1rem;
  max-width: 68ch;
  font-size: var(--mo-prose-size);
  line-height: 1.7;
  color: var(--mo-fg-body);
  overflow-wrap: break-word;
}
.prose-sm { --mo-prose-size: .9375rem; line-height: 1.6; }
.prose-lg { --mo-prose-size: 1.125rem; line-height: 1.75; }

/* Everything below skips .not-prose and what is inside it */
.prose :where(p, ul, ol, dl, blockquote, pre, table, figure, hr, details):not(:where(.not-prose, .not-prose *)) { margin-top: 0; margin-bottom: 1.25em; }

/* Headings */
.prose :where(h1, h2, h3, h4, h5, h6):not(:where(.not-prose, .not-prose *)) { margin-bottom: .6em; line-height: 1.25; letter-spacing: -.015em; text-wrap: balance; }
.prose :where(h1):not(:where(.not-prose, .not-prose *)) { margin-top: 0; font-size: 2.125em; letter-spacing: -.025em; }
.prose :where(h2):not(:where(.not-prose, .not-prose *)) { margin-top: 2em; font-size: 1.5em; }
.prose :where(h3):not(:where(.not-prose, .not-prose *)) { margin-top: 1.6em; font-size: 1.25em; }
.prose :where(h4):not(:where(.not-prose, .not-prose *)) { margin-top: 1.5em; font-size: 1.0625em; }
.prose :where(h5, h6):not(:where(.not-prose, .not-prose *)) { margin-top: 1.5em; font-size: 1em; }
.prose :where(h2, h3, h4) + :where(*) { margin-top: 0; }

/* Text */
.prose :where(a):not(:where(.not-prose, .not-prose *, .btn)) { font-weight: var(--mo-font-weight-medium); }
.prose :where(strong):not(:where(.not-prose, .not-prose *)) { font-weight: var(--mo-font-weight-semibold); }
.prose :where(:not(pre) > code):not(:where(.not-prose, .not-prose *)) {
  padding: .125em .375em;
  font-size: .875em;
  color: var(--mo-fg-body);
  background: color-mix(in oklab, var(--mo-fg-body) 7%, transparent);
  border-radius: var(--mo-radius-1);
}
.prose :where(hr):not(:where(.not-prose, .not-prose *)) { margin-block: 2.5em; }

/* Lists */
.prose :where(ul, ol):not(:where(.not-prose, .not-prose *)) { padding-inline-start: 1.5em; }
.prose :where(li):not(:where(.not-prose, .not-prose *)) { margin-block: .375em; padding-inline-start: .25em; }
.prose :where(li)::marker { color: var(--mo-fg-3); }
.prose :where(ol > li)::marker { font-variant-numeric: tabular-nums; }
.prose :where(li > ul, li > ol):not(:where(.not-prose, .not-prose *)) { margin-block: .375em; }
.prose :where(dt):not(:where(.not-prose, .not-prose *)) { margin-top: 1em; }
.prose :where(dd):not(:where(.not-prose, .not-prose *)) { margin-inline-start: 0; padding-inline-start: 1em; color: var(--mo-fg-2); }

/* Quotes */
.prose :where(blockquote):not(:where(.not-prose, .not-prose *)) {
  padding-inline-start: 1em;
  color: var(--mo-fg-2);
  border-inline-start: 3px solid color-mix(in oklab, var(--mo-fg-body) 18%, transparent);
}
.prose :where(blockquote > :last-child) { margin-bottom: 0; }

/* Code blocks */
.prose :where(pre):not(:where(.not-prose, .not-prose *)) {
  padding: 1em 1.25em;
  font-size: .85em;
  line-height: 1.65;
  background: var(--mo-bg-1);
  border-radius: var(--mo-radius-card);
}

/* Images & figures */
.prose :where(img, video, iframe):not(:where(.not-prose, .not-prose *)) { border-radius: var(--mo-radius-card); }
.prose :where(figure):not(:where(.not-prose, .not-prose *)) { margin-inline: 0; }
.prose :where(figure > img, figure > video) { display: block; margin-bottom: .5em; }
.prose :where(figcaption):not(:where(.not-prose, .not-prose *)) { font-size: .85em; color: var(--mo-fg-3); }

/* Tables — scroll sideways on their own instead of pushing the page */
.prose :where(table):not(:where(.not-prose, .not-prose *)) {
  display: block;
  max-width: 100%;
  overflow-x: auto;
  font-size: .9em;
  line-height: 1.5;
  border-collapse: collapse;
}
.prose :where(th, td):not(:where(.not-prose, .not-prose *)) { padding: .6em .9em; text-align: start; border-bottom: var(--mo-border-width) solid var(--mo-border-color); }
.prose :where(th:first-child, td:first-child) { padding-inline-start: 0; }
.prose :where(thead th):not(:where(.not-prose, .not-prose *)) { font-weight: var(--mo-font-weight-semibold); vertical-align: bottom; }
.prose :where(tbody tr:last-child td) { border-bottom: 0; }

/* Details / summary — FAQs */
.prose :where(details):not(:where(.not-prose, .not-prose *)) { padding: .75em 1em; background: var(--mo-bg-1); border-radius: var(--mo-radius-control); }
.prose :where(summary):not(:where(.not-prose, .not-prose *)) { font-weight: var(--mo-font-weight-medium); }
.prose :where(details[open] > summary) { margin-bottom: .5em; }

/* First and last things touch the edges (last in the file, so they win over the margins above) */
.prose > :where(:first-child) { margin-top: 0; }
.prose > :where(:last-child) { margin-bottom: 0; }
