/* Blog pages (scripts/blog.mjs writes the HTML): the homepage's colours and type, set for reading. */
:root {
  color-scheme: dark;
  --bg: #030409;
  --card: #0b1122;
  --accent: #7cc4ff;
  --accent-2: #ffb454;
  --accent-hi: #b3e5ff;
  --accent-deep: #4c96f0;
  --silver: #cdd6e6;
  --text: #eef2fa;
  --prose: #d3dbea;
  --text-2: #8e9ab3;
  --muted: #74819c;
  --border: rgba(255, 255, 255, 0.07);
  --display: 'Sora', 'Segoe UI', sans-serif;
  --body: 'Manrope', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, 'SFMono-Regular', Menlo, monospace;
  --measure: 690px;
  --gutter: 28px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  position: relative;
  min-height: 100vh;
  display: flex; flex-direction: column;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--body);
  font-size: 17px;
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
main { position: relative; z-index: 1; flex: 1; }
a { color: inherit; }
::selection { background: rgba(124, 196, 255, 0.3); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }
.wrap { width: 100%; max-width: calc(var(--measure) + 2 * var(--gutter)); margin-inline: auto; padding-inline: var(--gutter); }

.skip {
  position: absolute; left: 16px; top: -80px; z-index: 10;
  padding: 10px 16px; border-radius: 8px;
  background: var(--accent); color: #05070f;
  font-weight: 700; text-decoration: none;
}
.skip:focus { top: 12px; }

/* the homepage's black hole, dimmed, behind the top of the page */
.horizon {
  position: absolute; left: 0; right: 0; top: 0; z-index: 0;
  height: 640px;
  pointer-events: none;
  background: url("/blog/horizon.jpg") 72% 46% / cover no-repeat;
  opacity: 0.6;
  -webkit-mask-image: linear-gradient(180deg, #000 0%, rgba(0, 0, 0, 0.75) 45%, transparent 100%);
  mask-image: linear-gradient(180deg, #000 0%, rgba(0, 0, 0, 0.75) 45%, transparent 100%);
}
.horizon::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, rgba(3, 4, 9, 0.94) 0%, rgba(3, 4, 9, 0.72) 42%, rgba(3, 4, 9, 0.05) 78%);
}

/* ---------- top bar ---------- */
.bar { position: relative; z-index: 2; padding-top: env(safe-area-inset-top, 0px); }
.bar-inner { display: flex; align-items: center; gap: 28px; max-width: 1240px; margin-inline: auto; padding: 20px var(--gutter); }
.logo { margin-right: auto; font-family: var(--mono); font-weight: 600; font-size: 1rem; text-decoration: none; white-space: nowrap; }
.logo span { color: var(--accent); }
.bar-links { display: flex; align-items: center; gap: 26px; }
.bar-links a { font-size: 0.9rem; color: var(--text-2); text-decoration: none; white-space: nowrap; transition: color 0.3s, background 0.3s, border-color 0.3s; }
.bar-links a[aria-current="page"] { color: var(--text); }
.bar-links a.bar-cta { padding: 9px 18px; border: 1px solid rgba(124, 196, 255, 0.35); border-radius: 999px; color: var(--text); font-weight: 600; }
.bar-links a:focus-visible { color: var(--text); }
@media (hover: hover) {
  .bar-links a:hover { color: var(--text); }
  .bar-links a.bar-cta:hover { border-color: var(--accent); background: rgba(124, 196, 255, 0.1); }
}

/* ---------- post header ---------- */
.post-head, .index-head { padding-top: clamp(44px, 8vw, 104px); padding-bottom: 34px; }
.eyebrow {
  display: inline-flex; align-items: center; gap: 12px;
  margin: 0 0 18px;
  font-family: var(--mono); font-size: 0.72rem; font-weight: 600; line-height: 1.4;
  letter-spacing: 0.2em; text-transform: uppercase;
  color: var(--accent); text-decoration: none;
}
.eyebrow::before { content: ""; width: 28px; height: 1px; background: var(--accent); }
.post-title {
  margin: 0 0 18px;
  font-family: var(--display); font-weight: 700;
  font-size: clamp(1.95rem, 5vw, 3rem);
  line-height: 1.1; letter-spacing: -0.03em;
  text-wrap: balance;
  text-shadow: 0 2px 24px rgba(0, 0, 0, 0.6);
}
.post-lede { margin: 0 0 22px; max-width: 40em; font-size: 1.1rem; line-height: 1.65; color: var(--text-2); text-wrap: pretty; }
.post-lede a { color: var(--accent); text-underline-offset: 3px; }
.post-meta { display: flex; flex-wrap: wrap; gap: 4px 10px; margin: 0; font-family: var(--mono); font-size: 0.76rem; letter-spacing: 0.02em; color: var(--muted); }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin: 18px 0 0; padding: 0; list-style: none; }
.tags li {
  padding: 4px 10px; border-radius: 999px;
  font-family: var(--mono); font-size: 0.64rem; font-weight: 600; line-height: 1.5;
  letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--accent); background: rgba(124, 196, 255, 0.1);
}
.review-note {
  margin: 0 0 26px; padding: 10px 14px;
  border: 1px solid rgba(255, 180, 84, 0.4); border-radius: 10px;
  background: rgba(255, 180, 84, 0.08);
  color: #ffd9a6; font-size: 0.88rem; line-height: 1.55;
}

