/* Site-specific glue on top of md.css. Everything else comes from md.css. */

.sr-only:not(:focus) {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

[aria-current="page"] {
  color: var(--strong-color);
}

/* Theme toggle: show the current theme */

.theme-is-dark { display: none; }
:root[data-theme="dark"] .theme-is-light { display: none; }
:root[data-theme="dark"] .theme-is-dark { display: inline; }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-is-light { display: none; }
  :root:not([data-theme="light"]) .theme-is-dark { display: inline; }
}

/* Poems keep their line breaks in a <pre>, without code fences */

.poem pre::before,
.poem pre::after {
  content: none;
}

.poem pre {
  color: var(--text-color);
}

/* Inline annotations in posts */

.note-risk { color: var(--danger-color); }
.note-good { color: var(--accent-color); }

/* Syntax highlighting: a few Prism token colours from the md.css palette */

.token.comment,
.token.prolog,
.token.doctype,
.token.cdata,
.token.punctuation {
  color: var(--dim-color);
}

.token.string,
.token.attr-value,
.token.char,
.token.regex {
  color: var(--code-color);
}

.token.keyword,
.token.tag,
.token.selector,
.token.important {
  color: var(--strong-color);
}

.token.function,
.token.attr-name,
.token.property {
  color: var(--accent-color);
}

/* Header: the wordmark and nav on one line, identical on every page. The
   wordmark is an <h1> on the homepage and a link elsewhere; both render the
   same, without the setext underline or link brackets. */

body > header {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  column-gap: 3ch;
}

.wordmark {
  width: auto;
  margin: 0;
  padding: 0;
  font-weight: 600;
  color: var(--strong-color);
}

.wordmark::after,
.wordmark a::before,
.wordmark a::after {
  content: none;
}

.wordmark a {
  color: inherit;
}

.scheme {
  color: var(--dim-color);
  font-weight: normal;
}

/* The poem's <pre> is its wrapper's last child, so its margin collapses;
   keep the one-row gap before what follows. */
.poem {
  margin-block-end: var(--row);
}

/* Page layout: the footer hugs the bottom of the window on short pages, and
   on posts and poems previous/next travels with it. main grows to fill the
   leftover height; when it ends in previous/next, main becomes a column of
   <article> and <nav> with the nav pushed to the bottom. The gaps below are
   minimums. */

body {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  padding-block-end: var(--row);
}

body > main {
  flex-grow: 1;
}

body > footer {
  margin-block-start: calc(var(--row) * 2);
}

main:has(> nav:last-child) {
  display: flex;
  flex-direction: column;
}

main > nav:last-child {
  margin-block-start: auto;
  padding-block-start: calc(var(--row) * 2);
}

main:has(> nav:last-child) + footer {
  margin-block-start: var(--row);
}
