:root {
  --font-default: 1.4rem;
  --font-small: 1.2rem;
  --font-color: #333333;
  --clickable: rgb(0, 102, 153);
  --active: #b31e00;
  --white: #ffffff;
  --grey-light: #efefef;
  --grey-middle: #999999;
  --grey-dark: #666666;
  --space: 1rem;
  --border-radius: .25rem;
  --header-height: 5rem;
}
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}
html {
  font-size: 62.5%;
  @media screen and (min-width: 768px), print {
    font-size: 65%;
  }
  @media screen and (min-width: 1024px), print {
    font-size: 70%;
  }
  @media screen and (min-width: 2540px), print {
    font-size: 75%;
  }
}
body {
  font-family:
    Arial,
    Helvetica,
    sans-serif;
  font-weight: 400;
  font-size: var(--font-default);
  line-height: 1.25;
  color: var(--font-color);
  min-height: 100vh;
}
::selection {
  background-color: var(--clickable);
  color: #fff;
}
img,
svg {
  display: block;
}
h1 {
  font-size: 1.4rem;
}
h2 {
  font-size: 2rem;
}
.hidden {
  display: none;
}
.invisible {
  visibility: hidden;
}
#loader {
  --loading-width: 5rem;
  --loading-height: 5rem;
  --loading-color1: #ffffff;
  --loading-color2: transparent;
  position: absolute;
  inset: 0;
  z-index: 50;
  background-color: #000000bf;
  &:before {
    content: " ";
    position: absolute;
    top: calc(50% - var(--loading-width) / 2);
    left: calc(50% - var(--loading-height) / 2);
    width: var(--loading-width);
    height: var(--loading-height);
    background-color: transparent;
    border: 2px solid;
    border-color: var(--loading-color1) var(--loading-color2);
    border-radius: 50%;
    animation: loader 1s linear infinite;
  }
  .error-message {
    color: var(--white);
    background-color: red;
    position: absolute;
    top: 20%;
    left: 50%;
    transform: translate(-50%);
    z-index: 51;
    padding: .5rem 1rem;
    box-shadow: .2rem .2rem .5rem #00000080;
    border-radius: .3rem;
  }
}
@keyframes loader {
  0% {
    transform: rotate(0);
  }
  to {
    transform: rotate(360deg);
  }
}
.header {
  background-color: var(--grey-light);
  box-shadow: 0 0 .5rem #999;
  height: var(--header-height);
  display: flex;
  justify-content: space-between;
  align-items: stretch;
  .header-col {
    display: flex;
    align-items: center;
    &.header-col-right {
      align-self: center;
    }
  }
  .logo {
    height: 100%;
    a {
      width: 100%;
      height: 100%;
      padding: var(--space);
      color: var(--white);
      text-decoration: none;
      background-color: var(--clickable);
      display: flex;
      justify-content: center;
      align-items: center;
      white-space: nowrap;
    }
  }
  .backlink-container {
    display: none;
    #backlink {
      color: var(--clickable);
      text-decoration: none;
      padding-left: 2.5rem;
      margin-left: 2.5rem;
      position: relative;
      line-height: 1;
      white-space: nowrap;
      &:before {
        position: absolute;
        top: 50%;
        transform: translateY(-50%);
        left: 1rem;
        content: "";
        display: inline-block;
        width: 0;
        height: 0;
        border: calc(var(--space) / 2) solid transparent;
        border-right-color: var(--clickable);
      }
    }
  }
  .lang-menu {
    display: flex;
    padding-right: var(--space);
    a {
      display: block;
      color: var(--clickable);
      cursor: pointer;
      &.active {
        color: var(--font-color);
        cursor: default;
      }
      &:not(:last-of-type) {
        padding-right: calc(var(--space) / 2);
        border-right: 1px solid grey;
      }
      &:not(:first-of-type) {
        padding-left: calc(var(--space) / 2);
      }
    }
  }
}
.content {
  padding-top: var(--space);
}
.settings {
  margin: 1rem 0;
  padding: var(--space);
  background-color: var(--grey-light);
  box-shadow: 0 0 .5rem #999;
  .settings-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    #reset-button {
      color: var(--clickable);
      border: none;
      background: none;
      cursor: pointer;
      display: flex;
      align-items: center;
      justify-content: center;
      font-size: 1.2rem;
      width: 2rem;
      height: 2rem;
    }
  }
  .steps {
    border: 1px solid var(--grey-middle);
    border-radius: var(--border-radius);
    color: var(--clickable);
    background-color: var(--white);
    margin-top: calc(var(--space) / 2);
    overflow: hidden;
    .step {
      position: relative;
      display: flex;
      padding: var(--space);
      padding-left: 3rem;
      cursor: pointer;
      color: var(--clickable);
      background-color: var(--white);
      &:not(:last-of-type) {
        border-bottom: 1px solid var(--grey-middle);
      }
      .step-number {
        display: flex;
        justify-content: center;
        align-content: center;
        width: 2rem;
        height: 2rem;
        margin-right: 1rem;
        font-weight: 700;
        line-height: 1;
        border-radius: 100%;
        color: currentColor;
        border: 2px solid currentColor;
        pointer-events: none;
        padding-top: .05rem;
      }
      .step-title {
        pointer-events: none;
        padding-top: .1rem;
      }
      &.active {
        color: var(--active);
        cursor: default;
        background-color: var(--white);
        &:before {
          position: absolute;
          top: 50%;
          transform: translateY(-50%);
          left: 1rem;
          content: "";
          display: inline-block;
          width: 0;
          height: 0;
          border: calc(var(--space) / 2) solid transparent;
          border-left-color: currentColor;
        }
      }
    }
  }
}
.stepper-buttons {
  display: none;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space);
  margin-top: 1rem;
  .stepper-button {
    background-color: var(--white);
    color: var(--clickable);
    border: 1px solid var(--clickable);
    padding: var(--space);
    cursor: pointer;
    border-radius: var(--border-radius);
    display: flex;
    justify-content: center;
    align-items: center;
    &.disabled {
      opacity: .5;
      cursor: default;
    }
    svg {
      width: var(--font-default);
      height: var(--font-default);
      margin: 0 calc(var(--space) / 2);
      pointer-events: none;
    }
  }
}
.filter {
  margin-top: 3rem;
  margin-bottom: 3rem;
  &.in-active {
    display: none;
  }
  .field {
    margin-bottom: var(--space);
    label {
      font-size: var(--font-default);
      font-weight: 700;
    }
  }
  .segmentation.disabled {
    opacity: .5;
    cursor: not-allowed;
    * {
      pointer-events: none;
    }
    .toggler {
      opacity: .5;
    }
  }
  #topic-field label,
  #region-field label,
  #region-type-field label,
  .step-title {
    font-size: 1.8rem !important;
    font-weight: 700;
    display: inline-block;
    margin-bottom: calc(var(--space) / 2);
  }
  select {
    width: 100%;
    border: 1px solid var(--clickable);
    color: var(--clickable);
    background-color: var(--white);
    padding: calc(var(--space) / 2) 1rem;
    margin-top: .25rem;
    font-family: inherit;
    font-size: inherit;
    border-radius: var(--border-radius);
  }
  .segmentation {
    margin-bottom: var(--space);
  }
  #segmentation-label-all-regions,
  #segmentation-label-all-classifications {
    font-size: var(--font-default);
  }
  .segmentation-hint {
    color: var(--grey-dark);
    font-size: 80%;
    margin-bottom: 1rem;
  }
  #classification-total-text {
    font-size: var(--font-small);
    line-height: 1.5;
    hyphens: auto;
    margin-bottom: 2rem;
  }
  #classification-filter {
    margin-top: var(--space);
  }
  #filters {
    margin-top: 3rem;
    cursor: not-allowed;
    label,
    .disabled {
      color: #999;
    }
  }
}
.main {
  padding: var(--space);
  .main-header {
    .visualization-buttons {
      display: grid;
      grid-template-columns: repeat(2, 1fr);
      gap: var(--space);
      button {
        position: relative;
        background-color: var(--white);
        border: 2px solid var(--clickable);
        color: var(--clickable);
        padding: .5rem 3rem;
        border-radius: var(--border-radius);
        cursor: pointer;
        display: flex;
        justify-content: center;
        align-items: center;
        &.active {
          cursor: default;
          background-color: var(--white);
          border-color: var(--active);
          color: var(--active);
          &:before {
            position: absolute;
            top: 50%;
            transform: translateY(-50%);
            left: 1rem;
            content: "";
            display: inline-block;
            width: 0;
            height: 0;
            border: calc(var(--space) / 2) solid transparent;
            border-left-color: currentColor;
          }
        }
        svg {
          width: 2rem;
          height: 2rem;
          margin: 0 calc(var(--space) / 2);
          pointer-events: none;
        }
        .mode-button-label {
          display: block;
          pointer-events: none;
        }
      }
    }
    .visualize-link {
      text-align: center;
      font-size: var(--font-small);
      margin-top: var(--space);
      margin-bottom: var(--space);
      a {
        color: var(--clickable);
        text-decoration: none;
      }
    }
  }
  #main-content {
    flex-grow: 1;
  }
}
#chart {
  width: 100%;
  height: auto;
  aspect-ratio: 1/1.5;
  border: none;
}
@media screen and (min-width: 768px) {
  #chart {
    aspect-ratio: 1;
  }
  .settings {
    display: flex;
    gap: calc(3 * var(--space));
    .settings-top,
    .settings-bottom {
      flex-basis: 50%;
    }
  }
}
@media screen and (min-width: 1024px) {
  #chart {
    height: 100%;
    width: auto;
    max-width: 100%;
    aspect-ratio: 4/3;
    &.map {
      aspect-ratio: 1;
    }
  }
  .settings {
    display: block;
    box-shadow: none;
    margin: 0;
    .steps {
      .step {
        .step-number {
          padding-top: .15rem;
        }
      }
    }
  }
  .stepper-buttons {
    display: grid;
  }
  .content {
    display: flex;
    gap: var(--space);
    height: calc(100vh - var(--header-height));
    overflow: hidden;
    .settings {
      flex-basis: 30rem;
      overflow-y: auto;
    }
    .main-header {
      display: flex;
      justify-content: space-between;
      align-items: center;
      margin-bottom: var(--space);
    }
    .main {
      flex-grow: 1;
      display: flex;
      flex-direction: column;
      padding: 0 var(--space) var(--space) 0;
    }
  }
}
@media screen and (min-width: 1600px) {
  .content {
    .settings {
      flex-basis: 35rem;
    }
  }
  .filter {
    #filters {
      margin-top: 6rem;
    }
  }
}
.toggler {
  appearance: none;
  -webkit-appearance: none;
  -webkit-tap-highlight-color: transparent;
  position: relative;
  border: 0;
  outline: 0;
  cursor: pointer;
  display: inline-block;
  top: .4rem;
  width: 4rem;
  &:after {
    content: "";
    width: 4rem;
    height: 2rem;
    display: inline-block;
    background: #c4c3c38c;
    border-radius: 2rem;
    clear: both;
  }
  &:before {
    content: "";
    width: 1.7rem;
    height: 1.7rem;
    display: block;
    position: absolute;
    left: .2rem;
    top: .15rem;
    border-radius: 50%;
    background: #fff;
    transition: left .2s ease-in-out;
  }
  &:checked:before {
    left: 2.1rem;
    transition: left .2s ease-in-out;
    box-shadow: -.1rem .1rem .3rem #0009;
  }
  &:checked:after {
    background: var(--clickable);
  }
}
