:root {
  --bg: #fdfdfc;
  --fg: #1a1a1a;
  --muted: #8a8a85;
  --rule: #e6e6e1;
  --sun: none;
  --moon: block;
  --diagram-invert: 0;
  --diagram-blend: multiply;
}

/* The system preference is the default; an explicit choice overrides it. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111110;
    --fg: #ededea;
    --muted: #7a7a75;
    --rule: #2a2a28;
    --sun: block;
    --moon: none;
    --diagram-invert: 1;
    --diagram-blend: screen;
  }
}

:root[data-theme="dark"] {
  --bg: #111110;
  --fg: #ededea;
  --muted: #7a7a75;
  --rule: #2a2a28;
  --sun: block;
  --moon: none;
  --diagram-invert: 1;
  --diagram-blend: screen;
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  padding: 0 24px;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.25s ease, color 0.25s ease;
}

.title,
.bio dt,
.notes h2,
.fingerprint,
.links,
.back,
.crumb,
.meta,
.sep {
  transition: color 0.25s ease, border-color 0.25s ease;
}

main {
  width: 100%;
  max-width: 360px;
  padding: 64px 0;
  text-align: center;
}

/* A quiet reading column, centered on the page with a shared left edge. */
main.home {
  max-width: 520px;
  min-width: 0;
  padding: 72px 0 48px;
  text-align: left;
}

.home .portrait {
  margin: 0;
}

.home h1 {
  margin-top: 28px;
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.035em;
}

.home .title {
  max-width: 440px;
  font-size: 15px;
}

.home .bio {
  margin-top: 30px;
}

.home .bio dt {
  font-size: 12px;
}

.home .bio dd {
  font-size: 16px;
  line-height: 1.65;
}

@media (min-width: 560px) {
  .home .bio {
    display: grid;
    grid-template-columns: 92px minmax(0, 1fr);
    gap: 16px 20px;
  }

  .home .bio dt {
    padding-top: 5px;
  }

  .home .bio dd,
  .home .bio dd + dt {
    margin: 0;
  }
}

.portrait {
  position: relative;
  width: 120px;
  height: 120px;
  margin: 0 auto;
}

.avatar {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  display: block;
  transition: opacity 0.4s ease;
}

/* Once the points take over, the source steps aside. */
.is-gl .avatar,
.is-gl .four {
  opacity: 0;
}

/* The engine sizes and offsets each canvas itself. */
.particles {
  position: absolute;
  top: 50%;
  left: 50%;
  pointer-events: none;
}

h1 {
  margin: 24px 0 0;
  font-size: 17px;
  font-weight: 500;
  letter-spacing: 0.01em;
}

.title {
  margin: 7px 0 0;
  font-size: 14px;
  color: var(--muted);
}

.bio {
  margin: 22px 0 0;
}

.bio dt {
  font-size: 11px;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted);
}

.bio dd {
  margin: 3px 0 0;
  font-size: 14px;
  line-height: 1.5;
}

.bio dd + dt {
  margin-top: 14px;
}

/* --- beliefs & writing --- */

.notes {
  margin: 36px 0 0;
  padding: 28px 0 0;
  border-top: 1px solid var(--rule);
  text-align: left;
}

.notes h2 {
  margin: 0 0 22px;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--fg);
}

.notes blockquote {
  margin: 0;
  padding-left: 16px;
  border-left: 2px solid var(--rule);
  font-size: 16px;
  line-height: 1.7;
}

.notes blockquote + blockquote {
  margin-top: 26px;
}

.notes cite {
  display: block;
  margin-top: 8px;
  font-size: 13px;
  line-height: 1.5;
  font-style: normal;
  color: var(--muted);
}

.notes cite::before {
  content: "\2014\00a0";
}

.writing {
  list-style: none;
  margin: -8px 0 0;
  padding: 0;
  font-size: 16px;
  line-height: 1.5;
}

.writing li + li {
  border-top: 1px solid var(--rule);
}

.writing a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 0;
  border-bottom: 0;
}

.writing a:hover {
  text-decoration: underline;
  text-underline-offset: 4px;
}

.writing a:focus-visible {
  outline: 2px solid var(--fg);
  outline-offset: 4px;
}

.links {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px 24px;
  list-style: none;
  margin: -8px 0 0;
  padding: 0;
}

.links a {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 8px 0;
  border: 0;
}

