:root {
  --color-bg: #eef1f4;
  --color-surface: #ffffff;
  --color-surface-2: #e4e8ec;
  --color-text: #22272e;
  --color-text-muted: #5b6470;
  --color-accent: #a85a26;
  --color-accent-soft: #a85a2622;
  --color-border: #d5dbe1;
  --color-focus: #2f6fb0;

  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --font-serif: "Literata", Georgia, "Times New Roman", serif;

  color-scheme: light;

  /* Reskins the PagefindUI search widget (see
     openspec/changes/add-pagefind-search/) to this site's own tokens
     instead of Pagefind's defaults. Indirection through var(--color-*)
     means these automatically track the active theme — no separate
     dark-mode overrides needed here.
     !important is required: Pagefind's own bundled CSS (injected
     dynamically by its JS, load order not under our control) declares
     a bare `:root { --pagefind-ui-text: #393939; ... }` too — same
     0,1,0 specificity as this block, so without !important whichever
     stylesheet lands later in the cascade wins. Confirmed as a real
     bug, not theoretical: in light mode the hardcoded #393939 text
     happened to still read fine on a light background, masking it;
     in dark mode the background follows our dark token while the text
     stayed hardcoded dark, making search results unreadable. */
  --pagefind-ui-primary: var(--color-accent) !important;
  --pagefind-ui-text: var(--color-text) !important;
  --pagefind-ui-background: var(--color-surface) !important;
  --pagefind-ui-border: var(--color-border) !important;
  --pagefind-ui-tag: var(--color-surface-2) !important;
  --pagefind-ui-border-radius: 3px !important;
  --pagefind-ui-font: var(--font-serif) !important;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --color-bg: #12161b;
    --color-surface: #1a2027;
    --color-surface-2: #202832;
    --color-text: #dfe3e7;
    --color-text-muted: #8b95a1;
    --color-accent: #e0995a;
    --color-accent-soft: #e0995a26;
    --color-border: #2a323b;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --color-bg: #12161b;
  --color-surface: #1a2027;
  --color-surface-2: #202832;
  --color-text: #dfe3e7;
  --color-text-muted: #8b95a1;
  --color-accent: #e0995a;
  --color-accent-soft: #e0995a26;
  --color-border: #2a323b;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-serif);
  font-size: 17px;
  line-height: 1.6;
}

a {
  color: inherit;
  text-decoration: none;
}
a:focus-visible,
button:focus-visible {
  outline: 2px solid var(--color-focus);
  outline-offset: 2px;
}

.dead-link {
  color: var(--color-text-muted);
  text-decoration: underline dotted;
  text-decoration-color: var(--color-text-muted);
  cursor: help;
}

.eyebrow {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--color-text-muted);
}

/* ---------- Header ---------- */
header.site-header {
  border-bottom: 1px solid var(--color-border);
  background: var(--color-surface);
}

.header-inner {
  max-width: 78rem;
  margin: 0 auto;
  padding: 0.9rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 1.5rem;
  flex-wrap: wrap;
}

.site-title {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
  white-space: nowrap;
}
.site-title .prompt {
  color: var(--color-accent);
  margin-right: 0.35em;
}

nav.site-nav {
  display: flex;
  gap: 1.4rem;
  flex-wrap: wrap;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--color-text-muted);
  margin-left: auto;
}
nav.site-nav a {
  padding: 0.3rem 0;
  border-bottom: 1px solid transparent;
}
nav.site-nav a:hover {
  color: var(--color-text);
  border-color: var(--color-accent);
}
nav.site-nav .icon-link {
  display: inline-flex;
  align-items: center;
  gap: 0.35em;
}
nav.site-nav svg {
  width: 14px;
  height: 14px;
}

.nav-dropdown {
  position: relative;
}
.nav-dropdown summary {
  cursor: pointer;
  padding: 0.3rem 0;
  list-style: none;
}
.nav-dropdown summary::-webkit-details-marker {
  display: none;
}
.nav-dropdown summary::after {
  content: "▾";
  margin-left: 0.3em;
  font-size: 0.7em;
  opacity: 0.7;
}
.nav-dropdown[open] summary::after {
  content: "▴";
}
.nav-dropdown ul {
  position: absolute;
  top: 100%;
  left: 0;
  z-index: 20;
  list-style: none;
  margin: 0.4rem 0 0;
  padding: 0.5rem 0;
  min-width: 14rem;
  max-height: 20rem;
  overflow-y: auto;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 3px;
}
.nav-dropdown li {
  display: block;
}
.nav-dropdown li a {
  display: block;
  padding: 0.4rem 0.9rem;
  border-bottom: none;
  white-space: normal;
}
.nav-dropdown li a:hover {
  background: var(--color-surface-2);
  color: var(--color-accent);
}
.nav-dropdown-all {
  font-weight: 700;
  border-top: 1px solid var(--color-border);
  margin-top: 0.3rem;
  padding-top: 0.6rem !important;
}

.theme-toggle {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--color-text-muted);
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: 999px;
  padding: 0.35rem 0.8rem;
  cursor: pointer;
}
.theme-toggle:hover {
  color: var(--color-text);
}

/* ---------- Layout ---------- */
.layout {
  max-width: 78rem;
  margin: 0 auto;
  padding: 2.25rem 1.5rem 4rem;
  display: grid;
  grid-template-columns: 15.5rem 1fr;
  gap: 3rem;
  align-items: start;
}

@media (max-width: 860px) {
  .layout {
    grid-template-columns: 1fr;
  }
  aside.sidebar {
    order: 2;
  }
  main {
    order: 1;
  }
}

