/* The blog: /blog and /blog/<post>. Same type and colours as the simple page (index.html). */
:root {
  --bg: #0b0b0a;
  --fg: #e9e6df;
  --muted: #8e8a82;
  --line: rgba(233, 230, 223, .14);
  --soft: rgba(233, 230, 223, .05);
  --accent: #fdb515;
  --danger: #e0706a;
  --btn-bg: #e9e6df;
  --btn-fg: #0b0b0a;
}
:root[data-theme="light"] {
  --bg: #fbfaf7;
  --fg: #1b1b19;
  --muted: #6f6c66;
  --line: rgba(27, 27, 25, .14);
  --soft: rgba(27, 27, 25, .04);
  --accent: #1f5a8a;
  --danger: #8c1515;
  --btn-bg: #1b1b19;
  --btn-fg: #fbfaf7;
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--fg);
  font-family: "Newsreader", Georgia, "Times New Roman", serif;
  font-size: 17px; line-height: 1.6; font-optical-sizing: auto;
  -webkit-font-smoothing: antialiased;
  transition: background-color .3s, color .3s;
}
main { max-width: 620px; margin: 0 auto; padding: clamp(40px, 9vh, 88px) 16px 80px; }
a { color: inherit; }
button, input, textarea { font: inherit; color: inherit; }
::selection { background: var(--accent); color: var(--bg); }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.muted { color: var(--muted); }

/* top line: back to the simple page, and to the blog index from a post */
.top { display: flex; gap: 18px; font-size: 15px; color: var(--muted); margin-bottom: clamp(36px, 8vh, 72px); }
.top a { text-decoration: none; transition: color .2s; }
.top a:hover { color: var(--fg); }

h1 { font-size: 26px; font-weight: 500; letter-spacing: -.01em; line-height: 1.25; margin: 0 0 8px; }
h2 { font-size: 19px; font-weight: 500; margin: 36px 0 12px; }
p { margin: 0 0 16px; }
.meta { font-size: 15px; color: var(--muted); margin-bottom: 28px; }
.lede { font-size: 16px; color: var(--muted); margin: 0 0 40px; }
blockquote { margin: 0 0 16px; padding-left: 16px; border-left: 2px solid var(--line); color: var(--muted); }
code { font-family: "Geist Mono", ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .9em; background: var(--soft); padding: 1px 5px; border-radius: 4px; }
article img { max-width: 100%; height: auto; border-radius: 8px; }
.plain { text-decoration: underline; text-decoration-color: var(--line); text-underline-offset: 3px; transition: text-decoration-color .2s; }
.plain:hover { text-decoration-color: currentColor; }

/* post list on /blog */
.posts { list-style: none; padding: 0; margin: 0; }
.posts li { padding: 18px 0; border-top: 1px solid var(--line); }
.posts li:last-child { border-bottom: 1px solid var(--line); }
.posts a { text-decoration: none; display: block; }
.posts .title { font-size: 19px; font-weight: 500; transition: color .2s; }
.posts a:hover .title { color: var(--accent); }
.posts .when { font-size: 14.5px; color: var(--muted); margin: 2px 0 6px; }
.posts p { margin: 0; color: var(--muted); font-size: 16px; }

