/* Blog layout on top of organic.css (the Organic design system tokens + components, shared with the portfolio).
   One reading column everywhere; the colours and fonts come from the portfolio, the layout doesn't. */

:root { --measure: 720px; --gutter: 20px; }

html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  display: flex; flex-direction: column;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-body);
  font-size: 16px;
}
main { flex: 1; padding-bottom: 72px; }
a { color: var(--color-accent-700); text-decoration-color: var(--color-accent-400); text-decoration-thickness: 1.5px; }
a:hover { color: var(--color-accent-800); text-decoration-color: currentColor; }

.icon { fill: none; stroke: currentColor; stroke-width: 2.25; stroke-linecap: round; stroke-linejoin: round; }
.wrap { max-width: calc(var(--measure) + 2 * var(--gutter)); margin: 0 auto; padding: 0 var(--gutter); }

.skip-link { position: absolute; left: -9999px; top: 8px; z-index: 50; background: var(--color-text); color: var(--color-bg); padding: 8px 14px; border-radius: 8px; }
.skip-link:focus { left: 8px; }

/* ── Header ── */
.site-header { border-bottom: 1px solid var(--color-divider); }
.site-header-inner {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: 8px 24px;
  padding-top: 18px; padding-bottom: 18px;
}
.site-brand { font-family: var(--font-heading); font-size: 21px; color: var(--color-text); text-decoration: none; }
.site-brand:hover { color: var(--color-accent-700); }
.site-nav { display: flex; align-items: center; gap: 4px 18px; flex-wrap: wrap; font-size: 15.5px; }
.site-nav a { color: var(--color-neutral-800); text-decoration: none; padding: 4px 0; }
.site-nav a:hover, .site-nav a[aria-current="page"] { color: var(--color-accent-700); }
.site-nav a[aria-current="page"] { font-weight: 600; }
.site-nav-icon { display: inline-flex; }

/* ── Footer ── */
.site-footer { border-top: 1px solid var(--color-divider); font-size: 14px; color: var(--color-neutral-700); }
.site-footer-inner { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 24px; padding-top: 24px; padding-bottom: 32px; }
.site-footer nav { display: flex; flex-wrap: wrap; gap: 4px 16px; }
.site-footer a { color: inherit; text-decoration: none; }
.site-footer a:hover { color: var(--color-accent-700); }

/* ── Page headings ── */
.intro, .page-head { padding: clamp(40px, 7vw, 64px) 0 clamp(24px, 4vw, 36px); }
.intro h1, .page-head h1 { font-size: clamp(32px, 5vw, 44px); line-height: 1.1; margin: 0 0 12px; text-wrap: balance; overflow-wrap: anywhere; }
.intro p, .page-head p { font-size: 17.5px; line-height: 1.6; color: var(--color-neutral-800); margin: 0; text-wrap: pretty; }
.back-link { display: inline-block; font-size: 14.5px; margin-bottom: 16px; text-decoration: none; }
.empty { font-size: 17px; color: var(--color-neutral-700); }

/* ── Tags ── */
.tag-list { display: flex; flex-wrap: wrap; gap: 6px; }
.tag-list .tag { font-size: 12.5px; text-decoration: none; }
.tag-list a.tag:hover { background: var(--color-accent-200); color: var(--color-accent-800); }

