/* 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 "defines.css";
@import "scrollbar.css";

@namespace url("http://www.w3.org/1999/xhtml");
@namespace xul url("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul");

::-moz-selection {
  background-color: var(--color_background_highlight);
  color: var(--color_text_highlight);
}

/* Style the scrollbars */
xul|scrollbar[root="true"] {
  position: relative;
  z-index: 2147483647;
}

xul|scrollbar {
  -moz-appearance: none !important;
  -moz-binding: url("chrome://global/content/bindings/scrollbar.xml#scrollbar");
  background-color: transparent !important;
  background-image: none !important;
  border: 0px solid transparent !important;
  pointer-events: none;
}

/* Scrollbar code will reset the margin to the correct side depending on
   where layout actually puts the scrollbar */
xul|scrollbar[orient="vertical"] {
  margin-left: -6px;
  min-width: 6px;
  max-width: 6px;
}

xul|scrollbar[orient="vertical"] xul|thumb {
  -moz-appearance: scrollbarthumb-vertical !important;
  max-width: 2px !important;
  min-width: 2px !important;
}

xul|scrollbar[orient="horizontal"] {
  margin-top: -6px;
  min-height: 6px;
  max-height: 6px;
}

xul|scrollbar[orient="horizontal"] xul|thumb {
  -moz-appearance: scrollbarthumb-horizontal !important;
  max-height: 2px !important;
  min-height: 2px !important;
}

xul|scrollbar:not([active="true"]),
xul|scrollbar[disabled] {
  opacity: 0;
}

xul|scrollbarbutton {
  min-height: 6px !important;
  min-width: 6px !important;
  -moz-appearance: none !important;
  visibility: hidden;
}

xul|scrollbarbutton[sbattr="scrollbar-up-top"],
xul|scrollbarbutton[sbattr="scrollbar-bottom-top"] {
  display: none;
}

xul|scrollbar xul|thumb {
  background-color: rgba(119, 119, 119, 0.4) !important;
  -moz-border-top-colors: none !important;
  -moz-border-bottom-colors: none !important;
  -moz-border-right-colors: none !important;
  -moz-border-left-colors: none !important;
  border: none;
  border-radius: 4px;
}

xul|scrollbarbutton {
  background-image: none !important;
}

select:not([size]):not([multiple]) > xul|scrollbar,
select[size="1"] > xul|scrollbar,
select:not([size]):not([multiple]) xul|scrollbarbutton,
select[size="1"] xul|scrollbarbutton {
  display: block;
  margin-left: 0;
  min-width: 16px;
}

/* Override inverse OS themes */
textarea,
button,
xul|button,
* > input:not(:-moz-any([type="image"], [type="checkbox"], [type="radio"])) {
  -moz-appearance: none !important;  /* See bug 598421 for fixing the platform */
}

textarea,
button,
xul|button,
* > input:not(:-moz-any([type="image"], [type="checkbox"], [type="radio"])) {
  border-radius: var(--form_border_radius);
}

select[size],
select[multiple],
select[size][multiple],
textarea,
* > input:not(:-moz-any([type="image"], [type="checkbox"], [type="radio"])) {
  border-style: solid;
  border-color: var(--form_border);
  color: var(--form_text);
  background-color: var(--form_background);
}

/* Selects are handled by the form helper, see bug 685197 */
select option, select optgroup {
  pointer-events: none;
}

select:not([size]):not([multiple]),
select[size="0"],
select[size="1"],
* > input[type="button"],
* > input[type="submit"],
* > input[type="reset"],
button {
  border-style: solid;
  border-color: var(--form_border);
  color: var(--form_text);
  background-color: var(--form_background);
}

select {
  border-width: 1px;
  padding: 1px;
  border-radius: var(--form_border_radius);
}

select:not([size]):not([multiple]),
select[size="0"],
select[size="1"] {
  padding: 0 1px 0 1px;
}

