/* ============================================================
   0xc0ffee — blog.0xc0ff.ee
   A brutalist theme for a programming blog
   Palette derives from unstyled HTML: default link blue,
   default visited purple, ink on paper-grey.
   Extracted from the single-file demo (theme/demo.html).
   ============================================================ */

:root {
  --paper:    #E8E8E3;
  --surface:  #F3F3EF;
  --ink:      #14141A;
  --ink-soft: #55555F;
  --rule:     #14141A;
  --hairline: rgba(20, 20, 26, 0.22);
  --link:     #0F00E5;
  --visited:  #6E1FB8;
  --invert-bg: #14141A;
  --invert-fg: #E8E8E3;

  --display: "Martian Mono", ui-monospace, monospace;
  --body:    "Spline Sans Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --mono:    "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;

  --gutter: clamp(1rem, 4vw, 3rem);
  --measure: 34rem;
  --rule-w: 2px;
}

[data-theme="dark"] {
  --paper:    #101013;
  --surface:  #191920;
  --ink:      #E8E7E1;
  --ink-soft: #8E8E99;
  --rule:     #E8E7E1;
  --hairline: rgba(232, 231, 225, 0.24);
  --link:     #8E9BFF;
  --visited:  #C79CFF;
  --invert-bg: #E8E7E1;
  --invert-fg: #101013;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--body);
  font-size: 1.0625rem;
  line-height: 1.62;
  font-synthesis-weight: none;
  transition: background-color 120ms linear, color 120ms linear;
}

::selection { background: var(--ink); color: var(--paper); }

a { color: var(--link); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:visited { color: var(--visited); }

:focus-visible {
  outline: var(--rule-w) solid var(--ink);
  outline-offset: 3px;
}

/* ---------- shared shell ---------- */

.shell {
  max-width: 68rem;
  margin: 0 auto;
  padding: 0 var(--gutter);
}

.rule-top { border-top: var(--rule-w) solid var(--rule); }

.label {
  font-family: var(--mono);
  font-size: 0.6875rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

/* ---------- masthead ---------- */

.masthead {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--paper);
  border-bottom: var(--rule-w) solid var(--rule);
}

.masthead__inner {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  min-height: 3.25rem;
}

.wordmark {
  font-family: var(--mono);
  font-weight: 600;
  font-size: 1rem;
  letter-spacing: -0.02em;
  color: var(--ink);
  text-decoration: none;
  white-space: nowrap;
}
.wordmark:visited { color: var(--ink); }
.wordmark span { color: var(--ink-soft); }

.masthead__nav {
  display: flex;
  gap: 1rem;
  margin-left: auto;
  font-family: var(--mono);
  font-size: 0.75rem;
  letter-spacing: 0.06em;
}
.masthead__nav a { color: var(--ink); text-decoration: none; padding: 0.15rem 0; }
.masthead__nav a:visited { color: var(--ink); }
.masthead__nav a:hover { background: var(--ink); color: var(--paper); }
.masthead__nav a[aria-current="page"] { text-decoration: underline; text-underline-offset: 4px; }

/* theme switch — reads as a literal two-state toggle */
.switch {
  display: flex;
  border: var(--rule-w) solid var(--rule);
  font-family: var(--mono);
  font-size: 0.6875rem;
  letter-spacing: 0.1em;
}
.switch button {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  letter-spacing: inherit;
  padding: 0.3rem 0.5rem;
  cursor: pointer;
}
.switch button + button { border-left: var(--rule-w) solid var(--rule); }
.switch button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }

/* ---------- hero ---------- */

/* vertical only — horizontal gutter comes from .shell */
.hero { padding-top: clamp(2.5rem, 8vw, 5.5rem); padding-bottom: 2rem; }

.hero__eyebrow { display: block; margin-bottom: 1.5rem; }

.hero__statement {
  font-family: var(--display);
  font-weight: 800;
  font-size: clamp(2.25rem, 7.5vw, 4.75rem);
  line-height: 0.94;
  letter-spacing: -0.035em;
  margin: 0;
  max-width: 16ch;
  text-wrap: balance;
}
.hero__statement em {
  font-style: normal;
  display: inline-block;
  background: var(--ink);
  color: var(--paper);
  padding: 0 0.12em;
}

.hero__dek {
  margin: 1.75rem 0 0;
  max-width: 42ch;
  font-size: 1.125rem;
  color: var(--ink);
}

.hero__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0 2rem;
  margin-top: 2.5rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--hairline);
}

/* ---------- index list (signature element) ---------- */

.index { border-top: var(--rule-w) solid var(--rule); }