/* comments under a post */
.comments { margin-top: 56px; padding-top: 28px; border-top: 1px solid var(--line); }
.comments h2 { margin: 0 0 16px; }
.comments h2 .count { color: var(--muted); font-weight: 400; margin-left: 6px; }
.comment-list { list-style: none; padding: 0; margin: 0 0 28px; }
.comment { padding: 14px 0; border-bottom: 1px solid var(--line); }
.comment:first-child { border-top: 1px solid var(--line); }
.comment-meta { display: flex; gap: 10px; align-items: baseline; font-size: 14.5px; color: var(--muted); margin-bottom: 4px; }
.comment-meta b { font-weight: 500; color: var(--fg); }
.comment-meta .link-btn { font-size: 13.5px; margin-left: auto; }
.comment-body { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.comment-empty { font-size: 15.5px; color: var(--muted); margin: 0 0 24px; }

.comment-box { border: 1px solid var(--line); border-radius: 10px; padding: 18px; }
.comment-box p { font-size: 15px; color: var(--muted); margin: 0 0 14px; }
.comment-box p.who { color: var(--fg); }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.field label { font-size: 14px; color: var(--muted); }
.field input, .field textarea {
  width: 100%; background: var(--soft); border: 1px solid var(--line); border-radius: 8px; padding: 8px 11px;
  transition: border-color .2s;
}
.field input:focus, .field textarea:focus { border-color: var(--muted); outline: none; }
.field textarea { min-height: 110px; resize: vertical; }
.field input.code { font-size: 20px; letter-spacing: .25em; max-width: 180px; }
.row { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; }
.btn {
  display: inline-flex; align-items: center; gap: 8px; padding: 8px 16px; border-radius: 999px;
  font-size: 15.5px; text-decoration: none; cursor: pointer;
  background: var(--btn-bg); color: var(--btn-fg); border: 1px solid var(--btn-bg);
  transition: opacity .2s, transform .2s;
}
.btn:hover { opacity: .88; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: default; transform: none; }
.link-btn { background: none; border: 0; padding: 0; cursor: pointer; font-size: 15px; color: var(--muted); text-decoration: underline; text-decoration-color: var(--line); text-underline-offset: 3px; transition: color .2s; }
.link-btn:hover { color: var(--fg); }
.note { font-size: 14.5px; color: var(--muted); margin: 12px 0 0; }
.note.error { color: var(--danger); }
.note.ok { color: var(--fg); }
/* the honeypot: off-screen, never shown to people */
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

footer { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 22px; font-size: 15px; color: var(--muted); margin-top: 64px; }
footer a, footer button {
  display: inline-flex; align-items: center; gap: 7px; line-height: 1; color: var(--muted); text-decoration: none;
  background: none; border: 0; padding: 0; cursor: pointer; transition: color .2s;
}
footer a:hover, footer button:hover { color: var(--fg); }
footer svg { width: 14px; height: 14px; flex: none; position: relative; top: -1px; } /* on the text's visual centre */
.icon-to-dark { display: none; }
:root[data-theme="light"] .icon-to-dark { display: block; }
:root[data-theme="light"] .icon-to-light { display: none; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* small label next to a title (a draft, seen only by the owner) and a flex spacer in the top line */
.tag { font-size: 12.5px; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 1px 8px; margin-left: 8px; vertical-align: middle; font-weight: 400; }
.spacer { flex: 1; }

/* code in posts: `inline` stays as above; fenced blocks (```lang) get a Slack-style box with the
   language, a copy button, and colouring from highlight.js (loaded by blog.js only when needed) */
.snippet { position: relative; margin: 0 0 18px; border: 1px solid var(--line); border-radius: 10px; background: var(--soft); overflow: hidden; }
.snippet .bar { display: flex; align-items: center; justify-content: space-between; padding: 6px 12px; font-size: 12.5px; color: var(--muted); border-bottom: 1px solid var(--line); font-family: "Geist Mono", ui-monospace, SFMono-Regular, Menlo, monospace; }
.snippet .copy { background: none; border: 0; padding: 2px 0; cursor: pointer; color: var(--muted); font: inherit; transition: color .2s; }
.snippet .copy:hover { color: var(--fg); }
.snippet .copy.did { color: var(--accent); }
.snippet pre { margin: 0; padding: 12px 14px; overflow-x: auto; font-size: 14px; line-height: 1.55; }
.snippet pre code { background: none; padding: 0; font-size: inherit; white-space: pre; }
article pre:not(.snippet pre) { margin: 0 0 18px; padding: 12px 14px; overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; background: var(--soft); font-size: 14px; line-height: 1.55; }
article pre code { background: none; padding: 0; font-size: inherit; }

/* highlight.js tokens in the site's colours, dark and light */
.hljs-comment, .hljs-quote { color: var(--muted); font-style: italic; }
.hljs-keyword, .hljs-selector-tag, .hljs-literal, .hljs-type, .hljs-meta { color: #c792ea; }
.hljs-string, .hljs-regexp, .hljs-addition, .hljs-template-tag { color: #8fc79a; }
.hljs-number, .hljs-symbol, .hljs-bullet, .hljs-link { color: var(--accent); }
.hljs-title, .hljs-section, .hljs-function .hljs-title, .hljs-title.function_, .hljs-title.class_ { color: #7fb3e0; }
.hljs-attr, .hljs-attribute, .hljs-variable, .hljs-property, .hljs-name, .hljs-selector-class, .hljs-selector-id { color: #e0a86a; }
.hljs-built_in, .hljs-params { color: inherit; }
.hljs-deletion { color: var(--danger); }
.hljs-emphasis { font-style: italic; }
.hljs-strong { font-weight: 600; }
:root[data-theme="light"] .hljs-keyword, :root[data-theme="light"] .hljs-selector-tag, :root[data-theme="light"] .hljs-literal, :root[data-theme="light"] .hljs-type, :root[data-theme="light"] .hljs-meta { color: #7c3aad; }
:root[data-theme="light"] .hljs-string, :root[data-theme="light"] .hljs-regexp, :root[data-theme="light"] .hljs-addition { color: #2f7a3e; }
:root[data-theme="light"] .hljs-title, :root[data-theme="light"] .hljs-section, :root[data-theme="light"] .hljs-title.function_, :root[data-theme="light"] .hljs-title.class_ { color: #1f5a8a; }
:root[data-theme="light"] .hljs-attr, :root[data-theme="light"] .hljs-attribute, :root[data-theme="light"] .hljs-variable, :root[data-theme="light"] .hljs-property, :root[data-theme="light"] .hljs-name { color: #9a5b12; }

/* images: the title card above a post and as a thumbnail in the list, and pictures in the body */
.cover { margin: 0 0 24px; }
.cover img { display: block; width: 100%; height: auto; max-height: 520px; object-fit: cover; border-radius: 12px; }
.posts .thumb { display: block; width: 100%; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 10px; margin: 0 0 12px; }
article p > img { display: block; max-width: 100%; height: auto; margin: 4px auto 16px; border-radius: 10px; }
article figure { margin: 0 0 18px; }
article figure img { display: block; max-width: 100%; height: auto; border-radius: 10px; }
article figcaption { font-size: 14.5px; color: var(--muted); margin-top: 8px; text-align: center; }

/* maths in posts (KaTeX, rendered on the server; the stylesheet comes from cdnjs on pages that need it) */
.katex { font-size: 1.08em; }
.katex-display { margin: 6px 0 20px; padding: 2px 0; overflow-x: auto; overflow-y: hidden; }
.katex-display > .katex { font-size: 1.15em; }

/* the outline beside a post: section headings, the one being read marked by a bar (blog.js).
   Fixed to the left of the column on screens wide enough to hold it; otherwise not shown. */
article h2, article h3 { scroll-margin-top: 28px; }
html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
.outline { display: none; }
@media (min-width: 1120px) {
  .outline {
    display: block; position: fixed; top: clamp(40px, 9vh, 88px); left: calc(50% - 548px); width: 190px;
    max-height: calc(100vh - 140px); overflow-y: auto; font-size: 14.5px; line-height: 1.45;
  }
  .outline ol { list-style: none; margin: 0; padding: 0; }
  .outline a {
    display: block; padding: 4px 0 4px 14px; border-left: 2px solid transparent;
    color: var(--muted); text-decoration: none; transition: color .2s, border-color .2s;
  }
  .outline li.d3 a { padding-left: 28px; font-size: 13.5px; }
  .outline a:hover { color: var(--fg); }
  .outline li.active > a { color: var(--fg); border-left-color: var(--fg); }
}
