:root {
  --copper: #b87333;
  --copper-10: rgba(184, 115, 51, 0.10);
  --copper-20: rgba(184, 115, 51, 0.20);
  --copper-30: rgba(184, 115, 51, 0.30);
  --copper-40: rgba(184, 115, 51, 0.40);

  --bg: #f8fafc;          /* slate-50 */
  --bg-alt: #f1f5f9;      /* slate-100 */
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --line: #e2e8f0;        /* slate-200 */
  --line-strong: #cbd5e1; /* slate-300 */
  --ink: #020617;         /* slate-950 */
  --ink-2: #0f172a;       /* slate-900 */
  --muted: #475569;       /* slate-600 */
  --faint: #64748b;       /* slate-500 */
  --panel: #020617;       /* code/spec panels stay dark in both themes, as on the main site */
  --panel-line: #1e293b;
  --panel-ink: #cbd5e1;
  --btn-primary-bg: #020617;
  --btn-primary-ink: #ffffff;
  --header-bg: #ffffff;
  --shadow: 0 10px 30px -12px rgba(15, 23, 42, 0.25);

  --f-head: 'Fraunces', ui-serif, Georgia, Cambria, 'Times New Roman', serif;
  --f-body: 'Public Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --f-mono: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --f-brand: 'Playfair Display', ui-serif, Georgia, serif;
}

html.dark {
  --bg: #020617;
  --bg-alt: #0f172a;
  --surface: #0f172a;
  --surface-2: #0b1222;
  --line: #1e293b;
  --line-strong: #334155;
  --ink: #f1f5f9;
  --ink-2: #e2e8f0;
  --muted: #94a3b8;
  --faint: #64748b;
  --btn-primary-bg: var(--copper);
  --btn-primary-ink: #020617;
  --header-bg: #020617;
  --shadow: 0 10px 30px -12px rgba(0, 0, 0, 0.6);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: 5rem; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--f-body);
  font-size: 17px;
  line-height: 1.65;
  transition: background-color .3s, color .3s;
}
::selection { background: rgba(249, 115, 22, 0.3); }
a { color: inherit; }
img { max-width: 100%; height: auto; }
:focus-visible { outline: 2px solid var(--copper); outline-offset: 3px; border-radius: 2px; }

.wrap { max-width: 80rem; margin: 0 auto; padding: 0 24px; }
.wrap-narrow { max-width: 46rem; margin: 0 auto; padding: 0 24px; }
@media (max-width: 640px) { .wrap, .wrap-narrow { padding: 0 16px; } }

/* ---------------------------------------------------------------- header */
.site-header {
  position: fixed; inset: 0 0 auto 0; z-index: 50; height: 4rem;
  background: var(--header-bg); border-bottom: 1px solid var(--line);
  box-shadow: 0 1px 2px rgba(0,0,0,.05); transition: background-color .3s;
}
.site-header .wrap { height: 100%; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand { display: flex; align-items: center; gap: 4px; text-decoration: none; color: inherit; }
.brand-f { font-family: var(--f-brand); font-weight: 700; font-size: 3.75rem; line-height: 1; color: var(--copper); user-select: none; transition: transform .2s; }
.brand:hover .brand-f { transform: scale(1.05); }
.brand-text { display: flex; flex-direction: column; margin-left: 4px; }
.brand-name { margin: 0; font-family: var(--f-body); font-weight: 700; font-size: .75rem; text-transform: uppercase; letter-spacing: -0.01em; line-height: 1.2; color: var(--ink); }
.brand-sub { margin: 2px 0 0; padding-top: 4px; border-top: 1px solid var(--copper-30); font-family: var(--f-mono); font-weight: 700; font-size: .45rem; text-transform: uppercase; letter-spacing: .15em; line-height: 1; color: var(--copper); }
@media (min-width: 768px) {
  .brand-f { font-size: 4.5rem; }
  .brand-name { font-size: .875rem; }
  .brand-sub { font-size: .5rem; }
}
.crumb { font-family: var(--f-mono); font-size: .6rem; font-weight: 700; text-transform: uppercase; letter-spacing: .15em; color: var(--muted); text-decoration: none; margin-left: 18px; padding-left: 14px; border-left: 1px solid var(--line-strong); }
.crumb:hover { color: var(--copper); }
@media (max-width: 520px) { .crumb { display: none; } }
.tools { display: flex; align-items: center; gap: 4px; }
.tool-btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 8px; border-radius: 8px;
  border: 1px solid transparent; background: transparent; color: var(--ink-2); cursor: pointer;
  font: inherit; transition: background-color .2s, border-color .2s, color .2s;
}
.tool-btn:hover { background: var(--bg-alt); border-color: var(--line); }
.tool-btn svg { width: 20px; height: 20px; }
.tool-btn .lvl-label { display: none; font-family: var(--f-mono); font-size: .55rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; }
.tool-btn.is-alt { color: var(--copper); background: var(--copper-10); }
html.dark .tool-btn.is-alt { background: var(--copper-20); }
@media (min-width: 640px) { .tool-btn.is-alt .lvl-label { display: inline; } }
html.dark .icon-moon, html:not(.dark) .icon-sun { display: none; }

