// The code snippets in this file are derived from the Halcyon theme
// - https://github.com/dbarenholz/halcyon-obsidian?tab=readme-ov-file

body {
  --dimmed: 0.55;
  --upsize: 103%;
  --expand: 110%;
  --less-letter-spacing: -3px;
  --flexcyon-comm-item-opacity: 0.89;
  --flexcyon-tree-item-horiz-padding: 10px;
  --flexcyon-tree-item-verti-padding: 2px;

  .clickable-icon {
    opacity: var(--dimmed);
    padding: 4px 8px;

    &:hover {
      opacity: unset;
      scale: var(--upsize);
    }
  }
  .view-header-nav-buttons .clickable-icon,
  .view-actions .clickable-icon {
    padding: 5px 10px;
  }

  .graph-controls .clickable-icon,
  .clickable-icon.side-dock-ribbon-action {
    padding: var(--size-2-2) var(--size-2-3);
  }
  .mod-community-modal .modal-sidebar .setting-item.mod-toggle {
    padding: 6px 16px;
  }
  .mod-community-modal
    .modal-sidebar:not(:has(+ .community-modal-details))
    .setting-item.mod-toggle {
    margin-top: -8px;
  }
  .modal-sidebar:not(:has(+ .community-modal-details))
    .community-modal-controls {
    display: flex;
    .community-modal-search-summary {
      margin-top: 3px;
    }
  }
  .modal-sidebar {
    padding: 12px;
  }
  .community-modal-search-summary {
    padding: 6px 16px;
    margin-left: 4px;
  }
  .community-modal-search-results {
    padding: 16px;
    gap: 14px;
  }
  .community-modal-info hr {
    display: none;
  }
  .setting-item {
    border-top: none;
  }
  .setting-item.setting-item-heading {
    border-bottom: 1px solid var(--background-modifier-border);
    .setting-item-name {
      line-height: 1.5;
      padding-right: 4px;
    }
  }
  .setting-item + div > .setting-item-heading,
  .setting-item + .setting-item-heading {
    margin-top: 1.5em;
  }
  .horizontal-tab-nav-item,
  .vertical-tab-nav-item {
    padding: calc(var(--size-4-1) + 1px) var(--size-4-2);
    margin-bottom: 1px;
    font-size: calc(var(--font-ui-small) + 1.25px);
  }
  .LazyLoad.is-visible {
    height: unset !important;
  }
  .oz-folder-line,
  .oz-nav-file,
  .tree-item:not(.graph-control-section) {
    padding: var(--flexcyon-tree-item-verti-padding)
      var(--flexcyon-tree-item-horiz-padding);
  }
}

body.flexcyon-workspace-card-layout {
  .community-modal-info-name {
    border: 2px solid var(--text-faint);
    border-top-left-radius: 16px;
    border-top-right-radius: 16px;
    border-bottom: 0px;
    padding: 3px 16px;
    padding-top: 16px;
    margin-bottom: 0px;
    margin-top: 8px;
  }
  .community-modal-info-downloads,
  .community-modal-info-version,
  .community-modal-info-author,
  .community-modal-info-repo,
  .community-modal-info-desc {
    border: 2px solid var(--text-faint);
    border-top: 0px;
    border-bottom: 0px;
    padding: 3px 16px;
    overflow-wrap: break-word;
  }
  .community-modal-info-desc {
    margin-top: 0px;
  }
  .community-modal-info-downloads {
    width: 100%;
    margin-top: 0px;
  }

  .community-modal-button-container {
    border: 2px solid var(--text-faint);
    border-bottom-left-radius: 16px;
    border-bottom-right-radius: 16px;
    border-top: 0px;
    padding: 16px;
    padding-bottom: 24px;
    margin: 0px;
  }
  .community-modal-readme {
    margin-top: 32px;
  }
}

body.theme-light.flexcyon-flex-max-mode:not(.is-phone),
body.theme-light.flexcyon-settings-comm-item-enabled:not(.is-phone) {
  .community-item.is-selected {
    background-color: var(--background-primary);
    border: none;
    span.flair.mod-pop {
      background-color: rgba(var(--color-blue-rgb), var(--dimmed));
    }
    .community-item-name {
      color: var(--color-red);
      font-weight: bold;
    }
    .community-item-author {
      color: var(--color-yellow);
      font-weight: bold;
    }
    .community-item-downloads {
      color: var(--color-purple);
      font-weight: bold;
    }
    .community-item-updated {
      color: var(--color-green);
      font-weight: bold;
    }
    .community-item-desc {
      color: var(--text-normal);
    }
  }
}

body.theme-dark.flexcyon-flex-max-mode:not(.is-phone),
body.theme-dark.flexcyon-settings-comm-item-enabled:not(.is-phone) {
  .community-item.is-selected {
    background-color: var(--background-primary);
    border: none;
    span.flair.mod-pop {
      background-color: rgba(var(--color-yellow-rgb), var(--dimmed));
    }
    .community-item-name {
      color: var(--color-red);
      font-weight: bold;
    }
    .community-item-author {
      color: var(--color-blue);
      font-weight: bold;
    }
    .community-item-downloads {
      color: var(--color-pink);
      font-weight: bold;
    }
    .community-item-updated {
      color: var(--color-purple);
      font-weight: bold;
    }
    .community-item-desc {
      color: var(--text-normal);
    }
  }
}

