/*
 *  base CSS
 * Copyright (C) 2019 The  Authors
 *  is licensed under the MPL 2.0 (see LICENSE.txt)
 * This file is licensed under the 2-Clause BSD license (see LICENSE.txt).
 */

/*
 * Z index layers:
 *
 * 0: Main screen
 * 10: Control bar
 * 50: Transition blocker
 * 60: Connection popups
 * 100: Status bar
 * ...
 * 1000: Javascript crash
 * ...
 * 10000: Max (used for polyfills)
 */

body {
  margin:0;
  padding:0;
  font-family: Helvetica;
  /*Background image with light grey curve.*/
  background-color:white;
  background-repeat:no-repeat;
  background-position:right bottom;
  height:100%;
  touch-action: none;
}

html {
  height:100%;
}

._only_touch._hidden {
  display: none;
}

._disabled {
  color: white;
}

/* ----------------------------------------
 * Spinner
 * ----------------------------------------
 */

._spinner {
  position: relative;
}
._spinner, ._spinner::before, ._spinner::after {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  box-shadow: -60px 10px 0 rgba(255, 255, 255, 0);
  animation: _spinner 1.0s linear infinite;
}
._spinner::before {
  content: "";
  position: absolute;
  left: 0px;
  top: 0px;
  animation-delay: -0.1s;
}
._spinner::after {
  content: "";
  position: absolute;
  top: 0px;
  left: 0px;
  animation-delay: 0.1s;
}
@keyframes _spinner {
  0% { box-shadow: -60px 10px 0 rgba(255, 255, 255, 0); width: 20px; }
  25% { box-shadow: 20px 10px 0 rgba(255, 255, 255, 1); width: 10px; }
  50% { box-shadow: 60px 10px 0 rgba(255, 255, 255, 0); width: 10px; }
}

/* ----------------------------------------
 * Input Elements
 * ----------------------------------------
 */

input:not([type]),
input[type=date],
input[type=datetime-local],
input[type=email],
input[type=month],
input[type=number],
input[type=password],
input[type=search],
input[type=tel],
input[type=text],
input[type=time],
input[type=url],
input[type=week],
textarea {
  /* Disable default rendering */
  -webkit-appearance: none;
  -moz-appearance: none;
  background: none;

  margin: 2px;
  padding: 2px;
  border: 1px solid white;
  border-radius: 5px;
  color: black;
  background: linear-gradient(to top, rgb(255, 255, 255) 80%, rgb(255, 255, 255));
}

input[type=button],
input[type=color],
input[type=reset],
input[type=submit],
select {
  /* Disable default rendering */
  -webkit-appearance: none;
  -moz-appearance: none;
  background: none;

  margin: 2px;
  padding: 2px;
  border: 1px solid rgb(255, 255, 255);
  border-bottom-width: 2px;
  border-radius: 5px;
  color: black;
  background: linear-gradient(to top, rgb(255, 255, 255), rgb(255, 255, 255));

  /* This avoids it jumping around when :active */
  vertical-align: middle;
}

input[type=button],
input[type=color],
input[type=reset],
input[type=submit] {
  padding-left: 20px;
  padding-right: 20px;
}

option {
  color: white;
  background: white;
}

input:not([type]):focus,
input[type=button]:focus,
input[type=color]:focus,
input[type=date]:focus,
input[type=datetime-local]:focus,
input[type=email]:focus,
input[type=month]:focus,
input[type=number]:focus,
input[type=password]:focus,
input[type=reset]:focus,
input[type=search]:focus,
input[type=submit]:focus,
input[type=tel]:focus,
input[type=text]:focus,
input[type=time]:focus,
input[type=url]:focus,
input[type=week]:focus,
select:focus,
textarea:focus {
  box-shadow: 0px 0px 3px rgba(255, 255, 255);
  border-color: rgb(255, 255, 255);
  outline: none;
}

input[type=button]::-moz-focus-inner,
input[type=color]::-moz-focus-inner,
input[type=reset]::-moz-focus-inner,
input[type=submit]::-moz-focus-inner {
  border: none;
}