.entry {
  display: grid;
  grid-template-columns: 4.5rem 1fr 6.5rem;
  gap: 0 1.5rem;
  padding: 1.25rem 0.75rem 1.35rem;
  border-bottom: 1px solid var(--hairline);
  text-decoration: none;
  color: inherit;
  transition: background-color 90ms linear, color 90ms linear;
}
.entry:visited { color: inherit; }
.entry:hover,
.entry:focus-visible {
  background: var(--invert-bg);
  color: var(--invert-fg);
  outline-offset: -2px;
}
.entry:hover .entry__no,
.entry:hover .entry__meta,
.entry:hover .entry__dek { color: inherit; }

.entry__no {
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--ink-soft);
  padding-top: 0.35rem;
}

.entry__title {
  font-family: var(--display);
  font-weight: 700;
  font-size: clamp(1.25rem, 2.6vw, 1.65rem);
  line-height: 1.12;
  letter-spacing: -0.02em;
  margin: 0;
  text-wrap: balance;
}

.entry__dek {
  margin: 0.5rem 0 0;
  color: var(--ink-soft);
  font-size: 0.9375rem;
  max-width: 52ch;
}

.entry__meta {
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--ink-soft);
  text-align: right;
  padding-top: 0.35rem;
  white-space: nowrap;
}

.entry__tags {
  display: block;
  margin-top: 0.35rem;
  font-size: 0.6875rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* ---------- article ---------- */

.article { padding-top: clamp(2rem, 6vw, 4rem); }

.article__title {
  /* measured in the title's own font, like .hero__statement */
  max-width: 30ch;
  font-family: var(--display);
  font-weight: 800;
  font-size: clamp(2rem, 6vw, 3.5rem);
  line-height: 0.98;
  letter-spacing: -0.035em;
  margin: 1rem 0 0;
  text-wrap: balance;
}

.article__standfirst {
  margin: 1.5rem 0 0;
  max-width: 46ch;
  font-size: 1.1875rem;
  color: var(--ink-soft);
}

.article__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0 1.75rem;
  margin: 2.25rem 0 0;
  padding: 0.6rem 0;
  border-top: var(--rule-w) solid var(--rule);
  border-bottom: 1px solid var(--hairline);
}

/* the gutter carries section numbers — order is real here */
.prose {
  display: grid;
  grid-template-columns: 4.5rem minmax(0, var(--measure));
  gap: 0 1.5rem;
  padding: 2.5rem 0 4rem;
}
.prose > * { grid-column: 2; }

.prose h2 {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: subgrid;
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.5rem;
  letter-spacing: -0.02em;
  line-height: 1.15;
  margin: 3rem 0 1rem;
  padding-top: 0.75rem;
  border-top: var(--rule-w) solid var(--rule);
}
.prose h2 .sec {
  grid-column: 1;
  font-family: var(--mono);
  font-size: 0.75rem;
  font-weight: 400;
  color: var(--ink-soft);
  padding-top: 0.4rem;
}
.prose h2 .sec-title { grid-column: 2; }

.prose p { margin: 0 0 1.35rem; }
.prose p:first-of-type::first-line { font-variant-caps: small-caps; letter-spacing: 0.02em; }

.prose ul { margin: 0 0 1.35rem; padding-left: 1.1rem; }
.prose li { margin-bottom: 0.5rem; }
.prose li::marker { content: "— "; font-family: var(--mono); }

.prose strong { font-weight: 700; }

code {
  font-family: var(--mono);
  font-size: 0.85em;
  background: var(--surface);
  border: 1px solid var(--hairline);
  padding: 0.05em 0.3em;
}

pre {
  font-family: var(--mono);
  font-size: 0.8125rem;
  line-height: 1.6;
  background: var(--surface);
  border: var(--rule-w) solid var(--rule);
  padding: 1rem 1.1rem;
  margin: 0 0 1.5rem;
  overflow-x: auto;
}
pre code { background: none; border: 0; padding: 0; font-size: inherit; }

.callout {
  border: var(--rule-w) solid var(--rule);
  padding: 1.1rem 1.2rem;
  margin: 0 0 1.5rem;
  background: var(--surface);
}
.callout p { margin: 0.4rem 0 0; }
.callout p:last-child { margin-bottom: 0; }

blockquote {
  margin: 2rem 0;
  padding-left: 1.1rem;
  border-left: var(--rule-w) solid var(--rule);
  font-family: var(--display);
  font-weight: 600;
  font-size: 1.375rem;
  line-height: 1.25;
  letter-spacing: -0.02em;
}

figure { margin: 0 0 1.5rem; }
figcaption { margin-top: 0.5rem; }

/* ---------- footer ---------- */

.footer {
  border-top: var(--rule-w) solid var(--rule);
  padding: 2rem 0 3rem;
}
.footer__inner {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 2rem;
  align-items: baseline;
}
.footer a { color: var(--ink); }
.footer__spacer { margin-left: auto; }