body.theme-light.flexcyon-flex-max-mode:not([class*="iconic"]),
body.theme-light.flexcyon-settings-smiley-icons-enabled.flexcyon-ensure-plugin-icon:not(
    [class*="iconic"]
  ),
body.theme-light.flexcyon-settings-smiley-icons-enabled:not(
    .flexcyon-ensure-plugin-icon
  ) {
  div.setting-item-control {
    div.checkbox-container::after {
      filter: saturate(2.5);
      font-weight: bold;
    }
  }
}

body.flexcyon-flex-max-mode:not([class*="iconic"]) div.setting-item-control,
body.flexcyon-settings-smiley-icons-enabled.flexcyon-ensure-plugin-icon:not(
    [class*="iconic"]
  )
  div.setting-item-control,
body.flexcyon-settings-smiley-icons-enabled:not(.flexcyon-ensure-plugin-icon)
  div.setting-item-control {
  div.checkbox-container {
    background-color: var(--color-base-05);
    box-shadow: unset;
    font-weight: bolder;
  }

  div.checkbox-container::after {
    content: ":(";
    transform: translateY(-10%);
    width: fit-content;
    height: fit-content;
    background-color: inherit;
    color: var(--color-red);
    box-shadow: unset;
    border-radius: 25%;
  }

  div.checkbox-container.is-enabled::after {
    content: ":)";
    color: var(--color-green);
    transform: translate(16px, -10%);
  }

  input.slider {
    border-radius: unset;
  }
}

