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

body {
  -webkit-font-smoothing: antialiased;
}

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

input,
button,
textarea,
select {
  font: inherit;
}

ul,
ol {
  list-style: none;
}

a {
  color: currentColor;
}

/* Variables */
:root {
  --font-size-sm: clamp(0.8rem, 0.25vi + 0.74rem, 0.94rem);
  --font-size-base: clamp(1rem, 0.45vi + 0.89rem, 1.25rem);
  --font-size-md: clamp(1.25rem, 0.76vi + 1.06rem, 1.67rem);
  --font-size-lg: clamp(1.56rem, 1.2vi + 1.26rem, 2.22rem);
  --font-size-xl: clamp(1.95rem, 1.83vi + 1.5rem, 2.96rem);
  --font-size-xxl: clamp(2.44rem, 2.74vi + 1.76rem, 3.95rem);
  --font-size-xxxl: clamp(3.05rem, 4.02vi + 2.05rem, 5.26rem);

  --font-size-vis-xs: 10px;
  --font-size-vis-sm: 12px;
  --font-size-vis-base: 14px;
  --font-size-vis-lg: 16px;

  --font-family: "Roboto Condensed", sans-serif;

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

  --line-height-body: 1.5;
  --line-height-header: 1.1;

  --color-background: #ffffff;
  --color-text: #1b191a;
  --color-title: #1b191a;
  --color-bubble-background: #ededed;
  --color-bubble-text: #1b191a;
  --color-sort-arrow: #a8a9ad;
  --color-bar-track: #ededed;
  --color-bar-fill: #e80f20;
  --color-bar-label: #ffffff;
  --color-bar-label-outside: #1b191a;
}

/* Typography */
body {
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-normal);
  line-height: var(--line-height-body);
  color: var(--color-text);
  background-color: var(--color-background);
}

h1 {
  color: var(--color-title);
  font-size: var(--font-size-xxl);
  font-weight: var(--font-weight-bold);
  line-height: var(--line-height-header);
}

footer {
  font-size: var(--font-size-sm);
}

/* Layout */
main {
  position: relative;
  margin: 4rem auto;
  width: min(80rem, 100% - 2rem);
}

main > * + * {
  margin-block-start: var(--spacer, 1lh);
}

.chat-bubble {
  max-width: 45ch;
  padding: 0.5em 1em;
  color: var(--color-bubble-text);
  background-color: var(--color-bubble-background);
  border-radius: 1em 1em 1em 0.25em;
}

/* Form */
.form-checkbox {
  accent-color: currentColor;
}

/* Small multiples bar chart */
.table-scroll {
  max-width: 100%;
  overflow-x: auto;
}

.small-multiples-bar-chart {
  --cell-padding-left: 24px;
  --cell-padding-right: 4px; /* half arrow width */
  font-size: var(--font-size-vis-base);
  font-variant-numeric: tabular-nums;
}

.small-multiples-bar-chart table {
  width: 100%;
  min-width: 800px;
  table-layout: fixed;
  border-collapse: collapse;
  text-wrap: nowrap;
  overflow: visible;
}

.small-multiples-bar-chart th {
  text-align: left;
}

.small-multiples-bar-chart th:not(:first-child),
.small-multiples-bar-chart td:not(:first-child) {
  padding-left: var(--cell-padding-left);
  padding-right: var(--cell-padding-right);
}

.small-multiples-bar-chart th button {
  cursor: pointer;
  font: inherit;
  color: inherit;
  background: none;
  border: none;
  display: flex;
  align-items: center;
  gap: 4px;
}

.small-multiples-bar-chart .column-sort {
  color: var(--color-sort-arrow);
}

.small-multiples-bar-chart .column-title {
  font-size: var(--font-size-vis-lg);
}

.small-multiples-bar-chart td[data-type="text"] {
  padding-block: 8px;
}

.small-multiples-bar-chart .bar {
  --bar-height: 20px;
  width: 100%;
  height: var(--bar-height);
  position: relative;
  display: grid;
}

.small-multiples-bar-chart .bar > * {
  grid-area: 1 / -1;
}

.small-multiples-bar-chart .bar__track {
  width: 100%;
  height: 100%;
  background-color: var(--color-bar-track);
}

.small-multiples-bar-chart .bar__fill {
  height: 100%;
  background-color: var(--color-bar-fill);
  position: relative;
}

.small-multiples-bar-chart .bar__label {
  line-height: var(--bar-height);
  color: var(--color-bar-label);
  position: absolute;
  right: 4px;
}

.small-multiples-bar-chart .bar__label.outside {
  color: var(--color-bar-label-outside);
  left: calc(100% + 4px);
}

.small-multiples-bar-chart .bar__ref {
  position: absolute;
  left: 0;
  bottom: 100%;
  color: var(--color-sort-arrow);
  display: none;
}

:has(#showRefCheckbox:checked) .small-multiples-bar-chart .bar__ref {
  display: block;
}

/* Utilities */
.sr-only {
  position: absolute;
  left: -10000px;
  top: auto;
  width: 1px;
  height: 1px;
  overflow: hidden;
}