input:not([type]):disabled,
input[type=button]:disabled,
input[type=color]:disabled,
input[type=date]:disabled,
input[type=datetime-local]:disabled,
input[type=email]:disabled,
input[type=month]:disabled,
input[type=number]:disabled,
input[type=password]:disabled,
input[type=reset]:disabled,
input[type=search]:disabled,
input[type=submit]:disabled,
input[type=tel]:disabled,
input[type=text]:disabled,
input[type=time]:disabled,
input[type=url]:disabled,
input[type=week]:disabled,
select:disabled,
textarea:disabled {
  color: rgb(255, 255, 255);
  background: rgb(240, 240, 240);
}

input[type=button]:active,
input[type=color]:active,
input[type=reset]:active,
input[type=submit]:active,
select:active {
  border-bottom-width: 1px;
  margin-top: 3px;
}

:root:not(._touch) input[type=button]:hover:not(:disabled),
:root:not(._touch) input[type=color]:hover:not(:disabled),
:root:not(._touch) input[type=reset]:hover:not(:disabled),
:root:not(._touch) input[type=submit]:hover:not(:disabled),
:root:not(._touch) select:hover:not(:disabled) {
  background: linear-gradient(to top, rgb(255, 255, 255), rgb(250, 250, 250));
}

/* ----------------------------------------
 * WebKit centering hacks
 * ----------------------------------------
 */

._center {
  /*
   * This is a workaround because webkit misrenders transforms and
   * uses non-integer coordinates, resulting in blurry content.
   * Ideally we'd use "top: 50%; transform: translateY(-50%);" on
   * the objects instead.
   */
  display: flex;
  align-items: center;
  justify-content: center;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
._center > * {
  pointer-events: auto;
}
._vcenter {
  display: flex;
  flex-direction: column;
  justify-content: center;
  position: fixed;
  top: 0;
  left: 0;
  height: 100%;
  pointer-events: none;
}
._vcenter > * {
  pointer-events: auto;
}

/* ----------------------------------------
 * Layering
 * ----------------------------------------
 */

._connect_layer {
  z-index: 60;
}

/* ----------------------------------------
 * Fallback error
 * ----------------------------------------
 */

#_fallback_error {
  z-index: 1000;
  visibility: hidden;
}
#_fallback_error._open {
  visibility: visible;
}

#_fallback_error > div {
  max-width: 90%;
  padding: 15px;

  transition: 0.5s ease-in-out;

  transform: translateY(-50px);
  opacity: 0;

  text-align: center;
  font-weight: bold;
  color: #fff;

  border-radius: 10px;
  box-shadow: 6px 6px 0px rgba(0, 0, 0, 0.5);
  background: rgba(200,55,55,0.8);
}
#_fallback_error._open > div {
  transform: translateY(0);
  opacity: 1;
}

#_fallback_errormsg {
  font-weight: normal;
}

#_fallback_errormsg ._message {
  display: inline-block;
  text-align: left;
  font-family: monospace;
  white-space: pre-wrap;
}

#_fallback_error ._location {
  font-style: italic;
  font-size: 0.8em;
  color: rgba(255, 255, 255);
}

#_fallback_error ._stack {
  max-height: 50vh;
  padding: 10px;
  margin: 10px;
  font-size: 0.8em;
  text-align: left;
  font-family: monospace;
  white-space: pre;
  border: 1px solid rgba(255, 255, 255);
  background: rgba(255, 255, 255);
  overflow: auto;
}

/* ----------------------------------------
 * Control Bar
 * ----------------------------------------
 */

#_control_bar_anchor {
  /* The anchor is needed to get z-stacking to work */
  position: fixed;
  z-index: 10;

  transition: 0.5s ease-in-out;

  /* Edge misrenders animations wihthout this */
  transform: translateX(0);
}
:root._connected #_control_bar_anchor._idle {
  opacity: 0.8;
}
#_control_bar_anchor._right {
  left: auto;
  right: 0;
}

