/* 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;
}

/* General */
: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-family: "Noto Sans", sans-serif;
  --font-family-chinese: "Noto Sans SC", sans-serif;
  --font-weight-normal: 400;
  --font-weight-bold: 700;
  --line-height-body: 1.5;

  --line-height-emphasis: 0.8;
  --text-transform-emphasis: uppercase;
  --letter-spacing-emphasis: -0.02em;
  --font-weight-emphasis: 900;
  --font-stretch-emphasis: 62.5%;

  --color-background: #f2f3fb;
  --color-background-dark: #e4e6f6;
  --color-text: #0f1011;
  --color-text-secondary: #44454a;
  --color-added: #53afa1;
  --color-removed: #d58e7c;
  --color-remained: #9e9faa;
  --color-added-light: #a2d6ce;
  --color-removed-light: #e9c3ba;
  --color-remained-light: #c9cbd9;
  --color-added-dark: #428a80;
  --color-removed-dark: #ae6e5d;
  --color-remained-dark: #7d7e87;
}

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

main {
  margin-block: 4rem;
}

/* Layout */
article {
  --min-content-padding: 1rem;
  --max-content-width: 46rem;

  --full-track-size: minmax(var(--min-content-padding), 1fr);
  --content-track-size: min(
    var(--max-content-width),
    100% - var(--min-content-padding) * 2
  );

  display: grid;
  grid-template-columns:
    [full-start]
    var(--full-track-size)
    [content-start]
    var(--content-track-size)
    [content-end]
    var(--full-track-size)
    [full-end];

  > * {
    grid-column: content;
  }

  > .full {
    grid-column: full;
  }

  > * + * {
    margin-block-start: 4rem;
  }
}

.intro,
footer {
  > * + * {
    margin-block-start: 1em;
  }
}

/* Content */
h1 {
  font-size: var(--font-size-8xl);
  line-height: var(--line-height-emphasis);
  text-transform: var(--text-transform-emphasis);
  letter-spacing: var(--letter-spacing-emphasis);
  font-weight: var(--font-weight-emphasis);
  font-stretch: var(--font-stretch-emphasis);
  text-align: end;

  @media (width < 48rem) {
    font-size: var(--font-size-6xl);
  }

  @media (width < 30rem) {
    font-size: var(--font-size-5xl);
  }
}

/* Select */
.vscomp-wrapper {
  color: var(--color-text);
  font-family: var(--font-family);
}

.vscomp-toggle-button {
  border: 1px solid var(--color-text);
  color: var(--color-text);
  background-color: var(--color-background);
}

.vscomp-dropbox {
  border: 1px solid var(--color-text);
  color: var(--color-text);
  background-color: var(--color-background);
}

.vscomp-search-input {
  font-size: 14px;
}

.vscomp-option.focused {
  background-color: var(--color-background-dark);
}

.has-value .vscomp-value,
.vscomp-option-text {
  font-family: var(--font-family-chinese);
  font-weight: var(--font-weight-bold);
  font-size: 16px;
}

.vscomp-option-description {
  color: var(--color-text-secondary);
}

/* Figure */
.figure {
  position: relative;
  display: flex;
  justify-content: center;
}

.entries-wrapper {
  height: 100%;
  display: flex;
  flex-direction: column;

  .entries {
    display: flex;
    flex-wrap: wrap;
    gap: var(--gap);

    &[version="hsk2"] {
      margin-top: auto;
      flex-wrap: wrap-reverse;
    }
  }
}

.label {
  font-size: var(--font-size-md);

  [data-type="name"] {
    line-height: var(--line-height-emphasis);
    text-transform: var(--text-transform-emphasis);
    letter-spacing: var(--letter-spacing-emphasis);
    font-weight: var(--font-weight-emphasis);
    font-stretch: var(--font-stretch-emphasis);

    [data-hierarchy="version"] & {
      font-size: var(--font-size-xl);
    }
  }

  [data-type="count"] {
    font-weight: var(--font-weight-normal);
  }
}

.change-link {
  stroke-opacity: 0.5;

  &.is-highlighted {
    stroke-opacity: 1;
  }
}

.change-rect {
  &[data-change="added"] {
    --color-change: var(--color-added);
    &.is-highlighted {
      --color-change: var(--color-added-dark);
    }
  }
  &[data-change="removed"] {
    --color-change: var(--color-removed);
    &.is-highlighted {
      --color-change: var(--color-removed-dark);
    }
  }
  &[data-change="remained"] {
    --color-change: var(--color-remained);
    &.is-highlighted {
      --color-change: var(--color-remained-dark);
    }
  }

  fill: var(--color-change);
}

.entry {
  &[data-change="added"] {
    --color-change: var(--color-added);
    &:is(.is-highlighted, .is-freezed) {
      --color-change: var(--color-added-dark);
    }
  }
  &[data-change="removed"] {
    --color-change: var(--color-removed);
    &:is(.is-highlighted, .is-freezed) {
      --color-change: var(--color-removed-dark);
    }
  }
  &[data-change="remained"] {
    --color-change: var(--color-remained);
    &:is(.is-highlighted, .is-freezed) {
      --color-change: var(--color-remained-dark);
    }
  }

  background-color: var(--color-change);

  .is-clickable & {
    cursor: pointer;
  }
}

.tooltip {
  pointer-events: none;
  position: absolute;
  top: 0;
  left: 0;
  background-color: var(--color-change);
  border: 1px solid var(--color-change-border);
  font-size: var(--font-size-md);
  padding: 0.5em;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25em;
  opacity: 0;
  visibility: hidden;
  transition:
    opacity 0.2s ease-in-out,
    visibility 0.2s ease-in-out;

  &[data-change="added"] {
    --color-change: var(--color-added-light);
    --color-change-border: var(--color-added-dark);
  }
  &[data-change="removed"] {
    --color-change: var(--color-removed-light);
    --color-change-border: var(--color-removed-dark);
  }
  &[data-change="remained"] {
    --color-change: var(--color-remained-light);
    --color-change-border: var(--color-remained-dark);
  }

  &.is-visible {
    opacity: 1;
    visibility: visible;
  }
}

.count {
  .number {
    font-size: var(--font-size-xl);
  }
}

.level-change {
  display: flex;
  align-items: flex-end;
  gap: 0.25em;
  line-height: 1;

  line-height: var(--line-height-emphasis);
  text-transform: var(--text-transform-emphasis);
  letter-spacing: var(--letter-spacing-emphasis);
  font-weight: var(--font-weight-emphasis);
  font-stretch: var(--font-stretch-emphasis);

  .level {
    display: flex;
    flex-direction: column;
    align-items: center;
    :first-child {
      font-size: var(--font-size-sm);
    }
  }

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

.entry-chars {
  font-family: var(--font-family-chinese);
  font-weight: var(--font-weight-bold);
  font-size: var(--font-size-xl);
  line-height: 1;
}

/* Utilities */
.visually-hidden {
  border: 0;
  clip-path: inset(50%);
  height: 1px;
  margin: 0;
  overflow: hidden;
  position: absolute;
  white-space: nowrap;
  width: 1px;
}