@mixin nth-hover-color($color-map: ()) {
  $max-index: 0;
  @each $index, $color in $color-map {
    $max-index: max($max-index, $index);
  }
  $interval: $max-index + 1;

  @each $index, $color in $color-map {
    & :nth-of-type(#{$interval}n + #{$index}):hover {
      color: var(--color-#{$color});
    }
  }
}

body.flexcyon-flex-max-mode div.side-dock-actions,
body.flexcyon-sidedock-icon-effects div.side-dock-actions {
  opacity: var(--dimmed);
  scale: var(--upsize);

  &:hover {
    opacity: 1;
  }
  & :hover {
    scale: var(--expand);
  }

  @include nth-hover-color(
    (
      0: purple,
      1: cyan,
      2: blue,
      3: pink,
      4: green,
      5: yellow,
      6: orange,
      7: red,
    )
  );
}

body {
  --icon-stroke: 2px;
  --icon-color-active: var(--interactive-accent);
  --icon-color-focused: var(--interactive-accent);
  --clickable-icon-radius: 0;

  [aria-label^="Collapse results"] {
    letter-spacing: var(--less-letter-spacing);
  }

  span.flair.mod-pop {
    margin-left: var(--flexcyon-settings-installed-tooltip-left-margin);
  }
}

body.theme-light.flexcyon-settings-comm-item-enabled .community-item-name {
  color: var(--color-yellow);
}

body.flexcyon-settings-comm-item-enabled {
  div.community-modal-search-results div.community-item {
    opacity: var(--flexcyon-comm-item-opacity);
  }

  div.community-modal-search-results div.community-item.is-selected {
    opacity: unset;
    border: unset;
    font-weight: bold;
  }

  div.community-item div.community-item-name span.flair.mod-pop {
    position: absolute;
    right: 0.5rem;
    top: 0.7rem;
    background-color: var(--text-accent);
    color: var(--color-base-25);
  }

  div.community-item.is-selected div.community-item-name span.flair.mod-pop {
    background-color: var(--color-base-25);
    color: var(--text-normal);
  }

  .community-item-name {
    width: 75%;
    overflow-wrap: break-word;
    color: var(--color-blue);
  }

  .community-item-downloads,
  .community-modal-info-downloads {
    color: rgba(var(--color-cyan-rgb), var(--flexcyon-comm-item-opacity));
  }

  .community-item-updated {
    color: rgba(
      var(--color-blue-rgb),
      calc(var(--flexcyon-comm-item-opacity) - 0.1)
    );
  }

  .community-modal-info-version {
    color: rgba(
      var(--color-green-rgb),
      calc(var(--flexcyon-comm-item-opacity) - 0.1)
    );
  }
}

body.flexcyon-flex-max-mode,
body.flexcyon-settings-coloured-icons {
  [aria-label^="Uninstall"] {
    color: rgba(var(--color-red-rgb), 0.9);
  }

  [aria-label^="Options"] {
    color: rgba(var(--color-blue-rgb), 0.9);
  }

  [aria-label^="Customise this command"],
  [aria-label^="Customize this command"],
  [aria-label^="Hotkeys"],
  [aria-label^="Open snippets folder"],
  [aria-label^="Open plugins folder"] {
    color: rgba(var(--color-green-rgb), 0.9);
  }

  [aria-label^="Donate to support"] {
    color: rgba(var(--color-pink-rgb), 0.9);
  }

  [aria-label^="Reload plugins"],
  [aria-label^="Reload snippets"] {
    color: rgba(var(--color-cyan-rgb), 0.9);
  }

  [aria-label^="Restore default"] {
    color: rgba(var(--color-purple-rgb), 0.9);
  }
}

body.is-mobile .vertical-tab-content {
  background-color: var(--color-base-05);
}

body.flexcyon-workspace-angled-layout {
  .collapse-icon.is-collapsed svg.svg-icon {
    transform: rotate(calc(var(--direction) * -1 * 90deg)) skewX(-5deg);
  }
  .tree-item-self .collapse-icon svg {
    transform: skewX(7.5deg);
  }
}

@mixin ascii-aria-icon($aria-label, $content) {
  [aria-label*="#{$aria-label}"] {
    width: 24px;
    &::after {
      content: "#{$content}";
      font-size: var(--font-ui-small);
      letter-spacing: -0.75px;
    }
    svg {
      opacity: 0;
    }
  }
}

body.flexcyon-ascii-icon-set:not(.flexcyon-ensure-plugin-icon),
body.flexcyon-ascii-icon-set.flexcyon-ensure-plugin-icon:not(
    [class*="iconic"]
  ) {
  .workspace
    .mod-root
    .workspace-tab-header
    .workspace-tab-header-inner-close-button {
    color: inherit;
    &::after {
      content: "x_x";
      font-size: var(--font-ui-small);
    }
    svg {
      opacity: 0;
    }
  }

  .modal-close-button {
    position: absolute;
    right: 2.5%;
    width: min-content;
    top: 16px;
    width: 24px;
    padding-right: 48px;
    &::before {
      opacity: 0;
    }
    &::after {
      content: "x_x";
      font-size: var(--font-ui-small);
    }
  }

  .search-input-container {
    &::before {
      opacity: 0;
    }
    &::after {
      margin: 0px 8px;
      content: "?/";
      position: absolute;
      left: 0;
      bottom: 6px;
      font-size: var(--font-ui-small);
    }
  }

  .omnisearch-result__icon {
    svg {
      opacity: 0;
    }
    &:has(.lucide-file)::before {
      content: "''";
      font-size: var(--font-ui-smaller);
      letter-spacing: -2px;
    }
    &:has(.lucide-file-text)::before {
      content: "``";
      font-size: var(--font-ui-smaller);
      letter-spacing: -2px;
    }
  }

  .modal.mod-settings .vertical-tab-content {
    padding-top: 48px;
  }

  .workspace-left-content[aria-label*="Back"] {
    width: 24px;
    &::after {
      content: "<";
      font-size: var(--font-ui-small);
      letter-spacing: -0.75px;
    }
    svg {
      opacity: 0;
    }
  }

  // Iconic related overrides
  .iconic-drag {
    width: 24px;
    &::after {
      content: "|||";
      font-size: var(--font-ui-small);
      letter-spacing: -0.75px;
    }
    svg {
      opacity: 0;
    }
  }
  .iconic-rule-icon {
    width: 24px;
    &::after {
      content: "./^";
      font-size: var(--font-ui-small);
      letter-spacing: -0.75px;
    }
    svg {
      opacity: 0;
    }
  }
  .iconic-add {
    width: 24px;
    &::after {
      content: "[~]";
      font-size: var(--font-ui-small);
      letter-spacing: -0.75px;
      transform: translateX(-24px);
      color: var(--color-green);
    }
    svg {
      opacity: 0;
    }
  }

  @include ascii-aria-icon("Uninstall", "*_*");
  @include ascii-aria-icon("Options", "[*]");
  @include ascii-aria-icon("Hotkeys", "[%]");
  @include ascii-aria-icon("Customise this command", "[~]");
  @include ascii-aria-icon("Customize this command", "[~]");
  @include ascii-aria-icon("Export settings", ".>");
  @include ascii-aria-icon("Donate", "<3");
  @include ascii-aria-icon("Reload", "[R]");
  @include ascii-aria-icon("Change sort order", "|'|");
  @include ascii-aria-icon("folder", "./^");
  @include ascii-aria-icon("Restore default", "[0]");
  @include ascii-aria-icon("Reset all settings to default", "[0]");
  @include ascii-aria-icon("New note", "[N]");
  @include ascii-aria-icon("Expand", "[+]");
  @include ascii-aria-icon("Collapse", "[-]");
  @include ascii-aria-icon("Auto-reveal current file", "[>]");
  @include ascii-aria-icon("Auto-scroll to current section", "[>]");
  @include ascii-aria-icon("Show search filter", "?/");
  @include ascii-aria-icon("Bookmark the active tab", "[B]");
  @include ascii-aria-icon("New bookmark group", "{+}");

  [aria-label*="New bookmark group"]::after,
  [aria-label*="Collapse"]::after,
  [aria-label*="Expand"]::after {
    letter-spacing: -2px;
  }
  .nav-buttons-container {
    gap: 6px;
  }

  .search-input-clear-button {
    &::before {
      content: "x_x";
    }
    &::after {
      opacity: 0;
    }
  }
}
