/* bubble styles
 */
:host,
:host * {
  box-sizing: border-box;
}

:host {
  position: absolute;
  display: block;

  --bubble-size: 28px;
  --bubble-margin: 5px;
  --color-background: 229, 229, 229;
  --color-primary: #0d7af6;
  width: var(--bubble-size);
  height: var(--bubble-size);
  margin: var(--bubble-margin);

  font-family: sans-serif;
}

.b-bubble {
  position: relative;
  opacity: 0;
  visibility: hidden;
  transition: opacity ease-out .2s;

  appearance: none;
  display: block;
  width: 100%;
  height: 100%;
  padding: 5px;
  background-color: rgba(var(--color-background), .4);
  border: 0;
  border-radius: 5px;
  cursor: pointer;
}

/* disable the fade transition
 */
@media (prefers-reduced-motion) {
  .b-bubble {
    transition-duration: 0s;
  }
}

.b-bubble:hover {
  background-color: rgba(var(--color-background), .8);
  box-shadow: 0 0 12px rgba(0,0,0,.1);
}

.b-bubble:active {
  box-shadow: none;
  cursor: pointer;
}

.b-bubble svg {
  display: block;
  width: 100%;
  height: 100%;
}

.b-bubble-visible {
  opacity: 1;
  visibility: visible;
}

.b-bubble:hover + .b-bubble-tooltip {
  opacity: 1;
  visibility: visible;
  transition-delay: 1s;
}

.b-bubble-tooltip {
  --tooltip-bg: #2a2a2a;
  visibility: hidden;
  opacity: 0;
  transition: opacity ease-in .1s;

  position: absolute;
  top: 50%;
  left: 0;
  padding: 3px 5px;
  background: var(--tooltip-bg);
  border-radius: 2px;

  color: #fff;
  font-size: 11px;
  font-weight: bold;
  line-height: 1;
  white-space: nowrap;

  transform: translate(-100%, -50%);
  margin-left: -12px;
}

.b-bubble-tooltip:after {
  content: '';
  position: absolute;
  border-style: solid;
  border-color: transparent;
  border-width: 6px;
  border-left-color: var(--tooltip-bg);
  display: block;
  width: 0;
  z-index: 1;
  top: 0;
  right: 1px;
  transform: translate(100%, calc(50% - 3px));
}

/* RTL support
  * BUG dialog positioning is broken in rtl mode,
  * after clicking the button.
  */
:host([dir=rtl]) {
  right: auto !important;
  left: 0;
}

:host([dir=rtl]) .b-bubble-tooltip {
  transform: translate(var(--bubble-size), -50%);
  margin-left: 12px;
}

:host([dir=rtl]) .b-bubble-tooltip:after {
  left: 1px;
  right: auto;
  border-left-color: transparent;
  border-right-color: var(--tooltip-bg);
  transform: translate(-100%, calc(50% - 3px));
}
