/* Theme modelled on ascii.rest: Paper Mono, quiet greys, [bracketed] links, light and dark. */

@font-face { font-family: "Paper Mono"; font-weight: 400; font-style: normal; font-display: swap; src: url("/fonts/PaperMono-Regular.woff2") format("woff2"); }
@font-face { font-family: "Paper Mono"; font-weight: 700; font-style: normal; font-display: swap; src: url("/fonts/PaperMono-Bold.woff2") format("woff2"); }

:root {
  --mono: "Paper Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;

  /* dark (default) */
  --bg: #131518;
  --well: #1a1d21;
  --ink: #e8ebef;
  --text: #c3c9d1;
  --muted: #8c95a1;
  --rule: #2a2e34;
  --tag-bg: #e8ebef;
  --tag-ink: #131518;

  --sidebar: 186px;
  --gutter: 84px;
  --measure: 72ch;

  color-scheme: dark;
}

/* Light theme: follows the system unless the reader picked one with the toggle. */
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f5f6f7;
    --well: #eceef0;
    --ink: #1e2125;
    --text: #3b4149;
    --muted: #5f6873;
    --rule: #d9dde1;
    --tag-bg: #1e2125;
    --tag-ink: #f5f6f7;
    color-scheme: light;
  }
}
:root[data-theme="light"] {
  --bg: #f5f6f7;
  --well: #eceef0;
  --ink: #1e2125;
  --text: #3b4149;
  --muted: #5f6873;
  --rule: #d9dde1;
  --tag-bg: #1e2125;
  --tag-ink: #f5f6f7;
  color-scheme: light;
}

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

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--mono);
  font-size: 14px;
  line-height: 1.65;
  letter-spacing: 0.01em;
  -webkit-font-smoothing: antialiased;
}

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

a { color: var(--ink); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 0.25em; }
:focus-visible { outline: 1px dashed var(--ink); outline-offset: 3px; }

h1, h2, h3, h4 { color: var(--ink); font-weight: 400; font-size: 1em; line-height: 1.5; margin: 0; }

.muted { color: var(--muted); }

/* [bracketed] controls, as on ascii.rest */
.bracket {
  font: inherit;
  color: var(--ink);
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  white-space: nowrap;
}
.bracket::before { content: "["; }
.bracket::after { content: "]"; }
.bracket.muted { color: var(--muted); }
.bracket:hover { text-decoration: none; color: var(--ink); }
.bracket:hover::before, .bracket:hover::after { color: var(--muted); }

.skip-link { position: absolute; left: -9999px; }
.skip-link:focus { left: 16px; top: 16px; z-index: 10; background: var(--tag-bg); color: var(--tag-ink); padding: 2px 8px; }

.nowrap { white-space: nowrap; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

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

.shell {
  display: grid;
  grid-template-columns: var(--sidebar) minmax(0, 1fr);
  gap: 43px;
  max-width: 1440px;
  padding: 64px var(--gutter) 0;
}

.sidebar {
  position: sticky;
  top: 64px;
  align-self: start;
  max-height: calc(100vh - 64px);
  overflow-y: auto;
  padding-bottom: 32px;
}
.brand { color: var(--ink); }
.byline { margin: 0 0 14px; color: var(--muted); font-size: 12px; }
.byline a { color: var(--text); }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a[aria-current="page"] { color: var(--ink); text-decoration: underline; text-underline-offset: 0.25em; }

.side-section { margin-top: 32px; }
.side-head, .section-head {
  display: flex;
  justify-content: space-between;
  color: var(--ink);
  font-size: 1em;
  margin-bottom: 6px;
}
.count { color: var(--muted); }
.side-list { list-style: none; margin: 0; padding: 0; }
.side-list li { margin: 0 0 4px; line-height: 1.45; }
.side-list a { color: var(--muted); }
.side-list a:hover, .side-list a[aria-current="page"] { color: var(--ink); }

.main { min-width: 0; max-width: 1043px; }

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
  margin-bottom: 40px;
}
.crumb { color: var(--ink); }
.actions { display: flex; gap: 18px; }

.site-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px 24px;
  margin-top: 96px;
  padding: 18px 0 40px;
  border-top: 1px dashed var(--rule);
  color: var(--muted);
  font-size: 12px;
}
.site-footer a { color: var(--text); }

/* ---------- ascii art ---------- */

/* A text piece scales its font so its columns fill the box, like ascii.rest's --fit. */
.ascii {
  display: block;
  margin: 0;
  color: var(--ink);
  font-family: var(--mono);
  line-height: 1.2;
  letter-spacing: 0;
  white-space: pre;
  overflow: hidden;
}
/* 0.6075em is Paper Mono's advance width (measured), so --cols characters exactly fill the box. */
pre.ascii { font-size: min(calc(100cqi / (var(--cols) * 0.6075)), var(--max-size, 14px)); }
canvas.ascii { width: 100%; height: auto; }

