/* stuffaboutcode.com
   Tokens are oklch() on purpose -- the palette was tuned in that space.
   Dark is the default; light is a toggle on :root[data-theme="light"]. */

:root {
  --bg:      oklch(0.19 0.012 260);
  --surface: oklch(0.225 0.014 260);
  --codebg:  oklch(0.16 0.012 260);
  --chip:    oklch(0.26 0.016 260);
  --line:    oklch(0.32 0.014 260);
  --fg:      oklch(0.93 0.008 260);
  --muted:   oklch(0.66 0.012 260);
  --accent:  oklch(0.8 0.14 165);
  --accent2: oklch(0.8 0.13 75);

  /* syntax */
  --kw:  oklch(0.78 0.13 320);
  --str: oklch(0.83 0.13 100);
  --com: oklch(0.6 0.02 260);
  --num: oklch(0.8 0.12 40);

  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --sans: "IBM Plex Sans", system-ui, -apple-system, sans-serif;
}

:root[data-theme="light"] {
  --bg:      oklch(0.98 0.005 95);
  --surface: oklch(0.955 0.008 95);
  --codebg:  oklch(0.945 0.008 95);
  --chip:    oklch(0.925 0.01 95);
  --line:    oklch(0.875 0.01 95);
  --fg:      oklch(0.245 0.012 260);
  --muted:   oklch(0.52 0.012 260);
  --accent:  oklch(0.52 0.13 165);
  --accent2: oklch(0.55 0.13 60);

  --kw:  oklch(0.48 0.16 320);
  --str: oklch(0.45 0.12 130);
  --com: oklch(0.6 0.02 260);
  --num: oklch(0.45 0.12 40);
}

/* ---------------------------------------------------------------- base */

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--mono);
  font-size: 15px;
  line-height: 1.6;
  padding-bottom: 80px;
  min-height: 100vh;
  -webkit-text-size-adjust: 100%;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent2); }
::selection { background: var(--accent); color: var(--bg); }

img { max-width: 100%; height: auto; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.shell {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 28px;
}

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

/* ---------------------------------------------------------------- header */

.site-header {
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 20;
}

.site-header .shell {
  display: flex;
  align-items: center;
  gap: 28px;
  height: 62px;
}

.wordmark {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.01em;
  white-space: nowrap;
  color: var(--fg);
}
.wordmark:hover { color: var(--fg); }
.wordmark .p { color: var(--muted); }
.wordmark .n { color: var(--fg); }
.wordmark .a { color: var(--accent); }
.wordmark .s { color: var(--str); }

.site-nav {
  display: flex;
  gap: 20px;
  margin-left: auto;
  font-size: 13px;
}
.site-nav a { color: var(--muted); }
.site-nav a:hover { color: var(--fg); }
.site-nav a[aria-current] { color: var(--accent); }

.theme-toggle {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--muted);
  font-family: inherit;
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 4px;
  cursor: pointer;
  white-space: nowrap;
}
.theme-toggle:hover { color: var(--fg); border-color: var(--accent); }

/* ---------------------------------------------------------------- layout */

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 268px;
  gap: 56px;
  align-items: start;
}

.content {
  min-width: 0;
  padding-top: 40px;
}

/* ---------------------------------------------------------------- list */

.list-head {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 4px;
}
.list-kicker {
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  margin: 0;
  text-transform: lowercase;
  letter-spacing: 0.04em;
}
.list-rule { height: 1px; background: var(--line); flex: 1; }
.list-count { font-size: 12px; color: var(--muted); }
.list-sub { color: var(--muted); font-size: 13px; margin: 0 0 34px; }

.post-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.post-list > li {
  border-top: 1px solid var(--line);
  padding: 22px 0;
}
.post-link { display: block; }
.post-link:hover .post-list-title { color: var(--accent); }

.post-row {
  display: flex;
  align-items: baseline;
  gap: 14px;
  margin-bottom: 8px;
}
.post-date {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.post-list-title {
  font-size: 19px;
  font-weight: 500;
  margin: 0;
  color: var(--fg);
  letter-spacing: -0.01em;
}
.post-excerpt {
  margin: 0 0 12px;
  color: var(--muted);
  font-family: var(--sans);
  font-size: 14.5px;
  line-height: 1.65;
  max-width: 62ch;
  text-wrap: pretty;
}

.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  font-size: 11px;
  color: var(--muted);
  background: var(--chip);
  border-radius: 3px;
  padding: 3px 8px;
}
a.chip:hover { color: var(--bg); background: var(--accent); }

.empty-state {
  border: 1px dashed var(--line);
  border-radius: 6px;
  padding: 34px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}
