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

/* DO NOT EDIT this file directly, instead modify the relevant *.tokens.json file
 * and run `mach buildtokens` to see your changes. */

@import url("chrome://global/skin/design-system/tokens-shared.css");

@layer tokens-foundation {
  :root,
  :host(.anonymous-content-host) {
    /** background-color **/
    --background-color-box-info: color-mix(in srgb, currentColor 6%, transparent);
    --background-color-canvas: Canvas;
    --background-color-dimmed: color-mix(in srgb, currentColor 17%, transparent);
    --background-color-dimmed-further: color-mix(in srgb, currentColor 30%, transparent);
    --background-color-list-item-hover: color-mix(in srgb, currentColor 20%, transparent);

    /** border **/
    --border-color: color-mix(in srgb, currentColor 50%, transparent);
    --border-color-deemphasized: color-mix(in srgb, currentColor 24%, transparent);
    --border-color-interactive: color-mix(in srgb, currentColor 15%, var(--color-gray-60));

    /** button **/
    /* TODO Bug 1821203 - Gray use needs to be consolidated */
    --button-background-color: color-mix(in srgb, currentColor 13%, transparent);
    --button-background-color-hover: color-mix(in srgb, currentColor 17%, transparent);
    --button-background-color-active: color-mix(in srgb, currentColor 30%, transparent);
    --button-background-color-ghost: transparent;
    --button-text-color: currentColor;
    --button-text-color-menu-selected: currentColor;
    --button-text-color-primary: AccentColorText;

    /** color **/
    --color-accent-attention: AccentColor;
    --color-accent-primary: AccentColor;
    --color-accent-primary-hover: color-mix(in srgb, black 10%, var(--color-accent-primary));
    --color-accent-primary-active: color-mix(in srgb, black 20%, var(--color-accent-primary));
    --color-accent-primary-selected: SelectedItem;

    /** font-size **/
    --font-size-root: unset;
    --font-size-small: unset;

    /** info-bar **/
    --info-bar-border-color: var(--toolbarseparator-color);

    /** input **/
    --input-text-background-color: Field;
    --input-text-color: FieldText;

    /** link **/
    --link-color: LinkText;
    --link-color-hover: color-mix(in srgb, black 10%, var(--link-color));
    --link-color-active: color-mix(in srgb, black 20%, var(--link-color));

    /** panel **/
    --panel-background-color: Field;
    --panel-border-color: var(--border-color-deemphasized);
    --panel-text-color: FieldText;

    /** popup **/
    --popup-border-color: var(--border-color-deemphasized);

    /** sidebar **/
    --sidebar-background-color: -moz-sidebar;
    --sidebar-border-color: -moz-sidebarborder;
    --sidebar-text-color: -moz-sidebartext;

    /** table **/
    --table-header-text-color: AccentColorText;
    /* TODO Bug 1821203 - Gray use needs to be consolidated */
    --table-row-background-color-alternate: light-dark(rgba(0, 0, 0, 0.05), rgba(255, 255, 255, 0.05));

    /** text-color **/
    --text-color: currentColor;
    --text-color-accent-primary-selected: SelectedItemText;

    /** toolbar **/
    --toolbar-background-color: color-mix(in srgb, -moz-dialog 85%, var(--color-white));
    --toolbar-field-background-color: light-dark(rgba(0, 0, 0, 0.05), var(--color-black-alpha-30));
    --toolbar-field-background-color-focus: Field;
    --toolbar-field-border-color: var(--border-color-transparent);
    --toolbar-field-text-color: inherit;
    --toolbar-field-text-color-focus: FieldText;
    --toolbar-text-color: -moz-dialogtext;

    /** toolbarbutton **/
    --toolbarbutton-icon-fill: currentColor;
    --toolbarbutton-icon-fill-attention: AccentColor;
    --toolbarbutton-icon-fill-attention-text: AccentColorText;

    /** toolbox **/
    --toolbox-background-color: -moz-headerbar;
    --toolbox-background-color-inactive: -moz-headerbarinactive;
    --toolbox-text-color: -moz-headerbartext;
    --toolbox-text-color-inactive: -moz-headerbarinactivetext;
  }
}

/* Bug 1879900: Can't nest media queries inside of :host, :root selector
   until Bug 1879349 lands */
