/**
 * Rendered chronicle bodies — the article modal and the Admin Studio preview.
 *
 * `main.css` resets `* { margin: 0; padding: 0 }`, so a parsed article has no
 * spacing of its own. The old renderer tried to supply it with utility classes
 * (`my-3`, `pl-2`, `space-y-1`) that are not defined in this project's hand-
 * written utility sheet, so headings, paragraphs and bullets all ran together
 * into one block of text — markdown that HAD been parsed still read as if it
 * had not. Everything below is real CSS on real elements for that reason.
 *
 * Both containers share the rules; the preview only differs in scale, so what
 * the admin sees while typing is what gets published.
 */

.article-markdown-body,
.markdown-live-preview {
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-size: 1rem;
  line-height: 1.75;
  overflow-wrap: anywhere;
}

/* Headings ---------------------------------------------------------------- */

.article-markdown-body :is(.md-h1, .md-h2, .md-h3, .md-h4, .md-h5, .md-h6),
.markdown-live-preview :is(.md-h1, .md-h2, .md-h3, .md-h4, .md-h5, .md-h6) {
  font-family: var(--font-display);
  color: var(--text-primary);
  line-height: 1.3;
  margin: 1.75rem 0 0.75rem;
}

.article-markdown-body :first-child,
.markdown-live-preview :first-child {
  margin-top: 0;
}

.md-h1 { font-size: 1.85rem; font-weight: 800; letter-spacing: 0.02em; }
.md-h2 {
  font-size: 1.45rem;
  font-weight: 700;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--border-subtle);
}
.md-h3 { font-size: 1.2rem; font-weight: 700; color: var(--color-amber-bright); }
.md-h4 { font-size: 1.02rem; font-weight: 700; }
.md-h5,
.md-h6 {
  font-size: 0.9rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

/* The runes the old renderer typed into the markup itself. Decoration belongs
   in the stylesheet, so a heading's text stays its text — copyable, searchable
   and safe to slice for an excerpt. */
.md-h2::before,
.md-h3::before {
  margin-right: 0.5rem;
  color: var(--color-amber);
  font-weight: 400;
}
.md-h2::before { content: 'ᚦ'; }
.md-h3::before { content: 'ᚱ'; }

/* Text -------------------------------------------------------------------- */

.md-p { margin: 0.9rem 0; }

.md-strong { color: var(--text-primary); font-weight: 700; }
.md-em { color: #cbd5e1; font-style: italic; }
.md-del { color: var(--text-muted); }

.md-link {
  color: var(--color-amber-bright);
  text-decoration: underline;
  text-decoration-color: rgba(245, 158, 11, 0.45);
  text-underline-offset: 2px;
  transition: color var(--transition-fast), text-decoration-color var(--transition-fast);
}
.md-link:hover {
  color: #fcd34d;
  text-decoration-color: var(--color-amber-bright);
}

.md-hr {
  margin: 1.75rem 0;
  border: 0;
  border-top: 1px solid var(--border-subtle);
}

.md-image {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 1.25rem 0;
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
}

/* Lists ------------------------------------------------------------------- */

.md-list { margin: 0.9rem 0; }
.md-li { margin: 0.35rem 0; }

/* A nested list hugs its parent item instead of restating the block spacing. */
.md-li > .md-list { margin: 0.35rem 0 0.35rem 0.25rem; }

.md-ul {
  list-style: none;
  padding-left: 0;
}
.md-ul > .md-li {
  position: relative;
  padding-left: 1.5rem;
}
.md-ul > .md-li::before {
  content: '✦';
  position: absolute;
  left: 0.15rem;
  top: 0;
  color: var(--color-amber);
  font-size: 0.85em;
  line-height: 1.9;
  user-select: none;
}

.md-ol {
  list-style: decimal;
  padding-left: 1.85rem;
}
.md-ol > .md-li::marker {
  color: var(--color-amber-bright);
  font-family: var(--font-mono);
  font-size: 0.85em;
}

/* Quotes ------------------------------------------------------------------ */

.md-quote {
  margin: 1.25rem 0;
  padding: 0.75rem 1rem;
  border-left: 3px solid var(--color-amber);
  border-radius: 0 8px 8px 0;
  background: rgba(245, 158, 11, 0.06);
  color: #cbd5e1;
  font-style: italic;
}
.md-quote > :first-child { margin-top: 0; }
.md-quote > :last-child { margin-bottom: 0; }

/* Code -------------------------------------------------------------------- */

.md-code {
  padding: 0.12em 0.4em;
  border: 1px solid rgba(51, 65, 85, 0.8);
  border-radius: 5px;
  background: rgba(15, 23, 42, 0.9);
  color: var(--color-amber-bright);
  font-family: var(--font-mono);
  font-size: 0.85em;
  font-style: normal;
}

.md-pre {
  position: relative;
  margin: 1.25rem 0;
  padding: 1rem 1.1rem;
  border: 1px solid rgba(30, 41, 59, 0.9);
  border-radius: 10px;
  background: rgba(3, 7, 18, 0.85);
  overflow-x: auto;
}
.md-pre > code {
  color: #fcd34d;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  line-height: 1.6;
  white-space: pre;
}
.md-pre[data-lang]::after {
  content: attr(data-lang);
  position: absolute;
  top: 0.4rem;
  right: 0.7rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 0.65rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

/* The live preview is a smaller box; scale down rather than restyle, so it
   stays a faithful preview of the published article. */
.markdown-live-preview { font-size: 0.9rem; }
.markdown-live-preview .md-h1 { font-size: 1.4rem; }
.markdown-live-preview .md-h2 { font-size: 1.2rem; }
.markdown-live-preview .md-h3 { font-size: 1.05rem; }
.markdown-live-preview .md-pre > code { font-size: 0.75rem; }
