/* ═══════════════════════════════════════════════════════════
   Braindumps theme
   One column, reading first. Light and dark share one DOM: every colour is
   a custom property on :root, redefined under html[data-theme="dark"]. The
   toggle in the header writes data-theme; functions.php sets it before
   first paint from localStorage or the system preference.
   Mobile first: base styles are for phones, min-width queries scale up.
   ═══════════════════════════════════════════════════════════ */

/* ── Fonts, self-hosted ───────────────────────────────────── */
@font-face { font-family: "IBM Plex Sans"; font-style: normal; font-weight: 400; font-display: swap; src: url("../assets/fonts/ibm-plex-sans-400.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Sans"; font-style: italic; font-weight: 400; font-display: swap; src: url("../assets/fonts/ibm-plex-sans-400-italic.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Sans"; font-style: normal; font-weight: 500; font-display: swap; src: url("../assets/fonts/ibm-plex-sans-500.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Sans"; font-style: normal; font-weight: 600; font-display: swap; src: url("../assets/fonts/ibm-plex-sans-600.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Mono"; font-style: normal; font-weight: 400; font-display: swap; src: url("../assets/fonts/IBMPlexMono-400.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Mono"; font-style: normal; font-weight: 500; font-display: swap; src: url("../assets/fonts/IBMPlexMono-500.woff2") format("woff2"); }

/* ── Tokens ───────────────────────────────────────────────── */
:root {
  --accent: #C40E1D;        /* the logo red, darkened a touch for AA on white */
  --accent-ink: #FFFFFF;
  --bg: #FFFFFF;
  --bg2: #F6F4F1;           /* cards, code, quiet panels */
  --fg: #1B1B1F;
  --fg2: #5C5955;           /* meta, captions: 6.6:1 on white */
  --line: #E4E0DA;
  --code-bg: #1E1E24;
  --code-fg: #E8E6E3;
  --font: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --measure: 68ch;
  --radius: 10px;
  --max: 1040px;
  color-scheme: light;
}
html[data-theme="dark"] {
  --accent: #FF5A63;        /* lifted red: 5.6:1 on the dark ground */
  --accent-ink: #1B1B1F;
  --bg: #131316;
  --bg2: #1C1C21;
  --fg: #ECEAE6;
  --fg2: #A7A39D;
  --line: #2C2C33;
  --code-bg: #0F0F12;
  --code-fg: #E8E6E3;
  color-scheme: dark;
}

/* ── Base ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--fg); font-family: var(--font); font-size: 1.0625rem; line-height: 1.6; }
img { max-width: 100%; height: auto; }
a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
h1, h2, h3, h4 { line-height: 1.2; letter-spacing: -.01em; font-weight: 600; margin: 0 0 .5em; }
h1 { font-size: clamp(1.9rem, 1.3rem + 2.6vw, 2.75rem); }
h2 { font-size: clamp(1.4rem, 1.15rem + 1.1vw, 1.75rem); }
h3 { font-size: 1.2rem; }
.wrap { width: 100%; max-width: var(--max); margin: 0 auto; padding-inline: 20px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip-link { position: absolute; left: 16px; top: -60px; background: var(--accent); color: var(--accent-ink); padding: 10px 14px; border-radius: 8px; z-index: 100; }
.skip-link:focus { top: 12px; }
.btn { display: inline-block; padding: 10px 16px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg2); color: var(--fg); font: inherit; cursor: pointer; text-decoration: none; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

/* ── Header ───────────────────────────────────────────────── */
.site-header { border-bottom: 1px solid var(--line); background: var(--bg); position: sticky; top: 0; z-index: 30; }
.site-header .wrap { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 20px; min-height: 64px; padding-block: 10px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--fg); font-weight: 600; letter-spacing: .06em; text-transform: uppercase; font-size: .95rem; margin-right: auto; }
.brand-mark { width: 44px; height: auto; display: block; }
/* The living logo. The image is untouched; a masked sheet (.brand-fx) and
   five node dots sit over it and are animated by a class js/site.js adds
   for one run: fx-scan, fx-sweep, fx-neurons, fx-pulse, fx-charge. Nothing
   moves unless a class is present, and the reduced-motion rule at the end
   of this file collapses every animation to a single frame. */
.brand-mark-wrap { position: relative; display: block; width: 44px; flex: none; }
.brand-fx { position: absolute; inset: 0; opacity: 0; overflow: hidden; pointer-events: none;
  -webkit-mask: url(../assets/images/mark-red.png) center / contain no-repeat; mask: url(../assets/images/mark-red.png) center / contain no-repeat; }
.brand-fx::before { content: ""; position: absolute; inset: 0; }
.brand-node { position: absolute; left: var(--x); top: var(--y); width: 6px; height: 6px; margin: -3px 0 0 -3px; border-radius: 50%; background: #fff; opacity: 0; pointer-events: none;
  box-shadow: 0 0 3px 1px rgba(255,255,255,.9), 0 0 7px 3px var(--accent); }
/* Scan: a bright band crosses the brain left to right. Used on page load. */
.fx-scan .brand-fx { opacity: 1; animation: fx-fade 1.3s ease-out both; }
.fx-scan .brand-fx::before { background: linear-gradient(100deg, transparent 35%, rgba(255,255,255,.95) 50%, transparent 65%); inset: 0 -100%; animation: fx-scan 1.3s cubic-bezier(.4,0,.2,1) both; }
@keyframes fx-scan { from { transform: translateX(-34%); } to { transform: translateX(34%); } }
@keyframes fx-fade { 0%, 80% { opacity: 1; } 100% { opacity: 0; } }
/* Sweep: a light travels once around the outline, like a radar trace. */
.fx-sweep .brand-fx { opacity: 1; animation: fx-fade 1.6s ease-out both; }
.fx-sweep .brand-fx::before { inset: -60%; background: conic-gradient(from 0deg, transparent 0 78%, rgba(255,255,255,.9) 92%, transparent 100%); animation: fx-sweep 1.6s linear both; }
@keyframes fx-sweep { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
/* Neurons: the five nodes spark in a random order (delays set by the script). */
.fx-neurons .brand-node { animation: fx-node .7s ease-out var(--d, 0s) both; }
@keyframes fx-node { 0% { opacity: 0; transform: scale(.4); } 30% { opacity: 1; transform: scale(1.25); } 100% { opacity: 0; transform: scale(.8); } }
/* Pulse: two soft heartbeats with a red glow. */
.fx-pulse .brand-mark { animation: fx-pulse 1.4s ease-in-out both; }
@keyframes fx-pulse { 0%, 100% { transform: scale(1); filter: none; } 18%, 58% { transform: scale(1.07); filter: drop-shadow(0 0 3px var(--accent)); } 38%, 78% { transform: scale(1); filter: none; } }
/* Charge: the brain fills from the bottom like a level rising, then settles. */
.fx-charge .brand-fx { opacity: 1; animation: fx-fade 1.8s ease-out both; }
.fx-charge .brand-fx::before { background: linear-gradient(to top, rgba(255,255,255,.85), rgba(255,255,255,.85) 60%, transparent); inset: 0; animation: fx-charge 1.8s ease-in-out both; }
@keyframes fx-charge { 0% { transform: translateY(100%); } 70% { transform: translateY(0); } 100% { transform: translateY(-100%); } }
.brand-tld { color: var(--fg2); font-weight: 400; letter-spacing: .12em; font-size: .75rem; margin-left: 2px; }
.nav-toggle { background: none; border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; color: var(--fg); font: inherit; cursor: pointer; }
.site-nav { display: none; flex-basis: 100%; }
.site-nav.is-open { display: block; }
.menu { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.menu a { display: block; padding: 8px 4px; color: var(--fg); text-decoration: none; border-bottom: 2px solid transparent; }
.menu a:hover, .menu .current-menu-item > a, .menu .current-cat > a { border-bottom-color: var(--accent); }
.header-tools { display: flex; align-items: center; gap: 8px; }
.header-search input { width: 130px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg2); color: var(--fg); font: inherit; font-size: .95rem; }
.header-search input:focus { width: 180px; border-color: var(--accent); }
.theme-toggle { background: none; border: 1px solid var(--line); border-radius: 8px; width: 38px; height: 38px; display: inline-flex; align-items: center; justify-content: center; color: var(--fg); cursor: pointer; }
.theme-toggle .icon-moon { display: none; }
html[data-theme="dark"] .theme-toggle .icon-moon { display: block; }
html[data-theme="dark"] .theme-toggle .icon-sun { display: none; }
@media (min-width: 800px) {
  .nav-toggle { display: none; }
  .site-nav { display: block; flex-basis: auto; }
  .menu { flex-direction: row; gap: 4px 18px; }
  .menu a { padding: 6px 0; }
}

/* ── Lists and cards ──────────────────────────────────────── */
main { padding-block: 28px 56px; }
.home-intro { padding: 12px 0 28px; }
.tagline { margin: 0; font-size: 1.15rem; color: var(--fg2); max-width: var(--measure); }
.page-title { margin-bottom: 8px; }
.archive-header { padding-bottom: 20px; }
.archive-header .lead { color: var(--fg2); max-width: var(--measure); }
.list { display: grid; gap: 28px; }
.card { display: grid; gap: 14px; align-content: start; }
.card-large { padding-bottom: 28px; border-bottom: 1px solid var(--line); }
.card-large .card-title { font-size: clamp(1.5rem, 1.1rem + 1.8vw, 2.1rem); }
.card-image { display: block; border-radius: var(--radius); overflow: hidden; background: var(--bg2); }
.card-image img { display: block; width: 100%; height: 100%; object-fit: cover; }
.card-large .card-image { aspect-ratio: 2 / 1; max-height: 440px; }
.card-row { grid-template-columns: 1fr; }
.card-cat, .entry-cat { display: inline-block; font-size: .8rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; text-decoration: none; color: var(--accent); margin-bottom: 6px; }
.card-title { margin: 0 0 6px; font-size: 1.3rem; }
.card-title a { color: var(--fg); text-decoration: none; }
.card-title a:hover { text-decoration: underline; }
.card-excerpt { margin: 0 0 8px; color: var(--fg2); }
.card-meta { margin: 0; font-size: .875rem; color: var(--fg2); display: flex; gap: 8px; }
.grid { display: grid; gap: 16px; }
.card-grid { padding: 20px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg2); }
.card-grid .card-title { font-size: 1.15rem; }
@media (min-width: 640px) {
  .card-row { grid-template-columns: 200px 1fr; gap: 22px; }
  .card-row .card-image { aspect-ratio: 16 / 10; }
  .grid { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 900px) { .grid { grid-template-columns: repeat(3, 1fr); } }
.pagination { margin-top: 36px; }
.pagination .nav-links { display: flex; flex-wrap: wrap; gap: 8px; }
.pagination .page-numbers { padding: 8px 14px; border: 1px solid var(--line); border-radius: 8px; text-decoration: none; color: var(--fg); }
.pagination .page-numbers.current { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

/* ── Article ──────────────────────────────────────────────── */
.entry-header { padding-block: 8px 20px; }
.entry-title { max-width: 22ch; }
.entry-lead { font-size: 1.2rem; color: var(--fg2); max-width: var(--measure); margin: 0 0 14px; }
.entry-meta { margin: 0; font-size: .9rem; color: var(--fg2); display: flex; flex-wrap: wrap; gap: 8px; }
.entry-meta a { color: var(--fg2); }
.entry-figure { margin: 0 auto 28px; }
.entry-figure img { width: 100%; height: auto; border-radius: var(--radius); display: block; }
.entry { max-width: calc(var(--measure) + 40px); }
.entry > * { max-width: var(--measure); }
.entry > pre, .entry > .code, .entry > .table-scroll, .entry > figure, .entry > .wp-caption, .entry > img { max-width: 100%; }
.entry p, .entry ul, .entry ol { margin: 0 0 1.2em; }
.entry h2 { margin-top: 2em; }
.entry h3 { margin-top: 1.6em; }
.entry li { margin-bottom: .35em; }
.entry img { border-radius: 8px; }
.entry img.alignleft, .entry .alignleft { float: none; margin: 0 0 16px; }
.entry img.alignright, .entry .alignright { float: none; margin: 0 0 16px; }
.entry .wp-caption { max-width: 100%; margin: 0 0 24px; }
.entry .wp-caption img { display: block; margin-bottom: 6px; }
.entry .wp-caption-text, .entry figcaption { font-size: .875rem; color: var(--fg2); margin: 0; }
.entry blockquote { margin: 0 0 1.2em; padding: 4px 0 4px 18px; border-left: 3px solid var(--accent); color: var(--fg2); }
.entry hr { border: 0; border-top: 1px solid var(--line); margin: 2em 0; }
.entry code { font-family: var(--mono); font-size: .92em; background: var(--bg2); padding: .1em .35em; border-radius: 4px; }
.entry a.btn, .entry button { font-family: var(--font); }
.entry input, .entry select, .entry textarea { font: inherit; padding: 8px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--fg); max-width: 100%; }
@media (min-width: 640px) {
  .entry img.alignleft, .entry .alignleft { float: left; margin: 4px 24px 12px 0; max-width: 45%; }
  .entry img.alignright, .entry .alignright { float: right; margin: 4px 0 12px 24px; max-width: 45%; }
}

/* A browser tool inside an article: a quiet panel with proper controls. */
.tool { margin: 0 0 1.6em; padding: 20px 22px 8px; background: var(--bg2); border: 1px solid var(--line); border-radius: var(--radius); }
.tool h2, .tool h3 { margin-top: 0; }
.tool label { display: block; margin: 12px 0 6px; font-weight: 500; }
.tool input, .tool select, .tool textarea { margin: 0 0 8px; }
.tool button, .tool input[type="button"], .tool input[type="submit"] { display: inline-block; margin: 10px 8px 14px 0; padding: 10px 16px; border-radius: 8px; border: 1px solid var(--accent); background: var(--accent); color: var(--accent-ink); font: inherit; font-weight: 500; cursor: pointer; }
.tool p { margin: 0 0 12px; }
.tool br { display: none; }

/* Code blocks: dark in both themes, with the copy button in the corner. */
.code { position: relative; margin: 0 0 1.4em; }
.code pre { margin: 0; padding: 18px 20px; background: var(--code-bg); color: var(--code-fg); border-radius: var(--radius); overflow-x: auto; font-family: var(--mono); font-size: .9rem; line-height: 1.55; tab-size: 4; }
.code pre code { background: none; padding: 0; font-size: inherit; color: inherit; }
.code .copy { position: absolute; top: 8px; right: 8px; font: 500 .75rem var(--font); letter-spacing: .04em; text-transform: uppercase; background: rgba(255, 255, 255, .08); color: var(--code-fg); border: 1px solid rgba(255, 255, 255, .18); border-radius: 6px; padding: 5px 9px; cursor: pointer; opacity: .75; }
.code .copy:hover, .code .copy:focus-visible { opacity: 1; }
.code .copy.is-done { background: rgba(120, 220, 160, .18); border-color: rgba(120, 220, 160, .5); }
@media (max-width: 639px) { .code pre { white-space: pre-wrap; word-break: break-word; } }
/* Prism tokens, one restrained palette for both themes. */
.token.comment, .token.prolog, .token.doctype, .token.cdata { color: #8A8F98; }
.token.punctuation { color: #B8BCC6; }
.token.property, .token.tag, .token.constant, .token.symbol, .token.deleted { color: #FF8A80; }
.token.boolean, .token.number { color: #FFB86C; }
.token.selector, .token.attr-name, .token.string, .token.char, .token.builtin, .token.inserted { color: #A5E08E; }
.token.operator, .token.entity, .token.url, .language-css .token.string { color: #B8BCC6; }
.token.atrule, .token.attr-value, .token.keyword { color: #82AAFF; }
.token.function, .token.class-name { color: #FFD866; }
.token.regex, .token.important, .token.variable { color: #F2C4FF; }
.token.important, .token.bold { font-weight: 600; }
.token.italic { font-style: italic; }

/* Tables scroll rather than break the column. */
.table-scroll { overflow-x: auto; margin: 0 0 1.4em; border: 1px solid var(--line); border-radius: var(--radius); }
.entry table { border-collapse: collapse; width: 100%; min-width: 480px; font-size: .95rem; margin: 0; }
.entry th, .entry td { padding: 10px 14px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.entry th { background: var(--bg2); font-weight: 600; }
.entry tr:last-child td { border-bottom: 0; }

/* Maths sits comfortably in the text. */
.katex-display { overflow-x: auto; overflow-y: hidden; padding: 4px 0; }

/* Article footer. */
.entry-footer { margin-top: 40px; max-width: calc(var(--measure) + 40px); }
.entry-tags { color: var(--fg2); font-size: .9rem; }
.entry-tags span { margin-right: 6px; }
.related { margin-top: 28px; padding: 20px 22px; background: var(--bg2); border-radius: var(--radius); }
.related h2 { font-size: 1.05rem; margin: 0 0 10px; text-transform: uppercase; letter-spacing: .06em; color: var(--fg2); }
.related ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.related li span { color: var(--fg2); font-size: .85rem; margin-left: 6px; }
.post-nav { display: grid; gap: 12px; margin-top: 28px; padding-top: 20px; border-top: 1px solid var(--line); }
.post-nav span { display: block; font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--fg2); margin-bottom: 4px; }
.post-nav a { color: var(--fg); text-decoration: none; font-weight: 500; }
.post-nav a:hover { text-decoration: underline; }
.post-nav-next { text-align: left; }
@media (min-width: 640px) { .post-nav { grid-template-columns: 1fr 1fr; } .post-nav-next { text-align: right; } }

/* ── Search on its own pages ──────────────────────────────── */
.page-search { display: flex; gap: 8px; max-width: 520px; margin-top: 12px; }
.page-search input { flex: 1; min-width: 0; padding: 10px 14px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg2); color: var(--fg); font: inherit; }

/* ── Contact form ─────────────────────────────────────────── */
.entry .wpcf7-form label { display: block; font-weight: 500; margin-bottom: 6px; }
.entry .wpcf7-form input:not([type="submit"]), .entry .wpcf7-form textarea { width: 100%; margin-bottom: 16px; }
.entry .wpcf7-form input[type="submit"] { padding: 12px 20px; border-radius: 8px; border: 0; background: var(--accent); color: var(--accent-ink); font: inherit; font-weight: 500; cursor: pointer; }
.entry .wpcf7-response-output { margin: 16px 0 0; padding: 12px 16px; border: 1px solid var(--line); border-radius: 8px; }
.bd-hp { position: absolute; left: -9999px; top: auto; width: 1px; height: 1px; overflow: hidden; }

/* ── Footer ───────────────────────────────────────────────── */
.site-footer { border-top: 1px solid var(--line); padding: 32px 0 36px; color: var(--fg2); font-size: .9rem; }
.site-footer .wrap { display: grid; gap: 18px; }
.foot-top { display: flex; flex-wrap: wrap; gap: 10px 24px; align-items: center; justify-content: space-between; }
.foot-line { margin: 0; }
.foot-check { color: var(--fg); font-weight: 500; }
.foot-bottom { display: flex; flex-wrap: wrap; gap: 8px 20px; padding-top: 16px; border-top: 1px solid var(--line); font-size: .85rem; }
.foot-bottom a { color: var(--fg2); text-decoration: none; border-bottom: 1px solid transparent; }
.foot-bottom a:hover { color: var(--fg); border-bottom-color: var(--accent); }

/* ── Cookie consent card ──────────────────────────────────── */
.consent { position: fixed; left: 16px; right: 16px; bottom: 16px; margin: 0; inset-inline-start: auto; width: min(360px, calc(100vw - 32px)); padding: 18px 20px; background: var(--bg2); color: var(--fg); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 12px 32px rgba(0, 0, 0, .25); z-index: 60; font-size: .92rem; animation: consent-in .35s ease-out; }
.consent[open] { display: block; }
.consent-title { margin: 0 0 6px; font-weight: 600; }
.consent-text { margin: 0 0 14px; color: var(--fg2); line-height: 1.45; }
.consent-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.consent-actions .btn { padding: 9px 14px; font-size: .92rem; }
.consent-actions a { color: var(--fg2); font-size: .85rem; margin-left: auto; }
@keyframes consent-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@media (min-width: 700px) { .consent { left: auto; right: 24px; bottom: 24px; } }

/* ── Motion ───────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
