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

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

body {
  margin: 0;
  padding: 0;
  color: $color-text;
  background-color: $color-neutral-canvas;
  font-family: $font-base;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-wrap: anywhere;
}

div {
  position: relative;
}

b,
strong,
.bold {
  font-weight: bold;
}

@include all-headings {
  margin: 0.5em 0;
  font-weight: normal;
}

h1,
.h1 {
  color: var(--color-headline);
  font-family: var(--font-head);
  font-size: $font-size-xxl;
  line-height: 1.2;
}

h2,
.h2,
%h2 {
  color: var(--color-headline);
  font-family: var(--font-head);
  font-size: $font-size-xl;
  line-height: 1.2;
}

h3,
.h3,
%h3 {
  color: var(--color-headline);
  font-family: var(--font-head);
  font-size: $font-size-l;
  line-height: 1.2;
}

h4,
.h4 {
  letter-spacing: 0.05rem;
  text-transform: uppercase;
  color: var(--color-text);
  font-size: $font-size-default;
}

h5,
.h5 {
  font-size: $font-size-default;
  font-weight: bold;
}

h6,
.h6 {
  font-size: $font-size-default;
}

/* %link-default */
a,
%link-default,
button.link {
  text-decoration: none;
  color: $color-link;

  &.is-active {
    // Keep our styles.
    color: unset;
  }

  &:hover,
  &:focus {
    color: $color-text-inverted;
    background: $color-link;
  }

  &:active {
    color: $color-link;
    outline: $outline-active;
    background: $color-text-inverted;
  }

  .text-formatted & {
    border-bottom: 1px solid currentColor;
  }
}

.is-active a:focus,
.is-active a:hover {
  cursor: default;
  background-color: transparent;
}

p {
  margin-bottom: 1em;

  &:last-child {
    margin-bottom: 0;
  }
}

ul {
  margin-left: $grid-gutter;
  list-style: square outside;

  ul {
    margin-bottom: $grid-gutter;
    list-style-type: circle;

    ul {
      list-style-type: disc;
    }
  }

  &.inline {
    margin-left: 0;

    li {
      display: inline-block;
    }
  }
}

ol {
  margin-left: $grid-gutter;

  ol {
    margin-bottom: $grid-gutter;
  }
}

li {
  margin-bottom: 0.5em;

  &:last-child {
    margin-bottom: 0;
  }
}

table {
  display: table;
  overflow-x: auto;
  width: 100%;
  max-width: 100%;
  margin: 1em auto;

  p {
    margin: 0;
  }

  code,
  pre {
    max-width: 15rem;
  }

  .field-multiple-drag {
    white-space: nowrap;
  }

  .draggable {
    position: relative;
    .tabledrag-handle {
      position: absolute;
      top: calc(50% - 0.55rem);
      display: block;
      width: 2rem;
      height: 2rem;
      &:active,
      &:hover {
        background: transparent;
      }
      &:active {
        outline: 0;
      }

      .handle {
        width: 2rem;
        height: 2rem;
      }
    }
  }
}

td.is-active {
  background-color: transparent;
}

caption {
  @extend %allcaps;
}

tr {
  border-bottom: 1px solid $color-divider-light;
}

th {
  text-align: left;
}

td,
th {
  padding: 0.5em 2em 0.5em 0;
  vertical-align: top;
}

td:last-child,
th:last-child {
  padding-right: 0;
}

dl {
  margin-bottom: 1em;
  margin-left: $grid-gutter;

  &:last-child {
    margin-bottom: 0;
  }
}

dt {
  margin-bottom: 0.5em;
  margin-left: $grid-gutter;

  &:last-of-type {
    margin-bottom: 0;
  }
}

dd {
  margin-bottom: 1em;
}

hr {
  border-color: $color-divider-dark;
}

// Fontawesome
i.far,
i.fa,
i.fab,
i.fal,
i.fad {
  font-style: normal;
}

sub {
  position: relative;
  bottom: -0.25em;
  font-size: 0.75em;
}

sup {
  position: relative;
  top: -0.5em;
  font-size: 0.75em;
}

// %small
.tiny,
small,
.small,
%small {
  font-size: $font-size-s;
}

abbr {
  text-decoration: none;
  border-bottom: 2px dotted $color-text-muted;
}

kbd {
  padding: 0 0.5em;
  border: thin solid $color-text;
  border-radius: $button-border-radius;
  background: $color-text-muted;
  box-shadow: 1px 2px 2px $color-bg-light;
  font-family: inherit;
  font-size: 0.9em;
}

q {
  &::before {
    content: "„";
  }
  &::after {
    content: "“";
  }
}

mark {
  background-color: $color-bg-slight-contrast;
}

code,
kbd,
pre,
samp {
  white-space: pre;
  font-family: monospace;
  font-size: 1em;
}

pre {
  display: block;
  overflow: scroll;
  max-width: 100%;
  padding: 0.5rem 0.5rem 0.75rem;
  white-space: pre;
}

code,
pre,
kbd {
  background-color: var(--color-bg-slight-contrast);
}

mark {
  background-color: var(--color-bg-warning);
}

audio,
video {
  width: 100%;
  max-width: 100%;
}

img[alt] {
  color: var(--color-text-muted);
  font-style: italic;
}

img,
figure {
  max-width: 100%;
  height: auto;
  vertical-align: bottom;
}

figure {
  margin: (2 * $grid-gutter) 0;
  text-align: center;
}

figcaption {
  font-size: $font-size-default;
  font-weight: bold;
}

blockquote {
  display: flex;
  margin: (2 * $grid-gutter) 0;
  text-align: center;

  &,
  p {
    @extend %h3;

    color: $color-text-muted;
    font-size: $font-size-l;
    font-style: italic;
  }

  p {
    display: inline-block;
    padding: 0 $grid-gutter;
  }

  // span {
  // moved to blockquote because of changed wysiwyg output
  // }

  > *:first-child {
    margin-top: 0;
  }
  @include icon(quote-right, fas, before) {
    margin-right: 1rem;
  }
  @include icon(quote-left, fas, after) {
    margin-left: 1rem;
    white-space: nowrap;
  }

  @include breakpoint(m) {
    margin: (3 * $grid-gutter) $grid-gutter;
  }
}

// %allcaps
.allcaps,
%allcaps {
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

%label {
  @extend %allcaps;

  margin: 0;
  font-size: $font-size-s;
  font-weight: bold;
  line-height: 1.866;
}
