:root {
  --bg-color: #ffffff;
  --text-color: #484848;
  --icon-color: #949494;
  --gray-accent-1: #636363;
  --gray-accent-2: #555555;
  --gray-accent-3: #eeeeee;
  --gray-accent-4: #e1e1e1;
  --notice-color: #a0cefb;
  --warning-color: #d9c98d;
  --link-color: #2979bc;
  --visited-link-color: #8f5baa;
  --full-width: 720px;
  --map-color-1: rgba(253, 231, 37, 0.5);
  --map-color-2: rgba(122, 209, 81, 0.5);
  --map-color-3: rgba(34, 168, 132, 0.5);
  --map-color-4: rgba(42, 120, 142, 0.5);
  --map-color-5: rgba(65, 68, 135, 0.5);
  --map-color-6: rgba(68, 1, 84, 0.5);
}

html {
  font-size: 62.5%;
  height: 100%;
  scroll-padding-top: 2em;
  -webkit-text-size-adjust: 100%;
}

body {
  background-color: var(--bg-color);
  color: var(--text-color);
  font-size: 1.6rem;
  font-family: "Helvetica Neue", Arial, sans-serif;
  margin: 0 auto;
  line-height: 1.5;
  min-height: 100%;
  overflow: hidden scroll;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: var(--link-color);
  text-underline-offset: 0.15em;
  text-decoration-thickness: 0.05em;

  &:visited {
    color: var(--visited-link-color);
  }
}

table {
  border-collapse: collapse;
  margin: 1.5em auto;
  table-layout: fixed;
  overflow-x: auto;

  td,
  th {
    border: 1.5px solid var(--gray-accent-1);
    text-align: center;
    padding: 10px;
  }
}

h1,
h2,
h3,
h4,
h5,
h6 {
  line-height: 1.125;
}

.header-link {
  text-decoration: none;

  .header-link-icon {
    display: none;
    padding-left: 0.4em;
  }

  h1,
  h2,
  h3,
  h4,
  h5,
  h6 {
    color: var(--text-color);

    &:hover .header-link-icon,
    &:focus .header-link-icon,
    &:active .header-link-icon {
      display: inline;
    }
  }
}

hr {
  background-color: var(--gray-accent-1);
  border: 0;
  height: 1.5px;
  margin: 1.25em 0;
}

img {
  max-width: 100%;
  height: auto;
}

figure {
  margin: 1.6rem 0;

  figcaption {
    font-size: 1.4rem;
    font-style: italic;
    text-align: center;
    margin-top: 0.6rem;
    padding: 0 1rem;
  }
}

ul,
ol {
  box-sizing: border-box;
}

.hover-icon {
  svg {
    fill: var(--icon-color);
  }

  svg:hover {
    fill: var(--text-color);
  }
}

.content {
  position: relative;
  margin: auto;
  width: 100%;
  height: calc(100vh - 3.6em - 2px);

  /* Correct size on mobile Safari */
  height: calc(100svh - 3.6em - 2px);

  code {
    font-size: 1.5rem;
    padding: 0 0.4rem;
    font-family: Monaco, monospace;
    background-color: var(--gray-accent-4);
  }

  pre {
    display: block;
    white-space: pre;
    margin: 1.25em 0;
    padding: 1.25em;
    overflow-x: auto;
    word-break: break-all;
    word-wrap: break-word;
    border: thin solid var(--gray-accent-4);
    border-radius: 3px;
    font-family: Monaco, monospace;
  }

  pre code,
  pre {
    background-color: var(--gray-accent-3);
  }

  pre code {
    padding: 0;
  }

  >article {
    max-width: var(--full-width);
    margin: auto;
    padding: 1em 1.25em 1.25em;

    h2,
    h3,
    h4,
    h5 {
      margin: 1.5em auto 0.5em;
    }

    p {
      margin: 0.5em auto;
    }

    hr {
      margin: 2.5em auto;
    }

    blockquote p,
    .notice p,
    .warning p {
      margin: 0;
    }

    summary {
      cursor: pointer;
      margin-top: 1em;
      font-size: 1.17em;
      font-weight: bold;
    }
  }
}

.link-nowrap-nodec {
  color: var(--text-color) !important;
  text-decoration: none;
  white-space: nowrap;

  &:hover {
    text-decoration: underline;
  }
}

.navbar {
  position: relative;
  height: 3.6em;
  background-color: var(--bg-color);
  border-bottom: 1.5px solid var(--gray-accent-1);
}

