/* --- CSS Variables --- */

:root {
  --font-family: 'Darker Grotesque', sans-serif;

  --slider-offset: 50px;
  --slider-ticks-num: 2;
  --slider-background-size: 25% 1rem, 100% 0.25rem;
  --slider-color: #13c8c8;
}

svg {
  font-family: var(--font-family);
}

/* --- Chart specific --- */

.voronoi {
  /* Keep space for ephemeral "replaces" text; center content */
  margin-top: 16px;
  text-align: center;
}

/*
 * Determine width based upon number of charts shown
 * source: https://stackoverflow.com/questions/8720931/can-css-detect-the-number-of-children-an-element-has
 */

/* FOR SMALL WIDTHS */

/* always stacked */
.voronoi {
  min-width: 100%;
}

.voronoi:first-child {
  margin-top: 0;
}

/* FOR MEDIUM WIDTHS */
@media (min-width: 600px) {

  /* one item*/
  .voronoi:first-child:nth-last-child(1) {
    min-width: 100%;
    margin-top: 0;
  }

  /* two items: 1, 1 */
  .voronoi:first-child:nth-last-child(2),
  .voronoi:first-child:nth-last-child(2)~.voronoi {
    min-width: calc(100% / 2);
    margin-top: 0;
  }

  /* .voronoi:first-child:nth-last-child(2) {
        margin-top: 0;
    }
    .voronoi:first-child:nth-last-child(2),
    .voronoi:first-child:nth-last-child(2) ~ .voronoi {
        width: 100%;
    } */

  /* three items: 1, 2 */
  .voronoi:first-child:nth-last-child(3) {
    min-width: 100%;
    margin-top: 0;
  }

  .voronoi:first-child:nth-last-child(3)~.voronoi {
    min-width: calc(100% / 2);
  }

  /* four items: 2, 2 */
  .voronoi:first-child:nth-last-child(4),
  .voronoi:first-child:nth-last-child(4)~.voronoi {
    min-width: calc(100% / 2);
  }

  .voronoi:first-child:nth-last-child(4),
  .voronoi:first-child:nth-last-child(4)~.voronoi:nth-last-child(3) {
    margin-top: 0;
  }

  /* five items: 1, 2, 2 */
  .voronoi:first-child:nth-last-child(5) {
    min-width: 100%;
    margin-top: 0;
  }

  .voronoi:first-child:nth-last-child(5)~.voronoi {
    min-width: calc(100% / 2);
  }
}

/* FOR FULL WIDTHS */
@media (min-width: 900px) {

  /* one item*/
  .voronoi:first-child:nth-last-child(1) {
    min-width: calc(100%);
    margin-top: 0;
  }

  /* two items: 2 */
  .voronoi:first-child:nth-last-child(2),
  .voronoi:first-child:nth-last-child(2)~.voronoi {
    min-width: calc(100% / 2);
    margin-top: 0;
  }

  /* three items: 1, 2 */
  .voronoi:first-child:nth-last-child(3),
  .voronoi:first-child:nth-last-child(3)~.voronoi {
    min-width: calc(100% / 2);
  }

  .voronoi:first-child:nth-last-child(3),
  .voronoi:first-child:nth-last-child(3)~.voronoi:nth-last-child(3) {
    min-width: calc(100%);
    margin-top: 0;
  }

  /* four items: 2, 2 */
  .voronoi:first-child:nth-last-child(4),
  .voronoi:first-child:nth-last-child(4)~.voronoi {
    min-width: calc(100% / 2);
  }

  .voronoi:first-child:nth-last-child(4),
  .voronoi:first-child:nth-last-child(4)~.voronoi:nth-last-child(3) {
    margin-top: 0;
  }

  /* five items: 1, 2, 2 */
  .voronoi:first-child:nth-last-child(5),
  .voronoi:first-child:nth-last-child(5)~.voronoi {
    min-width: calc(100% / 2);
  }

  .voronoi:first-child:nth-last-child(5),
  .voronoi:first-child:nth-last-child(5)~.voronoi:nth-last-child(5) {
    min-width: calc(100%);
    margin-top: 0;
  }
}

.voronoi .title {
  font-size: 30px;
  font-weight: 400;
  text-anchor: middle;
}

.voronoi .change-text {
  text-anchor: middle;
  fill: #f8009a;
  font-size: 1.1rem;
}

.voronoi-text-group {
  pointer-events: none;
}

.voronoi .label-value,
.voronoi .label-name,
.voronoi .label-sub-title {
  pointer-events: none;
  font-weight: 500;
  text-anchor: middle;
}

.voronoi .label-name {
  font-size: 1rem;
  font-weight: 500;
  letter-spacing: 0.01rem;
}

.voronoi .label-value {
  font-size: 0.8rem;
  opacity: 0.8;
}

.voronoi .label-sub-title {
  font-size: 0.6rem;
  opacity: 0.6;
}

.voronoi-text-group-top .label-name {
  fill: white;
}

.voronoi-text-group-top .label-value {
  fill: white;
}

