/* 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;
}

%ifndef MOZ_PHOTON_THEME
#main-window[customization-lwtheme] #tab-view-deck:-moz-lwtheme {
  background-repeat: no-repeat;
  background-position: right top;
  background-attachment: fixed;
  background-color: transparent;
  background-image: -moz-image-rect(var(--lwt-header-image), 0, 100%,
                      var(--toolbox-rect-height), 0),
                    linear-gradient(to bottom,
                      var(--lwt-accent-color) calc(var(--toolbox-rect-height-with-unit) - 1px),
                      rgba(0,0,0,0.25) calc(var(--toolbox-rect-height-with-unit) - 1px),
                      rgba(0,0,0,0.25) calc(var(--toolbox-rect-height-with-unit) + 1px),
                      rgba(255,255,255,0.5) calc(var(--toolbox-rect-height-with-unit) + 1px),
                      rgba(255,255,255,0.5) calc(var(--toolbox-rect-height-with-unit) + 2px),
                      transparent calc(var(--toolbox-rect-height-with-unit) + 2px));
}

#main-window:-moz-any([customize-entering],[customize-entered]) #browser-bottombox {
  margin-bottom: 2em;
}

#main-window:-moz-any([customize-entering],[customize-entered]) #content-deck,
#main-window:-moz-any([customize-entering],[customize-entered]) #browser-bottombox,
#main-window:-moz-any([customize-entering],[customize-entered]) #navigator-toolbox {
  margin-left: 2em;
  margin-right: 2em;
}

#main-window:-moz-any([customize-entering],[customize-exiting]) #tab-view-deck {
  pointer-events: none;
}

#main-window[customize-entered] .customization-target:not(:-moz-any(#PanelUI-contents, #TabsToolbar, #toolbar-menubar))::before,
#PanelUI-contents > .panel-customization-placeholder {
  -moz-outline-radius: 2.5px;
  outline: 1px dashed transparent;
}

#main-window[customize-entered] .customization-target:not(:-moz-any(#PanelUI-contents, #TabsToolbar, #toolbar-menubar))::before {
  /* Prevent jumping of tabs when switching a window between inactive and active (bug 853415). */
  -moz-box-ordinal-group: 0;
  content: "";
  display: -moz-box;
  height: 100%;
  left: 0;
  outline-offset: -2px;
  pointer-events: none;
  position: absolute;
  top: 0;
  width: 100%;
}

/* Shift the TabsToolbar outline up 2px since the #nav-bar is shifted up by 1px and the
   #TabsToolbar::after is a pixel higher to draw the bottom border of the tabstrip so this makes the
   offset from the bottom effectively the same as other targets (-2px). */
#main-window[customize-entered] #TabsToolbar.customization-target::before {
  top: -2px;
}

/* The parents of the outline pseudo-elements need to be positioned so that the outline is positioned relative to it. */
#main-window[customize-entered] .customization-target:not(:-moz-any(#PanelUI-contents, #TabsToolbar, #toolbar-menubar)):hover,
#main-window[customize-entered] .customization-target[customizing-dragovertarget]:not(:-moz-any(#PanelUI-contents, #TabsToolbar, #toolbar-menubar)),
#main-window[customize-entered] #nav-bar-customization-target.customization-target {
  position: relative;
}

/* Most target outlines are shown on hover and drag over but the panel menu uses
   placeholders instead. */
#main-window[customize-entered] .customization-target:not(:-moz-any(#PanelUI-contents, #TabsToolbar, #toolbar-menubar)):hover::before,
#main-window[customize-entered] .customization-target[customizing-dragovertarget]:not(:-moz-any(#PanelUI-contents, #TabsToolbar, #toolbar-menubar))::before,
/* nav-bar and panel outlines are always shown */
#nav-bar[showoutline=true] > #nav-bar-customization-target.customization-target::before {
  outline-color: currentColor;
}

#nav-bar[showoutline=true] > #nav-bar-customization-target.customization-target::before {
  transition: outline-color 250ms linear;
}

#PanelUI-contents[showoutline=true] > .panel-customization-placeholder {
  transition: outline-color 250ms linear;
  outline-color: var(--panel-separator-color);
}

#PanelUI-contents > .panel-customization-placeholder {
  cursor: auto;
  outline-offset: -5px;
}
%endif

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

#customization-container {
%ifdef MOZ_PHOTON_THEME
  background-color: var(--toolbar-background-color);
  color: var(--toolbar-foreground-color);
%else
  background-color: -moz-field;
  color: -moz-fieldText;
%endif
  text-shadow: none;
}

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

#customization-header {
%ifndef MOZ_PHOTON_THEME
  border-bottom: 1px solid ThreeDLightShadow;
  font-size: 1.75em;
  line-height: 1.75em;
  color: GrayText;
  font-weight: 200;
  padding-bottom: 12px;
%else
  font-weight: 600;
  font-size: 1.2em;
%endif
  margin: 20px 20px 15px;
}

#customization-panel-container {
%ifndef MOZ_PHOTON_THEME
  padding: 15px 25px 25px;
  background-image: linear-gradient(to bottom, #3e86ce, #3878ba);
%else
  padding: 0 20px 25px;
%endif
}

%ifndef MOZ_PHOTON_THEME
#main-window:-moz-any([customize-entering],[customize-entered]) #browser-bottombox,
#customization-footer {
  background-color: -moz-dialog;
}
%endif

