/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

/* Customization mode */

:root {
  --drag-drop-transition-duration: .3s;
}

#main-window[customizing] .customization-target:not(#PanelUI-contents):not(#widget-overflow-fixed-list) {
  min-width: 100px;
}

#customization-container {
  background-color: var(--toolbar-non-lwt-bgcolor);
  background-image: var(--toolbar-non-lwt-bgimage);
  color: var(--toolbar-non-lwt-textcolor);
  text-shadow: none;
}

#customization-container:-moz-lwtheme {
  background-color: transparent;
  background-image: linear-gradient(var(--toolbar-bgcolor), var(--toolbar-non-lwt-bgcolor) 45px);
}

#customization-palette,
#customization-empty {
  padding: 5px 20px 20px;
}

#customization-header {
  font-weight: 500;
  font-size: 1.2em;
  margin: 20px 20px 15px;
}

#customization-header:-moz-lwtheme {
  text-shadow: 0 0 1em var(--toolbar-non-lwt-bgcolor),
               0 0 1em var(--toolbar-non-lwt-bgcolor),
               0 0 .5em var(--toolbar-non-lwt-bgcolor);
}

#customization-panel-container {
  padding: 0 20px 25px;
}

#customization-footer {
  border-top: 1px solid rgba(0,0,0,.15);
  padding: 10px;
}

%if defined(XP_MACOSX) || defined(XP_WIN)
%ifdef XP_WIN
@media (-moz-windows-default-theme) {
%endif

.customizationmode-button {
  border: 1px solid #b1b1b1;
  background-color: #fcfcfd;
  -moz-appearance: none;
}

.customizationmode-checkbox,
.customizationmode-button {
  margin: 6px 10px;
  padding: 2px 5px;
}

.customizationmode-checkbox:not(:-moz-lwtheme),
.customizationmode-button {
  color: rgb(71, 71, 71);
}

#customization-reset-button,
#customization-undo-reset-button,
#customization-done-button {
  min-width: 10em;
}

#customization-done-button {
  color: #fff;
  font-weight: 700;
  border-color: #0060df;
  background-color: #0a84ff;
}

.customizationmode-button > .box-inherit {
  border-width: 0;
  padding: 3px 0;
  padding-inline-start: 0;
  padding-inline-end: 0;
}

/* We use a smaller padding to ensure images don't have padding.
 * We can't detect whether a button has an image. This button doesn't
 * so it needs more padding, so we unfortunately hardcode the extra
 * padding in here:
 */
#customization-toolbar-visibility-button {
  padding-inline-start: 8px;
}

.customizationmode-button[type=menu] > .box-inherit > .box-inherit > .button-text {
  padding-inline-end: 10px;
}

.customizationmode-button > .button-icon {
  margin-inline-start: 0;
}

.customizationmode-button:not([type=menu]) > .button-text {
  margin-inline-end: 0;
}

.customizationmode-button > .box-inherit > .button-menu-dropmarker {
  margin-inline-end: 0;
  padding-inline-end: 0;
  list-style-image: url(chrome://global/skin/icons/arrow-dropdown-16.svg);
}

.customizationmode-button:-moz-any(:focus,:active,:hover):not([disabled]),
.customizationmode-button[open] {
  background-color: #e1e1e5;
}

#customization-done-button:-moz-any(:focus,:active,:hover):not([disabled]) {
  background-color: #0060df;
}

.customizationmode-button[disabled="true"] {
  opacity: .5;
}

%ifdef XP_WIN
} /* @media (-moz-windows-default-theme) */
%endif
%endif /* defined(XP_MACOSX) || defined(XP_WIN) */

.customizationmode-button > .box-inherit > .box-inherit > .button-icon,
.customizationmode-button > .button-box > .button-icon {
  height: 16px;
}

#customization-uidensity-button > .box-inherit > .box-inherit > .button-text,
#customization-lwtheme-button > .box-inherit > .box-inherit > .button-text {
  /* Sadly, button.css thinks its margins are perfect for everyone. */
  margin-inline-start: 6px !important;
}

#customization-uidensity-button > .box-inherit > .box-inherit > .button-icon,
#customization-lwtheme-button > .box-inherit > .box-inherit > .button-icon {
  width: 16px;
  height: 16px;
  border-radius: 2px;
  background-size: contain;
}