.navbar-content {
  display: grid;
  grid-template-columns: min-content 1fr min-content;
  margin: auto;
  padding: 1em 2rem;
  align-items: baseline;

  >.navbar-title {
    font-size: 1.9rem;
    margin: 0;
    padding-top: 0.2em;
    white-space: nowrap;
    line-height: 1;
    z-index: 20;
  }

  >.navbar-internal-links {
    display: flex;
    flex-wrap: wrap;
    justify-content: end;
    list-style: none;
    text-transform: capitalize;
    margin: 0;
    padding: 0 0.4em 0 0;
    line-height: 1;
    z-index: 20;

    li {
      padding-right: 1em;
    }
  }

  >.navbar-external-links {
    display: flex;
    justify-content: space-between;
    min-width: calc(1.6em * 2 + 1rem);
    align-self: center;
    z-index: 20;
  }
}

.navbar-external-links>.navbar-external-link {
  display: block;
  width: 1.6em;
  height: 1.6em;

  >svg {
    width: 1.6em;
    height: 1.6em;
  }
}

blockquote,
.content pre,
.notice,
.warning {
  margin: 1.25em 0;
  padding: 1.25em;
  border: thin solid var(--gray-accent-1);
  background-color: var(--gray-accent-3);
  border-radius: 3px;
  box-sizing: border-box;
}

.notice::before,
.warning::before {
  border-right: 2px solid var(--text-color);
  border-bottom: 2px solid var(--text-color);
  border-bottom-right-radius: 3px;
  display: block;
  text-align: center;
  position: relative;
  left: -1.25em;
  top: -1.25em;
  padding: 2px 10px;
  font-weight: bold;
}

.notice::before {
  content: "NOTE";
  background: var(--notice-color);
  width: 5rem;
}

.warning::before {
  content: "WARNING";
  background: var(--warning-color);
  width: 8rem;
}

#map {
  height: 100%;
  width: 100%;
}

#map-info {
  position: absolute;
  bottom: 10px;
  left: 10px;
  background-color: rgba(255, 255, 255, 0.75);
  padding: 10px;
  border-radius: 5px;
  font-family: Arial, sans-serif;
  font-size: 1.2em;
  pointer-events: none;
}

#map-spinner {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 6px;
  background: #3498db;
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.6s ease, opacity 0.4s ease-out 0.1s;
  z-index: 10;
}

.spinner-fade-out {
  opacity: 0 !important;
}

#map-color-scale {
  position: absolute;
  top: 10px;
  right: 10px;
  background-color: #ffffff;
  padding: 10px;
  border-radius: 5px;
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.1);
  min-width: 94px;

  span {
    font-size: 1.1em;
  }

  #legend-title > h2 {
    font-size: 1.2em;
    margin-top: 0;
    margin-bottom: 0.4em;
  }

  .dropdown-container {
    display: block;
    margin-top: 0.6em;
    margin-bottom: 0;
    width: 100%;

    label {
      display: block;
      font-weight: bold;
      font-size: 1.2em;
      margin-bottom: 0.2em;
    }

    select {
      width: 100%;
      font-size: 1.2em;
    }
  }

  div {
    position: relative;
    display: flex;
    margin-bottom: 3px;

    div {
      width: 20px;
      height: 20px;
      margin-right: 10px;
    }

    &:last-child {
      margin-bottom: 0;
    }
  }
}

#map-color-scale.collapsed {
  padding: 0;
  min-width: 30px;
  min-height: 30px;

  >div:not(:last-child) {
    display: none;
  }
}

#map-color-scale-toggle {
  position: absolute;
  top: 0;
  right: 0;
  background: none;
  border: none;
  font-size: 20px;
  color: var(--text-color);
  cursor: pointer;
  min-width: 30px;
  min-height: 30px;
  padding: 0;
  vertical-align: middle;
  line-height: 1;
}

/* support for Edge */
@supports (-ms-ime-align: auto) {
  .navbar-content>.navbar-internal-links {
    justify-content: space-around;
    margin: 0 1.4rem;
  }
}

/* adjustment when very small */
@media only screen and (min-width: 1px) and (max-width: 720px) {
  html {
    scroll-padding-top: 1.5em;
  }

  .navbar-content {
    >.navbar-title {
      padding-top: 0;
      line-height: 1.5;
    }

    >.navbar-internal-links {
      line-height: 1.5;
      justify-content: start;
      flex-wrap: nowrap !important;

      a {
        text-decoration: underline;
      }

      li {
        padding: 0 0 0 1em;

        &:last-of-type {
          padding-right: 1em;
        }
      }
    }
  }
}