/* Topic filter on the home page */
.filter { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.filter-chip {
  font: inherit; font-size: 13.5px; font-weight: 600;
  cursor: pointer;
  padding: 5px 12px;
  border-radius: 999px;
  border: 1px solid var(--color-divider);
  background: transparent;
  color: var(--color-text);
}
.filter-chip span { font-weight: 400; color: var(--color-neutral-600); margin-left: 2px; }
.filter-chip:hover { background: color-mix(in srgb, var(--color-text) 7%, transparent); }
.filter-chip[aria-pressed="true"] { background: var(--color-text); border-color: var(--color-text); color: var(--color-bg); }
.filter-chip[aria-pressed="true"] span { color: var(--color-neutral-400); }

/* ── Post list (home, topic pages) ── */
.post-list { list-style: none; margin: 0; padding: 0; }
.post-item { padding: 28px 0; border-bottom: 1px solid var(--color-divider); }
.post-item:last-child { border-bottom: 0; }
.post-item[hidden] { display: none; }
.post-item-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 14px; color: var(--color-neutral-700); margin-bottom: 6px; }
.post-item-title { font-size: clamp(22px, 3vw, 26px); line-height: 1.2; margin: 0 0 8px; text-wrap: balance; }
.post-item-title a { color: var(--color-text); text-decoration: none; }
.post-item-title a:hover { color: var(--color-accent-700); }
.post-item-desc { font-size: 16.5px; line-height: 1.6; color: var(--color-neutral-800); margin: 0 0 12px; text-wrap: pretty; }

/* ── Archive (All posts) ── */
.archive + .archive { margin-top: 36px; }
.archive-year { font-size: 22px; margin: 0 0 8px; color: var(--color-neutral-700); }
.archive-list { list-style: none; margin: 0; padding: 0; }
.archive-list li { display: grid; grid-template-columns: 110px 1fr; gap: 4px 16px; padding: 10px 0; border-bottom: 1px solid var(--color-divider); font-size: 17px; line-height: 1.45; }
.archive-list time { font-size: 14.5px; color: var(--color-neutral-700); padding-top: 2px; }
.archive-list a { color: var(--color-text); text-decoration: none; }
.archive-list a:hover { color: var(--color-accent-700); }
@media (max-width: 480px) {
  .archive-list li { grid-template-columns: 1fr; gap: 2px; }
}

/* ── Topics ── */
.topic-list { list-style: none; margin: 0; padding: 0; }
.topic-list a {
  display: flex; justify-content: space-between; align-items: baseline; gap: 16px;
  padding: 12px 0; border-bottom: 1px solid var(--color-divider);
  font-size: 18px; color: var(--color-text); text-decoration: none;
}
.topic-list a:hover { color: var(--color-accent-700); }
.topic-count { font-size: 14px; color: var(--color-neutral-700); }

/* ── Post page ── */
.post-head { padding-top: clamp(40px, 7vw, 64px); }
.post-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 14.5px; color: var(--color-neutral-700); margin-bottom: 12px; }
.post-head h1 { font-size: clamp(32px, 5vw, 46px); line-height: 1.1; letter-spacing: -0.015em; margin: 0 0 16px; text-wrap: balance; }
.post-lead { font-size: clamp(17.5px, 2vw, 20px); line-height: 1.55; color: var(--color-neutral-800); margin: 0 0 18px; text-wrap: pretty; }
.post-cover { margin-top: 32px; }
.post-cover img { width: 100%; max-height: 520px; object-fit: cover; border-radius: var(--radius-lg); }

/* Body, with an optional table of contents beside it on wide screens */
.post-body { margin-top: clamp(32px, 5vw, 48px); padding: 0 var(--gutter); }
.post-body.has-toc { display: grid; grid-template-columns: minmax(0, 1fr); gap: 24px; }
@media (min-width: 1180px) {
  .post-body.has-toc { grid-template-columns: minmax(0, 1fr) minmax(0, var(--measure)) minmax(0, 1fr); column-gap: 48px; }
  .post-body.has-toc .prose { grid-column: 2; grid-row: 1; }
  .post-body.has-toc .toc { grid-column: 3; grid-row: 1; align-self: start; position: sticky; top: 32px; max-width: 260px; margin: 0; }
}