#customization-lwtheme-button > .box-inherit > .box-inherit > .button-icon {
  background-image: url("chrome://browser/content/default-theme-icon.svg");
}

#customization-uidensity-button > .box-inherit > .box-inherit > .button-icon {
  background-image: url("chrome://browser/skin/customizableui/density-normal.svg");
}

#widget-overflow-fixed-list > toolbarpaletteitem[place="panel"],
toolbarpaletteitem[place="toolbar"] {
  transition: border-width 250ms ease-in-out;
}

toolbarpaletteitem[mousedown] {
  cursor: -moz-grabbing;
}

.panel-customization-placeholder,
toolbarpaletteitem[place="palette"],
toolbarpaletteitem[place="panel"] {
  transition: transform var(--drag-drop-transition-duration) ease-in-out;
}

#customization-palette {
  transition: opacity .3s ease-in-out;
  opacity: 0;
}

#customization-palette[showing="true"] {
  opacity: 1;
}

toolbarpaletteitem toolbarbutton[disabled] {
  color: inherit !important;
}

#widget-overflow-fixed-list > toolbarpaletteitem[notransition][place="panel"],
toolbarpaletteitem[notransition].panel-customization-placeholder,
toolbarpaletteitem[notransition][place="toolbar"],
toolbarpaletteitem[notransition][place="palette"],
toolbarpaletteitem[notransition][place="panel"] {
  transition: none;
}

toolbarpaletteitem > toolbarbutton > .toolbarbutton-icon,
toolbarpaletteitem > toolbarbutton > .toolbarbutton-badge-stack > .toolbarbutton-icon,
toolbarpaletteitem > toolbaritem.panel-wide-item,
toolbarpaletteitem > toolbarbutton[type="menu-button"] {
  transition: transform var(--drag-drop-transition-duration) cubic-bezier(.6, 2, .75, 1.5) !important;
}

toolbarpaletteitem[mousedown] > toolbarbutton > .toolbarbutton-icon,
toolbarpaletteitem[mousedown] > toolbarbutton > .toolbarbutton-badge-stack > .toolbarbutton-icon {
  transform: scale(1.3);
}

toolbarpaletteitem[mousedown] > toolbaritem.panel-wide-item,
toolbarpaletteitem[mousedown] > toolbarbutton[type="menu-button"] {
  transform: scale(1.1);
}

/* Override the toolkit styling for items being dragged over. */
toolbarpaletteitem[place="toolbar"] {
  border-left-width: 0;
  border-right-width: 0;
  margin-right: 0;
  margin-left: 0;
}
#widget-overflow-fixed-list > toolbarpaletteitem[place="panel"] {
  border-top: 0px solid transparent;
  border-bottom: 0px solid transparent;
}

#customization-palette:not([hidden]) {
  margin-bottom: 20px;
}

#customization-palette .toolbarbutton-1 {
  fill: currentColor;
}

toolbarpaletteitem[place="palette"]:-moz-focusring,
toolbarpaletteitem[place="panel"]:-moz-focusring,
toolbarpaletteitem[place="toolbar"]:-moz-focusring {
  outline-width: 0;
}

toolbarpaletteitem[place="palette"]:not([mousedown="true"]):-moz-focusring,
toolbarpaletteitem[place="panel"]:not([mousedown="true"]):-moz-focusring,
toolbarpaletteitem[place="toolbar"]:not([mousedown="true"]):-moz-focusring {
  /* Delay adding the focusring back until after the transform transition completes. */
  transition: outline-width .01s linear var(--drag-drop-transition-duration);
  outline: 1px dotted;
  -moz-outline-radius: 2.5px;
}

toolbarpaletteitem[place="toolbar"]:not([mousedown="true"]):-moz-focusring {
  outline-offset: -5px;
}

toolbarpaletteitem[place=palette] > toolbarspring {
  width: 7em;
  min-width: 7em;
  outline: 1px solid;
  outline-offset: -8px;
  opacity: .6;
  height: 37px;
}

toolbarpaletteitem[place=toolbar] > toolbarspring {
  outline: 1px solid;
  outline-offset: -2px;
  opacity: .6;
  margin-top: 5px;
  margin-bottom: 5px;
}

#wrapper-edit-controls > #edit-controls > toolbarbutton > .toolbarbutton-icon {
  opacity: 1; /* To ensure these buttons always look enabled in customize mode */
}

