// This file is suitable for publish
// Body + theme-dark
body {
  --bold-color: var(--blue-3);
  --italic-color: var(--pink-2);
  --ebw-strong-em: var(--yellow-2);
  --ebw-link-underline: var(--cyan-4);
  --ebw-link-hidden: var(--cyan-4);

  // --link-color 	Resolved link text color
  --link-color: var(--gray-light-1);
  // --link-color-hover 	Resolved link text color (hover)
  --link-color-hover: var(--cyan-2);
  // --link-decoration 	Resolved link text decoration
  --link-decoration: underline;
  // --link-decoration-hover 	Resolved link text decoration (hover)
  --link-decoration-hover: underline;
  // --link-decoration-thickness 	Resolved link text decoration thickness
  // --link-unresolved-color 	Unresolved link text color
  --link-unresolved-color: var(--link-color);
  // --link-unresolved-opacity 	Unresolved link opacity
  --link-unresolved-opacity: 0.9;
  // --link-unresolved-filter 	Unresolved link filter, e.g. hue-rotate
  // --link-unresolved-decoration-style 	Unresolved link text decoration style
  --link-unresolved-decoration-style: dotted;
  // --link-unresolved-decoration-color 	Unresolved link text decoration color
  --link-unresolved-decoration-color: var(--ebw-link-underline);
  // --link-external-color 	External link text color
  --link-external-color: var(--link-color);
  // --link-external-color-hover 	External link text color (hover)
  --link-external-color-hover: var(--link-color-hover);
  // --link-external-decoration 	External link text decoration
  --link-external-decoration: underline;
  // --link-external-decoration-hover 	External link text decoration (hover)
  --link-external-decoration-hover: underline;
}
.theme-light {
  --bold-color: var(--blue-4);
  --italic-color: var(--pink-4);
  --ebw-strong-em: var(--yellow-3);
  --ebw-link-underline: var(--cyan-3);
  --ebw-link-hidden: var(--cyan-2);

  --link-color: var(--gray-dark-3);
  --link-color-hover: var(--cyan-4);
}
a {
  text-decoration-color: var(--ebw-link-underline);
}
// General Styling in Source

.cm-s-obsidian {
  span.cm-quote.cm-em {
    color: var(--italic-color);
  }
  span.cm-quote.cm-strong {
    color: var(--bold-color);
  }
  span.cm-strong.cm-em,
  span.cm-quote.cm-strong.cm-em {
    color: var(--ebw-strong-em);
  }
}
.cm-s-obsidian,
.markdown-source-view.mod-cm6 {
  // Readable strikethrough characters in source mode
  .cm-formatting-strikethrough {
    text-decoration: none;
    color: var(--text-faint);
  }
  .cm-strikethrough:not(.cm-formatting-strikethrough) {
    text-decoration-line: line-through;
    text-decoration-thickness: var(--link-decoration-thickness);
  }
  span.cm-hmd-internal-link, // wiki links
  span.cm-link {             // markdown links
    .cm-underline {
      text-decoration: none;
    }
    // Strikethrough links in live preview
    &.cm-strikethrough .cm-underline {
      color: var(--text-muted);
      text-decoration-line: line-through;
      text-decoration-thickness: var(--link-decoration-thickness);
    }
    &.cm-strikethrough:has(.cm-underline):not(:has(.is-unresolved)):after {
      content: ' \27B9';
      font-size: .8rem;
      opacity: .5;
    }
    // Strikethrough link text in source mode
    &.cm-strikethrough:not(.cm-formatting-strikethrough):not(:has(.cm-underline)) {
      color: var(--text-muted);
      text-decoration-line: line-through;
      text-decoration-thickness: var(--link-decoration-thickness);
      text-decoration-color: var(--text-normal);
    }
    // Readable strikethrough formatting characters in source mode
    &.cm-formatting-strikethrough {
      color: var(--text-faint);
      text-decoration: none;
    }
    // consistent link decorations
    &:not(:has(.is-unresolved)),
    &.cm-em:not(:has(.is-unresolved)),
    &.cm-strong:not(:has(.is-unresolved)),
    &.cm-em.cm-strong:not(:has(.is-unresolved)) {
      text-decoration-line: var(--link-decoration);
      text-decoration-color: var(--ebw-link-underline);
    }
    &:has(.is-unresolved),
    &.cm-em:has(.is-unresolved),
    &.cm-strong:has(.is-unresolved),
    &.cm-em.cm-strong:has(.is-unresolved) {
      text-decoration-line: var(--link-decoration);
      text-decoration-color: var(--ebw-link-underline);
      text-decoration-style: var(--link-unresolved-decoration-style);
      &:after {
        content: ' ✎';
        color: var(--ebw-link-underline);
      }
    }
  }
  // Bare links
  .cm-line .cm-url.cm-link {
    color: var(--link-external-color);
    opacity: unset;
  }
  // Unmatched bare links are .. super strange for formatting in source mode/live preview.
  .cm-line:has(.cm-url):not(:has(.cm-link)) .cm-url:not(.cm-link) {
    color: var(--text-normal);
    font-weight: normal;
    font-style: normal;
  }
  span.cm-hmd-internal-link, // wiki links
  span.cm-link,              // markdown links
  span.cm-url.cm-link {      // bare links
    &.cm-em:hover,
    &.cm-strong:hover,
    &.cm-em.cm-strong:hover {
      color: var(--link-color-hover);
      text-decoration-line: var(--link-decoration-hover);
    }
    // Em A (wikilink & markdown link text)
    &.cm-em,
    &.cm-em .is-unresolved {
      color: var(--italic-color);
    }
    // Strong A (wikilink & markdown link text)
    &.cm-strong,
    &.cm-strong .is-unresolved {
      color: var(--bold-color);
    }
    // Em Strong A (wikilink & markdown link text)
    &.cm-em.cm-strong,
    &.cm-em.cm-strong .is-unresolved {
      color: var(--ebw-strong-em);
    }
  }
  span.cm-formatting-link:not(.cm-url.cm-link) {
    font-weight: normal;
    font-style: normal;
    opacity: .7;
  }
  // the URL portion of markdown URL
  span.cm-string.cm-url {
    color: var(--ebw-link-hidden);
    font-weight: normal;
    font-style: normal;
  }
}

