body {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  font-weight: 400;
  color: var(--color-text);
  background-color: var(--color-bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Skip link */
.skip-link {
  position: absolute;
  top: var(--space-s);
  left: var(--space-s);
  padding: var(--space-xs) var(--space-s);
  background: var(--color-accent);
  color: var(--color-on-accent);
  font-size: var(--text-sm);
  font-weight: 500;
  letter-spacing: var(--tracking-wide);
  text-decoration: none;
  text-transform: uppercase;
  transform: translateY(-200%);
  transition: transform 0.15s ease;
  z-index: 100;
}

.skip-link:focus {
  transform: translateY(0);
}

.skip-link:visited,
.skip-link:hover {
  color: var(--color-on-accent);
  background: var(--color-accent);
}

/* Focus styles — intentional, never suppressed */
:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 3px;
}

/* Links */
a {
  color: var(--color-accent);
  text-decoration-thickness: 0.1em;
  text-underline-offset: 0.2em;
  transition: var(--transition);
}

a:visited {
  color: var(--color-link-visited);
}

a:hover {
  color: var(--color-link-hover);
}

a[href^="http"]::after {
  content: "\00a0↗";
  font-size: 0.75em;
}

/* Headings */
h1 {
  font-size: var(--text-display);
  font-weight: 700;
  letter-spacing: var(--tracking-tight);
  margin-bottom: var(--space-l);
}

h2 {
  font-size: var(--text-xl);
  font-weight: 700;
  letter-spacing: var(--tracking-tight);
}

h3 {
  font-size: var(--text-lg);
  font-weight: 500;
}

h4, h5, h6 {
  font-size: var(--text-base);
  font-weight: 500;
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
}

/* Body copy */
p + p {
  margin-top: var(--space-m);
}


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

/* Uniform space under every page-level H1 */
main > * > h1 {
  margin-bottom: var(--space-2xl);
}

/* Prose content */
.page-content,
.note-body {
  /* max-width is set on <main> — these selectors exist for prose style scoping only */
}

.page-content h2,
.note-body h2 {
  margin-top: var(--space-xl);
  margin-bottom: var(--space-m);
  border-top: 0.25rem solid var(--color-text); /* em — scales with fluid H2 font size */
  padding-top: var(--space-12);
}

.page-content h3,
.note-body h3 {
  margin-top: var(--space-l);
  margin-bottom: var(--space-s);
}

.page-content h4,
.page-content h5,
.page-content h6,
.note-body h4,
.note-body h5,
.note-body h6 {
  margin-top: var(--space-l);
  margin-bottom: var(--space-s);
}

.page-content ul,
.page-content ol,
.note-body ul,
.note-body ol {
  padding-left: var(--space-l);
  margin: var(--space-m) 0;
}

/* All ul bullets in notes are custom CSS dots — consistent across all levels */
.note-body ul {
  list-style: none;
}

.note-body ul li {
  position: relative;
  line-height: var(--leading-normal); /* 1.5 — needed for precise bullet centering */
}

/* Static dot: 5px circle, centered on first line.
   top: 0.75em = half of 1.5 line-height; subtract half dot height to get top edge. */
.note-body ul li:not(.has-sublist):not(.task-list-item)::before {
  content: '';
  position: absolute;
  left: calc(-0.9em - 2.5px);
  top: calc(0.75em - 2.5px);
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
  pointer-events: none;
}

/* Interactive bullet: full-line hit area for easy tapping.
   Spans from the left edge of the ul padding to the right edge of the li.
   Uses em-based top so it always tracks the first line, never the li's total height. */
.list-bullet {
  appearance: none;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  position: absolute;
  left: calc(-1 * var(--space-l));
  right: 0;
  top: 0;
  height: 1.5em; /* one line, matches line-height: var(--leading-normal) */
  color: var(--color-text);
  transition: color 0.15s ease;
}

.list-bullet:hover {
  color: var(--color-accent);
}

.list-bullet:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 3px;
}

/* Dot — always present, same size and position as the static dot */
.list-bullet::before {
  content: '';
  position: absolute;
  left: calc(var(--space-l) - 0.9em - 2.5px);
  top: 50%;
  transform: translateY(-50%);
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
}

