/* Fix unreadable Github logo */
.bookmark-item[image^="page-icon:https://github.com/"] > .toolbarbutton-icon
{
  padding: 0 0 16px 16px !important;
  background-image: url("data:image/svg+xml;base64,[encoded data, 4328 characters]") !important;
  background-size: cover !important;
}

/* Center the bookmarks toolbar */
@media (-moz-bool-pref: "uc.bookmarks.center-toolbar") {
  #PlacesToolbarItems {
    justify-content: center;
  }
}

/* Positioning bookmarks toolbar direction */
:root:has(
    #theme-Bookmark-Toolbar-Tweaks[uc-bookmarks-position-toolbar="left"]
  ) {
  #PlacesToolbarItems {
    direction: ltr;
  }
}

:root:has(
    #theme-Bookmark-Toolbar-Tweaks[uc-bookmarks-position-toolbar="right"]
  ) {
  #PlacesToolbarItems {
    direction: rtl;
  }
}

/* Hide folder icons in the bookmarks toolbar */
@media (-moz-bool-pref: "uc.bookmarks.hide-folder-icons") {
  .bookmark-item[container="true"] .toolbarbutton-icon {
    display: none;
  }
}

/* Hide favicons in the bookmarks toolbar */
@media (-moz-bool-pref: "uc.bookmarks.hide-favicons") {
  .bookmark-item:not([container]) .toolbarbutton-icon {
    display: none;
  }
}

/* Hide bookmark labels */
@media (-moz-bool-pref: "uc.bookmarks.hide-name") {
  #personal-bookmarks .bookmark-item:not([container]) .toolbarbutton-text {
    display: none !important;
  }
}

@media (not (-moz-bool-pref: "uc.bookmarks.transparent")) {
  #PersonalToolbar:not([customizing]) {
    background-color: var(--zen-colors-tertiary) !important;
  }
}

@media (-moz-bool-pref: "uc.bookmarks.transparent") {
  #personal-bookmarks toolbarbutton.bookmark-item {
    background-color: var(--zen-colors-tertiary) !important;
  }

  #personal-bookmarks
    #PlacesToolbarItems
    > toolbarbutton.bookmark-item:not(
      .subviewbutton,
      [disabled="true"],
      [open]
    ):hover {
    filter: brightness(1.5);
  }

  #personal-bookmarks
    #PlacesToolbarItems
    > toolbarbutton.bookmark-item:not(
      .subviewbutton,
      [disabled="true"]
    ):hover:active {
    filter: brightness(3);
  }

  #personal-bookmarks
    #PlacesToolbarItems
    > toolbarbutton.bookmark-item[open="true"] {
    filter: brightness(3);
  }
}

@media (-moz-bool-pref: "uc.bookmarks.expand-on-search") or (-moz-bool-pref: "uc.bookmarks.expand-on-hover") {
  #PersonalToolbar[collapsed="false"]:not([customizing]) {
    position: relative;
    margin-bottom: calc(0px - var(--urlbar-min-height));
    transform: rotateX(90deg) !important;
    transform-origin: top;
    transition: transform 135ms linear !important;
    z-index: 1;
  }
}

/* Expand the bookmarks toolbar by hovering */
@media (-moz-bool-pref: "uc.bookmarks.expand-on-hover") {
  #zen-appcontent-navbar-container:hover {
    #PersonalToolbar {
      transform: rotateX(0deg) !important;
    }
  }
}

/* Expand the bookmarks toolbar when you search */
@media (-moz-bool-pref: "uc.bookmarks.expand-on-search") {
  #nav-bar:focus-within + #PersonalToolbar {
    transform: rotateX(0deg) !important;
  }
}