* > input:not(:-moz-any([type="image"], [type="checkbox"], [type="radio"])) {
  border-width: 1px;
  padding: 1px;
}

textarea {
  resize: none;
  border-width: 1px;
  padding-inline-start: 1px;
  padding-inline-end: 1px;
  padding-block-start: 2px;
  padding-block-end: 2px;
}

input[type="button"],
input[type="submit"],
input[type="reset"],
button {
  border-width: 1px;
  padding-inline-start: 7px;
  padding-inline-end: 7px;
  padding-block-start: 0;
  padding-block-end: 0;
}

select > button {
  border-width: 0px !important;
  margin: 0px !important;
  padding: 0px !important;
  border-radius: 0;
  color: #414141;

  background-size: auto auto;
  background-color: transparent;
  background-image: url("chrome://geckoview/skin/images/dropmarker.svg") !important;
  background-position: calc(50% + 1px) center !important;
  background-repeat: no-repeat !important;

  font-size: inherit;
}

select[size]:focus,
select[multiple]:focus,
select[size][multiple]:focus,
textarea:focus,
input[type="file"]:focus > input[type="text"],
* > input:not(:-moz-any([type="image"], [type="checkbox"], [type="radio"])):focus {
  outline: 0px !important;
  border-style: solid;
  border-color: var(--form_border);
  background-color: var(--form_background);
}

select:not([size]):not([multiple]):focus,
select[size="0"]:focus,
select[size="1"]:focus,
input[type="button"]:focus,
input[type="submit"]:focus,
input[type="reset"]:focus,
button:focus {
  outline: 0px !important;
  border-style: solid;
  border-color: var(--form_border);
  background-color: var(--form_background);
}

/* we need to be specific for selects because the above rules are specific too */
textarea:disabled,
select[size]:disabled,
select[multiple]:disabled,
select[size][multiple]:disabled,
select:not([size]):not([multiple]):disabled,
select[size="0"]:disabled,
select[size="1"]:disabled,
button:disabled,
button:disabled:active,
* > input:not(:-moz-any([type="image"], [type="checkbox"], [type="radio"])):disabled,
* > input:not(:-moz-any([type="image"], [type="checkbox"], [type="radio"])):disabled:active {
  color: var(--form_text_disabled);
  border-color: var(--form_border);
  border-style: solid;
  border-width: 1px;
  background-color: var(--form_background_disabled);
}

select:not([size]):not([multiple]):disabled,
select[size="0"]:disabled,
select[size="1"]:disabled {
  background-color: var(--form_background_disabled);
}

input[type="button"]:disabled,
input[type="button"]:disabled:active,
input[type="submit"]:disabled,
input[type="submit"]:disabled:active,
input[type="reset"]:disabled,
input[type="reset"]:disabled:active,
button:disabled,
button:disabled:active {
  padding-inline-start: 7px;
  padding-inline-end: 7px;
  padding-block-start: 0;
  padding-block-end: 0;
  background-color: var(--form_background_disabled);
}

select:disabled > button {
  opacity: 0.6;
  padding-inline-start: 7px;
  padding-inline-end: 7px;
  padding-block-start: 1px;
  padding-block-end: 1px;
}

/* -moz-touch-enabled? media elements */
:-moz-any(video, audio) > xul|videocontrols {
  -moz-binding: url("chrome://global/content/bindings/videocontrols.xml#touchControls");
}

/* display click to play when autoplay is blocked for videos */
video:not([controls]) > xul|videocontrols {
  visibility: visible;
  -moz-binding: url("chrome://global/content/bindings/videocontrols.xml#noControls");
}

*:any-link:active,
*[role=button]:active,
button:not(:disabled):active,
input:not(:-moz-any([type="checkbox"], [type="radio"])):not(:focus):not(:disabled):active,
select:not(:disabled):active,
textarea:not(:focus):not(:disabled):active,
option:active,
label:active,
xul|menulist:active {
  background-color: var(--color_background_highlight_overlay);
}