.link-icon {
  width: 20px;
  height: 20px;
  flex: 0 0 20px;
  color: var(--muted);
}

.link-arrow {
  margin-left: auto;
  padding-left: 4px;
  color: var(--muted);
  font-size: 16px;
}

.links a:hover span:not(.link-arrow) {
  text-decoration: underline;
  text-underline-offset: 4px;
}

.links a:hover .link-icon,
.writing a:hover .link-icon {
  color: var(--fg);
}

.links a:focus-visible {
  outline: 2px solid var(--fg);
  outline-offset: 4px;
}

@media (max-width: 359px) {
  .links {
    grid-template-columns: 1fr;
  }
}

a {
  color: var(--fg);
  text-decoration: none;
  border-bottom: 1px solid var(--rule);
  padding-bottom: 1px;
  transition: border-color 0.2s ease, color 0.2s ease;
}

a:hover {
  border-bottom-color: var(--fg);
}

.sep {
  color: var(--muted);
  margin: 0 6px;
}

.fingerprint {
  margin: 28px 0 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 1.7;
  color: var(--muted);
  word-spacing: 0.15em;
  overflow-wrap: anywhere;
}

/* --- 404 --- */

main.wide {
  max-width: 460px;
}

.glyph {
  position: relative;
  width: 100%;
  height: 150px;
}

.four {
  margin: 0;
  font-size: 104px;
  line-height: 150px;
  font-weight: 600;
  letter-spacing: -0.03em;
  transition: opacity 0.4s ease;
}

.back {
  margin: 30px 0 0;
  padding: 28px 0 0;
  border-top: 1px solid var(--rule);
}

/* --- posts --- */

main.post {
  max-width: 560px;
  min-width: 0; /* the diagram's intrinsic width must not widen the flex item */
  text-align: left;
}

.crumb {
  margin: 0;
  font-size: 11px;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted);
}

.crumb a {
  color: inherit;
  border-bottom: 0;
}

.crumb a:hover {
  color: var(--fg);
}

.post h1 {
  margin: 14px 0 0;
  font-size: 26px;
  line-height: 1.25;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.meta {
  margin: 8px 0 0;
  font-size: 13px;
  color: var(--muted);
}

.body {
  margin: 30px 0 0;
  padding: 28px 0 0;
  border-top: 1px solid var(--rule);
  font-size: 16px;
  line-height: 1.65;
}

.body p {
  margin: 0 0 1.25em;
}

.body h2,
.body h3 {
  margin: 2em 0 0.6em;
  font-weight: 600;
  line-height: 1.3;
}

.body h2 {
  font-size: 19px;
}

.body h3 {
  font-size: 16px;
}

.body ul {
  margin: 0 0 1.25em;
  padding-left: 1.25em;
}

.body li + li {
  margin-top: 0.9em;
}

.body figure {
  margin: 1.6em 0;
}

.body figure img {
  display: block;
  width: 100%;
  height: auto;
}

.body .post-hero {
  margin-top: 0;
}

.body .post-hero figcaption {
  text-align: center;
  font-size: 11px;
  font-style: italic;
}

.post-hero a {
  display: block;
  border-bottom: 0;
}

/* Diagrams are drawn on white; blend them into whichever ground is showing.
   The hue rotation undoes the color flip that inverting causes, so a blue
   line stays blue in the dark theme. */
.diagram {
  filter: invert(var(--diagram-invert)) hue-rotate(calc(var(--diagram-invert) * 180deg));
  mix-blend-mode: var(--diagram-blend);
}

.body figcaption {
  margin-top: 8px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--muted);
}

.video {
  position: relative;
  margin: 1.6em 0 0;
  padding-top: 56.25%;
  background: var(--rule);
}

.video iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

.video-link {
  margin-top: 8px;
  font-size: 13px;
  color: var(--muted);
}

/* --- theme toggle --- */

.theme-toggle {
  position: fixed;
  top: 16px;
  right: 16px;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--muted);
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  transition: color 0.2s ease;
}

.theme-toggle[hidden] {
  display: none;
}

.theme-toggle:hover {
  color: var(--fg);
}

.theme-toggle:focus-visible {
  outline: 1px solid var(--rule);
  outline-offset: 2px;
}

.theme-toggle svg {
  width: 16px;
  height: 16px;
}

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

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