::selection {
  color: var(--color-content-selection);
  background: var(--color-background-selection);
}

* {
  box-sizing: border-box;

  @media (prefers-reduced-motion: reduce) {
    transition-duration: 0s !important;
  }
}

html {
  scroll-behavior: smooth;

  :has(dialog:modal[open]) {
    overflow: hidden;
  }
}

body {
  min-inline-size: 320px;
  margin: 0;
  font: var(--font-m);
  font-family: var(--font-family-base);
  color: var(--color-content-primary);
  background: var(--color-background-primary);

  @media print {
    color: var(--color-content-print);
    background: var(--color-background-print);
  }
}

button {
  appearance: auto;
}

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

a,
select:not(:disabled),
button:not(:disabled) {
  cursor: pointer;
}

ul,
ol {
  padding-inline-start: 16px;
}

li {
  margin-block: var(--space-m);
}

a {
  padding-inline: 2px;
  color: var(--color-content-link);
  text-decoration: underline;
  text-underline-offset: 0.25em;
  outline: none;
  border-radius: var(--border-radius);
  transition: box-shadow 200ms;

  @media (hover: hover) {
    &:hover {
      color: var(--color-content-link-hover);
      border-color: var(--color-border-link-hover);
      transition: all 200ms;
    }
  }

  &:focus-visible {
    text-decoration: none;
    background: var(--color-overlay-brand);
    box-shadow: 0 0 0 2px var(--color-border-brand);
  }
}

p {
  margin-block: var(--space-m);
  text-wrap: pretty;

  @media print {
    widows: 2;
  }
}

i {
  font-style: normal;
}

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

h1 {
  font: var(--font-2xl);
}

h2 {
  margin-block: var(--space-l) var(--space-m);
  font: var(--font-xl);
}

h3 {
  margin-block: var(--space-l) var(--space-m);
  font: var(--font-l);
  font-weight: 600;
}

h4 {
  margin-block: var(--space-m);
  font: var(--font-m);
  font-weight: 600;
}

table {
  margin-block: var(--space-m);
  overflow: clip;
  border-collapse: collapse;
  border-style: hidden;
  border-radius: var(--border-radius);
  box-shadow: 0 0 0 1px var(--color-border-primary);
}

th,
td {
  border: 1px solid var(--color-border-primary);
}

th {
  padding: var(--space-xs) var(--space-s);
  text-align: start;
  background: var(--color-background-secondary);
}

td {
  padding: var(--space-2xs) var(--space-s);
}

tr:nth-child(even) {
  background: var(--color-background-primary);
}

tr:nth-child(odd) {
  background: color-mix(
    in lab,
    var(--color-background-primary),
    var(--color-background-primary-hover)
  );
}

img {
  max-inline-size: 100%;
  block-size: auto;
  color: transparent;
}

picture {
  display: flex;
  flex-shrink: 0;
}

pre,
code {
  font: var(--font-code);
  font-variation-settings:
    'wght' 560,
    'wdth' 111;
  background: var(--color-background-secondary) !important;
  border: 1px solid var(--color-border-primary);

  @media print {
    white-space: pre-wrap;
    background: var(--color-background-print) !important;
    widows: 2;
  }
}

code {
  padding: var(--space-2xs);
  white-space: nowrap;
  border-radius: calc(var(--border-radius) / 2);
}

main {
  outline: none;
}

pre {
  padding: var(--space-m);
  overflow: auto;
  outline: none;
  border-radius: var(--border-radius);
  transition: box-shadow 200ms;

  code {
    padding: 0;
    white-space: pre;
    border: none;
  }

  &:focus-visible {
    box-shadow: 0 0 0 2px var(--color-border-brand);
  }
}
