/* The blog's index and post pages, on top of the tokens and site.css. They reuse the system's own pieces: the legal pages' edge and
   head, the home page's hairline rows, and the 40em reading measure. Every value is a token. */

/* ---------- Both pages ---------- */

/* The legal pages' edge, which main.blog and main.post don't get from .legal. */
.blog, .post { padding: var(--space-24) var(--space-8) 0; }

/* A post sits in the blog, so its Blog links (aria-current="true") are drawn as the current page's are. */
.nav-links a[aria-current="true"] { color: var(--text-primary); border-bottom-color: var(--accent); }
.footer-links a[aria-current] { color: var(--text-primary); }

/* ---------- Index: the legal head, then the posts as the home page's product rows ----------
   site.css's .row grid places the title, the excerpt, then the date in mono at the end, where a product row has its domain. */

/* Titles are content, not names: Sora at h4 in sentence case, never the uppercase lockup, so notation keeps its case. */
.post-row-title { margin: 0; font: var(--type-h4); color: var(--text-primary); text-wrap: balance; overflow-wrap: anywhere; }
/* The excerpt is the row's line. It sits in the row's grid track, so a pasted link or an identifier has to break anywhere, or its
   min-content width grows the track past a phone. break-word wouldn't do it, because it leaves min-content as is. */
.post-row p { overflow-wrap: anywhere; }

/* Until the first post: one quiet row between hairlines. */
.empty {
  margin: 0; padding: var(--space-8) 0; font: var(--type-body-sm); color: var(--text-secondary);
  border-top: var(--line-thin) solid var(--border-hairline); border-bottom: var(--line-thin) solid var(--border-hairline);
}

/* ---------- Post: the title, the excerpt as lede, the byline, then the body at the measure ---------- */

.post header { display: grid; gap: var(--space-4); padding-bottom: var(--space-12); }
.post h1 { margin: 0; max-width: 16em; font: var(--type-h1); color: var(--text-primary); text-wrap: balance; overflow-wrap: anywhere; }
/* Like the legal head's h1, the title steps down at the one breakpoint, so a long title no longer runs to six lines at 390px. */
@media (max-width: 720px) { .post h1 { font: var(--type-h2); } }
/* The lede and the byline are grid items in the header, so like the title they break a long token anywhere rather than widen the page. */
.post .lede { margin: var(--space-4) 0 0; max-width: 36em; font: var(--type-body-lg); color: var(--text-secondary); text-wrap: pretty; overflow-wrap: anywhere; }
/* The footer's caption line: the author in ink, the date and the reading time in mono (site.css's .mono), spaced rather than dotted. */
.byline { margin: 0; display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--space-1) var(--space-4); font: var(--type-caption); color: var(--text-primary); overflow-wrap: anywhere; }

.post-body, .post article > .figure { max-width: 40em; }
.post article > .figure { margin: 0 0 var(--space-12); }
.post article > .mono { margin: var(--space-12) 0 0; }

.post-body { font: var(--type-body); color: var(--text-secondary); text-wrap: pretty; overflow-wrap: break-word; }
.post-body > * { margin: 0; }
.post-body > * + * { margin-top: var(--space-4); }
.post-body > :is(.figure, .code-block, .math-display, .table-block, blockquote) { margin-block: var(--space-6); }
.post-body h2 { margin-top: var(--space-12); font: var(--type-h3); color: var(--text-primary); text-wrap: balance; }
.post-body h3 { margin-top: var(--space-8); font: var(--type-h4); color: var(--text-primary); text-wrap: balance; }
.post-body > :first-child { margin-top: 0; }
.post-body :is(h2, h3) { scroll-margin-top: calc(var(--nav-height) + var(--space-6)); }
.post-body strong { font-weight: var(--weight-medium); color: var(--text-primary); }
.post-body :not(pre) > code { color: var(--text-primary); font-variant-ligatures: none; }
.post-body a { color: var(--text-primary); text-decoration: underline; text-decoration-thickness: var(--line-thin); text-underline-offset: 2px; }
.post-body a:hover { color: var(--text-link-hover); }
.post-body :is(ul, ol) { padding-left: 1.25em; }
.post-body li + li { margin-top: var(--space-2); }
.post-body li::marker { color: var(--text-tertiary); }
/* Numbers are numerals in mono. The dark tertiary grey is under 4.5:1, so in dark they step up a tier, as the rows' descriptions do. */
.post-body ol > li::marker { font: var(--type-mono-sm); }
html:not([data-theme="light"]) .post-body ol > li::marker { color: var(--text-secondary); }
.post-body blockquote { padding-left: var(--space-5); border-left: var(--line-thin) solid var(--border-strong); font: var(--type-body-lg); color: var(--text-primary); }