/* ---------- responsive ---------- */

@media (max-width: 46rem) {
  .entry {
    grid-template-columns: 3.25rem 1fr;
    padding-right: 0.5rem;
  }
  .entry__meta { grid-column: 2; text-align: left; padding-top: 0.6rem; }
  .prose { grid-template-columns: minmax(0, 1fr); }
  .prose > * { grid-column: 1; }
  .prose h2 { display: block; }
  .prose h2 .sec { display: block; padding: 0 0 0.35rem; }
  .masthead__nav { gap: 0.75rem; }
}

@media (max-width: 30rem) {
  .masthead__inner { flex-wrap: wrap; padding-top: 0.6rem; padding-bottom: 0.6rem; }
  .masthead__nav { margin-left: 0; order: 3; width: 100%; }
  .switch { margin-left: auto; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

@media print {
  .masthead, .switch, .footer { display: none; }
  body { background: #fff; color: #000; }
}

.wordmark { font-weight: 700; font-size: 1.0625rem; letter-spacing: -0.04em; }
.wordmark span { font-weight: 400; }

/* ---------- variant: TERMINAL ----------
   One idea, carried all the way: the whole page is set in monospace.
   Mono runs wide, so the measure narrows and the display sizes drop. */
body { font-size: 0.9375rem; line-height: 1.75; }
:root { --measure: 31rem; }

.hero__statement {
  font-size: clamp(1.65rem, 5vw, 3.35rem);
  font-weight: 700;
  line-height: 1.12;
  letter-spacing: -0.045em;
  text-transform: uppercase;
  max-width: 19ch;
}
.hero__statement em { padding: 0 0.1em; }
.hero__dek { font-size: 1rem; max-width: 48ch; }

.entry__title {
  font-size: clamp(1rem, 2vw, 1.2rem);
  font-weight: 700;
  line-height: 1.35;
  letter-spacing: -0.03em;
}
.entry__dek { font-size: 0.875rem; line-height: 1.6; }

.article__title {
  font-size: clamp(1.5rem, 4.4vw, 2.5rem);
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.045em;
}
.article__title { max-width: 24ch; }
.article__standfirst { font-size: 1.0625rem; }

.prose h2 { font-size: 1.0625rem; font-weight: 700; letter-spacing: -0.03em; line-height: 1.35; }
.prose p:first-of-type::first-line { font-variant-caps: normal; letter-spacing: 0; }
blockquote { font-size: 1.0625rem; font-weight: 700; line-height: 1.45; letter-spacing: -0.03em; }


/* ---------- figures ---------- */
.prose .codeblock,
.prose .diagram { grid-column: 1 / -1; }

.codeblock, .diagram {
  margin: 0 0 1.75rem;
  border: var(--rule-w) solid var(--rule);
  background: var(--surface);
}

.codeblock__bar {
  display: flex;
  gap: 1rem;
  align-items: baseline;
  padding: 0.45rem 0.7rem;
  border-bottom: 1px solid var(--hairline);
}
.codeblock__bar .label { color: var(--ink); }
.codeblock__bar .label + .label { margin-left: auto; color: var(--ink-soft); }

.codeblock pre { border: 0; margin: 0; background: none; }

.diagram svg { display: block; width: 100%; height: auto; padding: 1.5rem 1rem; }
.diagram text {
  font-family: var(--mono);
  font-size: 13px;
  letter-spacing: 0.06em;
  fill: currentColor;
}
.diagram text.dim { fill: var(--ink-soft); font-size: 11px; }

figure img { display: block; width: 100%; height: auto; border: var(--rule-w) solid var(--rule); }

figcaption {
  padding: 0.5rem 0.7rem;
  border-top: 1px solid var(--hairline);
  color: var(--ink-soft);
}
.diagram figcaption, .codeblock figcaption { background: var(--paper); }

/* ---------- syntax highlighting ----------
   Pre-tokenised at build time with Pygments class names, so highlighting
   works with JavaScript off. Four roles only: keywords carry weight,
   types take the visited purple, strings and calls take the link blue,
   everything structural stays quiet. */
.c, .c1, .cm, .cp, .cs, .sd { color: var(--ink-soft); }        /* comments */
.k, .kd, .kn, .kp, .kr, .kc { color: var(--ink); font-weight: 600; }
.kt, .nc, .nb, .nn { color: var(--visited); }                  /* types */
.nf, .fm, .nd { color: var(--link); }                          /* fns, attrs */
.s, .s1, .s2, .sc, .se { color: var(--link); }                 /* strings */
.m, .mf, .mi, .mh, .il { color: var(--visited); }              /* numbers */
.o, .ow, .p, .n { color: inherit; }
.na { color: var(--ink-soft); }
