/* Styles for blog pages. Same palette and display font as the home page;
   body text uses a proportional font because long articles in a monospace
   face are tiring to read. */

:root {
  --bg: #080c10;
  --bg2: #0d1117;
  --bg3: #111820;
  --border: rgba(0, 230, 160, 0.12);
  --border2: rgba(0, 230, 160, 0.25);
  --green: #00e6a0;
  --green-dim: rgba(0, 230, 160, 0.08);
  --amber: #ffb347;
  --blue: #4fc3f7;
  --text: #e2e8f0;
  --text-muted: #8a98a9;
  --font-body: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, monospace;
  --font-display: "Syne", sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.75 var(--font-body);
}

a { color: var(--green); text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }
a:focus-visible { outline: 2px solid var(--green); outline-offset: 3px; border-radius: 3px; }

.skip-link {
  position: absolute; left: -999px; top: 0;
  background: var(--green); color: var(--bg); padding: 8px 14px; z-index: 10;
}
.skip-link:focus { left: 0; }

/* Top bar */
.site-nav {
  display: flex; align-items: center; justify-content: space-between;
  max-width: 1100px; margin: 0 auto; padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  font-family: var(--font-mono); font-size: 13px;
}
/* Logo: KD in code braces, the same as the favicon and the home page. */
.site-nav .logo { display: inline-flex; line-height: 0; border-radius: 8px; }

.site-nav ul { display: flex; gap: 24px; margin: 0; padding: 0; list-style: none; }
.site-nav ul a { color: var(--text-muted); text-decoration: none; letter-spacing: 1px; text-transform: uppercase; }
.site-nav ul a:hover, .site-nav ul a[aria-current="page"] { color: var(--green); }

main { max-width: 760px; margin: 0 auto; padding: 48px 24px 80px; }

