/* The blog (src/modules/blog/render): the site's theme, tuned for reading. Loaded after styles.css, on blog pages and
   static pages only. Colours come from the tokens in styles.css. */

.blog-main, .post-main { --read: 42rem; max-width: var(--max); margin: 0 auto; padding: 0 var(--gutter) 24px; }
.crumbs { font-size: 0.85rem; color: var(--muted); margin-bottom: 14px; display: flex; flex-wrap: wrap; gap: 6px; }
.crumbs a { color: var(--muted); }
.crumbs a:hover { color: var(--text); }

/* ---- list pages ---------------------------------------------------------------------------------------------- */
.blog-hero { padding-block: clamp(40px, 8vw, 88px) clamp(24px, 4vw, 40px); max-width: 760px; }
.blog-hero h1 { font-size: clamp(2.3rem, 6vw, 3.6rem); line-height: 1.05; letter-spacing: -0.02em; margin-bottom: 14px; }
.blog-hero .lead { font-size: clamp(1.02rem, 2.2vw, 1.18rem); color: var(--text-2); max-width: 60ch; margin-bottom: 22px; }
.blog-hero.is-term { padding-top: clamp(32px, 6vw, 64px); }

.blog-search { display: flex; gap: 8px; max-width: 460px; margin-bottom: 20px; }
.blog-search input {
  flex: 1; min-width: 0; font: 400 0.98rem var(--font); color: var(--text); background: var(--bg-2);
  border: 1px solid var(--edge); border-radius: 999px; padding: 10px 18px; transition: border-color 0.2s, box-shadow 0.2s;
}
.blog-search input::placeholder { color: var(--muted); }
.blog-search input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.blog-search.is-big { max-width: 620px; }

.cat-nav ul { display: flex; flex-wrap: wrap; gap: 8px; list-style: none; padding: 0; margin: 0; }
.cat-nav a.chip { text-decoration: none; }
.cat-nav a.chip:hover { border-color: var(--edge-hi); color: var(--text); }
.chip .n { font: 500 0.72rem var(--mono); color: var(--muted); margin-inline-start: 6px; }

.featured { margin-bottom: 28px; }
.post-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 22px; }

.post-card {
  position: relative; display: flex; flex-direction: column; overflow: hidden; border-radius: var(--radius);
  background: linear-gradient(180deg, var(--surface-2), var(--surface)); border: 1px solid var(--edge); box-shadow: var(--shadow);
  transition: transform 0.35s var(--ease), border-color 0.3s;
}
.post-card:hover { transform: translateY(-3px); border-color: var(--edge-hi); }
.pc-cover { display: block; aspect-ratio: 1200 / 630; overflow: hidden; background: var(--bg-2); }
.pc-cover img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform 0.6s var(--ease); }
.post-card:hover .pc-cover img { transform: scale(1.03); }
.pc-body { padding: 18px 20px 22px; display: flex; flex-direction: column; gap: 8px; }
.pc-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 0; font-size: 0.8rem; color: var(--muted); }
.pc-cat { position: relative; z-index: 1; font: 600 0.72rem var(--mono); text-transform: uppercase; letter-spacing: 0.08em; color: var(--accent); }
.pc-title { font-size: 1.22rem; line-height: 1.3; }
.pc-title a { color: var(--text); text-decoration: none; }
/* The whole card is the link to the post (the category link stays on top). */
.pc-title a::after { content: ''; position: absolute; inset: 0; }
.pc-title a:focus-visible { outline: none; }
.post-card:has(.pc-title a:focus-visible) { outline: 2px solid var(--accent); outline-offset: 3px; }
.pc-excerpt { color: var(--text-2); font-size: 0.95rem; margin: 0; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }

.post-card.is-big { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); align-items: center; }
.post-card.is-big .pc-cover { height: 100%; aspect-ratio: auto; min-height: 260px; max-height: 380px; }
.post-card.is-big .pc-body { padding: clamp(22px, 4vw, 40px); gap: 12px; }
.post-card.is-big .pc-title { font-size: clamp(1.5rem, 3vw, 2.1rem); line-height: 1.15; }
.post-card.is-big .pc-excerpt { font-size: 1.02rem; -webkit-line-clamp: 4; }

