/* Typography: headings, paragraphs, lists, hgroup, blockquote, mark, abbr, ins, del, sub, sup */

small {
  --pico-font-size: 0.875em;
}

h1,
h2,
h3,
h4,
h5,
h6 {
  --pico-font-weight: 600;
}

h1 {
  --pico-font-size: 2.25rem;
  --pico-line-height: 1.15;
  letter-spacing: -0.025em;
  --pico-typography-spacing-top: 3rem;
  --pico-color: var(--pico-h1-color);
}

h2 {
  --pico-font-size: 1.75rem;
  --pico-line-height: 1.2;
  letter-spacing: -0.02em;
  --pico-typography-spacing-top: 2.625rem;
  --pico-color: var(--pico-h2-color);
}

h3 {
  --pico-font-size: 1.375rem;
  --pico-line-height: 1.3;
  letter-spacing: -0.015em;
  --pico-typography-spacing-top: 2.25rem;
  --pico-color: var(--pico-h3-color);
}

h4 {
  --pico-font-size: 1.125rem;
  --pico-line-height: 1.4;
  letter-spacing: -0.01em;
  --pico-typography-spacing-top: 1.874rem;
  --pico-color: var(--pico-h4-color);
}

h5 {
  --pico-font-size: 1rem;
  --pico-line-height: 1.5;
  --pico-typography-spacing-top: 1.6875rem;
  --pico-color: var(--pico-h5-color);
}

h6 {
  --pico-font-size: 0.875rem;
  --pico-line-height: 1.5;
  --pico-typography-spacing-top: 1.5rem;
  --pico-color: var(--pico-h6-color);
}

b,
strong {
  font-weight: bolder;
}

sub,
sup {
  position: relative;
  font-size: 0.75em;
  line-height: 0;
  vertical-align: baseline;
}

sub {
  bottom: -0.25em;
}

sup {
  top: -0.5em;
}

address,
blockquote,
dl,
ol,
p,
pre,
table,
ul {
  margin-top: 0;
  margin-bottom: var(--pico-typography-spacing-vertical);
  color: var(--pico-color);
  font-style: normal;
  font-weight: var(--pico-font-weight);
}

h1,
h2,
h3,
h4,
h5,
h6 {
  margin-top: 0;
  margin-bottom: var(--pico-typography-spacing-vertical);
  color: var(--pico-color);
  font-weight: var(--pico-font-weight);
  font-size: var(--pico-font-size);
  line-height: var(--pico-line-height);
  font-family: var(--pico-font-family);
  text-wrap: balance;
}

:where(p, li, figcaption, blockquote) {
  text-wrap: pretty;
}

:where(article, address, blockquote, dl, figure, form, ol, p, pre, table, ul)
  ~ :is(h1, h2, h3, h4, h5, h6) {
  margin-top: var(--pico-typography-spacing-top);
}

p {
  margin-bottom: var(--pico-typography-spacing-vertical);
}

hgroup {
  margin-bottom: var(--pico-typography-spacing-vertical);

  & > * {
    margin-top: 0;
    margin-bottom: 0;

    /* The subtitle: a last child that is not also the first */
    &:not(:first-child):last-child {
      --pico-color: var(--pico-muted-color);
      --pico-font-weight: unset;
      font-size: 1rem;
    }
  }
}

:where(ol, ul) li {
  margin-bottom: calc(var(--pico-typography-spacing-vertical) * 0.25);
}

:where(dl, ol, ul) :where(dl, ol, ul) {
  margin: 0;
  margin-top: calc(var(--pico-typography-spacing-vertical) * 0.25);
}

ul li {
  list-style: disc;
}

:where(ul, ol) li::marker {
  color: var(--pico-muted-color);
}

mark {
  padding: 0.125rem 0.25rem;
  background-color: var(--pico-mark-background-color);
  color: var(--pico-mark-color);
  vertical-align: baseline;
}

blockquote {
  display: block;
  margin: var(--pico-typography-spacing-vertical) 0;
  padding: var(--pico-spacing);
  border-inline-start: 0.25rem solid var(--pico-blockquote-border-color);
  border-inline-end: none;

  & footer {
    margin-top: calc(var(--pico-typography-spacing-vertical) * 0.5);
    color: var(--pico-blockquote-footer-color);
  }
}

abbr[title] {
  border-bottom: 1px dotted;
  text-decoration: none;
  cursor: help;
}

ins {
  color: var(--pico-ins-color);
  text-decoration: none;
}

del {
  color: var(--pico-del-color);
}

::selection {
  background-color: var(--pico-text-selection-color);
}