/* Outer ring — only when collapsed; dot size unchanged */
.list-bullet[aria-expanded="false"]::after {
  content: '';
  position: absolute;
  left: calc(var(--space-l) - 0.9em - 6.5px);
  top: 50%;
  transform: translateY(-50%);
  width: 13px;
  height: 13px;
  border-radius: 50%;
  border: 1.5px solid currentColor;
}

.note-body li.has-sublist.is-collapsed > ul,
.note-body li.has-sublist.is-collapsed > ol {
  display: none;
}

.page-content li + li,
.note-body li + li {
  margin-top: var(--space-xs);
}

/* Inline code */
code {
  font-family: ui-monospace, 'Cascadia Code', 'Source Code Pro', Menlo, Consolas, 'DejaVu Sans Mono', monospace;
  font-size: 0.875em;
  background: var(--color-border);
  padding: 0.1em 0.3em;
}

/* Block code */
pre {
  position: relative;
  background: var(--color-text);
  color: var(--color-bg);
  padding: var(--space-m);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  max-width: 100%;
  font-size: var(--text-sm);
  line-height: var(--rhythm-sm);
  tab-size: 2;
  margin: var(--space-l) 0;
  scrollbar-color: color-mix(in srgb, var(--color-bg) 60%, transparent) transparent;
}

pre code {
  background: none;
  padding: 0;
  font-size: inherit;
  line-height: inherit;
}

/* One Dark theme override: remove rounded corners (site uses no rounded corners) */
pre[class*="language-"] {
  border-radius: 0;
}

/* Code block — JS-enhanced wrapper */
.code-block {
  position: relative;
  margin: var(--space-l) 0;
}

.code-block pre {
  margin: 0;
  padding-top: var(--space-32);
}

.code-block-lang,
.code-block-copy {
  position: absolute;
  top: var(--space-12);
  font-family: var(--font-sans);
  font-size: var(--text-code-label);
  font-weight: 600;
  letter-spacing: var(--tracking-wider);
  text-transform: uppercase;
  line-height: 1;
  /* Fixed to One Dark palette — code block bg is always dark regardless of page theme */
  color: hsl(220, 10%, 40%);
}

.code-block-lang {
  left: var(--space-m);
  pointer-events: none;
  user-select: none;
}

.code-block-copy {
  right: var(--space-m);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  transition: color 0.15s ease;
}

.code-block-copy:hover {
  color: hsl(220, 14%, 71%); /* One Dark base text on hover */
}

.code-block-copy:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 3px;
}

/* Button — reusable component. Use .btn on any <button> or <a> that needs
   button appearance. Never define button styles ad-hoc in page templates. */
.btn {
  appearance: none;
  background: none;
  border: 1px solid var(--color-text);
  color: var(--color-text);
  font-family: inherit;
  font-size: var(--text-sm);
  font-weight: 500;
  letter-spacing: var(--tracking-wide);
  padding: var(--space-s) var(--space-m);
  cursor: pointer;
  transition: var(--transition), background-color 0.15s ease;
}

.btn:hover {
  background: var(--color-text);
  color: var(--color-bg);
}

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

/* 404 monologue */
.page-404 {
  padding-top: var(--space-xl);
}

.monologue {
  font-size: var(--text-lg);
  line-height: var(--rhythm-lg);
  margin-bottom: var(--space-l);
  min-height: 2lh;
}

/* Blockquote */
blockquote {
  border-left: 3px solid var(--color-accent);
  padding: var(--space-m) 0 var(--space-m) var(--space-m);
  color: var(--color-muted);
  font-size: var(--text-lg);
  margin: var(--space-xl) 0;
}

/* Tables */
.table-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: var(--space-l) 0;
  scrollbar-color: color-mix(in srgb, var(--color-text) 60%, transparent) transparent;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}

th, td {
  text-align: left;
  padding: var(--space-s) var(--space-m);
  border-bottom: 1px solid var(--color-border);
}

th {
  font-weight: 500;
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  border-bottom: 2px solid var(--color-text);
}

/* Task lists */
.page-content .contains-task-list,
.note-body .contains-task-list {
  list-style: none;
  padding-left: var(--space-s);
}

.task-list-item {
  display: flex;
  align-items: center;
  gap: var(--space-s);
}