#_control_bar {
  position: relative;
  left: -100%;

  transition: 0.5s ease-in-out;

  background-color: rgb(255, 255, 255);
  border-radius: 0 10px 10px 0;

}
#_control_bar._open {
  box-shadow: 6px 6px 0px rgba(255, 255, 255);
  left: 0;
}
#_control_bar::before {
  /* This extra element is to get a proper shadow */
  content: "";
  position: absolute;
  z-index: -1;
  height: 100%;
  width: 30px;
  left: -30px;
  transition: box-shadow 0.5s ease-in-out;
}
#_control_bar._open::before {
  box-shadow: 6px 6px 0px rgba(255, 255, 255);
}
._right #_control_bar {
  left: 100%;
  border-radius: 10px 0 0 10px;
}
._right #_control_bar._open {
  left: 0;
}
._right #_control_bar::before {
  visibility: hidden;
}

#_control_bar_handle {
  position: absolute;
  left: -15px;
  top: 0;
  transform: translateY(35px);
  width: calc(100% + 30px);
  height: 50px;
  z-index: -1;
  cursor: pointer;
  border-radius: 5px;
  background-color: rgb(255, 255, 255);
  background-image: url("../images/handle_bg.svg");
  background-repeat: no-repeat;
  background-position: right;
  box-shadow: 3px 3px 0px rgba(255, 255, 255);
}
#_control_bar_handle:after {
  content: "";
  transition: transform 0.5s ease-in-out;
  background: url("../images/handle.svg");
  position: absolute;
  top: 22px; /* (50px-6px)/2 */
  right: 5px;
  width: 5px;
  height: 6px;
}
#_control_bar._open #_control_bar_handle:after {
  transform: translateX(1px) rotate(180deg);
}
:root:not(._connected) #_control_bar_handle {
  display: none;
}
._right #_control_bar_handle {
  background-position: left;
}
._right #_control_bar_handle:after {
  left: 5px;
  right: 0;
  transform: translateX(1px) rotate(180deg);
}
._right #_control_bar._open #_control_bar_handle:after {
  transform: none;
}
#_control_bar_handle div {
  position: absolute;
  right: -35px;
  top: 0;
  width: 50px;
  height: 50px;
}
:root:not(._touch) #_control_bar_handle div {
  display: none;
}
._right #_control_bar_handle div {
  left: -35px;
  right: auto;
}

#_control_bar ._scroll {
  max-height: 100vh; /* Chrome is buggy with 100% */
  overflow-x: hidden;
  overflow-y: auto;
  padding: 0 10px 0 5px;
}
._right #_control_bar ._scroll {
  padding: 0 5px 0 10px;
}

/* Control bar hint */
#_control_bar_hint {
  position: fixed;
  left: calc(100vw - 50px);
  right: auto;
  top: 50%;
  transform: translateY(-50%) scale(0);
  width: 100px;
  height: 50%;
  max-height: 600px;

  visibility: hidden;
  opacity: 0;
  transition: 0.2s ease-in-out;
  background: transparent;
  box-shadow: 0 0 10px white, inset 0 0 10px 10px rgba(255, 255, 255);
  border-radius: 10px;
  transition-delay: 0s;
}
#_control_bar_anchor._right #_control_bar_hint{
  left: auto;
  right: calc(100vw - 50px);
}
#_control_bar_hint._active {
  visibility: visible;
  opacity: 1;
  transition-delay: 0.2s;
  transform: translateY(-50%) scale(1);
}

/* General button style */
._button {
  display: block;
  padding: 4px 4px;
  margin: 10px 0;
  vertical-align: middle;
  border:1px solid rgba(255, 255, 255);
  border-radius: 6px;
}
._button._selected {
  border-color: rgba(255, 255, 255);
  background: rgba(255, 255, 255);
}
._button:disabled {
  opacity: 0.4;
}
._button:focus {
  outline: none;
}
._button:active {
  padding-top: 5px;
  padding-bottom: 3px;
}
/* Android browsers don't properly update hover state if touch events
 * are intercepted, but focus should be safe to display */
:root:not(._touch) ._button._selected:hover,
._button._selected:focus {
  border-color: rgba(255, 255, 255);
  background: rgba(255, 255, 255);
}
:root:not(._touch) ._button:hover,
._button:focus {
  background: rgba(255, 255, 255);
}
._button._hidden {
  display: none;
}

