/** Base */
html {
  box-sizing: border-box;
  font-size: 100%;
  scroll-behavior: smooth;
}

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

::selection {
  background-color: #a3b387;
  color: #ffffff;
}

body {
  background-color: var(--color-bg);
  color: var(--color-fg);
  display: flex;
  flex-direction: column;
  font-family: var(--font-family-base);
  font-weight: var(--font-weight-normal);
  height: 100vh;
  line-height: 1.6;

  &::before {
    background-image: url('/assets/images/svg/bamboo.svg');
    background-repeat: no-repeat;
    background-size: 90vw auto;
    content: '';
    inset-block-end: 0;
    inset-block-start: 0;
    inset-inline-end: 0;
    inset-inline-start: 0;
    position: absolute;
    z-index: -1;
  }
}

[dir='rtl'] body::before {
  transform: scaleX(-1);
}

@media (--tablet) {
  body::before {
    background-size: 80vw auto;
  }
}

@media (--desktop) {
  body::before {
    background-size: 50vw auto;
  }
}

/** Headlines */
h1,
h2,
h3,
h4,
h5,
h6,
.page-title,
.headline,
.subheadline {
  font-weight: var(--font-weight-black);
  letter-spacing: -0.02em;
  line-height: var(--line-height-1);
  margin-block-start: 0;
  position: relative;
}

h1,
.page-title {
  font-size: var(--font-size-7);
  margin-block-end: var(--space-13);
}

h2,
.headline {
  font-size: var(--font-size-5);
  margin-block-end: var(--space-10);
  margin-block-start: var(--space-13);
}

h3,
h4,
h5,
h6,
.subheadline {
  font-size: var(--font-size-4);
  margin-block-end: var(--space-8);
  margin-block-start: var(--space-13);
}

h2:first-of-type,
h3:first-of-type {
  margin-block-start: 0;
}

p:last-of-type + h3 {
  margin-block-start: var(--space-13);
}

.dark h1,
.dark h2,
.dark h3,
.dark h4,
.dark h5,
.dark h6,
.dark .title,
.dark .headline,
.dark .subheadline {
  font-weight: var(--font-weight-extra-bold);
}

/** GitHub Style Anchor */
.anchor {
  float: left;
  inset-block-start: -0.01em;
  line-height: 1;
  margin-inline-start: -20px;
  padding-inline-end: 5px;
  position: relative;
  visibility: hidden;

  h2:hover &,
  h2:focus &,
  h3:hover &,
  h3:focus &,
  h4:hover &,
  h4:focus & {
    visibility: visible;
  }
}

/** Paragraph */
p,
.paragraph {
  font-size: var(--font-size-3);
  font-variant-ligatures: no-common-ligatures;
  font-weight: var(--font-weight-normal);
  letter-spacing: normal;
  line-height: var(--line-height-2);
  margin-block-end: var(--space-10);
  margin-block-start: 0;
}

p:last-of-type {
  margin-block-end: 0;
}

.dark p,
.dark .paragraph {
  font-weight: var(--font-weight-light);
}

/** Lists */
ul {
  font-size: var(--font-size-3);
  font-variant-ligatures: no-common-ligatures;
  list-style-type: square;
  margin-block-end: var(--space-12);
  margin-block-start: var(--space-12);
  padding-inline-start: 1.2em;

  ul,
  ol {
    margin-block-start: var(--space-5);
  }

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

  li & {
    margin-block-end: 0;
    padding-inline-start: 2rem;
  }
}

@media (--tablet) {
  ul {
    padding-inline-start: 0;
  }
}

ol {
  font-size: var(--font-size-3);
  font-variant-ligatures: no-common-ligatures;
  margin-block-end: var(--space-12);
  margin-block-start: var(--space-12);
  padding-inline-start: 1.2em;

  ol,
  ul {
    margin-block-start: var(--space-5);
  }

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

  li & {
    margin-block-end: 0;
    padding-inline-start: 2rem;
  }
}

@media (--tablet) {
  ol {
    padding-inline-start: 0;
  }
}

dl {
  font-size: var(--font-size-3);
  margin-block-end: var(--space-12);
  margin-block-start: 0;
  padding-inline-start: 1.2em;
}

dt {
  font-weight: var(--font-weight-extra-bold);
}

dd {
  margin-inline-start: 0;
}

/** Critic Markup */
del {
  text-decoration-thickness: 0.15em;
}

ins {
  text-decoration-style: solid;
  text-decoration-thickness: 0.15em;
}

mark {
  background-color: rgba(230, 240, 40, 0.7);
  border-color: rgba(0, 0, 0, 0.1);
  border-radius: 0.25em;
  box-shadow: var(--shadow-dark-inset);
  color: rgba(0, 0, 0, 0.75);
  padding-block-end: 0.4em;
  padding-block-start: 0.4em;
  padding-inline-end: 0.3em;
  padding-inline-start: 0.3em;
}

/** Code, Sample, Abbreviation, Keyboard Shortcuts etc. */
pre {
  white-space: pre;
}