@layer tokens-browser-theme {
  @media not ((forced-colors) or (-moz-native-theme)) {
    :root:is([theme-in-app], :not([lwtheme])),
    :host(.anonymous-content-host) {
      /** background-color **/
      --background-color-dimmed: light-dark(color-mix(in srgb, currentColor 12%, transparent), color-mix(in srgb, currentColor 17%, transparent));
      --background-color-dimmed-further: light-dark(color-mix(in srgb, currentColor 20%, transparent), color-mix(in srgb, currentColor 14%, transparent));

      /** button **/
      /* TODO Bug 1821203 - Gray use needs to be consolidated */
      --button-background-color: light-dark(rgba(207, 207, 216, 0.33), rgba(0, 0, 0, 0.33));
      --button-background-color-hover: light-dark(rgba(207, 207, 216, 0.66), rgba(207, 207, 216, 0.2));
      --button-background-color-active: light-dark(rgb(207, 207, 216), rgba(207, 207, 216, 0.4));
      --button-text-color: light-dark(rgb(21, 20, 26), rgb(251, 251, 254));
      --button-text-color-menu-selected: var(--button-text-color-ghost-selected);
      --button-text-color-primary: light-dark(rgb(251, 251, 254), rgb(43, 42, 51));

      /** color **/
      --color-accent-attention: light-dark(#2ac3a2, #54ffbd);
      --color-accent-primary: light-dark(var(--color-blue-60), var(--color-cyan-30));
      --color-accent-primary-hover: light-dark(var(--color-blue-70), var(--color-cyan-20));
      --color-accent-primary-active: light-dark(var(--color-blue-80), var(--color-cyan-10));
      --color-accent-primary-selected: light-dark(var(--color-blue-60), var(--color-cyan-30));

      /** info-bar **/
      --info-bar-border-color: light-dark(var(--color-violet-desaturated-20), var(--color-gray-60));

      /** input **/
      --input-text-background-color: light-dark(var(--color-white), #42414d);
      --input-text-color: light-dark(rgb(21, 20, 26), rgb(251, 251, 254));

      /** link **/
      --link-color: var(--color-accent-primary);
      --link-color-hover: var(--color-accent-primary-hover);
      --link-color-active: var(--color-accent-primary-active);

      /** panel **/
      --panel-background-color: light-dark(var(--color-white), rgb(66, 65, 77));
      --panel-border-color: light-dark(rgb(240, 240, 244), rgb(82, 82, 94));
      --panel-text-color: light-dark(var(--color-black), rgb(251, 251, 254));

      /** popup **/
      --popup-border-color: light-dark(rgb(240, 240, 244), rgb(82, 82, 94));

      /** sidebar **/
      --sidebar-background-color: light-dark(white, rgb(28, 27, 34));
      --sidebar-border-color: var(--card-border-color);
      --sidebar-text-color: light-dark(rgb(21, 20, 26), rgb(249, 249, 250));

      /** toolbar **/
      --toolbar-background-color: light-dark(#f9f9fb, rgb(43, 42, 51));
      --toolbar-field-background-color: light-dark(rgba(0, 0, 0, 0.05), var(--color-black-alpha-30));
      --toolbar-field-background-color-focus: light-dark(var(--color-white), rgb(66, 65, 77));
      --toolbar-field-border-color: var(--border-color-transparent);
      --toolbar-field-text-color: light-dark(var(--color-gray-100), var(--color-gray-0));
      --toolbar-field-text-color-focus: light-dark(var(--color-black), var(--color-gray-0));
      --toolbar-text-color: light-dark(var(--color-gray-100), var(--color-gray-0));

      /** toolbarbutton **/
      --toolbarbutton-icon-fill: light-dark(var(--color-gray-70), var(--color-gray-0));
      --toolbarbutton-icon-fill-attention: light-dark(var(--color-blue-60), var(--color-cyan-30));
      --toolbarbutton-icon-fill-attention-text: light-dark(var(--color-gray-20), var(--color-gray-90));

      /** toolbox **/
      --toolbox-background-color: light-dark(rgb(234, 234, 237), var(--color-gray-90));
      --toolbox-background-color-inactive: var(--toolbox-background-color);
      --toolbox-text-color: light-dark(var(--color-gray-100), var(--color-gray-0));
      --toolbox-text-color-inactive: var(--toolbox-text-color);
    }
  }
}

@media -moz-pref("browser.nova.enabled") {
  @layer tokens-foundation-nova {
    :root,
    :host(.anonymous-content-host) {
      /** button **/
      /* TODO Bug 1821203 - Gray use needs to be consolidated */
      --button-background-color: color-mix(in srgb, currentColor 13%, transparent);
      --button-background-color-hover: color-mix(in srgb, currentColor 17%, transparent);
      --button-background-color-active: color-mix(in srgb, currentColor 30%, transparent);
      --button-background-color-ghost: transparent;
      --button-text-color: currentColor;
      --button-text-color-menu-selected: currentColor;
      --button-text-color-primary: AccentColorText;

      /** color **/
      --color-accent-attention: AccentColor;
      --color-accent-primary: AccentColor;
      --color-accent-primary-hover: color-mix(in srgb, black 10%, var(--color-accent-primary));
      --color-accent-primary-active: color-mix(in srgb, black 20%, var(--color-accent-primary));
      --color-accent-primary-selected: SelectedItem;

      /** panel **/
      --panel-background-color: Field;
      --panel-border-color: var(--border-color-deemphasized);
      --panel-text-color: FieldText;

      /** popup **/
      --popup-border-color: var(--border-color-deemphasized);

      /** text-color **/
      --text-color: currentColor;
      --text-color-accent-primary-selected: SelectedItemText;

      /** toolbar **/
      --toolbar-background-color: color-mix(in srgb, -moz-dialog 85%, var(--color-white));
      --toolbar-field-background-color: light-dark(rgba(0, 0, 0, 0.05), var(--color-black-alpha-30));
      --toolbar-field-background-color-focus: Field;
      --toolbar-field-border-color: var(--border-color-transparent);
      --toolbar-field-border-color-focus: color-mix(in srgb, var(--focus-outline-color) 50%, transparent);
      --toolbar-field-text-color: inherit;
      --toolbar-field-text-color-focus: FieldText;

      /** toolbarbutton **/
      --toolbarbutton-icon-fill: currentColor;
      --toolbarbutton-icon-fill-attention: AccentColor;

      /** toolbox **/
      --toolbox-background-color-inactive: -moz-headerbarinactive;
      /* This gradient is only used for Nova */
      --toolbox-background-gradient: image(transparent);
      --toolbox-text-color: -moz-headerbartext;
    }
  }

  /* Bug 1879900: Can't nest media queries inside of :host, :root selector
   until Bug 1879349 lands */
  @layer tokens-browser-theme-nova {
    @media not ((forced-colors) or (-moz-native-theme)) {
      :root:is([theme-in-app], :not([lwtheme])),
      :host(.anonymous-content-host) {
        /** button **/
        /* TODO Bug 1821203 - Gray use needs to be consolidated */
        --button-background-color: transparent;
        --button-background-color-hover: light-dark(var(--color-violet-desaturated-20), var(--color-violet-desaturated-50));
        --button-background-color-active: light-dark(var(--color-violet-desaturated-30), var(--color-violet-desaturated-40));
        --button-background-color-ghost: var(--button-background-color);
        --button-text-color: light-dark(var(--color-violet-90), var(--color-gray-0));
        --button-text-color-menu-selected: light-dark(var(--button-text-color-ghost-selected), var(--button-text-color-selected));
        --button-text-color-primary: light-dark(var(--color-white), var(--color-gray-70));

        /** color **/
        --color-accent-attention: light-dark(var(--color-green-40), var(--color-green-30));
        --color-accent-primary: light-dark(var(--color-violet-50), var(--color-violet-30));
        --color-accent-primary-hover: light-dark(var(--color-violet-60), var(--color-violet-20));
        --color-accent-primary-active: light-dark(var(--color-violet-70), var(--color-violet-10));
        --color-accent-primary-selected: var(--button-background-color-primary-active);

        /** panel **/
        --panel-background-color: var(--popup-background-color);
        --panel-border-color: var(--popup-border-color);
        --panel-text-color: var(--text-color);

        /** popup **/
        --popup-border-color: light-dark(var(--color-gray-10), var(--color-gray-65));

        /** text-color **/
        --text-color: light-dark(var(--color-violet-desaturated-90), var(--color-violet-desaturated-0));

        /** toolbar **/
        --toolbar-background-color: var(--background-color-box);
        --toolbar-field-background-color: var(--toolbar-background-color);
        --toolbar-field-background-color-focus: var(--background-color-box);
        --toolbar-field-border-color: light-dark(var(--color-gray-20), var(--color-gray-60));
        --toolbar-field-border-color-focus: var(--focus-outline-color);
        --toolbar-field-text-color: light-dark(var(--color-violet-desaturated-70), var(--color-violet-desaturated-10));
        --toolbar-field-text-color-focus: var(--toolbar-field-text-color);

        /** toolbarbutton **/
        --toolbarbutton-icon-fill: light-dark(var(--color-violet-desaturated-50), var(--color-violet-desaturated-10));
        --toolbarbutton-icon-fill-attention: var(--color-accent-primary);

        /** toolbox **/
        --toolbox-background-color-inactive: transparent;
        /* This gradient is only used for Nova */
        --toolbox-background-gradient: linear-gradient(
          96deg,
          color-mix(var(--toolbox-background-color-gradient-leading) 50%, transparent) 39.84%,
          color-mix(var(--toolbox-background-color-gradient-trailing) 50%, transparent) 101.72%
        );
        --toolbox-text-color: var(--text-color);
      }
    }
  }
}