.well {
  margin: 0;
  padding: 16px;
  background: var(--well);
  container-type: inline-size;
}
.well figcaption { margin-top: 12px; color: var(--muted); font-size: 12px; }
.well figcaption a { color: var(--muted); text-decoration: underline; text-underline-offset: 0.25em; }

/* ---------- home ---------- */

.hero { container-type: inline-size; margin-bottom: 48px; }
.hero-banner { --max-size: 11px; color: var(--ink); }
.hero h1 { margin: 22px 0 4px; }
.hero-typewriter { --max-size: 14px; color: var(--muted); margin-bottom: 28px; }

/* ---------- prose ---------- */

.prose { max-width: var(--measure); }
.prose p { margin: 0 0 1.1em; }
.prose strong { color: var(--ink); font-weight: 700; }
.prose em { font-style: italic; }
.prose a { color: var(--ink); text-decoration: underline; text-decoration-color: var(--muted); text-underline-offset: 0.25em; }
.prose a:hover { text-decoration-color: var(--ink); }
.prose a.bracket { text-decoration: none; }
.prose h2, .prose h3, .prose h4 { margin: 2.4em 0 0.9em; }
.prose h2::before { content: "## "; color: var(--muted); }
.prose h3::before { content: "### "; color: var(--muted); }
.prose h4::before { content: "#### "; color: var(--muted); }
.prose ul, .prose ol { margin: 0 0 1.1em; padding-left: 2ch; }
.prose ul { list-style: none; }
.prose ul > li::before { content: "-"; color: var(--muted); margin-left: -2ch; display: inline-block; width: 2ch; }
.prose ol > li::marker { color: var(--muted); }
.prose li { margin: 0 0 0.4em; }
.prose li > p { margin: 0; }
.prose blockquote { margin: 0 0 1.1em; padding-left: 2ch; border-left: 1px solid var(--muted); color: var(--muted); }
.prose hr { border: 0; margin: 2em 0; height: 1.65em; }
.prose hr::before { content: "· · ·"; display: block; text-align: center; color: var(--muted); }
.prose code { color: var(--ink); background: var(--well); padding: 0 0.3em; }
.prose pre { background: var(--well); padding: 16px; overflow-x: auto; }
.prose img { max-width: 100%; height: auto; }
.prose .findings { padding-left: 0; }
.prose .findings > li::before { content: none; }

/* ---------- blog index ---------- */

.blog-index { max-width: var(--measure); }
.section-head { margin-bottom: 18px; }
.entries { list-style: none; margin: 0; padding: 0; }
.entry { padding: 22px 0 26px; border-top: 1px dashed var(--rule); }
.entry h2 { margin: 2px 0 10px; }
.entry .excerpt { font-size: 13px; }
.entry .excerpt p { margin-bottom: 0.8em; }
.meta { margin: 0; color: var(--muted); font-size: 12px; }

/* ---------- post ---------- */

.post { max-width: var(--measure); }
.post h1 { margin: 6px 0 40px; font-size: 18px; line-height: 1.45; }

.pager {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  max-width: var(--measure);
  margin-top: 64px;
  padding-top: 22px;
  border-top: 1px dashed var(--rule);
}
.pager a { display: flex; flex-direction: column; gap: 4px; color: var(--muted); }
.pager a:hover { text-decoration: none; color: var(--ink); }
.pager-title { color: var(--text); }
.pager-next { grid-column: 2; text-align: right; }

/* ---------- readme ---------- */

.readme {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 420px);
  gap: 48px;
  align-items: start;
}
.readme h1 { margin-bottom: 1.4em; }
.readme-terminal { position: sticky; top: 64px; }

/* ---------- 404 ---------- */

.not-found { max-width: 640px; }
.not-found .well { margin-bottom: 24px; }
.not-found p { display: flex; gap: 18px; }

/* ---------- small screens ---------- */

@media (max-width: 900px) {
  .readme { grid-template-columns: 1fr; }
  .readme-terminal { position: static; }
}

@media (max-width: 760px) {
  .shell { display: block; padding: 40px 20px 0; }
  .sidebar { position: static; max-height: none; overflow: visible; padding-bottom: 0; margin-bottom: 28px; }
  .nav { flex-direction: row; flex-wrap: wrap; gap: 4px 16px; }
  .side-section { display: none; }
  .topbar { margin-bottom: 28px; }
  .pager { grid-template-columns: 1fr; }
  .pager-next { grid-column: 1; text-align: left; }
  .site-footer { margin-top: 64px; }
}
