/**
 * Fonts
 */

body, button, input, select, label, textarea {
  font-family: var(--font-body);
}
pre, #markdown-editor-input, .text-mono, .code-base {
  font-family: var(--font-code);
}

/*
 * Header Styles
 */

h1 {
  font-size: 3.425em;
  line-height: 1.22222222em;
  margin-top: 0.48888889em;
  margin-bottom: 0.48888889em;
}
h2 {
  font-size: 2.8275em;
  line-height: 1.294117647em;
  margin-top: 0.8627451em;
  margin-bottom: 0.43137255em;
}
h3 {
  font-size: 2.333em;
  line-height: 1.221428572em;
  margin-top: 0.78571429em;
  margin-bottom: 0.43137255em;
}
h4 {
  font-size: 1.666em;
  line-height: 1.375em;
  margin-top: 0.78571429em;
  margin-bottom: 0.43137255em;
}

h1, h2, h3, h4, h5, h6 {
  font-weight: 400;
  position: relative;
  display: block;
  font-family: var(--font-heading, var(--font-body));
  @include lightDark(color, #222, #BBB);
  .subheader {
    font-size: 0.5em;
    line-height: 1em;
    color: lighten($text-dark, 32%);
  }
}

h5 {
  font-size: 1.4em;
}

h5, h6 {
  line-height: 1.2em;
  margin-top: 0.78571429em;
  margin-bottom: 0.66em;
}

@include smaller-than($s) {
  h1 {
    font-size: 2.8275em;
  }
  h2 {
    font-size: 2.333em;
  }
  h3 {
    font-size: 1.666em;
  }
  h4 {
    font-size: 1.333em;
  }
  h5 {
    font-size: 1.161616em;
  }
}

.list-heading {
  font-size: 2rem;
}

h2.list-heading {
  font-size: 1.333rem;
}

/*
 * Link styling
 */
a {
  color: var(--color-link);
  fill: currentColor;
  cursor: pointer;
  text-decoration: none;
  transition: filter ease-in-out 80ms;
  line-height: 1.6;
  &:hover {
    text-decoration: underline;
  }
  &.icon {
    display: inline-block;
  }
  svg {
    position: relative;
    display: inline-block;
  }
  &:focus img:only-child {
    outline: 2px dashed var(--color-link);
    outline-offset: 2px;
  }
}

a.no-link-style {
  color: inherit;
  &:hover {
    text-decoration: none;
  }
}

.blended-links a {
  color: inherit;
  svg {
    fill: currentColor;
  }
}

/*
 * Other HTML Text Elements
 */
p, ul, ol, pre, table, blockquote {
  margin-top: 0.3em;
  margin-bottom: 1.375em;
}

hr {
  border: 0;
  height: 1px;
  @include lightDark(background, #eaeaea, #555);
  margin-bottom: $-l;
  &.faded {
    background-image: linear-gradient(to right, #FFF, #e3e0e0 20%, #e3e0e0 80%, #FFF);
  }
  &.darker {
    @include lightDark(background, #DDD, #666);
  }
  &.margin-top, &.even {
    margin-top: $-l;
  }
}

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

em, i, .italic {
  font-style: italic;
}

small, p.small, span.small, .text-small {
  font-size: 0.75rem;
}

sup, .superscript {
  vertical-align: super;
  font-size: 0.8em;
}

sub, .subscript {
  vertical-align: sub;
  font-size: 0.8em;
}

pre {
  font-size: 12px;
  border: 1px solid #DDD;
  @include lightDark(background-color, #FFF, #2B2B2B);
  @include lightDark(border-color, #DDD, #111);
  border-radius: 4px;
  padding-inline-start: 26px;
  position: relative;
  padding-top: 3px;
  padding-bottom: 3px;
  &:before {
    content: '';
    display: block;
    position: absolute;
    top: 0;
    width: 22.4px;
    inset-inline-start: 0;
    height: 100%;
    @include lightDark(background-color, #f5f5f5, #313335);
    @include lightDark(border-inline-end, 1px solid #DDD, none);
  }
}

@media print {
  pre {
    padding-left: 12px;
  }
  pre:before {
    display: none;
  }
}

blockquote {
  display: block;
  position: relative;
  border-left: 4px solid transparent;
  border-left-color: var(--color-primary);
  @include lightDark(background-color, #f8f8f8, #333);
  padding: $-s $-m $-s $-xl;
  overflow: auto;
  &:before {
    content: "\201C";
    font-size: 2em;
    font-weight: bold;
    position: absolute;
    top: $-s;
    left: $-s;
    color: lighten($text-dark, 20%);
  }
}

.text-mono {
  font-family: var(--font-code);
}

.text-uppercase {
  text-transform: uppercase;
}

.text-capitals {
  text-transform: capitalize;
}

.code-base {
  font-size: 0.84em;
  border: 1px solid #DDD;
  border-radius: 3px;
  @include lightDark(background-color, #f8f8f8, #2b2b2b);
  @include lightDark(border-color, #DDD, #444);
}

code {
  @extend .code-base;
  display: inline;
  padding: 1px 3px;
  white-space:pre-wrap;
  line-height: 1.2em;
}

span.code {
  @extend .code-base;
  padding: 1px $-xs;
}

pre code {
  background-color: transparent;
  border: 0;
  font-size: 1em;
  display: block;
  line-height: 1.6;
}

span.highlight {
  font-weight: bold;
  padding: 2px 4px;
}

/*
 * Lists
 */
ul, ol {
  padding-left: $-m * 2.0;
  padding-right: $-m * 2.0;
  display: flow-root;
  p {
    margin: 0;
  }
}
ul {
  list-style: disc;
  ul {
    list-style: circle;
  }
  label {
    margin: 0;
  }
}

ol {
  list-style: decimal;
}

li > ol, li > ul {
  margin-top: 0;
  margin-bottom: 0;
  margin-block-end: 0;
  margin-block-start: 0;
  padding-block-end: 0;
  padding-block-start: 0;
  padding-left: $-m * 1.2;
  padding-right: $-m * 1.2;
}

/**
 * Checkbox lists
 * Some styles duplicated for supporting logical units (eg. inline-end) while
 * providing fallbacks to non-logical rules, so RTL is natively supported where possible.
 */
li.checkbox-item, li.task-list-item {
  display: list-item;
  list-style: none;
  margin-left: -($-m * 1.2);
  margin-inline-start: -($-m * 1.2);
  margin-inline-end: 0;
  input[type="checkbox"] {
    margin-right: $-xs;
    margin-inline-end: $-xs;
    margin-inline-start: 0;
  }
  li.checkbox-item, li.task-list-item {
    margin-left: $-xs;
    margin-inline-start: $-xs;
    margin-inline-end: 0;
  }
}

/*
 * Generic text styling classes
 */
.underlined {
  text-decoration: underline;
}

.text-center {
  text-align: center;
}
.text-left {
  text-align: start;
}
.text-right {
  text-align: end;
}

@each $sizeLetter, $size in $screen-sizes {
  @include larger-than($size) {
    .text-#{$sizeLetter}-center {
      text-align: center;
    }
    .text-#{$sizeLetter}-left {
      text-align: start;
    }
    .text-#{$sizeLetter}-right {
      text-align: end;
    }
  }
}

.text-bigger {
  font-size: 1.1em;
}

.text-large {
  font-size: 1.6666em;
}

.no-color {
  color: inherit;
}

.break-text {
  white-space: normal;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.text-limit-lines-1 {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.text-limit-lines-2 {
  // -webkit use here is actually standardised cross-browser:
  // https://developer.mozilla.org/en-US/docs/Web/CSS/-webkit-line-clamp
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
}

/**
 * Grouping
 */
.header-group {
  margin: $-m 0;
  h1, h2, h3, h4, h5, h6 {
    margin: 0;
  }
}

span.sep {
  color: #BBB;
  padding: 0 $-xs;
}

.list > * {
  display: block;
}

/**
  * Icons
  */
.svg-icon {
  width: 1em;
  height: 1em;
  display: inline-block;
  position: relative;
  bottom: -0.105em;
  margin-inline-end: $-xs;
  pointer-events: none;
  fill: currentColor;
}