/* Article */
.post-meta {
  font-family: var(--font-mono); font-size: 13px; color: var(--text-muted);
  margin: 0 0 12px;
}
h1 {
  font-family: var(--font-display); font-weight: 800;
  font-size: clamp(30px, 5vw, 44px); line-height: 1.15; letter-spacing: -0.5px;
  margin: 0 0 16px;
}
.lede { font-size: 19px; color: var(--text-muted); margin: 0 0 40px; }
h2 {
  font-family: var(--font-display); font-weight: 700; font-size: 26px; line-height: 1.25;
  margin: 56px 0 16px; padding-top: 8px; border-top: 1px solid var(--border);
}
h3 { font-family: var(--font-display); font-weight: 700; font-size: 20px; margin: 32px 0 8px; }
p, ul, ol { margin: 0 0 18px; }
li { margin: 6px 0; }
li::marker { color: var(--green); }
strong { color: #fff; font-weight: 600; }

code {
  font-family: var(--font-mono); font-size: 0.86em; font-variant-ligatures: none;
  background: var(--bg3); border: 1px solid var(--border);
  padding: 1px 5px; border-radius: 4px; color: var(--blue);
}
pre {
  background: var(--bg2); border: 1px solid var(--border); border-radius: 8px;
  padding: 16px 18px; overflow-x: auto; margin: 0 0 22px;
  font: 14px/1.6 var(--font-mono);
  /* Show == and -> as typed; ligatures hide the real characters. */
  font-variant-ligatures: none;
}
pre code { background: none; border: 0; padding: 0; color: var(--text); font-size: inherit; }

/* Syntax highlighting (highlight.js), using the site palette. */
.hljs-keyword, .hljs-selector-tag, .hljs-built_in.hljs-keyword, .hljs-meta .hljs-keyword { color: var(--green); }
.hljs-string, .hljs-regexp, .hljs-template-string, .hljs-addition { color: var(--amber); }
.hljs-number, .hljs-literal, .hljs-symbol, .hljs-bullet, .hljs-variable.constant_ { color: var(--blue); }
.hljs-title, .hljs-title.function_, .hljs-title.class_, .hljs-section { color: #c4b5fd; }
.hljs-meta, .hljs-decorator, .hljs-tag { color: #c4b5fd; }
.hljs-attr, .hljs-attribute, .hljs-property, .hljs-params, .hljs-name { color: #7dd3fc; }
.hljs-built_in, .hljs-type, .hljs-variable, .hljs-template-variable { color: #5eead4; }
.hljs-comment, .hljs-quote { color: #6b7a8c; font-style: italic; }
.hljs-deletion { color: #f87171; }
.hljs-emphasis { font-style: italic; }
.hljs-strong { font-weight: 700; }

/* Tables of facts that share a shape */
.table-wrap { overflow-x: auto; margin: 0 0 24px; }
table { width: 100%; border-collapse: collapse; font-size: 15px; }
th, td { text-align: left; vertical-align: top; padding: 10px 12px; border-bottom: 1px solid var(--border); }
th { font-family: var(--font-mono); font-size: 12px; letter-spacing: 1px; text-transform: uppercase; color: var(--amber); font-weight: 500; }

figure { margin: 28px 0 32px; }
figure a { display: block; }
figure img {
  display: block; width: 100%; height: auto;
  background: var(--bg2); border: 1px solid var(--border); border-radius: 8px;
}
figcaption { font-size: 14px; color: var(--text-muted); margin-top: 8px; }

.callout {
  border-left: 3px solid var(--amber); background: var(--bg3);
  padding: 14px 18px; border-radius: 0 8px 8px 0; margin: 0 0 22px;
}
.callout p:last-child { margin-bottom: 0; }

.sources li { font-size: 15px; }


.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* The blog index is wider than an article, so the grid has room. */
main.index { max-width: 1040px; }

/* Topic colours, used by the tiles and chips. */
.topic-fintech { --topic: var(--amber); }
.topic-python  { --topic: var(--green); }
.topic-tooling { --topic: #c4b5fd; }

/* Terminal-style header. */
.blog-head { margin-bottom: 28px; }
.prompt {
  font-family: var(--font-mono); font-size: clamp(22px, 4vw, 30px); font-weight: 500;
  color: var(--text); margin: 0 0 12px;
}
.prompt-sign { color: var(--green); }
.caret {
  display: inline-block; width: 0.55em; height: 1.05em; margin-left: 6px; vertical-align: -0.15em;
  background: var(--green); animation: caret-blink 1.1s steps(1) infinite;
}
@keyframes caret-blink { 50% { opacity: 0; } }
.stats { display: flex; flex-wrap: wrap; gap: 6px 18px; margin: 0 0 16px; font-family: var(--font-mono); font-size: 13px; color: var(--text-muted); }
.stats span::before { content: "# "; color: var(--green); }
.blog-head .lede { margin: 0; }

/* Topic filter chips: shown only when JavaScript can make them work. */
.filters { display: none; flex-wrap: wrap; gap: 10px; margin: 0 0 32px; }
.js .filters { display: flex; }
.chip {
  font: 500 12px/1 var(--font-mono); letter-spacing: 1px; text-transform: uppercase;
  color: var(--text-muted); background: transparent; cursor: pointer;
  border: 1px solid var(--border2); border-radius: 999px; padding: 8px 14px;
  transition: color .15s, border-color .15s, background .15s;
}
.chip .count { color: var(--text-muted); margin-left: 4px; opacity: .8; }
.chip:hover { color: var(--text); border-color: var(--topic, var(--green)); }
.chip[aria-pressed="true"] {
  color: var(--bg); background: var(--topic, var(--green)); border-color: var(--topic, var(--green));
}
.chip[aria-pressed="true"] .count { color: var(--bg); }
.chip:focus-visible { outline: 2px solid var(--green); outline-offset: 3px; }

/* Bento grid of posts: the newest is the big tile, every tile shows a faint
   code sample from its post and lifts in its topic colour on hover. */
.bento {
  list-style: none; margin: 0; padding: 0;
  display: grid; grid-template-columns: 1.3fr 1fr 1fr; grid-auto-rows: 250px; gap: 18px;
}
.tile { margin: 0; min-width: 0; }
.tile-big { grid-row: span 2; }
.tile-wide { grid-column: span 2; }
.bento.is-filtered .tile-big, .bento.is-filtered .tile-wide { grid-row: auto; grid-column: auto; }
.tile a {
  position: relative; display: flex; flex-direction: column; justify-content: flex-end; height: 100%;
  padding: 20px; border: 1px solid var(--border); border-radius: 12px; background: var(--bg2);
  color: var(--text); text-decoration: none; overflow: hidden;
  transition: transform .2s ease, border-color .2s ease, box-shadow .2s ease;
}
.tile a::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  z-index: 1; background: linear-gradient(to top, var(--bg2) 52%, transparent 80%);
}
.tile a > .tile-meta, .tile a > .tile-title, .tile a > .tile-summary, .tile a > .tile-date { position: relative; z-index: 2; }
.tile a:hover, .tile a:focus-visible {
  transform: translateY(-4px); border-color: var(--topic, var(--green));
  box-shadow: 0 12px 30px -18px var(--topic, var(--green));
}
.tile a:focus-visible { outline: none; }
.tile .tile-code {
  position: absolute; z-index: 0; top: 18px; left: 20px; right: 70px; max-height: 42%; margin: 0; padding: 0;
  border: 0; background: none; overflow: hidden; white-space: pre;
  font: 12px/1.6 var(--font-mono); color: #4d5a69;
}
.tile a:hover .tile-code { color: #6d7d8f; }
.tile a > .tile-num {
  position: absolute; z-index: 2; top: 10px; right: 14px; font: 800 56px/1 var(--font-display);
  color: var(--topic, var(--green)); opacity: .16; transition: opacity .2s;
}
.tile a:hover .tile-num { opacity: .4; }
.tile-meta {
  font: 500 11px/1 var(--font-mono); letter-spacing: 1.5px; text-transform: uppercase;
  color: var(--topic, var(--green)); margin-bottom: 8px;
}
.tile-latest {
  display: inline-block; margin-right: 8px; padding: 3px 7px; border-radius: 4px;
  background: var(--topic, var(--green)); color: var(--bg); letter-spacing: 1px;
}
.tile-title { font: 700 17px/1.3 var(--font-display); }
.tile-big .tile-title { font-size: 28px; line-height: 1.2; }
.tile-big .tile-code { max-height: 55%; font-size: 13px; }
.tile-summary { display: none; color: var(--text-muted); font-size: 14px; margin-top: 8px; }
.tile-big .tile-summary, .tile-wide .tile-summary { display: block; }
.tile-date { font: 12px/1 var(--font-mono); color: var(--text-muted); margin-top: 10px; }
.empty-note { color: var(--text-muted); font-family: var(--font-mono); font-size: 14px; }

@media (max-width: 800px) {
  .bento { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tile-big { grid-column: span 2; grid-row: span 1; }
}
@media (max-width: 560px) {
  .bento { grid-template-columns: minmax(0, 1fr); grid-auto-rows: minmax(190px, auto); }
  .tile-big, .tile-wide { grid-column: auto; }
  .tile-big .tile-title { font-size: 22px; }
  /* Tiles grow with their text here, so the code sits above it, not behind it. */
  .tile .tile-code, .tile-big .tile-code {
    position: static; max-height: 4.8em; max-width: 100%; margin: 0 0 14px; font-size: 11.5px;
  }
  .tile a::after { display: none; }
  .tile a > .tile-num { font-size: 44px; }
}
@media (prefers-reduced-motion: reduce) {
  .caret { animation: none; }
  .tile a, .tile-num, .chip { transition: none; }
  .tile a:hover { transform: none; }
}

.post-topic {
  font-family: var(--font-mono); font-size: 12px; color: var(--amber);
  text-transform: uppercase; letter-spacing: 1px; margin: 0 0 10px;
}

footer {
  /* Same width as the top bar, so the two frame the page; text centred. */
  max-width: 1100px; margin: 0 auto; padding: 24px; border-top: 1px solid var(--border);
  font-family: var(--font-mono); font-size: 12px; color: var(--text-muted); text-align: center;
}

@media (max-width: 640px) {
  body { font-size: 16px; }
  .site-nav ul { gap: 14px; }
  main { padding-top: 32px; }
}