/* ---------- the article ---------- */
.prose { padding-top: 38px; color: var(--prose); }
.prose::before { content: ""; display: block; height: 1px; margin-top: -38px; margin-bottom: 38px; background: linear-gradient(90deg, rgba(124, 196, 255, 0.45), rgba(124, 196, 255, 0.08) 60%, transparent); }
.prose > * { margin-top: 0; margin-bottom: 1.3em; }
.prose h2, .prose h3, .prose h4 { position: relative; color: var(--text); font-family: var(--display); font-weight: 600; text-wrap: balance; scroll-margin-top: 24px; }
.prose h2 { margin-top: 2.1em; margin-bottom: 0.65em; font-size: 1.5rem; line-height: 1.25; letter-spacing: -0.015em; }
.prose h3 { margin-top: 1.8em; margin-bottom: 0.55em; font-size: 1.18rem; line-height: 1.35; }
.prose h4 { margin-top: 1.6em; margin-bottom: 0.5em; font-size: 1rem; }
.prose .anchor { position: absolute; left: -1.05em; width: 1em; color: var(--muted); font-weight: 400; text-decoration: none; opacity: 0; transition: opacity 0.2s; }
.prose h2:hover .anchor, .prose h3:hover .anchor, .prose h4:hover .anchor { opacity: 1; }
.prose a { color: var(--accent); text-decoration: underline; text-decoration-thickness: 1px; text-decoration-color: rgba(124, 196, 255, 0.45); text-underline-offset: 3px; transition: text-decoration-color 0.2s; }
.prose a:focus-visible { text-decoration-color: var(--accent); }
@media (hover: hover) { .prose a:hover { text-decoration-color: var(--accent); } }
.prose h2 a.anchor, .prose h3 a.anchor, .prose h4 a.anchor { color: var(--muted); text-decoration: none; }
.prose strong { color: var(--text); font-weight: 700; }
.prose ul, .prose ol { padding-left: 1.35em; }
.prose li { margin-block: 0.4em; padding-left: 0.2em; }
.prose li::marker { color: var(--accent); }
.prose li > p { margin: 0; }
.prose blockquote {
  margin-inline: 0; padding: 14px 20px;
  border-left: 2px solid var(--accent); border-radius: 0 10px 10px 0;
  background: rgba(124, 196, 255, 0.05);
  color: var(--silver);
}
.prose blockquote > :last-child { margin-bottom: 0; }
.prose hr { height: 1px; margin-block: 2.4em; border: 0; background: var(--border); }
.prose img { display: block; max-width: 100%; height: auto; border: 1px solid var(--border); border-radius: 12px; }
.prose figure { margin-inline: 0; }
.prose figcaption { margin-top: 10px; font-size: 0.85rem; color: var(--muted); text-align: center; }
.prose :not(pre) > code {
  padding: 0.12em 0.38em; border-radius: 5px;
  background: rgba(124, 196, 255, 0.08);
  color: #cfe6ff;
  font-family: var(--mono); font-size: 0.85em;
  overflow-wrap: anywhere;
  -webkit-box-decoration-break: clone; box-decoration-break: clone;
}