#customization-footer {
  border-top: 2px solid ThreeDLightShadow;
  padding: 10px;
}

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

.customizationmode-button {
  border: 1px solid #b1b1b1;
  margin: 6px 10px;
  padding: 2px 5px;
  background-color: #fcfcfd;
  color: rgb(71,71,71);
  -moz-appearance: none;
}

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

#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://browser/skin/arrow-dropdown.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");
}

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

%ifndef MOZ_PHOTON_THEME
#main-window[customize-entered] #customization-panel-container {
  background-image: url("chrome://browser/skin/customizableui/customizeMode-separatorHorizontal.png"),
                    url("chrome://browser/skin/customizableui/customizeMode-separatorVertical.png"),
                    url("chrome://browser/skin/customizableui/customizeMode-gridTexture.png"),
                    url("chrome://browser/skin/customizableui/background-noise-toolbar.png"),
                    linear-gradient(to bottom, #3e86ce, #3878ba);
  background-position: center top, left center, left top, left top, left top;
  background-repeat: no-repeat, no-repeat, repeat, repeat, no-repeat;
  background-size: auto 12px, 12px 100%, auto, auto, auto;
  background-attachment: scroll, scroll, fixed, fixed, scroll;
}
%endif

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

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

.panel-customization-placeholder,
toolbarpaletteitem[place="palette"],
toolbarpaletteitem[place="menu-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="menu-panel"],
toolbarpaletteitem[notransition].panel-customization-placeholder,
toolbarpaletteitem[notransition][place="toolbar"],
toolbarpaletteitem[notransition][place="palette"],
toolbarpaletteitem[notransition][place="menu-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="menu-panel"] {
  border-top: 0px solid transparent;
  border-bottom: 0px solid transparent;
}

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

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

toolbarpaletteitem[place="palette"]:not([mousedown="true"]):-moz-focusring,
toolbarpaletteitem[place="menu-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 GrayText;
  outline-offset: -8px;
  height: 37px;
}

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

:root:not([photon-structure]) #wrapper-edit-controls[place="palette"] > #edit-controls > toolbarbutton,
:root:not([photon-structure]) #wrapper-edit-controls[place="palette"] > #edit-controls > separator,
:root:not([photon-structure]) #wrapper-zoom-controls[place="palette"] > #zoom-controls > toolbarbutton,
:root:not([photon-structure]) #wrapper-zoom-controls[place="palette"] > #zoom-controls > separator {
  margin-top: 20px;
}

:root:not([photon-structure]) #wrapper-edit-controls[place="palette"] > #edit-controls > toolbarbutton,
:root:not([photon-structure]) #wrapper-zoom-controls[place="palette"] > #zoom-controls > toolbarbutton {
  margin-left: 0;
  margin-right: 0;
  max-width: 24px;
  min-width: 24px;
  max-height: 24px;
  min-height: 24px;
  padding: 4px;
}

:root:not([photon-structure]) #wrapper-edit-controls[place="palette"] > #edit-controls > toolbarbutton > .toolbarbutton-icon,
:root:not([photon-structure]) #wrapper-zoom-controls[place="palette"] > #zoom-controls > toolbarbutton > .toolbarbutton-icon {
  width: 16px;
}

#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;
}

:root:not([photon-structure]) #wrapper-personal-bookmarks:not([place="toolbar"]) > #personal-bookmarks {
  -moz-box-pack: center;
  min-height: 48px;
}

#personal-bookmarks[cui-areatype="toolbar"]:not([overflowedItem=true]) > #bookmarks-toolbar-placeholder > .toolbarbutton-icon {
  margin-inline-end: 5px;
}

#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;
}

#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);
}

%ifdef MOZ_PHOTON_THEME
#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");
}
%endif

.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;
}

#customization-lwtheme-menu-header,
#customization-lwtheme-menu-recommended,
#customization-lwtheme-menu-footer {
  background-color: var(--arrowpanel-dimmed);
  margin-right: -10px;
  margin-left: -10px;
}

#customization-lwtheme-menu-header {
  margin-top: -10px;
  border-bottom: 1px solid var(--arrowpanel-dimmed);
}

#customization-lwtheme-menu-recommended {
  border-top: 1px solid var(--arrowpanel-dimmed);
  border-bottom: 1px solid var(--arrowpanel-dimmed);
}

#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;
  border: 1px solid var(--arrowpanel-border-color);
  box-shadow: 0 0 10px hsla(0,0%,0%,.2);
%ifdef XP_MACOSX
  -moz-appearance: none;
  border-radius: var(--arrowpanel-border-radius);
%endif
}

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

#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 + toolbarbutton-inner-padding (center of overflow button) +
   * 29px + 2 * toolbarbutton-inner-padding
   * The #customization-panel-container has a 25px margin, so that leaves:
   * 14px + 3 * toolbarbutton-inner-padding
   * Finally, we need to center the arrow, which is 20px wide, so subtract
   * 10px.
   */
  margin-inline-end: calc(4px + 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

/* Non-photon adjustments. Remove when we stop supporting non-photon. */
#customization-container:not([photon]) #customization-panelWrapper > .panel-arrowbox {
  margin-bottom: -1px;
}

#customization-container:not([photon]) #customization-panelWrapper > .panel-arrowbox > .panel-arrow[side="top"] {
  margin-inline-end: 0;
  margin-inline-start: 22.35em;
}

%ifdef MOZ_PHOTON_THEME
#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");
  }
}

%else
%include customizeTip.inc.css
%endif
