:root {
  --nq-ease: cubic-bezier(0.25, 0, 0, 1);
  --nq-shadow:
    0px 18px 38px rgba(31 35 72 / 0.07), 0px 7px 8.5px rgba(31 35 72 / 0.04), 0px 2px 2.5px rgba(31 35 72 / 0.02);
  --nq-shadow-lg:
    0px 6px 20px rgba(59 76 106 / 0.13), 0px 1.34018px 4.46726px rgba(59 76 106 / 0.0774939),
    0px 0.399006px 1.33002px rgba(59 76 106 / 0.0525061);
  /* This is the old box-shadox from nimiq-style framework. It stays here for reference */
  /* box-shadow: 0 0.5rem 1.5rem rgba(0, 0, 0, 0.15); */
  /* box-shadow: 0 0.5rem 2.5rem rgba(0, 0, 0, 0.15); */
  --nq-track: var(--colors-neutral-200);
  --nq-thumb: var(--colors-neutral-600);

  --nq-font-sans:
    'Mulish', ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Helvetica Neue, Arial,
    Noto Sans, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol, Noto Color Emoji;
  --nq-font-mono:
    'Fira Code', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace;

  --nq-m-min: 0;
  --nq-m-max: 0;

  --nq-screen-width-min: 320;
  --nq-screen-width-max: 1152;

  /* Base font sizes */
  --font-size-min: 16;
  --font-size-max: 16;
}

:where(*:not(:where(.nq-raw *, [nq-raw] *))) {
  /* Font size calculation */
  --f-font-width-range: calc(var(--nq-screen-width-max) - var(--nq-screen-width-min));
  --f-font-scale-factor: calc((100vw - (1px * var(--nq-screen-width-min))) / var(--f-font-width-range));
  --font-size-range: calc(var(--font-size-max) - var(--font-size-min));
  --font-size-fluid: calc(1px * var(--font-size-min) + var(--font-size-range) * var(--f-font-scale-factor));
  --font-size: clamp(calc(1px * var(--font-size-min)), var(--font-size-fluid), calc(var(--font-size-max) * 1px));

  border-color: var(--colors-neutral-400);
  outline-width: 1.5px;
  overscroll-behavior-x: contain;

  &:where(:not(:where(code, pre))) {
    font-family: var(--nq-font-sans, 'Mulish');
  }

  &:where(code, pre, pre *, code *) {
    font-family: var(--nq-font-mono, 'Fira Code');
    /* font-size-adjust: from-font;
    TODO
    Remove all font-sizes for Fira Code and instead using font-size-adjust to adjust the font-size to the parent element.
    https://developer.mozilla.org/en-US/docs/Web/CSS/font-size-adjust
    */
  }

  &:where(*, *:before, *:after) {
    box-sizing: inherit;
  }

  &:where(body) {
    box-sizing: border-box;
    -webkit-overflow-scrolling: touch;
    min-width: 300px;
    min-height: 100vh;
    min-height: 100dvh;
    color: var(--colors-neutral-900);
    background-color: var(--colors-neutral-0);

    :where([data-inverted] *) & {
      color: color-mix(in oklch, var(--colors-neutral-0) 80%);
    }
  }

  &:where(h1, h2, h3, h4, h5, h6) {
    text-wrap: balance;
    width: 100%;
    max-width: 100%;
    font-weight: bold;
    font-size: var(--font-size);
    line-height: 1.2;
    color: var(--colors-neutral);
    margin: 1em 0;

    /* text-box-trim: both;
    text-box-edge: cap alphabetic; */
  }

  &:where(h1) {
    --font-size-min: 24;
    --font-size-max: 32;
    margin-top: 0;
  }

  &:where(h2) {
    --font-size-max: 20;
    --font-size-min: 24;
  }

  &:where(p) {
    --line-height: 1.3125;
    margin: 1em 0;
  }

  small {
    --font-size-min: 12;
    --font-size-max: 14;
    font-size: var(--font-size);
    line-height: 1.2;
    font-weight: 600;
    margin: 0.5em 0;
  }

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

  /* Hide empty paragraphs. This is mostly for the markdown */
  &:where(p, span):empty:not(.iconify, [class*='i-']) {
    display: none;
  }

  &:where(a) {
    cursor: pointer;
  }

  &:where(blockquote p, blockquote p > :where(em, b)) {
    color: var(--colors-green);
  }

  &:where(blockquote) {
    margin: 1.5em 0;
    padding: 1em;
    background-color: var(--colors-green-400);
    outline: 1.5px solid var(--colors-green-500);
    font-size: 16px;
    border-radius: 8px;

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

    :is(code, pre) {
      background-color: color-mix(in oklch, var(--colors-green), transparent 80%);
      border-radius: 4px;
      font-weight: 400;
    }
  }

  &:not(:where(pre.shiki &, :where(h1, h2, h3, h4, h5, h6) &, blockquote &)):where(code, pre) {
    color: var(--colors-neutral-900);
    --font-size-min: 14;
    --font-size-max: 16;
    font-size: var(--font-size);
    overflow-x: auto;
    --nq-track: var(--colors-neutral-500);
    --nq-thumb: color-mix(in oklch, var(--colors-neutral-700) 75%, transparent);
  }

  :where(:where(h1, h2, h3, h4, h5, h6, p, li, span, a) > code) {
    background-color: var(--colors-neutral-200);
    padding-left: 0.15em;
    padding-right: 0.15em;
    border-radius: 0.1em;
  }

  &:where(pre) {
    background-color: var(--colors-neutral-50);
  }

  /* Links & buttons clickable */
  &:where(a, button:not([disabled])) {
    position: relative;

    @media not all and (hover: hover) {
      &::before {
        content: '';
        position: absolute;
        left: -1rem;
        top: -1rem;
        right: -1rem;
        bottom: -1rem;
      }
    }
  }

  &:where(input[type='text'], textarea) {
    caret-color: var(--colors-blue);
  }
}