#wrapper-zoom-controls[place="palette"] > #zoom-controls > #zoom-reset-button,
#wrapper-zoom-controls[place="palette"] > #zoom-controls > #zoom-reset-button + separator {
  display: none;
}

#customization-palette > toolbarpaletteitem > label {
  text-align: center;
  margin-left: 0;
  margin-right: 0;
}

#customization-uidensity-touch-spacer {
  border-top: 1px solid ThreeDLightShadow;
  margin: 0 -10px 10px;
}

#customization-uidensity-autotouchmode-checkbox {
  margin-bottom: 10px;
}

#customization-uidensity-menu > .panel-arrowcontainer > .panel-arrowcontent,
#customization-lwtheme-menu > .panel-arrowcontainer > .panel-arrowcontent {
  -moz-box-orient: vertical;
  font: menu;
}

#customization-lwtheme-menu > .panel-arrowcontainer > .panel-arrowcontent {
  /* Make the panel padding uniform across all platforms due to the
     styling of the section headers and footer. */
  padding: 10px;
}

#customization-uidensity-menu > .panel-arrowcontainer > .panel-arrowcontent {
  padding: 5px 10px;
}

.customization-uidensity-menuitem > .menu-iconic-left > .menu-iconic-icon,
.customization-lwtheme-menu-theme > .toolbarbutton-icon {
  width: 32px;
  height: 32px;
  margin: 5px;
}

.customization-uidensity-menuitem,
.customization-lwtheme-menu-theme {
  -moz-appearance: none;
  border: 1px solid transparent;
  margin: 0 -5px 5px;
  padding-top: 0;
  padding-inline-end: 5px;
  padding-bottom: 0;
  padding-inline-start: 0;
}

.customization-uidensity-menuitem {
  color: inherit;
}

.customization-lwtheme-menu-theme[defaulttheme] {
  list-style-image: url(chrome://browser/content/default-theme-icon.svg);
}

#customization-uidensity-menuitem-normal {
  list-style-image: url("chrome://browser/skin/customizableui/density-normal.svg");
}

#customization-uidensity-menuitem-compact {
  list-style-image: url("chrome://browser/skin/customizableui/density-compact.svg");
}

#customization-uidensity-menuitem-touch {
  list-style-image: url("chrome://browser/skin/customizableui/density-touch.svg");
}

.customization-uidensity-menuitem[active="true"],
.customization-uidensity-menuitem:hover,
.customization-lwtheme-menu-theme[active="true"],
.customization-lwtheme-menu-theme:hover {
  background-color: var(--arrowpanel-dimmed);
  border-color: var(--panel-separator-color);
}

.customization-uidensity-menuitem[active="true"],
.customization-uidensity-menuitem:hover:active,
.customization-lwtheme-menu-theme[active="true"],
.customization-lwtheme-menu-theme:hover:active {
  background-color: var(--arrowpanel-dimmed-further);
}

.customization-uidensity-menuitem > .menu-iconic-text,
.customization-lwtheme-menu-theme > .toolbarbutton-text {
  text-align: start;
}

#customization-lwtheme-menu-header,
#customization-lwtheme-menu-recommended {
  padding: 10px;
  margin-bottom: 5px;
  text-align: center;
  font-weight: 500;
  border-bottom: 1px solid var(--panel-separator-color);
}

#customization-lwtheme-menu-header,
#customization-lwtheme-menu-recommended,
#customization-lwtheme-menu-footer {
  margin-right: -10px;
  margin-left: -10px;
}

#customization-lwtheme-menu-header {
  margin-top: -10px;
}

#customization-lwtheme-menu-recommended {
  border-top: 1px solid var(--panel-separator-color);
}

#customization-lwtheme-menu-footer {
  background: linear-gradient(var(--arrowpanel-dimmed) 60%, transparent) border-box;
  border-top: 1px solid var(--arrowpanel-dimmed);
  margin-bottom: -10px;
}

.customization-lwtheme-menu-footeritem {
  -moz-appearance: none;
  -moz-box-flex: 1;
  color: inherit;
  border-style: none;
  padding: 10px;
  margin-left: 0;
  margin-right: 0;
}

.customization-lwtheme-menu-footeritem:hover {
  background: linear-gradient(var(--arrowpanel-dimmed) 40%, transparent) padding-box;
}