main { padding-top: 4rem; }

/* ---------------------------------------------------------------- shared pieces */
.badge {
  display: inline-block; padding: 4px 12px; border: 1px solid var(--copper-40); background: var(--copper-10);
  font-family: var(--f-mono); font-size: .6rem; font-weight: 700; text-transform: uppercase; letter-spacing: .15em; color: var(--copper);
}
.eyebrow { font-family: var(--f-mono); font-size: .65rem; font-weight: 700; text-transform: uppercase; letter-spacing: .2em; color: var(--copper); }
.mono-note { font-family: var(--f-mono); font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .12em; color: var(--muted); }
h1, h2, h3, h4 { font-family: var(--f-head); color: var(--ink); text-wrap: balance; }
.hl { color: var(--copper); font-style: italic; }
.display {
  margin: 1.5rem 0 1.25rem; font-weight: 800; text-transform: uppercase; letter-spacing: -0.02em;
  font-size: clamp(2.2rem, 6.2vw, 4.5rem); line-height: .98;
}
.lede { font-size: 1.15rem; line-height: 1.7; color: var(--muted); max-width: 44rem; }
html:not(.dark) .lede { color: var(--ink-2); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px; position: relative;
  padding: 14px 28px; border: 2px solid var(--ink); text-decoration: none;
  font-family: var(--f-body); font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .12em;
  color: var(--ink); background: transparent; cursor: pointer; transition: transform .15s, background-color .2s;
}
html.dark .btn { border-color: var(--line-strong); }
.btn:hover { transform: translateY(-1px); }
.btn-primary { background: var(--btn-primary-bg); color: var(--btn-primary-ink); border-color: var(--btn-primary-bg); box-shadow: var(--shadow); }
html.dark .btn-primary { border-color: var(--copper); }
.btn-primary::before, .btn-primary::after { content: ""; position: absolute; width: 4px; height: 4px; background: currentColor; }
.btn-primary::before { top: 4px; left: 4px; }
.btn-primary::after { bottom: 4px; right: 4px; }
html:not(.dark) .btn-primary::before, html:not(.dark) .btn-primary::after { background: #fff; }

/* ---------------------------------------------------------------- reading levels
   Any element with data-lv="technical standard eli5" (space separated) shows only at those levels.
   blog.js sets html[data-level]. Without it, the technical copy shows. */
html[data-level="technical"] [data-lv]:not([data-lv~="technical"]),
html[data-level="standard"] [data-lv]:not([data-lv~="standard"]),
html[data-level="eli5"] [data-lv]:not([data-lv~="eli5"]),
html:not([data-level]) [data-lv]:not([data-lv~="technical"]) { display: none !important; }

/* ---------------------------------------------------------------- post */
.post-hero { padding: 3.5rem 0 3rem; border-bottom: 1px solid var(--line); position: relative; overflow: hidden; }
.post-meta { display: flex; flex-wrap: wrap; gap: 8px 22px; margin-top: 1.75rem; }
.post-meta span { font-family: var(--f-mono); font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .12em; color: var(--muted); }
.post-meta b { color: var(--copper); font-weight: 700; }
.status-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--copper); margin-right: 6px; vertical-align: 1px; animation: pulse 2s infinite; }
@keyframes pulse { 50% { opacity: .35; } }
@media (prefers-reduced-motion: reduce) { .status-dot { animation: none; } html { scroll-behavior: auto; } }