.pager { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 36px; }
.empty-state { padding: 36px; text-align: center; color: var(--muted); }

.results { list-style: none; padding: 0; margin: 18px 0 0; display: flex; flex-direction: column; gap: 12px; max-width: 760px; }
.result { padding: 16px 20px; }
.result a strong { font: 600 1.1rem var(--display); color: var(--text); }
.result p { margin: 4px 0 0; }
.snip { color: var(--text-2); }
.snip mark { background: var(--accent-soft); color: var(--text); border-radius: 4px; padding: 0 2px; }

/* ---- a post ------------------------------------------------------------------------------------------------- */
.read-progress { position: fixed; inset-block-start: 0; inset-inline: 0; height: 3px; z-index: 60; pointer-events: none; }
.read-progress span { display: block; height: 100%; background: var(--grad); transform-origin: 0 50%; transform: scaleX(0); }

.preview-note { margin: 20px auto 0; max-width: var(--read); padding: 10px 14px; border-radius: 12px; background: var(--gold-soft); color: var(--gold); font-size: 0.9rem; }
.preview-note a { color: var(--gold); text-decoration: underline; }

.post-head { max-width: var(--read); margin: 0 auto; padding-block: clamp(36px, 7vw, 72px) 26px; }
.post-head h1 { font-size: clamp(2rem, 5.2vw, 3.1rem); line-height: 1.1; letter-spacing: -0.02em; }
.post-sub { font-size: clamp(1.08rem, 2.4vw, 1.3rem); color: var(--text-2); margin: 14px 0 0; line-height: 1.5; }
.post-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 22px 0 0; font-size: 0.9rem; color: var(--muted); }
.post-meta a { color: var(--text); }
.avatar { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; border: 1px solid var(--edge-hi); }

/* A little wider than the text, not the page: the words stay the main thing. */
.post-cover { max-width: calc(var(--read) + 120px); margin: 0 auto 40px; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--edge); box-shadow: var(--shadow); aspect-ratio: 12 / 5; background: var(--bg-2); }
/* Photos usually have their subject above the middle: crop the banner a little higher than centre. */
.post-cover img { width: 100%; height: 100%; object-fit: cover; object-position: 50% 30%; display: block; }

.post-layout { max-width: var(--read); margin: 0 auto; }
.toc { margin-bottom: 28px; }
.toc details { border: 1px solid var(--edge); border-radius: 14px; background: var(--surface); padding: 12px 16px; }
.toc summary { cursor: pointer; font: 500 0.75rem var(--mono); text-transform: uppercase; letter-spacing: 0.12em; color: var(--muted); }
.toc ol { list-style: none; margin: 10px 0 2px; padding: 0; display: flex; flex-direction: column; gap: 6px; font-size: 0.9rem; line-height: 1.4; }
.toc .lvl-3 { padding-inline-start: 14px; }
.toc a { color: var(--muted); text-decoration: none; display: block; border-inline-start: 2px solid transparent; padding-inline-start: 10px; margin-inline-start: -12px; transition: color 0.2s, border-color 0.2s; }
.toc a:hover, .toc a.is-active { color: var(--text); border-color: var(--accent); }