.task-list-item input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 0.75em;
  height: 0.75em;
  border: 1.5px solid var(--color-text);
  flex-shrink: 0;
  margin: 0;
  cursor: default;
  pointer-events: none;
}

.task-list-item input[type="checkbox"]:checked {
  background-color: var(--color-text);
}

/* Footnotes */
.footnotes-sep {
  margin-top: var(--space-2xl);
}

.footnotes {
  margin-top: var(--space-l);
  font-size: var(--text-sm);
}

.footnotes-list {
  padding-left: var(--space-l);
}

.footnote-item + .footnote-item {
  margin-top: var(--space-s);
}

.footnote-ref a,
.footnote-backref {
  text-decoration: none;
  font-variant-numeric: tabular-nums;
}

/* Figures and standalone images in content */
figure {
  margin: var(--space-xl) 0;
}

.page-content img,
.note-body img {
  margin: var(--space-xl) 0;
}

.page-content figure img,
.note-body figure img {
  margin: 0; /* figure already provides the vertical margin */
}

figcaption {
  margin-top: var(--space-xs);
  font-size: var(--text-sm);
  color: var(--color-muted);
}

/* Horizontal rule — default (outside content areas) */
hr {
  border: none;
  border-top: var(--rule-weight) solid var(--color-text);
  margin: var(--space-xl) 0;
}

/* Content <hr>s: dashed 1px to distinguish from 2px solid layout rulers.
   background-image used instead of border-style:dashed to control dash length. */
.page-content hr,
.note-body hr {
  border: none;
  height: 1px;
  background-image: repeating-linear-gradient(
    to right,
    var(--color-text) 0,
    var(--color-text) 12px,
    transparent 12px,
    transparent 18px
  );
}

/* Note meta */
.note-meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-l);
  font-size: var(--text-sm);
  color: var(--color-muted);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  margin-top: 0;
  margin-bottom: var(--space-s);
}


/* Webmentions */
.webmentions {
  margin-top: var(--space-2xl);
  padding-top: var(--space-l);
  border-top: var(--rule-weight) solid var(--color-text);
}

.webmentions h2 {
  font-size: var(--text-sm);
  font-weight: 500;
  letter-spacing: var(--tracking-wider);
  text-transform: uppercase;
  color: var(--color-muted);
  margin-bottom: var(--space-m);
}

.webmentions-counts {
  font-size: var(--text-sm);
  color: var(--color-muted);
  margin-bottom: var(--space-l);
}

.webmentions-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-l);
}

.webmention-meta {
  display: flex;
  align-items: baseline;
  gap: var(--space-m);
  margin-bottom: var(--space-xs);
}

.webmention-author {
  font-weight: 500;
  font-size: var(--text-sm);
}

.webmention-time {
  font-size: var(--text-sm);
  color: var(--color-muted);
}

.webmention-content {
  font-size: var(--text-sm);
  color: var(--color-muted);
}

/* Backlinks */
.backlinks {
  margin-top: var(--space-2xl);
}

.backlinks h2 {
  font-size: var(--text-sm);
  font-weight: 500;
  letter-spacing: var(--tracking-wider);
  text-transform: uppercase;
  color: var(--color-muted);
  margin-bottom: var(--space-m);
}

.backlinks ul {
  display: inline;
}

.backlinks li {
  display: inline;
  font-size: var(--text-sm);
}

.backlinks li + li::before {
  content: ", ";
}

/* Back link — compensates for .note-nav__link padding so the text aligns
   optically with the content below. Hover border intentionally overhangs left. */
.note-back {
  margin-left: calc(-1 * var(--space-s));
}

/* Note prev/next navigation */
.note-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-l);
  margin-top: var(--space-2xl);
  padding-top: var(--space-l);
  border-top: var(--border-weight) solid var(--color-text);
}

.note-nav__link {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  text-decoration: none;
  color: var(--color-text);
  padding: var(--space-s);
  border: 1px solid transparent;
  transition: var(--transition);
}

.note-nav__link:visited {
  color: var(--color-text);
}

.note-nav__link:hover {
  border-color: var(--color-text);
  color: var(--color-text);
}

.note-nav__next {
  text-align: right;
}

.note-nav__dir {
  font-size: var(--text-sm);
  font-weight: 500;
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  color: var(--color-muted);
}

.note-nav__title {
  font-size: var(--text-base);
}