p code,
li code,
samp {
  background-color: var(--color-bg-code);
  border-radius: 0.3em;
  color: var(--color-fg-code);
  padding-block-end: var(--space-1);
  padding-block-start: var(--space-1);
  padding-inline-end: var(--space-3);
  padding-inline-start: var(--space-3);
  white-space: normal;
}

kbd {
  background-color: #f7f7f7;
  border-color: #cccccc;
  border-style: solid;
  border-width: var(--border-width-1);
  box-shadow: var(--shadow-beveled-keyboard);
  color: #333333;
  display: inline-block;
  font-size: var(--font-size-2);
  font-weight: 700;
  line-height: 1.4;
  padding: 0.3em 0.6em 0.1em;
  text-shadow: var(--shadow-white-outline);
  white-space: nowrap;
}

abbr {
  font-variant: small-caps;
}

:is(code, kbd, samp) {
  font-family: var(--font-family-mono);
  font-size: clamp(0.8rem, 0.8vw, 1rem);
}

:is(abbr, dfn) {
  cursor: help;
}

/** Quotes */
[lang|='en'] blockquote,
blockquote[lang|='en'],
[lang|='en'] q,
q[lang|='en'] {
  quotes: '“' '”' '‘' '’';
}

[lang|='de'] blockquote,
blockquote[lang|='de'],
[lang|='de'] q,
q[lang|='de'] {
  quotes: '»' '«' '›' '‹';
}

[lang|='ja'] blockquote,
blockquote[lang|='ja'],
[lang|='ja'] q,
q[lang|='ja'] {
  font-style: normal;
  quotes: '「' '」,' '『' '』';
}

blockquote {
  margin-block-end: var(--space-12);
  margin-block-start: var(--space-12);
  margin-inline-end: var(--space-8);
  margin-inline-start: var(--space-8);
  position: relative;

  @media (--tablet) {
    margin-inline-end: var(--space-10);
    margin-inline-start: var(--space-10);
  }

  ul,
  ol {
    padding-block-start: var(--space-6);
  }

  &::before {
    color: var(--color-accent-primary);
    content: '“';
    font-family: Trebuchet MS, Georgia, serif;
    font-size: var(--font-size-6);
    height: 0.6em;
    inset-block-start: -0.55em;
    inset-inline-start: -0.55em;
    position: absolute;
  }

  p,
  ul,
  ol {
    font-size: var(--font-size-3);
    font-style: italic;
    font-weight: var(--font-weight-extra-light);
    margin-block-end: var(--space-10);
    margin-block-start: 0;

    &:nth-last-child(2) {
      margin-block-end: var(--space-2);
    }

    & strong {
      font-style: italic;
      font-weight: var(--font-weight-bold);
    }

    &:last-child {
      & strong {
        font-size: var(--font-size-3);
        font-style: normal;
        font-weight: var(--font-weight-bold);

        &::before {
          content: '—';
          font-weight: var(--font-weight-light);
          inset-inline-start: -0.8em;
          position: absolute;
        }

        & em {
          font-size: var(--font-size-3);
          font-weight: var(--font-weight-normal);
          font-weight: var(--font-weight-extra-light);
        }
      }
    }
  }
}

q {
  font-style: italic;

  &::before {
    font-style: normal;
    margin-inline-end: -0.05em;
  }

  &::after {
    font-style: normal;
    margin-inline-start: 0.1em;
  }
}

.pullquote {
  padding-block-end: var(--space-9);
  padding-block-start: var(--space-9);
  text-align: center;

  &::before {
    display: none;
  }

  & p {
    font-size: var(--font-size-4);
    font-weight: var(--font-weight-extra-bold);
    line-height: var(--line-height-1);
    margin: 0;
  }

  & p:first-child::before {
    content: open-quote;
    font-style: normal;
  }

  & p:nth-of-type(1):first-letter {
    margin-inline-start: -0.4em;
  }

  & p:nth-last-of-type(1)::after {
    content: close-quote;
    font-style: normal;
  }

  footer {
    font-size: var(--font-size-2);
    font-weight: normal;
    margin-block-start: var(--space-6);
  }

  b {
    font-style: normal;
  }
}

/** Links */
a {
  color: var(--color-fg);
  font-weight: var(--font-weight-semi-bold);
  text-decoration: underline;
  text-decoration-color: var(--color-fg-soft);
  text-decoration-thickness: 0.2em;
  text-underline-offset: auto;

  &:hover,
  &:focus {
    text-decoration-color: var(--color-accent-primary);
  }
}

/** Helper */
.no-margin {
  margin: 0 !important;
}

.hidden {
  display: none !important;
}

.spoiler {
  background: var(--color-fg-full);
  color: var(--color-fg-full);
  cursor: help;
  padding-block-end: var(--space-1);
  padding-block-start: var(--space-1);
  padding-inline-end: var(--space-1);
  padding-inline-start: var(--space-1);

  &.spoiler-visible {
    color: var(--color-fg-full-inverse);
    cursor: pointer;
  }
}

.no-js .spoiler {
  color: var(--color-fg-full-inverse);
}