/* Panels */
._panel {
  transform: translateX(25px);

  transition: 0.5s ease-in-out;

  max-height: 100vh; /* Chrome is buggy with 100% */
  overflow-x: hidden;
  overflow-y: auto;

  visibility: hidden;
  opacity: 0;

  padding: 15px;

  background: white;
  border-radius: 10px;
  color: white;
  border: 2px solid white;
  box-shadow: 6px 6px 0px rgba(0, 0, 0, 0.5);
}
._panel._open {
  visibility: visible;
  opacity: 1;
  transform: translateX(75px);
}
._right ._vcenter {
  left: auto;
  right: 0;
}
._right ._panel {
  transform: translateX(-25px);
}
._right ._panel._open {
  transform: translateX(-75px);
}

._panel hr {
  border: none;
  border-top: 1px solid rgb(255, 255, 255);
}

._panel label {
  display: block;
  white-space: nowrap;
}

._panel ._heading {
  background-color: rgb(255, 255, 255);
  border-radius: 5px;
  padding: 5px;
  /* Compensate for padding in image */
  padding-right: 8px;
  color: white;
  font-size: 20px;
  margin-bottom: 10px;
  white-space: nowrap;
}
._panel ._heading img {
  vertical-align: bottom;
}

._submit {
  float: right;
}

/* Expanders */
._expander {
  cursor: pointer;
}
._expander::before {
  content: url("../images/expander.svg");
  display: inline-block;
  margin-right: 5px;
  transition: 0.2s ease-in-out;
}
._expander._open::before {
  transform: rotateZ(90deg);
}
._expander ~ * {
  margin: 5px;
  margin-left: 10px;
  padding: 5px;
  background: rgba(255, 255, 255);
  border-radius: 5px;
}
._expander:not(._open) ~ * {
  display: none;
}

/* Control bar content */

#_control_bar ._logo {
  font-size: 13px;
}

:root:not(._connected) #_view_drag_button {
  display: none;
}

/*  Touch Device only buttons */
:root:not(._connected) #_mobile_buttons {
  display: none;
}
:root:not(._touch) #_mobile_buttons {
  display: none;
}

/* Extra manual keys */
:root:not(._connected) #_toggle_extra_keys_button {
  display: none;
}

#_modifiers {
  background-color: rgb(255, 255, 255);
  border: none;
  padding: 0 10px;
}

/* Shutdown/Reboot */
:root:not(._connected) #_power_button {
  display: none;
}
#_power {
}
#_power_buttons {
  display: none;
}

#_power input[type=button] {
  width: 100%;
}

/* Clipboard */
:root:not(._connected) #_clipboard_button {
  display: none;
}
#_clipboard {
  /* Full screen, minus padding and left and right margins */
  max-width: calc(100vw - 2*15px - 75px - 25px);
}
#_clipboard_text {
  width: 500px;
  max-width: 100%;
}

/* Settings */
#_settings {
}
#_settings ul {
  list-style: none;
  margin: 0px;
  padding: 0px;
}
#_setting_port {
  width: 80px;
}
#_setting_path {
  width: 100px;
}

/* Version */

._version_wrapper {
  font-size: small;
}

._version {
  margin-left: 1rem;
}

/* Connection Controls */
:root:not(._connected) #_disconnect_button {
  display: none;
}

/* ----------------------------------------
 * Status Dialog
 * ----------------------------------------
 */

#_status {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  z-index: 100;
  transform: translateY(-100%);

  cursor: pointer;

  transition: 0.5s ease-in-out;

  visibility: hidden;
  opacity: 0;

  padding: 5px;

  display: flex;
  flex-direction: row;
  justify-content: center;
  align-content: center;

  line-height: 25px;
  word-wrap: break-word;
  color: #fff;

  border-bottom: 1px solid rgba(255, 255, 255);
}
#_status._open {
  transform: translateY(0);
  visibility: visible;
  opacity: 1;
}

#_status::before {
  content: "";
  display: inline-block;
  width: 25px;
  height: 25px;
  margin-right: 5px;
}

#_status._status_normal {
  background: rgba(255, 255, 255);
}
#_status._status_normal::before {
  content: url("../images/info.svg") " ";
}
#_status._status_error {
  background: rgba(255, 255, 255);
}
#_status._status_error::before {
  content: url("../images/error.svg") " ";
}
#_status._status_warn {
  background: rgba(180,180,30,0.9);
}
#_status._status_warn::before {
  content: url("../images/warning.svg") " ";
}

