*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

svg {
  display: block;
  max-width: 100%;
  height: auto;
}

:root {
  --font-heading: "Lora", serif;
  --font-body: "Rubik", sans-serif;

  --font-weight-normal: 400;
  --font-weight-medium: 500;
  --font-weight-bold: 700;

  --font-size-0: 0.75rem;
  --font-size-1: 1rem;
  --font-size-2: 1.333rem;
  --font-size-3: 1.777rem;
  --font-size-4: 2.369rem;
  --font-size-5: 3.157rem;

  --line-height-0: 1.5;
  --line-height-1: 1.5;
  --line-height-2: 1.5;
  --line-height-3: 1.5;
  --line-height-4: 1.2;
  --line-height-5: 1.2;

  --color-bg: #fff;
  --color-text: #212529;
  --color-tick: #adb5bd;
  --color-active: #fcc419;
}

body {
  font-family: var(--font-body);
  font-weight: var(--font-weight-normal);
  font-size: var(--font-size-1);
  line-height: var(--line-height-1);
  color: var(--color-text);
  background-color: var(--color-bg);
}

h1 {
  font-family: var(--font-heading);
  font-weight: var(--font-weight-medium);
  font-size: var(--font-size-4);
  line-height: var(--line-height-4);
}

p {
  text-wrap: pretty;
}

a {
  color: currentColor;
}

section {
  width: min(100% - 2rem, var(--container-max, 60ch));
  margin-inline: auto;
  margin-block: 4rem;
}

.intro {
  --container-max: 80ch;
  display: flex;
  flex-direction: column;
  gap: 1em;
}

fieldset {
  border: 0;
  min-width: 0;
  display: flex;
  align-items: center;
  font-weight: var(--font-weight-bold);
}

legend {
  float: left;
  margin-inline-end: 1em;
}

fieldset input[type="radio"] {
  position: absolute;
  clip: rect(0, 0, 0, 0);
  pointer-events: none;
}

fieldset label {
  display: inline-block;
  padding: 0.375em 0.75em;
  border-radius: 0.375em;
  border: 2px solid transparent;
  cursor: pointer;
}

fieldset input[type="radio"]:checked + label {
  border-color: currentColor;
}

.vis {
  --container-max: 90rem;
  --gap: 2rem;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--gap);
}

.vis > :first-child {
  flex: 0 1 32rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--gap);
}

.vis > :last-child {
  flex: 0 1 52rem;
  display: flex;
  align-items: center;
}

svg text {
  font-size: var(--font-size-0);
  fill: currentColor;
}

.legend {
  font-size: var(--font-size-0);
  display: grid;
  grid-template-areas:
    ".    top    ."
    "left grid   right"
    ".    bottom .";
  grid-template-columns: repeat(3, auto);
  grid-template-rows: repeat(3, auto);
  align-items: center;
  justify-items: center;
  gap: 0.5em;
}

.legend .annotation__top {
  grid-area: top;
  text-align: center;
}

.legend .annotation__right {
  grid-area: right;
  text-align: left;
}

.legend .annotation__bottom {
  grid-area: bottom;
  text-align: center;
}

.legend .annotation__left {
  grid-area: left;
  text-align: right;
}

.legend svg {
  grid-area: grid;
  overflow: visible;
}

.axis-title {
  font-weight: var(--font-weight-bold);
}

.scatter,
.choropleth {
  width: 100%;
  display: grid;
  grid-template-areas: "stack";
}

.scatter > *,
.choropleth > * {
  grid-area: stack;
}

.scatter .axis .domain {
  display: none;
}

.scatter .axis line {
  stroke: var(--color-tick);
}

.scatter .threshold {
  stroke: var(--color-tick);
  stroke-dasharray: 4;
}

.scatter .active__circle,
.choropleth .active__path {
  fill: none;
  stroke: var(--color-active);
  stroke-width: 2;
}

.tooltip {
  font-size: var(--font-size-0);
  line-height: var(--line-height-0);
  position: fixed;
  top: 0;
  left: 0;
  pointer-events: none;
  padding: 0.375em 0.75em;
  border-radius: 0.375em;
  background-color: var(--color-bg);
  border: 2px solid var(--color-border);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.15s ease-in-out, visibility 0.15s ease-in-out;
}

.tooltip.visible {
  opacity: 1;
  visibility: visible;
}

.tooltip table {
  border-collapse: collapse;
}

.tooltip th,
.tooltip td {
  padding: 0.125em;
}

.tooltip th {
  text-align: start;
}

.tooltip td {
  text-align: end;
}