/* code blocks: a bar with the language and a copy button (added by blog.js), then the code */
.prose .code { margin-bottom: 1.5em; border: 1px solid var(--border); border-radius: 12px; background: var(--card); overflow: hidden; }
.code-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 36px; padding: 4px 6px 4px 16px; border-bottom: 1px solid var(--border); background: rgba(255, 255, 255, 0.015); }
.code-bar:empty { display: none; }
.code-lang { font-family: var(--mono); font-size: 0.66rem; font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); }
.copy {
  margin-left: auto; padding: 4px 11px;
  border: 1px solid rgba(255, 255, 255, 0.12); border-radius: 999px;
  background: transparent; color: var(--text-2);
  font-family: var(--mono); font-size: 0.68rem; letter-spacing: 0.04em;
  cursor: pointer; transition: color 0.2s, border-color 0.2s, background 0.2s;
}
.copy:focus-visible { color: var(--text); border-color: rgba(124, 196, 255, 0.5); }
@media (hover: hover) { .copy:hover { color: var(--text); border-color: rgba(124, 196, 255, 0.5); } }
.copy.done { border-color: var(--accent); background: var(--accent); color: #05070f; }
.prose pre {
  margin: 0; padding: 16px 18px;
  overflow-x: auto;
  color: #d6dfee;
  font-family: var(--mono); font-size: 0.82rem; line-height: 1.65;
  tab-size: 2;
  scrollbar-width: thin; scrollbar-color: rgba(255, 255, 255, 0.15) transparent;
}
.prose pre code { font: inherit; }
.prose pre:focus-visible { outline-offset: -2px; border-radius: 0 0 12px 12px; }
.prose .code.wrap pre { white-space: pre-wrap; overflow-wrap: anywhere; }
/* syntax colours from the site palette: blue for keywords, sand for strings, amber kept for numbers */
.hljs-comment, .hljs-quote { color: #818ea9; font-style: italic; }
.hljs-keyword, .hljs-selector-tag, .hljs-section, .hljs-name, .hljs-attr, .hljs-type { color: var(--accent); }
.hljs-built_in, .hljs-variable, .hljs-template-variable, .hljs-symbol, .hljs-link { color: var(--accent-hi); }
.hljs-string, .hljs-regexp, .hljs-meta .hljs-string { color: #ecc893; }
.hljs-number, .hljs-literal, .hljs-bullet { color: var(--accent-2); }
.hljs-title, .hljs-title.function_ { color: var(--text); font-weight: 600; }
.hljs-params, .hljs-subst { color: #d6dfee; }
.hljs-meta { color: var(--text-2); }
.hljs-addition { color: var(--accent-hi); background: rgba(124, 196, 255, 0.1); }
.hljs-deletion { color: #ffd3a0; background: rgba(255, 180, 84, 0.1); }
.hljs-emphasis { font-style: italic; }
.hljs-strong { font-weight: 700; }

/* a table wider than the column scrolls inside its box; the soft edges show there's more to see */
.table-wrap {
  margin-bottom: 1.5em; overflow-x: auto;
  border: 1px solid var(--border); border-radius: 12px;
  background:
    linear-gradient(90deg, var(--bg) 40%, rgba(3, 4, 9, 0)) left / 36px 100% no-repeat local,
    linear-gradient(270deg, var(--bg) 40%, rgba(3, 4, 9, 0)) right / 36px 100% no-repeat local,
    radial-gradient(farthest-side at 0 50%, rgba(124, 196, 255, 0.2), transparent) left / 14px 100% no-repeat scroll,
    radial-gradient(farthest-side at 100% 50%, rgba(124, 196, 255, 0.2), transparent) right / 14px 100% no-repeat scroll,
    var(--bg);
}
.table-wrap:focus-visible { outline-offset: -2px; }
.prose table { width: 100%; border-collapse: collapse; font-size: 0.9rem; line-height: 1.5; font-variant-numeric: tabular-nums; }
.prose th, .prose td { padding: 10px 14px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
.prose th { background: rgba(255, 255, 255, 0.02); color: var(--text-2); font-family: var(--mono); font-size: 0.68rem; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; white-space: nowrap; }
.prose th[align="center"], .prose td[align="center"] { text-align: center; }
.prose th[align="right"], .prose td[align="right"] { text-align: right; }
.prose td small { display: inline-block; margin-top: 3px; color: var(--muted); font-family: var(--mono); font-size: 0.74rem; white-space: nowrap; }
.prose tr:last-child td { border-bottom: 0; }
.prose td code { white-space: nowrap; }

/* ---------- after the article ---------- */
.post-foot { margin-top: 56px; }
.author {
  padding: 24px 26px;
  border: 1px solid var(--border); border-radius: 16px;
  background: radial-gradient(circle at 92% 0%, rgba(124, 196, 255, 0.12), transparent 55%), var(--card);
}
.author-name { margin: 0 0 6px; font-family: var(--display); font-weight: 600; font-size: 1.08rem; }
.author-role { margin: 0 0 14px; color: var(--text-2); font-size: 0.95rem; line-height: 1.6; }
.author-links, .share { display: flex; flex-wrap: wrap; gap: 8px 20px; margin: 0; font-family: var(--mono); font-size: 0.76rem; }
.author-links a { color: var(--accent); text-decoration: none; border-bottom: 1px solid rgba(124, 196, 255, 0.3); overflow-wrap: anywhere; transition: border-color 0.2s; }
.share { justify-content: space-between; margin-top: 20px; }
.share a { color: var(--text-2); text-decoration: none; transition: color 0.2s; }
@media (hover: hover) {
  .author-links a:hover { border-color: var(--accent); }
  .share a:hover { color: var(--text); }
}

.more { margin-top: 72px; }
.more-title { margin: 0 0 14px; font-family: var(--mono); font-size: 0.72rem; font-weight: 600; letter-spacing: 0.2em; text-transform: uppercase; color: var(--accent); }

/* ---------- lists of posts ---------- */
.entries { margin: 0; padding: 0; list-style: none; border-top: 1px solid var(--border); }
.entry-link {
  display: grid; grid-template-columns: 7.2em minmax(0, 1fr) auto; align-items: baseline; gap: 6px 24px;
  padding: 22px 4px;
  border-bottom: 1px solid var(--border);
  text-decoration: none;
  transition: padding 0.4s cubic-bezier(0.16, 1, 0.3, 1), background 0.3s;
}
.entry-date, .entry-read { font-family: var(--mono); font-size: 0.72rem; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.entry-read { color: var(--text-2); }
.entry-title { margin: 0 0 4px; font-family: var(--display); font-weight: 600; font-size: 1.14rem; line-height: 1.3; letter-spacing: -0.01em; color: var(--text); text-wrap: balance; transition: color 0.3s; }
.entry-desc { display: block; font-size: 0.93rem; line-height: 1.6; color: var(--text-2); }
.entry-link:focus-visible { outline-offset: -2px; }
.entry-link:focus-visible .entry-title { color: var(--accent-hi); }
@media (hover: hover) {
  .entry-link:hover { padding-inline: 14px; background: rgba(124, 196, 255, 0.03); }
  .entry-link:hover .entry-title { color: var(--accent-hi); }
}
.empty { margin: 0; padding: 22px 0; border-top: 1px solid var(--border); color: var(--text-2); }

.site-foot { position: relative; z-index: 1; margin-top: 88px; border-top: 1px solid var(--border); }
.foot-inner {
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px;
  max-width: 1240px; margin-inline: auto;
  padding: 26px var(--gutter) calc(26px + env(safe-area-inset-bottom, 0px));
  font-size: 0.85rem; color: var(--muted);
}
.foot-links { display: flex; flex-wrap: wrap; gap: 8px 22px; }
.foot-links a { color: var(--text-2); text-decoration: none; transition: color 0.2s; }
@media (hover: hover) { .foot-links a:hover { color: var(--text); } }

/* ---------- smaller screens ---------- */
@media (max-width: 760px) {
  .prose .anchor { display: none; }
}
@media (max-width: 640px) {
  :root { --gutter: 18px; }
  body { font-size: 16.5px; }
  .bar-inner { gap: 16px; padding-block: 16px; }
  .bar-links { gap: 18px; }
  .bar-links .hide-sm { display: none; }
  .bar-links a.bar-cta { padding: 8px 14px; font-size: 0.85rem; }
  /* phones: the black hole sits at the top of the screen, and the title starts below its brightest part */
  .horizon { height: 380px; opacity: 0.5; background-position: 70% 50%; }
  .horizon::after { background: linear-gradient(180deg, rgba(3, 4, 9, 0.2) 0%, rgba(3, 4, 9, 0.55) 45%, rgba(3, 4, 9, 0.9) 100%); }
  .post-head, .index-head { padding-top: 96px; }
  .post-lede { font-size: 1.03rem; }
  .entry-link { grid-template-columns: minmax(0, 1fr); gap: 6px; padding-block: 20px; }
  .entry-read { order: 3; }
  .author { padding: 20px; }
  .prose pre { font-size: 0.78rem; }
  .prose th, .prose td { padding: 9px 11px; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
@media print {
  :root { color-scheme: light; --bg: #fff; --card: #fff; --text: #111; --prose: #222; --text-2: #444; --muted: #555; --border: #ccc; --accent: #1d5f9e; }
  body { background: #fff; font-size: 11pt; }
  .horizon, .bar, .site-foot, .more, .share, .copy, .skip, .review-note { display: none !important; }
  .post-title { text-shadow: none; }
  .prose pre { white-space: pre-wrap; }
  .prose pre, .prose pre * { color: #111 !important; }
  .prose :not(pre) > code { color: #111; background: #eee; }
  .code, .table-wrap, .author { break-inside: avoid; }
  .tags li { color: #111; background: #eee; }
}

/* ---------- diagrams (inline SVG + a CSS timeline, authored in the post) ---------- */
.prose .diagram { margin: 2em 0; padding: 20px 20px 14px; border: 1px solid var(--border); border-radius: 14px; background: var(--card); }
.prose .diagram svg { display: block; width: 100%; height: auto; max-width: 540px; margin-inline: auto; overflow: visible; }
.prose .diagram figcaption { margin-top: 12px; text-align: center; font-size: 0.82rem; color: var(--muted); }
/* nodes */
.d-node rect, rect.d-node { fill: rgba(124, 196, 255, 0.06); stroke: rgba(124, 196, 255, 0.4); stroke-width: 1.2; }
.d-safe rect, rect.d-safe { fill: rgba(124, 196, 255, 0.07); stroke: rgba(124, 196, 255, 0.5); stroke-width: 1.2; }
.d-bad rect, rect.d-bad { fill: rgba(255, 180, 84, 0.07); stroke: rgba(255, 180, 84, 0.55); stroke-width: 1.2; }
/* text */
.d-title { fill: var(--text); font-family: var(--display); font-weight: 600; font-size: 16px; }
.d-text { fill: var(--prose); font-family: var(--mono); font-size: 14px; }
.d-tag { fill: var(--muted); font-family: var(--mono); font-size: 13px; }
.d-note { fill: var(--text-2); font-family: var(--mono); font-size: 13px; }
.d-bad-tag { fill: #ffc780; font-family: var(--mono); font-size: 13px; }
.d-div { stroke: var(--border); stroke-width: 1; }
/* flows */
.d-flow { fill: none; stroke: rgba(124, 196, 255, 0.55); stroke-width: 1.6; }
.d-flow-bad { fill: none; stroke: rgba(255, 180, 84, 0.6); stroke-width: 1.6; }
.d-ring { fill: none; stroke: var(--border); stroke-width: 1; stroke-dasharray: 4 6; }

/* a vertical timeline, built from an ordered list so it reflows on any width */
.prose .timeline { margin: 2em 0; padding: 0; list-style: none; }
.prose .timeline li { position: relative; margin: 0; padding: 0 0 22px 28px; border-left: 1px solid var(--border); }
.prose .timeline li:last-child { padding-bottom: 0; border-left-color: transparent; }
.prose .timeline li::before { content: ""; position: absolute; left: -5px; top: 4px; width: 9px; height: 9px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 4px var(--bg); }
.prose .timeline li.bad::before { background: var(--accent-2); }
.prose .t-when { display: block; margin-bottom: 2px; font-family: var(--mono); font-size: 0.74rem; letter-spacing: 0.04em; color: var(--accent); }
.prose .timeline li.bad .t-when { color: var(--accent-2); }
.prose .t-what { display: block; color: var(--prose); }

@media (max-width: 640px) {
  .prose .diagram { padding: 14px 12px 10px; }
}
@media print {
  .prose .diagram { background: #0b1122; -webkit-print-color-adjust: exact; print-color-adjust: exact; break-inside: avoid; }
  .prose .timeline li { break-inside: avoid; }
}

/* second flow colour, for the persistence loop */
.d-flow2 { fill: none; stroke: rgba(205, 214, 230, 0.5); stroke-width: 1.6; }

/* TL;DR dropdown (native <details>, no JS) */
.prose details.tldr { margin: 1.6em 0 2em; border: 1px solid rgba(124, 196, 255, 0.22); border-radius: 12px; background: rgba(124, 196, 255, 0.04); overflow: hidden; }
.prose details.tldr > summary { cursor: pointer; list-style: none; display: flex; align-items: center; gap: 10px; padding: 13px 18px; font-family: var(--mono); font-size: 0.72rem; font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase; color: var(--accent); }
.prose details.tldr > summary::-webkit-details-marker { display: none; }
.prose details.tldr > summary::before { content: "▸"; font-size: 0.9em; color: var(--text-2); transition: transform 0.2s ease; }
.prose details.tldr[open] > summary::before { transform: rotate(90deg); }
.prose details.tldr[open] > summary { border-bottom: 1px solid var(--border); }
.prose details.tldr > summary:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.prose .tldr-body { padding: 10px 18px 14px; }
.prose .tldr-body ol { margin: 0; padding-left: 1.3em; }
.prose .tldr-body li { margin-block: 0.5em; color: var(--prose); }
.prose .tldr-body li::marker { color: var(--accent); font-family: var(--mono); font-size: 0.85em; }
