/* One narrow column for every page, a contents list with leader dots and Roman
   numerals, paper texture, and a red-on-black dark mode. One stylesheet, no
   build step. */

/* Type. Display: Gothic Marriage, with Extreme Gothic as the alternate, both by
   Woodcutter (woodcutter.es). Text: Cormorant Garamond (OFL), variable, with
   the upright file covering 400–700 and the italic 400–500.

   To switch the display face, change the --display line in :root. */

@font-face {
  font-family: "Gothic Marriage";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/assets/fonts/GothicMarriage.woff2") format("woff2");
}

@font-face {
  font-family: "Extreme Gothic";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/assets/fonts/ExtremeGothic.woff2") format("woff2");
}

@font-face {
  font-family: "Cormorant Garamond";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("/assets/fonts/CormorantGaramond-normal.woff2") format("woff2");
}

@font-face {
  font-family: "Cormorant Garamond";
  font-style: italic;
  font-weight: 400 500;
  font-display: swap;
  src: url("/assets/fonts/CormorantGaramond-italic.woff2") format("woff2");
}

:root {
  --beige: #e4e2d7;
  --red: #ff3b3b;
  --black: #111;
  --bg: light-dark(var(--beige), var(--black));
  --fg: light-dark(var(--black), var(--red));
  --light: light-dark(rgba(0, 0, 0, 0.3), rgba(255, 59, 59, 0.3));
  --focus: light-dark(var(--red), #fff);
  --display-marriage: "Gothic Marriage", "Iowan Old Style", Georgia, serif;
  --display-extreme: "Extreme Gothic", "Iowan Old Style", Georgia, serif;
  --display: var(--display-marriage);
  --serif: "Cormorant Garamond", Cormorant, Garamond, "Iowan Old Style", Georgia, serif;
  --font-xs: 0.95rem;
  --font-sm: 1.1rem;
  --font-base: 1.32rem;
  --font-md: 1.65rem;
  --font-lg: 2.3rem;
  --font-xl: 3rem;
  --font-xxl: 6rem;
  --pad: 1.2rem;
  --toggle-sun: 1;
  --toggle-moon: 0;
}

@media (min-width: 500px) {
  :root {
    --pad: 2rem;
  }
}

html {
  height: 100%;
  color-scheme: light dark;
  -webkit-text-size-adjust: 100%;
}

html[data-user-color-scheme="light"] {
  color-scheme: light;
}

html[data-user-color-scheme="dark"] {
  color-scheme: dark;
  --toggle-sun: 0;
  --toggle-moon: 1;
}

@media (prefers-color-scheme: dark) {
  html:not([data-user-color-scheme]) {
    --toggle-sun: 0;
    --toggle-moon: 1;
  }
}

body {
  margin: 0;
  min-height: 100%;
  display: grid;
  background-color: var(--bg);
  background-image: url("/assets/paper.svg");
  background-repeat: repeat;
  background-size: 800px 800px;
  font-family: var(--serif);
  font-size: var(--font-base);
  font-weight: 500;
  line-height: 1.5;
  color: var(--fg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

@media (prefers-color-scheme: dark) {
  html:not([data-user-color-scheme]) body {
    background-image: url("/assets/paper-dark.svg");
  }
}

html[data-user-color-scheme="dark"] body {
  background-image: url("/assets/paper-dark.svg");
}

body.home {
  align-items: center;
}

.app {
  width: calc(100% - var(--pad) * 2);
  margin: var(--pad) auto;
}

@media (min-width: 500px) {
  .app {
    width: calc(500px - var(--pad) * 2);
  }
}

/* Type */

h1,
h2,
h3 {
  margin: 0;
  text-wrap: pretty;
}

h1 {
  font-family: var(--display);
  font-weight: 400;
  font-size: var(--font-xl);
  line-height: 1.1;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

h2 {
  font-size: var(--font-md);
  font-weight: 700;
  line-height: 1.2;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

h3 {
  font-size: var(--font-base);
  font-weight: 700;
  line-height: 1.2;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

p {
  margin: 0;
}

small,
.small {
  font-size: var(--font-sm);
}

strong {
  font-weight: 700;
}

a {
  color: var(--fg);
  font-weight: 600;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

a {
  transition: opacity 120ms ease-in-out;
}

a:hover {
  opacity: 0.6;
}

a:focus-visible,
button:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

/* Header */

.header-main {
  text-align: center;
}

.header-main.home h1 {
  font-size: var(--font-xxl);
  line-height: 1;
}

.header-main.home h2 {
  margin-top: 0.75em;
  font-size: var(--font-md);
  font-weight: 700;
  text-transform: none;
  letter-spacing: 0;
}

.header-main:not(.home) {
  margin-bottom: 4rem;
}

.chapter {
  margin: 2em 0;
  font-weight: 700;
}

@media (max-width: 499px) {
  .header-main.home h1 {
    font-size: min(calc(var(--font-xxl) - 0.6rem), 15.5vw);
  }

  h2 {
    font-size: calc(var(--font-md) - 0.2rem);
  }
}

/* Contents */

.main-nav {
  width: 100%;
  padding: 2rem 0;
}

.main-nav ol {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 1rem;
  counter-reset: chapter;
}

.main-nav li {
  counter-increment: chapter;
  display: flex;
}

.main-nav a {
  flex: 1;
  display: flex;
  gap: 0.4rem;
  font-size: var(--font-sm);
  font-weight: 400;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  text-decoration: none;
  transition: opacity 120ms ease-in-out;
}

.main-nav a:hover {
  opacity: 0.6;
}

.main-nav a::before {
  content: "";
  flex: 1;
  order: 2;
  background-image: radial-gradient(circle, var(--fg) 0.055em, transparent calc(0.055em + 0.5px));
  background-size: 2.2em 1em;
  background-repeat: space no-repeat;
  background-position: 0 50%;
}

.main-nav a::after {
  content: counter(chapter, upper-roman);
  order: 3;
}

.imprint {
  display: block;
  margin-top: 3rem;
  text-align: center;
  font-size: var(--font-sm);
  font-weight: 500;
  letter-spacing: 0.04em;
}

.imprint a {
  text-decoration: none;
  transition: opacity 120ms ease-in-out;
}

.imprint a:hover {
  opacity: 0.6;
}

/* Mode toggle */

.mode-toggle {
  margin-top: 0.5em;
  display: grid;
  place-content: center;
}

.no-js .mode-toggle {
  display: none;
}

.toggle-button {
  margin: 0;
  padding: 0;
  display: flex;
  align-items: center;
  background: transparent;
  border: 0;
  color: inherit;
  cursor: pointer;
}

.toggle-button:focus-visible {
  border-radius: 50%;
}

.toggle-icon {
  width: 1.6rem;
  height: 1.6rem;
  transition: opacity 120ms ease-in-out;
}

.toggle-button:hover .toggle-icon {
  opacity: 0.6;
}

.toggle-icon svg {
  width: 100%;
  height: auto;
  display: block;
}

.toggle-icon svg * {
  stroke: var(--fg);
}

.toggle-icon .sun {
  opacity: var(--toggle-sun);
}

.toggle-icon .moon {
  opacity: var(--toggle-moon);
}

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

/* Content */

.content > * + * {
  margin-top: 1.6em;
  margin-top: 1lh;
}

.content h2,
.content h3 {
  margin-top: 1.5lh;
}

.content h2 + *,
.content h3 + * {
  margin-top: 0.6em;
}

.content ul {
  padding-left: 1.3em;
  list-style-type: disc;
}

.content li + li {
  margin-top: 0.5em;
}

.content > p:first-of-type::first-letter {
  font-family: var(--display);
  font-size: var(--font-xl);
  font-weight: 400;
  line-height: 1;
  margin-right: 0.06em;
}

hr {
  height: 1px;
  margin: 2rem 0;
  border: 0;
  background-color: var(--light);
}

.avatar {
  width: 30%;
  margin: 0 1em 0 0;
  float: left;
  display: block;
  border: 1px solid;
  overflow: hidden;
}

.avatar img {
  width: 100%;
  height: auto;
  display: block;
  filter: grayscale(100%);
}

.avatar + * {
  margin-top: 0;
}

.meta {
  margin-top: 0.3em;
  font-size: var(--font-sm);
  font-weight: 400;
}

.links {
  margin: 0;
  padding: 0;
  list-style: none;
}

.links li {
  margin: 0;
  padding: 0.5em 0 0.3em;
  display: flex;
  justify-content: space-between;
  gap: 3em;
  align-items: baseline;
  font-size: var(--font-sm);
  font-weight: 400;
  line-height: 1.3;
}

.links li:not(:last-child) {
  border-bottom: 1px dotted var(--light);
}

.links li > :first-child {
  font-weight: 400;
}

.links .date {
  text-align: right;
  font-weight: 400;
  white-space: nowrap;
}

.links a {
  text-decoration: none;
}

.links a:hover {
  opacity: 0.6;
}

/* Footer */

.main-footer {
  margin-top: 4rem;
  font-size: var(--font-sm);
}

.footer-links {
  padding: 1em 0 0.8em;
  display: flex;
  gap: 0.5em 1.5em;
  justify-content: space-between;
  align-items: center;
  border-top: 2px solid;
  border-bottom: 2px solid;
  line-height: 1;
}

.footer-links nav {
  display: flex;
  gap: 0.75em;
}

.footer-links a {
  font-weight: 400;
  text-decoration: none;
}

.footer-links a:hover {
  opacity: 0.6;
}
