/* 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/. */

/*** Status and progress indicator ***/

#downloads-button {
%ifdef MOZ_PHOTON_THEME
  --downloads-indicator-image: url("chrome://browser/skin/downloads/download-icons.svg#arrow-with-bar");
%else
  --downloads-indicator-image: url("chrome://browser/skin/download.svg");
%endif
}

#downloads-indicator-anchor {
  min-width: 16px;
  min-height: 16px;
}

#downloads-indicator-progress-outer {
  width: 16px;
  height: 16px;
  background-size: 16px;
  -moz-context-properties: fill;
%ifdef MOZ_PHOTON_ANIMATIONS
  background: url("chrome://browser/skin/downloads/download-icons.svg#default-bar") center no-repeat;
%else
  background: var(--downloads-indicator-image) center no-repeat;
%endif
}

%ifdef MOZ_PHOTON_ANIMATIONS
#downloads-button[attention="success"] > #downloads-indicator-anchor > #downloads-indicator-icon,
%endif
#downloads-button[attention="success"] > #downloads-indicator-anchor > #downloads-indicator-progress-outer {
  fill: var(--toolbarbutton-icon-fill-attention);
}
%ifdef MOZ_PHOTON_ANIMATIONS
#downloads-button[progress] > #downloads-indicator-anchor > #downloads-indicator-progress-outer {
  background: url("chrome://browser/skin/downloads/download-icons.svg#progress-bar-bg") center no-repeat;
}
%endif

#downloads-button[attention="success"] {
  list-style-image: url("chrome://browser/skin/downloads/download-glow-menuPanel.png");
  -moz-image-region: auto;
}

%ifdef MOZ_PHOTON_ANIMATIONS
#downloads-indicator-icon {
  -moz-context-properties: fill;
  background-image: url("chrome://browser/skin/downloads/download-icons.svg#arrow");
  width: 16px;
  height: 16px;
}
%endif

#downloads-indicator-progress-inner {
%ifdef MOZ_PHOTON_ANIMATIONS
  background: url("chrome://browser/skin/downloads/download-icons.svg#progress-bar-fg") left no-repeat;
  margin-right: 16px;
%else
  background: var(--downloads-indicator-image) bottom no-repeat;
  margin-top: 16px;
%endif
  -moz-context-properties: fill;
  fill: var(--toolbarbutton-icon-fill-attention);
  background-size: 16px;
  /* From javascript side we use animation delay from 0s to -100s to show
   * corresponding frames needed for progress.
   * animation-delay is set to a positive value to make nothing shown.
   */
  animation-play-state: paused;
  animation-delay: 1s;
  animation-duration: 100s;
  animation-timing-function: linear;
  animation-name: indicatorArrowProgress;
}

%ifndef MOZ_PHOTON_ANIMATIONS
toolbar[brighttext] #downloads-indicator-progress-inner {
  animation-name: indicatorArrowProgressDark;
}
%endif

@keyframes indicatorArrowProgress {
  0% {
%ifdef MOZ_PHOTON_ANIMATIONS
    margin-right: 14px;
%else
    margin-top: 12px;
    filter: brightness(1.2);
%endif
  }
  100% {
%ifdef MOZ_PHOTON_ANIMATIONS
    margin-right: 2px;
%else
    margin-top: 2px;
    filter: brightness(1);
%endif
  }
}

%ifndef MOZ_PHOTON_ANIMATIONS
@keyframes indicatorArrowProgressDark {
  0% {
    margin-top: 12px;
    filter: brightness(0.7);
  }
  100% {
    margin-top: 2px;
    filter: brightness(1);
  }
}
%endif

/*** Status badges ***/

#downloads-button[attention="warning"] > .toolbarbutton-badge-stack > .toolbarbutton-badge,
#downloads-button[attention="severe"] > .toolbarbutton-badge-stack > .toolbarbutton-badge {
  display: -moz-box;
  height: 8px;
  width: 8px;
  min-width: 0;
  border-radius: 50%;
  /* "!important" is necessary to override the rule in toolbarbutton.css */
  margin-top: -1px !important;
  margin-right: -2px !important;
}

