/* The look of rendered Markdown — and the *only* place it is described.
   `lib/blog/markdown.js` is the one renderer; this is the one stylesheet for what it
   emits. The public post page (lib/blog/shell.html) and the admin editor's preview
   (admin-ui/index.html) both link this file, so the preview cannot drift from the
   published page the way it did when the admin kept its own `.preview` copies of these
   rules: tables had borders on the post and none in the preview.

   Everything here is scoped to `.post-body`, which is the class on the container both
   sides put the rendered HTML into. Nothing outside that class belongs in this file.

   The tokens are redeclared on `.post-body` with the same values `public/css/styles.css`
   and `blog.css` give them, so this file also stands on its own inside the admin PWA,
   which loads neither. On the public page they shadow identical values, so nothing
   changes there.

   A word with no break opportunity in it — a long identifier, a pasted URL — is
   wider than a phone, and the blog's sections are full-bleed, so one of them turns the
   whole page into a horizontal scroller with a white strip down the side. Rendered body
   text breaks mid-word rather than push the viewport out; `pre` and `table` are excluded
   because they scroll inside themselves instead.

   overflow-wrap inherits, so every list item, blockquote and table cell wraps a long word.
   Code blocks opt back out below: they scroll sideways instead of breaking a line. */
.post-body {
    --code-bg: #f3f4f6;
    --border-color: #e5e7eb;
    --bg-section: #f9fafb;
    --text-dark: #1f2937;
    --text-light: #6b7280;
    --secondary-color: #10b981;
    overflow-wrap: anywhere;
}

/* The global reset zeroes margins, so rendered Markdown has no spacing of its own —
   the same reason .bio-text > * + * exists on the home page. */
.post-body > * + * {
    margin-top: 1.1rem;
}

.post-body h2 {
    font-size: 1.3rem;
    margin-top: 2rem;
    line-height: 1.3;
}

.post-body h3 {
    font-size: 1.05rem;
    margin-top: 1.5rem;
}

.post-body ul,
.post-body ol {
    padding-left: 1.25rem;
}

.post-body li + li {
    margin-top: 0.35rem;
}

.post-body img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
}

.post-body table {
    display: block;
    max-width: 100%;
    overflow-x: auto;
    border-collapse: collapse;
    font-size: 0.95rem;
}

.post-body th,
.post-body td {
    border: 1px solid var(--border-color);
    padding: 0.5rem 0.75rem;
    text-align: left;
    vertical-align: top;
}

.post-body th {
    background: var(--bg-section);
    font-weight: 600;
}

.post-body code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.85em;
    background: var(--code-bg);
    padding: 0.12em 0.35em;
    border-radius: 4px;
    overflow-wrap: anywhere;
}

/* A wide code block scrolls inside itself; nothing on this page may make the page
   wider than the viewport. `position: relative` is the anchor for the data-lang
   label below. */
.post-body pre {
    background: var(--code-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1rem;
    overflow-x: auto;
    max-width: 100%;
    position: relative;
}

/* Language label in the block's top-right corner, from the data-lang the server sets. */
.post-body pre[data-lang]::before {
    content: attr(data-lang);
    position: absolute;
    top: 0.35rem;
    right: 0.6rem;
    font-size: 0.7rem;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    color: var(--text-light);
}


.post-body pre code {
    background: none;
    padding: 0;
    font-size: 0.82rem;
    line-height: 1.55;
    white-space: pre;
    overflow-wrap: normal;
}

.post-body blockquote {
    border-left: 3px solid var(--secondary-color);
    padding: 0.25rem 0 0.25rem 1rem;
    color: var(--text-light);
    font-style: italic;
}

/* Syntax colours for highlight.js, from the site palette instead of a stock theme: every
   stock light theme paints something red, which the palette deliberately has none of.
   The server does the highlighting (lib/blog/markdown.js); these only colour the
   classes it emits, which is why neither page loads highlight.js in the browser. */
.post-body .hljs { color: var(--text-dark); }
.post-body .hljs-comment, .post-body .hljs-quote, .post-body .hljs-meta { color: #6b7280; font-style: italic; }
.post-body .hljs-keyword, .post-body .hljs-selector-tag, .post-body .hljs-built_in, .post-body .hljs-doctag, .post-body .hljs-name, .post-body .hljs-tag { color: #2563eb; }
.post-body .hljs-string, .post-body .hljs-addition, .post-body .hljs-regexp, .post-body .hljs-symbol, .post-body .hljs-bullet, .post-body .hljs-link { color: #047857; }
.post-body .hljs-number, .post-body .hljs-literal, .post-body .hljs-variable, .post-body .hljs-template-variable, .post-body .hljs-attr, .post-body .hljs-attribute, .post-body .hljs-deletion { color: #b45309; }
.post-body .hljs-title, .post-body .hljs-section, .post-body .hljs-type, .post-body .hljs-class .hljs-title, .post-body .hljs-selector-id, .post-body .hljs-selector-class { color: #1d4ed8; font-weight: 600; }
.post-body .hljs-emphasis { font-style: italic; }
.post-body .hljs-strong { font-weight: 700; }