/* Reading type: one column of about 68 characters, generous line height. */
.article-body { font-size: 1.1rem; line-height: 1.78; color: var(--text); }
/* Blocks are spaced by the rule below only (same specificity, so it must stay after this one). */
.article-body > *, .article-body :where(p) { margin-block: 0; }
.article-body > * + * { margin-top: 1.2em; }
.article-body h2, .article-body h3, .article-body h4 { scroll-margin-top: 96px; position: relative; }
.article-body h2 { font-size: 1.65rem; margin-top: 2.1em; }
.article-body h3 { font-size: 1.3rem; margin-top: 1.8em; }
.article-body h4 { font-size: 1.1rem; margin-top: 1.6em; }
.article-body h2 + *, .article-body h3 + *, .article-body h4 + * { margin-top: 0.7em; }
.h-link { margin-inline-start: 6px; color: var(--muted); text-decoration: none; opacity: 0; transition: opacity 0.2s; font-weight: 400; }
.article-body :is(h2, h3, h4):hover .h-link, .h-link:focus-visible { opacity: 1; }
.article-body a { color: var(--accent); text-decoration: underline; text-decoration-color: var(--accent-soft); text-underline-offset: 3px; text-decoration-thickness: 2px; }
.article-body a:hover { text-decoration-color: var(--accent); }
.article-body strong { color: var(--text); font-weight: 650; }
.article-body ul, .article-body ol { padding-inline-start: 1.4em; }
.article-body li + li { margin-top: 0.35em; }
.article-body li > ul, .article-body li > ol { margin-top: 0.35em; }
.article-body li::marker { color: var(--accent); }
.article-body ul.checklist { list-style: none; padding-inline-start: 0; }
.article-body ul.checklist li { display: flex; gap: 10px; align-items: baseline; }
.tick { flex: none; width: 1em; height: 1em; border-radius: 5px; border: 1.5px solid var(--edge-hi); transform: translateY(0.15em); }
.done > .tick { background: var(--accent); border-color: var(--accent); box-shadow: inset 0 0 0 2px var(--bg); }
.article-body code { font: 500 0.86em var(--mono); background: var(--surface-2); border: 1px solid var(--edge); border-radius: 6px; padding: 0.1em 0.38em; }
.article-body mark { background: var(--gold-soft); color: var(--gold); border-radius: 4px; padding: 0 0.2em; }
.article-body pre.code { position: relative; margin-inline: 0; padding: 18px 20px; background: var(--bg-2); border: 1px solid var(--edge); border-radius: 14px; overflow-x: auto; font-size: 0.88rem; line-height: 1.65; }
.article-body pre.code code { background: none; border: 0; padding: 0; font-size: inherit; white-space: pre; }
.article-body pre.code[data-lang]::before { content: attr(data-lang); position: absolute; inset-block-start: 8px; inset-inline-end: 12px; font: 500 0.68rem var(--mono); text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); }
.article-body .quote { margin-inline: 0; padding: 4px 0 4px 22px; border-inline-start: 3px solid var(--accent-2); }
.article-body .quote blockquote { margin: 0; font: 500 1.28rem/1.5 var(--display); color: var(--text); }
.article-body .quote figcaption { margin-top: 8px; color: var(--muted); font-size: 0.92rem; }
.article-body .quote figcaption::before { content: '— '; }
.article-body .fig { margin-inline: 0; }
.article-body .fig img { max-width: 100%; max-height: min(70vh, 560px); width: auto; height: auto; display: block; margin-inline: auto; border-radius: 14px; border: 1px solid var(--edge); }
.article-body .fig figcaption { margin-top: 10px; text-align: center; color: var(--muted); font-size: 0.9rem; }
.article-body .table-wrap { overflow-x: auto; border: 1px solid var(--edge); border-radius: 14px; }
.article-body table { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
.article-body th, .article-body td { padding: 10px 14px; text-align: start; border-bottom: 1px solid var(--edge); vertical-align: top; }
.article-body th { font: 500 0.72rem var(--mono); text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); background: var(--surface); }
.article-body tr:last-child td { border-bottom: 0; }
.article-body .callout { padding: 16px 20px; border-radius: 14px; background: var(--accent-soft); border: 1px solid var(--edge-hi); border-inline-start: 3px solid var(--accent); }
.article-body .callout strong { display: block; margin-bottom: 4px; }
.article-body .callout p { margin: 0; color: var(--text-2); }
.article-body hr { border: 0; height: auto; margin-block: 2.4em; text-align: center; }
.article-body hr::before { content: '· · ·'; color: var(--muted); letter-spacing: 0.6em; font-size: 1.2rem; }