#downloads-button[cui-areatype="toolbar"] > .toolbarbutton-badge-stack > .toolbarbutton-badge {
  height: 7px;
  width: 7px;
}

#downloads-button[attention="severe"] > .toolbarbutton-badge-stack > .toolbarbutton-badge {
  background: #D90000;
}

#downloads-button[attention="warning"] > .toolbarbutton-badge-stack > .toolbarbutton-badge {
  background: #FFBF00;
}

#downloads-button[attention="severe"] > .toolbarbutton-badge-stack > .toolbarbutton-badge:-moz-window-inactive,
#downloads-button[attention="warning"] > .toolbarbutton-badge-stack > .toolbarbutton-badge:-moz-window-inactive {
  filter: none;
}

/*** Download notifications ***/

%ifdef MOZ_PHOTON_ANIMATIONS
#downloads-button[notification="start"] > #downloads-indicator-anchor > #downloads-indicator-icon
%else
#downloads-button[notification="start"] > #downloads-indicator-anchor > #downloads-indicator-progress-outer
%endif
{
  animation-name: downloadsIndicatorStartJump;
  /* Upon changing the overall duration below, please keep the delay time of
     setTimeout() identical in indicator.js for this animation. */
  animation-duration: 0.5s;
  animation-delay: 1s;
  animation-iteration-count: 2;
}

@keyframes downloadsIndicatorStartJump {
  0% {
    transform: translateY(0);
    animation-timing-function: ease-out;
  }
  50% {
    transform: translateY(-3px);
    animation-timing-function: ease-in;
  }
  100% {
    transform: translateY(0);
  }
}

#downloads-animation-container {
  min-height: 1px;
  min-width: 1px;
  height: 1px;
  margin-bottom: -1px;
  /* Makes the outermost animation container element positioned, so that its
     contents are rendered over the main browser window in the Z order.
     This is required by the animated event notification. */
  position: relative;
  /* The selected tab may overlap #downloads-indicator-notification */
  z-index: 5;
}

#downloads-indicator-notification {
  opacity: 0;
  background-size: 16px;
  background-position: center;
  background-repeat: no-repeat;
  width: 16px;
  height: 16px;
}

@keyframes downloadsIndicatorNotificationStartRight {
  from { opacity: 0; transform: translate(-128px, 128px) scale(8); }
  20%  { opacity: .85; animation-timing-function: ease-out; }
  to   { opacity: 0; transform: translate(0) scale(1); }
}

@keyframes downloadsIndicatorNotificationStartLeft {
  from { opacity: 0; transform: translate(128px, 128px) scale(8); }
  20%  { opacity: .85; animation-timing-function: ease-out; }
  to   { opacity: 0; transform: translate(0) scale(1); }
}

@keyframes downloadsIndicatorNotificationFinish {
  from { opacity: 0; transform: scale(1); }
  20%  { opacity: .65; animation-timing-function: ease-in; }
  to   { opacity: 0; transform: scale(8); }
}

#downloads-notification-anchor[notification="start"] > #downloads-indicator-notification {
  background-image: url("chrome://browser/skin/downloads/download-notification-start.png");
  animation-name: downloadsIndicatorNotificationStartRight;
  animation-duration: 1s;
}

#downloads-notification-anchor[notification="start"]:-moz-locale-dir(rtl) > #downloads-indicator-notification {
  animation-name: downloadsIndicatorNotificationStartLeft;
}

#downloads-notification-anchor[notification="finish"] > #downloads-indicator-notification {
  background-image: url("chrome://browser/skin/downloads/download-notification-finish.png");
  animation-name: downloadsIndicatorNotificationFinish;
  animation-duration: 1s;
}
