*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -moz-text-size-adjust: none;
  -webkit-text-size-adjust: none;
  text-size-adjust: none;
}

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

ul[role="list"],
ol[role="list"] {
  list-style: none;
}

body {
  line-height: 1.5;
}

h1,
h2,
h3 {
  text-wrap: balance;
}

a:not([class]) {
  text-decoration-skip-ink: auto;
  color: currentColor;
}

img,
picture {
  max-width: 100%;
  display: block;
}

input,
button,
textarea,
select {
  font: inherit;
}

textarea:not([rows]) {
  min-height: 10em;
}

:target {
  scroll-margin-block: 3ex;
}

:root {
  /* Solararized colors */
  --base03: #002b36;
  --base02: #073642;
  --base01: #586e75;
  --base00: #657b83;
  --base0: #839496;
  --base1: #93a1a1;
  --base2: #eee8d5;
  --base3: #fdf6e3;

  --yellow: #b58900;
  --orange: #cb4b16;
  --red: #dc322f;
  --magenta: #d33682;
  --violet: #6c71c4;
  --blue: #268bd2;
  --cyan: #2aa198;
  --green: #859900;

  --fg: var(--base00);
  --bg: var(--base3);
  --hl: var(--base2);
  --emph: var(--base01);
  --comment: var(--base1);
}

@media (prefers-color-scheme: dark) {
  :root {
    --fg: var(--base0);
    --bg: var(--base03);
    --hl: var(--base02);
    --emph: var(--base1);
    --comment: var(--base01);
  }
}

:root {
  --font-size: 100%;
}

@media (min-width: 40rem) {
  :root {
    --font-size: 140%;
  }
}

html {
  color-scheme: light dark;
  background-color: var(--bg);
  color: var(--fg);
  font-size: var(--font-size);

  font-family: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas,
    "Liberation Mono", monospace;
  font-weight: 400;

  line-height: 1.5;
  padding: 1ch;
}

body {
  font-size: 1rem;
  max-width: 64ch;
  margin: 0 auto;
  padding: 0 2ch 0 4ch;
}

a {
  color: inherit;
}

h1,
h2,
h3 {
  color: light-dark(var(--cyan), var(--yellow));
  font-size: 1rem;
  font-weight: inherit;
}

dl.metadata {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0 1ch;

  dt {
    grid-column: 1;
  }

  dd {
    grid-column: 2;
    margin-left: 0;
  }

  &.subtle {
    margin-top: 0;
    color: var(--comment);
    font-weight: lighter;
  }
}

blockquote {
  margin-left: 0;
  color: var(--comment);

  &::before {
    content: ">\ ";
    position: absolute;
    margin-left: -2ch;
  }
}

ul {
  margin-left: 0;
  padding-left: 0;
}

ul li {
  padding-left: 0;
  list-style-type: none;
}

ul li:before {
  content: "-\ ";
  position: absolute;
  margin-left: -2ch;
}

h1::before {
  content: "#\ ";
  position: absolute;
  margin-left: -2ch;
}

h2::before {
  content: "##\ ";
  position: absolute;
  margin-left: -3ch;
}

h3::before {
  content: "###\ ";
  position: absolute;
  margin-left: -4ch;
}

/* SPACING */

article {
  margin-top: 4rem;
}

/* WORD WRAPPING */

/* Prevent horizontal page scroll */
body {
  overflow-x: hidden;
}

/* Code blocks - scroll horizontally */
pre,
code {
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
}

pre {
  padding: 1rem;
  border-radius: 4px;
}

/* Inline code - wrap */
p code,
li code {
  overflow-wrap: break-word;
  word-break: break-word;
}

/* Long links and text - wrap */
a,
p,
li {
  overflow-wrap: break-word;
  word-break: break-word;
  /* or for more aggressive breaking: word-break: break-all; */
}

/* Images and other media */
img,
video,
iframe {
  max-width: 100%;
  height: auto;
}

/* Tables */
table {
  max-width: 100%;
  overflow-x: auto;
  display: block;
}