.voronoi-text-group-top .label-sub-title {
  fill: white;
}

.voronoi .enclosing-circle-label {
  font-size: 0.9rem;
  font-weight: 500;
  letter-spacing: 0.01rem;
  text-anchor: end;
  fill: #797d8b;
}

.voronoi .enclosing-circle-value {
  font-size: 1.3rem;
  font-weight: 500;
  text-anchor: end;
  fill: #212428;
  /* letter-spacing: 0.01rem; */
}

.voronoi .enclosing-circle,
.voronoi .enclosing-circle-line {
  fill: none;
  stroke: rgb(200, 200, 200);
  stroke-width: 1.5;
  stroke-linecap: round;
}

/* ----------- Voronoi legend ------------- */

#voronoi-legend {
  max-width: 900px;
  margin: 10px auto;
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  font-family: var(--font-family);
  font-size: 1rem;
  font-weight: 600;
  color: rgb(108, 108, 124);
  letter-spacing: 0.01rem;
}

.voronoi-legend-item {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  justify-content: flex-start;
  align-items: center;
  margin: 0.1rem 0.5rem;
}

.voronoi-legend-item img {
  width: 100%;
  margin: 5px;
  max-width: 16px;
  height: auto;
}

/* ----------- Range slider ------------- */

#slider-container {
  font-family: var(--font-family);
  margin: 10px auto;
  max-width: 500px;
  width: 100%;
  text-align: center;
}

#poll-slider {
  -webkit-appearance: none;
  width: 100%;
  height: 4px;
  border-radius: 2px;
  background: none;
  /* background: #d7dcdf; */
  outline: none;
  padding: 0;
  margin: 0 0 10px 0;
}

#poll-slider #thumb {
  position: relative;
}

#poll-slider:after {
  content: "";
  width: 1rem;
  height: 1rem;
  border-radius: 50%;
  background: #d7dcdf;
  position: absolute;
  right: 0;
}

#poll-slider:before {
  content: "";
  position: absolute;
  left: 0;
  right: 1rem;
  height: 1rem;
  background: radial-gradient(circle at 0.5rem 50%, #d7dcdf 0.3125rem, #d7dcdf 0.3125rem, #d7dcdf 0.5rem, transparent 0.5rem), linear-gradient(90deg, transparent 0, #d7dcdf 0) repeat-x 0 50%;
  box-sizing: border-box;
  margin: 0;
}

#poll-slider:before {
  background-size: var(--slider-background-size);
}

#poll-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  /* background: #282828; */
  background: var(--slider-color);
  cursor: pointer;
  transition: .15s ease-in-out;
  z-index: 10;
  margin-top: 12px;
  position: relative;
}

#poll-slider::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border: 0;
  border-radius: 50%;
  background: var(--slider-color);
  cursor: pointer;
  transition: .15s ease-in-out;
  z-index: 10;
}

#poll-slider::-webkit-slider-thumb:hover {
  background: var(--slider-color);
  box-shadow: 0 0 0 3px #fff, 0 0 0 6px var(--slider-color);
}

#poll-slider:active::-webkit-slider-thumb {
  background: var(--slider-color);
}

#poll-slider::-moz-range-thumb:hover {
  background: var(--slider-color);
  box-shadow: 0 0 0 3px #fff, 0 0 0 6px var(--slider-color);
}

#poll-slider:active::-moz-range-thumb {
  background: var(--slider-color);
}

#poll-slider:focus::-webkit-slider-thumb {
  /* box-shadow: 0 0 0 3px #fff, 0 0 0 6px var(--slider-color); */
}

::-moz-range-track {
  background: #d7dcdf;
  border: 0;
}

input::-moz-focus-inner,
input::-moz-focus-outer {
  border: 0;
}

#slider-container #slider-ticks {
  position: relative;
  display: flex;
  justify-content: space-between;
  height: auto;
  bottom: 11px;
  text-align: center;
  -webkit-user-select: none;
  /* Safari */
  -moz-user-select: none;
  /* Firefox */
  -ms-user-select: none;
  /* IE10+/Edge */
  user-select: none;
  /* Standard */
  pointer-events: none;
}

/* Specific settings depending on the number of polls */
#range-container {
  width: calc(100% - 10px);
  display: inline-block;
  /* margin-left: var(--slider-offset); */
  position: relative;
}


#slider-container #slider-ticks span {
  width: calc(100% / var(--slider-ticks-num));
  white-space: nowrap;
  height: 40px;
  padding: 0;
  line-height: 55px;
  font-size: 16px;
  font-weight: 400;
  letter-spacing: 0.02rem;
}

@media (max-width: 480px) {
  #slider-container #slider-ticks span {
    transform: rotate(70deg);
    position: relative;
    left: 16px;
    top: 16px;
    text-align: left;
  }

  #slider-container .arrow-left {
    display: none;
  }

  #slider-container .arrow-right {
    display: none;
  }
}

@media (min-width: 480px) {
  #range-container {
    width: calc(100% - 70px);
  }
}