/* ---------- Sidebar ---------- */
aside.sidebar {
  display: flex;
  flex-direction: column;
  gap: 1.9rem;
  position: sticky;
  top: 1.5rem;
}
@media (max-width: 860px) {
  aside.sidebar {
    position: static;
  }
}

.panel h2 {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--color-text-muted);
  margin: 0 0 0.7rem;
  display: flex;
  align-items: center;
  gap: 0.5em;
}
.panel h2::before {
  content: "";
  width: 0.55em;
  height: 0.55em;
  background: var(--color-accent);
  border-radius: 1px;
  display: inline-block;
}

.recent-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}
.recent-list a {
  font-size: 0.9rem;
  line-height: 1.35;
  display: block;
}
.recent-list a:hover {
  color: var(--color-accent);
}
.recent-list time {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--color-text-muted);
  margin-top: 0.15rem;
}

.tag-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}
.tag-pill {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  padding: 0.22rem 0.55rem;
  border: 1px solid var(--color-border);
  border-radius: 999px;
  color: var(--color-text-muted);
}
.tag-pill:hover {
  border-color: var(--color-accent);
  color: var(--color-accent);
}

/* Used by the full tags/categories index pages (tags.njk,
   categories.njk) — same treatment as the sidebar's .tag-pill, in a
   plain-list rather than a cloud layout. */
.post-tag {
  font-family: var(--font-mono);
  font-size: 0.85rem;
}
.post-tag:hover {
  color: var(--color-accent);
}

.panel-more {
  margin: 0.6rem 0 0;
  font-family: var(--font-mono);
  font-size: 0.72rem;
}
.panel-more a {
  color: var(--color-text-muted);
}
.panel-more a:hover {
  color: var(--color-accent);
}

.category-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.category-list a {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  padding: 0.15rem 0;
}
.category-list a:hover {
  color: var(--color-accent);
}
.category-list .count {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--color-text-muted);
}

/* ---------- Main / post list ---------- */
main h1.page-title {
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: 2rem;
  text-wrap: balance;
  margin: 0 0 0.3rem;
}
main .page-sub {
  color: var(--color-text-muted);
  font-size: 0.95rem;
  margin: 0 0 2.2rem;
}

/* Rendered by shared/_includes/postslist.njk — used on the home page,
   blog archive, and tag/category archive pages. */
ol.postlist {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
}
.postlist-item {
  padding: 1rem 0;
  border-bottom: 1px solid var(--color-border);
}
.postlist-item:first-child {
  padding-top: 0;
}
.postlist-heading {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  flex-wrap: wrap;
}
.postlist-link {
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: 1.05rem;
}
.postlist-link:hover {
  color: var(--color-accent);
}
.postlist-excerpt {
  margin: 0.35rem 0 0;
  font-size: 0.88rem;
  color: var(--color-text-muted);
  max-width: 62ch;
}
.postlist-date {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--color-text-muted);
  white-space: nowrap;
}

.post-meta {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--color-text-muted);
  display: flex;
  align-items: center;
  gap: 0.6em;
  margin-bottom: 0.5rem;
  flex-wrap: wrap;
}
.post-meta .dot {
  opacity: 0.5;
}
.post-meta .tag-pill {
  font-size: 0.68rem;
  padding: 0.15rem 0.5rem;
}

article h1.post-title {
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: 2rem;
  margin: 0 0 0.5rem;
  text-wrap: balance;
}

article .body-content {
  max-width: 68ch;
}
article .body-content img {
  max-width: 100%;
  height: auto;
  border-radius: 3px;
}

.links-nextprev {
  list-style: none;
  margin: 2rem 0 0;
  padding: 1.2rem 0 0;
  border-top: 1px solid var(--color-border);
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  font-size: 0.9rem;
  flex-wrap: wrap;
}
.links-nextprev a:hover {
  color: var(--color-accent);
}

.comments {
  margin-top: 2.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--color-border);
}
.comments h2 {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--color-text-muted);
}
.comments ul {
  list-style: none;
  margin: 0;
  padding: 0;
}
.comments .comment-replies {
  padding-left: 1.5rem;
  border-left: 1px solid var(--color-border);
  margin-top: 0.8rem;
}
.comment {
  margin-bottom: 1.2rem;
}
.comment-meta {
  font-size: 0.85rem;
  margin: 0 0 0.2rem;
}
.comment-meta time {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--color-text-muted);
}
.comment-body {
  color: var(--color-text-muted);
}

/* ---------- Footer ---------- */
footer.site-footer {
  border-top: 1px solid var(--color-border);
  background: var(--color-surface);
  margin-top: 1rem;
}
.footer-inner {
  max-width: 78rem;
  margin: 0 auto;
  padding: 2rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.4rem;
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.8rem;
  font-family: var(--font-mono);
  font-size: 0.78rem;
}
.footer-links a {
  color: var(--color-text-muted);
}
.footer-links a:hover {
  color: var(--color-accent);
}
.footer-links .icon-link {
  display: inline-flex;
  align-items: center;
  gap: 0.35em;
}
.footer-links svg {
  width: 13px;
  height: 13px;
}

.footer-meta {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding-top: 1.2rem;
  border-top: 1px solid var(--color-border);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--color-text-muted);
}

@media (prefers-reduced-motion: no-preference) {
  .post-item,
  .recent-list a,
  .tag-pill {
    transition: color 0.12s ease, border-color 0.12s ease;
  }
}
