/* 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(#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 {
  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;
  border-radius: 2px;
  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],
.customizationmode-button[checked] {
  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="menu-panel"],
toolbarpaletteitem[place="toolbar"] {
  transition: border-width 250ms ease-in-out;
}

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

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][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 > #search-container,
toolbarpaletteitem > toolbaritem.toolbaritem-combined-buttons {
  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] > #search-container,
toolbarpaletteitem[mousedown] > toolbaritem.toolbaritem-combined-buttons {
  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;
}

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

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;
  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-uidensity-menuitem > .menu-iconic-text {
  font: menu;
}

#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
  max-width: 29em;
}

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

/* In customize mode, the overflow button should look both 'disabled' and 'open'.
 * So we make the button fully opaque but fill the icon semi-transparent. */
#nav-bar[customizing] > .overflow-button > .toolbarbutton-icon {
  background-color: var(--toolbarbutton-active-background);
  opacity: 1;
  fill-opacity: 0.4;
}

#customization-panelWrapper > .panel-arrowbox > .panel-arrow[side="top"] {
%ifdef XP_MACOSX
  /* 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;
%endif
  list-style-image: url("chrome://global/skin/arrow/panelarrow-vertical.svg");
  -moz-context-properties: fill, stroke;
  fill: var(--arrowpanel-background);
  stroke: var(--arrowpanel-border-color);
  /* 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;
}

#customization-panelDescription {
  font-size: 1.1em;
  padding: 2px 12px 10px;
  margin: 0;
}

#customization-panelHeader {
  font-size: 1.3em;
  font-weight: 500;
  padding: 2px 12px;
  margin: 0;
}

#customization-panelHolder > #widget-overflow-fixed-list {
  padding-top: 10px;
}

/**
 * We create a ::before pseudoelement that contains a background image to show the
 * drop dragon. This element fades in and out depending on whether the containing
 * panel list is empty and unhovered, or not.
 */
#customization-panelHolder > #widget-overflow-fixed-list:not(:empty) {
  padding-bottom: 50px; /* Make sure there's always space to drop stuff. */
  border-top: 1px solid rgba(0,0,0,0.1);
}

#customization-panelHolder > #widget-overflow-fixed-list::before {
  display: block;
  content: "";
  background-image: url("chrome://browser/skin/customizableui/empty-overflow-panel.png");
  background-position: center bottom 10px;
  background-size: 218px 134px;
  background-repeat: no-repeat;
  opacity: 0;
  transition: opacity 300ms ease-out;
  padding-bottom: 154px; /* 154 = 134 for the image, 10px space on either side. */
  margin-bottom: -154px; /* don't affect positioning of the actual contents */
  pointer-events: none;
}

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

#customization-panelHolder > #widget-overflow-fixed-list:empty::before {
  opacity: 1;
}
#customization-panelHolder > #widget-overflow-fixed-list[draggingover]:empty::before {
  opacity: 0;
}

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

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

#whimsy-button {
  /* Don't need HiDPI versions since the size used will be scaled down to 20x20. */
  list-style-image: url("chrome://browser/skin/customizableui/whimsy.png");
}

#whimsy-button > .button-box > .button-icon {
  width: 16px;
  height: 16px;
}

#customization-palette[whimsypong] {
  /* Keep the palette in the render tree but invisible
     so -moz-element() will work. */
  padding: 0;
  min-height: 0;
  max-height: 0;
}

#customization-palette[whimsypong] > toolbarpaletteitem > toolbarspring {
  margin: 0 -7px;
}

%ifdef XP_UNIX
%ifndef XP_MACOSX
#customization-palette[whimsypong] > toolbarpaletteitem > toolbarspring {
  font-size: 12px;
}
%endif
%endif

#wp-lives,
#wp-ball {
  /* Don't need HiDPI versions since the size used will be scaled down to 20x20. */
  background-image: url("chrome://browser/skin/customizableui/whimsy.png");
  background-size: contain;
  width: 20px;
}

#customization-pong-arena {
  width: 300px;
  height: 300px;
  border-left: 1px solid currentColor;
  border-right: 1px solid currentColor;
  margin: 16px auto 0;
  box-sizing: content-box;
}

#customization-palette[whimsypong] > toolbarpaletteitem[kcode],
#customization-pong-arena[kcode] {
  animation-name: kcode;
  animation-timing-function: steps(5);
  animation-duration: 1s;
  animation-iteration-count: infinite;
}

#wp-ball {
  margin-inline-start: -10px;
  margin-top: -10px;
  height: 20px;
}

#wp-player1,
#wp-player2 {
  width: 84px;
  height: calc(39px + 3em);
}

#wp-player1,
#wp-player2,
#wp-ball,
#wp-score {
  position: fixed;
}

#wp-score {
  transform: translateX(-4ch);
}

#wp-score:-moz-locale-dir(rtl) {
  transform: translateX(4ch);
}

#wp-lives {
  transform: translate(-4ch, 1ch);
}

#wp-lives:-moz-locale-dir(rtl) {
  transform: translate(4ch, 1ch);
}

#wp-lives[lives="5"] {
  height: 100px;
}

#wp-lives[lives="4"] {
  height: 80px;
}

#wp-lives[lives="3"] {
  height: 60px;
}

#wp-lives[lives="2"] {
  height: 40px;
}

#wp-lives[lives="1"] {
  height: 20px;
}

#customization-pong-arena[lives="0"] > #wp-ball {
  animation: game-over 4s forwards ease;
}

@keyframes game-over {
  0% {
    transform: scale(1) translateY(0) rotateZ(0);
    opacity: 1;
  }
  15% {
    transform: scale(2) translateY(-10px) rotateZ(-90deg);
  }
  35% {
    opacity: 1;
  }
  65% {
    opacity: 0;
  }
  100% {
    transform: scale(2) translateY(300px) rotateZ(-2.5turn);
    opacity: 0;
  }
}

@keyframes kcode {
  0% { border-color: rgb(195,17,206); color: rgb(195,17,206); }
  20% { border-color: rgb(252,82,27); color: rgb(252,82,27); }
  40% { border-color: rgb(251,179,0); color: rgb(251,179,0); }
  60% { border-color: rgb(105,211,0); color: rgb(105,211,0); }
  80% { border-color: rgb(20,155,249); color: rgb(20,155,249); }
  100% { border-color: rgb(195,17,206); color: rgb(195,17,206); }
}