/* Table of contents */
.toc {
  width: 100%; max-width: var(--measure); margin: 0 auto;
  border: 1px solid var(--color-divider);
  border-radius: var(--radius-md);
  padding: 12px 18px;
  font-size: 15px;
}
.toc summary {
  cursor: pointer; list-style: none;
  font-size: 13px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--color-neutral-700);
  display: flex; justify-content: space-between; align-items: center;
}
.toc summary::-webkit-details-marker { display: none; }
.toc summary::after { content: "+"; font-size: 20px; line-height: 1; color: var(--color-accent-600); }
.toc[open] summary::after { content: "−"; }
.toc ol { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.toc a {
  display: block; padding: 5px 0 5px 12px;
  border-left: 2px solid var(--color-divider);
  color: var(--color-neutral-800); text-decoration: none; line-height: 1.35;
}
.toc a:hover { color: var(--color-text); border-left-color: var(--color-neutral-500); }
.toc a[aria-current="true"] { color: var(--color-accent-700); font-weight: 600; border-left-color: var(--color-accent); }
@media (min-width: 1180px) {
  .toc { border: 0; padding: 4px 0 0; }
  .toc summary { cursor: default; pointer-events: none; }
  .toc summary::after, .toc[open] summary::after { content: none; }
}

/* Series box at the top of a multi-part post */
.series {
  border-left: 3px solid var(--color-accent);
  background: var(--color-accent-100);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  padding: 16px 22px;
  font-size: 15.5px;
  line-height: 1.5;
}
.series-label { font-size: 13px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: var(--color-accent-700); }
.series-name { font-family: var(--font-heading); font-size: 20px; line-height: 1.2; margin: 2px 0 8px; }
.series ol { margin: 0; padding-left: 1.3em; }
.series li + li { margin-top: 0.2em; }
.series li::marker { color: var(--color-accent-700); font-weight: 700; }
.series [aria-current="page"] { font-weight: 700; }

/* Reading progress along the top edge of post pages */
.read-progress { position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 40; pointer-events: none; }
.read-progress span { display: block; height: 100%; background: var(--color-accent); transform-origin: 0 50%; transform: scaleX(0); }

/* Article text */
.prose {
  max-width: var(--measure);
  margin: 0 auto;
  width: 100%;
  font-size: 18px;
  line-height: 1.75;
  color: var(--color-neutral-900);
  overflow-wrap: break-word;
}
.prose > * + * { margin-top: 1.2em; }
.prose p { margin-bottom: 0; text-wrap: pretty; } /* top margin comes from the rule above */
.prose h2, .prose h3, .prose h4 { margin: 2em 0 0; scroll-margin-top: 24px; line-height: 1.2; }
.prose h2 { font-size: clamp(25px, 3vw, 30px); }
.prose h3 { font-size: clamp(21px, 2.3vw, 23px); }
.prose h4 { font-size: 19px; }
.prose h2 + *, .prose h3 + *, .prose h4 + * { margin-top: 0.6em; }
.heading-anchor {
  margin-left: 0.3em; padding: 0 0.15em;
  color: var(--color-accent-400); text-decoration: none; font-family: var(--font-body); font-weight: 700;
  opacity: 0; transition: opacity 0.15s ease;
}
.prose h2:hover .heading-anchor, .prose h3:hover .heading-anchor, .heading-anchor:focus-visible { opacity: 1; }
@media (hover: none) { .heading-anchor { display: none; } }
.prose strong { font-weight: 700; }
.prose ul, .prose ol { margin-bottom: 0; padding-left: 1.4em; }
.prose li + li { margin-top: 0.35em; }
.prose li::marker { color: var(--color-accent); }
.prose hr { height: 1px; border: 0; background: var(--color-divider); margin: 2.4em 0; }
.prose blockquote {
  margin-left: 0; margin-right: 0;
  padding: 4px 0 4px 22px;
  border-left: 3px solid var(--color-accent-2-500);
  color: var(--color-accent-2-900);
  font-style: italic;
}
.prose blockquote > * + * { margin-top: 0.8em; }
.prose img { border-radius: var(--radius-md); margin-left: auto; margin-right: auto; }
.prose figure img { width: 100%; }
.prose figcaption, .prose img + em { display: block; font-size: 14px; text-align: center; color: var(--color-neutral-700); margin-top: 10px; }
.prose table { width: 100%; border-collapse: collapse; font-size: 16px; display: block; overflow-x: auto; }
.prose th { text-align: left; font-size: 13px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--color-neutral-700); padding: 10px 14px 10px 0; border-bottom: 1.5px solid var(--color-divider); }
.prose td { padding: 10px 14px 10px 0; border-bottom: 1px solid var(--color-divider); vertical-align: top; }