// Styling in Markdown rendered

.markdown-rendered {
  a del,
  del a,
  del a.internal-link {
    color: var(--text-muted);
  }
  em a,
  em a.internal-link,
  em a.internal-link.is-unresolved {
    color: var(--italic-color);
  }
  strong a,
  strong a.internal-link,
  strong a.internal-link.is-unresolved {
    color: var(--bold-color);
  }
  strong em,
  strong em a.external-link,
  strong em a.internal-link,
  strong em a.internal-link.is-unresolved {
    color: var(--ebw-strong-em);
  }
  .internal-link.is-unresolved {
    text-decoration-line: var(--link-decoration);
    text-decoration-color: var(--ebw-link-underline);
  }
  .internal-link.is-unresolved::after {
    content: ' ✎';
    color: var(--ebw-link-underline);
  }
}

em a:hover,
strong a:hover {
  color: var(--link-color-hover);
  text-decoration: var(--link-decoration-hover);
}


// Collapse external links / markdown links in edit mode
body:not(.ebullientworks-show-edit-mode-links) .markdown-source-view.mod-cm6 {
  div.cm-line:not(.cm-active) {
    > .cm-string.cm-url {
      text-decoration: none;
    }
    > .cm-string.cm-url:not(.cm-formatting) {
      font-size: 0;
    }
    > .cm-string.cm-url:not(.cm-formatting)::after {
      content: '\27B9';
      font-size: .8rem;
    }
  }
}


// Highlight, matched text
.cm-s-obsidian span.obsidian-search-match-highlight,
.cm-s-obsidian span.cm-highlight,
.search-result-file-matched-text,
.markdown-preview-view mark,
.markdown-rendered mark {
  color: var(--text-highlight-fg);
}

div.CodeMirror.cm-s-obsidian span.cm-highlight.CodeMirror-selectedtext {
  --text-selection: var(--text-highlight-bg-active);
}
.ebw-test-select {
  background-color: var(--text-selection);
}

// DATAVIEW TASK Skip decorations on dataview task list item indicators
.markdown-preview-view .task-list-item,
.markdown-rendered .task-list-item {
  a[data-href][aria-label-position].internal-link {
    border-bottom: none;
    text-decoration: none;
    color: var(--ebw-link-underline);
  }
}
