/* https://dev.to/alvaromontoro/create-a-tag-cloud-with-html-and-css-1e90 */

html, body {
  height: 100vh;
  width: 100vw;
  margin: 0;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

ul.cloud {
  list-style: none;
  padding-left: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  line-height: 4rem;
  width: 1000px;
}

ul.cloud a {
  /*   
  Not supported by any browser at the moment :(
  --size: attr(data-weight number); 
  */
  --size: 4;
  --color: rgb(0, 217, 255);
  color: var(--color);
  font-size: calc(var(--size) * 0.25rem + 0.5rem);
  display: block;
  padding: 0.125rem 0.25rem;
  position: relative;
  text-decoration: none;
  /* 
  For different tones of a single color /*
  opacity: calc((15 - (9 - var(--size))) / 15); 
  */
}

ul.cloud a[data-weight="1"] { --size: 2; }
ul.cloud a[data-weight="2"] { --size: 4; }
ul.cloud a[data-weight="3"] { --size: 8; }
ul.cloud a[data-weight="4"] { --size: 10; }
ul.cloud a[data-weight="5"] { --size: 12; }
ul.cloud a[data-weight="6"] { --size: 14; }
ul.cloud a[data-weight="7"] { --size: 16; }
ul.cloud a[data-weight="8"] { --size: 21; }
ul.cloud a[data-weight="9"] { --size: 24; }

ul[data-show-value] a::after {
  content: " (" attr(data-weight) ")";
  font-size: 1rem;
}

ul.cloud li:nth-child(2n+1) a { --color: rgb(221, 223, 230); }
ul.cloud li:nth-child(3n+1) a { --color: rgb(6, 77, 117); }
ul.cloud li:nth-child(4n+1) a { --color: rgb(5, 212, 126); }

ul.cloud a:focus {
  outline: 1px dashed;
}

ul.cloud a::before {
  content: "";
  position: absolute;
  top: 0;
  left: 50%;
  width: 0;
  height: 100%;
  background: var(--color);
  transform: translate(-50%, 0);
  opacity: 0.15;
  transition: width 0.25s;
}

ul.cloud a:focus::before,
ul.cloud a:hover::before {
  width: 100%;
}

@media (prefers-reduced-motion) {
  ul.cloud * {
    transition: none !important;
  }
}