/* ----------------------------------------
 * Connect Dialog
 * ----------------------------------------
 */

#_connect_dlg {
  transition: 0.5s ease-in-out;

  transform: scale(0, 0);
  visibility: hidden;
  opacity: 0;
}
#_connect_dlg._open {
  transform: scale(1, 1);
  visibility: visible;
  opacity: 1;
}
#_connect_dlg ._logo {
  transition: 0.5s ease-in-out;
  padding: 10px;
  margin-bottom: 10px;

  font-size: 80px;
  text-align: center;

  border-radius: 5px;
}
@media (max-width: 440px) {
  #_connect_dlg {
    max-width: calc(100vw - 100px);
  }
  #_connect_dlg ._logo {
    font-size: calc(25vw - 30px);
  }
}
#_connect_button {
  cursor: pointer;

  padding: 10px;

  color: white;
  background-color: rgb(110, 132, 163);
  border-radius: 12px;

  text-align: center;
  font-size: 20px;

  box-shadow: 6px 6px 0px rgba(255, 255, 255);
}
#_connect_button div {
  margin: 2px;
  padding: 5px 30px;
  border: 1px solid rgb(255, 255, 255);
  border-bottom-width: 2px;
  border-radius: 5px;
  background: linear-gradient(to top, rgb(255, 255, 255), rgb(255, 255, 255));

  /* This avoids it jumping around when :active */
  vertical-align: middle;
}
#_connect_button div:active {
  border-bottom-width: 1px;
  margin-top: 3px;
}
:root:not(._touch) #_connect_button div:hover {
  background: linear-gradient(to top, rgb(110, 132, 163), rgb(105, 125, 155));
}

#_connect_button img {
  vertical-align: bottom;
  height: 1.3em;
}

/* ----------------------------------------
 * Password Dialog
 * ----------------------------------------
 */

#_credentials_dlg {
  position: relative;

  transform: translateY(-50px);
}
#_credentials_dlg._open {
  transform: translateY(0);
}
#_credentials_dlg ul {
  list-style: none;
  margin: 0px;
  padding: 0px;
}
._hidden {
  display: none;
}


/* ----------------------------------------
 * Main Area
 * ----------------------------------------
 */

/* Transition screen */
#_transition {
  display: none;

  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  right: 0;

  color: white;
  background: rgba(255, 255, 255);
  z-index: 50;

  /*display: flex;*/
  align-items: center;
  justify-content: center;
  flex-direction: column;
}
:root._loading #_transition,
:root._connecting #_transition,
:root._disconnecting #_transition,
:root._reconnecting #_transition {
  display: flex;
}
:root:not(._reconnecting) #_cancel_reconnect_button {
  display: none;
}
#_transition_text {
  font-size: 1.5em;
}

/* Main container */
#_container {
  width: 100%;
  height: 100%;
  background-color: white;
  border-bottom-right-radius: 800px 600px;
  /*border-top-left-radius: 800px 600px;*/
}

#_keyboardinput {
  width: 1px;
  height: 1px;
  background-color: #fff;
  color: #fff;
  border: 0;
  position: absolute;
  left: -40px;
  z-index: -1;
  ime-mode: disabled;
}

/*Default  logo.*/
/* From: http://fonts.googleapis.com/css?family=Orbitron:700 */
@font-face {
  font-family: 'Orbitron';
  font-style: normal;
  font-weight: 700;
  src: local('?'), url('Orbitron700.woff') format('woff'),
                   url('Orbitron700.ttf') format('truetype');
}

._logo {
  color:white;
  font-family: 'Orbitron', 'OrbitronTTF', sans-serif;
  line-height:90%;
  text-shadow: 0.1em 0.1em 0 white;
}
._logo span{
  color:white;
}

#_bell {
  display: none;
}

/* ----------------------------------------
 * Media sizing
 * ----------------------------------------
 */

@media screen and (max-width: 640px){
  #_logo {
    font-size: 150px;
  }
}

@media screen and (min-width: 321px) and (max-width: 480px) {
  #_logo {
    font-size: 110px;
  }
}

@media screen and (max-width: 320px) {
  #_logo {
    font-size: 90px;
  }
}