.post-foot { max-width: var(--read); margin: 44px auto 0; display: flex; flex-direction: column; gap: 26px; }
.tag-list { display: flex; flex-wrap: wrap; gap: 8px; list-style: none; padding: 0; margin: 0; }
.tag-list a.chip { text-decoration: none; }
.tag-list a.chip:hover { border-color: var(--edge-hi); color: var(--text); }
.author { display: flex; gap: 18px; align-items: flex-start; padding: 20px 22px; }
.author-photo { width: 64px; height: 64px; border-radius: 50%; object-fit: cover; border: 2px solid var(--edge-hi); flex: none; }
.author p { margin: 0; }
.author-name { font: 600 1.05rem var(--display); }
.author-name a { color: var(--text); }
.author-links { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px !important; }

.post-nav { max-width: 1080px; margin: 56px auto 0; display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.post-nav a { display: flex; flex-direction: column; gap: 4px; padding: 16px 20px; color: var(--text); text-decoration: none; transition: border-color 0.3s, transform 0.3s var(--ease); }
.post-nav a:hover { border-color: var(--edge-hi); transform: translateY(-2px); }
.post-nav .is-older { text-align: end; grid-column: 2; }
.post-nav strong { font: 600 1.02rem/1.35 var(--display); }

.related { max-width: 1080px; margin: 56px auto 0; }
.related h2 { font-size: 1.5rem; margin-bottom: 18px; }
.related .pc-title { font-size: 1.08rem; }

/* Wide screens: the contents beside the text, and wide images a little wider than the column. */
@media (min-width: 1100px) {
  /* The text stays centred like the header above it; the contents sit in the left gutter. */
  .post-layout.has-toc { max-width: none; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, var(--read)) minmax(0, 1fr); column-gap: 48px; }
  .post-layout.has-toc .article-body { grid-column: 2; grid-row: 1; }
  .post-layout.has-toc .toc { grid-column: 1; grid-row: 1; justify-self: end; width: min(220px, 100%); position: sticky; inset-block-start: 96px; align-self: start; margin: 0; max-height: calc(100vh - 120px); overflow-y: auto; }
  .post-layout.has-toc .toc details { border: 0; background: none; padding: 0; }
  .post-layout.has-toc .toc summary { list-style: none; pointer-events: none; }
  .post-layout.has-toc .toc summary::-webkit-details-marker { display: none; }
  .article-body .fig.wide { margin-inline: -64px; }
}

@media (max-width: 760px) {
  .post-card.is-big { grid-template-columns: minmax(0, 1fr); }
  .post-card.is-big .pc-cover { min-height: 0; aspect-ratio: 1200 / 630; }
  .post-grid { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  .post-nav { grid-template-columns: minmax(0, 1fr); }
  .post-nav .is-older { grid-column: auto; }
  .article-body { font-size: 1.04rem; line-height: 1.72; }
  .article-body pre.code { margin-inline: calc(-1 * var(--gutter)); border-radius: 0; border-inline: 0; }
  .author { flex-direction: column; }
  .post-cover { border-radius: 14px; margin-bottom: 28px; aspect-ratio: 2 / 1; }
}

/* ---- links into the portfolio (render/portfolio.js) ------------------------------------------------------------ */
.from-cv h2 { font-size: 1.15rem; margin-bottom: 12px; }
.from-cv.wide { margin-top: 56px; }
.from-cv.wide h2 { font-size: 1.5rem; margin-bottom: 18px; }
.cv-refs { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.cv-ref { display: flex; flex-direction: column; gap: 4px; height: 100%; padding: 14px 16px; border-radius: 14px; border: 1px solid var(--edge); background: var(--surface); color: var(--text); text-decoration: none !important; transition: border-color 0.25s, transform 0.25s var(--ease); }
.cv-ref:hover { border-color: var(--edge-hi); transform: translateY(-2px); }
.cr-kind { font: 500 0.68rem var(--mono); text-transform: uppercase; letter-spacing: 0.1em; color: var(--accent-3); }
.cv-ref strong { font: 600 1rem/1.35 var(--display); }
.cr-text { color: var(--text-2); font-size: 0.88rem; line-height: 1.5; }
