
/* START TOOLTIP STYLES */
[rsssl-tooltip] {
  position: relative; /* opinion 1 */
  margin-left: 5px;
}

/* Applies to all tooltips */
[rsssl-tooltip]::before,
[rsssl-tooltip]::after {
  text-transform: none; /* opinion 2 */
  font-size: 1em; /* opinion 3 */
  line-height: 1;
  user-select: none;
  pointer-events: none;
  position: absolute;
  display: none;
  opacity: 0;
}

[rsssl-tooltip]::before {
  content: '';
  border: 5px solid transparent; /* opinion 4 */
  z-index: 1001; /* absurdity 1 */
}

[rsssl-tooltip]::after {
  content: attr(rsssl-tooltip); /* magic! */
  min-width: 3em;
  font-weight:normal;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 1ch 1.5ch;
  border-radius: .3ch;
  box-shadow: 0 1em 2em -.5em rgba(0, 0, 0, 0.35);
  background: #333;
  color: #fff;
  z-index: 1000; /* absurdity 2 */
}

/* Make the tooltips respond to hover */
[rsssl-tooltip]:hover::before,
[rsssl-tooltip]:hover::after {
  display: block;
}

/* don't show empty tooltips */
[rsssl-tooltip='']::before,
[rsssl-tooltip='']::after {
  display: none !important;
}

/* FLOW: UP */
[rsssl-tooltip]:not([flow])::before,
[rsssl-tooltip][flow^="up"]::before {
  bottom: 100%;
  border-bottom-width: 0;
  border-top-color: #333;
}

[rsssl-tooltip]:not([flow])::after,
[rsssl-tooltip][flow^="up"]::after {
  bottom: calc(100% + 5px);
}

[rsssl-tooltip]:not([flow])::before,
[rsssl-tooltip]:not([flow])::after,
[rsssl-tooltip][flow^="up"]::before,
[rsssl-tooltip][flow^="up"]::after {
  left: 50%;
  transform: translate(-50%, -.5em);
}

/* FLOW: DOWN */
[rsssl-tooltip][flow^="down"]::before {
  top: 100%;
  border-top-width: 0;
  border-bottom-color: #333;
}

[rsssl-tooltip][flow^="down"]::after {
  top: calc(100% + 5px);
}

[rsssl-tooltip][flow^="down"]::before,
[rsssl-tooltip][flow^="down"]::after {
  left: 50%;
  transform: translate(-50%, .5em);
}

/* FLOW: LEFT */
[rsssl-tooltip][flow^="left"]::before {
  top: 50%;
  border-right-width: 0;
  border-left-color: #333;
  left: calc(0em - 5px);
  transform: translate(-.5em, -50%);
}

[rsssl-tooltip][flow^="left"]::after {
  top: 50%;
  right: calc(100% + 5px);
  transform: translate(-.5em, -50%);
}

/* FLOW: RIGHT */
[rsssl-tooltip][flow^="right"]::before {
  top: 50%;
  border-left-width: 0;
  border-right-color: #333;
  right: calc(0em - 19px);
  transform: translate(.5em, -50%);
}

[rsssl-tooltip][flow^="right"]::after {
  top: 50%;
  left: calc(100% + 19px);
  transform: translate(.5em, -50%);
  min-width:300px;
}

/* KEYFRAMES */
@keyframes tooltips-vert {
  to {
    opacity: .9;
    transform: translate(-50%, 0);
  }
}

@keyframes tooltips-horz {
  to {
    opacity: .9;
    transform: translate(0, -50%);
  }
}

/* FX All The Things */
[rsssl-tooltip]:not([flow]):hover::before,
[rsssl-tooltip]:not([flow]):hover::after,
[rsssl-tooltip][flow^="up"]:hover::before,
[rsssl-tooltip][flow^="up"]:hover::after,
[rsssl-tooltip][flow^="down"]:hover::before,
[rsssl-tooltip][flow^="down"]:hover::after {
  animation: tooltips-vert 300ms ease-out forwards;
}

[rsssl-tooltip][flow^="left"]:hover::before,
[rsssl-tooltip][flow^="left"]:hover::after,
[rsssl-tooltip][flow^="right"]:hover::before,
[rsssl-tooltip][flow^="right"]:hover::after {
  animation: tooltips-horz 300ms ease-out forwards;
}
