// stylelint-disable selector-max-type, no-descending-specificity

$typography-variants: ".h2, .h3, h4";

:is(#{$typography-variants}) {
  margin-bottom: 0.65em;
  line-height: calc(2px + 2ex + 2px);
  overflow-wrap: break-word;
  hyphens: auto;
}

h1 {
  font-family: var(--brand-font);
  font-size: clamp(2rem, 1rem + 5vw, 4rem);
  font-weight: var(--brand-font-weight);
  letter-spacing: 0.04em;
  line-height: 1.1;
}

h2,
.h2,
h3,
.h3,
.card__title,
.lead {
  font-family: var(--brand-font-alt);
}

h3,
.h3,
.card__title {
  font-weight: var(--brand-font-alt-weight-bold);
}

h2,
.h2 {
  font-size: clamp(1.85rem, 1rem + 5vw, 3rem);
  font-weight: var(--brand-font-alt-weight);
  line-height: 1.2;
}

article .h2 {
  color: var(--color-secondary);
}

h3,
.h3 {
  font-size: clamp(1.55rem, 1rem + 3vw, 2.15rem);
  line-height: 1.2;
}

article .h3 {
  color: var(--color-primary);
}

h4 {
  color: var(--color-inverse);
  font-size: 1.25rem;
  letter-spacing: 0.03em;
}

.logo-m {
  position: relative;
  font-family: var(--brand-font);
  font-weight: var(--brand-font-weight);

  &::before {
    content: "";
    z-index: -1;
    position: absolute;
    padding: 70%;
    transform: rotate(45deg) translateX(-20%);
    background-color: var(--color-background-alt);
  }
}

.hero--home {
  h1,
  h1::first-letter {
    -webkit-text-fill-color: transparent;
    -webkit-background-clip: text;
    background-clip: text;
    background-image: linear-gradient(
      -2deg,
      var(--color-secondary) 10%,
      var(--color-primary) 70%
    );
  }
}

.hero--home h1 {
  position: relative;
  margin-inline: auto;
  line-height: 0.8;
  text-align: left;

  @media (max-width: 75ch) {
    max-width: 10ch;
  }

  &::before {
    content: "";
    z-index: -1;
    position: absolute;
    top: 0;
    left: 0;
    padding: 1em;
    transform: rotate(45deg) translateX(-22%);
    background-color: var(--color-background-alt);
  }

  &::first-letter {
    font-size: 1.75em;
    float: left;
  }

  em {
    display: block;
    margin-top: 0.25em;
    font-size: 0.5em;
  }
}

article > * {
  + *:not([class]):not(details) {
    margin-top: 1.15em;
  }

  + .h2 {
    margin-top: 2em;
  }

  + .h3 {
    margin-top: 1.5em;
  }
}

article > ul,
article > ol {
  margin-bottom: 2em;

  li + li {
    margin-top: 0.75em;
  }
}

.heading-wrapper {
  display: flex;
  gap: 0.15em;
}

.anchor {
  font-size: max(0.75em, 1.75rem);
  line-height: 1;
  text-decoration: none;
  opacity: 0.6;
  order: -1;

  [hidden] {
    display: block;
  }

  &:hover {
    opacity: 1;
  }
}

::marker {
  color: var(--color-primary);
}

::selection {
  background-color: var(--color-yellow);
  color: var(--color-background);
  -webkit-text-fill-color: var(--color-background);
}

code:not([class*="language"]) {
  display: inline-block;
  padding: 0 0.15em;
  color: var(--color-secondary);
  font-family: Consolas, Monaco, "Andale Mono", "Ubuntu Mono", monospace;
  font-size: 0.92em;
}

a:not(.demo *),
button:not(.demo *),
input:not(.demo *),
textarea:not(.demo *) {
  --outline-size: max(2px, 0.08em);
  --outline-style: solid;
  --outline-color: currentColor;

  &:focus {
    outline: var(--outline-size) var(--outline-style) var(--outline-color);
    outline-offset: var(--outline-offset, var(--outline-size));
  }

  &:focus-visible {
    outline: var(--outline-size) var(--outline-style) var(--outline-color);
    outline-offset: var(--outline-offset, var(--outline-size));
  }

  &:focus:not(:focus-visible) {
    outline: none;
  }
}

a:not([class*="button"]) {
  border-radius: 0.15em;
  color: var(--color-blue);

  code {
    padding: 0;
    color: currentColor;
    font-size: 0.87em;
    line-height: 0;
    text-decoration: underline;
  }
}

.lead {
  font-size: 1.35rem;
  letter-spacing: 0.01em;
  line-height: 1.3;
}

.hero .lead {
  display: grid;
  position: relative;
  grid-template-columns: 8vw auto 8vw;
  align-items: center;
  justify-content: center;
  gap: 0.5em;
  letter-spacing: 0.03em;
  text-align: center;

  &::before,
  &::after {
    content: "";
    width: 100%;
    height: 1px;
    background: linear-gradient(to right, var(--gradient));
  }
}

blockquote {
  margin: var(--bq-margin, 3rem) 0;
  padding: 0.5rem 1.5rem;
  color: var(--color-inverse);
  font-size: 1.2rem;
  letter-spacing: 0.02em;

  &:first-child {
    max-width: 60ch;
    margin: 0 auto 3rem;
    color: var(--color-primary);
    text-align: center;
  }

  &:not(:first-child) {
    position: relative;
    border-width: 0;
    border-left-width: 2px;
    border-style: solid;
    border-image: linear-gradient(
        var(--gradient-angle, to bottom),
        var(--gradient)
      )
      1;
  }

  cite {
    color: var(--color-inverse);
    font-size: 0.75em;

    a:not([class]) {
      color: inherit;
    }
  }
}

hr {
  max-width: 10rem;
  height: 1px;
  margin: 3rem auto;
  border: none;
  background: linear-gradient(to right, var(--gradient));
}
