// The code snippets in this file are derived from the Halcyon theme

// - https://github.com/dbarenholz/halcyon-obsidian?tab=readme-ov-file

body {
  --h1-weight: 700;
  --h2-weight: 675;
  --h3-weight: 650;
  --h4-weight: 625;
  --h5-weight: 600;
  --h6-weight: 575;

  --h1-size: 1.81803em;
  --h2-size: 1.61803em;
  --h3-size: 1.41803em;
  --h4-size: 1.21803em;
  --h5-size: 1.11803em;
  --h6-size: 1.01803em;
}

body.flexcyon-coloured-headings {
  --h1-color: var(--flexcyon-blue);
  --h2-color: var(--flexcyon-purple-lilac);
  --h3-color: var(--flexcyon-cyan);
  --h4-color: var(--flexcyon-pink);
  --h5-color: var(--flexcyon-lime-green);
  --h6-color: var(--flexcyon-yellow);
}

body.flexcyon-headings-glow-enabled {
  h1,
  .cm-header-1 {
    text-shadow: 2px 2px 4px var(--h1-color);
  }
  h2,
  .cm-header-2 {
    text-shadow: 1.75px 1.75px 3.5px var(--h2-color);
  }
  h3,
  .cm-header-3 {
    text-shadow: 1.5px 1.5px 3px var(--h3-color);
  }
  h4,
  .cm-header-4 {
    text-shadow: 1.25px 1.25px 2.5px var(--h4-color);
  }
  h5,
  .cm-header-5 {
    text-shadow: 1px 1px 2px var(--h5-color);
  }
  h6,
  .cm-header-6 {
    text-shadow: 0.75px 0.75px 1.5px var(--h6-color);
  }
  .cm-formatting-header {
    text-shadow: none;
  }
}

@mixin heading-underlines($h-lvl) {
  body.flexcyon-h#{$h-lvl}-underline-enabled .HyperMD-header-#{$h_lvl},
  body.flexcyon-h#{$h-lvl}-underline-enabled h#{$h-lvl} {
    border-block-end: calc((var(--h#{$h-lvl}-weight) - 200) / 100 * 1px) solid
      var(--h#{$h-lvl}-color);
  }
}

@include heading-underlines(1);
@include heading-underlines(2);
@include heading-underlines(3);
@include heading-underlines(4);
@include heading-underlines(5);
@include heading-underlines(6);

@mixin headings-indicator($h_level) {
  .headings-indicator-all,
  .headings-indicator-h#{$h_level},
  .flexcyon-headings-indicator-h#{$h_level}
    .workspace-leaf-content[data-type="markdown"] {
    h#{$h_level}:not(:hover)::before,
    .HyperMD-header-#{$h_level}::before {
      position: relative;
      content: "h#{$h_level}";
      color: var(--h#{$h_level}-color);
      opacity: calc(var(--dimmed) + 0.25);
      font-size: var(--font-ui-medium);
      padding-right: 8px;
    }

    h#{$h_level}:not(:hover) svg,
    .HyperMD-header-#{$h_level} svg {
      transform: translateX(-28px);
    }
  }
}

@include headings-indicator(1);
@include headings-indicator(2);
@include headings-indicator(3);
@include headings-indicator(4);
@include headings-indicator(5);
@include headings-indicator(6);

@mixin heading-alignment($h-lvl) {
  body {
    --flexcyon-heading-#{$h-lvl}-alignment: left;
    .HyperMD-header-#{$h-lvl},
    h#{$h-lvl} {
      text-align: var(--flexcyon-heading-#{$h-lvl}-alignment);
    }
  }
}

@include heading-alignment(1);
@include heading-alignment(2);
@include heading-alignment(3);
@include heading-alignment(4);
@include heading-alignment(5);
@include heading-alignment(6);