/* Code: inline chips + dark blocks with Organic-coloured syntax */
.prose :not(pre) > code {
  font-family: ui-monospace, "Cascadia Code", "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.86em;
  padding: 2px 6px;
  border-radius: 6px;
  background: var(--color-accent-100);
  color: var(--color-accent-800);
}
.prose pre[class*="language-"], .prose pre {
  margin-left: 0; margin-right: 0;
  padding: 20px 24px;
  border-radius: var(--radius-md);
  background: var(--color-neutral-900);
  color: var(--color-neutral-200);
  overflow-x: auto;
  font-size: 14.5px;
  line-height: 1.65;
  tab-size: 2;
}
/* Copy button + language label, added by script.js around each code block */
.code-block { position: relative; }
.code-block > pre { margin-top: 0; padding-top: 44px; }
.code-tools { position: absolute; top: 10px; right: 12px; z-index: 1; display: flex; align-items: center; gap: 8px; }
.code-lang { font-size: 12px; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; color: var(--color-neutral-500); }
.code-copy {
  font: inherit; font-size: 12.5px; font-weight: 600;
  cursor: pointer;
  padding: 4px 11px;
  border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--color-neutral-200) 25%, transparent);
  background: color-mix(in srgb, var(--color-neutral-200) 10%, transparent);
  color: var(--color-neutral-200);
}
.code-copy:hover { background: color-mix(in srgb, var(--color-neutral-200) 20%, transparent); }
.code-copy.copied { color: var(--color-accent-2-300); border-color: var(--color-accent-2-400); }
/* Prism token classes that collide with page classes (.section, .tag) */
.prose pre :where(.section, .tag) { display: inline; padding: 0; margin: 0; border: 0; border-radius: 0; background: none; font: inherit; }
.prose pre code { font-family: ui-monospace, "Cascadia Code", "SF Mono", Menlo, Consolas, monospace; background: none; padding: 0; }
.token.comment, .token.prolog, .token.doctype, .token.cdata { color: var(--color-neutral-500); font-style: italic; }
.token.punctuation, .token.operator { color: var(--color-neutral-400); }
.token.keyword, .token.atrule, .token.important, .token.selector { color: var(--color-accent-400); }
.token.string, .token.char, .token.attr-value, .token.regex, .token.inserted { color: var(--color-accent-2-300); }
.token.number, .token.boolean, .token.constant, .token.symbol { color: var(--color-accent-300); }
.token.function, .token.class-name, .token.builtin { color: #f3d9a4; }
.token.tag, .token.property, .token.attr-name, .token.variable { color: var(--color-accent-300); }
.token.deleted { color: #f19b8b; }

/* Phones: slightly smaller body text and tighter code blocks */
@media (max-width: 600px) {
  :root { --gutter: 18px; }
  .prose { font-size: 17px; line-height: 1.7; }
  .prose pre[class*="language-"], .prose pre { padding: 16px 18px; font-size: 13.5px; }
  .code-block > pre { padding-top: 44px; }
  .prose table { font-size: 15px; }
}

/* Older / newer */
.post-nav {
  display: grid; grid-template-columns: 1fr 1fr; gap: 16px;
  margin-top: 56px; padding-top: 24px;
  border-top: 1px solid var(--color-divider);
}
.post-nav-link { display: flex; flex-direction: column; gap: 4px; text-decoration: none; color: var(--color-text); }
.post-nav-next { text-align: right; }
.post-nav-label { font-size: 13.5px; font-weight: 600; color: var(--color-neutral-700); }
.post-nav-title { font-family: var(--font-heading); font-size: 18px; line-height: 1.25; }
.post-nav-link:hover .post-nav-title { color: var(--color-accent-700); }
@media (max-width: 520px) {
  .post-nav { grid-template-columns: 1fr; }
  .post-nav-next { text-align: left; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .read-progress { display: none; }
}