.customization-lwtheme-menu-footeritem:first-child {
  border-inline-end: 1px solid var(--panel-separator-color);
}

#customization-panelWrapper > .panel-arrowcontent {
  color: var(--arrowpanel-color);
  background: var(--arrowpanel-background);
  background-clip: padding-box;
%ifdef XP_MACOSX
  /* Native styling adds more 'oompf' to the popup box-shadow, so simulate that
   * as best as we can here: */
  border: 1px solid var(--arrowpanel-dimmed-even-further);
  box-shadow: 0 4px 10px hsla(0,0%,0%,.3);
  -moz-appearance: none;
  border-radius: var(--arrowpanel-border-radius);
%else
  border: 1px solid var(--arrowpanel-border-color);
  box-shadow: 0 0 4px hsla(0,0%,0%,.2);
%endif
}

#customization-panelWrapper > .panel-arrowbox {
  position: relative;
  height: 10px;
  margin-bottom: -1px;
}

/* The overflow button icon _looks_ disabled, but is also shown as [open]. */
#nav-bar[customizing] > .overflow-button {
  /* This color is the hard-coded #4c4c4c at 40% opacity as found in toolbarbutton-icons.inc.css */
  fill: hsla(0,0%,30%,.4);
}

#nav-bar[customizing] > .overflow-button > .toolbarbutton-icon {
  background-color: var(--toolbarbutton-active-background);
  opacity: 1;
}

#customization-panelWrapper > .panel-arrowbox > .panel-arrow[side="top"] {
%ifdef XP_MACOSX
  list-style-image: var(--panel-arrow-image-vertical,
                        url("chrome://global/skin/arrow/panelarrow-vertical.png"));
  /* The OS X image is 2px narrower than the windows/linux one.
   * Add padding to compensate: */
  padding: 0 1px;
  /* specify width for hidpi image to fit correctly */
  width: 20px;
%else
  list-style-image: var(--panel-arrow-image-vertical,
                        url("chrome://global/skin/arrow/panelarrow-vertical-themed.svg"));
%endif
  /* The arrow needs to point to the overflow button. The numbers involved
   * are:
   * overflow button width: (16px + 2 * 2px padding
   * + 2 * toolbarbutton-inner-padding)
   * hamburger button width: (16px + 2 * 5px padding
   * + 2 * toolbarbutton-inner-padding)
   * hamburger button border + margin: 1px + 2px
   * The total desired offset from the right edge of the window is thus:
   * 10px + 1 * toolbarbutton-inner-padding (center of overflow button) +
   * 29px + 2 * toolbarbutton-inner-padding
   * The #customization-panel-container has a 20px margin, so that leaves:
   * 19px + 3 * toolbarbutton-inner-padding
   * Finally, we need to center the arrow, which is 20px wide, so subtract
   * 10px.
   */
  margin-inline-end: calc(9px + 3 * var(--toolbarbutton-inner-padding));
  vertical-align: top;
}

%ifdef XP_MACOSX
@media (min-resolution: 2dppx) {
  #customization-panelWrapper > .panel-arrowbox > .panel-arrow[side="top"] {
    list-style-image: var(--panel-arrow-image-vertical,
                          url("chrome://global/skin/arrow/panelarrow-vertical@2x.png"));
  }
}
%endif

#customization-panelHolder > #widget-overflow-fixed-list:not(:empty) {
  padding-bottom: 50px; /* Make sure there's always space to drop stuff. */
}

#customization-panelHolder > #widget-overflow-fixed-list:empty {
  background-image: url("chrome://browser/skin/customizableui/empty-overflow-panel.png");
  background-position: center top 10px;
  background-size: 218px 134px;
  background-repeat: no-repeat;
}

#customization-panelHolder > #widget-overflow-fixed-list:empty::after {
  content: attr(emptylabel);
  padding: 154px 10px 10px; /* 154 = 134 for the image, 10px space on either side. */
  text-align: center;
  display: block;
}

@media (min-resolution: 1.1dppx) {
  #customization-panelHolder > #widget-overflow-fixed-list:empty {
    background-image: url("chrome://browser/skin/customizableui/empty-overflow-panel@2x.png");
  }
}

#downloads-button-autohide-panel > .panel-arrowcontainer > .panel-arrowcontent {
  padding: 5px 12px;
}

#downloads-button-autohide-checkbox {
  margin: 0;
  padding: 0;
}