.empty-state a, .empty-state b { color: var(--accent); font-weight: 400; }
.empty-state p { margin: 0 0 14px; max-width: 58ch; margin-inline: auto; }
.empty-state p:last-child { margin-bottom: 0; }
.chips--centred { justify-content: center; }

.pagination {
  border-top: 1px solid var(--line);
  margin-top: 8px;
  padding-top: 24px;
  display: flex;
  gap: 12px;
  align-items: center;
  font-size: 13px;
  color: var(--muted);
}
.pagination .prompt { color: var(--muted); }
/* search hides the pager; [hidden] alone loses to display: flex */
.pagination[hidden] { display: none; }

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

.post {
  max-width: 74ch;
}
.back-link {
  font-size: 12px;
  color: var(--muted);
  display: inline-block;
  margin-bottom: 26px;
}
.back-link:hover { color: var(--accent); }

.post-title {
  font-size: 34px;
  line-height: 1.18;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0 0 18px;
  text-wrap: balance;
  color: var(--fg);
}

.post-meta {
  display: flex;
  gap: 14px;
  align-items: center;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--muted);
  padding-bottom: 26px;
  border-bottom: 1px solid var(--line);
}
.post-meta time { font-variant-numeric: tabular-nums; }
.post-meta .chips { margin-left: auto; }

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

.prose {
  font-family: var(--sans);
  font-size: 16.5px;
  line-height: 1.72;
  color: var(--fg);
  padding-top: 30px;
}
.prose p { margin: 0 0 22px; text-wrap: pretty; }

.prose h2, .prose h3, .prose h4 {
  font-family: var(--mono);
  font-weight: 700;
  color: var(--fg);
  letter-spacing: 0.01em;
}
.prose h2 { font-size: 15px; margin: 38px 0 14px; }
.prose h3 { font-size: 14px; margin: 32px 0 12px; }
.prose h4 { font-size: 13px; margin: 28px 0 10px; }

/* the signature detail: a literal ## marker on every h2 */
.prose h2::before { content: "## "; color: var(--accent); }
.prose h3::before { content: "### "; color: var(--accent); }

.prose ul, .prose ol { margin: 0 0 22px; padding-left: 24px; }
.prose li { margin: 0 0 8px; }
.prose li::marker { color: var(--muted); }

.prose a { color: var(--accent); }
.prose a:hover { color: var(--accent2); }

.prose strong { font-weight: 600; }

.prose code {
  font-family: var(--mono);
  font-size: 14px;
  background: var(--chip);
  padding: 1px 5px;
  border-radius: 3px;
}

.prose blockquote {
  border-left: 2px solid var(--accent);
  padding: 2px 0 2px 18px;
  margin: 0 0 26px;
  color: var(--muted);
  font-size: 15.5px;
}
.prose blockquote p:last-child { margin-bottom: 0; }

.prose hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 34px 0;
}

.prose table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--mono);
  font-size: 13px;
  margin: 0 0 26px;
  display: block;
  overflow-x: auto;
}
.prose th, .prose td {
  border: 1px solid var(--line);
  padding: 7px 10px;
  text-align: left;
}
.prose th { color: var(--fg); font-weight: 500; background: var(--surface); }
.prose td { color: var(--muted); }

/* ---------------------------------------------------------------- figures */

.prose figure, figure.embed {
  margin: 0 0 26px;
}
.prose figure img {
  display: block;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
}
.prose figcaption {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--muted);
  margin-top: 8px;
}

/* a bare markdown image, no caption */
.prose p > img {
  display: block;
  border: 1px solid var(--line);
  border-radius: 6px;
}

figure.embed iframe {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--codebg);
}

/* ---------------------------------------------------------------- code */

.prose div.highlighter-rouge,
.prose figure.highlight,
.code-block {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--codebg);
  margin: 0 0 26px;
  overflow: hidden;
}

.code-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
}
.code-lang { color: var(--accent2); }
.code-file { color: var(--muted); }

.copy-btn {
  margin-left: auto;
  background: transparent;
  border: 1px solid var(--line);
  color: var(--muted);
  font-family: inherit;
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 3px;
  cursor: pointer;
}
.copy-btn:hover { color: var(--accent); border-color: var(--accent); }

.prose pre {
  margin: 0;
  padding: 14px 16px;
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 13.5px;
  line-height: 1.7;
  background: var(--codebg);
  color: var(--fg);
  /* never wrap: these are Python posts and indentation is meaning */
  white-space: pre;
  tab-size: 4;
}
.prose pre code {
  background: none;
  padding: 0;
  border-radius: 0;
  font-size: inherit;
}

/* ---------------------------------------------------------------- rouge

   Mapped onto the palette by hand rather than shipping one of Rouge's built-in
   themes, which do not match. Only the four roles the spec names are coloured
   -- keyword, string, comment, number. Everything else inherits --fg, which is
   what the prototype shows: in its sample, `from`/`import` are keywords and the
   command name and function names stay plain. */