.post-layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: 3rem; padding: 3.5rem 0 4rem; }
@media (min-width: 1100px) { .post-layout { grid-template-columns: minmax(0, 1fr) 16rem; } }
.toc { display: none; }
@media (min-width: 1100px) {
  .toc { display: block; position: sticky; top: 6rem; align-self: start; border-left: 1px solid var(--line); padding-left: 20px; }
  .toc ol { list-style: none; margin: 12px 0 0; padding: 0; counter-reset: toc; }
  .toc li { counter-increment: toc; margin: 0 0 10px; }
  .toc a { text-decoration: none; font-size: .82rem; color: var(--muted); display: flex; gap: 10px; line-height: 1.35; }
  .toc a::before { content: counter(toc, decimal-leading-zero); font-family: var(--f-mono); font-size: .65rem; color: var(--copper); padding-top: 2px; }
  .toc a:hover { color: var(--ink); }
}

.prose { max-width: 46rem; min-width: 0; }
.prose > * + * { margin-top: 1.1em; }
.prose p, .prose li { color: var(--ink-2); }
html.dark .prose p, html.dark .prose li { color: #cbd5e1; }
.prose h2 {
  margin: 3.25rem 0 0; padding-top: 1.25rem; border-top: 1px solid var(--line);
  font-size: clamp(1.6rem, 3.6vw, 2.25rem); font-weight: 800; text-transform: uppercase; letter-spacing: -0.015em; line-height: 1.05;
}
.prose h2 .eyebrow { display: block; margin-bottom: .6rem; }
.prose h3 { margin-top: 2rem; font-size: 1.3rem; font-weight: 700; line-height: 1.2; }
.prose a { color: var(--copper); text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; }
.prose strong { color: var(--ink); }
.prose ul, .prose ol { padding-left: 1.25rem; }
.prose li + li { margin-top: .4em; }
.prose code { font-family: var(--f-mono); font-size: .86em; padding: 1px 6px; background: var(--bg-alt); border: 1px solid var(--line); border-radius: 3px; overflow-wrap: anywhere; }
.prose hr { border: 0; border-top: 1px solid var(--line); margin: 3rem 0; }

/* code block with label + copy button */
.code {
  position: relative; background: var(--panel); border: 1px solid var(--panel-line); color: var(--panel-ink);
  font-family: var(--f-mono); font-size: .82rem; line-height: 1.7; margin: 1.25rem 0;
}
.code-head { display: flex; justify-content: space-between; align-items: center; padding: 8px 14px; border-bottom: 1px solid var(--panel-line); }
.code-head span { font-size: .62rem; font-weight: 700; text-transform: uppercase; letter-spacing: .15em; color: var(--copper); }
.copy-btn { font: inherit; font-size: .62rem; font-weight: 700; text-transform: uppercase; letter-spacing: .15em; color: #94a3b8; background: none; border: 1px solid #334155; padding: 3px 10px; cursor: pointer; }
.copy-btn:hover { color: var(--copper); border-color: var(--copper); }
.code pre { margin: 0; padding: 14px 16px; overflow-x: auto; white-space: pre; }
.code .c { color: #64748b; }
.code .k { color: var(--copper); }

/* spec panel, like the home page's Registry_Spec */
.spec { background: var(--panel); border: 1px solid var(--panel-line); padding: 22px 24px; font-family: var(--f-mono); font-size: .78rem; color: var(--panel-ink); box-shadow: var(--shadow); }
.spec-head { display: flex; justify-content: space-between; gap: 12px; padding-bottom: 12px; margin-bottom: 14px; border-bottom: 1px solid var(--panel-line); font-size: .62rem; font-weight: 700; text-transform: uppercase; letter-spacing: .15em; color: var(--copper); }
.spec-head .ok { color: var(--copper); }
.spec dl { display: grid; grid-template-columns: auto 1fr; gap: 6px 18px; margin: 0; }
.spec dt { color: #64748b; text-transform: uppercase; letter-spacing: .06em; }
.spec dd { margin: 0; color: #e2e8f0; }
.spec .cmt { margin-top: 14px; color: var(--copper); opacity: .85; white-space: pre-line; }

/* numbered principle cards (01 02 03) */
.mechanics { display: grid; gap: 1.5rem; margin: 1.75rem 0; }
.mech { display: grid; grid-template-columns: 2.5rem 1fr; gap: 16px; align-items: start; }
.mech-num { width: 2.5rem; height: 2.5rem; display: grid; place-items: center; border: 1px solid var(--copper); font-family: var(--f-mono); font-size: .8rem; font-weight: 700; color: var(--copper); }
.mech h3 { margin: 0 0 4px; font-size: 1.05rem; font-weight: 800; text-transform: uppercase; letter-spacing: -0.01em; }
.mech p { margin: 0; color: var(--muted) !important; font-size: .95rem; }

/* step list */
.steps { list-style: none; padding: 0 !important; margin: 2rem 0 0; counter-reset: step; }
.step { counter-increment: step; position: relative; padding: 0 0 2.25rem 3.75rem; margin: 0 !important; }
.step::before {
  content: counter(step, decimal-leading-zero); position: absolute; left: 0; top: 0; width: 2.5rem; height: 2.5rem;
  display: grid; place-items: center; border: 1px solid var(--copper); background: var(--copper-10);
  font-family: var(--f-mono); font-size: .8rem; font-weight: 700; color: var(--copper);
}
.step::after { content: ""; position: absolute; left: calc(1.25rem - .5px); top: 2.75rem; bottom: .5rem; width: 1px; background: var(--line); }
.step:last-child::after { display: none; }
.step h3 { margin: 0 0 .5rem; padding-top: .35rem; font-size: 1.2rem; }
.step > p { margin: .5rem 0; }

/* callouts */
.note { border: 1px solid var(--line); border-left: 3px solid var(--copper); background: var(--surface); padding: 16px 20px; margin: 1.5rem 0; }
.note .eyebrow { display: block; margin-bottom: 6px; }
.note p { margin: 0; }
.note p + p { margin-top: .6em; }
.note.warn { border-left-color: #f97316; }

/* failure modes table */
.table-wrap { overflow-x: auto; margin: 1.5rem 0; border: 1px solid var(--line); }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th { text-align: left; font-family: var(--f-mono); font-size: .62rem; font-weight: 700; text-transform: uppercase; letter-spacing: .15em; color: var(--copper); background: var(--surface); padding: 12px 14px; border-bottom: 1px solid var(--line); }
td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: top; color: var(--ink-2); }
html.dark td { color: #cbd5e1; }
tr:last-child td { border-bottom: 0; }
td:first-child { font-weight: 600; color: var(--ink); min-width: 10rem; }

/* download panel */
.download { display: grid; gap: 18px; align-items: center; background: var(--surface); border: 1px solid var(--line); padding: 24px; margin: 2rem 0; box-shadow: var(--shadow); }
@media (min-width: 640px) { .download { grid-template-columns: 1fr auto; } }
.download h3 { margin: 0 0 4px; font-size: 1.2rem; text-transform: uppercase; }
.download p { margin: 0; color: var(--muted) !important; font-size: .92rem; }

/* link back to the blog page at the end of a post */
.back { margin-top: 4rem; padding-top: 2rem; border-top: 1px solid var(--line); font-family: var(--f-mono); font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .12em; }
.prose .back a { text-decoration: none; }

/* ---------------------------------------------------------------- index */
.index-hero { padding: 4rem 0 3rem; border-bottom: 1px solid var(--line); }
.feed { display: grid; gap: 1.5rem; padding: 3rem 0 4rem; }
@media (min-width: 900px) { .feed { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.card {
  display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line);
  text-decoration: none; color: inherit; transition: border-color .2s, transform .2s; min-width: 0;
}
.card:hover { border-color: var(--copper); transform: translateY(-2px); }
.card-top { padding: 22px 24px 0; display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.card-tag { padding: 3px 10px; border: 1px solid var(--copper); font-family: var(--f-mono); font-size: .58rem; font-weight: 700; text-transform: uppercase; letter-spacing: .12em; color: var(--ink); }
.card-date { font-family: var(--f-mono); font-size: .62rem; font-weight: 700; text-transform: uppercase; letter-spacing: .12em; color: var(--faint); }
.card-body { padding: 16px 24px 22px; flex: 1; }
.card h2 { margin: 0 0 10px; font-size: 1.45rem; font-weight: 800; text-transform: uppercase; line-height: 1.08; letter-spacing: -0.01em; }
.card p { margin: 0; font-family: var(--f-mono); font-size: .78rem; line-height: 1.65; color: var(--muted); }
.card-foot { margin: 0 24px; padding: 16px 0 20px; border-top: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; }
.card-foot span { font-family: var(--f-body); font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .15em; }
.card-foot .go { color: var(--copper); }
/* the newest post (first in the list) gets the wide, copper-edged card */
.feed > .card:first-of-type { border-left: 3px solid var(--copper); }
@media (min-width: 900px) { .feed > .card:first-of-type { grid-column: 1 / -1; } .feed > .card:first-of-type h2 { font-size: 2rem; } }

/* ---------------------------------------------------------------- footer */
.site-footer { border-top: 1px solid var(--line); background: var(--bg); padding: 3rem 0 2rem; }
html.dark .site-footer { background: #020617; }
.foot-top { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 24px; align-items: center; }
.foot-name { margin: 0 0 12px; font-family: var(--f-head); font-weight: 800; font-size: 1.35rem; text-transform: uppercase; letter-spacing: -0.02em; }
.foot-line { margin: 0; font-family: var(--f-mono); font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); }
.foot-line a { color: var(--copper); text-decoration: none; }
.foot-links { display: flex; gap: 28px; flex-wrap: wrap; }
.foot-links a { font-family: var(--f-mono); font-size: .8rem; text-decoration: none; color: var(--ink-2); }
.foot-links a:hover { color: var(--copper); }
.to-top { display: table; margin: 2.5rem auto; padding: 8px 22px; border: 1px solid var(--line-strong); font-family: var(--f-mono); font-size: .62rem; font-weight: 700; text-transform: uppercase; letter-spacing: .2em; color: var(--copper); text-decoration: none; }
.foot-bottom { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px; padding-top: 1.5rem; border-top: 1px solid var(--line); }
.foot-bottom span { font-family: var(--f-mono); font-size: .62rem; font-weight: 700; text-transform: uppercase; letter-spacing: .15em; color: var(--muted); }

/* post hero: headline left, spec panel right on wide screens */
.hero-grid { display: grid; gap: 2.5rem; grid-template-columns: minmax(0, 1fr); align-items: start; }
@media (min-width: 1100px) { .hero-grid { grid-template-columns: minmax(0, 1fr) 24rem; } .hero-grid .spec { margin-top: 3rem; } }

/* buttons inside a post keep button colours, not link colours */
.prose a.btn { text-decoration: none; color: var(--ink); }
.prose a.btn-primary { color: var(--btn-primary-ink); }
.prose > h2:first-child { margin-top: 0; border-top: 0; padding-top: 0; }

/* replaces the style="" attributes the pages used to carry */
.brand-row { display: flex; align-items: center; }
.foot-line a.plain { color: inherit; }
.prose h3.sub { font-size: 1.05rem; margin-top: 1.25rem; }
