/* Edge-Frfox - personalbar.css
 * https://github.com/bmFtZQ/edge-frfox */

/*
  MARK: Variables
*/
:root {
  --bookmark-block-padding: 6px !important;
  --bookmark-inline-padding: 6px !important;
  --bookmark-block-margin: 2px !important;
  --bookmark-inline-margin: 2px !important;
  --uc-bookmark-toolbar-padding-bottom: 2px;
  --bookmarks-toolbar-overlapping-browser-height: calc(
    var(--uc-bookmark-toolbar-padding-bottom) + 16px +
      (var(--bookmark-block-margin) + var(--bookmark-block-padding)) * 2
  ) !important;
}

#PersonalToolbar {
  padding-bottom: var(--uc-bookmark-toolbar-padding-bottom) !important;
}

/*
  MARK: Bookmark items
*/
#personal-toolbar-empty-description,
#PersonalToolbar .toolbarbutton-1,
toolbarbutton.bookmark-item:not(.subviewbutton) {
  margin-block: var(--bookmark-block-margin) !important;
  margin-inline: var(--bookmark-inline-margin) !important;
  padding-block: var(--bookmark-block-padding) !important;
  padding-inline: var(--bookmark-inline-padding) !important;
  font-size: 12px !important;

  /* Adjust vertical label position on Windows */
  @media (-moz-platform: windows) {
    & .toolbarbutton-text {
      margin-block: -1px 0 !important;
    }
  }
}

#PersonalToolbar .toolbarbutton-1 {
  padding: 0 !important;
}

/* Spacing between icon and label for bookmarks bar items */
#managed-bookmarks > .toolbarbutton-icon,
#bookmarks-toolbar-placeholder > .toolbarbutton-icon,
#PlacesToolbarItems
  > .bookmark-item
  > .toolbarbutton-icon[label]:not([label=""]),
#OtherBookmarks.bookmark-item[container] > .toolbarbutton-icon {
  margin-inline-end: 8px !important;
}

/* Sizing for bookmarks bar icons */
#PersonalToolbar .toolbarbutton-1 > .toolbarbutton-icon {
  width: calc(2 * var(--bookmark-block-padding) + 16px) !important;
  height: calc(2 * var(--bookmark-block-padding) + 16px) !important;
  padding: var(--bookmark-block-padding) !important;
}

/*
  MARK: Separators
*/
#PlacesToolbarItems > toolbarseparator {
  padding-inline: calc(3px - var(--bookmark-inline-margin)) !important;
  align-items: center !important;

  &::before {
    content: "";
    border-inline-start: 1px solid var(--toolbarseparator-color) !important;
    height: 16px !important;
    border-image: none !important;
  }

  /* Fractional scaling adjustments (150%, 175%, etc.) */
  @media (1dppx < resolution < 2dppx) {
    &::before {
      border-inline-start-width: 1.5px !important;
    }
  }
}

/* Left and Right padding of bookmarks bar */
#PersonalToolbar {
  padding-inline: calc(var(--toolbar-start-end-padding) - 2px)
    calc(var(--toolbar-start-end-padding) + 4px) !important;
}

@include Option("userChromeJS.Sidra.PlacesToolbar.Align.Center") {
  #PlacesToolbarItems:has(+ #PlacesChevron[collapsed="true"]) {
    -moz-box-pack: center;
    justify-content: center;
  }
}
@include Option("userChromeJS.Sidra.PlacesToolbar.IconsOnly.Enabled") {
  #PersonalToolbar toolbarbutton.bookmark-item:not(.subviewbutton, [id]) {
    margin-inline: 2px !important;
    padding: 0 !important;
  }

  #PlacesToolbar toolbarbutton.bookmark-item[id] {
    padding-inline: var(--toolbarbutton-inner-padding) !important;
  }

  #PersonalToolbar
    toolbarbutton.bookmark-item:not(.subviewbutton, [id])
    .toolbarbutton-icon {
    margin: 0 !important;
    width: calc(2 * var(--toolbarbutton-inner-padding) + 16px) !important;
    height: calc(2 * var(--toolbarbutton-inner-padding) + 16px) !important;
    padding: var(--toolbarbutton-inner-padding) !important;
    border-radius: var(--toolbarbutton-border-radius) !important;
  }

  #PersonalToolbar
    toolbarbutton.bookmark-item:not(.subviewbutton, [id])
    .toolbarbutton-text {
    display: none !important;
  }

  /* display the background on the icon, not the button, similar to regular
toolbar widgets. allows us to use padding to space the buttons instead of
margins, so when we drag a bookmark between buttons, it doesn't get dropped
at the end of the bookmarks */
  :root:not([fluent-reveal-hover], [fluent-reveal-click])
    #PersonalToolbar
    toolbarbutton.bookmark-item:not(.subviewbutton, [id]) {
    background: none !important;
    margin-inline: 0 !important;
    padding: 0 2px !important;
  }

  :root:not([fluent-reveal-hover], [fluent-reveal-click])
    #PlacesToolbarDropIndicator {
    margin-inline-start: -18px !important;
  }

  :root:not([fluent-reveal-hover], [fluent-reveal-click])
    #PersonalToolbar
    toolbarbutton.bookmark-item:not(.subviewbutton, [id]):is(
      :hover,
      :-moz-drag-over,
      :focus-visible
    )
    .toolbarbutton-icon {
    background-color: var(--button-solid-hover-background) !important;
  }

  :root:not([fluent-reveal-hover], [fluent-reveal-click])
    #PersonalToolbar
    toolbarbutton.bookmark-item:not(.subviewbutton, [id]):hover:active
    .toolbarbutton-icon {
    background-color: var(--button-solid-active-background) !important;
  }
}

@include Option("userChromeJS.Sidra.PlacesToolbar.Compact.Minimum.Enabled") {
  :root {
    --bookmark-block-padding: 2px !important;
    --bookmark-inline-padding: 2px !important;
    --bookmark-block-margin: 1px !important;
    --bookmark-inline-margin: 1px !important;
    --uc-bookmark-toolbar-padding-bottom: 1px;
    --bookmarks-toolbar-overlapping-browser-height: calc(
      var(--uc-bookmark-toolbar-padding-bottom) + 16px +
        (var(--bookmark-block-margin) + var(--bookmark-block-padding)) * 2
    ) !important;
  }
}
