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

html {
  -webkit-text-size-adjust: none;
  text-size-adjust: none;
  -webkit-font-smoothing: antialiased;
}

a {
  color: currentColor;
}

svg {
  display: block;
  max-inline-size: 100%;
  block-size: auto;
}

:root {
  --font-size-9xl: 9.313rem;
  --font-size-8xl: 7.451rem;
  --font-size-7xl: 5.96rem;
  --font-size-6xl: 4.768rem;
  --font-size-5xl: 3.815rem;
  --font-size-4xl: 3.052rem;
  --font-size-3xl: 2.441rem;
  --font-size-2xl: 1.953rem;
  --font-size-xl: 1.563rem;
  --font-size-lg: 1.25rem;
  --font-size-md: 1rem;
  --font-size-sm: 0.8rem;
  --font-size-xs: 0.64rem;

  --font-size-vis-lg: 18px;
  --font-size-vis-md: 16px;
  --font-size-vis-sm: 14px;
  --font-size-vis-xs: 12px;

  --font-family-heading: "Bangers", system-ui;
  --font-family-body: "Open Sans", sans-serif;

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

  --line-height-title: 1;
  --line-height-body: 1.4;

  --color-background: #f5f1de;
  --color-text: #231f20;
  --color-summer: #aa3d31;
  --color-winter: #027385;
  --color-spring-fall: #dfdccc;
}

body {
  font-family: var(--font-family-body);
  font-size: var(--font-size-md);
  font-weight: var(--font-weight-normal);
  line-height: var(--line-height-body);
  font-variation-settings: "wdth" 87.5;
  color: var(--color-text);
  background-color: var(--color-background);
}

h1 {
  font-family: var(--font-family-heading);
  font-size: var(--font-size-6xl);
  font-weight: var(--font-weight-normal);
  line-height: var(--line-height-title);
  letter-spacing: 0.04em;
  text-wrap: balance;
  color: var(--color-text-accent);
}

footer {
  display: grid;
  gap: 0.5rem;
}

main {
  margin-block: 4rem;
}

article {
  width: min(100% - 2rem, 75rem);
  margin-inline: auto;
  display: grid;
  gap: 2rem;
}

.segmented {
  --n: 3;
  --max-width: 24rem;

  --color-bg: var(--color-spring-fall);
  --color-selected: var(--color-background);
  --color-hover: var(--color-background);

  border: 0;
  max-width: var(--max-width);
  margin-inline: auto;

  font-family: var(--font-family-heading);

  legend {
    margin-bottom: 0.25rem;
  }

  div {
    position: relative;
    isolation: isolate;
    display: grid;
    grid-template-columns: repeat(var(--n), 1fr);
    gap: 0.25rem;
    border: 0.25rem solid var(--color-bg);
    border-radius: 9999px;
    background: var(--color-bg);

    &::before {
      content: "";
      position: absolute;
      border-radius: 9999px;
      background: var(--color-selected);
      z-index: -1;

      position-anchor: --selected;
      top: anchor(top);
      right: anchor(right);
      bottom: anchor(bottom);
      left: anchor(left);
      transition-property: top, right, bottom, left;
      transition-duration: 0.3s;
      transition-timing-function: ease-in-out;
    }

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

    label {
      padding: 0.5rem 1.5rem;
      border-radius: 9999px;
      background: transparent;
      user-select: none;
      height: 100%;
      display: grid;
      place-items: center;
      text-align: center;

      input:not(:checked) + &:hover,
      input:not(:checked) + input:focus + & {
        background: var(--color-hover);
      }

      input:checked + & {
        anchor-name: --selected;
      }
    }
  }
}

.chart .row__label,
.chart .row__total {
  font-size: var(--font-size-vis-sm);
  fill: currentColor;
}

.chart .bar__rect {
  fill: currentColor;
}

.chart .bar__label {
  font-size: var(--font-size-vis-xs);
  font-weight: var(--font-weight-bold);
  fill: var(--color-background);
  stroke: currentColor;
  stroke-width: 4px;
  paint-order: stroke;
  stroke-linejoin: round;
  stroke-linecap: round;
}
