/* ASCII skin for the StackEdit blog posts: home page type and colours, dark by default, with the
   post's own light/dark toggle kept (light becomes a paper version of the same look).
   Load it after the post's inline <style>. */

@font-face {
  font-family: "Geist Mono";
  src: url("../assets/fonts/GeistMono-var.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}

html:not([data-theme="light"]) {
  --bg-color: #0a0908;
  --text-color: #ece6d6;
  --muted-color: #a8a293;
  --faint-color: #6e695e;
  --border-color: rgba(236, 230, 214, 0.14);
  --link-color: #ece6d6;
  --link-hover-color: #facf0f;
  --underline-color: rgba(250, 207, 15, 0.55);
  --blockquote-bg: #12110e;
  --code-bg: #12110e;
  --accent: #facf0f;
}
html[data-theme="light"] {
  --bg-color: #f3efe6;
  --text-color: #1b1a17;
  --muted-color: #46433c;
  --faint-color: #6f6a61;
  --border-color: rgba(27, 26, 23, 0.16);
  --link-color: #1b1a17;
  --link-hover-color: #7a5c00;
  --underline-color: rgba(122, 92, 0, 0.62);
  --blockquote-bg: #ebe6da;
  --code-bg: #ebe6da;
  --accent: #7a5c00;
}
/* Dark text on paper: the thin "antialiased" smoothing washes it out, so use the normal one. */
html[data-theme="light"] body { -webkit-font-smoothing: auto; -moz-osx-font-smoothing: auto; }
:root { --mono: "Geist Mono", "Geeza Pro", "Noto Naskh Arabic", ui-monospace, "SF Mono", Menlo, monospace; }

html, body { background: var(--bg-color) !important; }
::selection { background: var(--accent); color: var(--bg-color); }

/* First-visit theme picker and its dimming overlay: the post opens straight to the text. */
.theme-selector { display: none !important; }
body.loading::before { content: none !important; }

/* Type */
body, body .stackedit__html, body .stackedit__toc, body .blog-title-overlay, body .theme-toggle {
  font-family: var(--mono) !important;
  font-variant-ligatures: none;
}
body .stackedit__html { font-size: 15.5px; line-height: 1.75; letter-spacing: 0; }
body .stackedit__html :is(h1, h2, h3, h4, h5, h6) { font-family: var(--mono) !important; font-weight: 500; letter-spacing: -0.01em; }
body .stackedit__html h1 { font-size: 2em; }
body .stackedit__html h2 { font-size: 1.45em; border-bottom: 1px solid var(--border-color) !important; padding-bottom: .4em; }
body .stackedit__html h3 { font-size: 1.15em; }
body .stackedit__html :is(p, li) { color: var(--text-color) !important; }
body .stackedit__html strong { font-weight: 600; }

/* Links: ink with a gold underline, like the rest of the site. */
body .stackedit__html a {
  color: var(--link-color) !important;
  text-decoration: underline;
  text-decoration-color: var(--underline-color);
  text-decoration-thickness: 1px;
  text-underline-offset: 4px;
}
body .stackedit__html a:hover { color: var(--link-hover-color) !important; text-decoration-color: var(--link-hover-color); }

/* Contents sidebar */
body .stackedit__toc { border-right: 1px solid var(--border-color) !important; font-size: 13px; }
body .stackedit__toc a { color: var(--muted-color) !important; text-decoration: none; }
body .stackedit__toc a:hover { color: var(--text-color) !important; }
body .stackedit__toc li { line-height: 1.6; }

/* Blocks: square, thin rules, no colour accents. */
body *:not(svg):not(svg *) { border-radius: 0 !important; box-shadow: none !important; }
body blockquote {
  background: var(--blockquote-bg) !important;
  border-left: 2px solid var(--accent) !important;
  color: var(--muted-color) !important;
  padding: .8em 1.2em !important;
}
body code { font-family: var(--mono) !important; background: var(--code-bg) !important; color: var(--text-color) !important; font-size: .9em; }
body pre { background: var(--code-bg) !important; border: 1px solid var(--border-color) !important; }
body pre code { background: transparent !important; }
body :is(th, td) { border: 1px solid var(--border-color) !important; }
body th { background: var(--code-bg) !important; font-weight: 500; }
body hr, body .part-divider { border: 0 !important; border-top: 1px dashed var(--border-color) !important; }
body .stackedit__html img { border: 1px solid var(--border-color); }
body .last-updated { color: var(--faint-color) !important; font-size: 12px !important; letter-spacing: .04em; }

/* Hero: same layout, mono title, quieter arrow. */
body .blog-title-overlay h1 { font-weight: 500 !important; letter-spacing: -0.02em; text-shadow: 0 1px 18px rgba(10, 9, 8, 0.85) !important; }
body .blog-title-overlay :is(p, .subtitle) { letter-spacing: 0; text-shadow: 0 1px 12px rgba(10, 9, 8, 0.85) !important; }
body .scroll-indicator { animation: none; font-size: 18px; opacity: .7; }

/* Theme toggle: a small square button. */
body .theme-toggle {
  width: 38px; height: 38px; font-size: 16px;
  background: var(--bg-color) !important;
  border: 1px solid var(--border-color) !important;
  color: var(--muted-color) !important;
}
body .theme-toggle:hover { color: var(--text-color) !important; border-color: var(--text-color) !important; }

/* The post sets light colours on body.loading for its first half second; keep the default dark. */
html:not([data-theme="light"]) body.loading { --bg-color: #0a0908; --text-color: #ece6d6; }

/* Mono is wider than the old face: long URLs wrap, and wide tables and formulas scroll in place. */
body .stackedit__html { overflow-wrap: break-word; }
body .stackedit__html a { overflow-wrap: anywhere; }
@media (max-width: 768px) {
  body .stackedit__html table { display: block; max-width: 100%; overflow-x: auto; }
  body .stackedit__html :is(.katex-display, math[display="block"], mjx-container) { display: block; max-width: 100%; overflow-x: auto; overflow-y: hidden; }
  body .stackedit__html .katex, body .stackedit__html math { max-width: 100%; }
}

/* Animated ASCII diagrams (assets/ascii-diagrams.js). */
body .stackedit__html .cs-diagram {
  margin: 1.6em 0 2em; padding: 1.4em 0;
  border-top: 1px dashed var(--border-color); border-bottom: 1px dashed var(--border-color);
  container-type: inline-size;
}
body .stackedit__html .cs-diagram pre {
  margin: 0; padding: 0; border: 0 !important; background: transparent !important; overflow: hidden;
  font-family: var(--mono) !important; font-size: min(15px, calc(100cqw / (var(--cols, 48) * 0.6))) !important;
  line-height: 1.55; min-height: calc(var(--rows, 1) * 1.55em); white-space: pre;
  color: var(--faint-color) !important;
}
body .stackedit__html .cs-diagram .m { color: var(--muted-color); }
body .stackedit__html .cs-diagram .o { color: var(--text-color); }
body .stackedit__html .cs-diagram .h { color: var(--accent); }
body .stackedit__html h2 + .cs-diagram { margin-top: .4em; }

/* "Blog Home / Site Home": a fixed inline-styled box. Give it a background so it never sits
   transparently over text, and on phones make it a slim bar along the bottom. */
body div[style*="position: fixed"][style*="bottom: 15px"] {
  background: var(--bg-color); border: 1px solid var(--border-color); padding: 4px 6px;
}
body div[style*="position: fixed"][style*="bottom: 15px"] a {
  font-family: var(--mono) !important; font-size: 13px !important; color: var(--muted-color) !important;
}
body div[style*="position: fixed"][style*="bottom: 15px"] a:hover { color: var(--text-color) !important; }
@media (max-width: 768px) {
  body div[style*="position: fixed"][style*="bottom: 15px"] {
    left: 0 !important; right: 0; bottom: 0 !important;
    flex-direction: row !important; justify-content: space-between;
    border-width: 1px 0 0; padding: 10px 16px;
  }
  body .content-wrapper { padding-bottom: 52px; }
}

/* Images follow the home page's work cards: greyscale until hovered. */
body .stackedit__html img, body .hero-image { filter: grayscale(1) contrast(1.04) brightness(.86); transition: filter .5s ease; }
body .stackedit__html img:hover, body .hero-video-container:hover .hero-image { filter: none; }