/* ---------- Code: JetBrains Mono on the surface, inside a default border, with the file name above a hairline ---------- */

.code-block { border: var(--line-thin) solid var(--border-default); border-radius: var(--radius-sm); background: var(--bg-surface); }
.code-block figcaption {
  padding: var(--space-2) var(--space-4); border-bottom: var(--line-thin) solid var(--border-hairline);
  font: var(--type-mono-sm); color: var(--text-secondary); overflow-wrap: anywhere;
}
/* No ligatures: JetBrains Mono would draw -> and => as arrows, and code shows what the author typed. */
.code { margin: 0; padding: var(--space-4); overflow-x: auto; font: var(--type-mono); font-variant-ligatures: none; color: var(--text-body); tab-size: 4; }
.code code { font: inherit; }

/* Highlighting is monochrome: weight, italic and the four text greys, never a hue. lowlight writes a compound scope as extra classes
   (hljs-title function_, hljs-title class_ inherited__), which .hljs-title matches, and wraps a sub-language, such as html`` or css``
   in JavaScript, in a span named for it (.xml, .css), which takes the block's grey. Any scope not named here stays the block's grey. */
.code .hljs-keyword, .code .hljs-selector-tag, .code .hljs-doctag { font-weight: var(--weight-medium); }
.code .hljs-title, .code .hljs-built_in { color: var(--text-primary); }
.code .hljs-string, .code .hljs-number, .code .hljs-literal, .code .hljs-regexp, .code .hljs-symbol { color: var(--text-secondary); }
/* An interpolation inside a string is code again. */
.code .hljs-subst { color: var(--text-body); }
.code .hljs-comment { font-style: italic; color: var(--text-tertiary); }
html:not([data-theme="light"]) .code .hljs-comment { color: var(--text-secondary); }

/* ---------- Math: KaTeX in the body's ink. A display equation wider than the measure scrolls inside it. ---------- */

.math-display { overflow-x: auto; overflow-y: hidden; padding-block: var(--space-1); }
.math-display .katex-display { margin: 0; text-align: left; }
.math-display .katex-display > .katex { text-align: left; }

/* ---------- Figures: the image at the measure, then a caption ---------- */

.figure { overflow-x: auto; }
.figure img { display: block; max-width: 100%; height: auto; }
.figure figcaption { margin-top: var(--space-3); font: var(--type-caption); color: var(--text-secondary); }
/* A diagram is usually drawn on white, which would glare on the dark canvas, so in dark it sits on a light panel. */
html:not([data-theme="light"]) .is-diagram img { padding: var(--space-4); border-radius: var(--radius-sm); background: var(--q-gray-50); }

/* ---------- Tables: rows on hairlines in the small body size. A table wider than the measure scrolls inside it. ---------- */

.table-block { overflow-x: auto; }
.table-block table { border-collapse: collapse; font: var(--type-body-sm); color: var(--text-secondary); }
.table-block :is(th, td) { padding: var(--space-3) var(--space-5) var(--space-3) 0; border-bottom: var(--line-thin) solid var(--border-hairline); text-align: left; vertical-align: top; }
.table-block :is(th, td):last-child { padding-right: 0; }
.table-block th { font-weight: var(--weight-medium); color: var(--text-primary); border-bottom-color: var(--border-default); }
.table-block td { min-width: 8em; }

/* ---------- Responsive: the system's one breakpoint ---------- */

@media (max-width: 720px) {
  .blog, .post { padding: var(--space-16) var(--space-5) 0; }
}
