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

* {
  margin: 0;
}

html {
  color-scheme: dark;
  scroll-behavior: smooth;
  /* Reserved gutter: locking scroll when a dialog opens must not shift the layout */
  scrollbar-gutter: stable;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}

body {
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: var(--text-body);
  line-height: 1.55;
  letter-spacing: -0.011em;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

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

a {
  color: inherit;
  text-decoration: none;
}

ul {
  list-style: none;
  padding: 0;
}

h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 600;
  text-wrap: balance;
}

p {
  text-wrap: pretty;
}

/* Keeps punctuation glued to an inline entity button, which is otherwise a line-break opportunity */
.nowrap {
  white-space: nowrap;
}

.mono {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.container {
  width: min(var(--max-width), 100% - var(--side-padding) * 2);
  margin-inline: auto;
}

.section-full {
  padding-block: var(--space-2xl);
}

.overline {
  font-family: var(--font-mono);
  font-size: var(--text-overline);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
}

.h2 {
  font-size: var(--text-h2);
  line-height: 1.1;
  letter-spacing: -0.02em;
  margin-top: var(--space-sm);
}

.body-lg {
  font-size: var(--text-body-lg);
  color: var(--text-secondary);
  line-height: 1.6;
  max-width: 65ch;
}

.body-lg strong {
  color: var(--text-primary);
  font-weight: 600;
}

.link-underline {
  position: relative;
  font-size: var(--text-body-sm);
  color: var(--text-secondary);
  padding-bottom: 2px;
}

.link-underline::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: 0;
  width: 100%;
  height: 1px;
  background: var(--text-tertiary);
  transform: scaleX(0.3);
  transform-origin: left;
  transition: transform var(--dur-md) var(--ease-out), background var(--dur-sm) ease;
}

.link-underline:hover {
  color: var(--text-primary);
}

.link-underline:hover::after {
  transform: scaleX(1);
  background: var(--accent);
}

::selection {
  background: var(--accent-muted);
  color: var(--text-primary);
}

/* Custom cursor: fine pointers only, and only when motion is welcome */
.cursor-dot {
  display: none;
}

@media (pointer: fine) {
  @media (prefers-reduced-motion: no-preference) {
    .cursor-dot {
      display: block;
      position: fixed;
      top: 0;
      left: 0;
      width: 8px;
      height: 8px;
      border-radius: 50%;
      background: var(--accent);
      pointer-events: none;
      z-index: 200;
      transform: translate(-50%, -50%);
      transition: transform var(--dur-sm) var(--ease-out), opacity var(--dur-sm) ease;
      mix-blend-mode: screen;
      will-change: transform;
    }
  }
}
