/* ==========================================================================
   thewilf — personal site
   VOICE   editorial, confident; big serif headlines over rich full-bleed art
   IDEA    the site behaves like a populated circuit board: a blue soldermask
           hero, gold ENIG pads as the accent, contour maps as section texture
   PICTURE generated art (covers.py): LQFP MCU fan-out, logic-analyser traces,
           space plates, topographic costmaps
   TYPE    Playfair Display (headlines) + Be Vietnam Pro (text) + JetBrains Mono (code)
   LAYOUT  full-bleed bands; cards with text over art; white / mist alternation
   ========================================================================== */

:root {
  --paper: #ffffff;
  --mist: #f3f5f8;
  --ink: #0f1b2d;
  --muted: #5b6779;
  --line: #e2e7ee;
  --mask: #173a66;
  --mask-deep: #0e2747;
  --gold: #d9ad55;
  --gold-ink: #8f6512;      /* gold dark enough for text on white */
  --link: #1b4f94;
  --code-bg: #f1f4f8;
  --shadow: 0 18px 40px -22px rgba(14, 39, 71, 0.45);

  --serif: "Playfair Display", Georgia, "Times New Roman", serif;
  --sans: "Be Vietnam Pro", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Consolas, monospace;

  --wrap: 78rem;
  --gutter: clamp(1.25rem, 4vw, 2.5rem);
  --radius: 14px;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --paper: #0c1524;
  --mist: #101c2f;
  --ink: #e7edf5;
  --muted: #9aa7ba;
  --line: #1f2f46;
  --gold-ink: #e3b765;
  --link: #8fb8ff;
  --code-bg: #13213a;
  --shadow: 0 18px 40px -22px rgba(0, 0, 0, 0.8);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
* { min-width: 0; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-padding-top: 1.5rem; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font: 400 1.0625rem/1.7 var(--sans); -webkit-font-smoothing: antialiased;
  overflow-x: clip;
}
img, svg { max-width: 100%; height: auto; display: block; }
a { color: var(--link); text-decoration-thickness: 1px; text-underline-offset: 0.2em; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; border-radius: 3px; }
h1, h2, h3 { font-family: var(--serif); font-weight: 700; line-height: 1.12; margin: 0; text-wrap: balance; }
p { margin: 0; }
code, pre, kbd { font-family: var(--mono); font-size: 0.9em; }

.wrap { width: 100%; max-width: var(--wrap); margin-inline: auto; padding-inline: var(--gutter); }
.narrow { max-width: 50rem; }
.center { text-align: center; }
.mt { margin-top: clamp(1.5rem, 3vw, 2rem); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 0.5rem; background: #fff; color: #000; padding: 0.5rem 1rem; z-index: 50; }
.skip:focus { left: 0.5rem; }
.ico { width: 1em; height: 1em; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* --- Buttons ----------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
  min-height: 3rem; padding: 0.7rem 1.6rem; border-radius: 6px;
  font: 600 0.95rem/1 var(--sans); text-decoration: none; border: 1.5px solid transparent;
  transition: background-color .15s, color .15s, border-color .15s;
}
.btn-sm { min-height: 2.4rem; padding: 0.5rem 1.1rem; font-size: 0.875rem; }
.btn-light { background: #fff; color: #0f1b2d; }
.btn-light:hover { background: var(--gold); }
.btn-ghost { color: #fff; border-color: rgba(255, 255, 255, 0.55); }
.btn-ghost:hover { background: #fff; color: #0f1b2d; }
.btn-outline { color: var(--ink); border-color: var(--ink); }
.btn-outline:hover { background: var(--ink); color: var(--paper); }

/* --- Masthead (overlays every banner) ------------------------------------------- */
.masthead { position: absolute; inset: 0 0 auto; z-index: 20; color: #fff; }
.masthead-inner {
  display: flex; align-items: center; gap: 2rem; min-height: 5.25rem;
  /* hairline that stops at the content edges, not the padded box */
  background: linear-gradient(rgba(255, 255, 255, 0.16), rgba(255, 255, 255, 0.16)) no-repeat center bottom / calc(100% - 2 * var(--gutter)) 1px;
}
.brand { display: inline-flex; align-items: center; gap: 0.65rem; color: #fff; text-decoration: none; font: 700 1.15rem/1 var(--sans); }
.brand-mark { width: 2rem; height: 2rem; }
.brand-mark rect { fill: none; stroke: #fff; stroke-width: 2; }
.brand-mark path { fill: none; stroke: var(--gold); stroke-width: 2.4; }
.mainnav { margin-inline: auto; }
.mainnav ul { list-style: none; display: flex; gap: 2.25rem; margin: 0; padding: 0; }
.mainnav a { color: rgba(255, 255, 255, 0.82); text-decoration: none; font-weight: 500; font-size: 0.95rem; padding-block: 1.9rem; position: relative; }
.mainnav a:hover, .mainnav a[aria-current] { color: #fff; }
.mainnav a[aria-current]::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; background: var(--gold); }
.masthead-tools { display: flex; align-items: center; gap: 0.75rem; }
.lang-switch {
  display: inline-flex; align-items: center; gap: 0.35rem; height: 2.4rem; padding: 0 0.8rem;
  border: 1.5px solid rgba(255, 255, 255, 0.4); border-radius: 999px; color: #fff; text-decoration: none;
  font: 600 0.82rem/1 var(--sans); letter-spacing: 0.02em;
}
.lang-switch:hover { border-color: #fff; }
.lang-switch .ico { width: 1rem; height: 1rem; }
.theme-toggle {
  width: 2.4rem; height: 2.4rem; display: grid; place-items: center; cursor: pointer;
  background: none; border: 1.5px solid rgba(255, 255, 255, 0.4); border-radius: 50%; color: #fff;
}
.theme-toggle:hover { border-color: #fff; }
.theme-toggle svg { width: 1.1rem; height: 1.1rem; fill: none; stroke: currentColor; stroke-width: 1.8; }
.theme-toggle path { fill: currentColor; stroke: none; }
@media (max-width: 52rem) {
  .masthead-inner { flex-wrap: wrap; gap: 0.25rem 1rem; padding-block: 0.9rem 0; min-height: 0; }
  .mainnav { order: 3; width: 100%; margin: 0; overflow-x: auto; }
  .mainnav ul { gap: 1.5rem; }
  .mainnav a { display: inline-block; padding-block: 0.8rem; }
  .masthead-tools { margin-left: auto; }
  .masthead-tools .btn { display: none; }
}

/* --- Hero (home) ---------------------------------------------------------------- */
.hero { position: relative; isolation: isolate; color: #fff; background: var(--mask-deep); min-height: min(92svh, 52rem); display: flex; }
.hero-img, .banner-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: 72% 50%; z-index: -2; }
.hero::before, .banner::before {
  content: ""; position: absolute; inset: 0; z-index: -1;
  background:
    linear-gradient(90deg, rgba(8, 22, 42, 0.94) 0%, rgba(8, 22, 42, 0.78) 38%, rgba(8, 22, 42, 0.12) 72%),
    linear-gradient(0deg, rgba(8, 22, 42, 0.92) 0%, rgba(8, 22, 42, 0) 42%);
}
.hero-inner { display: flex; flex-direction: column; justify-content: center; padding-top: 8.5rem; padding-bottom: clamp(4rem, 10vh, 7rem); }
.hero-copy { max-width: 40rem; }
.kicker { font: 600 0.95rem/1.4 var(--sans); color: var(--gold); margin-bottom: 1rem; }
.hero h1 { font-size: clamp(3.1rem, 8vw, 6.4rem); line-height: 1.02; letter-spacing: -0.01em; }
.hero-lede { margin-top: 1.5rem; font-size: clamp(1.05rem, 1.6vw, 1.2rem); line-height: 1.65; color: rgba(255, 255, 255, 0.86); max-width: 34em; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 0.9rem; margin-top: 2.25rem; }

@media (prefers-reduced-motion: no-preference) {
  .hero-copy > * { animation: rise .8s cubic-bezier(.2, .7, .2, 1) both; }
  .hero-copy > :nth-child(2) { animation-delay: .08s; }
  .hero-copy > :nth-child(3) { animation-delay: .16s; }
  .hero-copy > :nth-child(4) { animation-delay: .24s; }
  @keyframes rise { from { opacity: 0; transform: translateY(18px); } }
}

/* --- Inner-page banner ------------------------------------------------------------ */
.banner { position: relative; isolation: isolate; color: #fff; background: var(--mask-deep); }
.banner-inner { padding-top: clamp(9rem, 18vh, 11rem); padding-bottom: clamp(3rem, 7vh, 4.5rem); max-width: var(--wrap); }
.banner h1 { font-size: clamp(2.4rem, 5.5vw, 4.25rem); max-width: 18em; }
.banner-intro { margin-top: 1.1rem; font-size: 1.125rem; color: rgba(255, 255, 255, 0.82); max-width: 38em; }
.crumb { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-bottom: 1rem; font-size: 0.9rem; }
.crumb a { color: rgba(255, 255, 255, 0.78); }
.crumb a + a::before { content: "/"; margin-right: 0.4rem; color: rgba(255, 255, 255, 0.4); }
.banner-post::before { background: linear-gradient(90deg, rgba(8, 22, 42, 0.92), rgba(8, 22, 42, 0.62)), linear-gradient(0deg, rgba(8, 22, 42, 0.6), transparent 60%); }
.banner-post h1 { font-size: clamp(2.1rem, 4.6vw, 3.6rem); }
.post-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 0.6rem 1.4rem; margin-top: 1.4rem; color: rgba(255, 255, 255, 0.8); font-size: 0.95rem; }
.post-meta span { display: inline-flex; align-items: center; gap: 0.45rem; }
.post-meta .tag { color: #fff; text-decoration: none; border: 1px solid rgba(255, 255, 255, 0.4); border-radius: 999px; padding: 0.15rem 0.75rem; font-size: 0.85rem; }
.post-meta .tag:hover { border-color: var(--gold); color: var(--gold); }
.banner .hero-actions { margin-top: 1.75rem; }

/* --- Sections ----------------------------------------------------------------------- */
.section { padding-block: clamp(4rem, 9vw, 7.5rem); }
.section-tight { padding-block: clamp(2.5rem, 5vw, 4rem) clamp(4rem, 8vw, 6rem); }
.band { background: var(--mist); }
.band-topo { background: var(--mist) url("../img/topo.svg") center / cover no-repeat; }
:root[data-theme="dark"] .band-topo { background-image: url("../img/topo-dark.svg"); }
.section-head { text-align: center; margin-bottom: clamp(2rem, 5vw, 3.5rem); }
.eyebrow { font: 600 0.95rem/1.4 var(--sans); color: var(--gold-ink); margin-bottom: 0.6rem; }
.section-head h2 { font-size: clamp(2.1rem, 4.4vw, 3.25rem); }

/* --- Cards: text over art ------------------------------------------------------------ */
.grid { display: grid; gap: clamp(1rem, 2.2vw, 1.75rem); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 64rem) { .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 40rem) { .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; } }

.card {
  position: relative; isolation: isolate; overflow: hidden; display: flex; align-items: flex-end;
  aspect-ratio: 16 / 11; border-radius: var(--radius); color: #fff; text-decoration: none;
  background: var(--mask-deep); box-shadow: var(--shadow);
}
.card.tall { aspect-ratio: 3 / 4; }
.card.wide { aspect-ratio: 21 / 9; min-height: 22rem; }
.card-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; z-index: -2; transition: transform .6s cubic-bezier(.2, .7, .2, 1); }
.card::before { content: ""; position: absolute; inset: 0; z-index: -1; background: linear-gradient(0deg, rgba(6, 16, 30, 0.92) 0%, rgba(6, 16, 30, 0.55) 45%, rgba(6, 16, 30, 0.05) 80%); }
.card.wide::before { background: linear-gradient(90deg, rgba(6, 16, 30, 0.92) 0%, rgba(6, 16, 30, 0.7) 45%, rgba(6, 16, 30, 0.08) 85%); }
.card:hover .card-img { transform: scale(1.05); }
.card-body { display: flex; flex-direction: column; gap: 0.55rem; padding: clamp(1.25rem, 2.5vw, 1.75rem); width: 100%; }
.card.wide .card-body { max-width: 36rem; justify-content: center; align-self: stretch; padding: clamp(1.5rem, 4vw, 3rem); }
.card-tags { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.card-tags:empty { display: none; }
.card-tag-lang { background: rgba(255, 255, 255, 0.92) !important; }
.card-tag { align-self: flex-start; font: 600 0.78rem/1 var(--sans); color: #0f1b2d; background: var(--gold); border-radius: 999px; padding: 0.38rem 0.7rem; }
.card-title { font: 700 clamp(1.25rem, 2vw, 1.5rem)/1.22 var(--serif); text-wrap: balance; }
.card.wide .card-title { font-size: clamp(1.7rem, 3.4vw, 2.6rem); }
.card-text { color: rgba(255, 255, 255, 0.82); font-size: 0.98rem; line-height: 1.6; }
.card-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem; font-size: 0.85rem; color: rgba(255, 255, 255, 0.78); }
.card-meta .ico + * , .card-meta time { margin-right: 0.6rem; }
@media (max-width: 40rem) { .card.wide { aspect-ratio: auto; min-height: 26rem; } .card.wide::before { background: linear-gradient(0deg, rgba(6, 16, 30, 0.95) 10%, rgba(6, 16, 30, 0.3) 80%); } .card.wide .card-body { justify-content: flex-end; } }

/* --- Split (scope + copy) ----------------------------------------------------------- */
.split { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: clamp(2rem, 6vw, 5.5rem); align-items: center; }
@media (max-width: 56rem) { .split { grid-template-columns: 1fr; } }
.split-copy h2 { font-size: clamp(2rem, 4vw, 3rem); margin-bottom: 1.4rem; }
.split-copy p { color: var(--muted); margin-bottom: 1rem; max-width: 34em; }
.split-copy .btn { margin-top: 1rem; }

.scope-panel { margin: 0; background: #0b1f26; border-radius: var(--radius); padding: 1.25rem 1.25rem 1.1rem; box-shadow: var(--shadow); border: 1px solid #16363f; }
.scope-bar { display: flex; gap: 1rem; font: 500 0.78rem/1 var(--mono); color: #7fa3ac; margin-bottom: 0.9rem; }
.scope-bar span:first-child { color: #0b1f26; background: #f2c94c; padding: 0.3rem 0.45rem; border-radius: 3px; }
.scope-panel figcaption { color: #8fb0b8; font-size: 0.85rem; margin-top: 0.6rem; }
.wave { width: 100%; overflow: visible; }
.wave-grid line { stroke: #173c46; stroke-width: 1; }
.wave-trace { fill: none; stroke: #f2c94c; stroke-width: 2.25; vector-effect: non-scaling-stroke; }
.wave-frames path { fill: none; stroke: #56ccf2; stroke-width: 1.25; vector-effect: non-scaling-stroke; }
.wave-frames text { font-family: var(--mono); text-anchor: middle; fill: #56ccf2; }
.wave-frames .hex { font-size: 10.5px; }
.wave-frames .chr { font-size: 15px; font-weight: 600; fill: #fff; }
@media (max-width: 40rem) { .wave-frames .chr { font-size: 26px; } .wave-frames .hex { font-size: 17px; } }
@media (prefers-reduced-motion: no-preference) {
  .wave-trace { stroke-dasharray: 1; stroke-dashoffset: 1; animation: trace 1.8s cubic-bezier(.45, 0, .2, 1) .3s forwards; }
  .wave-frames > g { opacity: 0; animation: decode .3s ease-out forwards; animation-delay: calc(.65s + var(--i) * .16s); }
  @keyframes trace { to { stroke-dashoffset: 0; } }
  @keyframes decode { to { opacity: 1; } }
}

/* --- Series columns (home) ----------------------------------------------------------- */
.series-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 18rem), 1fr)); gap: clamp(1.5rem, 4vw, 3.5rem); }
.series-cols h3 { font-size: 1.5rem; margin-bottom: 0.75rem; }
.series-cols h3 a { color: var(--ink); text-decoration: none; }
.series-cols h3 a:hover { color: var(--link); }
.series-cols p { color: var(--muted); }
.series-count { margin-top: 0.9rem; font-size: 0.92rem; }
.series-count .ico { display: inline-block; vertical-align: -0.15em; margin-right: 0.4rem; color: var(--gold-ink); }

/* --- Blog index ----------------------------------------------------------------------- */
.toolbar { display: grid; gap: 1.25rem; margin-bottom: 2.5rem; }
.search input {
  width: 100%; font: inherit; color: var(--ink); background: var(--paper);
  border: 1.5px solid var(--line); border-radius: 10px; padding: 0.95rem 1.15rem; min-height: 3.25rem;
}
.search input:focus { outline: none; border-color: var(--mask); box-shadow: 0 0 0 4px color-mix(in srgb, var(--gold) 35%, transparent); }
.pills { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0.6rem; }
.pills a { display: inline-flex; gap: 0.45rem; align-items: center; padding: 0.45rem 1rem; border: 1.5px solid var(--line); border-radius: 999px; color: var(--ink); text-decoration: none; font-weight: 500; font-size: 0.92rem; }
.pills a span { color: var(--muted); font-size: 0.82rem; }
.pills a:hover { border-color: var(--ink); }
.series-strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 16rem), 1fr)); gap: 1rem; margin-bottom: 3rem; }
.series-chip { display: flex; gap: 0.9rem; align-items: center; padding: 0.6rem; border-radius: 12px; background: var(--mist); text-decoration: none; color: var(--ink); border: 1px solid var(--line); }
.series-chip img { width: 4.5rem; height: 3.25rem; object-fit: cover; border-radius: 8px; }
.series-chip strong { display: block; font: 700 1.05rem/1.25 var(--serif); }
.series-chip small { color: var(--muted); }
.series-chip:hover { border-color: var(--ink); }
.year-block + .year-block { margin-top: 3.5rem; }
.year { font-size: 2rem; margin-bottom: 1.25rem; font-variant-numeric: lining-nums; }
.search-results { list-style: none; margin: 0 0 3rem; padding: 0; }
.search-results li { padding-block: 1rem; border-bottom: 1px solid var(--line); }
.search-results a { font: 700 1.2rem/1.3 var(--serif); text-decoration: none; color: var(--ink); }
.search-results a:hover { color: var(--link); }
.search-results p { margin-top: 0.3rem; color: var(--muted); font-size: 0.95rem; }
.search-results mark { background: color-mix(in srgb, var(--gold) 45%, transparent); color: inherit; border-radius: 2px; }
.search-results .none { color: var(--muted); border: 0; }

/* --- Series list page --------------------------------------------------------------- */
.steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 1.25rem; }
.step { display: grid; grid-template-columns: 15rem 1fr; gap: 1.5rem; align-items: center; padding: 0.75rem; border: 1px solid var(--line); border-radius: var(--radius); text-decoration: none; color: var(--ink); background: var(--paper); }
.step:hover { border-color: var(--ink); }
.step img { width: 100%; aspect-ratio: 16 / 10; object-fit: cover; border-radius: 10px; }
.step-body { display: flex; flex-direction: column; gap: 0.4rem; padding-right: 1rem; }
.step-no { font-weight: 600; font-size: 0.9rem; color: var(--gold-ink); }
.step-title { font: 700 1.4rem/1.25 var(--serif); }
.step-text { color: var(--muted); font-size: 0.97rem; }
.step .card-meta { color: var(--muted); }
@media (max-width: 40rem) { .step { grid-template-columns: 1fr; } }

/* --- Post body ----------------------------------------------------------------------- */
.post { display: grid; grid-template-columns: minmax(0, 46rem); justify-content: center; column-gap: 4.5rem; padding-block: clamp(2.5rem, 5vw, 4rem) clamp(3rem, 6vw, 5rem); }
.post.has-toc { grid-template-columns: minmax(0, 46rem) 16rem; }
.legacy { margin-bottom: 2rem; padding: 0.9rem 1.15rem; border-radius: 10px; background: color-mix(in srgb, var(--gold) 16%, var(--paper)); font-size: 0.95rem; }
.toc { position: sticky; top: 2rem; align-self: start; font-size: 0.92rem; }
.toc h2 { font: 600 0.95rem/1.3 var(--sans); margin-bottom: 0.75rem; }
.toc ol { list-style: none; margin: 0; padding: 0 0 0 1rem; border-left: 2px solid var(--line); }
.toc li { padding-block: 0.3rem; }
.toc li.lv3 { padding-left: 0.9rem; }
.toc a { color: var(--muted); text-decoration: none; }
.toc a:hover, .toc a.active { color: var(--ink); }
.toc a.active { font-weight: 600; }
@media (max-width: 70rem) {
  .post.has-toc { grid-template-columns: minmax(0, 46rem); }
  .toc { position: static; order: -1; margin-bottom: 2rem; padding: 1.25rem; background: var(--mist); border-radius: var(--radius); }
}

.prose { font-size: 1.0625rem; line-height: 1.8; }
.prose > * + * { margin-top: 1.15em; }
.prose h2, .prose h3, .prose h4 { margin-top: 2.1em; scroll-margin-top: 1.5rem; }
.prose h2 { font-size: clamp(1.6rem, 3vw, 2.05rem); }
.prose h3 { font-size: 1.4rem; }
.prose h4 { font: 700 1.1rem/1.4 var(--sans); }
.prose > :first-child { margin-top: 0; }
.prose ul, .prose ol { padding-left: 1.35em; }
.prose li + li { margin-top: 0.35em; }
.prose blockquote { margin-inline: 0; padding: 0.25rem 0 0.25rem 1.25rem; border-left: 3px solid var(--gold); font: italic 1.25rem/1.6 var(--serif); }
.prose img { border-radius: 10px; margin-inline: auto; border: 1px solid var(--line); }
.prose p > img ~ em, .prose img + em { display: block; text-align: center; font-size: 0.9rem; color: var(--muted); margin-top: 0.5rem; }
.prose :not(pre) > code { background: var(--code-bg); padding: 0.12em 0.4em; border-radius: 4px; font-size: 0.86em; overflow-wrap: anywhere; }
.prose table { border-collapse: collapse; font-size: 0.95rem; font-variant-numeric: tabular-nums; display: block; overflow-x: auto; }
.prose th, .prose td { border: 1px solid var(--line); padding: 0.55em 1em; text-align: left; vertical-align: top; }
.prose td:first-child { white-space: nowrap; font-variant-numeric: tabular-nums; }
.prose thead th { background: var(--mist); }
.prose hr { border: 0; border-top: 1px solid var(--line); margin-block: 2.5em; }

.hl { position: relative; }
.hl pre { margin: 0; padding: 1.15rem 1.25rem; overflow-x: auto; background: var(--code-bg); border: 1px solid var(--line); border-radius: 12px; font-size: 0.88rem; line-height: 1.65; tab-size: 4; }
.copy {
  position: absolute; top: 0.6rem; right: 0.6rem; font: 600 0.75rem/1 var(--sans); color: var(--ink);
  background: var(--paper); border: 1px solid var(--line); border-radius: 6px; padding: 0.45rem 0.65rem; cursor: pointer; opacity: 0; transition: opacity .15s;
}
.hl:hover .copy, .copy:focus-visible { opacity: 1; }
@media (hover: none) { .copy { opacity: 1; } }

.post-foot .series-nav { max-width: 46rem; margin: 0 auto 3rem; padding: 1.75rem 2rem; background: var(--paper); border-radius: var(--radius); box-shadow: var(--shadow); }
.series-nav h2 { font-size: 1.5rem; margin-bottom: 1rem; }
.series-nav ol { margin: 0; padding-left: 1.4em; }
.series-nav li { padding-block: 0.25rem; }
.series-nav [aria-current] { font-weight: 700; }
.pager { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.75rem; }
.pager-next { grid-column: 2; }
.pager-label { font-weight: 600; color: var(--muted); margin-bottom: 0.75rem; }
@media (max-width: 40rem) { .pager { grid-template-columns: 1fr; } .pager-next { grid-column: 1; } }

/* --- Projects page -------------------------------------------------------------------- */
.project-rows { display: grid; gap: clamp(3rem, 7vw, 5.5rem); }
.project-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: clamp(2rem, 5vw, 4.5rem); align-items: center; scroll-margin-top: 2rem; }
.project-row:nth-child(even) .project-img { order: 2; }
.project-img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: var(--radius); box-shadow: var(--shadow); }
.project-copy h2 { font-size: clamp(1.9rem, 3.5vw, 2.6rem); margin-bottom: 1rem; }
.project-copy > p { color: var(--muted); }
.project-stack { display: flex; align-items: center; gap: 0.5rem; margin-top: 1.1rem; font-weight: 500; color: var(--ink) !important; }
.project-links { display: flex; gap: 0.75rem; margin-top: 1.5rem; }
@media (max-width: 52rem) { .project-row { grid-template-columns: 1fr; } .project-row:nth-child(even) .project-img { order: 0; } }

/* --- About ---------------------------------------------------------------------------- */
.about-grid { display: grid; grid-template-columns: minmax(0, 1fr) 20rem; gap: clamp(2rem, 6vw, 5rem); align-items: start; }
@media (max-width: 56rem) { .about-grid { grid-template-columns: 1fr; } }
.spec { position: sticky; top: 2rem; background: var(--mist) url("../img/topo.svg") center / cover; border-radius: var(--radius); padding: 1.75rem; border: 1px solid var(--line); }
:root[data-theme="dark"] .spec { background-image: url("../img/topo-dark.svg"); }
.spec h2 { font-size: 1.35rem; margin-bottom: 1rem; }
.spec h2 + ul { margin-top: 0; }
.spec dl { margin: 0 0 1.75rem; display: grid; gap: 0.75rem; }
.spec dt { font-size: 0.82rem; color: var(--muted); }
.spec dd { margin: 0; font-weight: 600; }
.spec ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.4rem; font-weight: 600; }

.empty { color: var(--muted); text-align: center; }

/* --- Footer ----------------------------------------------------------------------------- */
.footer-strip { background: var(--mist); border-top: 1px solid var(--line); }
.footer-strip-inner { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 1rem; padding-block: 1.4rem; }
.footer-nav, .footer-social { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0.5rem 1.75rem; font-weight: 600; font-size: 0.9rem; }
.footer-nav a, .footer-social a { color: var(--ink); text-decoration: none; }
.footer-nav a:hover, .footer-social a:hover { color: var(--link); }
.footer-main { background: var(--mask-deep) url("../img/topo-dark.svg") center / cover; color: rgba(255, 255, 255, 0.78); }
.footer-cols { display: grid; grid-template-columns: 1.4fr repeat(3, 1fr); gap: 2.5rem; padding-block: clamp(3rem, 6vw, 4.5rem) 2.5rem; }
@media (max-width: 56rem) { .footer-cols { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 34rem) { .footer-cols { grid-template-columns: 1fr; } }
.footer-cols h2 { color: #fff; font-size: 1.2rem; margin-bottom: 1rem; }
.footer-cols p { font-size: 0.95rem; max-width: 28em; }
.footer-cols ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.5rem; font-size: 0.95rem; }
.footer-cols a { color: rgba(255, 255, 255, 0.82); text-decoration: none; }
.footer-cols a:hover { color: var(--gold); }
.footer-base { padding-block: 0 2rem; font-size: 0.88rem; color: rgba(255, 255, 255, 0.6); }
.footer-base p { border-top: 1px solid rgba(255, 255, 255, 0.14); padding-top: 1.5rem; }

@media print {
  .masthead, .footer, .toc, .pager, .copy, .banner-img, .hero-img { display: none; }
  .banner, .hero { background: none; color: #000; }
  .banner::before, .hero::before { display: none; }
}
