/* Color Variables */
:root {
  --bg: #ffffff;
  --text: #222222;
  --link: #00008b;
  --link-hover: darkred;
  --border-light: #eee;
  --border-accent: #8ebeeb;
  --text-muted: #999;
  --tag-color: #777;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1a1a1a;
    --text: #e0e0e0;
    --link: #6b9bd1;
    --link-hover: #ff6b6b;
    --border-light: #333;
    --border-accent: #5a8bc4;
    --text-muted: #888;
    --tag-color: #999;
  }
}

/* Reset & Base */
*, *::before, *::after {
  box-sizing: border-box;
}

html {
  color-scheme: light dark;
  text-size-adjust: none;
}

body, h1, h2, h3, h4, p, figure, blockquote, dl, dd {
  margin-block-end: 0;
}

body {
  min-height: 100vh;
  line-height: 1.5;
  font-family: system-ui, sans-serif;
  font-size: 1.25rem;
  text-rendering: geometricPrecision;
  scroll-behavior: smooth;
  word-break: break-word;
  background-color: var(--bg);
  color: var(--text);
}

/* Headings */
h1, h2, h3, h4, button, input, label {
  line-height: 1.1;
  text-wrap: balance;
}

h1 { font-size: 1.5em; }
h2 { font-size: 1.2em; }
h3 { font-size: 1em; }
h4 { font-size: 0.8em; }
h5 { font-size: 0.67em; }
h6 { font-size: 0.50em; }

h1, h2, h3, h4 {
  position: relative;
  padding-left: 0;
}

h1::before, h2::before, h3:not(#TableOfContents)::before, h4::before {
  content: "#";
  position: absolute;
  left: -1em;
  top: 0;
  color: var(--text-muted);
  font-weight: normal;
}

/* Layout */
main, header, nav, footer {
  max-width: min(70ch, 100% - 4ch);
  margin-inline: auto;
}

main {
  hanging-punctuation: first last;
  font-feature-settings: "hang" 1, "onum" 1, "liga" 1;
  text-wrap: pretty;
}

article header {
  margin: 0;
}

main p, main ul li, main ol li, main blockquote {
  hyphens: auto;
}

main blockquote {
  hyphens: auto;
  margin-left: 0;
  position: relative;
  font-style: italic;
}

blockquote::before {
  content: "";
  position: absolute;
  left: -1em;
  top: 0;
  bottom: 0;
  width: 0.25em;
  background-color: var(--border-light);
}

/* Lists */
ul[role='list'], ol[role='list'] {
  list-style: none;
}

ul {
  list-style: square;
}

ul, ol {
  list-style-position: outside;
  padding-left: 0;
  margin-left: 0;
}

ul li, ol li {
  margin-bottom: 0.5rem;
}

li ul {
  padding-left: 1.25rem;
}

.menu {
  display: flex;
  list-style: none;
  margin-top: 1rem;
  padding-left: 0;
  gap: 1rem;
}

nav {
  margin: 0;
}

ul.menu li:not(:last-child)::after {
  content: " ※";
  margin-left: 0.5em;
  color: var(--text-muted);
}

/* Media */
img, picture, video, figure {
  max-width: 100%;
  display: block;
}

figcaption {
  text-align: center;
  font-size: 0.8em;
}

/* Links */
a, a:visited {
  color: var(--link);
  text-decoration: none;
}

a:hover, a.tag:hover {
  text-decoration: none;
  color: var(--link-hover);
}

/* Code */
code, pre {
  font-family: ui-monospace, monospace;
  font-size: 0.8em;
  hyphens: none;
  overflow: auto;
  hanging-punctuation: none;
}

div.highlight code {
  text-size-adjust: 100%;
  font-size: 1em;
}

p code::before,
h1 code::before,
h2 code::before,
h3 code::before,
h4 code::before,
h5 code::before,
h6 code::before,
li code::before,
p code::after,
h1 code::after,
h2 code::after,
h3 code::after,
h4 code::after,
h5 code::after,
h6 code::after,
li code::after {
  content: "`";
}

/* Tags */
a.tag::before {
  content: "#";
}

a.tag {
  color: var(--tag-color);
  font-variant: all-small-caps;
  font-size: 1rem;
}

article > header > p {
  font-size: 1rem;
}

/* Tables */
table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
  font-size: 0.9em;
}

thead {
  border-bottom: 2px solid currentColor;
}

th {
  font-weight: 600;
  text-align: left;
  padding: 0.75rem 1rem;
}

td {
  padding: 0.75rem 1rem;
}

tbody tr {
  border-bottom: 1px solid color-mix(in srgb, currentColor 20%, transparent);
}

tbody tr:last-child {
  border-bottom: none;
}

tbody tr:hover {
  background-color: color-mix(in srgb, currentColor 5%, transparent);
}

/* Definition Lists */
dl {
  margin: 1.5rem 0;
}

dt {
  font-weight: 600;
  margin-top: 1rem;
}

dt:first-child {
  margin-top: 0;
}

dd {
  margin-left: 2rem;
  margin-bottom: 0.5rem;
}

dd:last-of-type {
  margin-bottom: 0;
}

/* Series Info */
div.series-info {
  margin: 0;
  font-size: 0.9em;
  position: relative;
}

div.series-info span {
  display: block;
}

div.series-info span::before {
  content: "";
  position: absolute;
  left: -1em;
  top: 0;
  bottom: 0;
  width: 0.25em;
  background-color: var(--border-accent);
}

#tag-cloud {
  margin: 0;
  line-height: 1.2;
}

#tag-cloud a {
  display: inline-block;
  margin: 0.25rem 0.5rem;
  white-space: nowrap;
}