button:active:hover,
input[type="color"]:-moz-system-metric(color-picker-available):active:hover,
input[type="reset"]:active:hover,
input[type="button"]:active:hover,
input[type="submit"]:active:hover {
  padding-inline-end: 7px;
  padding-inline-start: 7px;
}

input[type=number] > div > div, /* work around bug 946184 */
input[type=number]::-moz-number-spin-box {
  display: none;
}

/* Override accessiblecaret css in layout/style/ua.css */
div:-moz-native-anonymous.moz-accessiblecaret > #text-overlay,
div:-moz-native-anonymous.moz-accessiblecaret > #image {
  /* border: 0.1px solid red; */ /* Uncomment border to see the touch target. */
  padding-left: 59%; /* Enlarge the touch area. ((48-22)/2)px / 22px ~= 59% */
  padding-right: 59%; /* Enlarge the touch area. */
  left: -59%;
}

div:-moz-native-anonymous.moz-accessiblecaret > #image {
  padding-bottom: 59%; /* Enlarge the touch area. */
}

div:-moz-native-anonymous.moz-accessiblecaret.normal > #image {
  background-image: url("chrome://geckoview/skin/images/accessiblecaret-normal-hdpi.png");
}

div:-moz-native-anonymous.moz-accessiblecaret.left > #text-overlay,
div:-moz-native-anonymous.moz-accessiblecaret.left > #image {
  margin-left: -50%;
}

div:-moz-native-anonymous.moz-accessiblecaret.left > #image {
  background-image: url("chrome://geckoview/skin/images/accessiblecaret-tilt-left-hdpi.png");
}

div:-moz-native-anonymous.moz-accessiblecaret.right > #text-overlay,
div:-moz-native-anonymous.moz-accessiblecaret.right > #image {
  margin-left: 47%;
}

div:-moz-native-anonymous.moz-accessiblecaret.right > #image {
  background-image: url("chrome://geckoview/skin/images/accessiblecaret-tilt-right-hdpi.png");
}

@media (min-resolution: 1.5dppx) {
  div:-moz-native-anonymous.moz-accessiblecaret.normal > #image {
    background-image: url("chrome://geckoview/skin/images/accessiblecaret-normal-hdpi.png");
  }

  div:-moz-native-anonymous.moz-accessiblecaret.left > #image {
    background-image: url("chrome://geckoview/skin/images/accessiblecaret-tilt-left-hdpi.png");
  }

  div:-moz-native-anonymous.moz-accessiblecaret.right > #image {
    background-image: url("chrome://geckoview/skin/images/accessiblecaret-tilt-right-hdpi.png");
  }
}

@media (min-resolution: 2dppx) {
  div:-moz-native-anonymous.moz-accessiblecaret.normal > #image {
    background-image: url("chrome://geckoview/skin/images/accessiblecaret-normal-xhdpi.png");
  }

  div:-moz-native-anonymous.moz-accessiblecaret.left > #image {
    background-image: url("chrome://geckoview/skin/images/accessiblecaret-tilt-left-xhdpi.png");
  }

  div:-moz-native-anonymous.moz-accessiblecaret.right > #image {
    background-image: url("chrome://geckoview/skin/images/accessiblecaret-tilt-right-xhdpi.png");
  }
}

@media (min-resolution: 2.25dppx) {
  div:-moz-native-anonymous.moz-accessiblecaret.normal > #image {
    background-image: url("chrome://geckoview/skin/images/accessiblecaret-normal-xxhdpi.png");
  }

  div:-moz-native-anonymous.moz-accessiblecaret.left > #image {
    background-image: url("chrome://geckoview/skin/images/accessiblecaret-tilt-left-xxhdpi.png");
  }

  div:-moz-native-anonymous.moz-accessiblecaret.right > #image {
    background-image: url("chrome://geckoview/skin/images/accessiblecaret-tilt-right-xxhdpi.png");
  }
}