.highlight .k,  .highlight .kc, .highlight .kd, .highlight .kn,
.highlight .kp, .highlight .kr, .highlight .kt, .highlight .ow,
.highlight .kv { color: var(--kw); }

.highlight .s,  .highlight .sa, .highlight .sb, .highlight .sc,
.highlight .dl, .highlight .sd, .highlight .s2, .highlight .se,
.highlight .sh, .highlight .si, .highlight .sx, .highlight .sr,
.highlight .s1, .highlight .ss { color: var(--str); }

.highlight .c,  .highlight .ch, .highlight .cd, .highlight .cm,
.highlight .cp, .highlight .cpf, .highlight .c1, .highlight .cs {
  color: var(--com);
  font-style: italic;
}

.highlight .m,  .highlight .mb, .highlight .mf, .highlight .mh,
.highlight .mi, .highlight .il, .highlight .mo { color: var(--num); }

/* markup: tag names and attributes read as structure, not prose */
.highlight .nt { color: var(--kw); }
.highlight .na { color: var(--accent2); }
.highlight .ni, .highlight .pi { color: var(--muted); }

.highlight .err { color: var(--fg); background: none; }
.highlight .gd { color: var(--str); }
.highlight .gi { color: var(--accent); }
.highlight .gh, .highlight .gu { color: var(--muted); }
.highlight .ge { font-style: italic; }
.highlight .gs { font-weight: 700; }

/* ---------------------------------------------------------------- prev/next */

.post-nav {
  border-top: 1px solid var(--line);
  margin-top: 40px;
  padding-top: 24px;
  display: flex;
  justify-content: space-between;
  gap: 20px;
  font-size: 12.5px;
}
.post-nav a { color: var(--muted); max-width: 46%; }
.post-nav a:hover { color: var(--accent); }
.post-nav .next { text-align: right; margin-left: auto; }

/* ---------------------------------------------------------------- sidebar */

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 30px;
  font-size: 12.5px;
  padding-top: 40px;
}
.sidebar h2 {
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 12px;
  font-weight: 500;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--surface);
  padding: 9px 11px;
}
.search-box .slash { color: var(--accent); }
.search-box input {
  background: transparent;
  border: 0;
  outline: 0;
  color: var(--fg);
  font-family: inherit;
  font-size: 12.5px;
  width: 100%;
}
.label-cloud { display: flex; flex-wrap: wrap; gap: 6px; }
.label-cloud a {
  font-size: 11.5px;
  color: var(--muted);
  background: var(--chip);
  border-radius: 3px;
  padding: 4px 8px;
}
.label-cloud a:hover { color: var(--bg); background: var(--accent); }
.label-cloud .count { opacity: 0.6; }

.page-links { display: flex; flex-direction: column; gap: 8px; }
.page-links a { color: var(--muted); }
.page-links a:hover { color: var(--accent); }

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

.site-footer {
  max-width: 1100px;
  margin: 60px auto 0;
  padding: 24px 28px 0;
  border-top: 1px solid var(--line);
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  font-size: 11.5px;
  color: var(--muted);
}
.site-footer .right { margin-left: auto; }
.site-footer a { color: var(--muted); }
.site-footer a:hover { color: var(--accent); }

/* ---------------------------------------------------------------- page */

.page-article { max-width: 66ch; }
.page-title {
  font-size: 30px;
  line-height: 1.2;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0 0 22px;
  text-wrap: balance;
}

.link-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
  margin: 28px 0 0;
}
.link-cards a {
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 12px 14px;
  font-size: 12.5px;
  color: var(--muted);
  font-family: var(--mono);
}
.link-cards a:hover { border-color: var(--accent); color: var(--accent); }

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

@media (max-width: 900px) {
  .layout {
    grid-template-columns: minmax(0, 1fr);
    gap: 40px;
  }
  .sidebar { padding-top: 0; }
  /* sidebar follows the content; search moves into the header */
  .sidebar .search-block { display: none; }
  .header-search { display: flex; }
  .site-nav { gap: 14px; }
  .post { max-width: none; }
  .page-article { max-width: none; }
}

@media (max-width: 620px) {
  .shell { padding: 0 18px; }
  .site-footer { padding: 24px 18px 0; }
  .site-header .shell { gap: 14px; }
  .site-nav .wide-only { display: none; }
  .post-title { font-size: 27px; }
  .prose { font-size: 16px; }
  /* never shrink code below 13px */
  .prose pre { font-size: 13px; }
  .post-row { flex-direction: column; gap: 4px; }
}

.header-search { display: none; }
