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

@import url("chrome://global/content/elements/moz-message-bar.tokens.css");

:host {
  --message-bar-icon-close-url: url("chrome://global/skin/icons/close.svg");

  background-color: var(--message-bar-background-color);
  border: var(--message-bar-border-width) solid var(--message-bar-border-color);
  border-radius: var(--message-bar-border-radius);
  color: var(--message-bar-text-color);
  text-align: start;
}

/* Make the host to behave as a block by default, but allow hidden to hide it. */
:host(:not([hidden])) {
  display: block;
}

/* MozMessageBar layout */

.container {
  display: flex;
  gap: var(--message-bar-container-gap);
  min-height: var(--message-bar-container-min-height);
  padding-inline: var(--message-bar-container-padding-inline);
  padding-block: var(--message-bar-container-padding-block);
}

.content {
  display: flex;
  flex-grow: 1;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--message-bar-content-gap);
}

.text-container {
  display: flex;
  gap: var(--message-bar-text-container-gap);
  padding-block: var(--message-bar-text-container-padding-block);
}

.text-content {
  display: inline-flex;
  gap: var(--message-bar-text-content-gap);
  flex-wrap: wrap;
  word-break: break-word;
  padding-block: var(--message-bar-icon-container-padding);
}

/* MozMessageBar icon style */

.icon-container {
  height: var(--message-bar-icon-container-height);
  display: flex;
  justify-content: center;
  align-items: center;
  border: var(--message-bar-icon-container-border);
  border-radius: var(--message-bar-icon-container-border-radius);
  background-color: var(--message-bar-icon-background-color);
  padding: calc(var(--message-bar-icon-container-padding));
  margin-block-start: var(--message-bar-icon-container-margin-block-start);
}

.icon {
  width: var(--message-bar-icon-size);
  height: var(--message-bar-icon-size);
  flex-shrink: 0;
  appearance: none;
  -moz-context-properties: fill, stroke;
  fill: currentColor;
  stroke: currentColor;
  color: var(--message-bar-icon-color);
}

/* MozMessageBar heading style */

.heading {
  font-weight: var(--font-weight-heading);
}

/* MozMessageBar message style */

.message.has-link-after {
  margin-inline-end: var(--message-bar-message-margin-inline-end);
}

/* MozMessageBar link style */

.link {
  display: inline-block;
}

.link ::slotted(a) {
  margin-inline-end: var(--message-bar-message-margin-inline-end);
}

/* MozMessageBar actions style */

.actions {
  display: none;
}

.actions.active {
  display: inline-flex;
  gap: var(--message-bar-actions-gap);
}

.actions ::slotted(button) {
  /* Enforce micro-button width. */
  min-width: fit-content !important;

  margin: 0 !important;
  padding: var(--message-bar-actions-button-padding) !important;
}

/* Close icon styles */

moz-button::part(button) {
  background-image: var(--message-bar-icon-close-url);
}

@media not (prefers-contrast) {
  /* MozMessageBar colors by message type */
  :host([type="warning"]) {
    --message-bar-background-color: var(--message-bar-background-color-warning);
    --message-bar-icon-background-color: var(--message-bar-icon-background-color-warning);
    --message-bar-icon-color: var(--icon-color-warning);
  }

  :host([type="success"]) {
    --message-bar-background-color: var(--message-bar-background-color-success);
    --message-bar-icon-background-color: var(--message-bar-icon-background-color-success);
    --message-bar-icon-color: var(--icon-color-success);
  }

  :host([type="error"]),
  :host([type="critical"]) {
    --message-bar-background-color: var(--message-bar-background-color-critical);
    --message-bar-icon-background-color: var(--message-bar-icon-background-color-critical);
    --message-bar-icon-color: var(--icon-color-critical);
  }
}
