/* GPLv3 license
FAS - Link
Author: ElsaTam (Kapirklaa in Discord)
*/
body {
  --link-decoration: doodle;
}

@container style(--link-decoration: doodle) {
  .cm-hmd-internal-link,
  .internal-link:not(.metadata-container .internal-link) {
    position: relative;
  }
}
@container style(--link-external-decoration: doodle) {
  .cm-url,
  .cm-link,
  .external-link:not(.metadata-container .external-link) {
    position: relative;
  }
}
@media (hover: hover) {
  @container style(--link-decoration: doodle) {
    .cm-hmd-internal-link:hover::after,
    .internal-link:not(.metadata-container .internal-link):hover::after {
      content: "";
      position: absolute;
      transition: bottom 0.3s;
      left: 0;
      right: 0;
      bottom: -0.3em;
      height: 0.34em;
      background-color: var(--link-color-hover);
      -webkit-mask-image: url("data:image/svg+xml,<svg width='100' height='64' fill='none' xmlns='http://www.w3.org/2000/svg'><path d='M-17 30.5C-1 22 72-4 54 13 37.9 28.2-2.5 57.5 16 55.5s72-29 104-40' stroke='black' stroke-width='14'/></svg>");
      -webkit-mask-size: auto 100%;
      -webkit-mask-repeat: repeat no-repeat;
    }
  }
  @container style(--link-external-decoration: doodle) {
    .cm-url:hover::after,
    .cm-link:hover::after,
    .external-link:not(.metadata-container .external-link):hover::after {
      content: "";
      position: absolute;
      transition: bottom 0.3s;
      left: 0;
      right: 0;
      bottom: -0.3em;
      height: 0.34em;
      background-color: var(--link-color-hover);
      -webkit-mask-image: url("data:image/svg+xml,<svg width='100' height='64' fill='none' xmlns='http://www.w3.org/2000/svg'><path d='M-17 30.5C-1 22 72-4 54 13 37.9 28.2-2.5 57.5 16 55.5s72-29 104-40' stroke='black' stroke-width='14'/></svg>");
      -webkit-mask-size: auto 100%;
      -webkit-mask-repeat: repeat no-repeat;
    }
  }
}
body {
  --link-decoration-hover: var(--link-decoration);
  --link-external-decoration: underline;
  --link-external-decoration-hover: var(--link-external-decoration);
  --link-decoration-thickness: 2px;
  --link-decoration-thickness-hover: 1px;
}

@container not style(--link-decoration: doodle) {
  .cm-hmd-internal-link .cm-underline,
  .markdown-rendered .internal-link:not(.metadata-container .internal-link),
  .internal-link:not(.metadata-container .internal-link) {
    text-underline-offset: 0.2em;
    transition: text-underline-offset 0.3s, opacity 0.15s ease-in-out;
  }
}
@media (hover: hover) {
  @container not style(--link-decoration: doodle) {
    .cm-hmd-internal-link .cm-underline:hover,
    .markdown-rendered .internal-link:not(.metadata-container .internal-link):hover,
    .internal-link:not(.metadata-container .internal-link):hover {
      text-underline-offset: calc(0.4em + var(--link-decoration-thickness) - var(--link-decoration-thickness-hover));
      text-decoration-thickness: var(--link-decoration-thickness-hover);
    }
  }
}
@container not style(--link-external-decoration: none) {
  .cm-url .cm-underline,
  .cm-link .cm-underline,
  .external-link:not(.metadata-container .external-link) {
    text-underline-offset: 0.2em;
    transition: text-underline-offset 0.3s, opacity 0.15s ease-in-out;
  }
}
@media (hover: hover) {
  @container not style(--link-external-decoration: none) {
    .cm-url .cm-underline:hover,
    .cm-link .cm-underline:hover,
    .external-link:not(.metadata-container .external-link):hover {
      text-underline-offset: calc(0.4em + var(--link-decoration-thickness) - var(--link-decoration-thickness-hover));
      text-decoration-thickness: var(--link-decoration-thickness-hover);
    }
  }
}
.cm-s-obsidian span.cm-url,
.cm-s-obsidian span.cm-link,
.cm-s-obsidian span.cm-hmd-internal-link {
  text-decoration-line: none;
}

@media (hover: hover) {
  .cm-s-obsidian span.cm-url:hover,
  .cm-s-obsidian span.cm-link:hover,
  .cm-s-obsidian span.cm-hmd-internal-link:hover {
    text-decoration-line: none;
  }
}
.external-link {
  background-position: top right;
  background-size: 10px;
  padding-inline-end: 13px;
}
